(()=>{var $=t=>{let o=[];for(;t;){if(t.id){o.unshift(`/*[@id="${t.id}"]`);break}let a=t.parentNode?.childNodes??[],e=1;for(let n=0;n<a.length;n++){let i=a[n];if(i===t){o.unshift(`${t.tagName.toLowerCase()}[${e}]`);break}i.nodeType===1&&i.tagName===t.tagName&&e++}t=t.parentNode}return"/"+o.join("/")},d=$;var B={initialState:{},modifiedXPaths:{}},l=B;var q="https://seonaapi.usestyle.ai/api/v3/plugin-code-changes",U=async()=>{try{let t=await fetch(`${q}?url=${encodeURIComponent(`https://${window.location.hostname}${window.location.pathname}`)}`),{success:o,data:a,error:e}=await t.json();if(!o)throw new Error(e);return a.codeChanges.map(n=>({...n,data:JSON.parse(n.data)}))}catch(t){return console.error(t),[]}},M=U;var K=(t,o)=>{o.innerHTML=t.innerHTML;for(let n of t.attributes)o.setAttribute(n.name,n.value);t.parentElement?.insertBefore(o,t);let a=window.getComputedStyle(t),e=window.getComputedStyle(o);for(let n in a){if(!Object.getOwnPropertyDescriptor(o.style,n)?.writable)return;let r=a[n],s=a.getPropertyValue(r);e.setProperty(r,s)}},y=K;var W=t=>document.evaluate(t,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,m=W;var J=({xpath:t,status:o})=>{let a=o==="REJECTED",{modifiedXPaths:e}=l,n=m(a?e[t]:t);if(!n)return;let i=document.createElement(a?"h1":"h2");if(y(n,i),n.remove(),a){delete e[t];return}e[t]=d(i)},Z=(t,o)=>t.tagName.toLowerCase()==="h1"&&d(t)===o.xpath,H={apply:J,verify:Z};var Y=({xpath:t,data:{tagName:o},status:a})=>{let e=a==="REJECTED",{modifiedXPaths:n}=l,i=m(e?n[t]:t);if(!i)return;let r=document.createElement(e?o:"h1");if(y(i,r),i.remove(),e){delete n[t];return}n[t]=d(r)},Q=(t,o)=>t.tagName.toLowerCase()!=="h1"&&d(t)===o.xpath,w={apply:Y,verify:Q};var tt=({xpath:t,data:o,status:a,id:e})=>{let{alt:n,src:i}=o,{initialState:r}=l,s=m(t);s&&s.src===i&&(a==="REJECTED"&&(n=r[e].alt),r[e]||(r[e]={alt:s.alt}),s.alt=n)},et="alt",x={apply:tt,property:et};var nt=({xpath:t,status:o,id:a,data:e})=>{let{initialState:n}=l,{href:i}=e,r=m(t);if(!r||r.href!==i)return;let s="_blank";o==="REJECTED"&&(s=n[a].target),n[a]||(n[a]={target:r.target}),r.target=s},ot="target",v={apply:nt,property:ot};var rt=({xpath:t,data:o,status:a,id:e})=>{let{title:n,href:i}=o,{initialState:r}=l,s=m(t);s&&s.href===i&&(a==="REJECTED"&&(n=r[e].title),r[e]||(r[e]={title:s.title}),s.title=n)},at="title",S={apply:rt,property:at};var it=({xpath:t,data:o,status:a,id:e})=>{let{content:n}=o,{initialState:i}=l,r=m(t);if(a==="REJECTED"){if(!r)return;if(!i[e]?.content){r.remove();return}n=i[e].content}if(r){i[e]||(i[e]={content:r.content}),r.content=n;return}console.log("Description");let s=document.createElement("meta");s.name="description",s.content=n,document.head.appendChild(s)},st=t=>t.tagName.toLowerCase()==="meta"&&t.name==="description",lt="content",P={apply:it,verify:st,property:lt};var mt=({xpath:t,data:o,status:a,id:e})=>{let{content:n,property:i,name:r}=o,{initialState:s}=l,f=m(t);if(a==="REJECTED"){if(!f)return;if(!s[e]?.content){f.remove();return}n=s[e].content}if(f){s[e]||(s[e]={content:f.content}),f.content=n;return}let E=document.createElement("meta");r&&E.setAttribute("name",r),i&&E.setAttribute("property",i),E.content=n,document.head.appendChild(E)},pt=(t,{data:o})=>{if(t.tagName.toLowerCase()!=="meta")return!1;let{name:a,property:e}=o;return a?t.name===a:t.getAttribute("property")===e},dt="content",R={apply:mt,verify:pt,property:dt};var ct=({xpath:t,data:o,status:a,id:e})=>{let{textContent:n}=o,{initialState:i}=l,r=m(t);if(a==="REJECTED"){if(!r)return;if(!i[e]?.textContent){r.remove();return}({textContent:n}=i[e])}if(r){i[e]||(i[e]={textContent:r.textContent}),r.textContent=n;return}let s=document.createElement("title");s.textContent=n,document.head.appendChild(s)},ft=t=>t.tagName.toLowerCase()==="title",A={apply:ct,verify:ft};var ut=({xpath:t,data:o,status:a,id:e})=>{let{content:n}=o,{initialState:i}=l,r=m(t);if(a==="REJECTED"){if(!r)return;if(!i[e]?.content){r.remove();return}n=i[e].content}if(r){i[e]||(i[e]={content:r.content}),r.content=n;return}let s=document.createElement("meta");s.name="viewport",s.content=n,document.head.appendChild(s)},ht=t=>t.tagName.toLowerCase()==="meta"&&t.name==="viewport",gt="content",b={apply:ut,verify:ht,property:gt};var Ct=({xpath:t,data:o,status:a,id:e})=>{let{href:n}=o,{initialState:i}=l,r=m(t);if(a==="REJECTED"){if(!r)return;if(!i[e]?.href){r.remove();return}n=i[e].href}if(r){i[e]||(i[e]={href:r.href}),r.href=n;return}let s=document.createElement("link");s.rel="canonical",s.href=n,document.head.appendChild(s)},Et=t=>t.tagName.toLowerCase()==="link"&&t.rel==="canonical",yt="href",D={apply:Ct,verify:Et,property:yt};var Tt={H1_DEMOTION:H,H1_PROMOTION:w,ADD_ALT_TAG:x,ADD_LINK_TARGET:v,ADD_LINK_TITLE:S,OPTIMIZE_DESCRIPTION:P,ADD_OG_SITE_TAG:R,OPTIMIZE_TITLE:A,ADD_VIEWPORT_META_TAG:b,ADD_CANONICAL_LINK:D},u=Tt;var hn={ADD_ALT_TAG:"alt",ADD_LINK_TITLE:"title",OPTIMIZE_DESCRIPTION:"content",ADD_OG_SITE_TAG:"content",ADD_VIEWPORT_META_TAG:"content",ADD_CANONICAL_LINK:"href"},h=[],N=null,_=(t,o)=>{if(t instanceof HTMLElement&&["title","h1","h2","h3","h4","h5","h6","meta","link","a","img"].includes(t.tagName.toLowerCase()))for(let a of o){let{verify:e,property:n,apply:i}=u[a.type];(e?e(t,a):d(t)===a.xpath)&&(a.type==="ADD_LINK_TARGET"&&t.target==="_blank"||n&&t[n]===a.data[n]||i(a))}},k=new MutationObserver(t=>{for(let{target:o,addedNodes:a}of t){_(o,h);for(let e of a)_(e,h)}}),L=async()=>{if(window.location.pathname!==N){if(N=window.location.pathname,k?.disconnect(),h){l.initialState={};let t=h.filter(({status:o})=>o!=="REJECTED").map(o=>({...o,status:"REJECTED"}));for(let o of t)u[o.type].apply(o)}h=await M();for(let t of h)u[t.type].apply(t);k?.observe(document,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["alt","property","content","title","target","href"]})}},Mt=history.pushState;history.pushState=function(){Mt.apply(history,arguments),L()};var Ht=history.replaceState;history.replaceState=function(){Ht.apply(history,arguments),L()};var O=L;var T=["https://seona.usestyle.ai","http://localhost:5181"],wt=t=>{for(let o of T)window.top?.postMessage(t,o)},g=wt;var C=null,c=null,j="#b523f9",xt=()=>{let t=document.createElement("div");return t.style.height="24px",t.style.width="24px",t.style.position="fixed",t.style.zIndex="2147483647",t.style.backgroundColor=j,t.style.borderRadius="50%",t.style.pointerEvents="none",t.style.boxShadow="0 0 256px 256px white",t},vt=()=>{let t=document.createElement("div");return t.style.height="24px",t.style.width="24px",t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.borderRadius="50%",t.style.border=`4px solid ${j}`,t.style.boxSizing="border-box",t},X=()=>{if(!C||!c)return;let{left:t,right:o,top:a,bottom:e}=C.getBoundingClientRect(),{left:n,top:i}=c.getBoundingClientRect(),r=t+(o-t)/2-12,s=a+(e-a)/2-12;(n!==r||i!==s)&&(c.style.left=r+"px",c.style.top=s+"px"),requestAnimationFrame(X)},St=t=>{let{modifiedXPaths:o}=l;if(c?.remove(),C=t?m(o[t]??t):null,!C){g("seonajsplugin_not_found");return}let{x:a,y:e,width:n,height:i}=C.getBoundingClientRect();if(a===0&&e===0&&n===0&&i===0){g("seonajsplugin_hidden");return}let r=xt(),s=vt();r.appendChild(s),s.animate([{transform:"scale(1)",opacity:1},{transform:"scale(4)",opacity:0}],{duration:1e3,iterations:4}).addEventListener("finish",()=>{r.remove()}),C.scrollIntoView({behavior:"smooth",inline:"center",block:"center"}),c=r,document.body.append(c),requestAnimationFrame(X)},F=St;var Pt=t=>{u[t.type]?.apply(t)},I=Pt;var Rt={locate:F,update:I},G=Rt;var At=t=>{if(!T.includes(t.origin)||!t.data.type||!t.data.payload)return;let{type:o,payload:a}=t.data;G[o]?.(a)},bt=()=>{window!==window.top&&(window.addEventListener("message",At),g("seonajsplugin"),g({type:"initialize",payload:window.location.href}))},V=bt;var z=async()=>{await O(),V()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",z):z();})();
