@sentientui/snippet 0.32.3 → 0.33.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.
@@ -1,5 +1,5 @@
1
- "use strict";var __sentientEditorBundle=(()=>{var Ft=Object.defineProperty,kr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptor,Er=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertyNames,Gt=Object.getOwnPropertySymbols;var mn=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable;var lo=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))mn.call(t,n)&&lo(e,n,t[n]);if(Gt)for(var n of Gt(t))co.call(t,n)&&lo(e,n,t[n]);return e},le=(e,t)=>kr(e,Er(t));var uo=e=>typeof e=="symbol"?e:e+"",po=(e,t)=>{var n={};for(var r in e)mn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Gt)for(var r of Gt(e))t.indexOf(r)<0&&co.call(e,r)&&(n[r]=e[r]);return n};var Tr=(e,t)=>()=>(e&&(t=e(e=0)),t);var Lr=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0})},_r=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Cr(t))!mn.call(e,s)&&s!==n&&Ft(e,s,{get:()=>t[s],enumerable:!(r=Sr(t,s))||r.enumerable});return e};var Ir=e=>_r(Ft({},"__esModule",{value:!0}),e);var Ar,$r,Br,fo,Or,Mr,go,de,lt,hn=Tr(()=>{"use strict";Ar=Object.defineProperty,$r=Object.defineProperties,Br=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,go=(e,t,n)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,de=(e,t)=>{for(var n in t||(t={}))Or.call(t,n)&&go(e,n,t[n]);if(fo)for(var n of fo(t))Mr.call(t,n)&&go(e,n,t[n]);return e},lt=(e,t)=>$r(e,Br(t))});var Bi={};Lr(Bi,{buildStyleOps:()=>Pn,clearTargetHighlights:()=>mt,computeMoveAnchors:()=>en,deriveSlotId:()=>Te,drawTargetHighlights:()=>nr,exchangeCode:()=>er,isHex6:()=>Rn,mount:()=>ir,registerAuditTargets:()=>tr,sectionTypesFor:()=>or,styleFieldError:()=>rr,toHexColor:()=>Bn});var mo;function ho(e=document){if(mo)return mo;try{let t=e.querySelector("script[nonce]");return(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"))||void 0}catch(t){return}}function It(e,t=document){let n=ho(t);return n&&e.setAttribute("nonce",n),e}var Pi=1800*1e3;var yn=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Pr(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Nr(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(),s=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var Rr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Dr(e,t){var r;let n=[];if(e.id){let s=t.getElementById(e.id);n=s?[s]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Rr.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(s){n=[]}return n}function we(e,t){if(e.urlMatch&&!Pr(t).includes(e.urlMatch))return null;let n=Dr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Nr(r,e.fingerprint)?null:r}var At={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"},Hr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function ct(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(!Hr.test((r=n[1])!=null?r:""))return!1;return!0}function bn(e){var r,s;let t=e.ownerDocument.createTreeWalker(e,4),n=null;for(let c=t.nextNode();c!==null;c=t.nextNode()){if(((r=c.nodeValue)!=null?r:"").trim()==="")continue;let m=(s=c.parentElement)==null?void 0:s.tagName;if(!(m==="SCRIPT"||m==="STYLE"||m==="TEMPLATE")){if(n!==null)return null;n=c}}return n}function vn(e){return e.childElementCount===0||bn(e)!==null}function xn(e){var t,n,r;return(r=(n=(t=bn(e))==null?void 0:t.nodeValue)!=null?n:e.textContent)!=null?r:""}function Ye(e,t){let n=bn(e);n!==null?n.nodeValue=t:e.textContent=t}var wn=/^https:\/\//i;function Wt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(wn.test(e)||e[0]==="/"&&e[1]!=="/")?e:null}var yo=new Map,Re=null;function zr(e){return e.replace(/["\\]/g,"\\$&")}function jr(e){var t;(!Re||!Re.isConnected)&&(Re=e.querySelector("style[data-sentient-ops]"),Re||(Re=It(e.createElement("style"),e),Re.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Re))),Re.textContent=[...yo.entries()].map(([n,r])=>`[data-snt-e="${zr(n)}"]{${r}}`).join(`
2
- `)}function bo(e,t,n,r){var x;let s=!1,c=(x=t.moveBefore)!=null?x:t.moveAfter;if(c){let g=we(c,r);!g||g===e||g.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,g):e.parentElement.insertBefore(e,g.nextSibling)}typeof t.text=="string"&&Ye(e,t.text),typeof t.href=="string"&&wn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&wn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let m=[];if(t.hidden&&m.push("display:none !important"),t.style)for(let[g,k]of Object.entries(t.style)){let y=At[g];y&&typeof k=="string"&&ct(k)&&m.push(`${y}:${k.trim()} !important`)}return m.length>0&&(e.setAttribute("data-snt-e",n),yo.set(n,m.join(";")),jr(r)),{anchorMiss:s}}var kn="data-sentient-block-arm",O=null;var Je=null;function ko(e){Je=e!=null?e:null}var So=e=>{var t;return typeof e=="string"?(t=Je==null?void 0:Je.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},Eo=e=>{let t=typeof e=="string"?Je==null?void 0:Je.entries.find(n=>n.id===e):void 0;return t!=null&&t.computed.inheritsColor?t.computed.color:void 0},$t="data-sentient-blocks-hid",dt={none:"0",sm:"8px",md:"16px",lg:"24px"},Sn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},vo={sm:"0.875em",md:"1em",lg:"1.25em"},Kr={sm:"1.25em",md:"1.5em",lg:"2em"},Ur={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},xo={sm:"8px",md:"16px",lg:"32px"},Gr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Fr={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function wo(e){return e==="muted"?O!=null&&O.muted?{color:O.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:O==null?void 0:O.accent}:{}}function Co(e,t){let n=Wr(e,t),r=Eo(e.like);return n&&r&&(n.style.color=r),n}function Wr(e,t){var n,r,s,c,m,x,g,k,y,$,L,D,E,z,J,Z,G,X,ne,Q;try{let M=So(e.like),re=e.maxWidth==="measure"?"65ch":void 0,ie=A=>(A.className=M,he(A,{"max-width":re}));switch(e.type){case"stack":case"grid":{let A=t.createElement("div");if(e.type==="stack"){let B=e;he(A,{display:"flex","flex-direction":B.direction,gap:(r=dt[(n=B.gap)!=null?n:"md"])!=null?r:dt.md,"align-items":B.align?Sn[B.align]:void 0,"justify-content":B.justify?Sn[B.justify]:void 0,"flex-wrap":B.wrap?"wrap":void 0})}else{let B=e,V=(c=dt[(s=B.gap)!=null?s:"md"])!=null?c:dt.md;he(A,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${B.columns-1} * ${V}) / ${B.columns})), 1fr))`,gap:V,"align-items":B.align?Sn[B.align]:void 0})}M&&(A.className=M);let P=!M&&e.type==="stack"&&e.surface==="raised",q=(m=e.pad)!=null?m:P?"md":void 0;q&&he(A,{padding:(x=dt[q])!=null?x:dt.md}),P&&he(A,{background:O==null?void 0:O.surface,color:O!=null&&O.surface?O==null?void 0:O.surfaceText:void 0,border:`1px solid ${(g=O==null?void 0:O.border)!=null?g:"currentColor"}`,"border-radius":(k=O==null?void 0:O.radius)!=null?k:"8px"});for(let B of(y=e.children)!=null?y:[]){let V=Co(B,t);V&&A.appendChild(V)}return A}case"text":{let A=t.createElement("p");return A.textContent=e.value,M?ie(A):he(A,le(K({margin:"0","font-size":e.size?vo[e.size]:void 0,"font-weight":e.weight?Fr[e.weight]:void 0,"text-align":e.align},wo(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let A=t.createElement(`h${e.level}`);return A.textContent=e.value,M?ie(A):he(A,{margin:"0","font-size":Kr[($=e.size)!=null?$:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let A=t.createElement("a");A.textContent=e.label;let P=Wt(e.href);if(P&&(A.href=P),e.tag&&A.setAttribute("data-sentient-tag",e.tag),M)return ie(A);let q=(L=e.emphasis)!=null?L:"primary";return he(A,{display:"inline-block",padding:Ur[(D=e.size)!=null?D:"md"],"border-radius":(E=O==null?void 0:O.radius)!=null?E:"8px",font:"inherit","font-size":e.size?vo[e.size]:void 0,"text-decoration":q==="ghost"?"underline":"none",cursor:"pointer",background:q==="primary"?(z=O==null?void 0:O.primaryBg)!=null?z:"#111827":"transparent",color:q==="primary"?(J=O==null?void 0:O.primaryText)!=null?J:"#ffffff":(Z=O==null?void 0:O.accent)!=null?Z:"inherit",border:q==="secondary"?`1px solid ${(G=O==null?void 0:O.accent)!=null?G:"currentColor"}`:"none"})}case"link":{let A=t.createElement("a");A.textContent=e.label;let P=Wt(e.href);return P&&(A.href=P),e.tag&&A.setAttribute("data-sentient-tag",e.tag),M?ie(A):he(A,{color:"inherit","text-decoration":"underline"})}case"image":{let A=t.createElement("img"),P=Wt(e.src);return P&&(A.src=P),A.alt=e.alt,M&&(A.className=M),he(A,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Gr[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let A=t.createElement("span");return A.textContent=e.value,M?ie(A):he(A,K({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(X=O==null?void 0:O.border)!=null?X:"currentColor"}`},wo(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(ne=xo[e.size])!=null?ne:xo.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(Q=O==null?void 0:O.border)!=null?Q:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(M){return null}}function To(e,t,n,r){var s,c;try{let m=new Set;for(let g of Array.from(e.children)){let k=g.getAttribute(kn);k!==null&&(t[k]===void 0?g.remove():m.add(k))}for(let[g,k]of Object.entries(t)){if(m.has(g))continue;let y="tree"in k?k:null,$=Co(y?y.tree:k,r);if(!$)continue;let L=r.createElement("div");L.setAttribute(kn,g),L.style.display="none";let D=y?So((s=y.surface)==null?void 0:s.like):void 0;if(D){let E=r.createElement("div");E.className=D;let z=Eo((c=y.surface)==null?void 0:c.like);z&&(E.style.color=z),E.appendChild($),L.appendChild(E)}else L.appendChild($);e.appendChild(L)}let x=n!==void 0&&t[n]!==void 0;for(let g of Array.from(e.children)){let k=g.getAttribute(kn),y=g;k!==null?y.style.display=x&&k===n?"":"none":x?y.hasAttribute($t)||(y.setAttribute($t,y.style.display),y.style.display="none"):y.hasAttribute($t)&&(y.style.display=y.getAttribute($t),y.removeAttribute($t))}}catch(m){}}var qr=/(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)|#[0-9a-f]{3,8}\b/gi,Vr=/^rgba?\(\s*[\d.]+[,\s]+[\d.]+[,\s]+[\d.]+(?:[,\s/]+[\d.]+%?)?\s*\)$/i,Bt;function Yr(e){if(Bt!==void 0)return Bt;try{let t=e.createElement("canvas");t.width=t.height=1,Bt=t.getContext("2d",{willReadFrequently:!0})}catch(t){Bt=null}return Bt}function ke(e,t){let n=(e!=null?e:"").trim();if(n===""||n==="transparent")return n==="transparent"?"rgba(0, 0, 0, 0)":"";if(Vr.test(n)||/^#[0-9a-f]{3,8}$/i.test(n))return n;let r=Yr(t);if(!r)return"";try{if(r.fillStyle="#010203",r.fillStyle=n,String(r.fillStyle).toLowerCase()==="#010203"&&n.toLowerCase()!=="#010203")return"";r.clearRect(0,0,1,1),r.fillRect(0,0,1,1);let[s,c,m,x]=r.getImageData(0,0,1,1).data;return x===255?`rgb(${s}, ${c}, ${m})`:`rgba(${s}, ${c}, ${m}, ${Math.round(x/255*1e3)/1e3})`}catch(s){return""}}function qt(e,t){var n;return!e||e==="none"||!/gradient/i.test(e)?[]:((n=e.match(qr))!=null?n:[]).map(r=>ke(r,t)).filter(r=>r!=="")}hn();function Io(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function Lo(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function Ao(e){let t=e.join("");return Lo(t,2166136261)+Lo(t,1523705862)}var Jr=new Set(["A","BUTTON"]),$o=/^H([1-6])$/,Xr=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]),Zr=new Set(["LABEL","FIGCAPTION","DT"]),Qr=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function Bo(e){return Jr.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function ei(e){if($o.test(e.tagName)||Xr.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function ti(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(Bo(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||ei(r))return r;return t}function _o(e,t){var n,r;if(e)try{let s=new URL(e,(r=(n=t.location)==null?void 0:n.href)!=null?r:"https://relative.invalid/");return s.protocol!=="https:"&&s.protocol!=="http:"?void 0:t.location&&s.origin===t.location.origin?s.pathname:`${s.origin}${s.pathname}`}catch(s){return}}function Oo(e){return e===""||e==="transparent"||/rgba\([^)]*,\s*0\)$/.test(e)}function ni(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{bg:null};for(let r=e;r;r=r.parentElement){let s=n.getComputedStyle(r),c=qt(s.backgroundImage,t);if(c.length>0)return de({bg:c[0]},c.length>1?{alt:c[c.length-1]}:{});let m=ke(s.backgroundColor,t);if(!Oo(m))return{bg:m}}return{bg:null}}function En(e,t=40){var n,r,s;let c=e.ownerDocument.createTreeWalker(e,4),m=[];for(let y=c.nextNode();y;y=c.nextNode())if(((n=y.nodeValue)!=null?n:"").trim()!==""&&!Qr.has((s=(r=y.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(y),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let x=[],g=[];for(let y of m){let $=ti(y,e),L=x.indexOf($);L===-1&&(x.push($),L=x.length-1),g.push(L)}if(x.length>t)return{reason:"too_large"};let k=m.map(y=>{var $;return Io(($=y.nodeValue)!=null?$:"")});return{textNodes:m,ownerEls:x,leafToNode:g,leaves:k,fp:Ao(k)}}function oi(e,t=40){var n;let r=En(e,t);if(!("fp"in r))return{skeleton:null,reason:r.reason};let{textNodes:s,ownerEls:c,leafToNode:m,leaves:x}=r,g=e.ownerDocument,k=g.defaultView,y=[],$=c.map((E,z)=>{var J,Z;let G=k==null?void 0:k.getComputedStyle(E),X=(J=E.parentElement)!=null?J:e,ne=y.indexOf(X);ne===-1&&(y.push(X),ne=y.length-1);let Q=$o.exec(E.tagName),M=Bo(E)?"action":Q?"heading":Zr.has(E.tagName)?"label":"text",re=Io(x.filter((ie,A)=>m[A]===z).join(" "));return lt(de(lt(de({tag:E.tagName.toLowerCase(),role:M},Q?{level:Number(Q[1])}:{}),{text:re,classes:((Z=E.getAttribute("class"))!=null?Z:"").replace(/\s+/g," ").trim()}),M==="action"?de({filled:!!G&&(!Oo(ke(G.backgroundColor,e.ownerDocument))||G.backgroundImage!==""&&G.backgroundImage!=="none")},_o(E.getAttribute("href"),g)!==void 0?{href:_o(E.getAttribute("href"),g)}:{}):{}),{color:ke(G==null?void 0:G.color,e.ownerDocument),group:ne,restylable:!0})}),L=ni(e),D=k==null?void 0:k.getComputedStyle(e);return{skeleton:{v:1,root:lt(de({tag:e.tagName.toLowerCase(),classes:((n=e.getAttribute("class"))!=null?n:"").replace(/\s+/g," ").trim(),ambientBg:L.bg},L.alt?{ambientBgAlt:L.alt}:{}),{ambientText:ke(D==null?void 0:D.color,e.ownerDocument)}),nodes:$,leaves:x,leafToNode:m,fp:Ao(x)},textNodes:s,ownerEls:c}}function Mo(e,t){try{let n=oi(e,t==null?void 0:t.maxNodes);return n.skeleton?{skeleton:n.skeleton}:n}catch(n){return{skeleton:null,reason:"unaddressable"}}}var Po=new WeakMap;function No(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Ro(e,t,n){var c,m,x;let r=Po.get(e);if(r){if(r.fp!==n.fp||!No(r.leafToNode,n.leafToNode))return"mismatch"}else{let g=En(e);if(!("fp"in g)||(r={fp:g.fp,leafToNode:g.leafToNode,textNodes:g.textNodes,ownerEls:g.ownerEls,classes:g.ownerEls.map(k=>{var y;return(y=k.getAttribute("class"))!=null?y:""})},r.fp!==n.fp||!No(r.leafToNode,n.leafToNode)))return"mismatch";Po.set(e,r)}let s=r;for(let[g,k]of Object.entries(t.nodes)){let y=Number(g),$=s.ownerEls[y];if($){if(typeof k.text=="string"){let L=!0;s.leafToNode.forEach((D,E)=>{D===y&&(s.textNodes[E].nodeValue=L?k.text:"",L=!1)})}k.like!==void 0&&s.classes[k.like]!==void 0&&$.setAttribute("class",s.classes[k.like]),k.hidden&&((c=$.style)==null||c.setProperty("display","none","important"))}}for(let g of Object.values((m=t.order)!=null?m:{})){let k=g.map(E=>s.ownerEls[E]).filter(E=>!!E),y=(x=k[0])==null?void 0:x.parentElement;if(!y||k.length!==g.length||k.some(E=>E.parentElement!==y))continue;let $=new Set(k),L=0;Array.from(y.children).map(E=>$.has(E)?k[L++]:E).forEach((E,z)=>{var J;y.children[z]!==E&&y.insertBefore(E,(J=y.children[z])!=null?J:null)})}return"applied"}hn();var ri=4,ii=new Set(["inline-block","block","flex","inline-flex"]),Do={H1:"heading-1",H2:"heading-2",H3:"heading-3"},Ot=null;function He(e){let t=Ot?ke(e,Ot):e,n=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(t);if(!n)return null;let r=n[4]===void 0?1:n[4].endsWith("%")?Number.parseFloat(n[4])/100:Number(n[4]);return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:r}}function Yt(e){let t=n=>{let r=n/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Cn(e,t){let[n,r]=[Yt(e),Yt(t)].sort((s,c)=>c-s);return(n+.05)/(r+.05)}var Jt=e=>{let t=He(e);return t!==null&&t.a>0};function Tn(e){return Ot?qt(e,Ot):[]}var De=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function Ho(e,t){for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(Jt(r.backgroundColor))return He(r.backgroundColor);let s=Tn(r.backgroundImage);if(s.length>0)return He(s[0])}return{r:255,g:255,b:255,a:1}}var ai='#CybotCookiebotDialog, #onetrust-consent-sdk, #usercentrics-root, #usercentrics-cmp-ui, .cky-consent-container, .cky-modal, #didomi-host, #qc-cmp2-container, #cmplz-cookiebanner-container, .cc-window, #cc-main, #iubenda-cs-banner, #truste-consent-track, [id^="sp_message_container"], #termly-code-snippet-support';function si(e,t,n){if(e.closest(ai))return!0;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement){let s=t.getComputedStyle(r).position;if(s==="fixed"||s==="sticky"){let c=r.getBoundingClientRect().width;return c>0&&n>0&&c<.6*n}}return!1}function Vt(e){var t;for(let n of Array.from(e.childNodes))if(n.nodeType===3&&((t=n.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function li(e,t,n){var r;let s=e.tagName,c=De(t.fontSize)||n.bodySize,m=Number(t.fontWeight)||400,x=Jt(t.backgroundColor),g=Tn(t.backgroundImage).length>0,k=De(t.borderTopLeftRadius||t.borderRadius),y=e.getBoundingClientRect().width;if(s==="BUTTON"||e.getAttribute("role")==="button"||s==="INPUT"&&/^(submit|button)$/i.test(e.type)||s==="A"&&ii.has(t.display)&&De(t.paddingLeft)>=8){if(((r=e.textContent)!=null?r:"").trim()==="")return null;let L=He(t.backgroundColor),D=e.parentElement?Ho(e.parentElement,n.view):n.pageBg;return x&&L&&L.a>=.9&&Cn(L,D)>=1.5?"button-primary":x||De(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(s==="A")return"link";if(Do[s])return Do[s];if(Vt(e)&&c>=1.8*n.bodySize&&m>=600)return c>=2.5*n.bodySize?"heading-1":c>=2*n.bodySize?"heading-2":"heading-3";let $=e.nextElementSibling;if(Vt(e)&&c<=.9*n.bodySize&&(t.textTransform==="uppercase"||De(t.letterSpacing)>.05*c)&&$!==null&&/^H[1-4]$/.test($.tagName))return"eyebrow";if(s==="UL"||s==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(s==="P"&&Vt(e)){if(c>=1.1*n.bodySize)return"text-lead";if(c<=.85*n.bodySize)return"text-small";let L=He(t.color);return L&&Cn(L,Ho(e,n.view))<n.bodyContrast*.8?"text-muted":"text-body"}return(s==="SPAN"||s==="DIV")&&x&&Vt(e)&&e.children.length===0&&k>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(s)&&(x||g)&&k>0&&De(t.paddingTop)>=16&&!(y>0&&y>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(s)&&(x||g)&&e.querySelector("h1,h2,h3")!==null&&(y===0||y>=.9*n.vw)?"section":null}function zo(e,t){var n,r,s,c,m,x,g,k,y;let $=e.defaultView;if(!$||!e.body)return{entries:[],images:[]};Ot=e;let L=$.getComputedStyle(e.body),D=De(L.fontSize)||16,E=Jt(L.backgroundColor)?He(L.backgroundColor):{r:255,g:255,b:255,a:1},z=(n=He(L.color))!=null?n:{r:17,g:24,b:39,a:1},J={bodySize:D,pageBg:E,bodyContrast:Cn(z,E),view:$,vw:$.innerWidth||0},Z=(s=(r=$.location)==null?void 0:r.pathname)!=null?s:"/",G=new Date().toISOString(),X=new Map,ne=new Map,Q=new Map,M=Array.from(e.body.querySelectorAll("*")).slice(0,(c=t==null?void 0:t.maxElements)!=null?c:4e3);for(let P of M)try{if(P.tagName==="IMG"){let ee=P,Ae=((m=ee.getAttribute("alt"))!=null?m:"").trim(),Y=ee.naturalWidth||Number(ee.getAttribute("width"))||0,et=ee.naturalHeight||Number(ee.getAttribute("height"))||0,ve=ee.getAttribute("src");if(Ae&&Y>=200&&ve){let $e=new URL(ve,e.baseURI).href;$e.startsWith("https://")&&!Q.has($e)&&Q.set($e,{id:`img-${Q.size+1}`,src:$e,alt:Ae.slice(0,200),w:Y,h:et,seenOn:Z})}}let q=((x=P.getAttribute("class"))!=null?x:"").replace(/\s+/g," ").trim();if(q===""||si(P,$,J.vw))continue;let B=$.getComputedStyle(P),V=P.tagName==="IMG"?((g=P.getAttribute("alt"))!=null?g:"").trim()?"image":null:li(P,B,J);if(!V)continue;let Se=`${V}|${q}`,ze=P.getBoundingClientRect();ne.set(Se,Math.max((k=ne.get(Se))!=null?k:0,ze.width*ze.height));let Ie=X.get(Se);if(Ie){Ie.seen.count++;continue}let ye=Tn(B.backgroundImage).map(He).filter(ee=>ee!==null),ue,je;if(Jt(B.backgroundColor))ue=ke(B.backgroundColor,e);else if(ye.length>0){let ee=[...ye].sort((Y,et)=>Yt(Y)-Yt(et)),Ae=Y=>Y.a<1?`rgba(${Y.r}, ${Y.g}, ${Y.b}, ${Y.a})`:`rgb(${Y.r}, ${Y.g}, ${Y.b})`;ue=Ae(ee[0]),ee.length>1&&(je=Ae(ee[ee.length-1]))}let pe=B.borderTopLeftRadius||B.borderRadius;X.set(Se,{id:V,role:V,classes:q,computed:de(de(de(de(de(de(de({},ke(B.color,e)?{color:ke(B.color,e)}:{}),P.parentElement&&$.getComputedStyle(P.parentElement).color===B.color?{inheritsColor:!0}:{}),ue?{bg:ue}:{}),je?{bgDark:je}:{}),B.fontSize?{fontSize:B.fontSize}:{}),B.fontWeight?{fontWeight:B.fontWeight}:{}),pe&&De(pe)>0?{radius:pe}:{}),seen:{url:Z,count:1,at:G}})}catch(q){}let re=new Map;for(let P of X.values())re.set(P.role,[...(y=re.get(P.role))!=null?y:[],P]);let ie=[],A=P=>{var q;return(q=ne.get(`${P.role}|${P.classes}`))!=null?q:0};for(let[P,q]of re)q.sort((B,V)=>(P.startsWith("button-")?A(V)-A(B):0)||V.seen.count-B.seen.count).slice(0,ri).forEach((B,V)=>ie.push(lt(de({},B),{id:V===0?P:`${P}-${V+1}`})));return{entries:ie,images:[...Q.values()]}}function jo(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let r=0;r<e.length;r++){let s=e[r],c=s>="0"&&s<="9";r===0&&c||r===1&&c&&e[0]==="-"?n+=`\\3${s} `:r===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function ci(e,t){if(e.id)return`#${jo(e.id)}`;let n=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){n.unshift(`#${jo(r.id)}`);break}let c=r.tagName.toLowerCase(),m=r.parentElement;if(m){let x=Array.from(m.children).filter(g=>g.tagName===r.tagName);x.length>1&&(c+=`:nth-of-type(${x.indexOf(r)+1})`)}n.unshift(c),r=r.parentElement,s++}return n.join(" > ")}function Xe(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let c of["data-framer-name","data-w-id","data-sentient-name"]){let m=e.getAttribute(c);if(m){n.dataAttr={name:c,value:m};break}}n.selector=ci(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=K({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function ut(e,t,n){return we(e,n)===t}var Ko="__snt_editor_token";function Uo(e){try{sessionStorage.setItem(Ko,e)}catch(t){}}function Mt(){try{sessionStorage.removeItem(Ko)}catch(e){}}var di=/rgba\([^)]*,\s*0\s*\)$/,ui=/^\d+(\.\d+)?px$/;function Go(e){var t,n;try{let r=e.defaultView;if(!r||!e.body)return null;let s=r.getComputedStyle(e.body).backgroundColor,c=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),m=new Map;for(let L of Array.from(c).slice(0,300)){let D=L.getBoundingClientRect();if(D.width>0&&(D.width<48||D.height<24))continue;let E=r.getComputedStyle(L),z=E.backgroundColor;if(!z||z==="transparent"||z===s||di.test(z))continue;let J=(t=(E.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${z}|${E.color}|${ui.test(J)?J:"8px"}`;m.set(Z,((n=m.get(Z))!=null?n:0)+1)}let x=null,g=0;for(let[L,D]of m)D>g&&(x=L,g=D);if(!x)return null;let[k,y,$]=x.split("|");return{primaryBg:k,primaryText:y,radius:$}}catch(r){return null}}function Pt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Fo(e,t){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===t?`This page (${e})`:`Only on ${e}`}function Ln(e,t){let n=Pt(e),r=n.split("/").filter(Boolean),s=[n,"*"];return r.length>=2&&s.push(`/${r[0]}/*`),(t?[t,...s.filter(c=>c!==t)]:s).filter(c=>yn.test(c))}function Xt(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Zt(e,t){return e.steps.map(n=>{var r;return{value:n.step_index,label:`${n.step_index+1}. ${(r=t.get(n.goal_id))!=null?r:n.goal_id}`}})}function Wo(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function pi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function qo(e,t){let n=e.trim();return n?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:pi(n),body:{displayName:n.slice(0,128),steps:t.map(r=>({goalId:r}))}}:{ok:!1,error:"Give the funnel a name."}}function Zo(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function pt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Te(e,t,n){var x,g;let r=t.id||((x=t.dataAttr)==null?void 0:x.value)||((g=n.textContent)!=null?g:"").trim()||n.tagName,s=pt(r)||"el",c=Zo(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var fi="sentient-editor-highlight",gi="sentient-editor-selection",gt="sentient-editor-panel",tn="sentient-editor-toast",In="sentient-editor-styles",An="sentient-editor-target-highlight",mi=10,Vo="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Yo="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Qo(){var t;if(document.getElementById(In))return;let e=It(document.createElement("style"));e.id=In,e.textContent=`
1
+ "use strict";var __sentientEditorBundle=(()=>{var Ft=Object.defineProperty,kr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptor,Er=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertyNames,Ut=Object.getOwnPropertySymbols;var mn=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable;var lo=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))mn.call(t,n)&&lo(e,n,t[n]);if(Ut)for(var n of Ut(t))co.call(t,n)&&lo(e,n,t[n]);return e},le=(e,t)=>kr(e,Er(t));var uo=e=>typeof e=="symbol"?e:e+"",po=(e,t)=>{var n={};for(var r in e)mn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ut)for(var r of Ut(e))t.indexOf(r)<0&&co.call(e,r)&&(n[r]=e[r]);return n};var Cr=(e,t)=>()=>(e&&(t=e(e=0)),t);var Lr=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0})},Ar=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Tr(t))!mn.call(e,s)&&s!==n&&Ft(e,s,{get:()=>t[s],enumerable:!(r=Sr(t,s))||r.enumerable});return e};var _r=e=>Ar(Ft({},"__esModule",{value:!0}),e);var Ir,$r,Br,fo,Or,Mr,go,de,lt,hn=Cr(()=>{"use strict";Ir=Object.defineProperty,$r=Object.defineProperties,Br=Object.getOwnPropertyDescriptors,fo=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Mr=Object.prototype.propertyIsEnumerable,go=(e,t,n)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,de=(e,t)=>{for(var n in t||(t={}))Or.call(t,n)&&go(e,n,t[n]);if(fo)for(var n of fo(t))Mr.call(t,n)&&go(e,n,t[n]);return e},lt=(e,t)=>$r(e,Br(t))});var Bi={};Lr(Bi,{buildStyleOps:()=>Rn,clearTargetHighlights:()=>mt,computeMoveAnchors:()=>en,deriveSlotId:()=>Ce,drawTargetHighlights:()=>nr,exchangeCode:()=>er,isHex6:()=>Nn,mount:()=>ir,registerAuditTargets:()=>tr,sectionTypesFor:()=>or,styleFieldError:()=>rr,toHexColor:()=>Bn});var mo;function ho(e=document){if(mo)return mo;try{let t=e.querySelector("script[nonce]");return(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"))||void 0}catch(t){return}}function _t(e,t=document){let n=ho(t);return n&&e.setAttribute("nonce",n),e}var Ri=1800*1e3;var yn=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Rr(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Pr(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(),s=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var Nr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Dr(e,t){var r;let n=[];if(e.id){let s=t.getElementById(e.id);n=s?[s]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Nr.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(s){n=[]}return n}function we(e,t){if(e.urlMatch&&!Rr(t).includes(e.urlMatch))return null;let n=Dr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Pr(r,e.fingerprint)?null:r}var It={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"},Hr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function ct(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(!Hr.test((r=n[1])!=null?r:""))return!1;return!0}function bn(e){var r,s;let t=e.ownerDocument.createTreeWalker(e,4),n=null;for(let c=t.nextNode();c!==null;c=t.nextNode()){if(((r=c.nodeValue)!=null?r:"").trim()==="")continue;let m=(s=c.parentElement)==null?void 0:s.tagName;if(!(m==="SCRIPT"||m==="STYLE"||m==="TEMPLATE")){if(n!==null)return null;n=c}}return n}function vn(e){return e.childElementCount===0||bn(e)!==null}function xn(e){var t,n,r;return(r=(n=(t=bn(e))==null?void 0:t.nodeValue)!=null?n:e.textContent)!=null?r:""}function Ye(e,t){let n=bn(e);n!==null?n.nodeValue=t:e.textContent=t}var wn=/^https:\/\//i;function Wt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(wn.test(e)||e[0]==="/"&&e[1]!=="/")?e:null}var yo=new Map,Ne=null;function zr(e){return e.replace(/["\\]/g,"\\$&")}function jr(e){var t;(!Ne||!Ne.isConnected)&&(Ne=e.querySelector("style[data-sentient-ops]"),Ne||(Ne=_t(e.createElement("style"),e),Ne.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Ne))),Ne.textContent=[...yo.entries()].map(([n,r])=>`[data-snt-e="${zr(n)}"]{${r}}`).join(`
2
+ `)}function bo(e,t,n,r){var x;let s=!1,c=(x=t.moveBefore)!=null?x:t.moveAfter;if(c){let g=we(c,r);!g||g===e||g.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,g):e.parentElement.insertBefore(e,g.nextSibling)}typeof t.text=="string"&&Ye(e,t.text),typeof t.href=="string"&&wn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&wn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let m=[];if(t.hidden&&m.push("display:none !important"),t.style)for(let[g,k]of Object.entries(t.style)){let y=It[g];y&&typeof k=="string"&&ct(k)&&m.push(`${y}:${k.trim()} !important`)}return m.length>0&&(e.setAttribute("data-snt-e",n),yo.set(n,m.join(";")),jr(r)),{anchorMiss:s}}var kn="data-sentient-block-arm",O=null;var Je=null;function ko(e){Je=e!=null?e:null}var So=e=>{var t;return typeof e=="string"?(t=Je==null?void 0:Je.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},Eo=e=>{let t=typeof e=="string"?Je==null?void 0:Je.entries.find(n=>n.id===e):void 0;return t!=null&&t.computed.inheritsColor?t.computed.color:void 0},$t="data-sentient-blocks-hid",dt={none:"0",sm:"8px",md:"16px",lg:"24px"},Sn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},vo={sm:"0.875em",md:"1em",lg:"1.25em"},Kr={sm:"1.25em",md:"1.5em",lg:"2em"},Gr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},xo={sm:"8px",md:"16px",lg:"32px"},Ur={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Fr={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function wo(e){return e==="muted"?O!=null&&O.muted?{color:O.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:O==null?void 0:O.accent}:{}}function To(e,t){let n=Wr(e,t),r=Eo(e.like);return n&&r&&(n.style.color=r),n}function Wr(e,t){var n,r,s,c,m,x,g,k,y,$,L,D,E,z,J,Z,U,X,ne,Q;try{let M=So(e.like),re=e.maxWidth==="measure"?"65ch":void 0,ie=I=>(I.className=M,he(I,{"max-width":re}));switch(e.type){case"stack":case"grid":{let I=t.createElement("div");if(e.type==="stack"){let B=e;he(I,{display:"flex","flex-direction":B.direction,gap:(r=dt[(n=B.gap)!=null?n:"md"])!=null?r:dt.md,"align-items":B.align?Sn[B.align]:void 0,"justify-content":B.justify?Sn[B.justify]:void 0,"flex-wrap":B.wrap?"wrap":void 0})}else{let B=e,V=(c=dt[(s=B.gap)!=null?s:"md"])!=null?c:dt.md;he(I,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${B.columns-1} * ${V}) / ${B.columns})), 1fr))`,gap:V,"align-items":B.align?Sn[B.align]:void 0})}M&&(I.className=M);let R=!M&&e.type==="stack"&&e.surface==="raised",q=(m=e.pad)!=null?m:R?"md":void 0;q&&he(I,{padding:(x=dt[q])!=null?x:dt.md}),R&&he(I,{background:O==null?void 0:O.surface,color:O!=null&&O.surface?O==null?void 0:O.surfaceText:void 0,border:`1px solid ${(g=O==null?void 0:O.border)!=null?g:"currentColor"}`,"border-radius":(k=O==null?void 0:O.radius)!=null?k:"8px"});for(let B of(y=e.children)!=null?y:[]){let V=To(B,t);V&&I.appendChild(V)}return I}case"text":{let I=t.createElement("p");return I.textContent=e.value,M?ie(I):he(I,le(K({margin:"0","font-size":e.size?vo[e.size]:void 0,"font-weight":e.weight?Fr[e.weight]:void 0,"text-align":e.align},wo(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let I=t.createElement(`h${e.level}`);return I.textContent=e.value,M?ie(I):he(I,{margin:"0","font-size":Kr[($=e.size)!=null?$:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let I=t.createElement("a");I.textContent=e.label;let R=Wt(e.href);if(R&&(I.href=R),e.tag&&I.setAttribute("data-sentient-tag",e.tag),M)return ie(I);let q=(L=e.emphasis)!=null?L:"primary";return he(I,{display:"inline-block",padding:Gr[(D=e.size)!=null?D:"md"],"border-radius":(E=O==null?void 0:O.radius)!=null?E:"8px",font:"inherit","font-size":e.size?vo[e.size]:void 0,"text-decoration":q==="ghost"?"underline":"none",cursor:"pointer",background:q==="primary"?(z=O==null?void 0:O.primaryBg)!=null?z:"#111827":"transparent",color:q==="primary"?(J=O==null?void 0:O.primaryText)!=null?J:"#ffffff":(Z=O==null?void 0:O.accent)!=null?Z:"inherit",border:q==="secondary"?`1px solid ${(U=O==null?void 0:O.accent)!=null?U:"currentColor"}`:"none"})}case"link":{let I=t.createElement("a");I.textContent=e.label;let R=Wt(e.href);return R&&(I.href=R),e.tag&&I.setAttribute("data-sentient-tag",e.tag),M?ie(I):he(I,{color:"inherit","text-decoration":"underline"})}case"image":{let I=t.createElement("img"),R=Wt(e.src);return R&&(I.src=R),I.alt=e.alt,M&&(I.className=M),he(I,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Ur[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let I=t.createElement("span");return I.textContent=e.value,M?ie(I):he(I,K({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(X=O==null?void 0:O.border)!=null?X:"currentColor"}`},wo(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(ne=xo[e.size])!=null?ne:xo.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(Q=O==null?void 0:O.border)!=null?Q:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(M){return null}}function Co(e,t,n,r){var s,c;try{let m=new Set;for(let g of Array.from(e.children)){let k=g.getAttribute(kn);k!==null&&(t[k]===void 0?g.remove():m.add(k))}for(let[g,k]of Object.entries(t)){if(m.has(g))continue;let y="tree"in k?k:null,$=To(y?y.tree:k,r);if(!$)continue;let L=r.createElement("div");L.setAttribute(kn,g),L.style.display="none";let D=y?So((s=y.surface)==null?void 0:s.like):void 0;if(D){let E=r.createElement("div");E.className=D;let z=Eo((c=y.surface)==null?void 0:c.like);z&&(E.style.color=z),E.appendChild($),L.appendChild(E)}else L.appendChild($);e.appendChild(L)}let x=n!==void 0&&t[n]!==void 0;for(let g of Array.from(e.children)){let k=g.getAttribute(kn),y=g;k!==null?y.style.display=x&&k===n?"":"none":x?y.hasAttribute($t)||(y.setAttribute($t,y.style.display),y.style.display="none"):y.hasAttribute($t)&&(y.style.display=y.getAttribute($t),y.removeAttribute($t))}}catch(m){}}var qr=/(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)|#[0-9a-f]{3,8}\b/gi,Vr=/^rgba?\(\s*[\d.]+[,\s]+[\d.]+[,\s]+[\d.]+(?:[,\s/]+[\d.]+%?)?\s*\)$/i,Bt;function Yr(e){if(Bt!==void 0)return Bt;try{let t=e.createElement("canvas");t.width=t.height=1,Bt=t.getContext("2d",{willReadFrequently:!0})}catch(t){Bt=null}return Bt}function ke(e,t){let n=(e!=null?e:"").trim();if(n===""||n==="transparent")return n==="transparent"?"rgba(0, 0, 0, 0)":"";if(Vr.test(n)||/^#[0-9a-f]{3,8}$/i.test(n))return n;let r=Yr(t);if(!r)return"";try{if(r.fillStyle="#010203",r.fillStyle=n,String(r.fillStyle).toLowerCase()==="#010203"&&n.toLowerCase()!=="#010203")return"";r.clearRect(0,0,1,1),r.fillRect(0,0,1,1);let[s,c,m,x]=r.getImageData(0,0,1,1).data;return x===255?`rgb(${s}, ${c}, ${m})`:`rgba(${s}, ${c}, ${m}, ${Math.round(x/255*1e3)/1e3})`}catch(s){return""}}function qt(e,t){var n;return!e||e==="none"||!/gradient/i.test(e)?[]:((n=e.match(qr))!=null?n:[]).map(r=>ke(r,t)).filter(r=>r!=="")}hn();function _o(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function Lo(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function Io(e){let t=e.join("");return Lo(t,2166136261)+Lo(t,1523705862)}var Jr=new Set(["A","BUTTON"]),$o=/^H([1-6])$/,Xr=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]),Zr=new Set(["LABEL","FIGCAPTION","DT"]),Qr=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function Bo(e){return Jr.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function ei(e){if($o.test(e.tagName)||Xr.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function ti(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(Bo(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||ei(r))return r;return t}function Ao(e,t){var n,r;if(e)try{let s=new URL(e,(r=(n=t.location)==null?void 0:n.href)!=null?r:"https://relative.invalid/");return s.protocol!=="https:"&&s.protocol!=="http:"?void 0:t.location&&s.origin===t.location.origin?s.pathname:`${s.origin}${s.pathname}`}catch(s){return}}function Oo(e){return e===""||e==="transparent"||/rgba\([^)]*,\s*0\)$/.test(e)}function ni(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{bg:null};for(let r=e;r;r=r.parentElement){let s=n.getComputedStyle(r),c=qt(s.backgroundImage,t);if(c.length>0)return de({bg:c[0]},c.length>1?{alt:c[c.length-1]}:{});let m=ke(s.backgroundColor,t);if(!Oo(m))return{bg:m}}return{bg:null}}function En(e,t=40){var n,r,s;let c=e.ownerDocument.createTreeWalker(e,4),m=[];for(let y=c.nextNode();y;y=c.nextNode())if(((n=y.nodeValue)!=null?n:"").trim()!==""&&!Qr.has((s=(r=y.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(y),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let x=[],g=[];for(let y of m){let $=ti(y,e),L=x.indexOf($);L===-1&&(x.push($),L=x.length-1),g.push(L)}if(x.length>t)return{reason:"too_large"};let k=m.map(y=>{var $;return _o(($=y.nodeValue)!=null?$:"")});return{textNodes:m,ownerEls:x,leafToNode:g,leaves:k,fp:Io(k)}}function oi(e,t=40){var n;let r=En(e,t);if(!("fp"in r))return{skeleton:null,reason:r.reason};let{textNodes:s,ownerEls:c,leafToNode:m,leaves:x}=r,g=e.ownerDocument,k=g.defaultView,y=[],$=c.map((E,z)=>{var J,Z;let U=k==null?void 0:k.getComputedStyle(E),X=(J=E.parentElement)!=null?J:e,ne=y.indexOf(X);ne===-1&&(y.push(X),ne=y.length-1);let Q=$o.exec(E.tagName),M=Bo(E)?"action":Q?"heading":Zr.has(E.tagName)?"label":"text",re=_o(x.filter((ie,I)=>m[I]===z).join(" "));return lt(de(lt(de({tag:E.tagName.toLowerCase(),role:M},Q?{level:Number(Q[1])}:{}),{text:re,classes:((Z=E.getAttribute("class"))!=null?Z:"").replace(/\s+/g," ").trim()}),M==="action"?de({filled:!!U&&(!Oo(ke(U.backgroundColor,e.ownerDocument))||U.backgroundImage!==""&&U.backgroundImage!=="none")},Ao(E.getAttribute("href"),g)!==void 0?{href:Ao(E.getAttribute("href"),g)}:{}):{}),{color:ke(U==null?void 0:U.color,e.ownerDocument),group:ne,restylable:!0})}),L=ni(e),D=k==null?void 0:k.getComputedStyle(e);return{skeleton:{v:1,root:lt(de({tag:e.tagName.toLowerCase(),classes:((n=e.getAttribute("class"))!=null?n:"").replace(/\s+/g," ").trim(),ambientBg:L.bg},L.alt?{ambientBgAlt:L.alt}:{}),{ambientText:ke(D==null?void 0:D.color,e.ownerDocument)}),nodes:$,leaves:x,leafToNode:m,fp:Io(x)},textNodes:s,ownerEls:c}}function Mo(e,t){try{let n=oi(e,t==null?void 0:t.maxNodes);return n.skeleton?{skeleton:n.skeleton}:n}catch(n){return{skeleton:null,reason:"unaddressable"}}}var Ro=new WeakMap;function Po(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function No(e,t,n){var c,m,x;let r=Ro.get(e);if(r){if(r.fp!==n.fp||!Po(r.leafToNode,n.leafToNode))return"mismatch"}else{let g=En(e);if(!("fp"in g)||(r={fp:g.fp,leafToNode:g.leafToNode,textNodes:g.textNodes,ownerEls:g.ownerEls,classes:g.ownerEls.map(k=>{var y;return(y=k.getAttribute("class"))!=null?y:""})},r.fp!==n.fp||!Po(r.leafToNode,n.leafToNode)))return"mismatch";Ro.set(e,r)}let s=r;for(let[g,k]of Object.entries(t.nodes)){let y=Number(g),$=s.ownerEls[y];if($){if(typeof k.text=="string"){let L=!0;s.leafToNode.forEach((D,E)=>{D===y&&(s.textNodes[E].nodeValue=L?k.text:"",L=!1)})}k.like!==void 0&&s.classes[k.like]!==void 0&&$.setAttribute("class",s.classes[k.like]),k.hidden&&((c=$.style)==null||c.setProperty("display","none","important"))}}for(let g of Object.values((m=t.order)!=null?m:{})){let k=g.map(E=>s.ownerEls[E]).filter(E=>!!E),y=(x=k[0])==null?void 0:x.parentElement;if(!y||k.length!==g.length||k.some(E=>E.parentElement!==y))continue;let $=new Set(k),L=0;Array.from(y.children).map(E=>$.has(E)?k[L++]:E).forEach((E,z)=>{var J;y.children[z]!==E&&y.insertBefore(E,(J=y.children[z])!=null?J:null)})}return"applied"}hn();var ri=4,ii=new Set(["inline-block","block","flex","inline-flex"]),Do={H1:"heading-1",H2:"heading-2",H3:"heading-3"},Ot=null;function He(e){let t=Ot?ke(e,Ot):e,n=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(t);if(!n)return null;let r=n[4]===void 0?1:n[4].endsWith("%")?Number.parseFloat(n[4])/100:Number(n[4]);return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:r}}function Yt(e){let t=n=>{let r=n/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Tn(e,t){let[n,r]=[Yt(e),Yt(t)].sort((s,c)=>c-s);return(n+.05)/(r+.05)}var Jt=e=>{let t=He(e);return t!==null&&t.a>0};function Cn(e){return Ot?qt(e,Ot):[]}var De=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function Ho(e,t){for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(Jt(r.backgroundColor))return He(r.backgroundColor);let s=Cn(r.backgroundImage);if(s.length>0)return He(s[0])}return{r:255,g:255,b:255,a:1}}var ai='#CybotCookiebotDialog, #onetrust-consent-sdk, #usercentrics-root, #usercentrics-cmp-ui, .cky-consent-container, .cky-modal, #didomi-host, #qc-cmp2-container, #cmplz-cookiebanner-container, .cc-window, #cc-main, #iubenda-cs-banner, #truste-consent-track, [id^="sp_message_container"], #termly-code-snippet-support';function si(e,t,n){if(e.closest(ai))return!0;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement){let s=t.getComputedStyle(r).position;if(s==="fixed"||s==="sticky"){let c=r.getBoundingClientRect().width;return c>0&&n>0&&c<.6*n}}return!1}function Vt(e){var t;for(let n of Array.from(e.childNodes))if(n.nodeType===3&&((t=n.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function li(e,t,n){var r;let s=e.tagName,c=De(t.fontSize)||n.bodySize,m=Number(t.fontWeight)||400,x=Jt(t.backgroundColor),g=Cn(t.backgroundImage).length>0,k=De(t.borderTopLeftRadius||t.borderRadius),y=e.getBoundingClientRect().width;if(s==="BUTTON"||e.getAttribute("role")==="button"||s==="INPUT"&&/^(submit|button)$/i.test(e.type)||s==="A"&&ii.has(t.display)&&De(t.paddingLeft)>=8){if(((r=e.textContent)!=null?r:"").trim()==="")return null;let L=He(t.backgroundColor),D=e.parentElement?Ho(e.parentElement,n.view):n.pageBg;return x&&L&&L.a>=.9&&Tn(L,D)>=1.5?"button-primary":x||De(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(s==="A")return"link";if(Do[s])return Do[s];if(Vt(e)&&c>=1.8*n.bodySize&&m>=600)return c>=2.5*n.bodySize?"heading-1":c>=2*n.bodySize?"heading-2":"heading-3";let $=e.nextElementSibling;if(Vt(e)&&c<=.9*n.bodySize&&(t.textTransform==="uppercase"||De(t.letterSpacing)>.05*c)&&$!==null&&/^H[1-4]$/.test($.tagName))return"eyebrow";if(s==="UL"||s==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(s==="P"&&Vt(e)){if(c>=1.1*n.bodySize)return"text-lead";if(c<=.85*n.bodySize)return"text-small";let L=He(t.color);return L&&Tn(L,Ho(e,n.view))<n.bodyContrast*.8?"text-muted":"text-body"}return(s==="SPAN"||s==="DIV")&&x&&Vt(e)&&e.children.length===0&&k>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(s)&&(x||g)&&k>0&&De(t.paddingTop)>=16&&!(y>0&&y>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(s)&&(x||g)&&e.querySelector("h1,h2,h3")!==null&&(y===0||y>=.9*n.vw)?"section":null}function zo(e,t){var n,r,s,c,m,x,g,k,y;let $=e.defaultView;if(!$||!e.body)return{entries:[],images:[]};Ot=e;let L=$.getComputedStyle(e.body),D=De(L.fontSize)||16,E=Jt(L.backgroundColor)?He(L.backgroundColor):{r:255,g:255,b:255,a:1},z=(n=He(L.color))!=null?n:{r:17,g:24,b:39,a:1},J={bodySize:D,pageBg:E,bodyContrast:Tn(z,E),view:$,vw:$.innerWidth||0},Z=(s=(r=$.location)==null?void 0:r.pathname)!=null?s:"/",U=new Date().toISOString(),X=new Map,ne=new Map,Q=new Map,M=Array.from(e.body.querySelectorAll("*")).slice(0,(c=t==null?void 0:t.maxElements)!=null?c:4e3);for(let R of M)try{if(R.tagName==="IMG"){let ee=R,Ie=((m=ee.getAttribute("alt"))!=null?m:"").trim(),Y=ee.naturalWidth||Number(ee.getAttribute("width"))||0,et=ee.naturalHeight||Number(ee.getAttribute("height"))||0,ve=ee.getAttribute("src");if(Ie&&Y>=200&&ve){let $e=new URL(ve,e.baseURI).href;$e.startsWith("https://")&&!Q.has($e)&&Q.set($e,{id:`img-${Q.size+1}`,src:$e,alt:Ie.slice(0,200),w:Y,h:et,seenOn:Z})}}let q=((x=R.getAttribute("class"))!=null?x:"").replace(/\s+/g," ").trim();if(q===""||si(R,$,J.vw))continue;let B=$.getComputedStyle(R),V=R.tagName==="IMG"?((g=R.getAttribute("alt"))!=null?g:"").trim()?"image":null:li(R,B,J);if(!V)continue;let Se=`${V}|${q}`,ze=R.getBoundingClientRect();ne.set(Se,Math.max((k=ne.get(Se))!=null?k:0,ze.width*ze.height));let _e=X.get(Se);if(_e){_e.seen.count++;continue}let ye=Cn(B.backgroundImage).map(He).filter(ee=>ee!==null),ue,je;if(Jt(B.backgroundColor))ue=ke(B.backgroundColor,e);else if(ye.length>0){let ee=[...ye].sort((Y,et)=>Yt(Y)-Yt(et)),Ie=Y=>Y.a<1?`rgba(${Y.r}, ${Y.g}, ${Y.b}, ${Y.a})`:`rgb(${Y.r}, ${Y.g}, ${Y.b})`;ue=Ie(ee[0]),ee.length>1&&(je=Ie(ee[ee.length-1]))}let pe=B.borderTopLeftRadius||B.borderRadius;X.set(Se,{id:V,role:V,classes:q,computed:de(de(de(de(de(de(de({},ke(B.color,e)?{color:ke(B.color,e)}:{}),R.parentElement&&$.getComputedStyle(R.parentElement).color===B.color?{inheritsColor:!0}:{}),ue?{bg:ue}:{}),je?{bgDark:je}:{}),B.fontSize?{fontSize:B.fontSize}:{}),B.fontWeight?{fontWeight:B.fontWeight}:{}),pe&&De(pe)>0?{radius:pe}:{}),seen:{url:Z,count:1,at:U}})}catch(q){}let re=new Map;for(let R of X.values())re.set(R.role,[...(y=re.get(R.role))!=null?y:[],R]);let ie=[],I=R=>{var q;return(q=ne.get(`${R.role}|${R.classes}`))!=null?q:0};for(let[R,q]of re)q.sort((B,V)=>(R.startsWith("button-")?I(V)-I(B):0)||V.seen.count-B.seen.count).slice(0,ri).forEach((B,V)=>ie.push(lt(de({},B),{id:V===0?R:`${R}-${V+1}`})));return{entries:ie,images:[...Q.values()]}}function jo(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let r=0;r<e.length;r++){let s=e[r],c=s>="0"&&s<="9";r===0&&c||r===1&&c&&e[0]==="-"?n+=`\\3${s} `:r===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function ci(e,t){if(e.id)return`#${jo(e.id)}`;let n=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){n.unshift(`#${jo(r.id)}`);break}let c=r.tagName.toLowerCase(),m=r.parentElement;if(m){let x=Array.from(m.children).filter(g=>g.tagName===r.tagName);x.length>1&&(c+=`:nth-of-type(${x.indexOf(r)+1})`)}n.unshift(c),r=r.parentElement,s++}return n.join(" > ")}function Xe(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let c of["data-framer-name","data-w-id","data-sentient-name"]){let m=e.getAttribute(c);if(m){n.dataAttr={name:c,value:m};break}}n.selector=ci(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=K({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function ut(e,t,n){return we(e,n)===t}var Ko="__snt_editor_token";function Go(e){try{sessionStorage.setItem(Ko,e)}catch(t){}}function Mt(){try{sessionStorage.removeItem(Ko)}catch(e){}}var di=/rgba\([^)]*,\s*0\s*\)$/,ui=/^\d+(\.\d+)?px$/;function Uo(e){var t,n;try{let r=e.defaultView;if(!r||!e.body)return null;let s=r.getComputedStyle(e.body).backgroundColor,c=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),m=new Map;for(let L of Array.from(c).slice(0,300)){let D=L.getBoundingClientRect();if(D.width>0&&(D.width<48||D.height<24))continue;let E=r.getComputedStyle(L),z=E.backgroundColor;if(!z||z==="transparent"||z===s||di.test(z))continue;let J=(t=(E.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${z}|${E.color}|${ui.test(J)?J:"8px"}`;m.set(Z,((n=m.get(Z))!=null?n:0)+1)}let x=null,g=0;for(let[L,D]of m)D>g&&(x=L,g=D);if(!x)return null;let[k,y,$]=x.split("|");return{primaryBg:k,primaryText:y,radius:$}}catch(r){return null}}function Rt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Fo(e,t){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===t?`This page (${e})`:`Only on ${e}`}function Ln(e,t){let n=Rt(e),r=n.split("/").filter(Boolean),s=[n,"*"];return r.length>=2&&s.push(`/${r[0]}/*`),(t?[t,...s.filter(c=>c!==t)]:s).filter(c=>yn.test(c))}function Xt(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Zt(e,t){return e.steps.map(n=>{var r;return{value:n.step_index,label:`${n.step_index+1}. ${(r=t.get(n.goal_id))!=null?r:n.goal_id}`}})}function Wo(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function pi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function qo(e,t){let n=e.trim();return n?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:pi(n),body:{displayName:n.slice(0,128),steps:t.map(r=>({goalId:r}))}}:{ok:!1,error:"Give the funnel a name."}}function Zo(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function pt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Ce(e,t,n){var x,g;let r=t.id||((x=t.dataAttr)==null?void 0:x.value)||((g=n.textContent)!=null?g:"").trim()||n.tagName,s=pt(r)||"el",c=Zo(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var fi="sentient-editor-highlight",gi="sentient-editor-selection",gt="sentient-editor-panel",tn="sentient-editor-toast",_n="sentient-editor-styles",In="sentient-editor-target-highlight",mi=10,Vo="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Yo="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Qo(){var t;if(document.getElementById(_n))return;let e=_t(document.createElement("style"));e.id=_n,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); }
@@ -21,14 +21,14 @@
21
21
  @media (prefers-reduced-motion: reduce) {
22
22
  #${gt}, #${gt} .sntedi-dot, #${tn} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Qt(e){var r,s;Qo(),(r=document.getElementById(tn))==null||r.remove();let t=d("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=tn;let n=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,d("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function hi(){let e=window.__sentientEditor;return e&&typeof e.apiBase=="string"&&(typeof e.token=="string"||typeof e.code=="string")?e:null}async function er(e){try{let t=await fetch(`${e.apiBase}/v1/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code})}),n=t.ok?(await t.json()).token:null;return e.code=null,n?(e.token=n,Uo(n),200):t.ok?500:t.status}catch(t){return 0}}async function yi(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 n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function Nn(e,t){return K(K(K(K({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 ce(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});if(r.ok)return{r:"ok"};let s=await r.json().catch(()=>null);return Nn(r.status,s)}catch(r){return{r:"error"}}}async function bi(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(n.ok)return{r:"ok"};let r=await n.json().catch(()=>null);return Nn(n.status,r)}catch(n){return{r:"error"}}}async function vi(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await r.json().catch(()=>null);return r.ok?{r:"ok",data:s,outcome:{r:"ok"}}:{r:r.status===401?"expired":"error",data:s,outcome:Nn(r.status,s)}}catch(r){return{r:"error",data:null,outcome:{r:"error"}}}}var $n=[];function Rn(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function Bn(e){let t=e.trim();if(Rn(t))return t;let n=/^#([0-9a-fA-F]{3})$/.exec(t);if(n)return`#${n[1].split("").map(c=>c+c).join("")}`;let r=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!r)return t;let s=c=>Math.min(255,Number(c)).toString(16).padStart(2,"0");return`#${s(r[1])}${s(r[2])}${s(r[3])}`}var Ze=null,On=[];function tr(e){On=e}async function xi(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return $n=Array.isArray(n.fonts)?n.fonts.filter(r=>typeof r=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function ft(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function mt(e=document){for(let t of Array.from(e.querySelectorAll(`.${An}`)))t.remove()}function nr(e,t=document){var r;mt(t);let n=0;for(let s of e){if(n>=mi)break;let c=we(s.locator,t);if(!c)continue;let m=c.getBoundingClientRect(),x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});x.className=An;let g=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${Math.max(0,m.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);g.className=An,((r=t.body)!=null?r:t.documentElement).append(x,g),n+=1}}function en(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,s=n?Xe(n,t):null,c=r?Xe(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&s&&ut(s,n,t)?s:null,nextLocator:r&&c&&ut(c,r,t)?c:null}}var wi=/testimonial|review|quote/i;function or(e){let t=[],n=e.headings.length>=1,r=e.links.length>=1;return n&&r&&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 Mn=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],ki=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Si=new Set(["left","center","right","justify","start","end"]),Ei=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Ci=/^(rgb|rgba|hsl|hsla)\(/i;function Ti(e){return Ei.test(e)||Ci.test(e)}function rr(e,t){switch(e){case"fontSize":case"borderRadius":return ki.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 Si.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ti(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(r=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(r))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Pn(e){let t={},n={};for(let r of Mn){let s=e[r];if(typeof s!="string")continue;let c=s.trim();if(c==="")continue;if(!ct(c)){n[r]="That value isn\u2019t allowed.";continue}let m=rr(r,c);if(m){n[r]=m;continue}t[r]=c}return{style:t,errors:n}}var Nt={display:"block",width:"100%",boxSizing:"border-box",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"};function d(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function ir(e){var so;let t=null,n=[],r=null,s=()=>{for(;n.length>0;){let o=n.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:o})}).catch(()=>{})}catch(i){}}},c=(o,i)=>{n.push(K({kind:o},i?{meta:i}:{})),r&&clearTimeout(r),r=setTimeout(s,2e3)};window.addEventListener("pagehide",s);let m=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});m.id=fi;let x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});x.id=gi;let g=()=>{if(!t||!t.isConnected){x.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(x.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},k=()=>g();Qo();let y=d("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"});y.id=gt;let $=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});$.className="sntedi-dot";let L=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});L.append($,d("span",{},"SentientUI"));let D=d("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),E=!1,z=d("button",F("#374151"),"Pause selecting");z.onclick=()=>{E=!E,z.textContent=E?"Resume selecting":"Pause selecting",E?(m.style.display="none",mt(document),C("Selection paused \u2014 browse normally, then resume.")):C("Click any element on the page to adapt it.")};let J=d("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=d("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),G=d("button",F("#6366f1"),"Test different text here"),X=d("button",F("#374151"),"Change style"),ne=d("button",F("#374151"),"Try a different layout for this section"),Q=d("button",F("#374151"),"Track clicks as a goal"),M=d("button",F("#374151"),"Track form submissions as a goal"),re=d("button",F("#374151"),"Track page visits as a goal"),ie=d("button",F("#374151"),"Track reading this far as a goal"),A=d("button",F("#374151"),"Set up a funnel"),P=d("button",F("#374151"),"Attach this test to a funnel step"),q=d("button",F("#10b981"),"Turn the funnel on"),B=d("button",F("#374151"),"Move up"),V=d("button",F("#374151"),"Move down"),Se=d("button",F("#6366f1"),"Save this arrangement"),ze=d("button",F("#374151"),"Undo"),Ie=_n("close","Close editor"),ye=d("button",F("#10b981"),"Publish now \u2014 go live"),ue=d("button",F("#10b981"),"Start tracking now");for(let o of[G,X,ne,Q,B,V])o.disabled=!0;let je=[G,X,ne,Q,M,B,V];for(let o of je)o.style.display="none";Se.style.display="none",ze.style.display="none",ye.style.display="none",ue.style.display="none",P.style.display="none",q.style.display="none";let pe=d("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),ee=d("div",{}),Ae=[{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"}],Y="text",et=new Map,ve=new Map,$e=new Map,Dn=d("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Hn=d("div",{paddingTop:"10px"});for(let o of Ae){let i=d("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"});i.append(d("span",{fontSize:"11px",marginRight:"3px"},o.icon),d("span",{},o.label)),i.onclick=()=>ar(o.id),et.set(o.id,i),Dn.append(i);let a=d("div",{display:"none"}),l=d("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(l),$e.set(o.id,l),ve.set(o.id,a),Hn.append(a)}ve.get("text").append(G),ve.get("style").append(X),ve.get("layout").append(ne,B,V,Se,ze),ve.get("goals").append(Q,M,re,ie),ve.get("funnels").append(A,P,q);let xe=d("div",{});ve.get("drafts").append(xe);let Rt=()=>{var i,a;for(let l of Ae){let u=l.id===Y,f=et.get(l.id);f.style.color=u?"#ffffff":"#9ca3af",f.style.borderBottom=u?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=u?"block":"none",$e.get(l.id).style.display="none"}let o=l=>{let u=$e.get(Y);u.textContent=l,u.style.display="block"};Y==="text"?t?G.disabled?o(G.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(i=G.onclick)==null||i.call(G,new MouseEvent("click")):o("Click any text on the page to test a different wording."):Y==="style"?t?X.disabled?o("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=X.onclick)==null||a.call(X,new MouseEvent("click")):o("Click any element on the page to change how it looks."):Y==="layout"?t||o("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."):Y==="goals"?t||o("Page-level goals work right away; click a button or form to track it specifically."):Y==="funnels"?o("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):Y==="drafts"&&tt()},Le=(o,i)=>d("button",le(K({},F(o)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),i),zn=(o,i)=>{let a=new URL(window.location.href);a.searchParams.set("sentient_preview",o),i&&a.searchParams.set("sentient_arm",i),window.location.assign(a.toString())},Dt=(o,i,a)=>{let l=Le("#374151","Discard");return l.onclick=async()=>{l.disabled=!0;let u=await bi(e,o);l.disabled=!1,be(u,i),u.r==="ok"&&a()},l},jn=(o,i)=>{Ke.textContent="";let a=d("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=d("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...i),a.append(d("div",{marginBottom:"6px"},o),l),Ke.append(a)},tt=async()=>{var S,T,w,v,b,_,N,H,U,R,ge,me;xe.textContent="",xe.append(d("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let o=[],i=[],a=null,l=!1;if(await Promise.all([(async()=>{var I;try{let j=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?o=(I=(await j.json()).slots)!=null?I:[]:a=j.status===401?"expired":"error"}catch(j){a="error"}})(),(async()=>{var I;try{let j=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?i=(I=(await j.json()).goals)!=null?I:[]:l=!0}catch(j){l=!0}})()]),Y!=="drafts")return;if(xe.textContent="",a){if(xe.append(d("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},a==="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.")),a==="error"){let I=Le("#374151","Retry");I.onclick=()=>{tt()},xe.append(I)}return}let u=o.filter(I=>{var j,se,_e,Ne,Ve,_t;return((_e=(se=(j=I.draft_config)==null?void 0:j.arms)==null?void 0:se.length)!=null?_e:0)>0||((_t=(Ve=(Ne=I.published_config)==null?void 0:Ne.arms)==null?void 0:Ve.length)!=null?_t:0)>0}),f=i.filter(I=>I.event!=="custom"&&(I.status==="draft"||I.status==="active"));if(u.length===0&&f.length===0&&!l){xe.append(d("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 h=I=>d("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:I?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:I?"#6ee7b7":"#c7d2fe"},I?"live":"draft"),p=I=>{let j=d("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),se=d("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},I);return j.append(se),{row:j,name:se}};for(let I of u){let{row:j}=p((S=I.display_name)!=null?S:I.slot_id);j.append(h(I.status==="published"));let se=(b=(v=(T=I.draft_config)==null?void 0:T.arms)!=null?v:(w=I.published_config)==null?void 0:w.arms)!=null?b:[],_e=(H=(_=se[1])==null?void 0:_.id)!=null?H:(N=se[0])==null?void 0:N.id,Ne=Le("#374151","Preview");if(Ne.onclick=()=>zn(I.slot_id,_e),j.append(Ne),I.status!=="published"&&((ge=(R=(U=I.draft_config)==null?void 0:U.arms)==null?void 0:R.length)!=null?ge:0)>0){let Ve=Le("#10b981","Publish");Ve.onclick=async()=>{Ve.disabled=!0;let _t=await ce(e,`/v1/editor/slots/${encodeURIComponent(I.slot_id)}/publish`,{});Ve.disabled=!1,be(_t,"\u2713 Published \u2014 live for new visitors."),_t.r==="ok"&&(c("published",{kind:"slot"}),tt())},j.append(Ve)}I.status!=="published"&&j.append(Dt(`/v1/editor/slots/${encodeURIComponent(I.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Yn(I.slot_id),tt()})),xe.append(j)}if(l)xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(f.length>0){xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let I of f){let{row:j}=p((me=I.display_name)!=null?me:I.goal_id);if(j.append(h(I.status==="active")),I.status==="draft"){let se=Le("#10b981","Start tracking");se.onclick=async()=>{se.disabled=!0;let _e=await ce(e,`/v1/editor/goals/${encodeURIComponent(I.goal_id)}/publish`,{});se.disabled=!1,be(_e,"\u2713 Tracking is live \u2014 it counts from your next visitor."),_e.r==="ok"&&(c("published",{kind:"goal"}),tt())},j.append(se,Dt(`/v1/editor/goals/${encodeURIComponent(I.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Jn(I.goal_id),tt()}))}xe.append(j)}}},ar=o=>{Y!==o&&(ae(),kt(),Y=o,Rt())},Kn=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(L.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Un=!1,Be=d("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});Be.append(_i(26)),Be.title="Open the SentientUI editor",Be.setAttribute("aria-label","Open the SentientUI editor");let Gn=_n("minimize","Minimize");Gn.onclick=()=>{y.style.display="none",Be.style.display="flex",Un=E,E=!0,m.style.display="none",mt(document)},Be.onclick=()=>{y.style.display="block",Be.style.display="none",E=Un},Object.assign(z.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Kn.append(L,z,Gn,Ie);let Fn=d("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Ke=d("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Fn.append(Ke,Z,ye,ue);let Wn=d("button",{display:"inline-block",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"),on=d("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(J.style,{flex:"1 1 auto",marginBottom:"0"}),on.append(J,Wn),Object.assign(on.style,{marginBottom:"6px"});let Ht=d("div",{}),W=d("div",{marginTop:"4px"});W.addEventListener("input",()=>{nt=!0}),W.addEventListener("change",()=>{nt=!0}),y.append(Kn,D,on,pe,ee,Ht,Dn,Hn,W,Fn),((so=document.body)!=null?so:document.documentElement).append(m,x,y,Be);let Oe=null,zt=()=>{Oe==null||Oe(),Oe=null},qn=()=>{Oe=null},ht=null,nt=!1,rn=null,ae=()=>{zt(),ht=null,W.textContent="",nt=!1,rn=null,gn=!1},yt=(o,i,a,l)=>{var T;ae();let u={},f={};for(let w of o){let v=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},w.label);if(W.append(v),w.type==="select"){let _=d("select",Nt);_.setAttribute("data-field",w.key);let N=document.createElement("option");N.value="",N.textContent="\u2014 no change \u2014",_.append(N);for(let H of(T=w.options)!=null?T:[]){let U=document.createElement("option");U.value=H,U.textContent=H,_.append(U)}u[w.key]=()=>_.value,W.append(_)}else if(w.type==="color"){let _=d("input",le(K({},Nt),{padding:"2px",height:"34px"}));_.type="color",_.setAttribute("data-field",w.key);let N=!1;_.addEventListener("input",()=>{N=!0}),u[w.key]=()=>N?_.value:"",W.append(_)}else{let _=d("input",Nt);_.setAttribute("data-field",w.key),w.value!==void 0&&(_.value=w.value),u[w.key]=()=>_.value,W.append(_)}let b=d("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});b.setAttribute("data-feedback",w.key),f[w.key]=b,W.append(b)}let h=(w,v)=>{let b=f[w];b&&(b.textContent=v!=null?v:"",b.style.display=v?"block":"none")};if(l){let w=Vn(l);W.append(w.node),u[bt]=w.value}let p=d("button",F("#6366f1"),i),S=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>a(Object.fromEntries(Object.entries(u).map(([w,v])=>[w,v()])),h),S.onclick=ae,W.append(p,S)},bt="__page",an={},sr=o=>{var i;for(let a of o!=null?o:[])an[a.slot_id]=(i=a.target)==null?void 0:i.page};ft(e,"/v1/editor/slots").then(o=>sr(o==null?void 0:o.slots));let Vn=o=>{let i=Pt(location.pathname),a=d("div",{}),l=d("select",Nt);l.setAttribute("data-field","page");for(let u of Ln(i,an[o])){let f=document.createElement("option");f.value=u,f.textContent=Fo(u,i),l.append(f)}return a.append(d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,d("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:a,value:()=>l.value}},vt=(o,i)=>i?le(K({},o),{page:i}):o,C=(o,i=!0)=>{Z.textContent=o,Z.style.color=i?"#a7f3d0":"#fca5a5"},sn=(o,i)=>{var l,u;if(c("error_shown",{code:(u=o.code)!=null?u:`http_${(l=o.status)!=null?l:"network"}`}),o.code==="plan_limit_reached"){let f=o.feature==="live_goals"?"live goal":"of these",h=o.plan?`${o.plan} plan`:"plan";return o.feature==="live_goals"?`Your ${h} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${h} has reached its limit for ${f}. Manage them in your dashboard, or upgrade for more.`}if(o.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(o.code==="demo_read_only"&&o.message)return o.message;let a=o.status?` (HTTP ${o.status})`:"";return`\u26A0 Couldn\u2019t ${i} \u2014 try again.${a}`},be=(o,i)=>{o.r==="ok"?C(i,!0):o.r==="expired"?C("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):C(sn(o,"save"),!1)},Ue=null,jt=o=>o.length>30?`${o.slice(0,27)}\u2026`:o,Yn=o=>{Ue===o&&(ht===o&&(zt(),ht=null),Ue=null,ye.style.display="none",P.style.display="none",Ke.textContent="")},Jn=o=>{at===o&&(at=null,ue.style.display="none",Ke.textContent="")},xt=(o,i,a)=>{Ue=o,ye.textContent=i?`Publish \u201C${jt(i)}\u201D \u2014 go live`:"Publish now \u2014 go live",ye.style.display="block",P.style.display="block";let l=[];if(a){let u=Le("#374151","Preview");u.onclick=()=>zn(o,a),l.push(u)}l.push(Dt(`/v1/editor/slots/${encodeURIComponent(o)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Yn(o))),jn(i?`Draft saved for \u201C${jt(i)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ye.onclick=async()=>{if(!Ue)return;ye.disabled=!0,C("Publishing\u2026");let o=await ce(e,`/v1/editor/slots/${encodeURIComponent(Ue)}/publish`,{});ye.disabled=!1,o.r==="ok"?(c("published",{kind:"slot"}),C("\u2713 Published \u2014 live for new visitors.",!0),ye.style.display="none",Ue=null,Ke.textContent=""):o.r==="expired"?C("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):C(sn(o,"publish"),!1)};let oe=null,Me=!1,ot=null,rt=null,Ee=null,Ge=null,wt=null,Kt=null,Fe=!1,Xn=(o,i)=>Me?o?"":`Nothing to swap with ${i} \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.",Zn=()=>{B.disabled=!Me||!Ee,V.disabled=!Me||!Ge,B.title=B.disabled?Xn(Ee,"above"):"",V.title=V.disabled?Xn(Ge,"below"):""},Ce=null,ln=o=>{o&&!Ce&&t&&oe?(Ce=Vn(Te("move",oe,t)),Se.before(Ce.node)):o||(Ce==null||Ce.node.remove(),Ce=null),Se.style.display=o?"block":"none",ze.style.display=o?"block":"none",Zn()},kt=()=>{if(Fe&&t&&wt&&wt.insertBefore(t,Kt),Fe=!1,wt=null,Kt=null,t){let o=en(t,document);ot=o.prevEl,rt=o.nextEl,Ee=o.prevLocator,Ge=o.nextLocator}g(),ln(!1)},Qn=o=>{if(E)return;let i=o.target;if(!i||y.contains(i)||i===m)return;mt(document);let a=i.getBoundingClientRect();Object.assign(m.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},Pe=o=>{var a;let i=((a=o.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},lr=o=>!!o.id||["section","header","footer","nav","main","form","article","aside"].includes(o.tagName.toLowerCase())||!!o.querySelector(":scope > h1, :scope > h2, :scope > h3"),cr=o=>{var l;let i=o.querySelector("h1, h2, h3"),a=(l=i==null?void 0:i.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:o.id?`#${o.id.length>24?`${o.id.slice(0,21)}\u2026`:o.id}`:`<${o.tagName.toLowerCase()}>`},dr=o=>{pe.textContent="";let i=[];for(let h=o.parentElement;h&&h!==document.body&&i.length<3;h=h.parentElement)lr(h)&&i.push(h);let a=Pe(o),l=()=>d("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),u=!0;for(let h of i){let p=cr(h);if(p===a||a.startsWith(p))continue;let S=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);S.onclick=()=>St(h),u||pe.append(l()),pe.append(S),u=!1}u||pe.append(l());let f=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");f.onclick=()=>eo(),pe.append(f),pe.style.display="block"},ur=o=>{ee.textContent="";let i=null,a=0;for(let u=o.parentElement;u&&u!==document.body&&a<6;u=u.parentElement,a++)if(ut(Xe(u,document),u,document)){i=u;break}let l=d("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(i){let u=i;l.append(d("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 f=d("button",le(K({},F("#6366f1")),{marginTop:"0"}),`Select \u201C${Pe(u)}\u201D instead`);f.onclick=()=>St(u);let h=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Pick something else");h.onclick=()=>{ee.textContent=""},l.append(f,h)}else l.append(d("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));ee.append(l)},St=o=>{kt(),ae(),ee.textContent="",t=o,oe=Xe(o,document);let i=ut(oe,o,document);Me=i,g(),J.style.display="block",J.textContent=`Selected: ${Pe(o)}`,dr(o),c("element_selected",{unique:i}),C(i?"\u2713 Matches exactly 1 element":"",i),i||ur(o),D.style.display="none",pn();for(let f of je)f.style.display="block";G.style.display="none",X.style.display="none";let a=vn(o);G.disabled=!i||!a,G.title=i?a?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",X.disabled=!i,ne.disabled=!i,Q.disabled=!i;let l=o.closest("form");M.style.display=l?"block":"none",M.disabled=!l;let u=en(o,document);ot=u.prevEl,rt=u.nextEl,Ee=u.prevLocator,Ge=u.nextLocator,Zn(),Rt()},eo=()=>{kt(),ae(),t=null,oe=null,Me=!1,ot=null,rt=null,Ee=null,Ge=null,g(),ee.textContent="",pn(),pe.textContent="",pe.style.display="none",J.textContent="",J.style.display="none";for(let o of je)o.style.display="none";D.style.display="block",C(""),Rt()},it=!1,cn=-1,to=o=>{var l,u;let i=o.target,a=!!((l=i==null?void 0:i.closest)!=null&&l.call(i,'input, textarea, select, [contenteditable="true"]'));if(o.key==="Escape"){if(W.childElementCount>0){ae(),it=!1;return}if(t){eo(),it=!1;return}if(!it){it=!0,C("Press Esc again to close the editor.");return}it=!1,(u=Ie.onclick)==null||u.call(Ie,new MouseEvent("click"));return}if(it=!1,!(a||E)){if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!t||(o.key==="ArrowUp"?B:V).disabled)return;o.preventDefault(),fn(o.key==="ArrowUp"?"up":"down");return}if(o.key==="Tab"){let f=[];for(let p of On){let S=we(p.locator,document);S&&!f.includes(S)&&f.push(S)}if(f.length===0)return;if(nt){C("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),o.preventDefault();return}o.preventDefault(),cn=(cn+(o.shiftKey?-1:1)+f.length)%f.length;let h=f[cn];St(h);try{h.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},no=o=>{if(E)return;let i=o.target;if(!(!i||y.contains(i))){if(o.preventDefault(),o.stopPropagation(),nt&&i!==t&&rn!==i){rn=i,C("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}St(i)}};G.onclick=()=>{var f,h;if(!t||!oe)return;c("form_opened",{kind:"text"});let o=oe,i=(h=(f=t.textContent)==null?void 0:f.trim())!=null?h:"";yt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async p=>{let S=p.alt.trim();if(!S){C("\u26A0 Enter alternative wording to test.",!1);return}if(S===p.current.trim()){C("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let T=Te("text",o,t);C("Saving\u2026");let w=await ce(e,`/v1/editor/slots/${encodeURIComponent(T)}`,{kind:"arms",target:vt(o,p[bt]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:p.current}},{id:"b",displayName:"Alternative",ops:{text:p.alt}}]}});w.r==="ok"&&(c("draft_saved",{kind:"slot"}),qn(),ae(),xt(T,Pe(t),"b")),be(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Te("text",o,t));let a=t,l=xn(a);Oe=()=>{Ye(a,l)};let u=W.querySelector('input[data-field="alt"]');u==null||u.addEventListener("input",()=>{Ye(a,u.value.trim()===""?l:u.value)})};let Et=null,oo=o=>{let i=p=>{var S;return((S=p.textContent)!=null?S:"").replace(/\s+/g," ").trim()},a=Array.from(o.querySelectorAll("h1,h2,h3,h4")).map(i).filter(Boolean);if(a.length===0){let p=o.closest("h1,h2,h3,h4");p&&a.push(i(p))}let l=Array.from(o.querySelectorAll("p")).map(i).filter(p=>p.length>0&&p.length<=300),u=[];for(let p of Array.from(o.querySelectorAll("a[href], button"))){let S=i(p);if(!S||S.length>60)continue;let T="",w=p.getAttribute("href");if(w)try{let v=new URL(w,window.location.href);v.protocol==="https:"&&(T=v.href)}catch(v){}u.push({label:S,href:T})}let f=Array.from(o.querySelectorAll("blockquote, q")).map(i).filter(Boolean);if(f.length===0&&wi.test(`${o.className} ${o.id}`))for(let p of l)p.length>=20&&f.push(p);let h=Array.from(o.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(i).filter(p=>p.length>0&&p.length<=80);return{headings:a,paragraphs:l,links:u,quotes:f,attributions:h}},pr=(o,i)=>{var l,u,f,h,p,S,T,w,v,b,_,N,H,U,R,ge,me,I,j,se;let a=_e=>{var Ne;return i.paragraphs.length>=3&&(Ne=i.paragraphs[i.paragraphs.length-3+_e])!=null?Ne:""};switch(o){case"headline":return(l=i.headings[0])!=null?l:"";case"supporting":return(u=i.paragraphs[0])!=null?u:"";case"cta_label":return(h=(f=i.links[0])==null?void 0:f.label)!=null?h:"";case"cta_href":return(S=(p=i.links[0])==null?void 0:p.href)!=null?S:"";case"secondary_label":return(w=(T=i.links[1])==null?void 0:T.label)!=null?w:"";case"secondary_href":return(b=(v=i.links[1])==null?void 0:v.href)!=null?b:"";case"quote":case"q1":return(_=i.quotes[0])!=null?_:"";case"q2":return(N=i.quotes[1])!=null?N:"";case"q3":return(H=i.quotes[2])!=null?H:"";case"name":case"n1":return(U=i.attributions[0])!=null?U:"";case"n2":return(R=i.attributions[1])!=null?R:"";case"n3":return(ge=i.attributions[2])!=null?ge:"";case"role":return(me=i.attributions[1])!=null?me:"";case"eyebrow":return"";case"f1_title":return(I=i.headings[1])!=null?I:"";case"f2_title":return(j=i.headings[2])!=null?j:"";case"f3_title":return(se=i.headings[3])!=null?se:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},fr=(o,i,a)=>{c("form_opened",{kind:"arrangement"});let l=oo(a);yt(o.fields.map(u=>({key:u.id,label:u.kind==="href"?`${u.label} (https link \u2014 required)`:u.label,value:pr(u.id,l)})),"Save draft",async(u,f)=>{var _,N,U,R,ge;let h=!1,p=!1;for(let me of o.fields){if(me.kind==="href"){let j=!1;try{j=new URL((_=u[me.id])!=null?_:"").protocol==="https:"}catch(se){}f(me.id,j?null:"Links need to start with https://"),j||(h=!0);continue}let I=((N=u[me.id])!=null?N:"").trim()==="";f(me.id,I?"Fill this in with your own words":null),I&&(p=!0)}if(h){C("\u26A0 Fix the highlighted link(s).",!1);return}if(p){C("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}C("Saving\u2026");let H=u,{[bt]:S}=H,T=po(H,[uo(bt)]),w=await vi(e,`/v1/editor/arrangements/${encodeURIComponent(o.id)}/instantiate`,{fields:T});if(w.r!=="ok"||!((U=w.data)!=null&&U.blocks)){w.r==="expired"?be(w.outcome,""):C(`\u26A0 ${(ge=(R=w.data)==null?void 0:R.reason)!=null?ge:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let v=Te("arrange",i,a),b=await ce(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:vt(i,S),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:o.id,displayName:o.name,blocks:w.data.blocks}],baseline:"original"}});b.r==="ok"&&(c("draft_saved",{kind:"arrangement"}),ae(),xt(v,o.name,o.id)),be(b,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},Te("arrange",i,a))};ne.onclick=async()=>{var f,h;if(!t||!oe)return;let o=oe,i=t;if(ae(),C("Loading arrangements\u2026"),!Et){let p=await ft(e,"/v1/editor/arrangements");Et=(f=p==null?void 0:p.arrangements)!=null?f:null}if(!Et||Et.length===0){C("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let a=or(oo(i)),l=Et.filter(p=>a.includes(p.sectionType));if(l.length===0){C("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}C("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let S=d("button",le(K({},F("#374151")),{textAlign:"left"}));S.append(d("div",{fontWeight:"600"},p.name),d("div",{fontSize:"11px",opacity:"0.7"},p.description)),S.onclick=()=>fr(p,o,i),W.append(S)}let u=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");u.onclick=ae,W.append(u),(h=W.scrollIntoView)==null||h.call(W,{block:"nearest"})};let at=null,gr=(o,i)=>{at=o,ue.textContent=i?`Start tracking \u201C${jt(i)}\u201D now`:"Start tracking now",ue.style.display="block",jn(i?`Goal \u201C${jt(i)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[Dt(`/v1/editor/goals/${encodeURIComponent(o)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Jn(o))])};ue.onclick=async()=>{if(!at)return;ue.disabled=!0,C("Activating\u2026");let o=await ce(e,`/v1/editor/goals/${encodeURIComponent(at)}/publish`,{});ue.disabled=!1,o.r==="ok"?(c("published",{kind:"goal"}),C("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ue.style.display="none",at=null,Ke.textContent=""):o.r==="expired"?C("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):C(sn(o,"activate"),!1)};let st=(o,i)=>`${pt(o)||"goal"}-${Zo(i)}`.slice(0,128),ro=o=>{var l,u,f;let i=((l=o.textContent)!=null?l:"").replace(/\s+/g," ").trim();return i&&i.length<=60?i:((f=(u=o.getAttribute("aria-label"))!=null?u:o.getAttribute("id"))!=null?f:"").trim()||"element-clicked"},Ct=async(o,i,a)=>{C("Saving\u2026");let l=await ce(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);return l.r==="ok"&&(c("draft_saved",{kind:"goal"}),gr(o,a)),be(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),l};Q.onclick=()=>{if(!t||!oe)return;let o=st(ro(t),JSON.stringify(oe));Ct(o,{event:"click",locator:oe},Pe(t))},M.onclick=()=>{var l,u;let o=t==null?void 0:t.closest("form");if(!o)return;let i=Xe(o,document),a=(u=(l=o.getAttribute("id"))!=null?l:o.getAttribute("name"))!=null?u:"form-submitted";Ct(st(a,JSON.stringify(i)),{event:"form_submit",locator:i},a)},re.onclick=()=>{let o=window.location.pathname||"/",i=pt(o)?`reached-${pt(o)}`:"page-visited";Ct(st(i,o),{event:"url_reached",urlPattern:o},o)};let dn=[{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}];ie.onclick=()=>{yt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:dn.map(o=>o.label)}],"Track it",o=>{var l;let i=(l=dn.find(u=>u.label===o.depth))!=null?l:dn[2],a=Math.round(i.value*100);Ct(`read-${a}pct`,{event:"scroll_depth",threshold:i.value},`read ${a}%`),ae()})};let Ut=null,mr=o=>{Ut=o,q.style.display="block"};q.onclick=async()=>{if(!Ut)return;q.disabled=!0,C("Turning on\u2026");let o=await ce(e,`/v1/editor/funnels/${encodeURIComponent(Ut)}/publish`,{});q.disabled=!1,o.r==="ok"?(c("published",{kind:"funnel"}),C("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),q.style.display="none",Ut=null):o.r==="expired"?C("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):C("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},A.onclick=async()=>{var w;C("Loading your goals\u2026");let o=await ft(e,"/v1/editor/goals"),i=(w=o==null?void 0:o.goals)!=null?w:[];if(i.length<2){C("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}C("Pick the steps in order \u2014 first click = first step."),ae();let a=[],l=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=d("input",Nt);W.append(l,u);let f=d("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");W.append(f);let h=new Map,p=()=>{var v,b;for(let[_,N]of h){let H=a.indexOf(_),U=(b=(v=i.find(R=>R.goal_id===_))==null?void 0:v.display_name)!=null?b:_;N.textContent=H===-1?U:`${H+1}. ${U}`,N.style.background=H===-1?"#374151":"#6366f1"}};for(let v of i){let b=d("button",le(K({},F("#374151")),{textAlign:"left"}));h.set(v.goal_id,b),b.onclick=()=>{a=Wo(a,v.goal_id),p()},W.append(b)}p();let S=d("button",F("#6366f1"),"Save funnel"),T=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");T.onclick=ae,S.onclick=async()=>{let v=qo(u.value,a);if(!v.ok){C(`\u26A0 ${v.error}`,!1);return}C("Saving\u2026");let b=await ce(e,`/v1/editor/funnels/${encodeURIComponent(v.funnelId)}`,v.body);b.r==="ok"&&(c("draft_saved",{kind:"funnel"}),ae(),mr(v.funnelId)),be(b,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},W.append(S,T)},P.onclick=async()=>{var p,S;let o=Ue;if(!o)return;C("Loading funnels\u2026");let i=await ft(e,"/v1/editor/funnels"),a=(p=i==null?void 0:i.funnels)!=null?p:[];if(a.length===0){C("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await ft(e,"/v1/editor/goals"),u=new Map(((S=l==null?void 0:l.goals)!=null?S:[]).map(T=>[T.goal_id,T.display_name]));yt([{key:"funnel",label:"Funnel",type:"select",options:a.map(T=>Xt(T))},{key:"step",label:"Which step does this element serve?",type:"select",options:Zt(a[0],u).map(T=>T.label)}],"Attach",async T=>{var _;let w=(_=a.find(N=>Xt(N)===T.funnel))!=null?_:a[0],v=Zt(w,u).findIndex(N=>N.label===T.step);if(v<0){C("\u26A0 Pick which step this element serves.",!1);return}C("Attaching\u2026");let b=await ce(e,`/v1/editor/funnels/${encodeURIComponent(w.funnel_id)}/assign`,{slotId:o,stepIndex:v});b.r==="ok"&&ae(),be(b,`\u2713 Attached \u2014 this test now works toward \u201C${w.display_name}\u201D.`)});let f=W.querySelector('select[data-field="funnel"]'),h=W.querySelector('select[data-field="step"]');f&&h&&f.addEventListener("change",()=>{var w;let T=(w=a.find(v=>Xt(v)===f.value))!=null?w:a[0];h.length=1;for(let v of Zt(T,u)){let b=document.createElement("option");b.value=v.label,b.textContent=v.label,h.append(b)}})},X.onclick=()=>{if(!t||!oe)return;c("form_opened",{kind:"style"});let o=oe;yt([{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:$n.length?`Font (this site has: ${$n.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(h,p)=>{var _;let{style:S,errors:T}=Pn(h),w=!1;for(let N of Mn)p(N,(_=T[N])!=null?_:null),T[N]&&(w=!0);if(w){C("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(S).length===0){C("\u26A0 Enter at least one style change.",!1);return}let v=Te("style",o,t);C("Saving\u2026");let b=await ce(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:vt(o,h[bt]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:S}}]}});b.r==="ok"&&(c("draft_saved",{kind:"slot"}),qn(),ae(),xt(v,Pe(t),"b")),be(b,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Te("style",o,t));let i=t,a=i.style.cssText;Oe=()=>{i.style.cssText=a};let l={},u=()=>{let{style:h}=Pn(l);i.style.cssText=a;for(let[p,S]of Object.entries(h)){let T=At[p];T&&ct(S)&&i.style.setProperty(T,S.trim(),"important")}};for(let h of Mn){let p=W.querySelector(`[data-field="${h}"]`);if(!p)continue;let S=()=>{l[h]=p.value,u()};p.addEventListener("input",S),p.addEventListener("change",S)}let f=[Ze==null?void 0:Ze.primaryBg,Ze==null?void 0:Ze.primaryText,"#ffffff"].filter(h=>!!h).map(Bn).filter((h,p,S)=>Rn(h)&&S.indexOf(h)===p);for(let h of["color","background"]){let p=W.querySelector(`input[data-field="${h}"]`);if(!p)continue;let S=d("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let T of f){let w=d("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:T,padding:"0"});w.title=T,w.onclick=()=>{p.value=Bn(T),p.dispatchEvent(new Event("input"))},S.append(w)}p.after(S)}};let We=[],Tt=new Map,un=!1,fe=null,te=null,Lt=null,hr=()=>{Tt.clear();let o=[],i=(a,l,u)=>{var p;if(o.length>=16||[...Tt.values()].some(S=>S.node===a))return;let f=a===t,h=f?"selected":`e${o.length}`;Tt.set(h,{node:a,locator:l}),o.push(K(K({ref:h,tag:a.tagName.toLowerCase().slice(0,16),text:((p=a.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:vn(a),inForm:!!a.closest("form")},f?{selected:!0}:{}),u?{label:u.slice(0,120)}:{}))};t&&oe&&Me&&i(t,oe);for(let a of On){let l=we(a.locator,document);l&&i(l,a.locator,a.label)}return{pagePath:Pt(location.pathname),pageTitle:document.title.slice(0,200),elements:o}},qe=(o,i="")=>{let a=o==="user",l=d("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:a?"auto":"0",background:a?"#6366f1":o==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:o==="note"?"0.75":"1"},i);return fe==null||fe.append(l),fe&&(fe.scrollTop=fe.scrollHeight),l},pn=()=>{Lt&&(Lt.textContent=t?Me?`Looking at: ${Pe(t)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},io=(o,i)=>{var u;zt();let a=xn(o),l=o.style.cssText;if(Oe=()=>{Ye(o,a),o.style.cssText=l},!!i){typeof i.text=="string"&&Ye(o,i.text);for(let[f,h]of Object.entries((u=i.style)!=null?u:{})){let p=At[f];p&&typeof h=="string"&&ct(h)&&o.style.setProperty(p,h.trim(),"important")}}},yr=async o=>{var _,N;let i=Tt.get(o.ref);if(!i||!i.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:a,locator:l}=i,u=o.versions.some(H=>typeof H.ops.text=="string"),f=Te(u?"text":"style",l,a),h=Ln(location.pathname,an[f])[0];C("Saving\u2026");let p=await ce(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:vt(l,h),draftConfig:{arms:[{id:"a",displayName:"Original",ops:u?{text:((_=a.textContent)!=null?_:"").trim()}:{}},...o.versions]}});if(be(p,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),p.r!=="ok")return(N=Z.textContent)!=null?N:"\u26A0 Couldn\u2019t save the draft.";c("draft_saved",{kind:"slot",via:"chat"}),a!==t&&St(a),ae();let S=a;io(S,o.versions[0].ops),ht=f;try{S.scrollIntoView({block:"center",behavior:"smooth"})}catch(H){}xt(f,o.label,o.versions[0].id);let T=qe("assistant");T.textContent="",T.append(d("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${o.label}`));let w=d("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),v=[],b=(H,U)=>{for(let R of v)R.style.background="#374151";H.style.background="#6366f1",io(S,U),ht=f};for(let[H,U]of[["Original",null],...o.versions.map(R=>[R.displayName,R.ops])]){let R=Le("#374151",H);R.onclick=()=>b(R,U),v.push(R),w.append(R)}return v[1].style.background="#6366f1",T.append(w),`[Created draft "${o.label}" with ${o.versions.length} version(s)]`},br=(o,i,a)=>{var h;let l=[],u={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},f=null;if(o){let p=o.getBoundingClientRect();f=p.top+window.scrollY,l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${p.left+window.scrollX-3}px`,top:`${f-3}px`,width:`${p.width+6}px`,height:`${p.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),d("div",le(K({},u),{left:`${p.left+window.scrollX}px`,top:`${Math.max(0,f-24)}px`}),`Goal: ${a}`))}else i!==void 0&&(f=Math.round(document.documentElement.scrollHeight*i),l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${f}px`,borderTop:"2px dashed #f59e0b"}),d("div",le(K({},u),{left:"16px",top:`${f+4}px`}),`Goal counts here: ${a}`)));if(l.length!==0){if(((h=document.body)!=null?h:document.documentElement).append(...l),f!==null)try{window.scrollTo({top:Math.max(0,f-window.innerHeight/3),behavior:"smooth"})}catch(p){}setTimeout(()=>{for(let p of l)p.remove()},6e3)}},vr=async o=>{var f,h,p,S,T,w;let i=null,a,l;if(o.event==="click"||o.event==="form_submit"){let v=o.ref?Tt.get(o.ref):void 0;if(!v||!v.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(o.event==="click")i=v.node,a=st(ro(i),JSON.stringify(v.locator)),l={event:"click",locator:v.locator};else{let b=v.node.closest("form");if(!b)return"\u26A0 That element isn\u2019t inside a form.";let _=Xe(b,document);if(!ut(_,b,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=b,a=st((h=(f=b.getAttribute("id"))!=null?f:b.getAttribute("name"))!=null?h:"form-submitted",JSON.stringify(_)),l={event:"form_submit",locator:_}}}else if(o.event==="url_reached"){let v=(p=o.urlPattern)!=null?p:Pt(location.pathname);a=st(pt(v)?`reached-${pt(v)}`:"page-visited",v),l={event:"url_reached",urlPattern:v}}else a=`read-${Math.round(((S=o.threshold)!=null?S:.75)*100)}pct`,l={event:"scroll_depth",threshold:(T=o.threshold)!=null?T:.75};return(await Ct(a,le(K({},l),{displayName:o.displayName}),o.displayName)).r!=="ok"?(w=Z.textContent)!=null?w:"\u26A0 Couldn\u2019t save the goal.":(br(i,o.event==="scroll_depth"?l.threshold:void 0,o.displayName),`[Created draft goal "${o.displayName}"]`)},ao=async o=>{var S,T,w;let i=o.trim();if(!i||un)return;un=!0,te&&(te.value="",te.disabled=!0),qe("user",i),We.push({role:"user",content:i.slice(0,4e3)}),c("form_opened",{kind:"chat"});let a=qe("assistant","\u2026"),l="",u=!1,f=[],h=[],p=v=>{var _,N;if(v==="[DONE]")return;let b;try{b=JSON.parse(v)}catch(H){return}if(b.error){f.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(b.type==="delta"&&b.text)u&&l&&(l+=`
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Qt(e){var r,s;Qo(),(r=document.getElementById(tn))==null||r.remove();let t=d("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=tn;let n=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,d("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function hi(){let e=window.__sentientEditor;return e&&typeof e.apiBase=="string"&&(typeof e.token=="string"||typeof e.code=="string")?e:null}async function er(e){try{let t=await fetch(`${e.apiBase}/v1/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code})}),n=t.ok?(await t.json()).token:null;return e.code=null,n?(e.token=n,Go(n),200):t.ok?500:t.status}catch(t){return 0}}async function yi(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 n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function Pn(e,t){return K(K(K(K({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 ce(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});if(r.ok)return{r:"ok"};let s=await r.json().catch(()=>null);return Pn(r.status,s)}catch(r){return{r:"error"}}}async function bi(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(n.ok)return{r:"ok"};let r=await n.json().catch(()=>null);return Pn(n.status,r)}catch(n){return{r:"error"}}}async function vi(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await r.json().catch(()=>null);return r.ok?{r:"ok",data:s,outcome:{r:"ok"}}:{r:r.status===401?"expired":"error",data:s,outcome:Pn(r.status,s)}}catch(r){return{r:"error",data:null,outcome:{r:"error"}}}}var $n=[];function Nn(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function Bn(e){let t=e.trim();if(Nn(t))return t;let n=/^#([0-9a-fA-F]{3})$/.exec(t);if(n)return`#${n[1].split("").map(c=>c+c).join("")}`;let r=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!r)return t;let s=c=>Math.min(255,Number(c)).toString(16).padStart(2,"0");return`#${s(r[1])}${s(r[2])}${s(r[3])}`}var Ze=null,On=[];function tr(e){On=e}async function xi(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return $n=Array.isArray(n.fonts)?n.fonts.filter(r=>typeof r=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function ft(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function mt(e=document){for(let t of Array.from(e.querySelectorAll(`.${In}`)))t.remove()}function nr(e,t=document){var r;mt(t);let n=0;for(let s of e){if(n>=mi)break;let c=we(s.locator,t);if(!c)continue;let m=c.getBoundingClientRect(),x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});x.className=In;let g=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${Math.max(0,m.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);g.className=In,((r=t.body)!=null?r:t.documentElement).append(x,g),n+=1}}function en(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,s=n?Xe(n,t):null,c=r?Xe(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&s&&ut(s,n,t)?s:null,nextLocator:r&&c&&ut(c,r,t)?c:null}}var wi=/testimonial|review|quote/i;function or(e){let t=[],n=e.headings.length>=1,r=e.links.length>=1;return n&&r&&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 Mn=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],ki=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Si=new Set(["left","center","right","justify","start","end"]),Ei=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Ti=/^(rgb|rgba|hsl|hsla)\(/i;function Ci(e){return Ei.test(e)||Ti.test(e)}function rr(e,t){switch(e){case"fontSize":case"borderRadius":return ki.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 Si.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ci(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(r=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(r))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Rn(e){let t={},n={};for(let r of Mn){let s=e[r];if(typeof s!="string")continue;let c=s.trim();if(c==="")continue;if(!ct(c)){n[r]="That value isn\u2019t allowed.";continue}let m=rr(r,c);if(m){n[r]=m;continue}t[r]=c}return{style:t,errors:n}}var Pt={display:"block",width:"100%",boxSizing:"border-box",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"};function d(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function ir(e){var so;let t=null,n=[],r=null,s=()=>{for(;n.length>0;){let o=n.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:o})}).catch(()=>{})}catch(i){}}},c=(o,i)=>{n.push(K({kind:o},i?{meta:i}:{})),r&&clearTimeout(r),r=setTimeout(s,2e3)};window.addEventListener("pagehide",s);let m=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});m.id=fi;let x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});x.id=gi;let g=()=>{if(!t||!t.isConnected){x.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(x.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},k=()=>g();Qo();let y=d("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"});y.id=gt;let $=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});$.className="sntedi-dot";let L=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});L.append($,d("span",{},"SentientUI"));let D=d("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),E=!1,z=d("button",F("#374151"),"Pause selecting");z.onclick=()=>{E=!E,z.textContent=E?"Resume selecting":"Pause selecting",E?(m.style.display="none",mt(document),T("Selection paused \u2014 browse normally, then resume.")):T("Click any element on the page to adapt it.")};let J=d("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=d("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),U=d("button",F("#6366f1"),"Test different text here"),X=d("button",F("#374151"),"Change style"),ne=d("button",F("#374151"),"Try a different layout for this section"),Q=d("button",F("#374151"),"Track clicks as a goal"),M=d("button",F("#374151"),"Track form submissions as a goal"),re=d("button",F("#374151"),"Track page visits as a goal"),ie=d("button",F("#374151"),"Track reading this far as a goal"),I=d("button",F("#374151"),"Set up a funnel"),R=d("button",F("#374151"),"Attach this test to a funnel step"),q=d("button",F("#10b981"),"Turn the funnel on"),B=d("button",F("#374151"),"Move up"),V=d("button",F("#374151"),"Move down"),Se=d("button",F("#6366f1"),"Save this arrangement"),ze=d("button",F("#374151"),"Undo"),_e=An("close","Close editor"),ye=d("button",F("#10b981"),"Publish now \u2014 go live"),ue=d("button",F("#10b981"),"Start tracking now");for(let o of[U,X,ne,Q,B,V])o.disabled=!0;let je=[U,X,ne,Q,M,B,V];for(let o of je)o.style.display="none";Se.style.display="none",ze.style.display="none",ye.style.display="none",ue.style.display="none",R.style.display="none",q.style.display="none";let pe=d("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),ee=d("div",{}),Ie=[{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"}],Y="text",et=new Map,ve=new Map,$e=new Map,Dn=d("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Hn=d("div",{paddingTop:"10px"});for(let o of Ie){let i=d("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"});i.append(d("span",{fontSize:"11px",marginRight:"3px"},o.icon),d("span",{},o.label)),i.onclick=()=>ar(o.id),et.set(o.id,i),Dn.append(i);let a=d("div",{display:"none"}),l=d("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(l),$e.set(o.id,l),ve.set(o.id,a),Hn.append(a)}ve.get("text").append(U),ve.get("style").append(X),ve.get("layout").append(ne,B,V,Se,ze),ve.get("goals").append(Q,M,re,ie),ve.get("funnels").append(I,R,q);let xe=d("div",{});ve.get("drafts").append(xe);let Nt=()=>{var i,a;for(let l of Ie){let u=l.id===Y,f=et.get(l.id);f.style.color=u?"#ffffff":"#9ca3af",f.style.borderBottom=u?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=u?"block":"none",$e.get(l.id).style.display="none"}let o=l=>{let u=$e.get(Y);u.textContent=l,u.style.display="block"};Y==="text"?t?U.disabled?o(U.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(i=U.onclick)==null||i.call(U,new MouseEvent("click")):o("Click any text on the page to test a different wording."):Y==="style"?t?X.disabled?o("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=X.onclick)==null||a.call(X,new MouseEvent("click")):o("Click any element on the page to change how it looks."):Y==="layout"?t||o("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."):Y==="goals"?t||o("Page-level goals work right away; click a button or form to track it specifically."):Y==="funnels"?o("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):Y==="drafts"&&tt()},Le=(o,i)=>d("button",le(K({},F(o)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),i),zn=(o,i)=>{let a=new URL(window.location.href);a.searchParams.set("sentient_preview",o),i&&a.searchParams.set("sentient_arm",i),window.location.assign(a.toString())},Dt=(o,i,a)=>{let l=Le("#374151","Discard");return l.onclick=async()=>{l.disabled=!0;let u=await bi(e,o);l.disabled=!1,be(u,i),u.r==="ok"&&a()},l},jn=(o,i)=>{Ke.textContent="";let a=d("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=d("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...i),a.append(d("div",{marginBottom:"6px"},o),l),Ke.append(a)},tt=async()=>{var S,C,w,v,b,A,P,H,G,N,ge,me;xe.textContent="",xe.append(d("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let o=[],i=[],a=null,l=!1;if(await Promise.all([(async()=>{var _;try{let j=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?o=(_=(await j.json()).slots)!=null?_:[]:a=j.status===401?"expired":"error"}catch(j){a="error"}})(),(async()=>{var _;try{let j=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?i=(_=(await j.json()).goals)!=null?_:[]:l=!0}catch(j){l=!0}})()]),Y!=="drafts")return;if(xe.textContent="",a){if(xe.append(d("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},a==="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.")),a==="error"){let _=Le("#374151","Retry");_.onclick=()=>{tt()},xe.append(_)}return}let u=o.filter(_=>{var j,se,Ae,Pe,Ve,At;return((Ae=(se=(j=_.draft_config)==null?void 0:j.arms)==null?void 0:se.length)!=null?Ae:0)>0||((At=(Ve=(Pe=_.published_config)==null?void 0:Pe.arms)==null?void 0:Ve.length)!=null?At:0)>0}),f=i.filter(_=>_.event!=="custom"&&(_.status==="draft"||_.status==="active"));if(u.length===0&&f.length===0&&!l){xe.append(d("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 h=_=>d("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:_?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:_?"#6ee7b7":"#c7d2fe"},_?"live":"draft"),p=_=>{let j=d("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),se=d("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},_);return j.append(se),{row:j,name:se}};for(let _ of u){let{row:j}=p((S=_.display_name)!=null?S:_.slot_id);j.append(h(_.status==="published"));let se=(b=(v=(C=_.draft_config)==null?void 0:C.arms)!=null?v:(w=_.published_config)==null?void 0:w.arms)!=null?b:[],Ae=(H=(A=se[1])==null?void 0:A.id)!=null?H:(P=se[0])==null?void 0:P.id,Pe=Le("#374151","Preview");if(Pe.onclick=()=>zn(_.slot_id,Ae),j.append(Pe),_.status!=="published"&&((ge=(N=(G=_.draft_config)==null?void 0:G.arms)==null?void 0:N.length)!=null?ge:0)>0){let Ve=Le("#10b981","Publish");Ve.onclick=async()=>{Ve.disabled=!0;let At=await ce(e,`/v1/editor/slots/${encodeURIComponent(_.slot_id)}/publish`,{});Ve.disabled=!1,be(At,"\u2713 Published \u2014 live for new visitors."),At.r==="ok"&&(c("published",{kind:"slot"}),tt())},j.append(Ve)}_.status!=="published"&&j.append(Dt(`/v1/editor/slots/${encodeURIComponent(_.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Yn(_.slot_id),tt()})),xe.append(j)}if(l)xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(f.length>0){xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let _ of f){let{row:j}=p((me=_.display_name)!=null?me:_.goal_id);if(j.append(h(_.status==="active")),_.status==="draft"){let se=Le("#10b981","Start tracking");se.onclick=async()=>{se.disabled=!0;let Ae=await ce(e,`/v1/editor/goals/${encodeURIComponent(_.goal_id)}/publish`,{});se.disabled=!1,be(Ae,"\u2713 Tracking is live \u2014 it counts from your next visitor."),Ae.r==="ok"&&(c("published",{kind:"goal"}),tt())},j.append(se,Dt(`/v1/editor/goals/${encodeURIComponent(_.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Jn(_.goal_id),tt()}))}xe.append(j)}}},ar=o=>{Y!==o&&(ae(),kt(),Y=o,Nt())},Kn=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(L.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Gn=!1,Be=d("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});Be.append(Ai(26)),Be.title="Open the SentientUI editor",Be.setAttribute("aria-label","Open the SentientUI editor");let Un=An("minimize","Minimize");Un.onclick=()=>{y.style.display="none",Be.style.display="flex",Gn=E,E=!0,m.style.display="none",mt(document)},Be.onclick=()=>{y.style.display="block",Be.style.display="none",E=Gn},Object.assign(z.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Kn.append(L,z,Un,_e);let Fn=d("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Ke=d("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Fn.append(Ke,Z,ye,ue);let Wn=d("button",{display:"inline-block",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"),on=d("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(J.style,{flex:"1 1 auto",marginBottom:"0"}),on.append(J,Wn),Object.assign(on.style,{marginBottom:"6px"});let Ht=d("div",{}),W=d("div",{marginTop:"4px"});W.addEventListener("input",()=>{nt=!0}),W.addEventListener("change",()=>{nt=!0}),y.append(Kn,D,on,pe,ee,Ht,Dn,Hn,W,Fn),((so=document.body)!=null?so:document.documentElement).append(m,x,y,Be);let Oe=null,zt=()=>{Oe==null||Oe(),Oe=null},qn=()=>{Oe=null},ht=null,nt=!1,rn=null,ae=()=>{zt(),ht=null,W.textContent="",nt=!1,rn=null,gn=!1},yt=(o,i,a,l)=>{var C;ae();let u={},f={};for(let w of o){let v=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},w.label);if(W.append(v),w.type==="select"){let A=d("select",Pt);A.setAttribute("data-field",w.key);let P=document.createElement("option");P.value="",P.textContent="\u2014 no change \u2014",A.append(P);for(let H of(C=w.options)!=null?C:[]){let G=document.createElement("option");G.value=H,G.textContent=H,A.append(G)}u[w.key]=()=>A.value,W.append(A)}else if(w.type==="color"){let A=d("input",le(K({},Pt),{padding:"2px",height:"34px"}));A.type="color",A.setAttribute("data-field",w.key);let P=!1;A.addEventListener("input",()=>{P=!0}),u[w.key]=()=>P?A.value:"",W.append(A)}else{let A=d("input",Pt);A.setAttribute("data-field",w.key),w.value!==void 0&&(A.value=w.value),u[w.key]=()=>A.value,W.append(A)}let b=d("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});b.setAttribute("data-feedback",w.key),f[w.key]=b,W.append(b)}let h=(w,v)=>{let b=f[w];b&&(b.textContent=v!=null?v:"",b.style.display=v?"block":"none")};if(l){let w=Vn(l);W.append(w.node),u[bt]=w.value}let p=d("button",F("#6366f1"),i),S=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>a(Object.fromEntries(Object.entries(u).map(([w,v])=>[w,v()])),h),S.onclick=ae,W.append(p,S)},bt="__page",an={},sr=o=>{var i;for(let a of o!=null?o:[])an[a.slot_id]=(i=a.target)==null?void 0:i.page};ft(e,"/v1/editor/slots").then(o=>sr(o==null?void 0:o.slots));let Vn=o=>{let i=Rt(location.pathname),a=d("div",{}),l=d("select",Pt);l.setAttribute("data-field","page");for(let u of Ln(i,an[o])){let f=document.createElement("option");f.value=u,f.textContent=Fo(u,i),l.append(f)}return a.append(d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,d("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:a,value:()=>l.value}},vt=(o,i)=>i?le(K({},o),{page:i}):o,T=(o,i=!0)=>{Z.textContent=o,Z.style.color=i?"#a7f3d0":"#fca5a5"},sn=(o,i)=>{var l,u;if(c("error_shown",{code:(u=o.code)!=null?u:`http_${(l=o.status)!=null?l:"network"}`}),o.code==="plan_limit_reached"){let f=o.feature==="live_goals"?"live goal":"of these",h=o.plan?`${o.plan} plan`:"plan";return o.feature==="live_goals"?`Your ${h} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${h} has reached its limit for ${f}. Manage them in your dashboard, or upgrade for more.`}if(o.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(o.code==="demo_read_only"&&o.message)return o.message;let a=o.status?` (HTTP ${o.status})`:"";return`\u26A0 Couldn\u2019t ${i} \u2014 try again.${a}`},be=(o,i)=>{o.r==="ok"?T(i,!0):o.r==="expired"?T("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):T(sn(o,"save"),!1)},Ge=null,jt=o=>o.length>30?`${o.slice(0,27)}\u2026`:o,Yn=o=>{Ge===o&&(ht===o&&(zt(),ht=null),Ge=null,ye.style.display="none",R.style.display="none",Ke.textContent="")},Jn=o=>{at===o&&(at=null,ue.style.display="none",Ke.textContent="")},xt=(o,i,a)=>{Ge=o,ye.textContent=i?`Publish \u201C${jt(i)}\u201D \u2014 go live`:"Publish now \u2014 go live",ye.style.display="block",R.style.display="block";let l=[];if(a){let u=Le("#374151","Preview");u.onclick=()=>zn(o,a),l.push(u)}l.push(Dt(`/v1/editor/slots/${encodeURIComponent(o)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Yn(o))),jn(i?`Draft saved for \u201C${jt(i)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ye.onclick=async()=>{if(!Ge)return;ye.disabled=!0,T("Publishing\u2026");let o=await ce(e,`/v1/editor/slots/${encodeURIComponent(Ge)}/publish`,{});ye.disabled=!1,o.r==="ok"?(c("published",{kind:"slot"}),T("\u2713 Published \u2014 live for new visitors.",!0),ye.style.display="none",Ge=null,Ke.textContent=""):o.r==="expired"?T("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):T(sn(o,"publish"),!1)};let oe=null,Me=!1,ot=null,rt=null,Ee=null,Ue=null,wt=null,Kt=null,Fe=!1,Xn=(o,i)=>Me?o?"":`Nothing to swap with ${i} \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.",Zn=()=>{B.disabled=!Me||!Ee,V.disabled=!Me||!Ue,B.title=B.disabled?Xn(Ee,"above"):"",V.title=V.disabled?Xn(Ue,"below"):""},Te=null,ln=o=>{o&&!Te&&t&&oe?(Te=Vn(Ce("move",oe,t)),Se.before(Te.node)):o||(Te==null||Te.node.remove(),Te=null),Se.style.display=o?"block":"none",ze.style.display=o?"block":"none",Zn()},kt=()=>{if(Fe&&t&&wt&&wt.insertBefore(t,Kt),Fe=!1,wt=null,Kt=null,t){let o=en(t,document);ot=o.prevEl,rt=o.nextEl,Ee=o.prevLocator,Ue=o.nextLocator}g(),ln(!1)},Qn=o=>{if(E)return;let i=o.target;if(!i||y.contains(i)||i===m)return;mt(document);let a=i.getBoundingClientRect();Object.assign(m.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},Re=o=>{var a;let i=((a=o.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},lr=o=>!!o.id||["section","header","footer","nav","main","form","article","aside"].includes(o.tagName.toLowerCase())||!!o.querySelector(":scope > h1, :scope > h2, :scope > h3"),cr=o=>{var l;let i=o.querySelector("h1, h2, h3"),a=(l=i==null?void 0:i.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:o.id?`#${o.id.length>24?`${o.id.slice(0,21)}\u2026`:o.id}`:`<${o.tagName.toLowerCase()}>`},dr=o=>{pe.textContent="";let i=[];for(let h=o.parentElement;h&&h!==document.body&&i.length<3;h=h.parentElement)lr(h)&&i.push(h);let a=Re(o),l=()=>d("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),u=!0;for(let h of i){let p=cr(h);if(p===a||a.startsWith(p))continue;let S=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);S.onclick=()=>St(h),u||pe.append(l()),pe.append(S),u=!1}u||pe.append(l());let f=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");f.onclick=()=>eo(),pe.append(f),pe.style.display="block"},ur=o=>{ee.textContent="";let i=null,a=0;for(let u=o.parentElement;u&&u!==document.body&&a<6;u=u.parentElement,a++)if(ut(Xe(u,document),u,document)){i=u;break}let l=d("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(i){let u=i;l.append(d("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 f=d("button",le(K({},F("#6366f1")),{marginTop:"0"}),`Select \u201C${Re(u)}\u201D instead`);f.onclick=()=>St(u);let h=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Pick something else");h.onclick=()=>{ee.textContent=""},l.append(f,h)}else l.append(d("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));ee.append(l)},St=o=>{kt(),ae(),ee.textContent="",t=o,oe=Xe(o,document);let i=ut(oe,o,document);Me=i,g(),J.style.display="block",J.textContent=`Selected: ${Re(o)}`,dr(o),c("element_selected",{unique:i}),T(i?"\u2713 Matches exactly 1 element":"",i),i||ur(o),D.style.display="none",pn();for(let f of je)f.style.display="block";U.style.display="none",X.style.display="none";let a=vn(o);U.disabled=!i||!a,U.title=i?a?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",X.disabled=!i,ne.disabled=!i,Q.disabled=!i;let l=o.closest("form");M.style.display=l?"block":"none",M.disabled=!l;let u=en(o,document);ot=u.prevEl,rt=u.nextEl,Ee=u.prevLocator,Ue=u.nextLocator,Zn(),Nt()},eo=()=>{kt(),ae(),t=null,oe=null,Me=!1,ot=null,rt=null,Ee=null,Ue=null,g(),ee.textContent="",pn(),pe.textContent="",pe.style.display="none",J.textContent="",J.style.display="none";for(let o of je)o.style.display="none";D.style.display="block",T(""),Nt()},it=!1,cn=-1,to=o=>{var l,u;let i=o.target,a=!!((l=i==null?void 0:i.closest)!=null&&l.call(i,'input, textarea, select, [contenteditable="true"]'));if(o.key==="Escape"){if(W.childElementCount>0){ae(),it=!1;return}if(t){eo(),it=!1;return}if(!it){it=!0,T("Press Esc again to close the editor.");return}it=!1,(u=_e.onclick)==null||u.call(_e,new MouseEvent("click"));return}if(it=!1,!(a||E)){if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!t||(o.key==="ArrowUp"?B:V).disabled)return;o.preventDefault(),fn(o.key==="ArrowUp"?"up":"down");return}if(o.key==="Tab"){let f=[];for(let p of On){let S=we(p.locator,document);S&&!f.includes(S)&&f.push(S)}if(f.length===0)return;if(nt){T("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),o.preventDefault();return}o.preventDefault(),cn=(cn+(o.shiftKey?-1:1)+f.length)%f.length;let h=f[cn];St(h);try{h.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},no=o=>{if(E)return;let i=o.target;if(!(!i||y.contains(i))){if(o.preventDefault(),o.stopPropagation(),nt&&i!==t&&rn!==i){rn=i,T("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}St(i)}};U.onclick=()=>{var f,h;if(!t||!oe)return;c("form_opened",{kind:"text"});let o=oe,i=(h=(f=t.textContent)==null?void 0:f.trim())!=null?h:"";yt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async p=>{let S=p.alt.trim();if(!S){T("\u26A0 Enter alternative wording to test.",!1);return}if(S===p.current.trim()){T("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let C=Ce("text",o,t);T("Saving\u2026");let w=await ce(e,`/v1/editor/slots/${encodeURIComponent(C)}`,{kind:"arms",target:vt(o,p[bt]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:p.current}},{id:"b",displayName:"Alternative",ops:{text:p.alt}}]}});w.r==="ok"&&(c("draft_saved",{kind:"slot"}),qn(),ae(),xt(C,Re(t),"b")),be(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ce("text",o,t));let a=t,l=xn(a);Oe=()=>{Ye(a,l)};let u=W.querySelector('input[data-field="alt"]');u==null||u.addEventListener("input",()=>{Ye(a,u.value.trim()===""?l:u.value)})};let Et=null,oo=o=>{let i=p=>{var S;return((S=p.textContent)!=null?S:"").replace(/\s+/g," ").trim()},a=Array.from(o.querySelectorAll("h1,h2,h3,h4")).map(i).filter(Boolean);if(a.length===0){let p=o.closest("h1,h2,h3,h4");p&&a.push(i(p))}let l=Array.from(o.querySelectorAll("p")).map(i).filter(p=>p.length>0&&p.length<=300),u=[];for(let p of Array.from(o.querySelectorAll("a[href], button"))){let S=i(p);if(!S||S.length>60)continue;let C="",w=p.getAttribute("href");if(w)try{let v=new URL(w,window.location.href);v.protocol==="https:"&&(C=v.href)}catch(v){}u.push({label:S,href:C})}let f=Array.from(o.querySelectorAll("blockquote, q")).map(i).filter(Boolean);if(f.length===0&&wi.test(`${o.className} ${o.id}`))for(let p of l)p.length>=20&&f.push(p);let h=Array.from(o.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(i).filter(p=>p.length>0&&p.length<=80);return{headings:a,paragraphs:l,links:u,quotes:f,attributions:h}},pr=(o,i)=>{var l,u,f,h,p,S,C,w,v,b,A,P,H,G,N,ge,me,_,j,se;let a=Ae=>{var Pe;return i.paragraphs.length>=3&&(Pe=i.paragraphs[i.paragraphs.length-3+Ae])!=null?Pe:""};switch(o){case"headline":return(l=i.headings[0])!=null?l:"";case"supporting":return(u=i.paragraphs[0])!=null?u:"";case"cta_label":return(h=(f=i.links[0])==null?void 0:f.label)!=null?h:"";case"cta_href":return(S=(p=i.links[0])==null?void 0:p.href)!=null?S:"";case"secondary_label":return(w=(C=i.links[1])==null?void 0:C.label)!=null?w:"";case"secondary_href":return(b=(v=i.links[1])==null?void 0:v.href)!=null?b:"";case"quote":case"q1":return(A=i.quotes[0])!=null?A:"";case"q2":return(P=i.quotes[1])!=null?P:"";case"q3":return(H=i.quotes[2])!=null?H:"";case"name":case"n1":return(G=i.attributions[0])!=null?G:"";case"n2":return(N=i.attributions[1])!=null?N:"";case"n3":return(ge=i.attributions[2])!=null?ge:"";case"role":return(me=i.attributions[1])!=null?me:"";case"eyebrow":return"";case"f1_title":return(_=i.headings[1])!=null?_:"";case"f2_title":return(j=i.headings[2])!=null?j:"";case"f3_title":return(se=i.headings[3])!=null?se:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},fr=(o,i,a)=>{c("form_opened",{kind:"arrangement"});let l=oo(a);yt(o.fields.map(u=>({key:u.id,label:u.kind==="href"?`${u.label} (https link \u2014 required)`:u.label,value:pr(u.id,l)})),"Save draft",async(u,f)=>{var A,P,G,N,ge;let h=!1,p=!1;for(let me of o.fields){if(me.kind==="href"){let j=!1;try{j=new URL((A=u[me.id])!=null?A:"").protocol==="https:"}catch(se){}f(me.id,j?null:"Links need to start with https://"),j||(h=!0);continue}let _=((P=u[me.id])!=null?P:"").trim()==="";f(me.id,_?"Fill this in with your own words":null),_&&(p=!0)}if(h){T("\u26A0 Fix the highlighted link(s).",!1);return}if(p){T("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}T("Saving\u2026");let H=u,{[bt]:S}=H,C=po(H,[uo(bt)]),w=await vi(e,`/v1/editor/arrangements/${encodeURIComponent(o.id)}/instantiate`,{fields:C});if(w.r!=="ok"||!((G=w.data)!=null&&G.blocks)){w.r==="expired"?be(w.outcome,""):T(`\u26A0 ${(ge=(N=w.data)==null?void 0:N.reason)!=null?ge:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let v=Ce("arrange",i,a),b=await ce(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:vt(i,S),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:o.id,displayName:o.name,blocks:w.data.blocks}],baseline:"original"}});b.r==="ok"&&(c("draft_saved",{kind:"arrangement"}),ae(),xt(v,o.name,o.id)),be(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("arrange",i,a))};ne.onclick=async()=>{var f,h;if(!t||!oe)return;let o=oe,i=t;if(ae(),T("Loading arrangements\u2026"),!Et){let p=await ft(e,"/v1/editor/arrangements");Et=(f=p==null?void 0:p.arrangements)!=null?f:null}if(!Et||Et.length===0){T("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let a=or(oo(i)),l=Et.filter(p=>a.includes(p.sectionType));if(l.length===0){T("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}T("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let S=d("button",le(K({},F("#374151")),{textAlign:"left"}));S.append(d("div",{fontWeight:"600"},p.name),d("div",{fontSize:"11px",opacity:"0.7"},p.description)),S.onclick=()=>fr(p,o,i),W.append(S)}let u=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");u.onclick=ae,W.append(u),(h=W.scrollIntoView)==null||h.call(W,{block:"nearest"})};let at=null,gr=(o,i)=>{at=o,ue.textContent=i?`Start tracking \u201C${jt(i)}\u201D now`:"Start tracking now",ue.style.display="block",jn(i?`Goal \u201C${jt(i)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[Dt(`/v1/editor/goals/${encodeURIComponent(o)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Jn(o))])};ue.onclick=async()=>{if(!at)return;ue.disabled=!0,T("Activating\u2026");let o=await ce(e,`/v1/editor/goals/${encodeURIComponent(at)}/publish`,{});ue.disabled=!1,o.r==="ok"?(c("published",{kind:"goal"}),T("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ue.style.display="none",at=null,Ke.textContent=""):o.r==="expired"?T("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):T(sn(o,"activate"),!1)};let st=(o,i)=>`${pt(o)||"goal"}-${Zo(i)}`.slice(0,128),ro=o=>{var l,u,f;let i=((l=o.textContent)!=null?l:"").replace(/\s+/g," ").trim();return i&&i.length<=60?i:((f=(u=o.getAttribute("aria-label"))!=null?u:o.getAttribute("id"))!=null?f:"").trim()||"element-clicked"},Tt=async(o,i,a)=>{T("Saving\u2026");let l=await ce(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);return l.r==="ok"&&(c("draft_saved",{kind:"goal"}),gr(o,a)),be(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),l};Q.onclick=()=>{if(!t||!oe)return;let o=st(ro(t),JSON.stringify(oe));Tt(o,{event:"click",locator:oe},Re(t))},M.onclick=()=>{var l,u;let o=t==null?void 0:t.closest("form");if(!o)return;let i=Xe(o,document),a=(u=(l=o.getAttribute("id"))!=null?l:o.getAttribute("name"))!=null?u:"form-submitted";Tt(st(a,JSON.stringify(i)),{event:"form_submit",locator:i},a)},re.onclick=()=>{let o=window.location.pathname||"/",i=pt(o)?`reached-${pt(o)}`:"page-visited";Tt(st(i,o),{event:"url_reached",urlPattern:o},o)};let dn=[{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}];ie.onclick=()=>{yt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:dn.map(o=>o.label)}],"Track it",o=>{var l;let i=(l=dn.find(u=>u.label===o.depth))!=null?l:dn[2],a=Math.round(i.value*100);Tt(`read-${a}pct`,{event:"scroll_depth",threshold:i.value},`read ${a}%`),ae()})};let Gt=null,mr=o=>{Gt=o,q.style.display="block"};q.onclick=async()=>{if(!Gt)return;q.disabled=!0,T("Turning on\u2026");let o=await ce(e,`/v1/editor/funnels/${encodeURIComponent(Gt)}/publish`,{});q.disabled=!1,o.r==="ok"?(c("published",{kind:"funnel"}),T("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),q.style.display="none",Gt=null):o.r==="expired"?T("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):T("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},I.onclick=async()=>{var w;T("Loading your goals\u2026");let o=await ft(e,"/v1/editor/goals"),i=(w=o==null?void 0:o.goals)!=null?w:[];if(i.length<2){T("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}T("Pick the steps in order \u2014 first click = first step."),ae();let a=[],l=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=d("input",Pt);W.append(l,u);let f=d("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");W.append(f);let h=new Map,p=()=>{var v,b;for(let[A,P]of h){let H=a.indexOf(A),G=(b=(v=i.find(N=>N.goal_id===A))==null?void 0:v.display_name)!=null?b:A;P.textContent=H===-1?G:`${H+1}. ${G}`,P.style.background=H===-1?"#374151":"#6366f1"}};for(let v of i){let b=d("button",le(K({},F("#374151")),{textAlign:"left"}));h.set(v.goal_id,b),b.onclick=()=>{a=Wo(a,v.goal_id),p()},W.append(b)}p();let S=d("button",F("#6366f1"),"Save funnel"),C=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");C.onclick=ae,S.onclick=async()=>{let v=qo(u.value,a);if(!v.ok){T(`\u26A0 ${v.error}`,!1);return}T("Saving\u2026");let b=await ce(e,`/v1/editor/funnels/${encodeURIComponent(v.funnelId)}`,v.body);b.r==="ok"&&(c("draft_saved",{kind:"funnel"}),ae(),mr(v.funnelId)),be(b,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},W.append(S,C)},R.onclick=async()=>{var p,S;let o=Ge;if(!o)return;T("Loading funnels\u2026");let i=await ft(e,"/v1/editor/funnels"),a=(p=i==null?void 0:i.funnels)!=null?p:[];if(a.length===0){T("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await ft(e,"/v1/editor/goals"),u=new Map(((S=l==null?void 0:l.goals)!=null?S:[]).map(C=>[C.goal_id,C.display_name]));yt([{key:"funnel",label:"Funnel",type:"select",options:a.map(C=>Xt(C))},{key:"step",label:"Which step does this element serve?",type:"select",options:Zt(a[0],u).map(C=>C.label)}],"Attach",async C=>{var A;let w=(A=a.find(P=>Xt(P)===C.funnel))!=null?A:a[0],v=Zt(w,u).findIndex(P=>P.label===C.step);if(v<0){T("\u26A0 Pick which step this element serves.",!1);return}T("Attaching\u2026");let b=await ce(e,`/v1/editor/funnels/${encodeURIComponent(w.funnel_id)}/assign`,{slotId:o,stepIndex:v});b.r==="ok"&&ae(),be(b,`\u2713 Attached \u2014 this test now works toward \u201C${w.display_name}\u201D.`)});let f=W.querySelector('select[data-field="funnel"]'),h=W.querySelector('select[data-field="step"]');f&&h&&f.addEventListener("change",()=>{var w;let C=(w=a.find(v=>Xt(v)===f.value))!=null?w:a[0];h.length=1;for(let v of Zt(C,u)){let b=document.createElement("option");b.value=v.label,b.textContent=v.label,h.append(b)}})},X.onclick=()=>{if(!t||!oe)return;c("form_opened",{kind:"style"});let o=oe;yt([{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:$n.length?`Font (this site has: ${$n.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(h,p)=>{var A;let{style:S,errors:C}=Rn(h),w=!1;for(let P of Mn)p(P,(A=C[P])!=null?A:null),C[P]&&(w=!0);if(w){T("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(S).length===0){T("\u26A0 Enter at least one style change.",!1);return}let v=Ce("style",o,t);T("Saving\u2026");let b=await ce(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:vt(o,h[bt]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:S}}]}});b.r==="ok"&&(c("draft_saved",{kind:"slot"}),qn(),ae(),xt(v,Re(t),"b")),be(b,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ce("style",o,t));let i=t,a=i.style.cssText;Oe=()=>{i.style.cssText=a};let l={},u=()=>{let{style:h}=Rn(l);i.style.cssText=a;for(let[p,S]of Object.entries(h)){let C=It[p];C&&ct(S)&&i.style.setProperty(C,S.trim(),"important")}};for(let h of Mn){let p=W.querySelector(`[data-field="${h}"]`);if(!p)continue;let S=()=>{l[h]=p.value,u()};p.addEventListener("input",S),p.addEventListener("change",S)}let f=[Ze==null?void 0:Ze.primaryBg,Ze==null?void 0:Ze.primaryText,"#ffffff"].filter(h=>!!h).map(Bn).filter((h,p,S)=>Nn(h)&&S.indexOf(h)===p);for(let h of["color","background"]){let p=W.querySelector(`input[data-field="${h}"]`);if(!p)continue;let S=d("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let C of f){let w=d("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:C,padding:"0"});w.title=C,w.onclick=()=>{p.value=Bn(C),p.dispatchEvent(new Event("input"))},S.append(w)}p.after(S)}};let We=[],Ct=new Map,un=!1,fe=null,te=null,Lt=null,hr=()=>{Ct.clear();let o=[],i=(a,l,u)=>{var p;if(o.length>=16||[...Ct.values()].some(S=>S.node===a))return;let f=a===t,h=f?"selected":`e${o.length}`;Ct.set(h,{node:a,locator:l}),o.push(K(K({ref:h,tag:a.tagName.toLowerCase().slice(0,16),text:((p=a.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:vn(a),inForm:!!a.closest("form")},f?{selected:!0}:{}),u?{label:u.slice(0,120)}:{}))};t&&oe&&Me&&i(t,oe);for(let a of On){let l=we(a.locator,document);l&&i(l,a.locator,a.label)}return{pagePath:Rt(location.pathname),pageTitle:document.title.slice(0,200),elements:o}},qe=(o,i="")=>{let a=o==="user",l=d("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:a?"auto":"0",background:a?"#6366f1":o==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:o==="note"?"0.75":"1"},i);return fe==null||fe.append(l),fe&&(fe.scrollTop=fe.scrollHeight),l},pn=()=>{Lt&&(Lt.textContent=t?Me?`Looking at: ${Re(t)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},io=(o,i)=>{var u;zt();let a=xn(o),l=o.style.cssText;if(Oe=()=>{Ye(o,a),o.style.cssText=l},!!i){typeof i.text=="string"&&Ye(o,i.text);for(let[f,h]of Object.entries((u=i.style)!=null?u:{})){let p=It[f];p&&typeof h=="string"&&ct(h)&&o.style.setProperty(p,h.trim(),"important")}}},yr=async o=>{var A,P;let i=Ct.get(o.ref);if(!i||!i.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:a,locator:l}=i,u=o.versions.some(H=>typeof H.ops.text=="string"),f=Ce(u?"text":"style",l,a),h=Ln(location.pathname,an[f])[0];T("Saving\u2026");let p=await ce(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:vt(l,h),draftConfig:{arms:[{id:"a",displayName:"Original",ops:u?{text:((A=a.textContent)!=null?A:"").trim()}:{}},...o.versions]}});if(be(p,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),p.r!=="ok")return(P=Z.textContent)!=null?P:"\u26A0 Couldn\u2019t save the draft.";c("draft_saved",{kind:"slot",via:"chat"}),a!==t&&St(a),ae();let S=a;io(S,o.versions[0].ops),ht=f;try{S.scrollIntoView({block:"center",behavior:"smooth"})}catch(H){}xt(f,o.label,o.versions[0].id);let C=qe("assistant");C.textContent="",C.append(d("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${o.label}`));let w=d("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),v=[],b=(H,G)=>{for(let N of v)N.style.background="#374151";H.style.background="#6366f1",io(S,G),ht=f};for(let[H,G]of[["Original",null],...o.versions.map(N=>[N.displayName,N.ops])]){let N=Le("#374151",H);N.onclick=()=>b(N,G),v.push(N),w.append(N)}return v[1].style.background="#6366f1",C.append(w),`[Created draft "${o.label}" with ${o.versions.length} version(s)]`},br=(o,i,a)=>{var h;let l=[],u={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},f=null;if(o){let p=o.getBoundingClientRect();f=p.top+window.scrollY,l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${p.left+window.scrollX-3}px`,top:`${f-3}px`,width:`${p.width+6}px`,height:`${p.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),d("div",le(K({},u),{left:`${p.left+window.scrollX}px`,top:`${Math.max(0,f-24)}px`}),`Goal: ${a}`))}else i!==void 0&&(f=Math.round(document.documentElement.scrollHeight*i),l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${f}px`,borderTop:"2px dashed #f59e0b"}),d("div",le(K({},u),{left:"16px",top:`${f+4}px`}),`Goal counts here: ${a}`)));if(l.length!==0){if(((h=document.body)!=null?h:document.documentElement).append(...l),f!==null)try{window.scrollTo({top:Math.max(0,f-window.innerHeight/3),behavior:"smooth"})}catch(p){}setTimeout(()=>{for(let p of l)p.remove()},6e3)}},vr=async o=>{var f,h,p,S,C,w;let i=null,a,l;if(o.event==="click"||o.event==="form_submit"){let v=o.ref?Ct.get(o.ref):void 0;if(!v||!v.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(o.event==="click")i=v.node,a=st(ro(i),JSON.stringify(v.locator)),l={event:"click",locator:v.locator};else{let b=v.node.closest("form");if(!b)return"\u26A0 That element isn\u2019t inside a form.";let A=Xe(b,document);if(!ut(A,b,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=b,a=st((h=(f=b.getAttribute("id"))!=null?f:b.getAttribute("name"))!=null?h:"form-submitted",JSON.stringify(A)),l={event:"form_submit",locator:A}}}else if(o.event==="url_reached"){let v=(p=o.urlPattern)!=null?p:Rt(location.pathname);a=st(pt(v)?`reached-${pt(v)}`:"page-visited",v),l={event:"url_reached",urlPattern:v}}else a=`read-${Math.round(((S=o.threshold)!=null?S:.75)*100)}pct`,l={event:"scroll_depth",threshold:(C=o.threshold)!=null?C:.75};return(await Tt(a,le(K({},l),{displayName:o.displayName}),o.displayName)).r!=="ok"?(w=Z.textContent)!=null?w:"\u26A0 Couldn\u2019t save the goal.":(br(i,o.event==="scroll_depth"?l.threshold:void 0,o.displayName),`[Created draft goal "${o.displayName}"]`)},ao=async o=>{var S,C,w;let i=o.trim();if(!i||un)return;un=!0,te&&(te.value="",te.disabled=!0),qe("user",i),We.push({role:"user",content:i.slice(0,4e3)}),c("form_opened",{kind:"chat"});let a=qe("assistant","\u2026"),l="",u=!1,f=[],h=[],p=v=>{var A,P;if(v==="[DONE]")return;let b;try{b=JSON.parse(v)}catch(H){return}if(b.error){f.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(b.type==="delta"&&b.text)u&&l&&(l+=`
25
25
 
26
- `),u=!1,l+=b.text,a.textContent=l,fe&&(fe.scrollTop=fe.scrollHeight);else if(b.type==="tool_status")u=!0,b.state==="running"&&!l&&(a.textContent=(_=b.name)!=null&&_.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(b.type==="choice_prompt"&&b.question){l+=(l?`
26
+ `),u=!1,l+=b.text,a.textContent=l,fe&&(fe.scrollTop=fe.scrollHeight);else if(b.type==="tool_status")u=!0,b.state==="running"&&!l&&(a.textContent=(A=b.name)!=null&&A.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(b.type==="choice_prompt"&&b.question){l+=(l?`
27
27
 
28
- `:"")+b.question,a.textContent=l;let H=d("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let U of(N=b.options)!=null?N:[]){let R=Le("#374151",U.label);R.onclick=()=>{ao(U.label)},H.append(R)}a.append(H)}else if(b.type==="artifact"&&b.artifact){let H=b.artifact.type==="editor_component_draft"?yr(b.artifact.payload):b.artifact.type==="editor_goal_draft"?vr(b.artifact.payload):null;H&&h.push(H.then(U=>{f.push(U),U.startsWith("\u26A0")&&qe("note",U)}))}};try{let v=We.slice(-20);for(;((S=v[0])==null?void 0:S.role)==="assistant";)v=v.slice(1);let b=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:v,context:hr()})});if(!b.ok){let R=(T=await b.json().catch(()=>null))==null?void 0:T.error;a.textContent=b.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":R==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":R==="plan_required"?"AI chat isn\u2019t included in this plan.":R==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${b.status})`,We.pop();return}let _=(w=b.body)==null?void 0:w.getReader(),N="",H=()=>{let R;for(;(R=N.indexOf(`
28
+ `:"")+b.question,a.textContent=l;let H=d("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let G of(P=b.options)!=null?P:[]){let N=Le("#374151",G.label);N.onclick=()=>{ao(G.label)},H.append(N)}a.append(H)}else if(b.type==="artifact"&&b.artifact){let H=b.artifact.type==="editor_component_draft"?yr(b.artifact.payload):b.artifact.type==="editor_goal_draft"?vr(b.artifact.payload):null;H&&h.push(H.then(G=>{f.push(G),G.startsWith("\u26A0")&&qe("note",G)}))}};try{let v=We.slice(-20);for(;((S=v[0])==null?void 0:S.role)==="assistant";)v=v.slice(1);let b=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:v,context:hr()})});if(!b.ok){let N=(C=await b.json().catch(()=>null))==null?void 0:C.error;a.textContent=b.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":N==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":N==="plan_required"?"AI chat isn\u2019t included in this plan.":N==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${b.status})`,We.pop();return}let A=(w=b.body)==null?void 0:w.getReader(),P="",H=()=>{let N;for(;(N=P.indexOf(`
29
29
 
30
- `))>=0;){for(let ge of N.slice(0,R).split(`
31
- `))ge.startsWith("data: ")&&p(ge.slice(6));N=N.slice(R+2)}};if(_){let R=new TextDecoder;for(;;){let{done:ge,value:me}=await _.read();if(ge)break;N+=R.decode(me,{stream:!0}),H()}}else N=await b.text();N+=`
30
+ `))>=0;){for(let ge of P.slice(0,N).split(`
31
+ `))ge.startsWith("data: ")&&p(ge.slice(6));P=P.slice(N+2)}};if(A){let N=new TextDecoder;for(;;){let{done:ge,value:me}=await A.read();if(ge)break;P+=N.decode(me,{stream:!0}),H()}}else P=await b.text();P+=`
32
32
 
33
- `,H(),await Promise.all(h),l||(a.textContent=f.some(R=>R.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let R of f)R.startsWith("\u26A0 The assistant")&&qe("note",R);let U=[l,...f.filter(R=>R.startsWith("["))].filter(Boolean).join(`
34
- `);We.push({role:"assistant",content:(U||"(no reply)").slice(0,4e3)})}catch(v){a.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",We.pop()}finally{un=!1,te&&(te.disabled=!1,te.focus())}},xr=()=>{if(fe){te==null||te.focus();return}let o=d("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});o.setAttribute("data-sentient-chat","");let i=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),a=_n("close","Close AI chat");if(a.onclick=()=>{Ht.textContent="",fe=null,te=null,Lt=null},i.append(d("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),a),Lt=d("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),pn(),fe=d("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),We.length===0)qe("note","Tell me what to try \u2014 e.g. \u201Cmake this headline more urgent\u201D or \u201Ctrack clicks on the signup button\u201D. I\u2019ll create a draft and show it on the page. Nothing goes live until you publish.");else for(let f of We)qe(f.role,f.content);let l=d("div",{display:"flex",gap:"6px",marginTop:"6px"});te=d("input",{flex:"1 1 auto",minWidth:"0",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"}),te.type="text",te.maxLength=1e3,te.placeholder="What do you want to change or track?",te.setAttribute("data-field","ai-chat");let u=Le("#6366f1","Send");u.setAttribute("data-action","ai-send"),u.onclick=()=>{te&&ao(te.value)},te.onkeydown=f=>{var h;f.key==="Enter"&&(f.preventDefault(),(h=u.onclick)==null||h.call(u,new MouseEvent("click")))},l.append(te,u),o.append(i,Lt,fe,l),Ht.textContent="",Ht.append(o),te.focus()};Wn.onclick=()=>xr();let fn=o=>{if(!t)return;let i=t.parentElement;if(!i)return;Fe||(wt=i,Kt=t.nextSibling,Fe=!0),o==="up"&&ot?i.insertBefore(t,ot):o==="down"&&rt&&i.insertBefore(t,rt.nextSibling);let a=en(t,document);ot=a.prevEl,rt=a.nextEl,Ee=a.prevLocator,Ge=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}g(),ln(!0),C("Previewing the new position \u2014 keep moving, save, or undo.")};B.onclick=()=>fn("up"),V.onclick=()=>fn("down"),ze.onclick=()=>{kt(),C("Move undone \u2014 back to the original position.")},Se.onclick=async()=>{if(!t||!oe||!Fe||!Me)return;let o=Ee?"moveAfter":"moveBefore",i=Ee!=null?Ee:Ge;if(!i){C("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=Te("move",oe,t);C("Saving\u2026");let l=await ce(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:vt(oe,Ce==null?void 0:Ce.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});l.r==="ok"&&(c("draft_saved",{kind:"move"}),Fe=!1,wt=null,Kt=null,ln(!1),xt(a,Pe(t),"b")),be(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let wr=()=>{var o,i;c("editor_closed"),s(),window.removeEventListener("pagehide",s),r&&clearTimeout(r),kt(),zt(),document.removeEventListener("mousemove",Qn,!0),document.removeEventListener("click",no,!0),document.removeEventListener("keydown",to,!0),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),mt(document),(o=document.getElementById(In))==null||o.remove(),m.remove(),x.remove(),y.remove(),Be.remove(),window.__sentientEditor=null,(i=document.querySelector("meta[data-sentient-editor]"))==null||i.remove(),Mt()},gn=!1;Ie.onclick=()=>{if((nt||Fe)&&!gn){gn=!0,C("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}wr()},document.addEventListener("mousemove",Qn,!0),document.addEventListener("click",no,!0),document.addEventListener("keydown",to,!0),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),Rt(),c("editor_opened")}var Li="http://www.w3.org/2000/svg";function Qe(e,t){let n=document.createElementNS(Li,e);for(let[r,s]of Object.entries(t))n.setAttribute(r,s);return n}function _i(e){let t=Qe("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),n={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return t.append(Qe("path",K({d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6"},n)),Qe("path",K({d:"M10 22H17"},n)),Qe("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),t}function _n(e,t){let n=d("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});n.setAttribute("aria-label",t),n.title=t;let r=Qe("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),s={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?r.append(Qe("path",K({d:"M3 7h8"},s))):r.append(Qe("path",K({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},s))),n.append(r),n.onmouseenter=()=>{n.style.background="rgba(255,255,255,0.1)",n.style.color="#fff"},n.onmouseleave=()=>{n.style.background="transparent",n.style.color="#9ca3af"},n}function F(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 nn="sentient-preview-bar";async function Ii(e,t){var y,$,L,D,E,z,J,Z,G,X,ne,Q;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 n=null;try{let M=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});M.ok&&(n=($=((y=(await M.json()).slots)!=null?y:[]).find(ie=>ie.slot_id===t&&ie.kind==="arms"))!=null?$:null)}catch(M){}let r=d("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)"});r.id=nn;let s=d("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");s.onclick=()=>{Mt();let M=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])M.searchParams.delete(re);location.assign(M.toString())};let c=d("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");c.onclick=()=>{let M=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])M.searchParams.delete(re);location.assign(M.toString())};let m=(z=(E=(L=n==null?void 0:n.draft_config)==null?void 0:L.arms)!=null?E:(D=n==null?void 0:n.published_config)==null?void 0:D.arms)!=null?z:[];if(!n||m.length===0){r.append(d("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),c,s),((J=document.body)!=null?J:document.documentElement).append(r);return}let x=new URLSearchParams(location.search).get("sentient_arm"),g=(G=(Z=m.find(M=>M.id===x))!=null?Z:m[1])!=null?G:m[0];r.append(d("span",{fontWeight:"700"},`Previewing: ${(X=n.display_name)!=null?X:n.slot_id}`));let k=n.target&&typeof n.target=="object"?we(n.target,document):null;if(!k)r.append(d("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{bo(k,g.ops,`preview-${n.slot_id}`,document);try{k.scrollIntoView({block:"center"})}catch(M){}for(let M of m){let re=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:M.id===g.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ne=M.displayName)!=null?ne:M.id);re.onclick=()=>{let ie=new URL(location.href);ie.searchParams.set("sentient_arm",M.id),location.assign(ie.toString())},r.append(re)}}r.append(c,s),((Q=document.body)!=null?Q:document.documentElement).append(r)}async function Ai(e,t){var y,$,L,D;let n=t.lastIndexOf("~"),r=n>0?t.slice(0,n):t,s=n>0?t.slice(n+1):"",c=d("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)"});c.id=nn;let m=d("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");m.onclick=()=>{Mt();let E=new URL(location.href);for(let z of["sentient_preview_cell","sentient_refresh_region"])E.searchParams.delete(z);location.assign(E.toString())};let x=E=>{var z;c.append(d("span",{},E),m),((z=document.body)!=null?z:document.documentElement).append(c)},g=null;try{let E=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(r)}&persona=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${e.token}`}});E.ok&&(g=await E.json())}catch(E){}if(!g)return x("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let k=g.target&&typeof g.target=="object"?we(g.target,document):null;if(!k)return x("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(g.edits!=null&&typeof g.skeletonFp=="string"&&Array.isArray(g.leafToNode)){if(Ro(k,g.edits,{fp:g.skeletonFp,leafToNode:g.leafToNode})==="mismatch")return x("This part of the page changed since this version was written \u2014 regenerate it from your dashboard.")}else if(g.compose!=null||g.blocks!=null)g.vocabulary&&Array.isArray(g.vocabulary.entries)&&ko(g.vocabulary),To(k,{preview:(y=g.compose)!=null?y:g.blocks},"preview",document);else if(typeof g.content=="string")k.textContent=g.content;else return x("Nothing to preview in that square yet.");try{k.scrollIntoView({block:"center"})}catch(E){}c.append(d("span",{fontWeight:"700"},`Previewing: ${($=g.slotName)!=null?$:r}`),d("span",{opacity:"0.85"},`for ${(L=g.personaDisplay)!=null?L:s}${g.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),m),((D=document.body)!=null?D:document.documentElement).append(c)}async function Jo(e,t){var c;let n=await ft(e,"/v1/editor/slots"),r=((c=n==null?void 0:n.slots)!=null?c:[]).filter(m=>t?m.slot_id===t:m.region_skeleton_status==null),s=r.length===0&&t?"missing":"none";for(let m of r){let x=m.target&&typeof m.target=="object"?we(m.target,document):null;if(!x){t&&(s="missing");continue}let g=Mo(x),k=g.skeleton?{slotId:m.slot_id,skeleton:g.skeleton}:{slotId:m.slot_id,status:g.reason};s=(await ce(e,"/v1/editor/region-skeleton",k)).r==="ok"?"ok":"failed"}return s}async function Xo(e){try{await ce(e,"/v1/editor/style-vocabulary",zo(document))}catch(t){}}async function $i(){if(typeof document=="undefined")return;let e=hi();if(!e)return;if(e.code){let x=await er(e);if(x!==200){Qt(x===401?Vo:Yo);return}}let t=await yi(e);if(!t.ok){t.unauthorized?(Mt(),Qt(Vo)):Qt(Yo);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(nn)||await Ii(e,n);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(nn)||await Ai(e,r),Xo(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let x=await Jo(e,s);Qt(x==="ok"?"Region refreshed \u2014 you can regenerate its versions now.":x==="missing"?"We couldn\u2019t find that part of the page here. It may live on another page.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.");return}if(document.getElementById(gt))return;ir(e);let c=Go(document);Ze=c,c&&ce(e,"/v1/editor/palette",c),Xo(e),Jo(e).catch(()=>{});let m=await xi(e);tr(m),nr(m,document)}$i();return Ir(Bi);})();
33
+ `,H(),await Promise.all(h),l||(a.textContent=f.some(N=>N.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let N of f)N.startsWith("\u26A0 The assistant")&&qe("note",N);let G=[l,...f.filter(N=>N.startsWith("["))].filter(Boolean).join(`
34
+ `);We.push({role:"assistant",content:(G||"(no reply)").slice(0,4e3)})}catch(v){a.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",We.pop()}finally{un=!1,te&&(te.disabled=!1,te.focus())}},xr=()=>{if(fe){te==null||te.focus();return}let o=d("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});o.setAttribute("data-sentient-chat","");let i=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),a=An("close","Close AI chat");if(a.onclick=()=>{Ht.textContent="",fe=null,te=null,Lt=null},i.append(d("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),a),Lt=d("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),pn(),fe=d("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),We.length===0)qe("note","Tell me what to try \u2014 e.g. \u201Cmake this headline more urgent\u201D or \u201Ctrack clicks on the signup button\u201D. I\u2019ll create a draft and show it on the page. Nothing goes live until you publish.");else for(let f of We)qe(f.role,f.content);let l=d("div",{display:"flex",gap:"6px",marginTop:"6px"});te=d("input",{flex:"1 1 auto",minWidth:"0",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"}),te.type="text",te.maxLength=1e3,te.placeholder="What do you want to change or track?",te.setAttribute("data-field","ai-chat");let u=Le("#6366f1","Send");u.setAttribute("data-action","ai-send"),u.onclick=()=>{te&&ao(te.value)},te.onkeydown=f=>{var h;f.key==="Enter"&&(f.preventDefault(),(h=u.onclick)==null||h.call(u,new MouseEvent("click")))},l.append(te,u),o.append(i,Lt,fe,l),Ht.textContent="",Ht.append(o),te.focus()};Wn.onclick=()=>xr();let fn=o=>{if(!t)return;let i=t.parentElement;if(!i)return;Fe||(wt=i,Kt=t.nextSibling,Fe=!0),o==="up"&&ot?i.insertBefore(t,ot):o==="down"&&rt&&i.insertBefore(t,rt.nextSibling);let a=en(t,document);ot=a.prevEl,rt=a.nextEl,Ee=a.prevLocator,Ue=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}g(),ln(!0),T("Previewing the new position \u2014 keep moving, save, or undo.")};B.onclick=()=>fn("up"),V.onclick=()=>fn("down"),ze.onclick=()=>{kt(),T("Move undone \u2014 back to the original position.")},Se.onclick=async()=>{if(!t||!oe||!Fe||!Me)return;let o=Ee?"moveAfter":"moveBefore",i=Ee!=null?Ee:Ue;if(!i){T("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=Ce("move",oe,t);T("Saving\u2026");let l=await ce(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:vt(oe,Te==null?void 0:Te.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});l.r==="ok"&&(c("draft_saved",{kind:"move"}),Fe=!1,wt=null,Kt=null,ln(!1),xt(a,Re(t),"b")),be(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let wr=()=>{var o,i;c("editor_closed"),s(),window.removeEventListener("pagehide",s),r&&clearTimeout(r),kt(),zt(),document.removeEventListener("mousemove",Qn,!0),document.removeEventListener("click",no,!0),document.removeEventListener("keydown",to,!0),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),mt(document),(o=document.getElementById(_n))==null||o.remove(),m.remove(),x.remove(),y.remove(),Be.remove(),window.__sentientEditor=null,(i=document.querySelector("meta[data-sentient-editor]"))==null||i.remove(),Mt()},gn=!1;_e.onclick=()=>{if((nt||Fe)&&!gn){gn=!0,T("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}wr()},document.addEventListener("mousemove",Qn,!0),document.addEventListener("click",no,!0),document.addEventListener("keydown",to,!0),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),Nt(),c("editor_opened")}var Li="http://www.w3.org/2000/svg";function Qe(e,t){let n=document.createElementNS(Li,e);for(let[r,s]of Object.entries(t))n.setAttribute(r,s);return n}function Ai(e){let t=Qe("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),n={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return t.append(Qe("path",K({d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6"},n)),Qe("path",K({d:"M10 22H17"},n)),Qe("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),t}function An(e,t){let n=d("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});n.setAttribute("aria-label",t),n.title=t;let r=Qe("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),s={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?r.append(Qe("path",K({d:"M3 7h8"},s))):r.append(Qe("path",K({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},s))),n.append(r),n.onmouseenter=()=>{n.style.background="rgba(255,255,255,0.1)",n.style.color="#fff"},n.onmouseleave=()=>{n.style.background="transparent",n.style.color="#9ca3af"},n}function F(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 nn="sentient-preview-bar";async function _i(e,t){var y,$,L,D,E,z,J,Z,U,X,ne,Q;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 n=null;try{let M=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});M.ok&&(n=($=((y=(await M.json()).slots)!=null?y:[]).find(ie=>ie.slot_id===t&&ie.kind==="arms"))!=null?$:null)}catch(M){}let r=d("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)"});r.id=nn;let s=d("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");s.onclick=()=>{Mt();let M=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])M.searchParams.delete(re);location.assign(M.toString())};let c=d("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");c.onclick=()=>{let M=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])M.searchParams.delete(re);location.assign(M.toString())};let m=(z=(E=(L=n==null?void 0:n.draft_config)==null?void 0:L.arms)!=null?E:(D=n==null?void 0:n.published_config)==null?void 0:D.arms)!=null?z:[];if(!n||m.length===0){r.append(d("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),c,s),((J=document.body)!=null?J:document.documentElement).append(r);return}let x=new URLSearchParams(location.search).get("sentient_arm"),g=(U=(Z=m.find(M=>M.id===x))!=null?Z:m[1])!=null?U:m[0];r.append(d("span",{fontWeight:"700"},`Previewing: ${(X=n.display_name)!=null?X:n.slot_id}`));let k=n.target&&typeof n.target=="object"?we(n.target,document):null;if(!k)r.append(d("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{bo(k,g.ops,`preview-${n.slot_id}`,document);try{k.scrollIntoView({block:"center"})}catch(M){}for(let M of m){let re=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:M.id===g.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ne=M.displayName)!=null?ne:M.id);re.onclick=()=>{let ie=new URL(location.href);ie.searchParams.set("sentient_arm",M.id),location.assign(ie.toString())},r.append(re)}}r.append(c,s),((Q=document.body)!=null?Q:document.documentElement).append(r)}async function Ii(e,t){var y,$,L,D;let n=t.lastIndexOf("~"),r=n>0?t.slice(0,n):t,s=n>0?t.slice(n+1):"",c=d("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)"});c.id=nn;let m=d("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");m.onclick=()=>{Mt();let E=new URL(location.href);for(let z of["sentient_preview_cell","sentient_refresh_region"])E.searchParams.delete(z);location.assign(E.toString())};let x=E=>{var z;c.append(d("span",{},E),m),((z=document.body)!=null?z:document.documentElement).append(c)},g=null;try{let E=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(r)}&persona=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${e.token}`}});E.ok&&(g=await E.json())}catch(E){}if(!g)return x("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let k=g.target&&typeof g.target=="object"?we(g.target,document):null;if(!k)return x("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(g.edits!=null&&typeof g.skeletonFp=="string"&&Array.isArray(g.leafToNode)){if(No(k,g.edits,{fp:g.skeletonFp,leafToNode:g.leafToNode})==="mismatch")return x("This part of the page changed since this version was written \u2014 regenerate it from your dashboard.")}else if(g.compose!=null||g.blocks!=null)g.vocabulary&&Array.isArray(g.vocabulary.entries)&&ko(g.vocabulary),Co(k,{preview:(y=g.compose)!=null?y:g.blocks},"preview",document);else if(typeof g.content=="string")k.textContent=g.content;else return x("Nothing to preview in that square yet.");try{k.scrollIntoView({block:"center"})}catch(E){}c.append(d("span",{fontWeight:"700"},`Previewing: ${($=g.slotName)!=null?$:r}`),d("span",{opacity:"0.85"},`for ${(L=g.personaDisplay)!=null?L:s}${g.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),m),((D=document.body)!=null?D:document.documentElement).append(c)}async function Jo(e,t){var c;let n=await ft(e,"/v1/editor/slots"),r=((c=n==null?void 0:n.slots)!=null?c:[]).filter(m=>t?m.slot_id===t:m.region_skeleton_status==null),s=r.length===0&&t?"missing":"none";for(let m of r){let x=m.target&&typeof m.target=="object"?we(m.target,document):null;if(!x){t&&(s="missing");continue}let g=Mo(x),k=g.skeleton?{slotId:m.slot_id,skeleton:g.skeleton}:{slotId:m.slot_id,status:g.reason};s=(await ce(e,"/v1/editor/region-skeleton",k)).r==="ok"?"ok":"failed"}return s}async function Xo(e){try{await ce(e,"/v1/editor/style-vocabulary",zo(document))}catch(t){}}async function $i(){if(typeof document=="undefined")return;let e=hi();if(!e)return;if(e.code){let x=await er(e);if(x!==200){Qt(x===401?Vo:Yo);return}}let t=await yi(e);if(!t.ok){t.unauthorized?(Mt(),Qt(Vo)):Qt(Yo);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(nn)||await _i(e,n);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(nn)||await Ii(e,r),Xo(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let x=await Jo(e,s);Qt(x==="ok"?"Region refreshed \u2014 you can regenerate its versions now.":x==="missing"?"We couldn\u2019t find that part of the page here. It may live on another page.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.");return}if(document.getElementById(gt))return;ir(e);let c=Uo(document);Ze=c,c&&ce(e,"/v1/editor/palette",c),Xo(e),Jo(e).catch(()=>{});let m=await xi(e);tr(m),nr(m,document)}$i();return _r(Bi);})();