@sentientui/snippet 0.24.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.global.js +7 -7
- package/dist/snippet.global.js +2 -2
- package/package.json +2 -2
package/dist/editor.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var
|
|
2
|
-
`)}function
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var ft=Object.defineProperty,Zn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptor,eo=Object.getOwnPropertyDescriptors,to=Object.getOwnPropertyNames,mn=Object.getOwnPropertySymbols;var yn=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var hn=(e,t,r)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,H=(e,t)=>{for(var r in t||(t={}))yn.call(t,r)&&hn(e,r,t[r]);if(mn)for(var r of mn(t))no.call(t,r)&&hn(e,r,t[r]);return e},K=(e,t)=>Zn(e,eo(t));var oo=(e,t)=>{for(var r in t)ft(e,r,{get:t[r],enumerable:!0})},ro=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of to(t))!yn.call(e,c)&&c!==r&&ft(e,c,{get:()=>t[c],enumerable:!(i=Qn(t,c))||i.enumerable});return e};var io=e=>ro(ft({},"__esModule",{value:!0}),e);var jo={};oo(jo,{buildStyleOps:()=>Ft,clearTargetHighlights:()=>We,computeMoveAnchors:()=>vt,deriveSlotId:()=>nt,drawTargetHighlights:()=>Hn,isHex6:()=>wt,mount:()=>On,registerAuditTargets:()=>In,sectionTypesFor:()=>Pn,styleFieldError:()=>zn,toHexColor:()=>xt});function so(e){var r,i,c;let t=(i=(r=e.defaultView)!=null?r:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(c=t==null?void 0:t.pathname)!=null?c:""}function ao(e,t){var r;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let i=((r=e.textContent)!=null?r:"").replace(/\s+/g," ").trim().toLowerCase(),c=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===c||i.startsWith(c)||c.startsWith(i)))return!1}return!0}var lo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function he(e,t){var c;if(e.urlMatch&&!so(t).includes(e.urlMatch))return null;let r=[];if(e.id){let u=t.getElementById(e.id);r=u?[u]:[]}if(r.length===0&&((c=e.dataAttr)!=null&&c.name)&&lo.test(e.dataAttr.name))try{let u=e.dataAttr.value.replace(/["\\]/g,"\\$&");r=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${u}"]`))}catch(u){r=[]}if(r.length===0&&e.selector)try{r=Array.from(t.querySelectorAll(e.selector))}catch(u){r=[]}if(r.length!==1)return null;let i=r[0];return e.fingerprint&&!ao(i,e.fingerprint)?null:i}var Pt="data-sentient-block-arm",S=null;var Ze="data-sentient-blocks-hid",qe={none:"0",sm:"8px",md:"16px",lg:"24px"},zt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},bn={sm:"0.875em",md:"1em",lg:"1.25em"},co={sm:"1.25em",md:"1.5em",lg:"2em"},uo={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},xn={sm:"8px",md:"16px",lg:"32px"},po={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},fo={normal:"400",medium:"500",bold:"700"};function ee(e,t){for(let[r,i]of Object.entries(t))i!==void 0&&e.style.setProperty(r,i);return e}function vn(e){return e==="muted"?S!=null&&S.muted?{color:S.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:S==null?void 0:S.accent}:{}}function kn(e,t){var r,i,c,u,k,T,x,_,P,X,F,M,I,U,Y,Z,N,q,te,V;try{switch(e.type){case"stack":case"grid":{let m=t.createElement("div");if(e.type==="stack"){let j=e;ee(m,{display:"flex","flex-direction":j.direction,gap:(i=qe[(r=j.gap)!=null?r:"md"])!=null?i:qe.md,"align-items":j.align?zt[j.align]:void 0,"justify-content":j.justify?zt[j.justify]:void 0,"flex-wrap":j.wrap?"wrap":void 0})}else{let j=e,oe=(u=qe[(c=j.gap)!=null?c:"md"])!=null?u:qe.md;ee(m,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${j.columns-1} * ${oe}) / ${j.columns})), 1fr))`,gap:oe,"align-items":j.align?zt[j.align]:void 0})}let D=e.type==="stack"&&e.surface==="raised",ne=(k=e.pad)!=null?k:D?"md":void 0;ne&&ee(m,{padding:(T=qe[ne])!=null?T:qe.md}),D&&ee(m,{background:S==null?void 0:S.surface,color:S!=null&&S.surface?S==null?void 0:S.surfaceText:void 0,border:`1px solid ${(x=S==null?void 0:S.border)!=null?x:"currentColor"}`,"border-radius":(_=S==null?void 0:S.radius)!=null?_:"8px"});for(let j of(P=e.children)!=null?P:[]){let oe=kn(j,t);oe&&m.appendChild(oe)}return m}case"text":{let m=t.createElement("p");return m.textContent=e.value,ee(m,K(H({margin:"0","font-size":e.size?bn[e.size]:void 0,"font-weight":e.weight?fo[e.weight]:void 0,"text-align":e.align},vn(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let m=t.createElement(`h${e.level}`);return m.textContent=e.value,ee(m,{margin:"0","font-size":co[(X=e.size)!=null?X:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let m=t.createElement("a");m.textContent=e.label,m.href=e.href,e.tag&&m.setAttribute("data-sentient-tag",e.tag);let D=(F=e.emphasis)!=null?F:"primary";return ee(m,{display:"inline-block",padding:uo[(M=e.size)!=null?M:"md"],"border-radius":(I=S==null?void 0:S.radius)!=null?I:"8px",font:"inherit","font-size":e.size?bn[e.size]:void 0,"text-decoration":D==="ghost"?"underline":"none",cursor:"pointer",background:D==="primary"?(U=S==null?void 0:S.primaryBg)!=null?U:"#111827":"transparent",color:D==="primary"?(Y=S==null?void 0:S.primaryText)!=null?Y:"#ffffff":(Z=S==null?void 0:S.accent)!=null?Z:"inherit",border:D==="secondary"?`1px solid ${(N=S==null?void 0:S.accent)!=null?N:"currentColor"}`:"none"})}case"link":{let m=t.createElement("a");return m.textContent=e.label,m.href=e.href,e.tag&&m.setAttribute("data-sentient-tag",e.tag),ee(m,{color:"inherit","text-decoration":"underline"})}case"image":{let m=t.createElement("img");return m.src=e.src,m.alt=e.alt,ee(m,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?po[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let m=t.createElement("span");return m.textContent=e.value,ee(m,H({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(q=S==null?void 0:S.border)!=null?q:"currentColor"}`},vn(e.tone)))}case"spacer":return ee(t.createElement("div"),{height:(te=xn[e.size])!=null?te:xn.md});case"divider":return ee(t.createElement("hr"),{border:"none","border-top":`1px solid ${(V=S==null?void 0:S.border)!=null?V:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(m){return null}}function wn(e,t,r,i){try{let c=new Set;for(let k of Array.from(e.children)){let T=k.getAttribute(Pt);T!==null&&(t[T]===void 0?k.remove():c.add(T))}for(let[k,T]of Object.entries(t)){if(c.has(k))continue;let x=kn(T,i);if(!x)continue;let _=i.createElement("div");_.setAttribute(Pt,k),_.style.display="none",_.appendChild(x),e.appendChild(_)}let u=r!==void 0&&t[r]!==void 0;for(let k of Array.from(e.children)){let T=k.getAttribute(Pt),x=k;T!==null?x.style.display=u&&T===r?"":"none":u?x.hasAttribute(Ze)||(x.setAttribute(Ze,x.style.display),x.style.display="none"):x.hasAttribute(Ze)&&(x.style.display=x.getAttribute(Ze),x.removeAttribute(Ze))}}catch(c){}}function En(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let r="";for(let i=0;i<e.length;i++){let c=e[i],u=c>="0"&&c<="9";i===0&&u||i===1&&u&&e[0]==="-"?r+=`\\3${c} `:i===0&&c==="-"&&e.length===1?r+="\\-":/[a-zA-Z0-9_-]/.test(c)?r+=c:r+=`\\${c}`}return r}function go(e,t){if(e.id)return`#${En(e.id)}`;let r=[],i=e,c=0;for(;i&&i!==t.body&&i!==t.documentElement&&c<6;){if(i.id){r.unshift(`#${En(i.id)}`);break}let u=i.tagName.toLowerCase(),k=i.parentElement;if(k){let T=Array.from(k.children).filter(x=>x.tagName===i.tagName);T.length>1&&(u+=`:nth-of-type(${T.indexOf(i)+1})`)}r.unshift(u),i=i.parentElement,c++}return r.join(" > ")}function Ue(e,t){var c;let r={v:1};e.id&&(r.id=e.id);for(let u of["data-framer-name","data-w-id","data-sentient-name"]){let k=e.getAttribute(u);if(k){r.dataAttr={name:u,value:k};break}}r.selector=go(e,t);let i=((c=e.textContent)!=null?c:"").trim().replace(/\s+/g," ").slice(0,80);return r.fingerprint=H({tag:e.tagName.toLowerCase()},i?{text:i}:{}),r}function Qe(e,t,r){return he(e,r)===t}var mo="__snt_editor_token";function et(){try{sessionStorage.removeItem(mo)}catch(e){}}var ho=/rgba\([^)]*,\s*0\s*\)$/,yo=/^\d+(\.\d+)?px$/;function Sn(e){var t,r;try{let i=e.defaultView;if(!i||!e.body)return null;let c=i.getComputedStyle(e.body).backgroundColor,u=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),k=new Map;for(let F of Array.from(u).slice(0,300)){let M=F.getBoundingClientRect();if(M.width>0&&(M.width<48||M.height<24))continue;let I=i.getComputedStyle(F),U=I.backgroundColor;if(!U||U==="transparent"||U===c||ho.test(U))continue;let Y=(t=(I.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${U}|${I.color}|${yo.test(Y)?Y:"8px"}`;k.set(Z,((r=k.get(Z))!=null?r:0)+1)}let T=null,x=0;for(let[F,M]of k)M>x&&(T=F,x=M);if(!T)return null;let[_,P,X]=T.split("|");return{primaryBg:_,primaryText:P,radius:X}}catch(i){return null}}var gt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},bo=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function tt(e){var i;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,r;for(;(r=t.exec(e))!==null;)if(!bo.test((i=r[1])!=null?i:""))return!1;return!0}var Tn=/^https:\/\//i,Cn=new Map,we=null;function xo(e){return e.replace(/["\\]/g,"\\$&")}function vo(e){var t;(!we||!we.isConnected)&&(we=e.querySelector("style[data-sentient-ops]"),we||(we=e.createElement("style"),we.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(we))),we.textContent=[...Cn.entries()].map(([r,i])=>`[data-snt-e="${xo(r)}"]{${i}}`).join(`
|
|
2
|
+
`)}function Ln(e,t,r,i){var T;let c=!1,u=(T=t.moveBefore)!=null?T:t.moveAfter;if(u){let x=he(u,i);!x||x===e||x.parentElement!==e.parentElement||!e.parentElement?c=!0:t.moveBefore?e.parentElement.insertBefore(e,x):e.parentElement.insertBefore(e,x.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Tn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Tn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let k=[];if(t.hidden&&k.push("display:none !important"),t.style)for(let[x,_]of Object.entries(t.style)){let P=gt[x];P&&typeof _=="string"&&tt(_)&&k.push(`${P}:${_.trim()} !important`)}return k.length>0&&(e.setAttribute("data-snt-e",r),Cn.set(r,k.join(";")),vo(i)),{anchorMiss:c}}function mt(e){let t=e.steps.length,r=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${r}`}function ht(e,t){return e.steps.map(r=>{var i;return{value:r.step_index,label:`${r.step_index+1}. ${(i=t.get(r.goal_id))!=null?i:r.goal_id}`}})}function Bn(e,t){return e.includes(t)?e.filter(r=>r!==t):[...e,t]}function ko(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function An(e,t){let r=e.trim();return r?t.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:t.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:ko(r),body:{displayName:r.slice(0,128),steps:t.map(i=>({goalId:i}))}}:{ok:!1,error:"Give the funnel a name."}}function $n(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)>>>0;return t.toString(36)}function bt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function nt(e,t,r){var T,x;let i=t.id||((T=t.dataAttr)==null?void 0:T.value)||((x=r.textContent)!=null?x:"").trim()||r.tagName,c=bt(i)||"el",u=$n(JSON.stringify(t));return`${e}-${c}-${u}`.slice(0,128)}var wo="sentient-editor-highlight",Eo="sentient-editor-selection",Ge="sentient-editor-panel",kt="sentient-editor-toast",Ot="sentient-editor-styles",Nt="sentient-editor-target-highlight",So=10,To="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Co="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Rn(){var t;if(document.getElementById(Ot))return;let e=document.createElement("style");e.id=Ot,e.textContent=`
|
|
3
3
|
@keyframes sntedi-in {
|
|
4
4
|
from { opacity: 0; transform: translateY(28px) scale(0.94); }
|
|
5
5
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
|
|
13
13
|
50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
|
|
14
14
|
}
|
|
15
|
-
#${
|
|
15
|
+
#${Ge} {
|
|
16
16
|
animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both,
|
|
17
17
|
sntedi-attn 1.7s ease-in-out 0.42s 3;
|
|
18
18
|
}
|
|
19
|
-
#${
|
|
20
|
-
#${
|
|
19
|
+
#${Ge} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
|
|
20
|
+
#${kt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
|
|
21
21
|
@media (prefers-reduced-motion: reduce) {
|
|
22
|
-
#${
|
|
22
|
+
#${Ge}, #${Ge} .sntedi-dot, #${kt} { animation: none !important; }
|
|
23
23
|
}
|
|
24
|
-
`,((t=document.head)!=null?t:document.documentElement).appendChild(n)}function bn(n){var i,u;vn(),(i=document.getElementById(ht))==null||i.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=ht;let r=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(r,a("div",{},n)),((u=document.body)!=null?u:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function po(){let n=window.__sentientEditor;return n&&typeof n.token=="string"&&typeof n.apiBase=="string"?n:null}async function fo(n){try{let t=await fetch(`${n.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${n.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let r=(await t.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function It(n,t){return A(A(A(A({r:n===401?"expired":"error",status:n},typeof(t==null?void 0:t.error)=="string"?{code:t.error}:{}),typeof(t==null?void 0:t.message)=="string"?{message:t.message}:{}),typeof(t==null?void 0:t.feature)=="string"?{feature:t.feature}:{}),typeof(t==null?void 0:t.plan)=="string"?{plan:t.plan}:{})}async function G(n,t,r){try{let i=await fetch(`${n.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(r)});if(i.ok)return{r:"ok"};let u=await i.json().catch(()=>null);return It(i.status,u)}catch(i){return{r:"error"}}}async function go(n,t){try{let r=await fetch(`${n.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${n.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return It(r.status,i)}catch(r){return{r:"error"}}}async function mo(n,t,r){try{let i=await fetch(`${n.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(r)}),u=await i.json().catch(()=>null);return i.ok?{r:"ok",data:u,outcome:{r:"ok"}}:{r:i.status===401?"expired":"error",data:u,outcome:It(i.status,u)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var Mt=[];function yt(n){return/^#[0-9a-fA-F]{6}$/.test(n)}function gt(n){let t=n.trim();if(yt(t))return t;let r=/^#([0-9a-fA-F]{3})$/.exec(t);if(r)return`#${r[1].split("").map(p=>p+p).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!i)return t;let u=p=>Math.min(255,Number(p)).toString(16).padStart(2,"0");return`#${u(i[1])}${u(i[2])}${u(i[3])}`}var de=null,kn=[];function wn(n){kn=n}async function ho(n){try{let t=await fetch(`${n.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${n.token}`}});if(!t.ok)return[];let r=await t.json();return Mt=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(t){return[]}}async function pt(n,t){try{let r=await fetch(`${n.apiBase}${t}`,{headers:{authorization:`Bearer ${n.token}`}});return r.ok?await r.json():null}catch(r){return null}}function Fe(n=document){for(let t of Array.from(n.querySelectorAll(`.${At}`)))t.remove()}function En(n,t=document){var i;Fe(t);let r=0;for(let u of n){if(r>=lo)break;let p=he(u.locator,t);if(!p)continue;let k=p.getBoundingClientRect(),$=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`,height:`${k.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});$.className=At;let L=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${Math.max(0,k.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},u.label);L.className=At,((i=t.body)!=null?i:t.documentElement).append($,L),r+=1}}function mt(n,t){let r=n.previousElementSibling,i=n.nextElementSibling,u=r?Ne(r,t):null,p=i?Ne(i,t):null;return{prevEl:r,nextEl:i,prevLocator:r&&u&&Ve(u,r,t)?u:null,nextLocator:i&&p&&Ve(p,i,t)?p:null}}var yo=/testimonial|review|quote/i;function Sn(n){let t=[],r=n.headings.length>=1,i=n.links.length>=1;return r&&i&&t.push("hero","cta_band"),n.headings.length>=2&&n.paragraphs.length>=2&&t.push("feature_grid"),n.quotes.length>=1&&t.push("testimonial"),t}var Rt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],bo=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,xo=new Set(["left","center","right","justify","start","end"]),vo=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ko=/^(rgb|rgba|hsl|hsla)\(/i;function wo(n){return vo.test(n)||ko.test(n)}function Tn(n,t){switch(n){case"fontSize":case"borderRadius":return bo.test(t)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(t)||/^\d{1,4}$/.test(t)&&+t>=1&&+t<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return xo.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return wo(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=t.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&r.length>=1&&r.length<=5&&r.every(i=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(i))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Ht(n){let t={},r={};for(let i of Rt){let u=n[i];if(typeof u!="string")continue;let p=u.trim();if(p==="")continue;if(!Je(p)){r[i]="That value isn\u2019t allowed.";continue}let k=Tn(i,p);if(k){r[i]=k;continue}t[i]=p}return{style:t,errors:r}}function a(n,t,r){let i=document.createElement(n);return Object.assign(i.style,t),r!==void 0&&(i.textContent=r),i}function Cn(n){var an;let t=null,r=[],i=null,u=()=>{for(;r.length>0;){let e=r.splice(0,20);try{fetch(`${n.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify({events:e})}).catch(()=>{})}catch(o){}}},p=(e,o)=>{r.push(A({kind:e},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(u,2e3)};window.addEventListener("pagehide",u);let k=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});k.id=so;let $=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});$.id=ao;let L=()=>{if(!t||!t.isConnected){$.style.display="none";return}let e=t.getBoundingClientRect();Object.assign($.style,{display:"block",left:`${e.left-2}px`,top:`${e.top-2}px`,width:`${e.width}px`,height:`${e.height}px`})},D=()=>L();vn();let I=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});I.id=De;let be=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});be.className="sntedi-dot";let V=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});V.append(be,a("span",{},"SentientUI"));let j=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),H=!1,q=a("button",T("#374151"),"Pause selecting");q.onclick=()=>{H=!H,q.textContent=H?"Resume selecting":"Pause selecting",H?(k.style.display="none",Fe(document),h("Selection paused \u2014 browse normally, then resume.")):h("Click any element on the page to adapt it.")};let W=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),P=a("button",T("#6366f1"),"Test different text here"),F=a("button",T("#374151"),"Change style"),ce=a("button",T("#374151"),"Try a different layout for this section"),Y=a("button",T("#374151"),"Track clicks as a goal"),C=a("button",T("#374151"),"Track form submissions as a goal"),Q=a("button",T("#374151"),"Track page visits as a goal"),ue=a("button",T("#374151"),"Track reading this far as a goal"),Pt=a("button",T("#374151"),"Set up a funnel"),je=a("button",T("#374151"),"Attach this test to a funnel step"),xe=a("button",T("#10b981"),"Turn the funnel on"),pe=a("button",T("#374151"),"Move up"),fe=a("button",T("#374151"),"Move down"),Xe=a("button",T("#6366f1"),"Save this arrangement"),Ze=a("button",T("#374151"),"Undo"),Be=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Close editor"),ne=a("button",T("#10b981"),"Publish now \u2014 go live"),oe=a("button",T("#10b981"),"Start tracking now");for(let e of[P,F,ce,Y,pe,fe])e.disabled=!0;let bt=[P,F,ce,Y,C,pe,fe];for(let e of bt)e.style.display="none";Xe.style.display="none",Ze.style.display="none",ne.style.display="none",oe.style.display="none",je.style.display="none",xe.style.display="none";let re=a("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),_e=a("div",{}),Ot=[{id:"text",label:"Text",icon:"\u270F\uFE0F"},{id:"style",label:"Style",icon:"\u{1F3A8}"},{id:"layout",label:"Layout",icon:"\u{1F9F1}"},{id:"goals",label:"Goals",icon:"\u{1F3AF}"},{id:"funnels",label:"Funnels",icon:"\u{1F9ED}"},{id:"drafts",label:"Drafts",icon:"\u{1F5C2}\uFE0F"}],J="text",zt=new Map,ge=new Map,xt=new Map,Nt=a("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Dt=a("div",{paddingTop:"10px"});for(let e of Ot){let o=a("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});o.append(a("span",{fontSize:"11px",marginRight:"3px"},e.icon),a("span",{},e.label)),o.onclick=()=>vt(e.id),zt.set(e.id,o),Nt.append(o);let s=a("div",{display:"none"}),l=a("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(l),xt.set(e.id,l),ge.set(e.id,s),Dt.append(s)}ge.get("text").append(P),ge.get("style").append(F),ge.get("layout").append(ce,pe,fe,Xe,Ze),ge.get("goals").append(Y,C,Q,ue),ge.get("funnels").append(Pt,je,xe);let K=a("div",{});ge.get("drafts").append(K);let Qe=()=>{var o,s;for(let l of Ot){let d=l.id===J,m=zt.get(l.id);m.style.color=d?"#ffffff":"#9ca3af",m.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",ge.get(l.id).style.display=d?"block":"none",xt.get(l.id).style.display="none"}let e=l=>{let d=xt.get(J);d.textContent=l,d.style.display="block"};J==="text"?t?P.disabled?e(P.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=P.onclick)==null||o.call(P,new MouseEvent("click")):e("Click any text on the page to test a different wording."):J==="style"?t?F.disabled?e("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=F.onclick)==null||s.call(F,new MouseEvent("click")):e("Click any element on the page to change how it looks."):J==="layout"?t||e("Click a section to move it or lay it out differently. Layouts re-arrange the words already on the page \u2014 they never add a section you don\u2019t have."):J==="goals"?t||e("Page-level goals work right away; click a button or form to track it specifically."):J==="funnels"?e("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):J==="drafts"&&Ae()},Bn=(e,o,s)=>{e.onclick=()=>{if(e.dataset.armed==="1"){e.dataset.armed="",s();return}e.dataset.armed="1",e.textContent="Sure?",setTimeout(()=>{e.isConnected&&e.dataset.armed==="1"&&(e.dataset.armed="",e.textContent=o)},4e3)}},$e=(e,o)=>a("button",U(A({},T(e)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),Ft=(e,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",e),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},et=(e,o,s)=>{let l=$e("#374151","Discard");return Bn(l,"Discard",async()=>{l.disabled=!0;let d=await go(n,e);l.disabled=!1,X(d,o),d.r==="ok"&&s()}),l},jt=(e,o)=>{ke.textContent="";let s=a("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=a("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...o),s.append(a("div",{marginBottom:"6px"},e),l),ke.append(s)},Ae=async()=>{var g,y,b,x,w,E,S,M,R,te,ae,ze;K.textContent="",K.append(a("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let e=[],o=[],s=null,l=!1;if(await Promise.all([(async()=>{var v;try{let _=await fetch(`${n.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${n.token}`}});_.ok?e=(v=(await _.json()).slots)!=null?v:[]:s=_.status===401?"expired":"error"}catch(_){s="error"}})(),(async()=>{var v;try{let _=await fetch(`${n.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${n.token}`}});_.ok?o=(v=(await _.json()).goals)!=null?v:[]:l=!0}catch(_){l=!0}})()]),J!=="drafts")return;if(K.textContent="",s){if(K.append(a("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},s==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),s==="error"){let v=$e("#374151","Retry");v.onclick=()=>{Ae()},K.append(v)}return}let d=e.filter(v=>{var _,z,le,me,Le,Ye;return((le=(z=(_=v.draft_config)==null?void 0:_.arms)==null?void 0:z.length)!=null?le:0)>0||((Ye=(Le=(me=v.published_config)==null?void 0:me.arms)==null?void 0:Le.length)!=null?Ye:0)>0}),m=o.filter(v=>v.event!=="custom"&&(v.status==="draft"||v.status==="active"));if(d.length===0&&m.length===0&&!l){K.append(a("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let f=v=>a("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:v?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:v?"#6ee7b7":"#c7d2fe"},v?"live":"draft"),c=v=>{let _=a("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),z=a("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},v);return _.append(z),{row:_,name:z}};for(let v of d){let{row:_}=c((g=v.display_name)!=null?g:v.slot_id);_.append(f(v.status==="published"));let z=(w=(x=(y=v.draft_config)==null?void 0:y.arms)!=null?x:(b=v.published_config)==null?void 0:b.arms)!=null?w:[],le=(M=(E=z[1])==null?void 0:E.id)!=null?M:(S=z[0])==null?void 0:S.id,me=$e("#374151","Preview");if(me.onclick=()=>Ft(v.slot_id,le),_.append(me),v.status!=="published"&&((ae=(te=(R=v.draft_config)==null?void 0:R.arms)==null?void 0:te.length)!=null?ae:0)>0){let Le=$e("#10b981","Publish");Le.onclick=async()=>{Le.disabled=!0;let Ye=await G(n,`/v1/editor/slots/${encodeURIComponent(v.slot_id)}/publish`,{});Le.disabled=!1,X(Ye,"\u2713 Published \u2014 live for new visitors."),Ye.r==="ok"&&(p("published",{kind:"slot"}),Ae())},_.append(Le)}v.status!=="published"&&_.append(et(`/v1/editor/slots/${encodeURIComponent(v.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Kt(v.slot_id),Ae()})),K.append(_)}if(l)K.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(m.length>0){K.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let v of m){let{row:_}=c((ze=v.display_name)!=null?ze:v.goal_id);if(_.append(f(v.status==="active")),v.status==="draft"){let z=$e("#10b981","Start tracking");z.onclick=async()=>{z.disabled=!0;let le=await G(n,`/v1/editor/goals/${encodeURIComponent(v.goal_id)}/publish`,{});z.disabled=!1,X(le,"\u2713 Tracking is live \u2014 it counts from your next visitor."),le.r==="ok"&&(p("published",{kind:"goal"}),Ae())},_.append(z,et(`/v1/editor/goals/${encodeURIComponent(v.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Xt(v.goal_id),Ae()}))}K.append(_)}}},vt=e=>{J!==e&&(O(),Ge(),J=e,Qe())},qt=a("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(V.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Ut=!1,ve=a("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"46px",height:"46px",borderRadius:"50%",border:"1px solid rgba(99,102,241,0.55)",background:"#111827",color:"#fff",cursor:"pointer",display:"none",alignItems:"center",justifyContent:"center",gap:"4px",font:"700 15px system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"}),Gt=a("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});Gt.className="sntedi-dot",ve.append(Gt,a("span",{},"S")),ve.title="Open the SentientUI editor";let Wt=a("button",{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",color:"#fff",border:"none",cursor:"pointer",whiteSpace:"nowrap"},"Minimize");Wt.onclick=()=>{I.style.display="none",ve.style.display="flex",Ut=H,H=!0,k.style.display="none",Fe(document)},ve.onclick=()=>{I.style.display="block",ve.style.display="none",H=Ut},Object.assign(q.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(Be.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),qt.append(V,q,Wt,Be);let Yt=a("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),ke=a("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Yt.append(ke,Z,ne,oe);let ie=a("button",{display:"none",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u2728 Ask AI"),kt=a("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(W.style,{flex:"1 1 auto",marginBottom:"0"}),kt.append(W,ie),Object.assign(kt.style,{marginBottom:"6px"});let se=a("div",{}),B=a("div",{marginTop:"4px"});B.addEventListener("input",()=>{Me=!0}),B.addEventListener("change",()=>{Me=!0}),I.append(qt,j,kt,re,_e,se,Nt,Dt,B,Yt),((an=document.body)!=null?an:document.documentElement).append(k,$,I,ve);let we=null,Vt=()=>{we==null||we(),we=null},Jt=()=>{we=null},Me=!1,wt=null,O=()=>{Vt(),B.textContent="",Me=!1,wt=null,_t=!1},qe=(e,o,s)=>{var y;O();let l={},d={},m={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let b of e){let x=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},b.label);if(B.append(x),b.type==="select"){let E=a("select",m);E.setAttribute("data-field",b.key);let S=document.createElement("option");S.value="",S.textContent="\u2014 no change \u2014",E.append(S);for(let M of(y=b.options)!=null?y:[]){let R=document.createElement("option");R.value=M,R.textContent=M,E.append(R)}l[b.key]=()=>E.value,B.append(E)}else if(b.type==="color"){let E=a("input",U(A({},m),{padding:"2px",height:"34px"}));E.type="color",E.setAttribute("data-field",b.key);let S=!1;E.addEventListener("input",()=>{S=!0}),l[b.key]=()=>S?E.value:"",B.append(E)}else{let E=a("input",m);E.setAttribute("data-field",b.key),b.value!==void 0&&(E.value=b.value),l[b.key]=()=>E.value,B.append(E)}let w=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});w.setAttribute("data-feedback",b.key),d[b.key]=w,B.append(w)}let f=(b,x)=>{let w=d[b];w&&(w.textContent=x!=null?x:"",w.style.display=x?"block":"none")},c=a("button",T("#6366f1"),o),g=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");c.onclick=()=>s(Object.fromEntries(Object.entries(l).map(([b,x])=>[b,x()])),f),g.onclick=O,B.append(c,g)},h=(e,o=!0)=>{Z.textContent=e,Z.style.color=o?"#a7f3d0":"#fca5a5"},Et=(e,o)=>{var l,d;if(p("error_shown",{code:(d=e.code)!=null?d:`http_${(l=e.status)!=null?l:"network"}`}),e.code==="plan_limit_reached"){let m=e.feature==="live_goals"?"live goal":"of these",f=e.plan?`${e.plan} plan`:"plan";return e.feature==="live_goals"?`Your ${f} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${f} has reached its limit for ${m}. Manage them in your dashboard, or upgrade for more.`}if(e.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(e.code==="demo_read_only"&&e.message)return e.message;let s=e.status?` (HTTP ${e.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},X=(e,o)=>{e.r==="ok"?h(o,!0):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):h(Et(e,"save"),!1)},Ee=null,tt=e=>e.length>30?`${e.slice(0,27)}\u2026`:e,Kt=e=>{Ee===e&&(Ee=null,ne.style.display="none",je.style.display="none",ke.textContent="")},Xt=e=>{Oe===e&&(Oe=null,oe.style.display="none",ke.textContent="")},nt=(e,o,s)=>{Ee=e,ne.textContent=o?`Publish \u201C${tt(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",ne.style.display="block",je.style.display="block";let l=[];if(s){let d=$e("#374151","Preview");d.onclick=()=>Ft(e,s),l.push(d)}l.push(et(`/v1/editor/slots/${encodeURIComponent(e)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Kt(e))),jt(o?`Draft saved for \u201C${tt(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ne.onclick=async()=>{if(!Ee)return;ne.disabled=!0,h("Publishing\u2026");let e=await G(n,`/v1/editor/slots/${encodeURIComponent(Ee)}/publish`,{});ne.disabled=!1,e.r==="ok"?(p("published",{kind:"slot"}),h("\u2713 Published \u2014 live for new visitors.",!0),ne.style.display="none",Ee=null,ke.textContent=""):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):h(Et(e,"publish"),!1)};let N=null,Re=!1,He=null,Ie=null,ee=null,Se=null,Ue=null,ot=null,Te=!1,Zt=(e,o)=>Re?e?"":`Nothing to swap with ${o} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Qt=()=>{pe.disabled=!Re||!ee,fe.disabled=!Re||!Se,pe.title=pe.disabled?Zt(ee,"above"):"",fe.title=fe.disabled?Zt(Se,"below"):""},St=e=>{Xe.style.display=e?"block":"none",Ze.style.display=e?"block":"none",Qt()},Ge=()=>{if(Te&&t&&Ue&&Ue.insertBefore(t,ot),Te=!1,Ue=null,ot=null,t){let e=mt(t,document);He=e.prevEl,Ie=e.nextEl,ee=e.prevLocator,Se=e.nextLocator}L(),St(!1)},en=e=>{if(H)return;let o=e.target;if(!o||I.contains(o)||o===k)return;Fe(document);let s=o.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},Ce=e=>{var s;let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:e.tagName.toLowerCase()},_n=e=>!!e.id||["section","header","footer","nav","main","form","article","aside"].includes(e.tagName.toLowerCase())||!!e.querySelector(":scope > h1, :scope > h2, :scope > h3"),$n=e=>{var l;let o=e.querySelector("h1, h2, h3"),s=(l=o==null?void 0:o.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:e.id?`#${e.id.length>24?`${e.id.slice(0,21)}\u2026`:e.id}`:`<${e.tagName.toLowerCase()}>`},An=e=>{re.textContent="";let o=[];for(let f=e.parentElement;f&&f!==document.body&&o.length<3;f=f.parentElement)_n(f)&&o.push(f);let s=Ce(e),l=()=>a("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let f of o){let c=$n(f);if(c===s||s.startsWith(c))continue;let g=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},c);g.onclick=()=>rt(f),d||re.append(l()),re.append(g),d=!1}d||re.append(l());let m=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");m.onclick=()=>tn(),re.append(m),re.style.display="block"},Mn=e=>{_e.textContent="";let o=null,s=0;for(let d=e.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(Ve(Ne(d,document),d,document)){o=d;break}let l=a("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(o){let d=o;l.append(a("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let m=a("button",U(A({},T("#6366f1")),{marginTop:"0"}),`Select \u201C${Ce(d)}\u201D instead`);m.onclick=()=>rt(d);let f=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Pick something else");f.onclick=()=>{_e.textContent=""},l.append(m,f)}else l.append(a("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));_e.append(l)},rt=e=>{Ge(),O(),_e.textContent="",t=e,N=Ne(e,document);let o=Ve(N,e,document);Re=o,L(),W.style.display="block",W.textContent=`Selected: ${Ce(e)}`,An(e),p("element_selected",{unique:o}),h(o?"\u2713 Matches exactly 1 element":"",o),o||Mn(e),j.style.display="none",ie.style.display="inline-block",se.textContent="";for(let m of bt)m.style.display="block";P.style.display="none",F.style.display="none";let s=e.childElementCount===0;P.disabled=!o||!s,P.title=o?s?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",F.disabled=!o,ce.disabled=!o,Y.disabled=!o;let l=e.closest("form");C.style.display=l?"block":"none",C.disabled=!l;let d=mt(e,document);He=d.prevEl,Ie=d.nextEl,ee=d.prevLocator,Se=d.nextLocator,Qt(),Qe()},tn=()=>{Ge(),O(),t=null,N=null,Re=!1,He=null,Ie=null,ee=null,Se=null,L(),_e.textContent="",se.textContent="",re.textContent="",re.style.display="none",W.textContent="",W.style.display="none",ie.style.display="none";for(let e of bt)e.style.display="none";j.style.display="block",h(""),Qe()},Pe=!1,Tt=-1,nn=e=>{var l,d;let o=e.target,s=!!((l=o==null?void 0:o.closest)!=null&&l.call(o,'input, textarea, select, [contenteditable="true"]'));if(e.key==="Escape"){if(B.childElementCount>0){O(),Pe=!1;return}if(t){tn(),Pe=!1;return}if(!Pe){Pe=!0,h("Press Esc again to close the editor.");return}Pe=!1,(d=Be.onclick)==null||d.call(Be,new MouseEvent("click"));return}if(Pe=!1,!(s||H)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){if(!t||(e.key==="ArrowUp"?pe:fe).disabled)return;e.preventDefault(),Bt(e.key==="ArrowUp"?"up":"down");return}if(e.key==="Tab"){let m=[];for(let c of kn){let g=he(c.locator,document);g&&!m.includes(g)&&m.push(g)}if(m.length===0)return;if(Me){h("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),e.preventDefault();return}e.preventDefault(),Tt=(Tt+(e.shiftKey?-1:1)+m.length)%m.length;let f=m[Tt];rt(f);try{f.scrollIntoView({block:"center",behavior:"smooth"})}catch(c){}}}},on=e=>{if(H)return;let o=e.target;if(!(!o||I.contains(o))){if(e.preventDefault(),e.stopPropagation(),Me&&o!==t&&wt!==o){wt=o,h("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}rt(o)}};P.onclick=()=>{var m,f,c;if(!t||!N)return;p("form_opened",{kind:"text"});let e=N,o=(f=(m=t.textContent)==null?void 0:m.trim())!=null?f:"";qe([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async g=>{let y=g.alt.trim();if(!y){h("\u26A0 Enter alternative wording to test.",!1);return}if(y===g.current.trim()){h("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let b=Ke("text",e,t);h("Saving\u2026");let x=await G(n,`/v1/editor/slots/${encodeURIComponent(b)}`,{kind:"arms",target:e,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:g.current}},{id:"b",displayName:"Alternative",ops:{text:g.alt}}]}});x.r==="ok"&&(p("draft_saved",{kind:"slot"}),Jt(),O(),nt(b,Ce(t),"b")),X(x,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let s=t,l=(c=s.textContent)!=null?c:"";we=()=>{s.textContent=l};let d=B.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?l:d.value})};let We=null,rn=e=>{let o=c=>{var g;return((g=c.textContent)!=null?g:"").replace(/\s+/g," ").trim()},s=Array.from(e.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let c=e.closest("h1,h2,h3,h4");c&&s.push(o(c))}let l=Array.from(e.querySelectorAll("p")).map(o).filter(c=>c.length>0&&c.length<=300),d=[];for(let c of Array.from(e.querySelectorAll("a[href], button"))){let g=o(c);if(!g||g.length>60)continue;let y="",b=c.getAttribute("href");if(b)try{let x=new URL(b,window.location.href);x.protocol==="https:"&&(y=x.href)}catch(x){}d.push({label:g,href:y})}let m=Array.from(e.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(m.length===0&&yo.test(`${e.className} ${e.id}`))for(let c of l)c.length>=20&&m.push(c);let f=Array.from(e.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(c=>c.length>0&&c.length<=80);return{headings:s,paragraphs:l,links:d,quotes:m,attributions:f}},Rn=(e,o)=>{var l,d,m,f,c,g,y,b,x,w,E,S,M,R,te,ae,ze,v,_,z;let s=le=>{var me;return o.paragraphs.length>=3&&(me=o.paragraphs[o.paragraphs.length-3+le])!=null?me:""};switch(e){case"headline":return(l=o.headings[0])!=null?l:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(f=(m=o.links[0])==null?void 0:m.label)!=null?f:"";case"cta_href":return(g=(c=o.links[0])==null?void 0:c.href)!=null?g:"";case"secondary_label":return(b=(y=o.links[1])==null?void 0:y.label)!=null?b:"";case"secondary_href":return(w=(x=o.links[1])==null?void 0:x.href)!=null?w:"";case"quote":case"q1":return(E=o.quotes[0])!=null?E:"";case"q2":return(S=o.quotes[1])!=null?S:"";case"q3":return(M=o.quotes[2])!=null?M:"";case"name":case"n1":return(R=o.attributions[0])!=null?R:"";case"n2":return(te=o.attributions[1])!=null?te:"";case"n3":return(ae=o.attributions[2])!=null?ae:"";case"role":return(ze=o.attributions[1])!=null?ze:"";case"eyebrow":return"";case"f1_title":return(v=o.headings[1])!=null?v:"";case"f2_title":return(_=o.headings[2])!=null?_:"";case"f3_title":return(z=o.headings[3])!=null?z:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},Hn=(e,o,s)=>{p("form_opened",{kind:"arrangement"});let l=rn(s);qe(e.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:Rn(d.id,l)})),"Save draft",async(d,m)=>{var x,w,E,S,M;let f=!1,c=!1;for(let R of e.fields){if(R.kind==="href"){let ae=!1;try{ae=new URL((x=d[R.id])!=null?x:"").protocol==="https:"}catch(ze){}m(R.id,ae?null:"Links need to start with https://"),ae||(f=!0);continue}let te=((w=d[R.id])!=null?w:"").trim()==="";m(R.id,te?"Fill this in with your own words":null),te&&(c=!0)}if(f){h("\u26A0 Fix the highlighted link(s).",!1);return}if(c){h("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}h("Saving\u2026");let g=await mo(n,`/v1/editor/arrangements/${encodeURIComponent(e.id)}/instantiate`,{fields:d});if(g.r!=="ok"||!((E=g.data)!=null&&E.blocks)){g.r==="expired"?X(g.outcome,""):h(`\u26A0 ${(M=(S=g.data)==null?void 0:S.reason)!=null?M:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let y=Ke("arrange",o,s),b=await G(n,`/v1/editor/slots/${encodeURIComponent(y)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:e.id,displayName:e.name,blocks:g.data.blocks}],baseline:"original"}});b.r==="ok"&&(p("draft_saved",{kind:"arrangement"}),O(),nt(y,e.name,e.id)),X(b,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")})};ce.onclick=async()=>{var m,f;if(!t||!N)return;let e=N,o=t;if(O(),h("Loading arrangements\u2026"),!We){let c=await pt(n,"/v1/editor/arrangements");We=(m=c==null?void 0:c.arrangements)!=null?m:null}if(!We||We.length===0){h("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=Sn(rn(o)),l=We.filter(c=>s.includes(c.sectionType));if(l.length===0){h("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}h("Pick a layout for this section \u2014 your own words are carried across.");for(let c of l){let g=a("button",U(A({},T("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},c.name),a("div",{fontSize:"11px",opacity:"0.7"},c.description)),g.onclick=()=>Hn(c,e,o),B.append(g)}let d=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=O,B.append(d),(f=B.scrollIntoView)==null||f.call(B,{block:"nearest"})};let Oe=null,In=(e,o)=>{Oe=e,oe.textContent=o?`Start tracking \u201C${tt(o)}\u201D now`:"Start tracking now",oe.style.display="block",jt(o?`Goal \u201C${tt(o)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[et(`/v1/editor/goals/${encodeURIComponent(e)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Xt(e))])};oe.onclick=async()=>{if(!Oe)return;oe.disabled=!0,h("Activating\u2026");let e=await G(n,`/v1/editor/goals/${encodeURIComponent(Oe)}/publish`,{});oe.disabled=!1,e.r==="ok"?(p("published",{kind:"goal"}),h("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),oe.style.display="none",Oe=null,ke.textContent=""):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):h(Et(e,"activate"),!1)};let Ct=(e,o)=>`${ft(e)||"goal"}-${xn(o)}`.slice(0,128),Pn=e=>{var l,d,m;let o=((l=e.textContent)!=null?l:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((m=(d=e.getAttribute("aria-label"))!=null?d:e.getAttribute("id"))!=null?m:"").trim()||"element-clicked"},it=async(e,o,s)=>{h("Saving\u2026");let l=await G(n,`/v1/editor/goals/${encodeURIComponent(e)}`,o);l.r==="ok"&&(p("draft_saved",{kind:"goal"}),In(e,s)),X(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live.")};Y.onclick=()=>{if(!t||!N)return;let e=Ct(Pn(t),JSON.stringify(N));it(e,{event:"click",locator:N},Ce(t))},C.onclick=()=>{var l,d;let e=t==null?void 0:t.closest("form");if(!e)return;let o=Ne(e,document),s=(d=(l=e.getAttribute("id"))!=null?l:e.getAttribute("name"))!=null?d:"form-submitted";it(Ct(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},Q.onclick=()=>{let e=window.location.pathname||"/",o=ft(e)?`reached-${ft(e)}`:"page-visited";it(Ct(o,e),{event:"url_reached",urlPattern:e},e)};let Lt=[{label:"25% \u2014 skimmed the top",value:.25},{label:"50% \u2014 read halfway",value:.5},{label:"75% \u2014 read most of the page",value:.75},{label:"90% \u2014 read to the end",value:.9}];ue.onclick=()=>{qe([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Lt.map(e=>e.label)}],"Track it",e=>{var l;let o=(l=Lt.find(d=>d.label===e.depth))!=null?l:Lt[2],s=Math.round(o.value*100);it(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),O()})};let st=null,On=e=>{st=e,xe.style.display="block"};xe.onclick=async()=>{if(!st)return;xe.disabled=!0,h("Turning on\u2026");let e=await G(n,`/v1/editor/funnels/${encodeURIComponent(st)}/publish`,{});xe.disabled=!1,e.r==="ok"?(p("published",{kind:"funnel"}),h("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),xe.style.display="none",st=null):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):h("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},Pt.onclick=async()=>{var b;h("Loading your goals\u2026");let e=await pt(n,"/v1/editor/goals"),o=(b=e==null?void 0:e.goals)!=null?b:[];if(o.length<2){h("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}h("Pick the steps in order \u2014 first click = first step."),O();let s=[],l=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});B.append(l,d);let m=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");B.append(m);let f=new Map,c=()=>{var x,w;for(let[E,S]of f){let M=s.indexOf(E),R=(w=(x=o.find(te=>te.goal_id===E))==null?void 0:x.display_name)!=null?w:E;S.textContent=M===-1?R:`${M+1}. ${R}`,S.style.background=M===-1?"#374151":"#6366f1"}};for(let x of o){let w=a("button",U(A({},T("#374151")),{textAlign:"left"}));f.set(x.goal_id,w),w.onclick=()=>{s=hn(s,x.goal_id),c()},B.append(w)}c();let g=a("button",T("#6366f1"),"Save funnel"),y=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");y.onclick=O,g.onclick=async()=>{let x=yn(d.value,s);if(!x.ok){h(`\u26A0 ${x.error}`,!1);return}h("Saving\u2026");let w=await G(n,`/v1/editor/funnels/${encodeURIComponent(x.funnelId)}`,x.body);w.r==="ok"&&(p("draft_saved",{kind:"funnel"}),O(),On(x.funnelId)),X(w,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},B.append(g,y)},je.onclick=async()=>{var c,g;let e=Ee;if(!e)return;h("Loading funnels\u2026");let o=await pt(n,"/v1/editor/funnels"),s=(c=o==null?void 0:o.funnels)!=null?c:[];if(s.length===0){h("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await pt(n,"/v1/editor/goals"),d=new Map(((g=l==null?void 0:l.goals)!=null?g:[]).map(y=>[y.goal_id,y.display_name]));qe([{key:"funnel",label:"Funnel",type:"select",options:s.map(y=>ct(y))},{key:"step",label:"Which step does this element serve?",type:"select",options:ut(s[0],d).map(y=>y.label)}],"Attach",async y=>{var E;let b=(E=s.find(S=>ct(S)===y.funnel))!=null?E:s[0],x=ut(b,d).findIndex(S=>S.label===y.step);if(x<0){h("\u26A0 Pick which step this element serves.",!1);return}h("Attaching\u2026");let w=await G(n,`/v1/editor/funnels/${encodeURIComponent(b.funnel_id)}/assign`,{slotId:e,stepIndex:x});w.r==="ok"&&O(),X(w,`\u2713 Attached \u2014 this test now works toward \u201C${b.display_name}\u201D.`)});let m=B.querySelector('select[data-field="funnel"]'),f=B.querySelector('select[data-field="step"]');m&&f&&m.addEventListener("change",()=>{var b;let y=(b=s.find(x=>ct(x)===m.value))!=null?b:s[0];f.length=1;for(let x of ut(y,d)){let w=document.createElement("option");w.value=x.label,w.textContent=x.label,f.append(w)}})},F.onclick=()=>{if(!t||!N)return;p("form_opened",{kind:"style"});let e=N;qe([{key:"color",label:"Text colour",type:"color"},{key:"background",label:"Background colour",type:"color"},{key:"fontSize",label:"Font size (e.g. 20px)"},{key:"fontWeight",label:"Font weight (e.g. 700)"},{key:"fontFamily",label:Mt.length?`Font (this site has: ${Mt.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(f,c)=>{var E;let{style:g,errors:y}=Ht(f),b=!1;for(let S of Rt)c(S,(E=y[S])!=null?E:null),y[S]&&(b=!0);if(b){h("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(g).length===0){h("\u26A0 Enter at least one style change.",!1);return}let x=Ke("style",e,t);h("Saving\u2026");let w=await G(n,`/v1/editor/slots/${encodeURIComponent(x)}`,{kind:"arms",target:e,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:g}}]}});w.r==="ok"&&(p("draft_saved",{kind:"slot"}),Jt(),O(),nt(x,Ce(t),"b")),X(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let o=t,s=o.style.cssText;we=()=>{o.style.cssText=s};let l={},d=()=>{let{style:f}=Ht(l);o.style.cssText=s;for(let[c,g]of Object.entries(f)){let y=dt[c];y&&Je(g)&&o.style.setProperty(y,g.trim(),"important")}};for(let f of Rt){let c=B.querySelector(`[data-field="${f}"]`);if(!c)continue;let g=()=>{l[f]=c.value,d()};c.addEventListener("input",g),c.addEventListener("change",g)}let m=[de==null?void 0:de.primaryBg,de==null?void 0:de.primaryText,"#ffffff"].filter(f=>!!f).map(gt).filter((f,c,g)=>yt(f)&&g.indexOf(f)===c);for(let f of["color","background"]){let c=B.querySelector(`input[data-field="${f}"]`);if(!c)continue;let g=a("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let y of m){let b=a("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:y,padding:"0"});b.title=y,b.onclick=()=>{c.value=gt(y),c.dispatchEvent(new Event("input"))},g.append(b)}c.after(g)}};let sn=e=>{var l;let o=e==="text"?P:F;if(o.disabled)return h(o.title||"This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section.",!1),!1;vt(e);let s=e==="text"?'[data-field="alt"]':'[data-field="color"]';return B.querySelector(s)||(l=o.onclick)==null||l.call(o,new MouseEvent("click")),!0},zn=()=>{if(!t)return;se.textContent="";let e=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"}),o=a("input",{width:"100%",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"});o.type="text",o.maxLength=300,o.placeholder="e.g. shorter and more urgent",o.setAttribute("data-field","ai-instruction");let s=a("button",U(A({},T("#6366f1")),{display:"inline-block",width:"auto",margin:"8px 0 0",padding:"4px 10px",fontSize:"11px"}),"Go");s.setAttribute("data-action","ai-go"),s.onclick=()=>{Nn(o.value.trim())},o.onkeydown=l=>{var d;l.key==="Enter"&&(l.preventDefault(),(d=s.onclick)==null||d.call(s,new MouseEvent("click")))},e.append(a("div",{fontWeight:"600",marginBottom:"4px"},"What should this element do differently?"),o,a("div",{opacity:"0.7",fontSize:"11px",marginTop:"4px"},"Leave it blank for ideas. Nothing goes live \u2014 you review and save whatever comes back."),s),se.append(e),o.focus()};ie.onclick=()=>zn();let Nn=async e=>{var c,g;if(!t)return;let o=t;ie.disabled=!0;let s=ie.textContent;ie.textContent="Thinking\u2026",se.textContent="",p("form_opened",{kind:"suggest"});let l={},d=null;try{let y=await fetch(`${n.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(A(A({element:{tag:o.tagName.toLowerCase(),text:((c=o.textContent)!=null?c:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},e?{instruction:e.slice(0,300)}:{}),de?{palette:de}:{}))});y.ok?l=await y.json():d=y.status===401?"expired":"error"}catch(y){d="error"}if(ie.disabled=!1,ie.textContent=s,t!==o)return;if(d){h(d==="expired"?"Editor session expired \u2014 reopen it from your dashboard to keep editing.":"\u26A0 Couldn\u2019t get suggestions \u2014 check your connection and try again.",!1);return}if(l.locked){h("AI suggestions aren\u2019t included in this plan.",!1);return}if(l.exhausted){h("You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.",!1);return}let m=(g=l.suggestions)!=null?g:[];if(m.length===0){h(e?"Couldn\u2019t do that safely on this element \u2014 try asking for a smaller change, or pick a headline or a button.":"No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let f=(y,b)=>{let x=B.querySelector(`[data-field="${y}"]`);x&&(x.value=b,x.dispatchEvent(new Event("input")))};for(let y of m){let b=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",fontSize:"12px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"});b.append(a("div",{fontWeight:"600",marginBottom:"2px"},y.title),a("div",{opacity:"0.75",marginBottom:"6px"},y.reason));let x=a("button",U(A({},T("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");x.onclick=()=>{var w,E;if(t!==o){se.textContent="";return}if(se.textContent="",y.kind==="text"){if(!sn("text"))return;f("alt",y.variant)}else if(y.kind==="style"){if(!sn("style"))return;for(let[S,M]of Object.entries(y.style))if(S==="color"||S==="background"){let R=gt(M);yt(R)&&f(S,R)}else S==="textAlign"?f(S,M==="start"?"left":M==="end"?"right":M):f(S,M)}else{let S=y.goalType==="form_submit"&&!C.disabled;if(!S&&Y.disabled){h("This element can\u2019t be tracked reliably \u2014 select a specific button or link instead.",!1);return}vt("goals"),S?(w=C.onclick)==null||w.call(C,new MouseEvent("click")):(E=Y.onclick)==null||E.call(Y,new MouseEvent("click"))}},b.append(x),se.append(b)}},Bt=e=>{if(!t)return;let o=t.parentElement;if(!o)return;Te||(Ue=o,ot=t.nextSibling,Te=!0),e==="up"&&He?o.insertBefore(t,He):e==="down"&&Ie&&o.insertBefore(t,Ie.nextSibling);let s=mt(t,document);He=s.prevEl,Ie=s.nextEl,ee=s.prevLocator,Se=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}L(),St(!0),h("Previewing the new position \u2014 keep moving, save, or undo.")};pe.onclick=()=>Bt("up"),fe.onclick=()=>Bt("down"),Ze.onclick=()=>{Ge(),h("Move undone \u2014 back to the original position.")},Xe.onclick=async()=>{if(!t||!N||!Te||!Re)return;let e=ee?"moveAfter":"moveBefore",o=ee!=null?ee:Se;if(!o){h("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=Ke("move",N,t);h("Saving\u2026");let l=await G(n,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:N,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[e]:o}}]}});l.r==="ok"&&(p("draft_saved",{kind:"move"}),Te=!1,Ue=null,ot=null,St(!1),nt(s,Ce(t),"b")),X(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let Dn=()=>{var e,o;p("editor_closed"),u(),window.removeEventListener("pagehide",u),i&&clearTimeout(i),Ge(),Vt(),document.removeEventListener("mousemove",en,!0),document.removeEventListener("click",on,!0),document.removeEventListener("keydown",nn,!0),window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D),Fe(document),(e=document.getElementById($t))==null||e.remove(),k.remove(),$.remove(),I.remove(),ve.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),lt()},_t=!1;Be.onclick=()=>{if((Me||Te)&&!_t){_t=!0,h("\u26A0 Unsaved changes \u2014 click \u201CClose editor\u201D again to discard them.",!1);return}Dn()},document.addEventListener("mousemove",en,!0),document.addEventListener("click",on,!0),document.addEventListener("keydown",nn,!0),window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),Qe(),p("editor_opened")}function T(n){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:n,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var Ln="sentient-preview-bar";async function Eo(n,t){var I,be,V,j,H,q,W,Z,P,F,ce,Y;try{fetch(`${n.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(C){}let r=null;try{let C=await fetch(`${n.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${n.token}`}});C.ok&&(r=(be=((I=(await C.json()).slots)!=null?I:[]).find(ue=>ue.slot_id===t&&ue.kind==="arms"))!=null?be:null)}catch(C){}let i=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Ln;let u=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");u.onclick=()=>{lt();let C=new URL(location.href);for(let Q of["sentient_editor","sentient_preview","sentient_arm"])C.searchParams.delete(Q);location.assign(C.toString())};let p=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");p.onclick=()=>{let C=new URL(location.href);for(let Q of["sentient_preview","sentient_arm"])C.searchParams.delete(Q);location.assign(C.toString())};let k=(q=(H=(V=r==null?void 0:r.draft_config)==null?void 0:V.arms)!=null?H:(j=r==null?void 0:r.published_config)==null?void 0:j.arms)!=null?q:[];if(!r||k.length===0){i.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),p,u),((W=document.body)!=null?W:document.documentElement).append(i);return}let $=new URLSearchParams(location.search).get("sentient_arm"),L=(P=(Z=k.find(C=>C.id===$))!=null?Z:k[1])!=null?P:k[0];i.append(a("span",{fontWeight:"700"},`Previewing: ${(F=r.display_name)!=null?F:r.slot_id}`));let D=r.target&&typeof r.target=="object"?he(r.target,document):null;if(!D)i.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{mn(D,L.ops,`preview-${r.slot_id}`,document);try{D.scrollIntoView({block:"center"})}catch(C){}for(let C of k){let Q=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:C.id===L.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ce=C.displayName)!=null?ce:C.id);Q.onclick=()=>{let ue=new URL(location.href);ue.searchParams.set("sentient_arm",C.id),location.assign(ue.toString())},i.append(Q)}}i.append(p,u),((Y=document.body)!=null?Y:document.documentElement).append(i)}async function So(){if(typeof document=="undefined")return;let n=po();if(!n)return;let t=await fo(n);if(!t.ok){t.unauthorized?(lt(),bn(co)):bn(uo);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Ln)||await Eo(n,r);return}if(document.getElementById(De))return;Cn(n);let i=pn(document);de=i,i&&G(n,"/v1/editor/palette",i);let u=await ho(n);wn(u),En(u,document)}So();return Vn(To);})();
|
|
24
|
+
`,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function _n(e){var i,c;Rn(),(i=document.getElementById(kt))==null||i.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=kt;let r=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(r,a("div",{},e)),((c=document.body)!=null?c:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function Lo(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Bo(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let r=(await t.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function qt(e,t){return H(H(H(H({r:e===401?"expired":"error",status:e},typeof(t==null?void 0:t.error)=="string"?{code:t.error}:{}),typeof(t==null?void 0:t.message)=="string"?{message:t.message}:{}),typeof(t==null?void 0:t.feature)=="string"?{feature:t.feature}:{}),typeof(t==null?void 0:t.plan)=="string"?{plan:t.plan}:{})}async function Q(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)});if(i.ok)return{r:"ok"};let c=await i.json().catch(()=>null);return qt(i.status,c)}catch(i){return{r:"error"}}}async function Ao(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return qt(r.status,i)}catch(r){return{r:"error"}}}async function _o(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)}),c=await i.json().catch(()=>null);return i.ok?{r:"ok",data:c,outcome:{r:"ok"}}:{r:i.status===401?"expired":"error",data:c,outcome:qt(i.status,c)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var Dt=[];function wt(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function xt(e){let t=e.trim();if(wt(t))return t;let r=/^#([0-9a-fA-F]{3})$/.exec(t);if(r)return`#${r[1].split("").map(u=>u+u).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!i)return t;let c=u=>Math.min(255,Number(u)).toString(16).padStart(2,"0");return`#${c(i[1])}${c(i[2])}${c(i[3])}`}var ye=null,Mn=[];function In(e){Mn=e}async function $o(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let r=await t.json();return Dt=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(t){return[]}}async function yt(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return r.ok?await r.json():null}catch(r){return null}}function We(e=document){for(let t of Array.from(e.querySelectorAll(`.${Nt}`)))t.remove()}function Hn(e,t=document){var i;We(t);let r=0;for(let c of e){if(r>=So)break;let u=he(c.locator,t);if(!u)continue;let k=u.getBoundingClientRect(),T=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`,height:`${k.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});T.className=Nt;let x=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${Math.max(0,k.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},c.label);x.className=Nt,((i=t.body)!=null?i:t.documentElement).append(T,x),r+=1}}function vt(e,t){let r=e.previousElementSibling,i=e.nextElementSibling,c=r?Ue(r,t):null,u=i?Ue(i,t):null;return{prevEl:r,nextEl:i,prevLocator:r&&c&&Qe(c,r,t)?c:null,nextLocator:i&&u&&Qe(u,i,t)?u:null}}var Ro=/testimonial|review|quote/i;function Pn(e){let t=[],r=e.headings.length>=1,i=e.links.length>=1;return r&&i&&t.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&t.push("feature_grid"),e.quotes.length>=1&&t.push("testimonial"),t}var jt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Mo=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Io=new Set(["left","center","right","justify","start","end"]),Ho=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Po=/^(rgb|rgba|hsl|hsla)\(/i;function zo(e){return Ho.test(e)||Po.test(e)}function zn(e,t){switch(e){case"fontSize":case"borderRadius":return Mo.test(t)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(t)||/^\d{1,4}$/.test(t)&&+t>=1&&+t<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return Io.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return zo(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=t.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&r.length>=1&&r.length<=5&&r.every(i=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(i))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Ft(e){let t={},r={};for(let i of jt){let c=e[i];if(typeof c!="string")continue;let u=c.trim();if(u==="")continue;if(!tt(u)){r[i]="That value isn\u2019t allowed.";continue}let k=zn(i,u);if(k){r[i]=k;continue}t[i]=u}return{style:t,errors:r}}function a(e,t,r){let i=document.createElement(e);return Object.assign(i.style,t),r!==void 0&&(i.textContent=r),i}function On(e){var gn;let t=null,r=[],i=null,c=()=>{for(;r.length>0;){let n=r.splice(0,20);try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:n})}).catch(()=>{})}catch(o){}}},u=(n,o)=>{r.push(H({kind:n},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(c,2e3)};window.addEventListener("pagehide",c);let k=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});k.id=wo;let T=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});T.id=Eo;let x=()=>{if(!t||!t.isConnected){T.style.display="none";return}let n=t.getBoundingClientRect();Object.assign(T.style,{display:"block",left:`${n.left-2}px`,top:`${n.top-2}px`,width:`${n.width}px`,height:`${n.height}px`})},_=()=>x();Rn();let P=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});P.id=Ge;let X=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});X.className="sntedi-dot";let F=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});F.append(X,a("span",{},"SentientUI"));let M=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),I=!1,U=a("button",A("#374151"),"Pause selecting");U.onclick=()=>{I=!I,U.textContent=I?"Resume selecting":"Pause selecting",I?(k.style.display="none",We(document),y("Selection paused \u2014 browse normally, then resume.")):y("Click any element on the page to adapt it.")};let Y=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),N=a("button",A("#6366f1"),"Test different text here"),q=a("button",A("#374151"),"Change style"),te=a("button",A("#374151"),"Try a different layout for this section"),V=a("button",A("#374151"),"Track clicks as a goal"),m=a("button",A("#374151"),"Track form submissions as a goal"),D=a("button",A("#374151"),"Track page visits as a goal"),ne=a("button",A("#374151"),"Track reading this far as a goal"),j=a("button",A("#374151"),"Set up a funnel"),oe=a("button",A("#374151"),"Attach this test to a funnel step"),Ee=a("button",A("#10b981"),"Turn the funnel on"),be=a("button",A("#374151"),"Move up"),xe=a("button",A("#374151"),"Move down"),ot=a("button",A("#6366f1"),"Save this arrangement"),rt=a("button",A("#374151"),"Undo"),Re=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Close editor"),de=a("button",A("#10b981"),"Publish now \u2014 go live"),ce=a("button",A("#10b981"),"Start tracking now");for(let n of[N,q,te,V,be,xe])n.disabled=!0;let St=[N,q,te,V,m,be,xe];for(let n of St)n.style.display="none";ot.style.display="none",rt.style.display="none",de.style.display="none",ce.style.display="none",oe.style.display="none",Ee.style.display="none";let ue=a("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),Me=a("div",{}),Ut=[{id:"text",label:"Text",icon:"\u270F\uFE0F"},{id:"style",label:"Style",icon:"\u{1F3A8}"},{id:"layout",label:"Layout",icon:"\u{1F9F1}"},{id:"goals",label:"Goals",icon:"\u{1F3AF}"},{id:"funnels",label:"Funnels",icon:"\u{1F9ED}"},{id:"drafts",label:"Drafts",icon:"\u{1F5C2}\uFE0F"}],re="text",Gt=new Map,ve=new Map,Tt=new Map,Wt=a("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Yt=a("div",{paddingTop:"10px"});for(let n of Ut){let o=a("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});o.append(a("span",{fontSize:"11px",marginRight:"3px"},n.icon),a("span",{},n.label)),o.onclick=()=>Ct(n.id),Gt.set(n.id,o),Wt.append(o);let s=a("div",{display:"none"}),l=a("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(l),Tt.set(n.id,l),ve.set(n.id,s),Yt.append(s)}ve.get("text").append(N),ve.get("style").append(q),ve.get("layout").append(te,be,xe,ot,rt),ve.get("goals").append(V,m,D,ne),ve.get("funnels").append(j,oe,Ee);let ie=a("div",{});ve.get("drafts").append(ie);let it=()=>{var o,s;for(let l of Ut){let d=l.id===re,h=Gt.get(l.id);h.style.color=d?"#ffffff":"#9ca3af",h.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=d?"block":"none",Tt.get(l.id).style.display="none"}let n=l=>{let d=Tt.get(re);d.textContent=l,d.style.display="block"};re==="text"?t?N.disabled?n(N.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=N.onclick)==null||o.call(N,new MouseEvent("click")):n("Click any text on the page to test a different wording."):re==="style"?t?q.disabled?n("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=q.onclick)==null||s.call(q,new MouseEvent("click")):n("Click any element on the page to change how it looks."):re==="layout"?t||n("Click a section to move it or lay it out differently. Layouts re-arrange the words already on the page \u2014 they never add a section you don\u2019t have."):re==="goals"?t||n("Page-level goals work right away; click a button or form to track it specifically."):re==="funnels"?n("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):re==="drafts"&&He()},Nn=(n,o,s)=>{n.onclick=()=>{if(n.dataset.armed==="1"){n.dataset.armed="",s();return}n.dataset.armed="1",n.textContent="Sure?",setTimeout(()=>{n.isConnected&&n.dataset.armed==="1"&&(n.dataset.armed="",n.textContent=o)},4e3)}},Ie=(n,o)=>a("button",K(H({},A(n)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),Vt=(n,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",n),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},st=(n,o,s)=>{let l=Ie("#374151","Discard");return Nn(l,"Discard",async()=>{l.disabled=!0;let d=await Ao(e,n);l.disabled=!1,se(d,o),d.r==="ok"&&s()}),l},Jt=(n,o)=>{Te.textContent="";let s=a("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=a("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...o),s.append(a("div",{marginBottom:"6px"},n),l),Te.append(s)},He=async()=>{var g,b,v,w,C,L,B,z,O,le,ge,Fe;ie.textContent="",ie.append(a("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let n=[],o=[],s=null,l=!1;if(await Promise.all([(async()=>{var E;try{let R=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});R.ok?n=(E=(await R.json()).slots)!=null?E:[]:s=R.status===401?"expired":"error"}catch(R){s="error"}})(),(async()=>{var E;try{let R=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});R.ok?o=(E=(await R.json()).goals)!=null?E:[]:l=!0}catch(R){l=!0}})()]),re!=="drafts")return;if(ie.textContent="",s){if(ie.append(a("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},s==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),s==="error"){let E=Ie("#374151","Retry");E.onclick=()=>{He()},ie.append(E)}return}let d=n.filter(E=>{var R,W,me,ke,$e,Xe;return((me=(W=(R=E.draft_config)==null?void 0:R.arms)==null?void 0:W.length)!=null?me:0)>0||((Xe=($e=(ke=E.published_config)==null?void 0:ke.arms)==null?void 0:$e.length)!=null?Xe:0)>0}),h=o.filter(E=>E.event!=="custom"&&(E.status==="draft"||E.status==="active"));if(d.length===0&&h.length===0&&!l){ie.append(a("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let f=E=>a("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:E?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:E?"#6ee7b7":"#c7d2fe"},E?"live":"draft"),p=E=>{let R=a("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),W=a("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},E);return R.append(W),{row:R,name:W}};for(let E of d){let{row:R}=p((g=E.display_name)!=null?g:E.slot_id);R.append(f(E.status==="published"));let W=(C=(w=(b=E.draft_config)==null?void 0:b.arms)!=null?w:(v=E.published_config)==null?void 0:v.arms)!=null?C:[],me=(z=(L=W[1])==null?void 0:L.id)!=null?z:(B=W[0])==null?void 0:B.id,ke=Ie("#374151","Preview");if(ke.onclick=()=>Vt(E.slot_id,me),R.append(ke),E.status!=="published"&&((ge=(le=(O=E.draft_config)==null?void 0:O.arms)==null?void 0:le.length)!=null?ge:0)>0){let $e=Ie("#10b981","Publish");$e.onclick=async()=>{$e.disabled=!0;let Xe=await Q(e,`/v1/editor/slots/${encodeURIComponent(E.slot_id)}/publish`,{});$e.disabled=!1,se(Xe,"\u2713 Published \u2014 live for new visitors."),Xe.r==="ok"&&(u("published",{kind:"slot"}),He())},R.append($e)}E.status!=="published"&&R.append(st(`/v1/editor/slots/${encodeURIComponent(E.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{on(E.slot_id),He()})),ie.append(R)}if(l)ie.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(h.length>0){ie.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let E of h){let{row:R}=p((Fe=E.display_name)!=null?Fe:E.goal_id);if(R.append(f(E.status==="active")),E.status==="draft"){let W=Ie("#10b981","Start tracking");W.onclick=async()=>{W.disabled=!0;let me=await Q(e,`/v1/editor/goals/${encodeURIComponent(E.goal_id)}/publish`,{});W.disabled=!1,se(me,"\u2713 Tracking is live \u2014 it counts from your next visitor."),me.r==="ok"&&(u("published",{kind:"goal"}),He())},R.append(W,st(`/v1/editor/goals/${encodeURIComponent(E.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{rn(E.goal_id),He()}))}ie.append(R)}}},Ct=n=>{re!==n&&(G(),Je(),re=n,it())},Kt=a("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(F.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Xt=!1,Se=a("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"46px",height:"46px",borderRadius:"50%",border:"1px solid rgba(99,102,241,0.55)",background:"#111827",color:"#fff",cursor:"pointer",display:"none",alignItems:"center",justifyContent:"center",gap:"4px",font:"700 15px system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"}),Zt=a("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});Zt.className="sntedi-dot",Se.append(Zt,a("span",{},"S")),Se.title="Open the SentientUI editor";let Qt=a("button",{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",color:"#fff",border:"none",cursor:"pointer",whiteSpace:"nowrap"},"Minimize");Qt.onclick=()=>{P.style.display="none",Se.style.display="flex",Xt=I,I=!0,k.style.display="none",We(document)},Se.onclick=()=>{P.style.display="block",Se.style.display="none",I=Xt},Object.assign(U.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(Re.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),Kt.append(F,U,Qt,Re);let en=a("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Te=a("div",{});Object.assign(Z.style,{marginBottom:"4px"}),en.append(Te,Z,de,ce);let pe=a("button",{display:"none",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u2728 Ask AI"),Lt=a("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(Y.style,{flex:"1 1 auto",marginBottom:"0"}),Lt.append(Y,pe),Object.assign(Lt.style,{marginBottom:"6px"});let fe=a("div",{}),$=a("div",{marginTop:"4px"});$.addEventListener("input",()=>{Pe=!0}),$.addEventListener("change",()=>{Pe=!0}),P.append(Kt,M,Lt,ue,Me,fe,Wt,Yt,$,en),((gn=document.body)!=null?gn:document.documentElement).append(k,T,P,Se);let Ce=null,tn=()=>{Ce==null||Ce(),Ce=null},nn=()=>{Ce=null},Pe=!1,Bt=null,G=()=>{tn(),$.textContent="",Pe=!1,Bt=null,Ht=!1},Ye=(n,o,s)=>{var b;G();let l={},d={},h={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let v of n){let w=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},v.label);if($.append(w),v.type==="select"){let L=a("select",h);L.setAttribute("data-field",v.key);let B=document.createElement("option");B.value="",B.textContent="\u2014 no change \u2014",L.append(B);for(let z of(b=v.options)!=null?b:[]){let O=document.createElement("option");O.value=z,O.textContent=z,L.append(O)}l[v.key]=()=>L.value,$.append(L)}else if(v.type==="color"){let L=a("input",K(H({},h),{padding:"2px",height:"34px"}));L.type="color",L.setAttribute("data-field",v.key);let B=!1;L.addEventListener("input",()=>{B=!0}),l[v.key]=()=>B?L.value:"",$.append(L)}else{let L=a("input",h);L.setAttribute("data-field",v.key),v.value!==void 0&&(L.value=v.value),l[v.key]=()=>L.value,$.append(L)}let C=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});C.setAttribute("data-feedback",v.key),d[v.key]=C,$.append(C)}let f=(v,w)=>{let C=d[v];C&&(C.textContent=w!=null?w:"",C.style.display=w?"block":"none")},p=a("button",A("#6366f1"),o),g=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>s(Object.fromEntries(Object.entries(l).map(([v,w])=>[v,w()])),f),g.onclick=G,$.append(p,g)},y=(n,o=!0)=>{Z.textContent=n,Z.style.color=o?"#a7f3d0":"#fca5a5"},At=(n,o)=>{var l,d;if(u("error_shown",{code:(d=n.code)!=null?d:`http_${(l=n.status)!=null?l:"network"}`}),n.code==="plan_limit_reached"){let h=n.feature==="live_goals"?"live goal":"of these",f=n.plan?`${n.plan} plan`:"plan";return n.feature==="live_goals"?`Your ${f} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${f} has reached its limit for ${h}. Manage them in your dashboard, or upgrade for more.`}if(n.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(n.code==="demo_read_only"&&n.message)return n.message;let s=n.status?` (HTTP ${n.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},se=(n,o)=>{n.r==="ok"?y(o,!0):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):y(At(n,"save"),!1)},Le=null,at=n=>n.length>30?`${n.slice(0,27)}\u2026`:n,on=n=>{Le===n&&(Le=null,de.style.display="none",oe.style.display="none",Te.textContent="")},rn=n=>{je===n&&(je=null,ce.style.display="none",Te.textContent="")},lt=(n,o,s)=>{Le=n,de.textContent=o?`Publish \u201C${at(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",de.style.display="block",oe.style.display="block";let l=[];if(s){let d=Ie("#374151","Preview");d.onclick=()=>Vt(n,s),l.push(d)}l.push(st(`/v1/editor/slots/${encodeURIComponent(n)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>on(n))),Jt(o?`Draft saved for \u201C${at(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};de.onclick=async()=>{if(!Le)return;de.disabled=!0,y("Publishing\u2026");let n=await Q(e,`/v1/editor/slots/${encodeURIComponent(Le)}/publish`,{});de.disabled=!1,n.r==="ok"?(u("published",{kind:"slot"}),y("\u2713 Published \u2014 live for new visitors.",!0),de.style.display="none",Le=null,Te.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):y(At(n,"publish"),!1)};let J=null,ze=!1,Oe=null,Ne=null,ae=null,Be=null,Ve=null,dt=null,Ae=!1,sn=(n,o)=>ze?n?"":`Nothing to swap with ${o} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",an=()=>{be.disabled=!ze||!ae,xe.disabled=!ze||!Be,be.title=be.disabled?sn(ae,"above"):"",xe.title=xe.disabled?sn(Be,"below"):""},_t=n=>{ot.style.display=n?"block":"none",rt.style.display=n?"block":"none",an()},Je=()=>{if(Ae&&t&&Ve&&Ve.insertBefore(t,dt),Ae=!1,Ve=null,dt=null,t){let n=vt(t,document);Oe=n.prevEl,Ne=n.nextEl,ae=n.prevLocator,Be=n.nextLocator}x(),_t(!1)},ln=n=>{if(I)return;let o=n.target;if(!o||P.contains(o)||o===k)return;We(document);let s=o.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},_e=n=>{var s;let o=((s=n.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:n.tagName.toLowerCase()},Dn=n=>!!n.id||["section","header","footer","nav","main","form","article","aside"].includes(n.tagName.toLowerCase())||!!n.querySelector(":scope > h1, :scope > h2, :scope > h3"),jn=n=>{var l;let o=n.querySelector("h1, h2, h3"),s=(l=o==null?void 0:o.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:n.id?`#${n.id.length>24?`${n.id.slice(0,21)}\u2026`:n.id}`:`<${n.tagName.toLowerCase()}>`},Fn=n=>{ue.textContent="";let o=[];for(let f=n.parentElement;f&&f!==document.body&&o.length<3;f=f.parentElement)Dn(f)&&o.push(f);let s=_e(n),l=()=>a("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let f of o){let p=jn(f);if(p===s||s.startsWith(p))continue;let g=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);g.onclick=()=>ct(f),d||ue.append(l()),ue.append(g),d=!1}d||ue.append(l());let h=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");h.onclick=()=>dn(),ue.append(h),ue.style.display="block"},qn=n=>{Me.textContent="";let o=null,s=0;for(let d=n.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(Qe(Ue(d,document),d,document)){o=d;break}let l=a("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(o){let d=o;l.append(a("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let h=a("button",K(H({},A("#6366f1")),{marginTop:"0"}),`Select \u201C${_e(d)}\u201D instead`);h.onclick=()=>ct(d);let f=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Pick something else");f.onclick=()=>{Me.textContent=""},l.append(h,f)}else l.append(a("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));Me.append(l)},ct=n=>{Je(),G(),Me.textContent="",t=n,J=Ue(n,document);let o=Qe(J,n,document);ze=o,x(),Y.style.display="block",Y.textContent=`Selected: ${_e(n)}`,Fn(n),u("element_selected",{unique:o}),y(o?"\u2713 Matches exactly 1 element":"",o),o||qn(n),M.style.display="none",pe.style.display="inline-block",fe.textContent="";for(let h of St)h.style.display="block";N.style.display="none",q.style.display="none";let s=n.childElementCount===0;N.disabled=!o||!s,N.title=o?s?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",q.disabled=!o,te.disabled=!o,V.disabled=!o;let l=n.closest("form");m.style.display=l?"block":"none",m.disabled=!l;let d=vt(n,document);Oe=d.prevEl,Ne=d.nextEl,ae=d.prevLocator,Be=d.nextLocator,an(),it()},dn=()=>{Je(),G(),t=null,J=null,ze=!1,Oe=null,Ne=null,ae=null,Be=null,x(),Me.textContent="",fe.textContent="",ue.textContent="",ue.style.display="none",Y.textContent="",Y.style.display="none",pe.style.display="none";for(let n of St)n.style.display="none";M.style.display="block",y(""),it()},De=!1,$t=-1,cn=n=>{var l,d;let o=n.target,s=!!((l=o==null?void 0:o.closest)!=null&&l.call(o,'input, textarea, select, [contenteditable="true"]'));if(n.key==="Escape"){if($.childElementCount>0){G(),De=!1;return}if(t){dn(),De=!1;return}if(!De){De=!0,y("Press Esc again to close the editor.");return}De=!1,(d=Re.onclick)==null||d.call(Re,new MouseEvent("click"));return}if(De=!1,!(s||I)){if(n.key==="ArrowUp"||n.key==="ArrowDown"){if(!t||(n.key==="ArrowUp"?be:xe).disabled)return;n.preventDefault(),It(n.key==="ArrowUp"?"up":"down");return}if(n.key==="Tab"){let h=[];for(let p of Mn){let g=he(p.locator,document);g&&!h.includes(g)&&h.push(g)}if(h.length===0)return;if(Pe){y("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),n.preventDefault();return}n.preventDefault(),$t=($t+(n.shiftKey?-1:1)+h.length)%h.length;let f=h[$t];ct(f);try{f.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},un=n=>{if(I)return;let o=n.target;if(!(!o||P.contains(o))){if(n.preventDefault(),n.stopPropagation(),Pe&&o!==t&&Bt!==o){Bt=o,y("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}ct(o)}};N.onclick=()=>{var h,f,p;if(!t||!J)return;u("form_opened",{kind:"text"});let n=J,o=(f=(h=t.textContent)==null?void 0:h.trim())!=null?f:"";Ye([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async g=>{let b=g.alt.trim();if(!b){y("\u26A0 Enter alternative wording to test.",!1);return}if(b===g.current.trim()){y("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let v=nt("text",n,t);y("Saving\u2026");let w=await Q(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:g.current}},{id:"b",displayName:"Alternative",ops:{text:g.alt}}]}});w.r==="ok"&&(u("draft_saved",{kind:"slot"}),nn(),G(),lt(v,_e(t),"b")),se(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let s=t,l=(p=s.textContent)!=null?p:"";Ce=()=>{s.textContent=l};let d=$.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?l:d.value})};let Ke=null,pn=n=>{let o=p=>{var g;return((g=p.textContent)!=null?g:"").replace(/\s+/g," ").trim()},s=Array.from(n.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let p=n.closest("h1,h2,h3,h4");p&&s.push(o(p))}let l=Array.from(n.querySelectorAll("p")).map(o).filter(p=>p.length>0&&p.length<=300),d=[];for(let p of Array.from(n.querySelectorAll("a[href], button"))){let g=o(p);if(!g||g.length>60)continue;let b="",v=p.getAttribute("href");if(v)try{let w=new URL(v,window.location.href);w.protocol==="https:"&&(b=w.href)}catch(w){}d.push({label:g,href:b})}let h=Array.from(n.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(h.length===0&&Ro.test(`${n.className} ${n.id}`))for(let p of l)p.length>=20&&h.push(p);let f=Array.from(n.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(p=>p.length>0&&p.length<=80);return{headings:s,paragraphs:l,links:d,quotes:h,attributions:f}},Un=(n,o)=>{var l,d,h,f,p,g,b,v,w,C,L,B,z,O,le,ge,Fe,E,R,W;let s=me=>{var ke;return o.paragraphs.length>=3&&(ke=o.paragraphs[o.paragraphs.length-3+me])!=null?ke:""};switch(n){case"headline":return(l=o.headings[0])!=null?l:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(f=(h=o.links[0])==null?void 0:h.label)!=null?f:"";case"cta_href":return(g=(p=o.links[0])==null?void 0:p.href)!=null?g:"";case"secondary_label":return(v=(b=o.links[1])==null?void 0:b.label)!=null?v:"";case"secondary_href":return(C=(w=o.links[1])==null?void 0:w.href)!=null?C:"";case"quote":case"q1":return(L=o.quotes[0])!=null?L:"";case"q2":return(B=o.quotes[1])!=null?B:"";case"q3":return(z=o.quotes[2])!=null?z:"";case"name":case"n1":return(O=o.attributions[0])!=null?O:"";case"n2":return(le=o.attributions[1])!=null?le:"";case"n3":return(ge=o.attributions[2])!=null?ge:"";case"role":return(Fe=o.attributions[1])!=null?Fe:"";case"eyebrow":return"";case"f1_title":return(E=o.headings[1])!=null?E:"";case"f2_title":return(R=o.headings[2])!=null?R:"";case"f3_title":return(W=o.headings[3])!=null?W:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},Gn=(n,o,s)=>{u("form_opened",{kind:"arrangement"});let l=pn(s);Ye(n.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:Un(d.id,l)})),"Save draft",async(d,h)=>{var w,C,L,B,z;let f=!1,p=!1;for(let O of n.fields){if(O.kind==="href"){let ge=!1;try{ge=new URL((w=d[O.id])!=null?w:"").protocol==="https:"}catch(Fe){}h(O.id,ge?null:"Links need to start with https://"),ge||(f=!0);continue}let le=((C=d[O.id])!=null?C:"").trim()==="";h(O.id,le?"Fill this in with your own words":null),le&&(p=!0)}if(f){y("\u26A0 Fix the highlighted link(s).",!1);return}if(p){y("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}y("Saving\u2026");let g=await _o(e,`/v1/editor/arrangements/${encodeURIComponent(n.id)}/instantiate`,{fields:d});if(g.r!=="ok"||!((L=g.data)!=null&&L.blocks)){g.r==="expired"?se(g.outcome,""):y(`\u26A0 ${(z=(B=g.data)==null?void 0:B.reason)!=null?z:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let b=nt("arrange",o,s),v=await Q(e,`/v1/editor/slots/${encodeURIComponent(b)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:n.id,displayName:n.name,blocks:g.data.blocks}],baseline:"original"}});v.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),G(),lt(b,n.name,n.id)),se(v,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")})};te.onclick=async()=>{var h,f;if(!t||!J)return;let n=J,o=t;if(G(),y("Loading arrangements\u2026"),!Ke){let p=await yt(e,"/v1/editor/arrangements");Ke=(h=p==null?void 0:p.arrangements)!=null?h:null}if(!Ke||Ke.length===0){y("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=Pn(pn(o)),l=Ke.filter(p=>s.includes(p.sectionType));if(l.length===0){y("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}y("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let g=a("button",K(H({},A("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},p.name),a("div",{fontSize:"11px",opacity:"0.7"},p.description)),g.onclick=()=>Gn(p,n,o),$.append(g)}let d=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=G,$.append(d),(f=$.scrollIntoView)==null||f.call($,{block:"nearest"})};let je=null,Wn=(n,o)=>{je=n,ce.textContent=o?`Start tracking \u201C${at(o)}\u201D now`:"Start tracking now",ce.style.display="block",Jt(o?`Goal \u201C${at(o)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[st(`/v1/editor/goals/${encodeURIComponent(n)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>rn(n))])};ce.onclick=async()=>{if(!je)return;ce.disabled=!0,y("Activating\u2026");let n=await Q(e,`/v1/editor/goals/${encodeURIComponent(je)}/publish`,{});ce.disabled=!1,n.r==="ok"?(u("published",{kind:"goal"}),y("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ce.style.display="none",je=null,Te.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):y(At(n,"activate"),!1)};let Rt=(n,o)=>`${bt(n)||"goal"}-${$n(o)}`.slice(0,128),Yn=n=>{var l,d,h;let o=((l=n.textContent)!=null?l:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((h=(d=n.getAttribute("aria-label"))!=null?d:n.getAttribute("id"))!=null?h:"").trim()||"element-clicked"},ut=async(n,o,s)=>{y("Saving\u2026");let l=await Q(e,`/v1/editor/goals/${encodeURIComponent(n)}`,o);l.r==="ok"&&(u("draft_saved",{kind:"goal"}),Wn(n,s)),se(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live.")};V.onclick=()=>{if(!t||!J)return;let n=Rt(Yn(t),JSON.stringify(J));ut(n,{event:"click",locator:J},_e(t))},m.onclick=()=>{var l,d;let n=t==null?void 0:t.closest("form");if(!n)return;let o=Ue(n,document),s=(d=(l=n.getAttribute("id"))!=null?l:n.getAttribute("name"))!=null?d:"form-submitted";ut(Rt(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},D.onclick=()=>{let n=window.location.pathname||"/",o=bt(n)?`reached-${bt(n)}`:"page-visited";ut(Rt(o,n),{event:"url_reached",urlPattern:n},n)};let Mt=[{label:"25% \u2014 skimmed the top",value:.25},{label:"50% \u2014 read halfway",value:.5},{label:"75% \u2014 read most of the page",value:.75},{label:"90% \u2014 read to the end",value:.9}];ne.onclick=()=>{Ye([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Mt.map(n=>n.label)}],"Track it",n=>{var l;let o=(l=Mt.find(d=>d.label===n.depth))!=null?l:Mt[2],s=Math.round(o.value*100);ut(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),G()})};let pt=null,Vn=n=>{pt=n,Ee.style.display="block"};Ee.onclick=async()=>{if(!pt)return;Ee.disabled=!0,y("Turning on\u2026");let n=await Q(e,`/v1/editor/funnels/${encodeURIComponent(pt)}/publish`,{});Ee.disabled=!1,n.r==="ok"?(u("published",{kind:"funnel"}),y("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),Ee.style.display="none",pt=null):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):y("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},j.onclick=async()=>{var v;y("Loading your goals\u2026");let n=await yt(e,"/v1/editor/goals"),o=(v=n==null?void 0:n.goals)!=null?v:[];if(o.length<2){y("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}y("Pick the steps in order \u2014 first click = first step."),G();let s=[],l=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});$.append(l,d);let h=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");$.append(h);let f=new Map,p=()=>{var w,C;for(let[L,B]of f){let z=s.indexOf(L),O=(C=(w=o.find(le=>le.goal_id===L))==null?void 0:w.display_name)!=null?C:L;B.textContent=z===-1?O:`${z+1}. ${O}`,B.style.background=z===-1?"#374151":"#6366f1"}};for(let w of o){let C=a("button",K(H({},A("#374151")),{textAlign:"left"}));f.set(w.goal_id,C),C.onclick=()=>{s=Bn(s,w.goal_id),p()},$.append(C)}p();let g=a("button",A("#6366f1"),"Save funnel"),b=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");b.onclick=G,g.onclick=async()=>{let w=An(d.value,s);if(!w.ok){y(`\u26A0 ${w.error}`,!1);return}y("Saving\u2026");let C=await Q(e,`/v1/editor/funnels/${encodeURIComponent(w.funnelId)}`,w.body);C.r==="ok"&&(u("draft_saved",{kind:"funnel"}),G(),Vn(w.funnelId)),se(C,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},$.append(g,b)},oe.onclick=async()=>{var p,g;let n=Le;if(!n)return;y("Loading funnels\u2026");let o=await yt(e,"/v1/editor/funnels"),s=(p=o==null?void 0:o.funnels)!=null?p:[];if(s.length===0){y("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await yt(e,"/v1/editor/goals"),d=new Map(((g=l==null?void 0:l.goals)!=null?g:[]).map(b=>[b.goal_id,b.display_name]));Ye([{key:"funnel",label:"Funnel",type:"select",options:s.map(b=>mt(b))},{key:"step",label:"Which step does this element serve?",type:"select",options:ht(s[0],d).map(b=>b.label)}],"Attach",async b=>{var L;let v=(L=s.find(B=>mt(B)===b.funnel))!=null?L:s[0],w=ht(v,d).findIndex(B=>B.label===b.step);if(w<0){y("\u26A0 Pick which step this element serves.",!1);return}y("Attaching\u2026");let C=await Q(e,`/v1/editor/funnels/${encodeURIComponent(v.funnel_id)}/assign`,{slotId:n,stepIndex:w});C.r==="ok"&&G(),se(C,`\u2713 Attached \u2014 this test now works toward \u201C${v.display_name}\u201D.`)});let h=$.querySelector('select[data-field="funnel"]'),f=$.querySelector('select[data-field="step"]');h&&f&&h.addEventListener("change",()=>{var v;let b=(v=s.find(w=>mt(w)===h.value))!=null?v:s[0];f.length=1;for(let w of ht(b,d)){let C=document.createElement("option");C.value=w.label,C.textContent=w.label,f.append(C)}})},q.onclick=()=>{if(!t||!J)return;u("form_opened",{kind:"style"});let n=J;Ye([{key:"color",label:"Text colour",type:"color"},{key:"background",label:"Background colour",type:"color"},{key:"fontSize",label:"Font size (e.g. 20px)"},{key:"fontWeight",label:"Font weight (e.g. 700)"},{key:"fontFamily",label:Dt.length?`Font (this site has: ${Dt.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(f,p)=>{var L;let{style:g,errors:b}=Ft(f),v=!1;for(let B of jt)p(B,(L=b[B])!=null?L:null),b[B]&&(v=!0);if(v){y("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(g).length===0){y("\u26A0 Enter at least one style change.",!1);return}let w=nt("style",n,t);y("Saving\u2026");let C=await Q(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:g}}]}});C.r==="ok"&&(u("draft_saved",{kind:"slot"}),nn(),G(),lt(w,_e(t),"b")),se(C,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let o=t,s=o.style.cssText;Ce=()=>{o.style.cssText=s};let l={},d=()=>{let{style:f}=Ft(l);o.style.cssText=s;for(let[p,g]of Object.entries(f)){let b=gt[p];b&&tt(g)&&o.style.setProperty(b,g.trim(),"important")}};for(let f of jt){let p=$.querySelector(`[data-field="${f}"]`);if(!p)continue;let g=()=>{l[f]=p.value,d()};p.addEventListener("input",g),p.addEventListener("change",g)}let h=[ye==null?void 0:ye.primaryBg,ye==null?void 0:ye.primaryText,"#ffffff"].filter(f=>!!f).map(xt).filter((f,p,g)=>wt(f)&&g.indexOf(f)===p);for(let f of["color","background"]){let p=$.querySelector(`input[data-field="${f}"]`);if(!p)continue;let g=a("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let b of h){let v=a("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:b,padding:"0"});v.title=b,v.onclick=()=>{p.value=xt(b),p.dispatchEvent(new Event("input"))},g.append(v)}p.after(g)}};let fn=n=>{var l;let o=n==="text"?N:q;if(o.disabled)return y(o.title||"This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section.",!1),!1;Ct(n);let s=n==="text"?'[data-field="alt"]':'[data-field="color"]';return $.querySelector(s)||(l=o.onclick)==null||l.call(o,new MouseEvent("click")),!0},Jn=()=>{if(!t)return;fe.textContent="";let n=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"}),o=a("input",{width:"100%",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"});o.type="text",o.maxLength=300,o.placeholder="e.g. shorter and more urgent",o.setAttribute("data-field","ai-instruction");let s=a("button",K(H({},A("#6366f1")),{display:"inline-block",width:"auto",margin:"8px 0 0",padding:"4px 10px",fontSize:"11px"}),"Go");s.setAttribute("data-action","ai-go"),s.onclick=()=>{Kn(o.value.trim())},o.onkeydown=l=>{var d;l.key==="Enter"&&(l.preventDefault(),(d=s.onclick)==null||d.call(s,new MouseEvent("click")))},n.append(a("div",{fontWeight:"600",marginBottom:"4px"},"What should this element do differently?"),o,a("div",{opacity:"0.7",fontSize:"11px",marginTop:"4px"},"Leave it blank for ideas. Nothing goes live \u2014 you review and save whatever comes back."),s),fe.append(n),o.focus()};pe.onclick=()=>Jn();let Kn=async n=>{var p,g;if(!t)return;let o=t;pe.disabled=!0;let s=pe.textContent;pe.textContent="Thinking\u2026",fe.textContent="",u("form_opened",{kind:"suggest"});let l={},d=null;try{let b=await fetch(`${e.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(H(H({element:{tag:o.tagName.toLowerCase(),text:((p=o.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},n?{instruction:n.slice(0,300)}:{}),ye?{palette:ye}:{}))});b.ok?l=await b.json():d=b.status===401?"expired":"error"}catch(b){d="error"}if(pe.disabled=!1,pe.textContent=s,t!==o)return;if(d){y(d==="expired"?"Editor session expired \u2014 reopen it from your dashboard to keep editing.":"\u26A0 Couldn\u2019t get suggestions \u2014 check your connection and try again.",!1);return}if(l.locked){y("AI suggestions aren\u2019t included in this plan.",!1);return}if(l.exhausted){y("You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.",!1);return}let h=(g=l.suggestions)!=null?g:[];if(h.length===0){y(n?"Couldn\u2019t do that safely on this element \u2014 try asking for a smaller change, or pick a headline or a button.":"No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let f=(b,v)=>{let w=$.querySelector(`[data-field="${b}"]`);w&&(w.value=v,w.dispatchEvent(new Event("input")))};for(let b of h){let v=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",fontSize:"12px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"});v.append(a("div",{fontWeight:"600",marginBottom:"2px"},b.title),a("div",{opacity:"0.75",marginBottom:"6px"},b.reason));let w=a("button",K(H({},A("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");w.onclick=()=>{var C,L;if(t!==o){fe.textContent="";return}if(fe.textContent="",b.kind==="text"){if(!fn("text"))return;f("alt",b.variant)}else if(b.kind==="style"){if(!fn("style"))return;for(let[B,z]of Object.entries(b.style))if(B==="color"||B==="background"){let O=xt(z);wt(O)&&f(B,O)}else B==="textAlign"?f(B,z==="start"?"left":z==="end"?"right":z):f(B,z)}else{let B=b.goalType==="form_submit"&&!m.disabled;if(!B&&V.disabled){y("This element can\u2019t be tracked reliably \u2014 select a specific button or link instead.",!1);return}Ct("goals"),B?(C=m.onclick)==null||C.call(m,new MouseEvent("click")):(L=V.onclick)==null||L.call(V,new MouseEvent("click"))}},v.append(w),fe.append(v)}},It=n=>{if(!t)return;let o=t.parentElement;if(!o)return;Ae||(Ve=o,dt=t.nextSibling,Ae=!0),n==="up"&&Oe?o.insertBefore(t,Oe):n==="down"&&Ne&&o.insertBefore(t,Ne.nextSibling);let s=vt(t,document);Oe=s.prevEl,Ne=s.nextEl,ae=s.prevLocator,Be=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}x(),_t(!0),y("Previewing the new position \u2014 keep moving, save, or undo.")};be.onclick=()=>It("up"),xe.onclick=()=>It("down"),rt.onclick=()=>{Je(),y("Move undone \u2014 back to the original position.")},ot.onclick=async()=>{if(!t||!J||!Ae||!ze)return;let n=ae?"moveAfter":"moveBefore",o=ae!=null?ae:Be;if(!o){y("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=nt("move",J,t);y("Saving\u2026");let l=await Q(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:J,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[n]:o}}]}});l.r==="ok"&&(u("draft_saved",{kind:"move"}),Ae=!1,Ve=null,dt=null,_t(!1),lt(s,_e(t),"b")),se(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let Xn=()=>{var n,o;u("editor_closed"),c(),window.removeEventListener("pagehide",c),i&&clearTimeout(i),Je(),tn(),document.removeEventListener("mousemove",ln,!0),document.removeEventListener("click",un,!0),document.removeEventListener("keydown",cn,!0),window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_),We(document),(n=document.getElementById(Ot))==null||n.remove(),k.remove(),T.remove(),P.remove(),Se.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),et()},Ht=!1;Re.onclick=()=>{if((Pe||Ae)&&!Ht){Ht=!0,y("\u26A0 Unsaved changes \u2014 click \u201CClose editor\u201D again to discard them.",!1);return}Xn()},document.addEventListener("mousemove",ln,!0),document.addEventListener("click",un,!0),document.addEventListener("keydown",cn,!0),window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),it(),u("editor_opened")}function A(e){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:e,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var Et="sentient-preview-bar";async function Oo(e,t){var P,X,F,M,I,U,Y,Z,N,q,te,V;try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(m){}let r=null;try{let m=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});m.ok&&(r=(X=((P=(await m.json()).slots)!=null?P:[]).find(ne=>ne.slot_id===t&&ne.kind==="arms"))!=null?X:null)}catch(m){}let i=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Et;let c=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");c.onclick=()=>{et();let m=new URL(location.href);for(let D of["sentient_editor","sentient_preview","sentient_arm"])m.searchParams.delete(D);location.assign(m.toString())};let u=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");u.onclick=()=>{let m=new URL(location.href);for(let D of["sentient_preview","sentient_arm"])m.searchParams.delete(D);location.assign(m.toString())};let k=(U=(I=(F=r==null?void 0:r.draft_config)==null?void 0:F.arms)!=null?I:(M=r==null?void 0:r.published_config)==null?void 0:M.arms)!=null?U:[];if(!r||k.length===0){i.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),u,c),((Y=document.body)!=null?Y:document.documentElement).append(i);return}let T=new URLSearchParams(location.search).get("sentient_arm"),x=(N=(Z=k.find(m=>m.id===T))!=null?Z:k[1])!=null?N:k[0];i.append(a("span",{fontWeight:"700"},`Previewing: ${(q=r.display_name)!=null?q:r.slot_id}`));let _=r.target&&typeof r.target=="object"?he(r.target,document):null;if(!_)i.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{Ln(_,x.ops,`preview-${r.slot_id}`,document);try{_.scrollIntoView({block:"center"})}catch(m){}for(let m of k){let D=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:m.id===x.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(te=m.displayName)!=null?te:m.id);D.onclick=()=>{let ne=new URL(location.href);ne.searchParams.set("sentient_arm",m.id),location.assign(ne.toString())},i.append(D)}}i.append(u,c),((V=document.body)!=null?V:document.documentElement).append(i)}async function No(e,t){var P,X,F;let r=t.lastIndexOf("~"),i=r>0?t.slice(0,r):t,c=r>0?t.slice(r+1):"",u=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});u.id=Et;let k=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");k.onclick=()=>{et();let M=new URL(location.href);for(let I of["sentient_editor","sentient_preview_cell"])M.searchParams.delete(I);location.assign(M.toString())};let T=M=>{var I;u.append(a("span",{},M),k),((I=document.body)!=null?I:document.documentElement).append(u)},x=null;try{let M=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${e.token}`}});M.ok&&(x=await M.json())}catch(M){}if(!x)return T("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let _=x.target&&typeof x.target=="object"?he(x.target,document):null;if(!_)return T("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(x.blocks!=null)wn(_,{preview:x.blocks},"preview",document);else if(typeof x.content=="string")_.textContent=x.content;else return T("Nothing to preview in that square yet.");try{_.scrollIntoView({block:"center"})}catch(M){}u.append(a("span",{fontWeight:"700"},`Previewing: ${(P=x.slotName)!=null?P:i}`),a("span",{opacity:"0.85"},`for ${(X=x.personaDisplay)!=null?X:c}${x.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),k),((F=document.body)!=null?F:document.documentElement).append(u)}async function Do(){if(typeof document=="undefined")return;let e=Lo();if(!e)return;let t=await Bo(e);if(!t.ok){t.unauthorized?(et(),_n(To)):_n(Co);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Et)||await Oo(e,r);return}let i=new URLSearchParams(location.search).get("sentient_preview_cell");if(i){document.getElementById(Et)||await No(e,i);return}if(document.getElementById(Ge))return;On(e);let c=Sn(document);ye=c,c&&Q(e,"/v1/editor/palette",c);let u=await $o(e);In(u),Hn(u,document)}Do();return io(jo);})();
|
package/dist/snippet.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var Je=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames,jt=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable;var Gt=(e,t,n)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t)=>{for(var n in t||(t={}))Ut.call(t,n)&&Gt(e,n,t[n]);if(jt)for(var n of jt(t))gr.call(t,n)&&Gt(e,n,t[n]);return e};var zt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ft=(e,t)=>{for(var n in t)Je(e,n,{get:t[n],enumerable:!0})},mr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pr(t))!Ut.call(e,o)&&o!==n&&Je(e,o,{get:()=>t[o],enumerable:!(r=fr(t,o))||r.enumerable});return e};var hr=e=>mr(Je({},"__esModule",{value:!0}),e);var yr,vr,br,qt,wr,Sr,Wt,O,be,De=zt(()=>{"use strict";yr=Object.defineProperty,vr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,wr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Wt=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))wr.call(t,n)&&Wt(e,n,t[n]);if(qt)for(var n of qt(t))Sr.call(t,n)&&Wt(e,n,t[n]);return e},be=(e,t)=>vr(e,br(t))});var on={};Ft(on,{LOCAL_ENGINE_AVAILABLE:()=>Ir,createLocalEngine:()=>Or});function Or(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Ir,sn=zt(()=>{"use strict";Ir=!1});var qo={};Ft(qo,{applyPersonaAttributes:()=>at,applyRegistrySlots:()=>ut,applySlotArms:()=>ct,applySlotAttributes:()=>lt,parseEditorToken:()=>sr,parsePersonaPreview:()=>cr,parsePreview:()=>lr,parseSnippetConfig:()=>rt,planReorder:()=>pt,reapply:()=>Nt,run:()=>ur,version:()=>We});De();var Ar=["buyer","researcher","deal_seeker","browser"];var Er={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Ve(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Ht(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function bt(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Ve(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[c,i]of Object.entries((n=e.dims)!=null?n:{}))o[c]=(r=i[0])!=null?r:"";return Ve(o)}function Jt(e,t){var n,r;return e.dims!=null?(r=(n=Ht(t))!=null?n:Ht(bt(e)))!=null?r:{}:t}function Vt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function we(e){return e>=.3?e<.7?"medium":"high":"low"}var Jo=Ar.map(e=>({key:e,displayName:Er[e]}));function Xe(e){return e?`_${e.slice(0,12)}`:""}var xr="_snt_uid";function Xt(e){return`${xr}${Xe(e)}`}var kr=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function Yt(e){return Cr(e)!==null}function Cr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=kr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Zt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Qt(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function en(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var _r=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function tn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,c])=>{let i=Array.isArray(c)?c[0]:c;return i===void 0?[]:[[o,i]]});for(let[o,c]of r)o.startsWith("utm_")?o in t||(t[o]=c):_r.includes(o)&&(o in n||(n[o]=c))}catch(r){}return{utmParams:t,clickIds:n}}function nn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function wt(e){return O(O(O({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function St(e){let t=wt(e);return Jt(t,bt(t))}function rn(e){return typeof e=="string"?e:Ve(e)}De();function dn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Pr="_snt_uid",Lr=365,Ye="_snt_uid";function Rr(){return dn()}function an(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Tr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function At(e){try{return localStorage.getItem(e)}catch(t){return null}}function ln(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function cn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Dr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Mr(e){try{sessionStorage.removeItem(e)}catch(t){}}function Nr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Br(e){try{localStorage.removeItem(e)}catch(t){}}function $r(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Kr={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function fn(e){var t,n,r,o,c,i,s;if(typeof window=="undefined")return Kr;let a=Xe(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Xt(e==null?void 0:e.apiKey),l=`${Ye}${a}`,d=`${Ye}_tomb${a}`,m=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Lr)*24*60*60,w=b=>b&&b.length>0?b:null,p=()=>{var b,_;return a&&!(e!=null&&e.cookieName)&&At(d)===null?(_=(b=w(an(Pr)))!=null?b:w(At(Ye)))!=null?_:w(cn(Ye)):null},h=(s=(i=(c=(o=(r=w(an(u)))!=null?r:w(At(l)))!=null?o:w(cn(l)))!=null?c:p())!=null?i:w(e==null?void 0:e.ssrSessionId))!=null?s:Rr();Tr(u,h,m);let E=ln(l,h),C=Nr(u),P=E?!1:Dr(l,h),f=!E&&!C&&!P;return{getSessionId:()=>h,isEphemeral:()=>f,destroy:()=>{h=null,$r(u),Br(l),Mr(l),a&&!(e!=null&&e.cookieName)&&ln(d,"1")}}}function Ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Ct(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function pn(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function _e(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let i=JSON.parse(c);return Array.isArray(i)?i:[]}catch(c){return[]}})(),o=new Map;for(let c of r)o.set(c.id,c);for(let c of e)o.set(c.id,c);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function gn(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),c=r.filter(i=>!o.has(i.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var jr=500,Gr=56*1024;function mn(e){return`_snt_retry_${e.slice(0,12)}`}var Ur={push:()=>{},flush:()=>{},destroy:()=>{}};function zr(e){var t,n,r;if(typeof window=="undefined")return Ur;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,a=e.apiKey,u=mn(a),l=[],d=new Set,m=[],w=S=>{for(let v of S)p.delete(v),!d.has(v)&&(d.add(v),m.push(v));for(;m.length>jr;){let v=m.shift();v&&d.delete(v)}gn(S,u)},p=new Set,h=()=>{for(;l.length>i;){let S=l.shift();S&&p.delete(S.id)}},E=S=>{d.has(S.id)||p.has(S.id)||(p.add(S.id),l.push(S),h())},C=S=>{for(let v of S)d.has(v.id)||(p.add(v.id),l.push(v));h()},P=pn(u,i);for(let S of P)E(S);let f=0,b=0,_=(S,v=!0)=>{if(S.length===0)return;let k=JSON.stringify(S),x=S.map(F=>F.id),I;try{I=fetch(s,{method:"POST",keepalive:!0,body:k,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(F){_e(S,i,u),C(S),b++,f=Date.now()+Ne(b);return}let ee=F=>{if(Ct(F)!=="retry"){if(!F.ok&&v){let ae=S.filter(q=>q.eventType!=="pageview");if(ae.length>0&&ae.length<S.length){w(S.filter(q=>q.eventType==="pageview").map(q=>q.id)),_(ae,!1);return}}w(x),b=0,f=0;return}_e(S,i,u),C(S),b++,f=Date.now()+Ne(b)};I instanceof Promise?I.then(ee).catch(()=>{_e(S,i,u),C(S),b++,f=Date.now()+Ne(b)}):ee(I)},K=typeof TextEncoder!="undefined"?new TextEncoder:null,A=S=>K?K.encode(S).length:S.length,D=S=>{let v=[],k=2;for(let x of S){let I=A(JSON.stringify(x))+1;if(v.length>0&&k+I>Gr||v.length>=c)break;v.push(x),k+=I}return v},G=()=>{try{if(Date.now()<f)return;for(;l.length>0&&!(Date.now()<f);){let S=l.filter(k=>!d.has(k.id));if(l.length=0,S.length===0)break;let v=D(S);if(v.length===0)break;v.length<S.length&&l.push(...S.slice(v.length)),_(v)}}catch(S){}},X=!0,M=null;M=setInterval(()=>{X&&G()},o);let j=()=>{document.visibilityState==="hidden"&&G()},se=()=>{G()};return document.addEventListener("visibilitychange",j),window.addEventListener("pagehide",se),{push(S){E(S),l.length>=c&&G()},flush:G,destroy(){X=!1,M!==null&&(clearInterval(M),M=null),document.removeEventListener("visibilitychange",j),window.removeEventListener("pagehide",se),G()}}}var Fr=200;function hn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var qr={send:()=>{},flush:()=>{},destroy:()=>{}};function Wr(e){var t,n,r;if(typeof window=="undefined")return qr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=hn(e.apiKey),a=[],u=new Set,l=new Set,d=[],m=0,w=0,p=!1,h=A=>{for(u.delete(A.id),l.has(A.id)||(l.add(A.id),d.push(A.id));d.length>Fr;){let D=d.shift();D&&l.delete(D)}gn([A.id],s)},E=A=>{_e([A],c,s),!l.has(A.id)&&!u.has(A.id)&&(u.add(A.id),a.push(A)),Date.now()>=m&&(w++,m=Date.now()+Ne(w))},C=A=>{let D;try{D=fetch(e.url,{method:"POST",keepalive:!0,body:A.body,headers:e.headers})}catch(X){E(A);return}let G=X=>{var M;let j=Ct(X);if(j==="retry"){E(A);return}j==="dropped"&&((M=e.onDrop)==null||M.call(e,A,X.status)),h(A),w=0,m=0};D instanceof Promise?D.then(G).catch(()=>E(A)):G(D)},P=()=>{try{if(p||Date.now()<m)return;let A=0;for(;a.length>0&&A<i&&!(Date.now()<m);){let D=a.shift();u.delete(D.id),!l.has(D.id)&&(A++,C(D))}}catch(A){}},f=pn(s,c);for(let A of f)u.has(A.id)||(u.add(A.id),a.push(A));f.length>0&&_e(f,c,s);let b=setInterval(P,o),_=()=>{document.visibilityState==="hidden"&&P()},K=()=>P();return document.addEventListener("visibilitychange",_),window.addEventListener("pagehide",K),{send(A){if(!p&&!(l.has(A.id)||u.has(A.id))){if(Date.now()<m){_e([A],c,s),u.add(A.id),a.push(A);return}C(A)}},flush:P,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",_),window.removeEventListener("pagehide",K),P(),p=!0}}}var Hr=1800*1e3;function Ze(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Jr(e=Hr,t){let n=new Map,r=`_snt_asgn${Xe(t)}_`,o=(a,u)=>`${r}${encodeURIComponent(a)}:${encodeURIComponent(u)}`,c=a=>{let u=a.slice(r.length),l=u.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,l)),segment:decodeURIComponent(u.slice(l+1))}}catch(d){return null}},i=()=>{try{let a=[];for(let u=0;u<localStorage.length;u++){let l=localStorage.key(u);l!=null&&l.startsWith(r)&&a.push(l)}return a}catch(a){return[]}},s=a=>a.assignedAt+(a.ttlMs&&a.ttlMs>0?a.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let a of i())try{let u=localStorage.getItem(a);if(!u)continue;let l=JSON.parse(u);if(s(l)){localStorage.removeItem(a);continue}let d=c(a);if(!d)continue;n.set(Ze(d.componentId,d.segment),l)}catch(u){}})(),{get(a,u){let l=n.get(Ze(a,u));return l?s(l)?(n.delete(Ze(a,u)),null):l:null},set(a,u,l){let d=Ze(a,u);n.set(d,l);try{localStorage.setItem(o(a,u),JSON.stringify(l))}catch(m){}},clear(){n.clear();for(let a of i())try{localStorage.removeItem(a)}catch(u){}}}}var tt="_snt_snap:",Vr=["low","medium","high"];function Be(e){try{let t=localStorage.getItem(tt+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Vr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function $e(e,t){try{localStorage.setItem(tt+e,JSON.stringify(t))}catch(n){}}var xt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",yn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",un=!1,Qe=!1;function Xr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Yr(e){var t;let n=fn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Xr(),c=Promise.resolve().then(()=>(sn(),on)).then(l=>{let d=l;return d.LOCAL_ENGINE_AVAILABLE?(un||(un=!0,console.info(yn)),d):(Qe||(Qe=!0,console.error(xt)),null)}).catch(()=>(Qe||(Qe=!0,console.error(xt)),null)),i=null,s={low:.15,medium:.5,high:.85},a=(()=>{var l;if(e.initialPersona)return O({},e.initialPersona);let d=Be(e.apiKey||"local");return d?{persona:d.persona,confidence:(l=s[d.band])!=null?l:.15}:null})();function u(l){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=l.persona,d.dataset.sentientConfidence=we(l.confidence))}return{isLocal:!0,async decide(l){var d,m,w;let p=await c;if(!p)return null;let h=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=be(O({},h),{layoutOrder:(m=(d=h.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?m:null,slots:O(O({},(w=i==null?void 0:i.slots)!=null?w:{}),h.slots)}),$e(e.apiKey||"local",{v:1,persona:i.persona,band:we(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(h),h},getSlotResult(l){var d,m,w;return(w=(m=i==null?void 0:i.slots[l])!=null?m:(d=e.initialSlots)==null?void 0:d[l])!=null?w:null},getSlotConfig(l){var d,m;return(m=(d=e.initialSlotConfig)==null?void 0:d[l])!=null?m:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:a;return l?{persona:l.persona,confidence:l.confidence,band:we(l.confidence)}:null},async assign(l,d){var m;let w=await c;return!w||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(m=w.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:d}]}).assignments[l])!=null?m:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function nt(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(nt):!1}function Ke(e,t,n,r){let o=[];{let c=!1,i=[],s=()=>{if(c)return;let a=Date.now();for(i.push(a);i.length>0&&a-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let c=!1,i=s=>{if(c||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;c=!0;let a=typeof window!="undefined"?window.getSelection():null,u=a?a.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{c||!i||(a(),s=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},l=()=>{a(),u()},d=w=>{for(let p of w)i=p.intersectionRatio>.3,i?u():a()},m=new IntersectionObserver(d,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{m.disconnect(),window.removeEventListener("scroll",l),a()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),s=()=>{if(c||document.visibilityState!=="hidden")return;let a=Date.now()-i;a<15e3&&(c=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let c of o)c()}}var vn="https://api.sentient-ui.com/v1/events",ne=new Map,bn=null;function Zr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Qr=3;function Et(){return dn()}function et(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function eo(){let e=new WeakMap,t=new Map,n=!1,r=(s,a,u)=>{let l=s.get(a);return u===null?l?!0:(s.set(a,new Set),!1):l?l.has(u)?!0:(l.add(u),!1):(s.set(a,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,a=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(a,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),a()},u.port2.postMessage(0)}};return{firedBefore(s,a){let u=c();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,a)}let l=r(t,s,a);return!l&&!n&&(n=!0,i()),l}}}var wn=new Set;function to(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let u=et();!u||u===c||(c=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let l=r[u],d=function(...m){let w=l.apply(this,m);return i(),w};r[u]=d,s.push([u,l,d])}window.addEventListener("popstate",i);let a=et();return a&&wn.has(`${t}:${a}`)?c=a:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,l,d]of s)r[u]===d&&(r[u]=l)}}}var Me={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function no(){try{return tn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Sn(e){return e.replace(/\/events\/?$/,"")}function Se(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function _t(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:bn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=ne.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:c,reinit:i}=r;if(!c){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Se())return;let s=(i!=null?i:je)(be(O({},o),{consent:!0}));c(s);let a=(t=ne.get(n))==null?void 0:t.dispose;ne.set(n,{config:be(O({},o),{consent:!0}),upgrade:null,dispose:a})}function ro(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Sn((t=e.ingestUrl)!=null?t:vn),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(l,d,m){if(!n)return Promise.resolve(null);let w=c.get(l);return w?Promise.resolve(w):kt(i,l,async()=>{try{let p=new URLSearchParams({componentId:l});for(let C of d!=null?d:[])p.append("variantIds[]",C);let h=await fetch(`${r}/winner?${p.toString()}`,{headers:o});if(!h.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let E={variantId:(await h.json()).variantId,assignmentTtlMs:0};return c.set(l,E),E}catch(p){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:l=>s.track(l),goal:((l,d,m,w)=>s.goal(l,d,m,w)),componentGoal:(l,d,m)=>s.componentGoal(l,d,m),identify:l=>s.identify(l),getAssignment:(l,d)=>s.getAssignment(l,d),assign:(l,d,m,w)=>s.assign(l,d,m,w),decide:l=>s.decide(l),getSlotResult:l=>s.getSlotResult(l),getSlotConfig:l=>s.getSlotConfig(l),getSitePalette:()=>s.getSitePalette(),reportSlots:l=>s.reportSlots(l),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function u(l){s=l}return{proxy:a,setInner:u}}function kt(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function je(e){var t,n,r,o,c,i,s,a,u,l;if(typeof window=="undefined")return Me;bn=e.apiKey||"local";let d=ne.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(g){}let m=e.respectDoNotTrack!==!1&&Se(),w=e.consent===!1||m,p=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!p&&e.localMode!==!1)return ne.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),w?Me:Yr(e);if(w){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),ne.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Me;let{proxy:g,setInner:y}=ro(e);return ne.set(e.apiKey,{config:e,upgrade:m?null:y}),g}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Me;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Me;let h=(t=e.ingestUrl)!=null?t:vn,E=Date.now(),C=fn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),P=Jr(void 0,e.apiKey),f=zr({ingestUrl:h,apiKey:e.apiKey}),b=Sn(h),_={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},K=new Set,A=Wr({url:`${b}/goals`,apiKey:e.apiKey,headers:_,onDrop:(g,y)=>{if(!e.debug){if(K.has(y))return;K.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),g)}}),D=Zt((n=navigator.userAgent)!=null?n:""),G=window.location.origin,X=Qt((r=document.referrer)!=null?r:"",G),M=(o=e.sessionSegment)!=null?o:`${D}:${X}`,j=new Map,se=new Map,S=new Map,v=new Map,k=null,x=null,I=new Set,ee=new Set,F=null,ae=g=>{for(let y of g)S.has(y.id)||S.set(y.id,St(y))};if(e.initialSlots)for(let[g,y]of Object.entries(e.initialSlots))S.set(g,y);if(e.initialSlotConfig)for(let[g,y]of Object.entries(e.initialSlotConfig))v.set(g,y);e.initialPalette&&(k=e.initialPalette);let q=Be(e.apiKey);if(q){for(let[g,y]of Object.entries(q.slots))S.has(g)||S.set(g,y);for(let[g,y]of Object.entries((c=q.slotConfig)!=null?c:{}))v.has(g)||v.set(g,y);!k&&q.palette&&(k=q.palette)}let ke={low:.15,medium:.5,high:.85};if(e.initialPersona)x=O({},e.initialPersona);else{let g=document.documentElement.dataset;g.sentientPersona?x={persona:g.sentientPersona,confidence:(s=ke[(i=g.sentientConfidence)!=null?i:"low"])!=null?s:.15}:q&&(x={persona:q.persona,confidence:(a=ke[q.band])!=null?a:.15})}if(e.initialAssignments)for(let[g,y]of Object.entries(e.initialAssignments))P.set(g,M,{variantId:y,assignedAt:Date.now(),segment:M,confidence:1});let fe=Promise.resolve(),Bt=C.getSessionId();if(Bt){let g=en((u=document.referrer)!=null?u:""),{utmParams:y,clickIds:N}=no(),te=O(O(O(O({sessionId:Bt,deviceClass:D,trafficSource:X,referrerDomain:g,utmParams:y,clickIds:N,timeOfDay:nn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:C.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Yt((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),H=async()=>{for(let L=0;;L++){try{let B=await fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(te),headers:_});if(B.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(B.ok||Ct(B)==="dropped")return}catch(B){}if(L>=Qr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(B=>setTimeout(B,Ne(L+1)))}};try{fe=H()}catch(L){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let dr=eo(),Le=null,vt=!1,Ce={goal(g,y={},N=1,te=0){var H,L,B,Y,Z,ve,pe;let Re=C.getSessionId();if(!Re)return;let Q=Zr(y)?y:{metadata:y},Te=[g,(H=Q.externalId)!=null?H:"",(L=Q.stepIndex)!=null?L:te,(B=Q.weight)!=null?B:N].join("\0"),R=Q.value!==void 0?`${Q.value}\0${(Y=Q.currency)!=null?Y:""}`:null;if(dr.firedBefore(Te,R)){e.debug&&console.log(`[sentient] goal("${g}") already recorded for this action \u2014 not sent twice`);return}let le=Et(),He={sessionId:Re,name:g,metadata:(Z=Q.metadata)!=null?Z:{},weight:(ve=Q.weight)!=null?ve:N,stepIndex:(pe=Q.stepIndex)!=null?pe:te,goalId:le,value:Q.value,currency:Q.currency,externalId:Q.externalId};e.debug&&console.log("[sentient] goal",He);let z={id:le,body:JSON.stringify(He)};fe.then(()=>A.send(z))},componentGoal(g,y,N){var te,H,L;let B=C.getSessionId();if(!B)return;let Y=P.get(g,M),Z=Y?null:(te=S.get(g))!=null?te:null;if(!Y&&Z===null){e.debug&&console.warn(`[sentient] componentGoal("${g}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let ve=Y?Y.variantId:rn(Z),pe={id:Et(),sessionId:B,projectId:e.apiKey,componentId:g,variantId:ve,eventType:"goal_achieved",goalType:y,payload:O({reward:(H=N==null?void 0:N.reward)!=null?H:1,goalValue:N==null?void 0:N.value,currency:N==null?void 0:N.currency},(L=N==null?void 0:N.metadata)!=null?L:{}),timestamp:Date.now(),timeInSession:Date.now()-E,path:et()};e.debug&&console.log("[sentient] componentGoal",pe),fe.then(()=>f.push(pe))},identify(g){let y=C.getSessionId();y&&fe.then(()=>{fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:g,ephemeral:C.isEphemeral()}),headers:_}).catch(()=>{})})},track(g){let y=C.getSessionId();if(!y)return;let N=be(O({path:et()},g),{id:Et(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-E});e.debug&&console.log("[sentient] track",N),fe.then(()=>f.push(N))},getAssignment(g,y){return P.get(g,y)},async assign(g,y,N,te){let H=C.getSessionId();if(!H)return null;let L=P.get(g,M);if(L&&(y!=null&&y.length||L.content!==void 0)){let B=L.ttlMs&&L.ttlMs>0?Math.max(0,L.assignedAt+L.ttlMs-Date.now()):0;return{variantId:L.variantId,assignmentTtlMs:B,content:L.content}}return kt(j,g,async()=>{await fe;try{let B={sessionId:H,componentId:g,variantIds:y};te!==void 0?B.agentDataByVariant=te:N!==void 0&&(B.agentData=N);let Y=await fetch(`${b}/assign`,{method:"POST",body:JSON.stringify(B),headers:_});if(!Y.ok)return null;let Z=await Y.json();return P.set(g,M,O({variantId:Z.variantId,assignedAt:Date.now(),segment:M,confidence:1,content:Z.content},Z.assignmentTtlMs&&Z.assignmentTtlMs>0?{ttlMs:Z.assignmentTtlMs}:{})),Z}catch(B){return null}})},async decide(g){var y,N;let te=C.getSessionId();if(!te)return null;let H=(y=g.slots)!=null?y:[],L={sessionId:te};g.sections&&g.sections.length>0&&(L.sections=g.sections.map(Y=>({id:Y}))),L.components=(N=g.components)!=null?N:[],H.length>0&&(L.slots=H.map(wt)),g.slotsFrom==="registry"&&(L.slotsFrom="registry"),g.v&&(L.v=g.v),typeof g.pp=="number"&&(L.pp=g.pp),e.persona&&(L.persona=e.persona);let B=JSON.stringify(L);return kt(se,B,async()=>{var Y,Z,ve,pe,Re,Q;await fe;try{let Te=await fetch(`${b}/decide`,{method:"POST",body:B,headers:_});if(!Te.ok)return ae(H),null;let R=await Te.json(),le={};for(let z of H){let re=(Y=R.slots)==null?void 0:Y[z.id];if(re!==void 0){le[z.id]=re,S.set(z.id,re);continue}let $t=S.get(z.id);if($t!==void 0)le[z.id]=$t;else{let Kt=St(z);le[z.id]=Kt,S.set(z.id,Kt)}}if(R.slots)for(let[z,re]of Object.entries(R.slots))z in le||(le[z]=re,S.set(z,re));let He=x!=null&&x.persona!=="unknown";R.persona&&!(R.persona==="unknown"&&He)?x={persona:R.persona,confidence:(Z=R.confidence)!=null?Z:0}:x||(x={persona:"unknown",confidence:0});for(let[z,re]of Object.entries((ve=R.assignments)!=null?ve:{}))P.set(z,M,{variantId:re,assignedAt:Date.now(),segment:M,confidence:1});if(R.slotConfig)for(let[z,re]of Object.entries(R.slotConfig))v.set(z,re);return R.palette&&(k=R.palette),$e(e.apiKey,O(O({v:1,persona:x.persona,band:we(x.confidence),slots:Object.fromEntries(S),layoutOrder:(pe=R.layoutOrder)!=null?pe:null,savedAt:Date.now()},v.size>0?{slotConfig:Object.fromEntries(v)}:{}),k?{palette:k}:{})),O(O(O(O({layoutOrder:(Re=R.layoutOrder)!=null?Re:null,assignments:(Q=R.assignments)!=null?Q:{},slots:le,persona:x.persona,confidence:x.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{}),R.sectionMap?{sectionMap:R.sectionMap}:{}),R.palette?{palette:R.palette}:{})}catch(Te){return ae(H),null}})},getSlotResult(g){var y;return(y=S.get(g))!=null?y:null},getSlotConfig(g){var y;return(y=v.get(g))!=null?y:null},reportSlots(g){for(let y of g)typeof y=="string"&&y.length>0&&!I.has(y)&&(I.add(y),ee.add(y));ee.size===0||F!=null||(F=setTimeout(()=>{F=null;let y=[...ee].slice(0,20);ee.clear(),y.length!==0&&fetch(`${b}/slots/observed`,{method:"POST",headers:_,body:JSON.stringify({slotIds:y})}).catch(()=>{})},1e3))},getSitePalette(){return k},getPersona(){return x?{persona:x.persona,confidence:x.confidence,band:we(x.confidence)}:null},async fetchWeights(){var g;try{let y=await fetch(`${b}/weights`,{headers:_});return y.ok?(g=(await y.json()).components)!=null?g:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var g;Le==null||Le(),vt=!0,f.destroy(),A.destroy(),((g=ne.get(e.apiKey))==null?void 0:g.dispose)===Ce.dispose&&ne.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var g;Le==null||Le(),vt=!0,f.destroy(),A.destroy(),C.destroy(),P.clear(),((g=ne.get(e.apiKey))==null?void 0:g.dispose)===Ce.dispose&&ne.delete(e.apiKey);try{localStorage.removeItem(tt+e.apiKey),localStorage.removeItem(mn(e.apiKey)),localStorage.removeItem(hn(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(ne.set(e.apiKey,{config:e,upgrade:null,dispose:Ce.dispose}),Le=to(Ce,e.apiKey,g=>{fe.then(()=>{vt||wn.add(g)})}),e.debug){let g=window;g.__sentient&&(g.__sentient.client=Ce)}return Ce}var oo=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function It(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function io(e){return{tag:e.tagName.toLowerCase(),text:It(e).slice(0,40)}}function An(e){return e.replace(/["\\\]]/g,"\\$&")}function Ge(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function En(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),c=[r,...o.map(s=>`${r}.${s}`)];for(let s of c)if(Ge(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=En(i,t);if(s){for(let d of c){let m=`${s} > ${d}`;if(Ge(t,m))return m}let a=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=a.indexOf(e),l=a.some(d=>d!==e&&It(d)!==It(e));if(u>=0&&l){let d=`${s} > ${r}:nth-of-type(${u+1})`;if(Ge(t,d))return d}}}return null}function xn(e,t){let n=io(e),r=e.getAttribute("id");if(r&&Ge(t,`#${An(r)}`))return{v:1,id:r,fingerprint:n};for(let c of oo){let i=e.getAttribute(c);if(i&&Ge(t,`[${c}="${An(i)}"]`))return{v:1,dataAttr:{name:c,value:i},fingerprint:n}}let o=En(e,t);return o?{v:1,selector:o,fingerprint:n}:null}De();var Cn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],so={banner:"hero",navigation:"navigation",contentinfo:"footer"};function ao(e){let t=e.ariaRole?so[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function lo(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var co=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],Ot=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],kn={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function uo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function _n(e){var t,n;let r=ao(e);if(r)return{type:(t=kn[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of co)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of Ot)if(s.test(e.bodyText))return{type:i,strength:"strong"};let c=lo(e);return{type:(n=kn[c])!=null?n:"generic",strength:"weak"}}function In(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return O({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:uo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}De();var fo="section, header, footer, nav, main > div, [data-sentient-section]",po=2e4;function go(e){let t=Array.from(e.querySelectorAll(fo)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function mo(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var On=()=>{};function Pn(e,t){var n,r,o,c,i,s,a,u,l,d,m,w;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||Se()||!t.apiKey||!t.apiKey.startsWith("pk_"))return On;let h=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),E=go(p);if(E.length===0)return On;let C=new Map,P=[];for(let v of E){let k=v.getAttribute("data-sentient-type"),x=k&&Cn.includes(k)?k:null,I=In(v),ee=(c=x!=null?x:(o=t.typeOf)==null?void 0:o.call(t,v))!=null?c:_n(I).type,F=xn(v,p),ae=F?`nc-${ee}-${Vt(JSON.stringify({id:(i=F.id)!=null?i:null,dataAttr:(s=F.dataAttr)!=null?s:null,selector:(a=F.selector)!=null?a:null})).toString(36)}`:`nc-${ee}`;C.set(v,ae);let q=Ot.filter(([,ke])=>ke.test(I.bodyText)).map(([ke])=>ke);P.push(be(O({componentId:ae,semanticType:ee,source:x?"markup":"auto"},F?{locator:F}:{}),{observation:O(O({tag:I.tag,idClass:I.idClass.slice(0,200),headingText:I.headingText,textLength:I.textLength,actionCount:I.actionCount},I.ariaRole?{ariaRole:I.ariaRole}:{}),q.length>0?{patternFlags:q}:{})}))}let f=(m=(d=(l=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:d.pathname)!=null?m:"/";mo(t.apiKey,h,f,P);let b=new Map,_=v=>{let k=b.get(v);return k||(k={ms:0,scroll:0,enterAt:null,intersecting:!1},b.set(v,k)),k},K=new IntersectionObserver(v=>{for(let k of v){let x=C.get(k.target);if(!x)continue;let I=_(x);k.isIntersecting?(I.intersecting=!0,I.enterAt=Date.now(),k.intersectionRatio>I.scroll&&(I.scroll=k.intersectionRatio)):(I.intersecting=!1,I.enterAt!=null&&(I.ms+=Date.now()-I.enterAt,I.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let v of C.keys())K.observe(v);let A=()=>{let v=Date.now();for(let[k,x]of b)if(x.enterAt!=null&&(x.ms+=v-x.enterAt,x.enterAt=null),!(x.ms<=0)){try{e.track({projectId:t.apiKey,componentId:k,eventType:"dwell",payload:{dwell_time:Math.round(x.ms),scroll_depth:Number(x.scroll.toFixed(2))}})}catch(I){}x.ms=0}},D=()=>{if(p.hidden)A();else{let v=Date.now();for(let k of b.values())k.intersecting&&(k.enterAt=v)}},G=!1,X=v=>{if(A(),v!=null&&v.persisted){G=!0;return}try{K.disconnect()}catch(k){}},M=v=>{if(!(v!=null&&v.persisted)||!G)return;G=!1;let k=Date.now();for(let x of b.values())x.enterAt=x.intersecting&&!p.hidden?k:null};p.addEventListener("visibilitychange",D);let j=(w=p.defaultView)!=null?w:typeof window!="undefined"?window:void 0;j==null||j.addEventListener("pagehide",X),j==null||j.addEventListener("pageshow",M);let se=setInterval(()=>{if(p.hidden||G)return;A();let v=Date.now();for(let k of b.values())k.intersecting&&(k.enterAt=v)},po),S=[];return t.microSignals&&[...C.entries()].forEach(([v,k],x)=>{S.push(Ke((I,ee={})=>{try{e.track({projectId:t.apiKey,componentId:k,eventType:"micro_signal",payload:O({signalType:I},ee)})}catch(F){}},v,void 0,{tabLoss:x===0}))}),()=>{A(),clearInterval(se),p.removeEventListener("visibilitychange",D),j==null||j.removeEventListener("pagehide",X),j==null||j.removeEventListener("pageshow",M);for(let v of S)v();try{K.disconnect()}catch(v){}}}var ho=["landing","ecommerce","saas","marketplace"];function yo(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(c=>typeof c=="string"))return null;n[r]=o}return n}function vo(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function bo(e){try{return e()}catch(t){return}}function rt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=ho.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let a=s,u=yo(a.dims);if(!u||a.target!==void 0&&typeof a.target!="string")continue;let l=a.arms!==void 0?vo(a.arms):null,d={dims:u};typeof a.target=="string"&&(d.target=a.target),l&&(d.arms=l),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?bo(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),Array.isArray(t.sections)){let i=t.sections.filter(s=>typeof s=="string"&&s.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function ot(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function wo(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim().toLowerCase(),o=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Ln(e,t){return!!(e!=null&&e.urlMatch)&&!ot(t).includes(e.urlMatch)}var So=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ge(e,t){var o;if(e.urlMatch&&!ot(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&So.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!wo(r,e.fingerprint)?null:r}var Rn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Ao=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Tn(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Ao.test((r=n[1])!=null?r:""))return!1;return!0}var Dn=/^https:\/\//i,Mn=new Map,me=null;function Eo(e){return e.replace(/["\\]/g,"\\$&")}function xo(e){var t;(!me||!me.isConnected)&&(me=e.querySelector("style[data-sentient-ops]"),me||(me=e.createElement("style"),me.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(me))),me.textContent=[...Mn.entries()].map(([n,r])=>`[data-snt-e="${Eo(n)}"]{${r}}`).join(`
|
|
2
|
-
`)}function Nn(e,t,n,r){var s;let o=!1,c=(s=t.moveBefore)!=null?s:t.moveAfter;if(c){let a=ge(c,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Dn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Dn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[a,u]of Object.entries(t.style)){let l=Rn[a];l&&typeof u=="string"&&Tn(u)&&i.push(`${l}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Mn.set(n,i.join(";")),xo(r)),{anchorMiss:o}}var Ue="data-sentient-block-arm",oe=null;function ze(e){oe=e!=null?e:null}var ue="data-sentient-blocks-hid",it={none:"0",sm:"8px",md:"16px",lg:"24px"},Pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Bn={sm:"0.875em",md:"1em",lg:"1.25em"},ko={sm:"1.25em",md:"1.5em",lg:"2em"},Co={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},_o={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Io={normal:"400",medium:"500",bold:"700"};function ce(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Kn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function jn(e,t){var n,r,o,c,i,s,a,u,l,d,m,w;try{switch(e.type){case"stack":case"grid":{let p=t.createElement("div");if(e.type==="stack"){let h=e;ce(p,{display:"flex","flex-direction":h.direction,gap:(r=it[(n=h.gap)!=null?n:"md"])!=null?r:it.md,"align-items":h.align?Pt[h.align]:void 0,"justify-content":h.justify?Pt[h.justify]:void 0,"flex-wrap":h.wrap?"wrap":void 0})}else{let h=e,E=(c=it[(o=h.gap)!=null?o:"md"])!=null?c:it.md;ce(p,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${h.columns-1} * ${E}) / ${h.columns})), 1fr))`,gap:E,"align-items":h.align?Pt[h.align]:void 0})}for(let h of(i=e.children)!=null?i:[]){let E=jn(h,t);E&&p.appendChild(E)}return p}case"text":{let p=t.createElement("p");return p.textContent=e.value,ce(p,J({margin:"0","font-size":e.size?Bn[e.size]:void 0,"font-weight":e.weight?Io[e.weight]:void 0,"text-align":e.align},Kn(e.tone)))}case"heading":{let p=t.createElement(`h${e.level}`);return p.textContent=e.value,ce(p,{margin:"0","font-size":ko[(s=e.size)!=null?s:"md"],"text-align":e.align})}case"button":{let p=t.createElement("a");p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag);let h=(a=e.emphasis)!=null?a:"primary";return ce(p,{display:"inline-block",padding:Co[(u=e.size)!=null?u:"md"],"border-radius":(l=oe==null?void 0:oe.radius)!=null?l:"8px",font:"inherit","font-size":e.size?Bn[e.size]:void 0,"text-decoration":h==="ghost"?"underline":"none",cursor:"pointer",background:h==="primary"?(d=oe==null?void 0:oe.primaryBg)!=null?d:"#111827":"transparent",color:h==="primary"?(m=oe==null?void 0:oe.primaryText)!=null?m:"#ffffff":"inherit",border:h==="secondary"?"1px solid currentColor":"none"})}case"link":{let p=t.createElement("a");return p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag),ce(p,{color:"inherit","text-decoration":"underline"})}case"image":{let p=t.createElement("img");return p.src=e.src,p.alt=e.alt,ce(p,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?_o[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let p=t.createElement("span");return p.textContent=e.value,ce(p,J({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},Kn(e.tone)))}case"spacer":return ce(t.createElement("div"),{height:(w=$n[e.size])!=null?w:$n.md});default:return null}}catch(p){return null}}function Gn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Ue);s!==null&&(t[s]===void 0?i.remove():o.add(s))}for(let[i,s]of Object.entries(t)){if(o.has(i))continue;let a=jn(s,r);if(!a)continue;let u=r.createElement("div");u.setAttribute(Ue,i),u.style.display="none",u.appendChild(a),e.appendChild(u)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Ue),a=i;s!==null?a.style.display=c&&s===n?"":"none":c?a.hasAttribute(ue)||(a.setAttribute(ue,a.style.display),a.style.display="none"):a.hasAttribute(ue)&&(a.style.display=a.getAttribute(ue),a.removeAttribute(ue))}}catch(o){}}function Oo(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ue)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function st(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ue}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ue}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||Oo(r)}catch(n){}}function Lt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function at(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function lt(e,t,n,r){var o;for(let[c,i]of Object.entries(t)){let s=e[c];if(!s||typeof s=="string")continue;let a=Lt(i.target,n);for(let u of a)for(let[l,d]of Object.entries(s))(o=i.dims[l])!=null&&o.includes(d)&&(u.setAttribute(`data-${l}`,d),r==null||r(u,`data-${l}`))}}function ct(e,t,n,r){for(let[o,c]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!c.arms||!c.arms.includes(i))continue;let s=Lt(c.target,n);for(let a of s)a.setAttribute("data-sentient-arm",i),r==null||r(a,"data-sentient-arm")}}function ut(e,t,n,r){var s,a,u,l;let o=new Set,c=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[d,m]of Object.entries(t)){if(Ln(m.locator,n))continue;let w;if(m.locator){let h=ge(m.locator,n);w=h?[h]:[]}else w=Lt(m.target,n);(m.locator||m.target)&&w.length===0&&i.push(d);let p=e[d];for(let h of w){if(p!==void 0)if(typeof p=="string")h.setAttribute("data-sentient-arm",p),(a=r==null?void 0:r.onAttr)==null||a.call(r,h,"data-sentient-arm"),c&&((u=r==null?void 0:r.onApplied)==null||u.call(r,d,p,h));else for(let[E,C]of Object.entries(p))h.setAttribute(`data-${E}`,C),(l=r==null?void 0:r.onAttr)==null||l.call(r,h,`data-${E}`);if(m.blocks&&!Lo(n)){let E=Object.fromEntries(Object.entries(m.blocks).filter(([,C])=>!nt(C)));Object.keys(E).length>0&&(Gn(h,E,typeof p=="string"?p:void 0,n),o.add(h))}c&&(typeof m.content=="string"&&(h.textContent=m.content),m.ops&&Nn(h,m.ops,d,n).anchorMiss&&!i.includes(d)&&i.push(d))}}return st(n,o),i}var Po=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Lo(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:Po.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var Ro=800;function dt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},s)=>{r.push(Ke((m,w={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:J({signalType:m},w)})}catch(p){}},i,void 0,{tabLoss:s===0}));let a=null,u=0,l=()=>{u=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(m){}a=null},Ro)},d=()=>{a!==null&&(clearTimeout(a),a=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",d),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function To(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function zn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var Do="_snt_fired_goals";function Fn(e,t){try{e==null||e.sessionStorage.removeItem(zn(t)),e==null||e.sessionStorage.removeItem(Do)}catch(n){}}function Un(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Mo(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function No(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function ft(e,t,n,r){var C,P;let o=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,c=zn(r),i=Mo(o,c),s=f=>{let b=Un(f);if(!i.has(b))try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId),i.add(b),No(o,c,i)}catch(_){}},a=e.filter(f=>f.event==="click"),u=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),d=e.filter(f=>f.event==="scroll_depth"),m=(f,b)=>{if(!f.locator)return!1;let _=ge(f.locator,n);return!!_&&(_===b||_.contains(b))},w=f=>{let b=f.target;if(!(!b||typeof b.closest!="function"))for(let _ of a)m(_,b)&&s(_)},p=f=>{let b=f.target;if(b)for(let _ of u)m(_,b)&&s(_)},h=()=>{if(l.length===0)return;let f=ot(n);for(let b of l)b.urlPattern&&To(b.urlPattern,f)&&s(b)},E=()=>{var _;let f=n.documentElement,b=f.scrollHeight>0?(f.scrollTop+f.clientHeight)/f.scrollHeight:0;for(let K of d)b>=((_=K.threshold)!=null?_:.75)&&s(K);d.every(K=>i.has(Un(K)))&&n.removeEventListener("scroll",E)};return n.addEventListener("click",w,!0),n.addEventListener("submit",p,!0),(P=n.defaultView)==null||P.addEventListener("popstate",h),h(),d.length>0&&(n.addEventListener("scroll",E,{passive:!0}),E()),{checkUrl:h,teardown:()=>{var f;n.removeEventListener("click",w,!0),n.removeEventListener("submit",p,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",h),d.length>0&&n.removeEventListener("scroll",E)}}}function pt(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),c=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(c.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return c}var qn="__snt_editor_token";function Wn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(qn):null}catch(e){return null}}function Hn(e){try{sessionStorage.setItem(qn,e)}catch(t){}}var We="0.24.1",ht=We!=="0.0.0-dev"?{name:"snippet",version:We}:void 0,tr=5e3,Bo=50,nr=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),V=null,T=null,de={},ye=null,U=null,he=null,W=null,ie=null,$=null,Ae=null,Jn=!1,Rt=null,gt=null,yt=null,Ie=!1,Fe=!1,xe=!1;function rr(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function Ee(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Oe(e,t){return V?(V.personaAttributes&&$&&at($.persona,$.band,e,t==null?void 0:t.onAttr),lt(de,V.slots,e,t==null?void 0:t.onAttr),ct(de,V.slots,e,t==null?void 0:t.onAttr),ye?ut(de,ye,e,t):(st(e,new Set),[])):[]}function or(e){var n;let t=new Map;for(let r of(n=V==null?void 0:V.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Tt(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=pt(e,or(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function $o(e,t,n){let r=(o,c)=>t.some(([i,s])=>i===o&&s===c);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[c,i,s]=o;!c||typeof i!="string"||r(c,i)||(s==null?c.removeAttribute(i):c.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function Ko(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function ir(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function jo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Pe(){return!!(V&&T&&V.sectionCapture!==!1&&(V.consent!==!1||Fe)&&!Se())}function Go(){if(!T||!V||!Pe()||ie)return;let e=[];Oe(document,{contentAndOps:Ie,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Mt();try{W==null||W(),W=dt(T,V.apiKey,e)}catch(t){}}function Mt(){if(typeof document=="undefined"||!Pe())return;let e;try{if(gt&>.length>0){let t=new Map;for(let n of gt){if(n.urlMatch!==window.location.pathname)continue;let r=ge(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ie=Pn(T,J({apiKey:V.apiKey,apiBase:V.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),yt=window.location.pathname}catch(t){}}function Nt(){try{let e=[];if(W==null||W(),W=null,Oe(document,{contentAndOps:Ie,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Tt(Ae,document),e.length>0&&Pe())try{W=dt(T,V.apiKey,e)}catch(t){}try{typeof window!="undefined"&&yt!==null&&window.location.pathname!==yt&&Pe()&&(ie==null||ie(),ie=null,Mt())}catch(t){}}catch(e){}}function Vn(){Rt===null&&(Rt=setTimeout(()=>{Rt=null,Nt();try{U==null||U.checkUrl()}catch(e){}},Bo))}function Dt(){if(!(Jn||typeof window=="undefined"||typeof history=="undefined")){Jn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,c){let i=n.call(this,r,o,c!=null?c:null);return Vn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Vn)}catch(e){}}}function mt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function sr(e){return new URLSearchParams(e).get("sentient_editor")}function Uo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function zo(e,t){var n,r,o,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let a=document.createElement("meta");a.name="referrer",a.content="no-referrer",a.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let i=(o=e.editorSrc)!=null?o:Uo();if(!i){Yn();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>Yn(),((c=document.head)!=null?c:document.documentElement).appendChild(s)}catch(i){}}var Xn="sentient-editor-load-notice",ar={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Yn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Xn))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Xn,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,ar,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function lr(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),c=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!c||!i))if(i.includes("=")){let s={};for(let a of i.split(",")){let[u,l]=a.split("=");u&&l&&(s[u]=l)}Object.keys(s).length&&(n[c]=s)}else n[c]=i}return Object.keys(n).length?n:null}function cr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Zn="sentient-persona-preview-banner";function Qn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Zn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Zn,o.setAttribute("role","status"),Object.assign(o.style,ar,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Fo(e,t){var u,l,d,m,w,p,h,E,C,P;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((l=e.registry)!=null?l:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,b])=>({id:f,dims:b.dims}))},c=await rr(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(f=>f.ok?f.json():null).catch(()=>null),tr);if(!c){qe(e),Ee(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;de=(d=i.slots)!=null?d:{},ye=(m=i.slotConfig)!=null?m:null,ze(i.palette);let s=(h=(p=(w=i.personaAttributes)==null?void 0:w.persona)!=null?p:i.persona)!=null?h:t,a=(C=(E=i.personaAttributes)==null?void 0:E.confidence)!=null?C:"high";$={persona:s,band:a},Oe(document),Ie=!0,Dt(),qe(e),i.recognized===!1?Qn(t,!0):Qn((P=i.personaDisplay)!=null?P:s)}function qe(e){let t={goal(n,r){try{T==null||T.goal(n,r)}catch(o){}},componentGoal(n,r){try{T==null||T.componentGoal(n,r)}catch(o){}},grantConsent(){try{!T&&xe?(T=je(J({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:ir(e)},ht?{sdk:ht}:{})),he&&he.length>0&&(U==null||U.teardown(),U=ft(he,T,document,e.apiKey))):(_t(e.apiKey),T&&he&&he.length>0&&(U==null||U.teardown(),U=ft(he,T,document,e.apiKey))),xe=!1}catch(n){}Fe=!0;try{Go()}catch(n){}},revokeConsent(){try{ie==null||ie(),ie=null,yt=null,W==null||W(),W=null,U==null||U.teardown(),U=null,Fn(typeof window!="undefined"?window:null,e.apiKey),Fe=!1,xe=!0,T==null||T.destroy(),T=null}catch(n){}},reapply:Nt,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=$==null?void 0:$.persona)!=null?n:null,band:(r=$==null?void 0:$.band)!=null?r:null,slots:de,matchCounts:mt(e),consent:!xe&&(e.consent!==!1||Fe)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of nr.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function er(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},nr.length=0}catch(t){}}async function ur(){var e,t;try{let n=rt(window.sentient);if(!n){er();return}V=n,Ie=!1,Ae=null,ze(null),Fe=!1,xe=!1,he=null;let r=typeof window!="undefined"?sr(window.location.search):null;if(r){Hn(r);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let o=r!=null?r:Wn();if(o){zo(n,o),qe(n),Ee(n,"editor mode");return}let c=typeof window!="undefined"?lr(window.location.search):null;if(c){de=c,$=null,Oe(document),Dt(),qe(n),Ee(n,"preview mode",c);return}let i=typeof window!="undefined"?cr(window.location.search):null;if(i){await Fo(n,i),Ee(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0,a=Ko();try{(t=a==null?void 0:a.stop)==null||t.call(a)}catch(f){}let u=Be(n.apiKey),l=[];u&&($={persona:u.persona,band:u.band},de=u.slots,u.slotConfig&&(ye=u.slotConfig),u.palette&&ze(u.palette),Oe(document,J({contentAndOps:!1},a?{onAttr:(f,b)=>l.push([f,b])}:{})),u.layoutOrder&&(Ae=u.layoutOrder,Tt(Ae,document))),a&&$o(a,l,document);let d=je(J({apiKey:n.apiKey,context:n.context,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:ir(n)},ht?{sdk:ht}:{}));T=d,qe(n),Dt();let m=Object.entries(n.slots).map(([f,b])=>({id:f,dims:b.dims})),w=We!=="0.0.0-dev"?{v:We}:{},p={pp:a?a.v:0},h=Array.from(or(document).keys()),E=d.decide(J(J(J(J({slots:m},w),p),h.length>=2?{sections:h}:{}),s?{slotsFrom:"registry"}:{})),C=await rr(E,tr),P=f=>{var K,A,D,G,X,M;let b=d.getPersona();b?$={persona:b.persona,band:b.band}:f.persona&&($={persona:f.persona,band:"low"}),de=f.slots,s?ye=(K=f.slotConfig)!=null?K:null:f.slotConfig&&(ye=f.slotConfig),f.palette&&ze(f.palette),Ae=(A=f.layoutOrder)!=null?A:Ae;let _=()=>{let j=[];if(jo(n,Oe(document,{onApplied:(se,S,v)=>j.push({slotId:se,arm:S,el:v})})),Tt(Ae,document),Ie=!0,Pe())try{W==null||W(),W=dt(T,n.apiKey,j)}catch(se){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_,{once:!0}):_(),he=(D=f.goals)!=null?D:null,f.goals&&f.goals.length>0&&n.consent!==!1&&T)try{U==null||U.teardown(),U=ft(f.goals,T,document,n.apiKey)}catch(j){}gt=(G=f.sectionMap)!=null?G:null,Pe()&&Mt(),Ee(n,"applied",{persona:$,slots:de,matches:mt(n)}),!xe&&$e(n.apiKey,J(J({v:1,persona:(X=$==null?void 0:$.persona)!=null?X:f.persona,band:(M=$==null?void 0:$.band)!=null?M:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ye?{slotConfig:ye}:{}),f.palette?{palette:f.palette}:{}))};if(!C){Ee(n,"decide timeout/null \u2014 snapshot state stands",mt(n)),E.then(f=>{!f||Ie||xe||T!==d||(P(f),Ee(n,"late decide applied",mt(n)))}).catch(()=>{});return}P(C)}catch(n){er()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{ur()}))}return hr(qo);})();
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var Xe=Object.defineProperty,hr=Object.defineProperties,yr=Object.getOwnPropertyDescriptor,vr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertyNames,zt=Object.getOwnPropertySymbols;var qt=Object.prototype.hasOwnProperty,wr=Object.prototype.propertyIsEnumerable;var Ft=(e,t,n)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))qt.call(t,n)&&Ft(e,n,t[n]);if(zt)for(var n of zt(t))wr.call(t,n)&&Ft(e,n,t[n]);return e},Wt=(e,t)=>hr(e,vr(t));var Ht=(e,t)=>()=>(e&&(t=e(e=0)),t);var Jt=(e,t)=>{for(var n in t)Xe(e,n,{get:t[n],enumerable:!0})},Sr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of br(t))!qt.call(e,o)&&o!==n&&Xe(e,o,{get:()=>t[o],enumerable:!(r=yr(t,o))||r.enumerable});return e};var Ar=e=>Sr(Xe({},"__esModule",{value:!0}),e);var Er,kr,xr,Vt,_r,Cr,Xt,T,we,Be=Ht(()=>{"use strict";Er=Object.defineProperty,kr=Object.defineProperties,xr=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,_r=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,Xt=(e,t,n)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))_r.call(t,n)&&Xt(e,n,t[n]);if(Vt)for(var n of Vt(t))Cr.call(t,n)&&Xt(e,n,t[n]);return e},we=(e,t)=>kr(e,xr(t))});var cn={};Jt(cn,{LOCAL_ENGINE_AVAILABLE:()=>Dr,createLocalEngine:()=>Mr});function Mr(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Dr,un=Ht(()=>{"use strict";Dr=!1});var Zo={};Jt(Zo,{applyPersonaAttributes:()=>lt,applyRegistrySlots:()=>dt,applySlotArms:()=>ut,applySlotAttributes:()=>ct,parseEditorToken:()=>ur,parsePersonaPreview:()=>pr,parsePreview:()=>fr,parseSnippetConfig:()=>it,planReorder:()=>gt,reapply:()=>$t,run:()=>gr,version:()=>Je});Be();var Or=["buyer","researcher","deal_seeker","browser"];var Ir={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Ye(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Yt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function wt(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Ye(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[c,i]of Object.entries((n=e.dims)!=null?n:{}))o[c]=(r=i[0])!=null?r:"";return Ye(o)}function Zt(e,t){var n,r;return e.dims!=null?(r=(n=Yt(t))!=null?n:Yt(wt(e)))!=null?r:{}:t}function Qt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function Se(e){return e>=.3?e<.7?"medium":"high":"low"}var ti=Or.map(e=>({key:e,displayName:Ir[e]}));function Ze(e){return e?`_${e.slice(0,12)}`:""}var Lr="_snt_uid";function en(e){return`${Lr}${Ze(e)}`}var Pr=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function tn(e){return Rr(e)!==null}function Rr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Pr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function nn(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function rn(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function on(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Tr=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function sn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,c])=>{let i=Array.isArray(c)?c[0]:c;return i===void 0?[]:[[o,i]]});for(let[o,c]of r)o.startsWith("utm_")?o in t||(t[o]=c):Tr.includes(o)&&(o in n||(n[o]=c))}catch(r){}return{utmParams:t,clickIds:n}}function an(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function St(e){return T(T(T({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function At(e){let t=St(e);return Zt(t,wt(t))}function ln(e){return typeof e=="string"?e:Ye(e)}Be();function mn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Br="_snt_uid",$r=365,Qe="_snt_uid";function Nr(){return mn()}function dn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Kr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Et(e){try{return localStorage.getItem(e)}catch(t){return null}}function fn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function pn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function jr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Gr(e){try{sessionStorage.removeItem(e)}catch(t){}}function Ur(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function zr(e){try{localStorage.removeItem(e)}catch(t){}}function Fr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var qr={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function hn(e){var t,n,r,o,c,i,s;if(typeof window=="undefined")return qr;let a=Ze(e==null?void 0:e.apiKey),d=(t=e==null?void 0:e.cookieName)!=null?t:en(e==null?void 0:e.apiKey),l=`${Qe}${a}`,u=`${Qe}_tomb${a}`,g=((n=e==null?void 0:e.cookieTTLDays)!=null?n:$r)*24*60*60,v=m=>m&&m.length>0?m:null,S=()=>{var m,I;return a&&!(e!=null&&e.cookieName)&&Et(u)===null?(I=(m=v(dn(Br)))!=null?m:v(Et(Qe)))!=null?I:v(pn(Qe)):null},A=(s=(i=(c=(o=(r=v(dn(d)))!=null?r:v(Et(l)))!=null?o:v(pn(l)))!=null?c:S())!=null?i:v(e==null?void 0:e.ssrSessionId))!=null?s:Nr();Kr(d,A,g);let O=fn(l,A),x=Ur(d),D=O?!1:jr(l,A),f=!O&&!x&&!D;return{getSessionId:()=>A,isEphemeral:()=>f,destroy:()=>{A=null,Fr(d),zr(l),Gr(l),a&&!(e!=null&&e.cookieName)&&fn(u,"1")}}}function Ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Ct(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function yn(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function Oe(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let i=JSON.parse(c);return Array.isArray(i)?i:[]}catch(c){return[]}})(),o=new Map;for(let c of r)o.set(c.id,c);for(let c of e)o.set(c.id,c);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function vn(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),c=r.filter(i=>!o.has(i.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var Wr=500,Hr=56*1024;function bn(e){return`_snt_retry_${e.slice(0,12)}`}var Jr={push:()=>{},flush:()=>{},destroy:()=>{}};function Vr(e){var t,n,r;if(typeof window=="undefined")return Jr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,a=e.apiKey,d=bn(a),l=[],u=new Set,g=[],v=b=>{for(let h of b)S.delete(h),!u.has(h)&&(u.add(h),g.push(h));for(;g.length>Wr;){let h=g.shift();h&&u.delete(h)}vn(b,d)},S=new Set,A=()=>{for(;l.length>i;){let b=l.shift();b&&S.delete(b.id)}},O=b=>{u.has(b.id)||S.has(b.id)||(S.add(b.id),l.push(b),A())},x=b=>{for(let h of b)u.has(h.id)||(S.add(h.id),l.push(h));A()},D=yn(d,i);for(let b of D)O(b);let f=0,m=0,I=(b,h=!0)=>{if(b.length===0)return;let C=JSON.stringify(b),_=b.map(V=>V.id),R;try{R=fetch(s,{method:"POST",keepalive:!0,body:C,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(V){Oe(b,i,d),x(b),m++,f=Date.now()+Ne(m);return}let te=V=>{if(Ct(V)!=="retry"){if(!V.ok&&h){let oe=b.filter(ie=>ie.eventType!=="pageview");if(oe.length>0&&oe.length<b.length){v(b.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),I(oe,!1);return}}v(_),m=0,f=0;return}Oe(b,i,d),x(b),m++,f=Date.now()+Ne(m)};R instanceof Promise?R.then(te).catch(()=>{Oe(b,i,d),x(b),m++,f=Date.now()+Ne(m)}):te(R)},E=typeof TextEncoder!="undefined"?new TextEncoder:null,w=b=>E?E.encode(b).length:b.length,$=b=>{let h=[],C=2;for(let _ of b){let R=w(JSON.stringify(_))+1;if(h.length>0&&C+R>Hr||h.length>=c)break;h.push(_),C+=R}return h},P=()=>{try{if(Date.now()<f)return;for(;l.length>0&&!(Date.now()<f);){let b=l.filter(C=>!u.has(C.id));if(l.length=0,b.length===0)break;let h=$(b);if(h.length===0)break;h.length<b.length&&l.push(...b.slice(h.length)),I(h)}}catch(b){}},U=!0,j=null;j=setInterval(()=>{U&&P()},o);let q=()=>{document.visibilityState==="hidden"&&P()},le=()=>{P()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",le),{push(b){O(b),l.length>=c&&P()},flush:P,destroy(){U=!1,j!==null&&(clearInterval(j),j=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",le),P()}}}var Xr=200;function wn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Yr={send:()=>{},flush:()=>{},destroy:()=>{}};function Zr(e){var t,n,r;if(typeof window=="undefined")return Yr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=wn(e.apiKey),a=[],d=new Set,l=new Set,u=[],g=0,v=0,S=!1,A=w=>{for(d.delete(w.id),l.has(w.id)||(l.add(w.id),u.push(w.id));u.length>Xr;){let $=u.shift();$&&l.delete($)}vn([w.id],s)},O=w=>{Oe([w],c,s),!l.has(w.id)&&!d.has(w.id)&&(d.add(w.id),a.push(w)),Date.now()>=g&&(v++,g=Date.now()+Ne(v))},x=w=>{let $;try{$=fetch(e.url,{method:"POST",keepalive:!0,body:w.body,headers:e.headers})}catch(U){O(w);return}let P=U=>{var j;let q=Ct(U);if(q==="retry"){O(w);return}q==="dropped"&&((j=e.onDrop)==null||j.call(e,w,U.status)),A(w),v=0,g=0};$ instanceof Promise?$.then(P).catch(()=>O(w)):P($)},D=()=>{try{if(S||Date.now()<g)return;let w=0;for(;a.length>0&&w<i&&!(Date.now()<g);){let $=a.shift();d.delete($.id),!l.has($.id)&&(w++,x($))}}catch(w){}},f=yn(s,c);for(let w of f)d.has(w.id)||(d.add(w.id),a.push(w));f.length>0&&Oe(f,c,s);let m=setInterval(D,o),I=()=>{document.visibilityState==="hidden"&&D()},E=()=>D();return document.addEventListener("visibilitychange",I),window.addEventListener("pagehide",E),{send(w){if(!S&&!(l.has(w.id)||d.has(w.id))){if(Date.now()<g){Oe([w],c,s),d.add(w.id),a.push(w);return}x(w)}},flush:D,destroy(){clearInterval(m),document.removeEventListener("visibilitychange",I),window.removeEventListener("pagehide",E),D(),S=!0}}}var Qr=1800*1e3;function et(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function eo(e=Qr,t){let n=new Map,r=`_snt_asgn${Ze(t)}_`,o=(a,d)=>`${r}${encodeURIComponent(a)}:${encodeURIComponent(d)}`,c=a=>{let d=a.slice(r.length),l=d.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(d.slice(0,l)),segment:decodeURIComponent(d.slice(l+1))}}catch(u){return null}},i=()=>{try{let a=[];for(let d=0;d<localStorage.length;d++){let l=localStorage.key(d);l!=null&&l.startsWith(r)&&a.push(l)}return a}catch(a){return[]}},s=a=>a.assignedAt+(a.ttlMs&&a.ttlMs>0?a.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let a of i())try{let d=localStorage.getItem(a);if(!d)continue;let l=JSON.parse(d);if(s(l)){localStorage.removeItem(a);continue}let u=c(a);if(!u)continue;n.set(et(u.componentId,u.segment),l)}catch(d){}})(),{get(a,d){let l=n.get(et(a,d));return l?s(l)?(n.delete(et(a,d)),null):l:null},set(a,d,l){let u=et(a,d);n.set(u,l);try{localStorage.setItem(o(a,d),JSON.stringify(l))}catch(g){}},clear(){n.clear();for(let a of i())try{localStorage.removeItem(a)}catch(d){}}}}var rt="_snt_snap:",to=["low","medium","high"];function Ke(e){try{let t=localStorage.getItem(rt+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!to.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function je(e,t){try{localStorage.setItem(rt+e,JSON.stringify(t))}catch(n){}}var xt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Sn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",gn=!1,tt=!1;function no(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function ro(e){var t;let n=hn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=no(),c=Promise.resolve().then(()=>(un(),cn)).then(l=>{let u=l;return u.LOCAL_ENGINE_AVAILABLE?(gn||(gn=!0,console.info(Sn)),u):(tt||(tt=!0,console.error(xt)),null)}).catch(()=>(tt||(tt=!0,console.error(xt)),null)),i=null,s={low:.15,medium:.5,high:.85},a=(()=>{var l;if(e.initialPersona)return T({},e.initialPersona);let u=Ke(e.apiKey||"local");return u?{persona:u.persona,confidence:(l=s[u.band])!=null?l:.15}:null})();function d(l){let u=document.documentElement;u.dataset.sentientPersona===void 0&&(u.dataset.sentientPersona=l.persona,u.dataset.sentientConfidence=Se(l.confidence))}return{isLocal:!0,async decide(l){var u,g,v;let S=await c;if(!S)return null;let A=S.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=we(T({},A),{layoutOrder:(g=(u=A.layoutOrder)!=null?u:i==null?void 0:i.layoutOrder)!=null?g:null,slots:T(T({},(v=i==null?void 0:i.slots)!=null?v:{}),A.slots)}),je(e.apiKey||"local",{v:1,persona:i.persona,band:Se(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),d(A),A},getSlotResult(l){var u,g,v;return(v=(g=i==null?void 0:i.slots[l])!=null?g:(u=e.initialSlots)==null?void 0:u[l])!=null?v:null},getSlotConfig(l){var u,g;return(g=(u=e.initialSlotConfig)==null?void 0:u[l])!=null?g:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:a;return l?{persona:l.persona,confidence:l.confidence,band:Se(l.confidence)}:null},async assign(l,u){var g;let v=await c;return!v||!u||u.length===0?u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null:{variantId:(g=v.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:u}]}).assignments[l])!=null?g:u[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function ot(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(ot):!1}function Ge(e,t,n,r){let o=[];{let c=!1,i=[],s=()=>{if(c)return;let a=Date.now();for(i.push(a);i.length>0&&a-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let c=!1,i=s=>{if(c||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;c=!0;let a=typeof window!="undefined"?window.getSelection():null,d=a?a.toString().length:0;e("text_copy",{selectionLength:d})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null)},d=()=>{c||!i||(a(),s=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},l=()=>{a(),d()},u=v=>{for(let S of v)i=S.intersectionRatio>.3,i?d():a()},g=new IntersectionObserver(u,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{g.disconnect(),window.removeEventListener("scroll",l),a()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),s=()=>{if(c||document.visibilityState!=="hidden")return;let a=Date.now()-i;a<15e3&&(c=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let c of o)c()}}function oo(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var An="https://api.sentient-ui.com/v1/events",ne=new Map,En=null;function io(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var so=3;function kt(){return mn()}function nt(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function ao(){let e=new WeakMap,t=new Map,n=!1,r=(s,a,d)=>{let l=s.get(a);return d===null?l?!0:(s.set(a,new Set),!1):l?l.has(d)?!0:(l.add(d),!1):(s.set(a,new Set([d])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,a=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(a,0),typeof MessageChannel=="function"){let d=new MessageChannel;d.port1.onmessage=()=>{d.port1.close(),d.port2.close(),a()},d.port2.postMessage(0)}};return{firedBefore(s,a){let d=c();if(d){let u=e.get(d);return u||(u=new Map,e.set(d,u)),r(u,s,a)}let l=r(t,s,a);return!l&&!n&&(n=!0,i()),l}}}var kn=new Set;function lo(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let d=nt();!d||d===c||(c=d,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${d}`))},s=[];for(let d of["pushState","replaceState"]){let l=r[d],u=function(...g){let v=l.apply(this,g);return i(),v};r[d]=u,s.push([d,l,u])}window.addEventListener("popstate",i);let a=nt();return a&&kn.has(`${t}:${a}`)?c=a:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[d,l,u]of s)r[d]===u&&(r[d]=l)}}}var $e={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function co(){try{return sn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function xn(e){return e.replace(/\/events\/?$/,"")}function Ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function Ot(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:En;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=ne.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:c,reinit:i}=r;if(!c){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Ae())return;let s=(i!=null?i:Ue)(we(T({},o),{consent:!0}));c(s);let a=(t=ne.get(n))==null?void 0:t.dispose;ne.set(n,{config:we(T({},o),{consent:!0}),upgrade:null,dispose:a})}function uo(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=xn((t=e.ingestUrl)!=null?t:An),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(l,u,g){if(!n)return Promise.resolve(null);let v=c.get(l);return v?Promise.resolve(v):_t(i,l,async()=>{try{let S=new URLSearchParams({componentId:l});for(let x of u!=null?u:[])S.append("variantIds[]",x);let A=await fetch(`${r}/winner?${S.toString()}`,{headers:o});if(!A.ok)return u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null;let O={variantId:(await A.json()).variantId,assignmentTtlMs:0};return c.set(l,O),O}catch(S){return u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:l=>s.track(l),goal:((l,u,g,v)=>s.goal(l,u,g,v)),componentGoal:(l,u,g)=>s.componentGoal(l,u,g),identify:l=>s.identify(l),getAssignment:(l,u)=>s.getAssignment(l,u),assign:(l,u,g,v)=>s.assign(l,u,g,v),decide:l=>s.decide(l),getSlotResult:l=>s.getSlotResult(l),getSlotConfig:l=>s.getSlotConfig(l),getSitePalette:()=>s.getSitePalette(),reportSlots:(l,u)=>s.reportSlots(l,u),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function d(l){s=l}return{proxy:a,setInner:d}}function _t(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Ue(e){var t,n,r,o,c,i,s,a,d,l;if(typeof window=="undefined")return $e;En=e.apiKey||"local";let u=ne.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(p){}let g=e.respectDoNotTrack!==!1&&Ae(),v=e.consent===!1||g,S=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!S&&e.localMode!==!1)return ne.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),v?$e:ro(e);if(v){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),ne.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),$e;let{proxy:p,setInner:y}=uo(e);return ne.set(e.apiKey,{config:e,upgrade:g?null:y}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),$e;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),$e;let A=(t=e.ingestUrl)!=null?t:An,O=Date.now(),x=hn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),D=eo(void 0,e.apiKey),f=Vr({ingestUrl:A,apiKey:e.apiKey}),m=xn(A),I={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},E=new Set,w=Zr({url:`${m}/goals`,apiKey:e.apiKey,headers:I,onDrop:(p,y)=>{if(!e.debug){if(E.has(y))return;E.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),$=nn((n=navigator.userAgent)!=null?n:""),P=window.location.origin,U=rn((r=document.referrer)!=null?r:"",P),j=(o=e.sessionSegment)!=null?o:`${$}:${U}`,q=new Map,le=new Map,b=new Map,h=new Map,C=null,_=null,R=new Set,te=new Set,V=new Map,oe=null,ie=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,_e=new Set,Nt=p=>{for(let y of p)b.has(y.id)||b.set(y.id,At(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))b.set(p,y);if(e.initialSlotConfig)for(let[p,y]of Object.entries(e.initialSlotConfig))h.set(p,y);e.initialPalette&&(C=e.initialPalette);let fe=Ke(e.apiKey);if(fe){for(let[p,y]of Object.entries(fe.slots))b.has(p)||b.set(p,y);for(let[p,y]of Object.entries((c=fe.slotConfig)!=null?c:{}))h.has(p)||h.set(p,y);!C&&fe.palette&&(C=fe.palette)}let Kt={low:.15,medium:.5,high:.85};if(e.initialPersona)_=T({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?_={persona:p.sentientPersona,confidence:(s=Kt[(i=p.sentientConfidence)!=null?i:"low"])!=null?s:.15}:fe&&(_={persona:fe.persona,confidence:(a=Kt[fe.band])!=null?a:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))D.set(p,j,{variantId:y,assignedAt:Date.now(),segment:j,confidence:1});let pe=Promise.resolve(),jt=x.getSessionId();if(jt){let p=on((d=document.referrer)!=null?d:""),{utmParams:y,clickIds:L}=co(),z=T(T(T(T({sessionId:jt,deviceClass:$,trafficSource:U,referrerDomain:p,utmParams:y,clickIds:L,timeOfDay:an(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:x.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||tn((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),G=async()=>{for(let M=0;;M++){try{let B=await fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(z),headers:I});if(B.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(B.ok||Ct(B)==="dropped")return}catch(B){}if(M>=so){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(B=>setTimeout(B,Ne(M+1)))}};try{pe=G()}catch(M){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let mr=ao(),Te=null,bt=!1,Ce={goal(p,y={},L=1,z=0){var G,M,B,H,Q,be,ge;let De=x.getSessionId();if(!De)return;let ee=io(y)?y:{metadata:y},Me=[p,(G=ee.externalId)!=null?G:"",(M=ee.stepIndex)!=null?M:z,(B=ee.weight)!=null?B:L].join("\0"),N=ee.value!==void 0?`${ee.value}\0${(H=ee.currency)!=null?H:""}`:null;if(mr.firedBefore(Me,N)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let ce=kt(),Ve={sessionId:De,name:p,metadata:(Q=ee.metadata)!=null?Q:{},weight:(be=ee.weight)!=null?be:L,stepIndex:(ge=ee.stepIndex)!=null?ge:z,goalId:ce,value:ee.value,currency:ee.currency,externalId:ee.externalId};e.debug&&console.log("[sentient] goal",Ve);let J={id:ce,body:JSON.stringify(Ve)};pe.then(()=>w.send(J))},componentGoal(p,y,L){var z,G,M;let B=x.getSessionId();if(!B)return;let H=D.get(p,j),Q=H?null:(z=b.get(p))!=null?z:null;if(!H&&Q===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let be=H?H.variantId:ln(Q),ge={id:kt(),sessionId:B,projectId:e.apiKey,componentId:p,variantId:be,eventType:"goal_achieved",goalType:y,payload:T({reward:(G=L==null?void 0:L.reward)!=null?G:1,goalValue:L==null?void 0:L.value,currency:L==null?void 0:L.currency},(M=L==null?void 0:L.metadata)!=null?M:{}),timestamp:Date.now(),timeInSession:Date.now()-O,path:nt()};e.debug&&console.log("[sentient] componentGoal",ge),pe.then(()=>f.push(ge))},identify(p){let y=x.getSessionId();y&&pe.then(()=>{fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:x.isEphemeral()}),headers:I}).catch(()=>{})})},track(p){let y=x.getSessionId();if(!y)return;let L=we(T({path:nt()},p),{id:kt(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-O});e.debug&&console.log("[sentient] track",L),pe.then(()=>f.push(L))},getAssignment(p,y){return D.get(p,y)},async assign(p,y,L,z){let G=x.getSessionId();if(!G)return null;let M=D.get(p,j);if(M&&(y!=null&&y.length||M.content!==void 0)){let B=M.ttlMs&&M.ttlMs>0?Math.max(0,M.assignedAt+M.ttlMs-Date.now()):0;return{variantId:M.variantId,assignmentTtlMs:B,content:M.content}}return _t(q,p,async()=>{await pe;try{let B={sessionId:G,componentId:p,variantIds:y};z!==void 0?B.agentDataByVariant=z:L!==void 0&&(B.agentData=L);let H=await fetch(`${m}/assign`,{method:"POST",body:JSON.stringify(B),headers:I});if(!H.ok)return null;let Q=await H.json();return D.set(p,j,T({variantId:Q.variantId,assignedAt:Date.now(),segment:j,confidence:1,content:Q.content},Q.assignmentTtlMs&&Q.assignmentTtlMs>0?{ttlMs:Q.assignmentTtlMs}:{})),Q}catch(B){return null}})},async decide(p){var y,L;let z=x.getSessionId();if(!z)return null;let G=(y=p.slots)!=null?y:[],M={sessionId:z};p.sections&&p.sections.length>0&&(M.sections=p.sections.map(H=>({id:H}))),M.components=(L=p.components)!=null?L:[],G.length>0&&(M.slots=G.map(St)),p.slotsFrom==="registry"&&(M.slotsFrom="registry"),p.v&&(M.v=p.v),typeof p.pp=="number"&&(M.pp=p.pp),e.persona&&(M.persona=e.persona);let B=JSON.stringify(M);return _t(le,B,async()=>{var H,Q,be,ge,De,ee;await pe;try{let Me=await fetch(`${m}/decide`,{method:"POST",body:B,headers:I});if(!Me.ok)return Nt(G),null;let N=await Me.json(),ce={};for(let J of G){let se=(H=N.slots)==null?void 0:H[J.id];if(se!==void 0){ce[J.id]=se,b.set(J.id,se);continue}let Gt=b.get(J.id);if(Gt!==void 0)ce[J.id]=Gt;else{let Ut=At(J);ce[J.id]=Ut,b.set(J.id,Ut)}}if(N.slots)for(let[J,se]of Object.entries(N.slots))J in ce||(ce[J]=se,b.set(J,se));let Ve=_!=null&&_.persona!=="unknown";N.persona&&!(N.persona==="unknown"&&Ve)?_={persona:N.persona,confidence:(Q=N.confidence)!=null?Q:0}:_||(_={persona:"unknown",confidence:0});for(let[J,se]of Object.entries((be=N.assignments)!=null?be:{}))D.set(J,j,{variantId:se,assignedAt:Date.now(),segment:j,confidence:1});if(N.slotConfig)for(let[J,se]of Object.entries(N.slotConfig))h.set(J,se);return N.palette&&(C=N.palette),je(e.apiKey,T(T({v:1,persona:_.persona,band:Se(_.confidence),slots:Object.fromEntries(b),layoutOrder:(ge=N.layoutOrder)!=null?ge:null,savedAt:Date.now()},h.size>0?{slotConfig:Object.fromEntries(h)}:{}),C?{palette:C}:{})),T(T(T(T({layoutOrder:(De=N.layoutOrder)!=null?De:null,assignments:(ee=N.assignments)!=null?ee:{},slots:ce,persona:_.persona,confidence:_.confidence},N.slotConfig?{slotConfig:N.slotConfig}:{}),N.goals?{goals:N.goals}:{}),N.sectionMap?{sectionMap:N.sectionMap}:{}),N.palette?{palette:N.palette}:{})}catch(Me){return Nt(G),null}})},getSlotResult(p){var y;return(y=b.get(p))!=null?y:null},getSlotConfig(p){var y;return(y=h.get(p))!=null?y:null},reportSlots(p,y){for(let L of p)if(!(typeof L!="string"||L.length===0)){if(!ie.test(L)){oo()&&!_e.has(L)&&(_e.add(L),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(L)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!R.has(L)){R.add(L),te.add(L);let z=y==null?void 0:y[L];if(typeof z=="string"){let G=z.replace(/\s+/g," ").trim().slice(0,400);G!==""&&V.set(L,G)}}}te.size===0||oe!=null||(oe=setTimeout(()=>{oe=null;let L=[...te];te.clear();for(let z=0;z<L.length;z+=20){let G=L.slice(z,z+20),M={};for(let B of G){let H=V.get(B);H!==void 0&&(M[B]=H,V.delete(B))}fetch(`${m}/slots/observed`,{method:"POST",headers:I,body:JSON.stringify(T({slotIds:G},Object.keys(M).length>0?{baselineTexts:M}:{}))}).catch(()=>{})}},1e3))},getSitePalette(){return C},getPersona(){return _?{persona:_.persona,confidence:_.confidence,band:Se(_.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${m}/weights`,{headers:I});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;Te==null||Te(),bt=!0,f.destroy(),w.destroy(),((p=ne.get(e.apiKey))==null?void 0:p.dispose)===Ce.dispose&&ne.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;Te==null||Te(),bt=!0,f.destroy(),w.destroy(),x.destroy(),D.clear(),((p=ne.get(e.apiKey))==null?void 0:p.dispose)===Ce.dispose&&ne.delete(e.apiKey);try{localStorage.removeItem(rt+e.apiKey),localStorage.removeItem(bn(e.apiKey)),localStorage.removeItem(wn(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(ne.set(e.apiKey,{config:e,upgrade:null,dispose:Ce.dispose}),Te=lo(Ce,e.apiKey,p=>{pe.then(()=>{bt||kn.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=Ce)}return Ce}var fo=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function It(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function po(e){return{tag:e.tagName.toLowerCase(),text:It(e).slice(0,40)}}function _n(e){return e.replace(/["\\\]]/g,"\\$&")}function ze(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function Cn(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),c=[r,...o.map(s=>`${r}.${s}`)];for(let s of c)if(ze(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=Cn(i,t);if(s){for(let u of c){let g=`${s} > ${u}`;if(ze(t,g))return g}let a=Array.from(i.children).filter(u=>u.tagName.toLowerCase()===r),d=a.indexOf(e),l=a.some(u=>u!==e&&It(u)!==It(e));if(d>=0&&l){let u=`${s} > ${r}:nth-of-type(${d+1})`;if(ze(t,u))return u}}}return null}function On(e,t){let n=po(e),r=e.getAttribute("id");if(r&&ze(t,`#${_n(r)}`))return{v:1,id:r,fingerprint:n};for(let c of fo){let i=e.getAttribute(c);if(i&&ze(t,`[${c}="${_n(i)}"]`))return{v:1,dataAttr:{name:c,value:i},fingerprint:n}}let o=Cn(e,t);return o?{v:1,selector:o,fingerprint:n}:null}Be();var Ln=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],go={banner:"hero",navigation:"navigation",contentinfo:"footer"};function mo(e){let t=e.ariaRole?go[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function ho(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var yo=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],Lt=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],In={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function vo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Pn(e){var t,n;let r=mo(e);if(r)return{type:(t=In[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of yo)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of Lt)if(s.test(e.bodyText))return{type:i,strength:"strong"};let c=ho(e);return{type:(n=In[c])!=null?n:"generic",strength:"weak"}}function Rn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return T({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:vo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}Be();var bo="section, header, footer, nav, main > div, [data-sentient-section]",wo=2e4;function So(e){let t=Array.from(e.querySelectorAll(bo)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function Ao(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var Tn=()=>{};function Dn(e,t){var n,r,o,c,i,s,a,d,l,u,g,v;let S=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!S||typeof IntersectionObserver=="undefined"||Ae()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Tn;let A=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),O=So(S);if(O.length===0)return Tn;let x=new Map,D=[];for(let h of O){let C=h.getAttribute("data-sentient-type"),_=C&&Ln.includes(C)?C:null,R=Rn(h),te=(c=_!=null?_:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?c:Pn(R).type,V=On(h,S),oe=V?`nc-${te}-${Qt(JSON.stringify({id:(i=V.id)!=null?i:null,dataAttr:(s=V.dataAttr)!=null?s:null,selector:(a=V.selector)!=null?a:null})).toString(36)}`:`nc-${te}`;x.set(h,oe);let ie=Lt.filter(([,_e])=>_e.test(R.bodyText)).map(([_e])=>_e);D.push(we(T({componentId:oe,semanticType:te,source:_?"markup":"auto"},V?{locator:V}:{}),{observation:T(T({tag:R.tag,idClass:R.idClass.slice(0,200),headingText:R.headingText,textLength:R.textLength,actionCount:R.actionCount},R.ariaRole?{ariaRole:R.ariaRole}:{}),ie.length>0?{patternFlags:ie}:{})}))}let f=(g=(u=(l=(d=S.defaultView)!=null?d:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:u.pathname)!=null?g:"/";Ao(t.apiKey,A,f,D);let m=new Map,I=h=>{let C=m.get(h);return C||(C={ms:0,scroll:0,enterAt:null,intersecting:!1},m.set(h,C)),C},E=new IntersectionObserver(h=>{for(let C of h){let _=x.get(C.target);if(!_)continue;let R=I(_);C.isIntersecting?(R.intersecting=!0,R.enterAt=Date.now(),C.intersectionRatio>R.scroll&&(R.scroll=C.intersectionRatio)):(R.intersecting=!1,R.enterAt!=null&&(R.ms+=Date.now()-R.enterAt,R.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of x.keys())E.observe(h);let w=()=>{let h=Date.now();for(let[C,_]of m)if(_.enterAt!=null&&(_.ms+=h-_.enterAt,_.enterAt=null),!(_.ms<=0)){try{e.track({projectId:t.apiKey,componentId:C,eventType:"dwell",payload:{dwell_time:Math.round(_.ms),scroll_depth:Number(_.scroll.toFixed(2))}})}catch(R){}_.ms=0}},$=()=>{if(S.hidden)w();else{let h=Date.now();for(let C of m.values())C.intersecting&&(C.enterAt=h)}},P=!1,U=h=>{if(w(),h!=null&&h.persisted){P=!0;return}try{E.disconnect()}catch(C){}},j=h=>{if(!(h!=null&&h.persisted)||!P)return;P=!1;let C=Date.now();for(let _ of m.values())_.enterAt=_.intersecting&&!S.hidden?C:null};S.addEventListener("visibilitychange",$);let q=(v=S.defaultView)!=null?v:typeof window!="undefined"?window:void 0;q==null||q.addEventListener("pagehide",U),q==null||q.addEventListener("pageshow",j);let le=setInterval(()=>{if(S.hidden||P)return;w();let h=Date.now();for(let C of m.values())C.intersecting&&(C.enterAt=h)},wo),b=[];return t.microSignals&&[...x.entries()].forEach(([h,C],_)=>{b.push(Ge((R,te={})=>{try{e.track({projectId:t.apiKey,componentId:C,eventType:"micro_signal",payload:T({signalType:R},te)})}catch(V){}},h,void 0,{tabLoss:_===0}))}),()=>{w(),clearInterval(le),S.removeEventListener("visibilitychange",$),q==null||q.removeEventListener("pagehide",U),q==null||q.removeEventListener("pageshow",j);for(let h of b)h();try{E.disconnect()}catch(h){}}}var Eo=["landing","ecommerce","saas","marketplace"];function ko(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(c=>typeof c=="string"))return null;n[r]=o}return n}function xo(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function _o(e){try{return e()}catch(t){return}}function it(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=Eo.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let a=s,d=ko(a.dims);if(!d||a.target!==void 0&&typeof a.target!="string")continue;let l=a.arms!==void 0?xo(a.arms):null,u={dims:d};typeof a.target=="string"&&(u.target=a.target),l&&(u.arms=l),r[i]=u}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?_o(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),Array.isArray(t.sections)){let i=t.sections.filter(s=>typeof s=="string"&&s.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function st(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Co(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim().toLowerCase(),o=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Mn(e,t){return!!(e!=null&&e.urlMatch)&&!st(t).includes(e.urlMatch)}var Oo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function me(e,t){var o;if(e.urlMatch&&!st(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Oo.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Co(r,e.fingerprint)?null:r}var Bn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Io=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function $n(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Io.test((r=n[1])!=null?r:""))return!1;return!0}var Nn=/^https:\/\//i,Kn=new Map,he=null;function Lo(e){return e.replace(/["\\]/g,"\\$&")}function Po(e){var t;(!he||!he.isConnected)&&(he=e.querySelector("style[data-sentient-ops]"),he||(he=e.createElement("style"),he.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(he))),he.textContent=[...Kn.entries()].map(([n,r])=>`[data-snt-e="${Lo(n)}"]{${r}}`).join(`
|
|
2
|
+
`)}function jn(e,t,n,r){var s;let o=!1,c=(s=t.moveBefore)!=null?s:t.moveAfter;if(c){let a=me(c,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Nn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Nn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[a,d]of Object.entries(t.style)){let l=Bn[a];l&&typeof d=="string"&&$n(d)&&i.push(`${l}:${d.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Kn.set(n,i.join(";")),Po(r)),{anchorMiss:o}}var Fe="data-sentient-block-arm",k=null;function qe(e){k=e!=null?e:null}var ue="data-sentient-blocks-hid",Ie={none:"0",sm:"8px",md:"16px",lg:"24px"},Pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Gn={sm:"0.875em",md:"1em",lg:"1.25em"},Ro={sm:"1.25em",md:"1.5em",lg:"2em"},To={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Un={sm:"8px",md:"16px",lg:"32px"},Do={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Mo={normal:"400",medium:"500",bold:"700"};function re(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function zn(e){return e==="muted"?k!=null&&k.muted?{color:k.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:k==null?void 0:k.accent}:{}}function Fn(e,t){var n,r,o,c,i,s,a,d,l,u,g,v,S,A,O,x,D,f,m,I;try{switch(e.type){case"stack":case"grid":{let E=t.createElement("div");if(e.type==="stack"){let P=e;re(E,{display:"flex","flex-direction":P.direction,gap:(r=Ie[(n=P.gap)!=null?n:"md"])!=null?r:Ie.md,"align-items":P.align?Pt[P.align]:void 0,"justify-content":P.justify?Pt[P.justify]:void 0,"flex-wrap":P.wrap?"wrap":void 0})}else{let P=e,U=(c=Ie[(o=P.gap)!=null?o:"md"])!=null?c:Ie.md;re(E,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${P.columns-1} * ${U}) / ${P.columns})), 1fr))`,gap:U,"align-items":P.align?Pt[P.align]:void 0})}let w=e.type==="stack"&&e.surface==="raised",$=(i=e.pad)!=null?i:w?"md":void 0;$&&re(E,{padding:(s=Ie[$])!=null?s:Ie.md}),w&&re(E,{background:k==null?void 0:k.surface,color:k!=null&&k.surface?k==null?void 0:k.surfaceText:void 0,border:`1px solid ${(a=k==null?void 0:k.border)!=null?a:"currentColor"}`,"border-radius":(d=k==null?void 0:k.radius)!=null?d:"8px"});for(let P of(l=e.children)!=null?l:[]){let U=Fn(P,t);U&&E.appendChild(U)}return E}case"text":{let E=t.createElement("p");return E.textContent=e.value,re(E,Wt(Y({margin:"0","font-size":e.size?Gn[e.size]:void 0,"font-weight":e.weight?Mo[e.weight]:void 0,"text-align":e.align},zn(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let E=t.createElement(`h${e.level}`);return E.textContent=e.value,re(E,{margin:"0","font-size":Ro[(u=e.size)!=null?u:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let E=t.createElement("a");E.textContent=e.label,E.href=e.href,e.tag&&E.setAttribute("data-sentient-tag",e.tag);let w=(g=e.emphasis)!=null?g:"primary";return re(E,{display:"inline-block",padding:To[(v=e.size)!=null?v:"md"],"border-radius":(S=k==null?void 0:k.radius)!=null?S:"8px",font:"inherit","font-size":e.size?Gn[e.size]:void 0,"text-decoration":w==="ghost"?"underline":"none",cursor:"pointer",background:w==="primary"?(A=k==null?void 0:k.primaryBg)!=null?A:"#111827":"transparent",color:w==="primary"?(O=k==null?void 0:k.primaryText)!=null?O:"#ffffff":(x=k==null?void 0:k.accent)!=null?x:"inherit",border:w==="secondary"?`1px solid ${(D=k==null?void 0:k.accent)!=null?D:"currentColor"}`:"none"})}case"link":{let E=t.createElement("a");return E.textContent=e.label,E.href=e.href,e.tag&&E.setAttribute("data-sentient-tag",e.tag),re(E,{color:"inherit","text-decoration":"underline"})}case"image":{let E=t.createElement("img");return E.src=e.src,E.alt=e.alt,re(E,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Do[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let E=t.createElement("span");return E.textContent=e.value,re(E,Y({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(f=k==null?void 0:k.border)!=null?f:"currentColor"}`},zn(e.tone)))}case"spacer":return re(t.createElement("div"),{height:(m=Un[e.size])!=null?m:Un.md});case"divider":return re(t.createElement("hr"),{border:"none","border-top":`1px solid ${(I=k==null?void 0:k.border)!=null?I:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(E){return null}}function qn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Fe);s!==null&&(t[s]===void 0?i.remove():o.add(s))}for(let[i,s]of Object.entries(t)){if(o.has(i))continue;let a=Fn(s,r);if(!a)continue;let d=r.createElement("div");d.setAttribute(Fe,i),d.style.display="none",d.appendChild(a),e.appendChild(d)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Fe),a=i;s!==null?a.style.display=c&&s===n?"":"none":c?a.hasAttribute(ue)||(a.setAttribute(ue,a.style.display),a.style.display="none"):a.hasAttribute(ue)&&(a.style.display=a.getAttribute(ue),a.removeAttribute(ue))}}catch(o){}}function Bo(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Fe)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function at(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Fe}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ue}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||Bo(r)}catch(n){}}function Rt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function lt(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function ct(e,t,n,r){var o;for(let[c,i]of Object.entries(t)){let s=e[c];if(!s||typeof s=="string")continue;let a=Rt(i.target,n);for(let d of a)for(let[l,u]of Object.entries(s))(o=i.dims[l])!=null&&o.includes(u)&&(d.setAttribute(`data-${l}`,u),r==null||r(d,`data-${l}`))}}function ut(e,t,n,r){for(let[o,c]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!c.arms||!c.arms.includes(i))continue;let s=Rt(c.target,n);for(let a of s)a.setAttribute("data-sentient-arm",i),r==null||r(a,"data-sentient-arm")}}function dt(e,t,n,r){var s,a,d,l;let o=new Set,c=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[u,g]of Object.entries(t)){if(Mn(g.locator,n))continue;let v;if(g.locator){let A=me(g.locator,n);v=A?[A]:[]}else v=Rt(g.target,n);(g.locator||g.target)&&v.length===0&&i.push(u);let S=e[u];for(let A of v){if(S!==void 0)if(typeof S=="string")A.setAttribute("data-sentient-arm",S),(a=r==null?void 0:r.onAttr)==null||a.call(r,A,"data-sentient-arm"),c&&((d=r==null?void 0:r.onApplied)==null||d.call(r,u,S,A));else for(let[O,x]of Object.entries(S))A.setAttribute(`data-${O}`,x),(l=r==null?void 0:r.onAttr)==null||l.call(r,A,`data-${O}`);if(g.blocks&&!No(n)){let O=Object.fromEntries(Object.entries(g.blocks).filter(([,x])=>!ot(x)));Object.keys(O).length>0&&(qn(A,O,typeof S=="string"?S:void 0,n),o.add(A))}c&&(typeof g.content=="string"&&(A.textContent=g.content),g.ops&&jn(A,g.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return at(n,o),i}var $o=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function No(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:$o.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var Ko=800;function ft(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},s)=>{r.push(Ge((g,v={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:Y({signalType:g},v)})}catch(S){}},i,void 0,{tabLoss:s===0}));let a=null,d=0,l=()=>{d=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-d}})}catch(g){}a=null},Ko)},u=()=>{a!==null&&(clearTimeout(a),a=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",u),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",u),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function jo(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function Hn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var Go="_snt_fired_goals";function Jn(e,t){try{e==null||e.sessionStorage.removeItem(Hn(t)),e==null||e.sessionStorage.removeItem(Go)}catch(n){}}function Wn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Uo(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function zo(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function pt(e,t,n,r){var x,D;let o=(x=n.defaultView)!=null?x:typeof window!="undefined"?window:null,c=Hn(r),i=Uo(o,c),s=f=>{let m=Wn(f);if(!i.has(m))try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId),i.add(m),zo(o,c,i)}catch(I){}},a=e.filter(f=>f.event==="click"),d=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),u=e.filter(f=>f.event==="scroll_depth"),g=(f,m)=>{if(!f.locator)return!1;let I=me(f.locator,n);return!!I&&(I===m||I.contains(m))},v=f=>{let m=f.target;if(!(!m||typeof m.closest!="function"))for(let I of a)g(I,m)&&s(I)},S=f=>{let m=f.target;if(m)for(let I of d)g(I,m)&&s(I)},A=()=>{if(l.length===0)return;let f=st(n);for(let m of l)m.urlPattern&&jo(m.urlPattern,f)&&s(m)},O=()=>{var I;let f=n.documentElement,m=f.scrollHeight>0?(f.scrollTop+f.clientHeight)/f.scrollHeight:0;for(let E of u)m>=((I=E.threshold)!=null?I:.75)&&s(E);u.every(E=>i.has(Wn(E)))&&n.removeEventListener("scroll",O)};return n.addEventListener("click",v,!0),n.addEventListener("submit",S,!0),(D=n.defaultView)==null||D.addEventListener("popstate",A),A(),u.length>0&&(n.addEventListener("scroll",O,{passive:!0}),O()),{checkUrl:A,teardown:()=>{var f;n.removeEventListener("click",v,!0),n.removeEventListener("submit",S,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",A),u.length>0&&n.removeEventListener("scroll",O)}}}function gt(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),c=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(c.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return c}var Vn="__snt_editor_token";function Xn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Vn):null}catch(e){return null}}function Yn(e){try{sessionStorage.setItem(Vn,e)}catch(t){}}var Je="0.25.0",yt=Je!=="0.0.0-dev"?{name:"snippet",version:Je}:void 0,ir=5e3,Fo=50,sr=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),Z=null,K=null,de={},ve=null,W=null,ye=null,X=null,ae=null,F=null,Ee=null,Zn=!1,Tt=null,mt=null,vt=null,Le=!1,We=!1,xe=!1;function ar(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function ke(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Pe(e,t){return Z?(Z.personaAttributes&&F&<(F.persona,F.band,e,t==null?void 0:t.onAttr),ct(de,Z.slots,e,t==null?void 0:t.onAttr),ut(de,Z.slots,e,t==null?void 0:t.onAttr),ve?dt(de,ve,e,t):(at(e,new Set),[])):[]}function lr(e){var n;let t=new Map;for(let r of(n=Z==null?void 0:Z.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Dt(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=gt(e,lr(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function qo(e,t,n){let r=(o,c)=>t.some(([i,s])=>i===o&&s===c);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[c,i,s]=o;!c||typeof i!="string"||r(c,i)||(s==null?c.removeAttribute(i):c.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function Wo(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function cr(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function Ho(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Re(){return!!(Z&&K&&Z.sectionCapture!==!1&&(Z.consent!==!1||We)&&!Ae())}function Jo(){if(!K||!Z||!Re()||ae)return;let e=[];Pe(document,{contentAndOps:Le,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Bt();try{X==null||X(),X=ft(K,Z.apiKey,e)}catch(t){}}function Bt(){if(typeof document=="undefined"||!Re())return;let e;try{if(mt&&mt.length>0){let t=new Map;for(let n of mt){if(n.urlMatch!==window.location.pathname)continue;let r=me(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ae=Dn(K,Y({apiKey:Z.apiKey,apiBase:Z.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),vt=window.location.pathname}catch(t){}}function $t(){try{let e=[];if(X==null||X(),X=null,Pe(document,{contentAndOps:Le,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Dt(Ee,document),e.length>0&&Re())try{X=ft(K,Z.apiKey,e)}catch(t){}try{typeof window!="undefined"&&vt!==null&&window.location.pathname!==vt&&Re()&&(ae==null||ae(),ae=null,Bt())}catch(t){}}catch(e){}}function Qn(){Tt===null&&(Tt=setTimeout(()=>{Tt=null,$t();try{W==null||W.checkUrl()}catch(e){}},Fo))}function Mt(){if(!(Zn||typeof window=="undefined"||typeof history=="undefined")){Zn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,c){let i=n.call(this,r,o,c!=null?c:null);return Qn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Qn)}catch(e){}}}function ht(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function ur(e){return new URLSearchParams(e).get("sentient_editor")}function Vo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function Xo(e,t){var n,r,o,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let a=document.createElement("meta");a.name="referrer",a.content="no-referrer",a.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let i=(o=e.editorSrc)!=null?o:Vo();if(!i){tr();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>tr(),((c=document.head)!=null?c:document.documentElement).appendChild(s)}catch(i){}}var er="sentient-editor-load-notice",dr={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function tr(){var e,t;try{if(typeof document=="undefined"||document.getElementById(er))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=er,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,dr,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function fr(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),c=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!c||!i))if(i.includes("=")){let s={};for(let a of i.split(",")){let[d,l]=a.split("=");d&&l&&(s[d]=l)}Object.keys(s).length&&(n[c]=s)}else n[c]=i}return Object.keys(n).length?n:null}function pr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var nr="sentient-persona-preview-banner";function rr(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(nr))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=nr,o.setAttribute("role","status"),Object.assign(o.style,dr,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Yo(e,t){var d,l,u,g,v,S,A,O,x,D;let n=(d=e.apiBase)!=null?d:"https://api.sentient-ui.com",o=((l=e.registry)!=null?l:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,m])=>({id:f,dims:m.dims}))},c=await ar(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(f=>f.ok?f.json():null).catch(()=>null),ir);if(!c){He(e),ke(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;de=(u=i.slots)!=null?u:{},ve=(g=i.slotConfig)!=null?g:null,qe(i.palette);let s=(A=(S=(v=i.personaAttributes)==null?void 0:v.persona)!=null?S:i.persona)!=null?A:t,a=(x=(O=i.personaAttributes)==null?void 0:O.confidence)!=null?x:"high";F={persona:s,band:a},Pe(document),Le=!0,Mt(),He(e),i.recognized===!1?rr(t,!0):rr((D=i.personaDisplay)!=null?D:s)}function He(e){let t={goal(n,r){try{K==null||K.goal(n,r)}catch(o){}},componentGoal(n,r){try{K==null||K.componentGoal(n,r)}catch(o){}},grantConsent(){try{!K&&xe?(K=Ue(Y({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:cr(e)},yt?{sdk:yt}:{})),ye&&ye.length>0&&(W==null||W.teardown(),W=pt(ye,K,document,e.apiKey))):(Ot(e.apiKey),K&&ye&&ye.length>0&&(W==null||W.teardown(),W=pt(ye,K,document,e.apiKey))),xe=!1}catch(n){}We=!0;try{Jo()}catch(n){}},revokeConsent(){try{ae==null||ae(),ae=null,vt=null,X==null||X(),X=null,W==null||W.teardown(),W=null,Jn(typeof window!="undefined"?window:null,e.apiKey),We=!1,xe=!0,K==null||K.destroy(),K=null}catch(n){}},reapply:$t,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=F==null?void 0:F.persona)!=null?n:null,band:(r=F==null?void 0:F.band)!=null?r:null,slots:de,matchCounts:ht(e),consent:!xe&&(e.consent!==!1||We)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of sr.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function or(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},sr.length=0}catch(t){}}async function gr(){var e,t;try{let n=it(window.sentient);if(!n){or();return}Z=n,Le=!1,Ee=null,qe(null),We=!1,xe=!1,ye=null;let r=typeof window!="undefined"?ur(window.location.search):null;if(r){Yn(r);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let o=r!=null?r:Xn();if(o){Xo(n,o),He(n),ke(n,"editor mode");return}let c=typeof window!="undefined"?fr(window.location.search):null;if(c){de=c,F=null,Pe(document),Mt(),He(n),ke(n,"preview mode",c);return}let i=typeof window!="undefined"?pr(window.location.search):null;if(i){await Yo(n,i),ke(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0,a=Wo();try{(t=a==null?void 0:a.stop)==null||t.call(a)}catch(f){}let d=Ke(n.apiKey),l=[];d&&(F={persona:d.persona,band:d.band},de=d.slots,d.slotConfig&&(ve=d.slotConfig),d.palette&&qe(d.palette),Pe(document,Y({contentAndOps:!1},a?{onAttr:(f,m)=>l.push([f,m])}:{})),d.layoutOrder&&(Ee=d.layoutOrder,Dt(Ee,document))),a&&qo(a,l,document);let u=Ue(Y({apiKey:n.apiKey,context:n.context,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:cr(n)},yt?{sdk:yt}:{}));K=u,He(n),Mt();let g=Object.entries(n.slots).map(([f,m])=>({id:f,dims:m.dims})),v=Je!=="0.0.0-dev"?{v:Je}:{},S={pp:a?a.v:0},A=Array.from(lr(document).keys()),O=u.decide(Y(Y(Y(Y({slots:g},v),S),A.length>=2?{sections:A}:{}),s?{slotsFrom:"registry"}:{})),x=await ar(O,ir),D=f=>{var E,w,$,P,U,j;let m=u.getPersona();m?F={persona:m.persona,band:m.band}:f.persona&&(F={persona:f.persona,band:"low"}),de=f.slots,s?ve=(E=f.slotConfig)!=null?E:null:f.slotConfig&&(ve=f.slotConfig),f.palette&&qe(f.palette),Ee=(w=f.layoutOrder)!=null?w:Ee;let I=()=>{let q=[];if(Ho(n,Pe(document,{onApplied:(le,b,h)=>q.push({slotId:le,arm:b,el:h})})),Dt(Ee,document),Le=!0,Re())try{X==null||X(),X=ft(K,n.apiKey,q)}catch(le){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",I,{once:!0}):I(),ye=($=f.goals)!=null?$:null,f.goals&&f.goals.length>0&&n.consent!==!1&&K)try{W==null||W.teardown(),W=pt(f.goals,K,document,n.apiKey)}catch(q){}mt=(P=f.sectionMap)!=null?P:null,Re()&&Bt(),ke(n,"applied",{persona:F,slots:de,matches:ht(n)}),!xe&&je(n.apiKey,Y(Y({v:1,persona:(U=F==null?void 0:F.persona)!=null?U:f.persona,band:(j=F==null?void 0:F.band)!=null?j:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ve?{slotConfig:ve}:{}),f.palette?{palette:f.palette}:{}))};if(!x){ke(n,"decide timeout/null \u2014 snapshot state stands",ht(n)),O.then(f=>{!f||Le||xe||K!==u||(D(f),ke(n,"late decide applied",ht(n)))}).catch(()=>{});return}D(x)}catch(n){or()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{gr()}))}return Ar(Zo);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/snippet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsx": "^4.19.2",
|
|
39
39
|
"typescript": "^5.7.2",
|
|
40
40
|
"vitest": "^2.1.8",
|
|
41
|
-
"@sentientui/core": "0.
|
|
41
|
+
"@sentientui/core": "0.28.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|