@sentientui/snippet 0.17.2 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ page is left exactly as it was.
30
30
  };
31
31
  </script>
32
32
  <script
33
- src="https://unpkg.com/@sentientui/snippet@0.11.4/dist/snippet.global.js"
33
+ src="https://unpkg.com/@sentientui/snippet@0.17.2/dist/snippet.global.js"
34
34
  defer
35
35
  crossorigin="anonymous"
36
36
  ></script>
@@ -67,4 +67,4 @@ signals by default — that's what builds audience profiles with zero tagging. A
67
67
  `sectionCapture: false` to `window.sentient` to turn it off; it never runs for a Do-Not-Track,
68
68
  Global Privacy Control, or consent-gated visitor.
69
69
 
70
- Bundle ≤ 20 KiB gzip (CI-enforced). MIT.
70
+ Bundle ≤ 21 KiB gzip (CI-enforced). MIT.
@@ -1,5 +1,5 @@
1
- "use strict";var SentientSnippet=(()=>{var Lt=Object.defineProperty,Ee=Object.defineProperties,we=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertyNames,Jt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Xt=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t)=>{for(var n in t||(t={}))Zt.call(t,n)&&Xt(e,n,t[n]);if(Jt)for(var n of Jt(t))Ce.call(t,n)&&Xt(e,n,t[n]);return e},V=(e,t)=>Ee(e,Se(t));var Te=(e,t)=>{for(var n in t)Lt(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Le(t))!Zt.call(e,s)&&s!==n&&Lt(e,s,{get:()=>t[s],enumerable:!(o=we(t,s))||o.enumerable});return e};var $e=e=>Be(Lt({},"__esModule",{value:!0}),e);var on={};Te(on,{buildStyleOps:()=>fe,clearTargetHighlights:()=>yt,computeMoveAnchors:()=>_t,deriveSlotId:()=>ht,drawTargetHighlights:()=>ce,mount:()=>ge,styleFieldError:()=>pe});function Ae(e){var n,o,s;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function _e(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let o=((n=e.textContent)!=null?n:"").trim().toLowerCase(),s=t.text.trim().toLowerCase();if(!(o===s||o.startsWith(s)||s.startsWith(o)))return!1}return!0}var Re=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function et(e,t){var s;if(e.urlMatch&&!Ae(t).includes(e.urlMatch))return null;let n=[];if(e.id){let d=t.getElementById(e.id);n=d?[d]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Re.test(e.dataAttr.name))try{let d=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${d}"]`))}catch(d){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(d){n=[]}if(n.length!==1)return null;let o=n[0];return e.fingerprint&&!_e(o,e.fingerprint)?null:o}function Kt(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let o=0;o<e.length;o++){let s=e[o],d=s>="0"&&s<="9";o===0&&d||o===1&&d&&e[0]==="-"?n+=`\\3${s} `:o===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function Ie(e,t){if(e.id)return`#${Kt(e.id)}`;let n=[],o=e,s=0;for(;o&&o!==t.body&&o!==t.documentElement&&s<6;){if(o.id){n.unshift(`#${Kt(o.id)}`);break}let d=o.tagName.toLowerCase(),f=o.parentElement;if(f){let v=Array.from(f.children).filter(m=>m.tagName===o.tagName);v.length>1&&(d+=`:nth-of-type(${v.indexOf(o)+1})`)}n.unshift(d),o=o.parentElement,s++}return n.join(" > ")}function mt(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let d of["data-framer-name","data-w-id","data-sentient-name"]){let f=e.getAttribute(d);if(f){n.dataAttr={name:d,value:f};break}}n.selector=Ie(e,t);let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=F({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function Ct(e,t,n){return et(e,n)===t}var Me="__snt_editor_token";function Tt(){try{sessionStorage.removeItem(Me)}catch(e){}}var Pe=/rgba\([^)]*,\s*0\s*\)$/,He=/^\d+(\.\d+)?px$/;function Qt(e){var t,n;try{let o=e.defaultView;if(!o||!e.body)return null;let s=o.getComputedStyle(e.body).backgroundColor,d=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),f=new Map;for(let I of Array.from(d).slice(0,300)){let _=I.getBoundingClientRect();if(_.width>0&&(_.width<48||_.height<24))continue;let M=o.getComputedStyle(I),L=M.backgroundColor;if(!L||L==="transparent"||L===s||Pe.test(L))continue;let P=(t=(M.borderRadius||"").split(" ")[0])!=null?t:"",H=`${L}|${M.color}|${He.test(P)?P:"8px"}`;f.set(H,((n=f.get(H))!=null?n:0)+1)}let v=null,m=0;for(let[I,_]of f)_>m&&(v=I,m=_);if(!v)return null;let[z,B,G]=v.split("|");return{primaryBg:z,primaryText:B,radius:G}}catch(o){return null}}var te={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"},Oe=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Bt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Oe.test((t=n[1])!=null?t:""))return!1;return!0}var ee=/^https:\/\//i,ne=new Map,J=null;function ze(e){return e.replace(/["\\]/g,"\\$&")}function Ne(e){var t;(!J||!J.isConnected)&&(J=e.querySelector("style[data-sentient-ops]"),J||(J=e.createElement("style"),J.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(J))),J.textContent=[...ne.entries()].map(([n,o])=>`[data-snt-e="${ze(n)}"]{${o}}`).join(`
2
- `)}function oe(e,t,n,o){var v;let s=!1,d=(v=t.moveBefore)!=null?v:t.moveAfter;if(d){let m=et(d,o);!m||m===e||m.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,m):e.parentElement.insertBefore(e,m.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&ee.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&ee.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let f=[];if(t.hidden&&f.push("display:none !important"),t.style)for(let[m,z]of Object.entries(t.style)){let B=te[m];B&&typeof z=="string"&&Bt(z)&&f.push(`${B}:${z.trim()} !important`)}return f.length>0&&(e.setAttribute("data-snt-e",n),ne.set(n,f.join(";")),Ne(o)),{anchorMiss:s}}function Ht(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Ot(e,t){return e.steps.map(n=>{var o;return{value:n.step_index,label:`${n.step_index+1}. ${(o=t.get(n.goal_id))!=null?o:n.goal_id}`}})}function re(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function ie(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:Fe(n),body:{displayName:n.slice(0,128),steps:t.map(o=>({goalId:o}))}}:{ok:!1,error:"Give the funnel a name."}}function le(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 At(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function ht(e,t,n){var v,m;let o=t.id||((v=t.dataAttr)==null?void 0:v.value)||((m=n.textContent)!=null?m:"").trim()||n.tagName,s=At(o)||"el",d=le(JSON.stringify(t));return`${e}-${s}-${d}`.slice(0,128)}var De="sentient-editor-highlight",je="sentient-editor-selection",st="sentient-editor-panel",Rt="sentient-editor-toast",se="sentient-editor-styles",zt="sentient-editor-target-highlight",Ge=10,Ue="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",We="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function de(){var t;if(document.getElementById(se))return;let e=document.createElement("style");e.id=se,e.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var Lt=Object.defineProperty,Ee=Object.defineProperties,we=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertyNames,Jt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Xt=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t)=>{for(var n in t||(t={}))Zt.call(t,n)&&Xt(e,n,t[n]);if(Jt)for(var n of Jt(t))Ce.call(t,n)&&Xt(e,n,t[n]);return e},V=(e,t)=>Ee(e,Se(t));var Te=(e,t)=>{for(var n in t)Lt(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Le(t))!Zt.call(e,s)&&s!==n&&Lt(e,s,{get:()=>t[s],enumerable:!(o=we(t,s))||o.enumerable});return e};var $e=e=>Be(Lt({},"__esModule",{value:!0}),e);var on={};Te(on,{buildStyleOps:()=>fe,clearTargetHighlights:()=>yt,computeMoveAnchors:()=>It,deriveSlotId:()=>ht,drawTargetHighlights:()=>de,mount:()=>ge,styleFieldError:()=>pe});function Ae(e){var n,o,s;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function _e(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let o=((n=e.textContent)!=null?n:"").trim().toLowerCase(),s=t.text.trim().toLowerCase();if(!(o===s||o.startsWith(s)||s.startsWith(o)))return!1}return!0}var Re=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function et(e,t){var s;if(e.urlMatch&&!Ae(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Re.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let o=n[0];return e.fingerprint&&!_e(o,e.fingerprint)?null:o}function Kt(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let o=0;o<e.length;o++){let s=e[o],c=s>="0"&&s<="9";o===0&&c||o===1&&c&&e[0]==="-"?n+=`\\3${s} `:o===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function Ie(e,t){if(e.id)return`#${Kt(e.id)}`;let n=[],o=e,s=0;for(;o&&o!==t.body&&o!==t.documentElement&&s<6;){if(o.id){n.unshift(`#${Kt(o.id)}`);break}let c=o.tagName.toLowerCase(),f=o.parentElement;if(f){let E=Array.from(f.children).filter(y=>y.tagName===o.tagName);E.length>1&&(c+=`:nth-of-type(${E.indexOf(o)+1})`)}n.unshift(c),o=o.parentElement,s++}return n.join(" > ")}function mt(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 f=e.getAttribute(c);if(f){n.dataAttr={name:c,value:f};break}}n.selector=Ie(e,t);let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=D({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function Ct(e,t,n){return et(e,n)===t}var Me="__snt_editor_token";function Tt(){try{sessionStorage.removeItem(Me)}catch(e){}}var Pe=/rgba\([^)]*,\s*0\s*\)$/,He=/^\d+(\.\d+)?px$/;function Qt(e){var t,n;try{let o=e.defaultView;if(!o||!e.body)return null;let s=o.getComputedStyle(e.body).backgroundColor,c=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),f=new Map;for(let M of Array.from(c).slice(0,300)){let _=M.getBoundingClientRect();if(_.width>0&&(_.width<48||_.height<24))continue;let P=o.getComputedStyle(M),T=P.backgroundColor;if(!T||T==="transparent"||T===s||Pe.test(T))continue;let H=(t=(P.borderRadius||"").split(" ")[0])!=null?t:"",O=`${T}|${P.color}|${He.test(H)?H:"8px"}`;f.set(O,((n=f.get(O))!=null?n:0)+1)}let E=null,y=0;for(let[M,_]of f)_>y&&(E=M,y=_);if(!E)return null;let[N,B,G]=E.split("|");return{primaryBg:N,primaryText:B,radius:G}}catch(o){return null}}var te={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"},Oe=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Bt(e){var o;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Oe.test((o=n[1])!=null?o:""))return!1;return!0}var ee=/^https:\/\//i,ne=new Map,J=null;function ze(e){return e.replace(/["\\]/g,"\\$&")}function Ne(e){var t;(!J||!J.isConnected)&&(J=e.querySelector("style[data-sentient-ops]"),J||(J=e.createElement("style"),J.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(J))),J.textContent=[...ne.entries()].map(([n,o])=>`[data-snt-e="${ze(n)}"]{${o}}`).join(`
2
+ `)}function oe(e,t,n,o){var E;let s=!1,c=(E=t.moveBefore)!=null?E:t.moveAfter;if(c){let y=et(c,o);!y||y===e||y.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,y):e.parentElement.insertBefore(e,y.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&ee.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&ee.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let f=[];if(t.hidden&&f.push("display:none !important"),t.style)for(let[y,N]of Object.entries(t.style)){let B=te[y];B&&typeof N=="string"&&Bt(N)&&f.push(`${B}:${N.trim()} !important`)}return f.length>0&&(e.setAttribute("data-snt-e",n),ne.set(n,f.join(";")),Ne(o)),{anchorMiss:s}}function $t(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function At(e,t){return e.steps.map(n=>{var o;return{value:n.step_index,label:`${n.step_index+1}. ${(o=t.get(n.goal_id))!=null?o:n.goal_id}`}})}function re(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function ie(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:Fe(n),body:{displayName:n.slice(0,128),steps:t.map(o=>({goalId:o}))}}:{ok:!1,error:"Give the funnel a name."}}function le(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 Rt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function ht(e,t,n){var E,y;let o=t.id||((E=t.dataAttr)==null?void 0:E.value)||((y=n.textContent)!=null?y:"").trim()||n.tagName,s=Rt(o)||"el",c=le(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var De="sentient-editor-highlight",je="sentient-editor-selection",st="sentient-editor-panel",Mt="sentient-editor-toast",se="sentient-editor-styles",zt="sentient-editor-target-highlight",Ge=10,Ue="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",qe="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function ce(){var t;if(document.getElementById(se))return;let e=document.createElement("style");e.id=se,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); }
@@ -17,8 +17,8 @@
17
17
  sntedi-attn 1.7s ease-in-out 0.42s 3;
18
18
  }
19
19
  #${st} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
- #${Rt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
20
+ #${Mt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
21
21
  @media (prefers-reduced-motion: reduce) {
22
- #${st}, #${st} .sntedi-dot, #${Rt} { animation: none !important; }
22
+ #${st}, #${st} .sntedi-dot, #${Mt} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function ae(e){var o,s;de(),(o=document.getElementById(Rt))==null||o.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Rt;let n=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,a("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function qe(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Ye(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}}}async function O(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?"ok":o.status===401?"expired":"error"}catch(o){return"error"}}async function Ve(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await o.json().catch(()=>null);return o.ok?{r:"ok",data:s}:{r:o.status===401?"expired":"error",data:s}}catch(o){return{r:"error",data:null}}}var Nt=[];async function Je(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 Nt=Array.isArray(n.fonts)?n.fonts.filter(o=>typeof o=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function $t(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 yt(e=document){for(let t of Array.from(e.querySelectorAll(`.${zt}`)))t.remove()}function ce(e,t=document){var o;yt(t);let n=0;for(let s of e){if(n>=Ge)break;let d=et(s.locator,t);if(!d)continue;let f=d.getBoundingClientRect(),v=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});v.className=zt;let m=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${Math.max(0,f.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);m.className=zt,((o=t.body)!=null?o:t.documentElement).append(v,m),n+=1}}function _t(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,s=n?mt(n,t):null,d=o?mt(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&s&&Ct(s,n,t)?s:null,nextLocator:o&&d&&Ct(d,o,t)?d:null}}var ue=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Xe=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Ze=new Set(["left","center","right","justify","start","end"]),Ke=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Qe=/^(rgb|rgba|hsl|hsla)\(/i;function tn(e){return Ke.test(e)||Qe.test(e)}function pe(e,t){switch(e){case"fontSize":case"borderRadius":return Xe.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 Ze.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return tn(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(o=>o.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(o=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(o))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function fe(e){let t={},n={};for(let o of ue){let s=e[o];if(typeof s!="string")continue;let d=s.trim();if(d==="")continue;if(!Bt(d)){n[o]="That value isn\u2019t allowed.";continue}let f=pe(o,d);if(f){n[o]=f;continue}t[o]=d}return{style:t,errors:n}}function a(e,t,n){let o=document.createElement(e);return Object.assign(o.style,t),n!==void 0&&(o.textContent=n),o}function ge(e){var Vt;let t=null,n=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=De;let o=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});o.id=je;let s=()=>{if(!t||!t.isConnected){o.style.display="none";return}let r=t.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${r.left-2}px`,top:`${r.top-2}px`,width:`${r.width}px`,height:`${r.height}px`})},d=()=>s();de();let f=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",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)"});f.id=st;let v=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});v.className="sntedi-dot";let m=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});m.append(v,a("span",{},"SentientUI editor"));let z=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),B=!1,G=a("button",h("#374151"),"Pause selecting");G.onclick=()=>{B=!B,G.textContent=B?"Resume selecting":"Pause selecting",B?(n.style.display="none",yt(document),c("Selection paused \u2014 browse normally, then resume.")):c("Click any element on the page to adapt it.")};let I=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),_=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),M=r=>a("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),L=a("button",h("#6366f1"),"Test different text here"),P=a("button",h("#374151"),"Change style"),H=a("button",h("#374151"),"Try a different arrangement"),U=a("button",h("#374151"),"Track clicks as a goal"),W=a("button",h("#374151"),"Track form submissions as a goal"),at=a("button",h("#374151"),"Track page visits as a goal"),S=a("button",h("#374151"),"Track reading this far as a goal"),q=a("button",h("#374151"),"Set up a funnel"),N=a("button",h("#374151"),"Attach this test to a funnel step"),X=a("button",h("#10b981"),"Turn the funnel on"),Z=a("button",h("#374151"),"Move up"),K=a("button",h("#374151"),"Move down"),bt=a("button",h("#6366f1"),"Save this arrangement"),xt=a("button",h("#374151"),"Undo"),Ft=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Close editor"),Q=a("button",h("#10b981"),"Publish now \u2014 go live"),tt=a("button",h("#10b981"),"Start tracking now");for(let r of[L,P,H,U,Z,K])r.disabled=!0;let Dt=[L,P,H,U,W,Z,K];for(let r of Dt)r.style.display="none";bt.style.display="none",xt.style.display="none",Q.style.display="none",tt.style.display="none",N.style.display="none",X.style.display="none",f.append(m,z,G,I,_,M("Content & style"),L,P,H,M("Track a goal"),U,W,at,S,M("Funnels"),q,N,X,M("Move"),Z,K,bt,xt,Q,tt,Ft),((Vt=document.body)!=null?Vt:document.documentElement).append(n,o,f);let $=a("div",{marginTop:"10px"});f.append($);let R=()=>{$.textContent=""},lt=(r,i,l)=>{var T;R();let p={},u={},g={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let b of r){let x=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},b.label);if($.append(x),b.type==="select"){let E=a("select",g);E.setAttribute("data-field",b.key);let j=document.createElement("option");j.value="",j.textContent="\u2014 no change \u2014",E.append(j);for(let rt of(T=b.options)!=null?T:[]){let it=document.createElement("option");it.value=rt,it.textContent=rt,E.append(it)}p[b.key]=()=>E.value,$.append(E)}else if(b.type==="color"){let E=a("input",V(F({},g),{padding:"2px",height:"34px"}));E.type="color",E.setAttribute("data-field",b.key);let j=!1;E.addEventListener("input",()=>{j=!0}),p[b.key]=()=>j?E.value:"",$.append(E)}else{let E=a("input",g);E.setAttribute("data-field",b.key),b.value!==void 0&&(E.value=b.value),p[b.key]=()=>E.value,$.append(E)}let k=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});k.setAttribute("data-feedback",b.key),u[b.key]=k,$.append(k)}let w=(b,x)=>{let k=u[b];k&&(k.textContent=x!=null?x:"",k.style.display=x?"block":"none")},y=a("button",h("#6366f1"),i),C=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");y.onclick=()=>l(Object.fromEntries(Object.entries(p).map(([b,x])=>[b,x()])),w),C.onclick=R,$.append(y,C)},c=(r,i=!0)=>{_.textContent=r,_.style.color=i?"#a7f3d0":"#fca5a5"},Y=(r,i)=>{r==="ok"?c(i,!0):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},dt=null,vt=r=>{dt=r,Q.style.display="block",N.style.display="block"};Q.onclick=async()=>{if(!dt)return;Q.disabled=!0,c("Publishing\u2026");let r=await O(e,`/v1/editor/slots/${encodeURIComponent(dt)}/publish`,{});Q.disabled=!1,r==="ok"?(c("\u2713 Published \u2014 live for new visitors.",!0),Q.style.display="none",dt=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let A=null,ct=!1,ut=null,pt=null,D=null,nt=null,ft=null,kt=null,ot=!1,jt=(r,i)=>ct?r?"":`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.",Gt=()=>{Z.disabled=!ct||!D,K.disabled=!ct||!nt,Z.title=Z.disabled?jt(D,"above"):"",K.title=K.disabled?jt(nt,"below"):""},It=r=>{bt.style.display=r?"block":"none",xt.style.display=r?"block":"none",Gt()},Ut=()=>{if(ot&&t&&ft&&ft.insertBefore(t,kt),ot=!1,ft=null,kt=null,t){let r=_t(t,document);ut=r.prevEl,pt=r.nextEl,D=r.prevLocator,nt=r.nextLocator}s(),It(!1)},Wt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i)||i===n)return;yt(document);let l=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${l.left}px`,top:`${l.top}px`,width:`${l.width}px`,height:`${l.height}px`})},he=r=>{var l;let i=((l=r.textContent)!=null?l:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:r.tagName.toLowerCase()},qt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i))return;r.preventDefault(),r.stopPropagation(),Ut(),R(),t=i,A=mt(i,document);let l=Ct(A,i,document);ct=l,s(),I.style.display="block",I.textContent=`Selected: ${he(i)}`,c(l?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",l);for(let w of Dt)w.style.display="block";let p=i.childElementCount===0;L.disabled=!l||!p,L.title=l?p?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",P.disabled=!l,H.disabled=!l,U.disabled=!l;let u=i.closest("form");W.style.display=u?"block":"none",W.disabled=!u;let g=_t(i,document);ut=g.prevEl,pt=g.nextEl,D=g.prevLocator,nt=g.nextLocator,Gt()};L.onclick=()=>{var l,p;if(!t||!A)return;let r=A,i=(p=(l=t.textContent)==null?void 0:l.trim())!=null?p:"";lt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async u=>{let g=u.alt.trim();if(!g){c("\u26A0 Enter alternative wording to test.",!1);return}if(g===u.current.trim()){c("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let w=ht("text",r,t);c("Saving\u2026");let y=await O(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:u.current}},{id:"b",displayName:"Alternative",ops:{text:u.alt}}]}});y==="ok"&&(R(),vt(w)),Y(y,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let gt=null,ye=(r,i,l)=>{lt(r.fields.map(p=>{var u;return{key:p.id,label:p.kind==="href"?`${p.label} (link \u2014 required)`:p.label,value:(u=p.default)!=null?u:""}}),"Save draft",async p=>{var y,C,T;c("Saving\u2026");let u=await Ve(e,`/v1/editor/arrangements/${encodeURIComponent(r.id)}/instantiate`,{fields:p});if(u.r!=="ok"||!((y=u.data)!=null&&y.blocks)){u.r==="expired"?Y("expired",""):c(`\u26A0 ${(T=(C=u.data)==null?void 0:C.reason)!=null?T:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let g=ht("arrange",i,l),w=await O(e,`/v1/editor/slots/${encodeURIComponent(g)}`,{kind:"arms",target:i,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:r.id,displayName:r.name,blocks:u.data.blocks}],baseline:"original"}});w==="ok"&&(R(),vt(g)),Y(w,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish now\u201D to go live.")})};H.onclick=async()=>{var p;if(!t||!A)return;let r=A,i=t;if(R(),c("Loading arrangements\u2026"),!gt){let u=await $t(e,"/v1/editor/arrangements");gt=(p=u==null?void 0:u.arrangements)!=null?p:null}if(!gt||gt.length===0){c("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}c("Pick an arrangement to test against this section.");for(let u of gt){let g=a("button",V(F({},h("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},u.name),a("div",{fontSize:"11px",opacity:"0.7"},u.description)),g.onclick=()=>ye(u,r,i),$.append(g)}let l=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");l.onclick=R,$.append(l)};let Et=null,be=r=>{Et=r,tt.style.display="block"};tt.onclick=async()=>{if(!Et)return;tt.disabled=!0,c("Activating\u2026");let r=await O(e,`/v1/editor/goals/${encodeURIComponent(Et)}/publish`,{});tt.disabled=!1,r==="ok"?(c("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),tt.style.display="none",Et=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let Mt=(r,i)=>`${At(r)||"goal"}-${le(i)}`.slice(0,128),wt=async(r,i)=>{c("Saving\u2026");let l=await O(e,`/v1/editor/goals/${encodeURIComponent(r)}`,i);l==="ok"&&be(r),Y(l,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};U.onclick=()=>{var i;if(!t||!A)return;let r=Mt(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(A));wt(r,{event:"click",locator:A})},W.onclick=()=>{var p,u;let r=t==null?void 0:t.closest("form");if(!r)return;let i=mt(r,document),l=(u=(p=r.getAttribute("id"))!=null?p:r.getAttribute("name"))!=null?u:"form-submitted";wt(Mt(l,JSON.stringify(i)),{event:"form_submit",locator:i})},at.onclick=()=>{let r=window.location.pathname||"/",i=At(r)?`reached-${At(r)}`:"page-visited";wt(Mt(i,r),{event:"url_reached",urlPattern:r})};let Pt=[{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}];S.onclick=()=>{lt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Pt.map(r=>r.label)}],"Track it",r=>{var p;let i=(p=Pt.find(u=>u.label===r.depth))!=null?p:Pt[2],l=Math.round(i.value*100);wt(`read-${l}pct`,{event:"scroll_depth",threshold:i.value}),R()})};let St=null,xe=r=>{St=r,X.style.display="block"};X.onclick=async()=>{if(!St)return;X.disabled=!0,c("Turning on\u2026");let r=await O(e,`/v1/editor/funnels/${encodeURIComponent(St)}/publish`,{});X.disabled=!1,r==="ok"?(c("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),X.style.display="none",St=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.":"\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},q.onclick=async()=>{var b;c("Loading your goals\u2026");let r=await $t(e,"/v1/editor/goals"),i=(b=r==null?void 0:r.goals)!=null?b:[];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."),R();let l=[],p=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});$.append(p,u);let g=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");$.append(g);let w=new Map,y=()=>{var x,k;for(let[E,j]of w){let rt=l.indexOf(E),it=(k=(x=i.find(ke=>ke.goal_id===E))==null?void 0:x.display_name)!=null?k:E;j.textContent=rt===-1?it:`${rt+1}. ${it}`,j.style.background=rt===-1?"#374151":"#6366f1"}};for(let x of i){let k=a("button",V(F({},h("#374151")),{textAlign:"left"}));w.set(x.goal_id,k),k.onclick=()=>{l=re(l,x.goal_id),y()},$.append(k)}y();let C=a("button",h("#6366f1"),"Save funnel"),T=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");T.onclick=R,C.onclick=async()=>{let x=ie(u.value,l);if(!x.ok){c(`\u26A0 ${x.error}`,!1);return}c("Saving\u2026");let k=await O(e,`/v1/editor/funnels/${encodeURIComponent(x.funnelId)}`,x.body);k==="ok"&&(R(),xe(x.funnelId)),Y(k,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},$.append(C,T)},N.onclick=async()=>{var g,w;let r=dt;if(!r)return;c("Loading funnels\u2026");let i=await $t(e,"/v1/editor/funnels"),l=(g=i==null?void 0:i.funnels)!=null?g:[];if(l.length===0){c("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let p=await $t(e,"/v1/editor/goals"),u=new Map(((w=p==null?void 0:p.goals)!=null?w:[]).map(y=>[y.goal_id,y.display_name]));lt([{key:"funnel",label:"Funnel",type:"select",options:l.map(y=>Ht(y))},{key:"step",label:"Which step does this element serve?",type:"select",options:Ot(l[0],u).map(y=>y.label)}],"Attach",async y=>{var x;let C=(x=l.find(k=>Ht(k)===y.funnel))!=null?x:l[0],T=Ot(C,u).findIndex(k=>k.label===y.step);c("Attaching\u2026");let b=await O(e,`/v1/editor/funnels/${encodeURIComponent(C.funnel_id)}/assign`,{slotId:r,stepIndex:T>=0?T:null});b==="ok"&&R(),Y(b,`\u2713 Attached \u2014 this test now works toward \u201C${C.display_name}\u201D.`)})},P.onclick=()=>{if(!t||!A)return;let r=A;lt([{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:Nt.length?`Font (this site has: ${Nt.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(i,l)=>{var C;let{style:p,errors:u}=fe(i),g=!1;for(let T of ue)l(T,(C=u[T])!=null?C:null),u[T]&&(g=!0);if(g){c("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(p).length===0){c("\u26A0 Enter at least one style change.",!1);return}let w=ht("style",r,t);c("Saving\u2026");let y=await O(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:p}}]}});y==="ok"&&(R(),vt(w)),Y(y,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Yt=r=>{if(!t)return;let i=t.parentElement;if(!i)return;ot||(ft=i,kt=t.nextSibling,ot=!0),r==="up"&&ut?i.insertBefore(t,ut):r==="down"&&pt&&i.insertBefore(t,pt.nextSibling);let l=_t(t,document);ut=l.prevEl,pt=l.nextEl,D=l.prevLocator,nt=l.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),It(!0),c("Previewing the new position \u2014 keep moving, save, or undo.")};Z.onclick=()=>Yt("up"),K.onclick=()=>Yt("down"),xt.onclick=()=>{Ut(),c("Move undone \u2014 back to the original position.")},bt.onclick=async()=>{if(!t||!A||!ot||!ct)return;let r=D?"moveAfter":"moveBefore",i=D!=null?D:nt;if(!i){c("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let l=ht("move",A,t);c("Saving\u2026");let p=await O(e,`/v1/editor/slots/${encodeURIComponent(l)}`,{kind:"arms",target:A,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:i}}]}});p==="ok"&&(ot=!1,ft=null,kt=null,It(!1),vt(l)),Y(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let ve=()=>{var r;document.removeEventListener("mousemove",Wt,!0),document.removeEventListener("click",qt,!0),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d),yt(document),n.remove(),o.remove(),f.remove(),window.__sentientEditor=null,(r=document.querySelector("meta[data-sentient-editor]"))==null||r.remove(),Tt()};Ft.onclick=ve,document.addEventListener("mousemove",Wt,!0),document.addEventListener("click",qt,!0),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d)}function h(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 me="sentient-preview-bar";async function en(e,t){var z,B,G,I,_,M,L,P,H,U,W,at;let n=null;try{let S=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(n=(B=((z=(await S.json()).slots)!=null?z:[]).find(N=>N.slot_id===t&&N.kind==="arms"))!=null?B:null)}catch(S){}let o=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});o.id=me;let s=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{Tt();let S=new URL(location.href);for(let q of["sentient_editor","sentient_preview","sentient_arm"])S.searchParams.delete(q);location.assign(S.toString())};let d=(M=(_=(G=n==null?void 0:n.draft_config)==null?void 0:G.arms)!=null?_:(I=n==null?void 0:n.published_config)==null?void 0:I.arms)!=null?M:[];if(!n||d.length===0){o.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),s),((L=document.body)!=null?L:document.documentElement).append(o);return}let f=new URLSearchParams(location.search).get("sentient_arm"),v=(H=(P=d.find(S=>S.id===f))!=null?P:d[1])!=null?H:d[0];o.append(a("span",{fontWeight:"700"},`Previewing: ${(U=n.display_name)!=null?U:n.slot_id}`));let m=n.target&&typeof n.target=="object"?et(n.target,document):null;if(!m)o.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{oe(m,v.ops,`preview-${n.slot_id}`,document);try{m.scrollIntoView({block:"center"})}catch(S){}for(let S of d){let q=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:S.id===v.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(W=S.displayName)!=null?W:S.id);q.onclick=()=>{let N=new URL(location.href);N.searchParams.set("sentient_arm",S.id),location.assign(N.toString())},o.append(q)}}o.append(s),((at=document.body)!=null?at:document.documentElement).append(o)}async function nn(){if(typeof document=="undefined")return;let e=qe();if(!e)return;let t=await Ye(e);if(!t.ok){t.unauthorized?(Tt(),ae(Ue)):ae(We);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(me)||await en(e,n);return}if(document.getElementById(st))return;ge(e);let o=Qt(document);o&&O(e,"/v1/editor/palette",o);let s=await Je(e);ce(s,document)}nn();return $e(on);})();
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function ae(e){var o,s;ce(),(o=document.getElementById(Mt))==null||o.remove();let t=l("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=Mt;let n=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,l("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function We(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Ye(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}}}async function z(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?"ok":o.status===401?"expired":"error"}catch(o){return"error"}}async function Ve(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await o.json().catch(()=>null);return o.ok?{r:"ok",data:s}:{r:o.status===401?"expired":"error",data:s}}catch(o){return{r:"error",data:null}}}var Nt=[];async function Je(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 Nt=Array.isArray(n.fonts)?n.fonts.filter(o=>typeof o=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function _t(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 yt(e=document){for(let t of Array.from(e.querySelectorAll(`.${zt}`)))t.remove()}function de(e,t=document){var o;yt(t);let n=0;for(let s of e){if(n>=Ge)break;let c=et(s.locator,t);if(!c)continue;let f=c.getBoundingClientRect(),E=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});E.className=zt;let y=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${Math.max(0,f.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);y.className=zt,((o=t.body)!=null?o:t.documentElement).append(E,y),n+=1}}function It(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,s=n?mt(n,t):null,c=o?mt(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&s&&Ct(s,n,t)?s:null,nextLocator:o&&c&&Ct(c,o,t)?c:null}}var ue=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Xe=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Ze=new Set(["left","center","right","justify","start","end"]),Ke=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Qe=/^(rgb|rgba|hsl|hsla)\(/i;function tn(e){return Ke.test(e)||Qe.test(e)}function pe(e,t){switch(e){case"fontSize":case"borderRadius":return Xe.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 Ze.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return tn(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(o=>o.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(o=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(o))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function fe(e){let t={},n={};for(let o of ue){let s=e[o];if(typeof s!="string")continue;let c=s.trim();if(c==="")continue;if(!Bt(c)){n[o]="That value isn\u2019t allowed.";continue}let f=pe(o,c);if(f){n[o]=f;continue}t[o]=c}return{style:t,errors:n}}function l(e,t,n){let o=document.createElement(e);return Object.assign(o.style,t),n!==void 0&&(o.textContent=n),o}function ge(e){var Vt;let t=null,n=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=De;let o=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});o.id=je;let s=()=>{if(!t||!t.isConnected){o.style.display="none";return}let r=t.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${r.left-2}px`,top:`${r.top-2}px`,width:`${r.width}px`,height:`${r.height}px`})},c=()=>s();ce();let f=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",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)"});f.id=st;let E=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});E.className="sntedi-dot";let y=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});y.append(E,l("span",{},"SentientUI editor"));let N=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),B=!1,G=l("button",b("#374151"),"Pause selecting");G.onclick=()=>{B=!B,G.textContent=B?"Resume selecting":"Pause selecting",B?(n.style.display="none",yt(document),d("Selection paused \u2014 browse normally, then resume.")):d("Click any element on the page to adapt it.")};let M=l("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"}),_=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),P=r=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),T=l("button",b("#6366f1"),"Test different text here"),H=l("button",b("#374151"),"Change style"),O=l("button",b("#374151"),"Try a different arrangement"),U=l("button",b("#374151"),"Track clicks as a goal"),q=l("button",b("#374151"),"Track form submissions as a goal"),at=l("button",b("#374151"),"Track page visits as a goal"),S=l("button",b("#374151"),"Track reading this far as a goal"),W=l("button",b("#374151"),"Set up a funnel"),F=l("button",b("#374151"),"Attach this test to a funnel step"),X=l("button",b("#10b981"),"Turn the funnel on"),Z=l("button",b("#374151"),"Move up"),K=l("button",b("#374151"),"Move down"),bt=l("button",b("#6366f1"),"Save this arrangement"),xt=l("button",b("#374151"),"Undo"),Ft=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Close editor"),Q=l("button",b("#10b981"),"Publish now \u2014 go live"),tt=l("button",b("#10b981"),"Start tracking now");for(let r of[T,H,O,U,Z,K])r.disabled=!0;let Dt=[T,H,O,U,q,Z,K];for(let r of Dt)r.style.display="none";bt.style.display="none",xt.style.display="none",Q.style.display="none",tt.style.display="none",F.style.display="none",X.style.display="none",f.append(y,N,G,M,_,P("Content & style"),T,H,O,P("Track a goal"),U,q,at,S,P("Funnels"),W,F,X,P("Move"),Z,K,bt,xt,Q,tt,Ft),((Vt=document.body)!=null?Vt:document.documentElement).append(n,o,f);let C=l("div",{marginTop:"10px"});f.append(C);let R=()=>{C.textContent=""},lt=(r,i,a)=>{var x;R();let p={},u={},h={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let g of r){let m=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},g.label);if(C.append(m),g.type==="select"){let k=l("select",h);k.setAttribute("data-field",g.key);let I=document.createElement("option");I.value="",I.textContent="\u2014 no change \u2014",k.append(I);for(let rt of(x=g.options)!=null?x:[]){let it=document.createElement("option");it.value=rt,it.textContent=rt,k.append(it)}p[g.key]=()=>k.value,C.append(k)}else if(g.type==="color"){let k=l("input",V(D({},h),{padding:"2px",height:"34px"}));k.type="color",k.setAttribute("data-field",g.key);let I=!1;k.addEventListener("input",()=>{I=!0}),p[g.key]=()=>I?k.value:"",C.append(k)}else{let k=l("input",h);k.setAttribute("data-field",g.key),g.value!==void 0&&(k.value=g.value),p[g.key]=()=>k.value,C.append(k)}let v=l("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});v.setAttribute("data-feedback",g.key),u[g.key]=v,C.append(v)}let w=(g,m)=>{let v=u[g];v&&(v.textContent=m!=null?m:"",v.style.display=m?"block":"none")},L=l("button",b("#6366f1"),i),A=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");L.onclick=()=>a(Object.fromEntries(Object.entries(p).map(([g,m])=>[g,m()])),w),A.onclick=R,C.append(L,A)},d=(r,i=!0)=>{_.textContent=r,_.style.color=i?"#a7f3d0":"#fca5a5"},Y=(r,i)=>{r==="ok"?d(i,!0):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},ct=null,vt=r=>{ct=r,Q.style.display="block",F.style.display="block"};Q.onclick=async()=>{if(!ct)return;Q.disabled=!0,d("Publishing\u2026");let r=await z(e,`/v1/editor/slots/${encodeURIComponent(ct)}/publish`,{});Q.disabled=!1,r==="ok"?(d("\u2713 Published \u2014 live for new visitors.",!0),Q.style.display="none",ct=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let $=null,dt=!1,ut=null,pt=null,j=null,nt=null,ft=null,kt=null,ot=!1,jt=(r,i)=>dt?r?"":`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.",Gt=()=>{Z.disabled=!dt||!j,K.disabled=!dt||!nt,Z.title=Z.disabled?jt(j,"above"):"",K.title=K.disabled?jt(nt,"below"):""},Pt=r=>{bt.style.display=r?"block":"none",xt.style.display=r?"block":"none",Gt()},Ut=()=>{if(ot&&t&&ft&&ft.insertBefore(t,kt),ot=!1,ft=null,kt=null,t){let r=It(t,document);ut=r.prevEl,pt=r.nextEl,j=r.prevLocator,nt=r.nextLocator}s(),Pt(!1)},qt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i)||i===n)return;yt(document);let a=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},he=r=>{var a;let i=((a=r.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:r.tagName.toLowerCase()},Wt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i))return;r.preventDefault(),r.stopPropagation(),Ut(),R(),t=i,$=mt(i,document);let a=Ct($,i,document);dt=a,s(),M.style.display="block",M.textContent=`Selected: ${he(i)}`,d(a?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",a);for(let w of Dt)w.style.display="block";let p=i.childElementCount===0;T.disabled=!a||!p,T.title=a?p?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",H.disabled=!a,O.disabled=!a,U.disabled=!a;let u=i.closest("form");q.style.display=u?"block":"none",q.disabled=!u;let h=It(i,document);ut=h.prevEl,pt=h.nextEl,j=h.prevLocator,nt=h.nextLocator,Gt()};T.onclick=()=>{var a,p;if(!t||!$)return;let r=$,i=(p=(a=t.textContent)==null?void 0:a.trim())!=null?p:"";lt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async u=>{let h=u.alt.trim();if(!h){d("\u26A0 Enter alternative wording to test.",!1);return}if(h===u.current.trim()){d("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let w=ht("text",r,t);d("Saving\u2026");let L=await z(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:u.current}},{id:"b",displayName:"Alternative",ops:{text:u.alt}}]}});L==="ok"&&(R(),vt(w)),Y(L,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let gt=null,ye=(r,i,a)=>{lt(r.fields.map(p=>{var u;return{key:p.id,label:p.kind==="href"?`${p.label} (link \u2014 required)`:p.label,value:(u=p.default)!=null?u:""}}),"Save draft",async p=>{var L,A,x;d("Saving\u2026");let u=await Ve(e,`/v1/editor/arrangements/${encodeURIComponent(r.id)}/instantiate`,{fields:p});if(u.r!=="ok"||!((L=u.data)!=null&&L.blocks)){u.r==="expired"?Y("expired",""):d(`\u26A0 ${(x=(A=u.data)==null?void 0:A.reason)!=null?x:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let h=ht("arrange",i,a),w=await z(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:i,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:r.id,displayName:r.name,blocks:u.data.blocks}],baseline:"original"}});w==="ok"&&(R(),vt(h)),Y(w,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish now\u201D to go live.")})};O.onclick=async()=>{var p;if(!t||!$)return;let r=$,i=t;if(R(),d("Loading arrangements\u2026"),!gt){let u=await _t(e,"/v1/editor/arrangements");gt=(p=u==null?void 0:u.arrangements)!=null?p:null}if(!gt||gt.length===0){d("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}d("Pick an arrangement to test against this section.");for(let u of gt){let h=l("button",V(D({},b("#374151")),{textAlign:"left"}));h.append(l("div",{fontWeight:"600"},u.name),l("div",{fontSize:"11px",opacity:"0.7"},u.description)),h.onclick=()=>ye(u,r,i),C.append(h)}let a=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");a.onclick=R,C.append(a)};let Et=null,be=r=>{Et=r,tt.style.display="block"};tt.onclick=async()=>{if(!Et)return;tt.disabled=!0,d("Activating\u2026");let r=await z(e,`/v1/editor/goals/${encodeURIComponent(Et)}/publish`,{});tt.disabled=!1,r==="ok"?(d("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),tt.style.display="none",Et=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let Ht=(r,i)=>`${Rt(r)||"goal"}-${le(i)}`.slice(0,128),wt=async(r,i)=>{d("Saving\u2026");let a=await z(e,`/v1/editor/goals/${encodeURIComponent(r)}`,i);a==="ok"&&be(r),Y(a,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};U.onclick=()=>{var i;if(!t||!$)return;let r=Ht(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify($));wt(r,{event:"click",locator:$})},q.onclick=()=>{var p,u;let r=t==null?void 0:t.closest("form");if(!r)return;let i=mt(r,document),a=(u=(p=r.getAttribute("id"))!=null?p:r.getAttribute("name"))!=null?u:"form-submitted";wt(Ht(a,JSON.stringify(i)),{event:"form_submit",locator:i})},at.onclick=()=>{let r=window.location.pathname||"/",i=Rt(r)?`reached-${Rt(r)}`:"page-visited";wt(Ht(i,r),{event:"url_reached",urlPattern:r})};let Ot=[{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}];S.onclick=()=>{lt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Ot.map(r=>r.label)}],"Track it",r=>{var p;let i=(p=Ot.find(u=>u.label===r.depth))!=null?p:Ot[2],a=Math.round(i.value*100);wt(`read-${a}pct`,{event:"scroll_depth",threshold:i.value}),R()})};let St=null,xe=r=>{St=r,X.style.display="block"};X.onclick=async()=>{if(!St)return;X.disabled=!0,d("Turning on\u2026");let r=await z(e,`/v1/editor/funnels/${encodeURIComponent(St)}/publish`,{});X.disabled=!1,r==="ok"?(d("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),X.style.display="none",St=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.":"\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},W.onclick=async()=>{var g;d("Loading your goals\u2026");let r=await _t(e,"/v1/editor/goals"),i=(g=r==null?void 0:r.goals)!=null?g:[];if(i.length<2){d("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}d("Pick the steps in order \u2014 first click = first step."),R();let a=[],p=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=l("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});C.append(p,u);let h=l("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");C.append(h);let w=new Map,L=()=>{var m,v;for(let[k,I]of w){let rt=a.indexOf(k),it=(v=(m=i.find(ke=>ke.goal_id===k))==null?void 0:m.display_name)!=null?v:k;I.textContent=rt===-1?it:`${rt+1}. ${it}`,I.style.background=rt===-1?"#374151":"#6366f1"}};for(let m of i){let v=l("button",V(D({},b("#374151")),{textAlign:"left"}));w.set(m.goal_id,v),v.onclick=()=>{a=re(a,m.goal_id),L()},C.append(v)}L();let A=l("button",b("#6366f1"),"Save funnel"),x=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=R,A.onclick=async()=>{let m=ie(u.value,a);if(!m.ok){d(`\u26A0 ${m.error}`,!1);return}d("Saving\u2026");let v=await z(e,`/v1/editor/funnels/${encodeURIComponent(m.funnelId)}`,m.body);v==="ok"&&(R(),xe(m.funnelId)),Y(v,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},C.append(A,x)},F.onclick=async()=>{var L,A;let r=ct;if(!r)return;d("Loading funnels\u2026");let i=await _t(e,"/v1/editor/funnels"),a=(L=i==null?void 0:i.funnels)!=null?L:[];if(a.length===0){d("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let p=await _t(e,"/v1/editor/goals"),u=new Map(((A=p==null?void 0:p.goals)!=null?A:[]).map(x=>[x.goal_id,x.display_name]));lt([{key:"funnel",label:"Funnel",type:"select",options:a.map(x=>$t(x))},{key:"step",label:"Which step does this element serve?",type:"select",options:At(a[0],u).map(x=>x.label)}],"Attach",async x=>{var k;let g=(k=a.find(I=>$t(I)===x.funnel))!=null?k:a[0],m=At(g,u).findIndex(I=>I.label===x.step);if(m<0){d("\u26A0 Pick which step this element serves.",!1);return}d("Attaching\u2026");let v=await z(e,`/v1/editor/funnels/${encodeURIComponent(g.funnel_id)}/assign`,{slotId:r,stepIndex:m});v==="ok"&&R(),Y(v,`\u2713 Attached \u2014 this test now works toward \u201C${g.display_name}\u201D.`)});let h=C.querySelector('select[data-field="funnel"]'),w=C.querySelector('select[data-field="step"]');h&&w&&h.addEventListener("change",()=>{var g;let x=(g=a.find(m=>$t(m)===h.value))!=null?g:a[0];w.length=1;for(let m of At(x,u)){let v=document.createElement("option");v.value=m.label,v.textContent=m.label,w.append(v)}})},H.onclick=()=>{if(!t||!$)return;let r=$;lt([{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:Nt.length?`Font (this site has: ${Nt.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(i,a)=>{var A;let{style:p,errors:u}=fe(i),h=!1;for(let x of ue)a(x,(A=u[x])!=null?A:null),u[x]&&(h=!0);if(h){d("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(p).length===0){d("\u26A0 Enter at least one style change.",!1);return}let w=ht("style",r,t);d("Saving\u2026");let L=await z(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:p}}]}});L==="ok"&&(R(),vt(w)),Y(L,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Yt=r=>{if(!t)return;let i=t.parentElement;if(!i)return;ot||(ft=i,kt=t.nextSibling,ot=!0),r==="up"&&ut?i.insertBefore(t,ut):r==="down"&&pt&&i.insertBefore(t,pt.nextSibling);let a=It(t,document);ut=a.prevEl,pt=a.nextEl,j=a.prevLocator,nt=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),Pt(!0),d("Previewing the new position \u2014 keep moving, save, or undo.")};Z.onclick=()=>Yt("up"),K.onclick=()=>Yt("down"),xt.onclick=()=>{Ut(),d("Move undone \u2014 back to the original position.")},bt.onclick=async()=>{if(!t||!$||!ot||!dt)return;let r=j?"moveAfter":"moveBefore",i=j!=null?j:nt;if(!i){d("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=ht("move",$,t);d("Saving\u2026");let p=await z(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:$,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:i}}]}});p==="ok"&&(ot=!1,ft=null,kt=null,Pt(!1),vt(a)),Y(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let ve=()=>{var r;document.removeEventListener("mousemove",qt,!0),document.removeEventListener("click",Wt,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),yt(document),n.remove(),o.remove(),f.remove(),window.__sentientEditor=null,(r=document.querySelector("meta[data-sentient-editor]"))==null||r.remove(),Tt()};Ft.onclick=ve,document.addEventListener("mousemove",qt,!0),document.addEventListener("click",Wt,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c)}function b(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 me="sentient-preview-bar";async function en(e,t){var N,B,G,M,_,P,T,H,O,U,q,at;let n=null;try{let S=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(n=(B=((N=(await S.json()).slots)!=null?N:[]).find(F=>F.slot_id===t&&F.kind==="arms"))!=null?B:null)}catch(S){}let o=l("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)"});o.id=me;let s=l("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=()=>{Tt();let S=new URL(location.href);for(let W of["sentient_editor","sentient_preview","sentient_arm"])S.searchParams.delete(W);location.assign(S.toString())};let c=(P=(_=(G=n==null?void 0:n.draft_config)==null?void 0:G.arms)!=null?_:(M=n==null?void 0:n.published_config)==null?void 0:M.arms)!=null?P:[];if(!n||c.length===0){o.append(l("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),s),((T=document.body)!=null?T:document.documentElement).append(o);return}let f=new URLSearchParams(location.search).get("sentient_arm"),E=(O=(H=c.find(S=>S.id===f))!=null?H:c[1])!=null?O:c[0];o.append(l("span",{fontWeight:"700"},`Previewing: ${(U=n.display_name)!=null?U:n.slot_id}`));let y=n.target&&typeof n.target=="object"?et(n.target,document):null;if(!y)o.append(l("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{oe(y,E.ops,`preview-${n.slot_id}`,document);try{y.scrollIntoView({block:"center"})}catch(S){}for(let S of c){let W=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:S.id===E.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(q=S.displayName)!=null?q:S.id);W.onclick=()=>{let F=new URL(location.href);F.searchParams.set("sentient_arm",S.id),location.assign(F.toString())},o.append(W)}}o.append(s),((at=document.body)!=null?at:document.documentElement).append(o)}async function nn(){if(typeof document=="undefined")return;let e=We();if(!e)return;let t=await Ye(e);if(!t.ok){t.unauthorized?(Tt(),ae(Ue)):ae(qe);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(me)||await en(e,n);return}if(document.getElementById(st))return;ge(e);let o=Qt(document);o&&z(e,"/v1/editor/palette",o);let s=await Je(e);de(s,document)}nn();return $e(on);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var Ke=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames,bt=Object.getOwnPropertySymbols;var At=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable;var St=(e,t,n)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,X=(e,t)=>{for(var n in t||(t={}))At.call(t,n)&&St(e,n,t[n]);if(bt)for(var n of bt(t))$n.call(t,n)&&St(e,n,t[n]);return e};var xt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Et=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},jn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Kn(t))!At.call(e,i)&&i!==n&&Ke(e,i,{get:()=>t[i],enumerable:!(r=Nn(t,i))||r.enumerable});return e};var Gn=e=>jn(Ke({},"__esModule",{value:!0}),e);var Un,zn,qn,kt,Wn,Hn,It,C,Ee,$e=xt(()=>{"use strict";Un=Object.defineProperty,zn=Object.defineProperties,qn=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,It=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))Wn.call(t,n)&&It(e,n,t[n]);if(kt)for(var n of kt(t))Hn.call(t,n)&&It(e,n,t[n]);return e},Ee=(e,t)=>zn(e,qn(t))});var Mt={};Et(Mt,{LOCAL_ENGINE_AVAILABLE:()=>Zn,createLocalEngine:()=>Qn});function Qn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Zn,Nt=xt(()=>{"use strict";Zn=!1});var po={};Et(po,{applyPersonaAttributes:()=>Je,applyRegistrySlots:()=>Ze,applySlotArms:()=>Xe,applySlotAttributes:()=>Ye,parseEditorToken:()=>Pn,parsePersonaPreview:()=>Bn,parsePreview:()=>Dn,parseSnippetConfig:()=>Fe,reapply:()=>wt,run:()=>Mn,version:()=>mt});$e();var Fn=["buyer","researcher","deal_seeker","browser"];var Vn={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function je(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Ot(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let i=n.slice(0,r);if(i in t)return null;t[i]=n.slice(r+1)}return t}function ot(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return je(e.baseline);if(typeof e.baseline=="string")return e.baseline;let i={};for(let[c,a]of Object.entries((n=e.dims)!=null?n:{}))i[c]=(r=a[0])!=null?r:"";return je(i)}function _t(e,t){var n,r;return e.dims!=null?(r=(n=Ot(t))!=null?n:Ot(ot(e)))!=null?r:{}:t}function me(e){return e>=.3?e<.7?"medium":"high":"low"}var mo=Fn.map(e=>({key:e,displayName:Vn[e]}));function Ge(e){return e?`_${e.slice(0,12)}`:""}var Jn="_snt_uid";function Ct(e){return`${Jn}${Ge(e)}`}var Yn=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function Lt(e){return Xn(e)!==null}function Xn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Yn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Tt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Rt(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(i){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Pt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function Dt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function it(e){return C(C(C({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function st(e){let t=it(e);return _t(t,ot(t))}function Bt(e){return typeof e=="string"?e:je(e)}$e();function Ut(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var er="_snt_uid",tr=365,at="_snt_uid";function nr(){return Ut()}function Kt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function rr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function $t(e){try{return localStorage.getItem(e)}catch(t){return null}}function or(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function jt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function ir(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function sr(e){try{sessionStorage.removeItem(e)}catch(t){}}function ar(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function lr(e){try{localStorage.removeItem(e)}catch(t){}}function cr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var ur={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function zt(e){var t,n,r,i,c,a,l;if(typeof window=="undefined")return ur;let o=Ge(e==null?void 0:e.apiKey),s=(t=e==null?void 0:e.cookieName)!=null?t:Ct(e==null?void 0:e.apiKey),u=`${at}${o}`,d=((n=e==null?void 0:e.cookieTTLDays)!=null?n:tr)*24*60*60,f=m=>m&&m.length>0?m:null,g=()=>{var m,A;return o&&!(e!=null&&e.cookieName)?(A=(m=f(Kt(er)))!=null?m:f($t(at)))!=null?A:f(jt(at)):null},S=(l=(a=(c=(i=(r=f(Kt(s)))!=null?r:f($t(u)))!=null?i:f(jt(u)))!=null?c:g())!=null?a:f(e==null?void 0:e.ssrSessionId))!=null?l:nr();rr(s,S,d);let O=or(u,S),k=ar(s),L=O?!1:ir(u,S),v=!O&&!k&&!L;return{getSessionId:()=>S,isEphemeral:()=>v,destroy:()=>{S=null,cr(s),lr(u),sr(u)}}}function Ie(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ut(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function qt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function be(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let a=JSON.parse(c);return Array.isArray(a)?a:[]}catch(c){return[]}})(),i=new Map;for(let c of r)i.set(c.id,c);for(let c of e)i.set(c.id,c);localStorage.setItem(n,JSON.stringify([...i.values()].slice(-t)))}catch(r){}}function Wt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let i=new Set(e),c=r.filter(a=>!i.has(a.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var dr=500,pr=56*1024;function Ht(e){return`_snt_retry_${e.slice(0,12)}`}var fr={push:()=>{},flush:()=>{},destroy:()=>{}};function gr(e){var t,n,r;if(typeof window=="undefined")return fr;let i=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,a=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,o=e.apiKey,s=Ht(o),u=[],d=new Set,f=[],g=p=>{for(let y of p)S.delete(y),!d.has(y)&&(d.add(y),f.push(y));for(;f.length>dr;){let y=f.shift();y&&d.delete(y)}Wt(p,s)},S=new Set,O=p=>{d.has(p.id)||S.has(p.id)||(S.add(p.id),u.push(p))},k=p=>{for(let y of p)d.has(y.id)||(S.add(y.id),u.push(y))},L=qt(s,a);for(let p of L)O(p);let v=0,m=0,A=(p,y=!0)=>{if(p.length===0)return;let E=JSON.stringify(p),P=p.map(ge=>ge.id),T;try{T=fetch(l,{method:"POST",keepalive:!0,body:E,headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}})}catch(ge){be(p,a,s),k(p),m++,v=Date.now()+Ie(m);return}let ve=ge=>{if(ut(ge)!=="retry"){if(!ge.ok&&y){let oe=p.filter(ie=>ie.eventType!=="pageview");if(oe.length>0&&oe.length<p.length){g(p.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),A(oe,!1);return}}g(P),m=0,v=0;return}be(p,a,s),k(p),m++,v=Date.now()+Ie(m)};T instanceof Promise?T.then(ve).catch(()=>{be(p,a,s),k(p),m++,v=Date.now()+Ie(m)}):ve(T)},x=typeof TextEncoder!="undefined"?new TextEncoder:null,K=p=>x?x.encode(p).length:p.length,b=p=>{let y=[],E=2;for(let P of p){let T=K(JSON.stringify(P))+1;if(y.length>0&&E+T>pr||y.length>=c)break;y.push(P),E+=T}return y},R=()=>{try{if(Date.now()<v)return;for(;u.length>0&&!(Date.now()<v);){let p=u.filter(E=>!d.has(E.id));if(u.length=0,p.length===0)break;let y=b(p);if(y.length===0)break;y.length<p.length&&u.push(...p.slice(y.length)),A(y)}}catch(p){}},Z=!0,I=null;I=setInterval(()=>{Z&&R()},i);let Q=()=>{document.visibilityState==="hidden"&&R()},$=()=>{R()};return document.addEventListener("visibilitychange",Q),window.addEventListener("pagehide",$),{push(p){O(p),u.length>=c&&R()},flush:R,destroy(){Z=!1,I!==null&&(clearInterval(I),I=null),document.removeEventListener("visibilitychange",Q),window.removeEventListener("pagehide",$),R()}}}var mr=200;function Ft(e){return`_snt_goal_retry_${e.slice(0,12)}`}var hr={send:()=>{},flush:()=>{},destroy:()=>{}};function yr(e){var t,n,r;if(typeof window=="undefined")return hr;let i=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,a=(r=e.maxPerFlush)!=null?r:5,l=Ft(e.apiKey),o=[],s=new Set,u=new Set,d=[],f=0,g=0,S=!1,O=b=>{for(s.delete(b.id),u.has(b.id)||(u.add(b.id),d.push(b.id));d.length>mr;){let R=d.shift();R&&u.delete(R)}Wt([b.id],l)},k=b=>{be([b],c,l),!u.has(b.id)&&!s.has(b.id)&&(s.add(b.id),o.push(b)),Date.now()>=f&&(g++,f=Date.now()+Ie(g))},L=b=>{let R;try{R=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(I){k(b);return}let Z=I=>{var Q;let $=ut(I);if($==="retry"){k(b);return}$==="dropped"&&((Q=e.onDrop)==null||Q.call(e,b,I.status)),O(b),g=0,f=0};R instanceof Promise?R.then(Z).catch(()=>k(b)):Z(R)},v=()=>{try{if(S||Date.now()<f)return;let b=0;for(;o.length>0&&b<a&&!(Date.now()<f);){let R=o.shift();s.delete(R.id),!u.has(R.id)&&(b++,L(R))}}catch(b){}},m=qt(l,c);for(let b of m)s.has(b.id)||(s.add(b.id),o.push(b));m.length>0&&be(m,c,l);let A=setInterval(v,i),x=()=>{document.visibilityState==="hidden"&&v()},K=()=>v();return document.addEventListener("visibilitychange",x),window.addEventListener("pagehide",K),{send(b){if(!S&&!(u.has(b.id)||s.has(b.id))){if(Date.now()<f){be([b],c,l),s.add(b.id),o.push(b);return}L(b)}},flush:v,destroy(){clearInterval(A),document.removeEventListener("visibilitychange",x),window.removeEventListener("pagehide",K),v(),S=!0}}}var vr=1800*1e3;function Ue(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function wr(e=vr,t){let n=new Map,r=`_snt_asgn${Ge(t)}_`,i=(o,s)=>`${r}${encodeURIComponent(o)}:${encodeURIComponent(s)}`,c=o=>{let s=o.slice(r.length),u=s.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,u)),segment:decodeURIComponent(s.slice(u+1))}}catch(d){return null}},a=()=>{try{let o=[];for(let s=0;s<localStorage.length;s++){let u=localStorage.key(s);u!=null&&u.startsWith(r)&&o.push(u)}return o}catch(o){return[]}},l=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of a())try{let s=localStorage.getItem(o);if(!s)continue;let u=JSON.parse(s);if(l(u)){localStorage.removeItem(o);continue}let d=c(o);if(!d)continue;n.set(Ue(d.componentId,d.segment),u)}catch(s){}})(),{get(o,s){let u=n.get(Ue(o,s));return u?l(u)?(n.delete(Ue(o,s)),null):u:null},set(o,s,u){let d=Ue(o,s);n.set(d,u);try{localStorage.setItem(i(o,s),JSON.stringify(u))}catch(f){}},invalidate(o){let s=`${encodeURIComponent(o)}:`;for(let u of[...n.keys()])u.startsWith(s)&&n.delete(u);for(let u of a()){let d=c(u);if((d==null?void 0:d.componentId)===o)try{localStorage.removeItem(u)}catch(f){}}},clear(){n.clear();for(let o of a())try{localStorage.removeItem(o)}catch(s){}}}}var We="_snt_snap:",br=["low","medium","high"];function He(e){try{let t=localStorage.getItem(We+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!br.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function Oe(e,t){try{localStorage.setItem(We+e,JSON.stringify(t))}catch(n){}}var ct="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Vt="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Gt=!1,ze=!1;function Sr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Ar(e){var t;let n=zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",i=Sr(),c=Promise.resolve().then(()=>(Nt(),Mt)).then(o=>{let s=o;return s.LOCAL_ENGINE_AVAILABLE?(Gt||(Gt=!0,console.info(Vt)),s):(ze||(ze=!0,console.error(ct)),null)}).catch(()=>(ze||(ze=!0,console.error(ct)),null)),a=null;function l(o){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=o.persona,s.dataset.sentientConfidence=me(o.confidence))}return{isLocal:!0,async decide(o){var s,u,d;let f=await c;if(!f)return null;let g=f.createLocalEngine({sessionId:r,forcedPersona:i}).decide(o);return a=Ee(C({},g),{layoutOrder:(u=(s=g.layoutOrder)!=null?s:a==null?void 0:a.layoutOrder)!=null?u:null,slots:C(C({},(d=a==null?void 0:a.slots)!=null?d:{}),g.slots)}),Oe(e.apiKey||"local",{v:1,persona:a.persona,band:me(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(o){var s,u,d;return(d=(u=a==null?void 0:a.slots[o])!=null?u:(s=e.initialSlots)==null?void 0:s[o])!=null?d:null},getPersona(){return a?{persona:a.persona,confidence:a.confidence,band:me(a.confidence)}:null},async assign(o,s){var u;let d=await c;return!d||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(u=d.createLocalEngine({sessionId:r,forcedPersona:i}).decide({components:[{id:o,variantIds:s}]}).assignments[o])!=null?u:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function _e(e,t,n,r){let i=[];{let c=!1,a=[],l=()=>{if(c)return;let o=Date.now();for(a.push(o);a.length>0&&o-a[0]>500;)a.shift();a.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",l),i.push(()=>t.removeEventListener("click",l))}{let c=!1,a=l=>{if(c||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;c=!0;let o=typeof window!="undefined"?window.getSelection():null,s=o?o.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",a),i.push(()=>document.removeEventListener("copy",a))}{let c=!1,a=!1,l=null,o=()=>{l!==null&&(clearTimeout(l),l=null)},s=()=>{c||!a||(o(),l=setTimeout(()=>{!c&&a&&(c=!0,e("scroll_hesitation"))},3e3))},u=()=>{o(),s()},d=g=>{for(let S of g)a=S.intersectionRatio>.3,a?s():o()},f=new IntersectionObserver(d,{threshold:[.3]});f.observe(t),window.addEventListener("scroll",u,{passive:!0}),i.push(()=>{f.disconnect(),window.removeEventListener("scroll",u),o()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,a=n!=null?n:Date.now(),l=()=>{if(c||document.visibilityState!=="hidden")return;let o=Date.now()-a;o<15e3&&(c=!0,e("tab_loss",{timeOnPage:o}))};document.addEventListener("visibilitychange",l),i.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let c of i)c()}}var Jt="https://api.sentient-ui.com/v1/events",Y=new Map,Yt=null;function xr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Er=3;function lt(){return Ut()}function qe(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function kr(){let e=new WeakMap,t=new Map,n=!1,r=(l,o,s)=>{let u=l.get(o);return s===null?u?!0:(l.set(o,new Set),!1):u?u.has(s)?!0:(u.add(s),!1):(l.set(o,new Set([s])),!1)},i=typeof window!="undefined"&&"event"in window,c=()=>{if(!i)return;let l=window.event;return typeof Event=="function"&&l instanceof Event?l:void 0},a=()=>{if(i){Promise.resolve().then(()=>{n=!1,t.clear()});return}let l=!1,o=()=>{l||(l=!0,n=!1,t.clear())};if(setTimeout(o,0),typeof MessageChannel=="function"){let s=new MessageChannel;s.port1.onmessage=()=>{s.port1.close(),s.port2.close(),o()},s.port2.postMessage(0)}};return{firedBefore(l,o){let s=c();if(s){let d=e.get(s);return d||(d=new Map,e.set(s,d)),r(d,l,o)}let u=r(t,l,o);return!u&&!n&&(n=!0,a()),u}}}var Xt=new Set;function Ir(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let i=!1,c,a=()=>{if(i)return;let s=qe();!s||s===c||(c=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},l=[];for(let s of["pushState","replaceState"]){let u=r[s],d=function(...f){let g=u.apply(this,f);return a(),g};r[s]=d,l.push([s,u,d])}window.addEventListener("popstate",a);let o=qe();return o&&Xt.has(`${t}:${o}`)?c=o:a(),()=>{if(!i){i=!0,window.removeEventListener("popstate",a);for(let[s,u,d]of l)r[s]===d&&(r[s]=u)}}}var ke={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Or(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function Zt(e){return e.replace(/\/events\/?$/,"")}function he(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function dt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Yt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=Y.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:i,upgrade:c}=r;if(!c||i.respectDoNotTrack!==!1&&he())return;let a=Ce(Ee(C({},i),{consent:!0}));c(a);let l=(t=Y.get(n))==null?void 0:t.dispose;Y.set(n,{config:Ee(C({},i),{consent:!0}),upgrade:null,dispose:l})}function _r(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Zt((t=e.ingestUrl)!=null?t:Jt),i={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(o,s,u){if(!n)return null;try{let d=new URLSearchParams({componentId:o});for(let g of s!=null?s:[])d.append("variantIds[]",g);let f=await fetch(`${r}/winner?${d.toString()}`,{headers:i});return f.ok?{variantId:(await f.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(d){return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:o=>c.track(o),goal:((o,s,u,d)=>c.goal(o,s,u,d)),componentGoal:(o,s,u)=>c.componentGoal(o,s,u),identify:o=>c.identify(o),getAssignment:(o,s)=>c.getAssignment(o,s),assign:(o,s,u,d)=>c.assign(o,s,u,d),decide:o=>c.decide(o),getSlotResult:o=>c.getSlotResult(o),getPersona:()=>c.getPersona(),fetchWeights:()=>c.fetchWeights(),getGraph:()=>c.getGraph(),dispose:()=>c.dispose(),destroy:()=>c.destroy()};function l(o){c=o}return{proxy:a,setInner:l}}function Ce(e){var t,n,r,i,c,a,l,o,s;if(typeof window=="undefined")return ke;Yt=e.apiKey;let u=Y.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&he(),f=e.consent===!1||d,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return f?(Y.set(e.apiKey||"local",{config:e,upgrade:null}),ke):(Y.set(e.apiKey||"local",{config:e,upgrade:null}),Ar(e));if(f){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Y.set(e.apiKey,{config:e,upgrade:null}),ke;let{proxy:h,setInner:w}=_r(e);return Y.set(e.apiKey,{config:e,upgrade:d?null:w}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),ke;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ke;let S=(t=e.ingestUrl)!=null?t:Jt,O=Date.now(),k=zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),L=wr(void 0,e.apiKey),v=gr({ingestUrl:S,apiKey:e.apiKey}),m=Zt(S),A={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},x=new Set,K=yr({url:`${m}/goals`,apiKey:e.apiKey,headers:A,onDrop:(h,w)=>{if(!e.debug){if(x.has(w))return;x.add(w)}console.warn(`[sentient] goal dropped (HTTP ${w}) \u2014 this will not be retried. `+(w===400?"The session was not found: call init() and let the session upsert complete before firing goals.":w===401||w===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),b=Tt((n=navigator.userAgent)!=null?n:""),R=typeof window!="undefined"?window.location.origin:void 0,Z=Rt((r=document.referrer)!=null?r:"",R),I=(i=e.sessionSegment)!=null?i:`${b}:${Z}`,Q=new Map,$=new Map,p=null,y=h=>{for(let w of h)$.has(w.id)||$.set(w.id,st(w))};if(e.initialSlots)for(let[h,w]of Object.entries(e.initialSlots))$.set(h,w);let E=He(e.apiKey);if(E)for(let[h,w]of Object.entries(E.slots))$.has(h)||$.set(h,w);let P={low:.15,medium:.5,high:.85};if(e.initialPersona)p=C({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?p={persona:h.sentientPersona,confidence:(a=P[(c=h.sentientConfidence)!=null?c:"low"])!=null?a:.15}:E&&(p={persona:E.persona,confidence:(l=P[E.band])!=null?l:.15})}if(e.initialAssignments)for(let[h,w]of Object.entries(e.initialAssignments))L.set(h,I,{variantId:w,assignedAt:Date.now(),segment:I,confidence:1});let T=Promise.resolve(),ve=k.getSessionId();if(ve){let h=Pt((o=document.referrer)!=null?o:""),w=C(C(C({sessionId:ve,deviceClass:b,trafficSource:Z,referrerDomain:h,utmParams:Or(),timeOfDay:Dt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:k.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Lt((s=navigator.userAgent)!=null?s:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let z=0;;z++){try{let j=await fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(w),headers:A});if(j.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(j.ok||ut(j)==="dropped")return}catch(j){}if(z>=Er){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(j=>setTimeout(j,Ie(z+1)))}};try{T=D()}catch(z){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:v});let ge=kr(),oe=null,ie=!1,we={goal(h,w={},D=1,z=0){var j,G,ee,J,W,te,H;let ce=k.getSessionId();if(!ce)return;let M=xr(w)?w:{metadata:w},Me=[h,(j=M.externalId)!=null?j:"",(G=M.stepIndex)!=null?G:z,(ee=M.weight)!=null?ee:D].join("\0"),_=M.value!==void 0?`${M.value}\0${(J=M.currency)!=null?J:""}`:null;if(ge.firedBefore(Me,_)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let ue=lt(),Ne={sessionId:ce,name:h,metadata:(W=M.metadata)!=null?W:{},weight:(te=M.weight)!=null?te:D,stepIndex:(H=M.stepIndex)!=null?H:z,goalId:ue,value:M.value,currency:M.currency,externalId:M.externalId};e.debug&&console.log("[sentient] goal",Ne);let V={id:ue,body:JSON.stringify(Ne)};T.then(()=>K.send(V))},componentGoal(h,w,D){var z,j,G;let ee=k.getSessionId();if(!ee)return;let J=L.get(h,I),W=J?null:(z=$.get(h))!=null?z:null;if(!J&&W===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let te=J?J.variantId:Bt(W),H={id:lt(),sessionId:ee,projectId:e.apiKey,componentId:h,variantId:te,eventType:"goal_achieved",goalType:w,payload:C({reward:(j=D==null?void 0:D.reward)!=null?j:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(G=D==null?void 0:D.metadata)!=null?G:{}),timestamp:Date.now(),timeInSession:Date.now()-O,path:qe()};e.debug&&console.log("[sentient] componentGoal",H),T.then(()=>v.push(H))},identify(h){let w=k.getSessionId();w&&T.then(()=>{fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:w,userId:h,ephemeral:k.isEphemeral()}),headers:A}).catch(()=>{})})},track(h){let w=k.getSessionId();if(!w)return;let D=Ee(C({path:qe()},h),{id:lt(),sessionId:w,timestamp:Date.now(),timeInSession:Date.now()-O});e.debug&&console.log("[sentient] track",D),T.then(()=>v.push(D))},getAssignment(h,w){return L.get(h,w)},async assign(h,w,D,z){let j=k.getSessionId();if(!j)return null;let G=L.get(h,I);if(G&&(w!=null&&w.length||G.content!==void 0)){let W=G.ttlMs&&G.ttlMs>0?Math.max(0,G.assignedAt+G.ttlMs-Date.now()):0;return{variantId:G.variantId,assignmentTtlMs:W,content:G.content}}let ee=Q.get(h);if(ee)return ee;let J=(async()=>{await T;try{let W={sessionId:j,componentId:h,variantIds:w};z!==void 0?W.agentDataByVariant=z:D!==void 0&&(W.agentData=D);let te=await fetch(`${m}/assign`,{method:"POST",body:JSON.stringify(W),headers:A});if(!te.ok)return null;let H=await te.json();return L.set(h,I,C({variantId:H.variantId,assignedAt:Date.now(),segment:I,confidence:1,content:H.content},H.assignmentTtlMs&&H.assignmentTtlMs>0?{ttlMs:H.assignmentTtlMs}:{})),H}catch(W){return null}finally{Q.delete(h)}})();return Q.set(h,J),J},async decide(h){var w,D,z,j,G,ee,J,W,te;let H=k.getSessionId();if(!H)return null;let ce=(w=h.slots)!=null?w:[];await T;try{let M={sessionId:H};h.sections&&h.sections.length>0&&(M.sections=h.sections.map(V=>({id:V}))),M.components=(D=h.components)!=null?D:[],ce.length>0&&(M.slots=ce.map(it)),h.slotsFrom==="registry"&&(M.slotsFrom="registry"),h.v&&(M.v=h.v),e.persona&&(M.persona=e.persona);let Me=await fetch(`${m}/decide`,{method:"POST",body:JSON.stringify(M),headers:A});if(!Me.ok)return y(ce),null;let _=await Me.json(),ue={};for(let V of ce)ue[V.id]=(j=(z=_.slots)==null?void 0:z[V.id])!=null?j:st(V);if(_.slots)for(let[V,xe]of Object.entries(_.slots))V in ue||(ue[V]=xe);for(let[V,xe]of Object.entries(ue))$.set(V,xe);let Ne=p!=null&&p.persona!=="unknown";_.persona&&!(_.persona==="unknown"&&Ne)?p={persona:_.persona,confidence:(G=_.confidence)!=null?G:0}:p||(p={persona:"unknown",confidence:0});for(let[V,xe]of Object.entries((ee=_.assignments)!=null?ee:{}))L.set(V,I,{variantId:xe,assignedAt:Date.now(),segment:I,confidence:1});return Oe(e.apiKey,C(C({v:1,persona:p.persona,band:me(p.confidence),slots:Object.fromEntries($),layoutOrder:(J=_.layoutOrder)!=null?J:null,savedAt:Date.now()},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.palette?{palette:_.palette}:{})),C(C(C(C({layoutOrder:(W=_.layoutOrder)!=null?W:null,assignments:(te=_.assignments)!=null?te:{},slots:ue,persona:p.persona,confidence:p.confidence},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.goals?{goals:_.goals}:{}),_.sectionMap?{sectionMap:_.sectionMap}:{}),_.palette?{palette:_.palette}:{})}catch(M){return y(ce),null}},getSlotResult(h){var w;return(w=$.get(h))!=null?w:null},getPersona(){return p?{persona:p.persona,confidence:p.confidence,band:me(p.confidence)}:null},async fetchWeights(){var h;try{let w=await fetch(`${m}/weights`,{headers:A});return w.ok?(h=(await w.json()).components)!=null?h:[]:[]}catch(w){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;oe==null||oe(),ie=!0,v.destroy(),K.destroy(),((h=Y.get(e.apiKey))==null?void 0:h.dispose)===we.dispose&&Y.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;oe==null||oe(),ie=!0,v.destroy(),K.destroy(),k.destroy(),((h=Y.get(e.apiKey))==null?void 0:h.dispose)===we.dispose&&Y.delete(e.apiKey);try{localStorage.removeItem(We+e.apiKey),localStorage.removeItem(Ht(e.apiKey)),localStorage.removeItem(Ft(e.apiKey))}catch(w){}e.debug&&console.log("[sentient] destroyed")}};if(Y.set(e.apiKey,{config:e,upgrade:null,dispose:we.dispose}),oe=Ir(we,e.apiKey,h=>{T.then(()=>{ie||Xt.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=we)}return we}var Qt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Cr=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],Lr=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function Tr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function en(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of Cr)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Lr)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function tn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Tr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function nn(e){return en(tn(e)).type}$e();var Rr="section, header, footer, nav, main > div, [data-sentient-section]",Pr=2e4;function Dr(e){let t=Array.from(e.querySelectorAll(Rr)),n=t.filter(r=>t.filter(i=>i!==r&&r.contains(i)).length<2);return n.filter(r=>!n.some(i=>i!==r&&i.contains(r)))}function Br(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(i){}}var rn=()=>{};function on(e,t){var n,r,i,c,a,l,o,s,u;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||he()||!t.apiKey)return rn;let f=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Dr(d);if(g.length===0)return rn;let S=new Map,O=new Map,k=new Map;for(let p of g){let y=p.getAttribute("data-sentient-type"),E=y&&Qt.includes(y)?y:null,P=(c=E!=null?E:(i=t.typeOf)==null?void 0:i.call(t,p))!=null?c:nn(p),T=`nc-${P}`;S.set(p,T),O.set(T,P),E?k.set(T,"markup"):k.has(T)||k.set(T,"auto")}let L=(s=(o=(l=(a=d.defaultView)!=null?a:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:o.pathname)!=null?s:"/";Br(t.apiKey,f,L,[...O.entries()].map(([p,y])=>{var E;return{componentId:p,semanticType:y,source:(E=k.get(p))!=null?E:"auto"}}));let v=new Map,m=p=>{let y=v.get(p);return y||(y={ms:0,scroll:0,enterAt:null,intersecting:!1},v.set(p,y)),y},A=new IntersectionObserver(p=>{for(let y of p){let E=S.get(y.target);if(!E)continue;let P=m(E);y.isIntersecting?(P.intersecting=!0,P.enterAt=Date.now(),y.intersectionRatio>P.scroll&&(P.scroll=y.intersectionRatio)):(P.intersecting=!1,P.enterAt!=null&&(P.ms+=Date.now()-P.enterAt,P.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let p of S.keys())A.observe(p);let x=()=>{let p=Date.now();for(let[y,E]of v)if(E.enterAt!=null&&(E.ms+=p-E.enterAt,E.enterAt=null),!(E.ms<=0)){try{e.track({projectId:t.apiKey,componentId:y,eventType:"dwell",payload:{dwell_time:Math.round(E.ms),scroll_depth:Number(E.scroll.toFixed(2))}})}catch(P){}E.ms=0}},K=()=>{if(d.hidden)x();else{let p=Date.now();for(let y of v.values())y.intersecting&&(y.enterAt=p)}},b=!1,R=p=>{if(x(),p!=null&&p.persisted){b=!0;return}try{A.disconnect()}catch(y){}},Z=p=>{if(!(p!=null&&p.persisted)||!b)return;b=!1;let y=Date.now();for(let E of v.values())E.enterAt=E.intersecting&&!d.hidden?y:null};d.addEventListener("visibilitychange",K);let I=(u=d.defaultView)!=null?u:typeof window!="undefined"?window:void 0;I==null||I.addEventListener("pagehide",R),I==null||I.addEventListener("pageshow",Z);let Q=setInterval(()=>{if(d.hidden||b)return;x();let p=Date.now();for(let y of v.values())y.intersecting&&(y.enterAt=p)},Pr),$=[];return t.microSignals&&[...S.entries()].forEach(([p,y],E)=>{$.push(_e((P,T={})=>{try{e.track({projectId:t.apiKey,componentId:y,eventType:"micro_signal",payload:C({signalType:P},T)})}catch(ve){}},p,void 0,{tabLoss:E===0}))}),()=>{x(),clearInterval(Q),d.removeEventListener("visibilitychange",K),I==null||I.removeEventListener("pagehide",R),I==null||I.removeEventListener("pageshow",Z);for(let p of $)p();try{A.disconnect()}catch(p){}}}var Mr=["landing","ecommerce","saas","marketplace"];function Nr(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,i]of t){if(!Array.isArray(i)||i.length<2||i.length>6||!i.every(c=>typeof c=="string"))return null;n[r]=i}return n}function Kr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function $r(e){try{return e()}catch(t){return}}function Fe(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=Mr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[a,l]of Object.entries(t.slots)){if(typeof l!="object"||l===null)continue;let o=l,s=Nr(o.dims);if(!s||o.target!==void 0&&typeof o.target!="string")continue;let u=o.arms!==void 0?Kr(o.arms):null,d={dims:s};typeof o.target=="string"&&(d.target=o.target),u&&(d.arms=u),r[a]=d}let i={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(i.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(i.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(i.debug=!0),typeof t.registry=="boolean"&&(i.registry=t.registry),typeof t.editorSrc=="string"&&(i.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(i.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(i.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?$r(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(i.persona=c),Array.isArray(t.sections)){let a=t.sections.filter(l=>typeof l=="string"&&l.trim()!=="").slice(0,50);a.length>=2&&(i.sections=a)}return i}function sn(e){var n,r,i;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function jr(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:"").trim().toLowerCase(),i=t.text.trim().toLowerCase();if(!(r===i||r.startsWith(i)||i.startsWith(r)))return!1}return!0}function an(e,t){return!!(e!=null&&e.urlMatch)&&!sn(t).includes(e.urlMatch)}var Gr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var i;if(e.urlMatch&&!sn(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((i=e.dataAttr)!=null&&i.name)&&Gr.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!jr(r,e.fingerprint)?null:r}var ln={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"},Ur=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function cn(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Ur.test((t=n[1])!=null?t:""))return!1;return!0}var un=/^https:\/\//i,dn=new Map,pe=null;function zr(e){return e.replace(/["\\]/g,"\\$&")}function qr(e){var t;(!pe||!pe.isConnected)&&(pe=e.querySelector("style[data-sentient-ops]"),pe||(pe=e.createElement("style"),pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(pe))),pe.textContent=[...dn.entries()].map(([n,r])=>`[data-snt-e="${zr(n)}"]{${r}}`).join(`
2
- `)}function pn(e,t,n,r){var l;let i=!1,c=(l=t.moveBefore)!=null?l:t.moveAfter;if(c){let o=de(c,r);!o||o===e||o.parentElement!==e.parentElement||!e.parentElement?i=!0:t.moveBefore?e.parentElement.insertBefore(e,o):e.parentElement.insertBefore(e,o.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&un.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&un.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let a=[];if(t.hidden&&a.push("display:none !important"),t.style)for(let[o,s]of Object.entries(t.style)){let u=ln[o];u&&typeof s=="string"&&cn(s)&&a.push(`${u}:${s.trim()} !important`)}return a.length>0&&(e.setAttribute("data-snt-e",n),dn.set(n,a.join(";")),qr(r)),{anchorMiss:i}}var Le="data-sentient-block-arm",ne=null;function Te(e){ne=e!=null?e:null}var ae="data-sentient-blocks-hid",fn={none:"0",sm:"8px",md:"16px",lg:"24px"},pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},gn={sm:"0.875em",md:"1em",lg:"1.25em"},Wr={sm:"1.25em",md:"1.5em",lg:"2em"},Hr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},mn={sm:"8px",md:"16px",lg:"32px"},Fr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Vr={normal:"400",medium:"500",bold:"700"};function se(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function hn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function yn(e,t){var n,r,i,c,a,l,o,s,u,d;try{switch(e.type){case"stack":case"grid":{let f=t.createElement("div");if(e.type==="stack"){let g=e;se(f,{display:"flex","flex-direction":g.direction,gap:fn[(n=g.gap)!=null?n:"md"],"align-items":g.align?pt[g.align]:void 0,"justify-content":g.justify?pt[g.justify]:void 0,"flex-wrap":g.wrap?"wrap":void 0})}else{let g=e,S=fn[(r=g.gap)!=null?r:"md"];se(f,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${g.columns-1} * ${S}) / ${g.columns})), 1fr))`,gap:S,"align-items":g.align?pt[g.align]:void 0})}for(let g of(i=e.children)!=null?i:[]){let S=yn(g,t);S&&f.appendChild(S)}return f}case"text":{let f=t.createElement("p");return f.textContent=e.value,se(f,X({margin:"0","font-size":e.size?gn[e.size]:void 0,"font-weight":e.weight?Vr[e.weight]:void 0,"text-align":e.align},hn(e.tone)))}case"heading":{let f=t.createElement(`h${e.level}`);return f.textContent=e.value,se(f,{margin:"0","font-size":Wr[(c=e.size)!=null?c:"md"],"text-align":e.align})}case"button":{let f=t.createElement("a");f.textContent=e.label,f.href=e.href,e.tag&&f.setAttribute("data-sentient-tag",e.tag);let g=(a=e.emphasis)!=null?a:"primary";return se(f,{display:"inline-block",padding:Hr[(l=e.size)!=null?l:"md"],"border-radius":(o=ne==null?void 0:ne.radius)!=null?o:"8px",font:"inherit","font-size":e.size?gn[e.size]:void 0,"text-decoration":g==="ghost"?"underline":"none",cursor:"pointer",background:g==="primary"?(s=ne==null?void 0:ne.primaryBg)!=null?s:"#111827":"transparent",color:g==="primary"?(u=ne==null?void 0:ne.primaryText)!=null?u:"#ffffff":"inherit",border:g==="secondary"?"1px solid currentColor":"none"})}case"link":{let f=t.createElement("a");return f.textContent=e.label,f.href=e.href,e.tag&&f.setAttribute("data-sentient-tag",e.tag),se(f,{color:"inherit","text-decoration":"underline"})}case"image":{let f=t.createElement("img");return f.src=e.src,f.alt=e.alt,se(f,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Fr[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let f=t.createElement("span");return f.textContent=e.value,se(f,X({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},hn(e.tone)))}case"spacer":return se(t.createElement("div"),{height:(d=mn[e.size])!=null?d:mn.md});default:return null}}catch(f){return null}}function vn(e,t,n,r){try{let i=new Set;for(let a of Array.from(e.children)){let l=a.getAttribute(Le);l!==null&&(t[l]===void 0?a.remove():i.add(l))}for(let[a,l]of Object.entries(t)){if(i.has(a))continue;let o=yn(l,r);if(!o)continue;let s=r.createElement("div");s.setAttribute(Le,a),s.style.display="none",s.appendChild(o),e.appendChild(s)}let c=n!==void 0&&t[n]!==void 0;for(let a of Array.from(e.children)){let l=a.getAttribute(Le),o=a;l!==null?o.style.display=c&&l===n?"":"none":c?o.hasAttribute(ae)||(o.setAttribute(ae,o.style.display),o.style.display="none"):o.hasAttribute(ae)&&(o.style.display=o.getAttribute(ae),o.removeAttribute(ae))}}catch(i){}}function Jr(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Le)!==null){n.remove();continue}n.hasAttribute(ae)&&(n.style.display=n.getAttribute(ae),n.removeAttribute(ae))}}catch(t){}}function Ve(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Le}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ae}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||Jr(r)}catch(n){}}function Je(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Ye(e,t,n){var r;for(let[i,c]of Object.entries(t)){let a=e[i];if(!a||typeof a=="string")continue;let l=c.target?Array.from(n.querySelectorAll(c.target)):[n.documentElement];for(let o of l)for(let[s,u]of Object.entries(a))(r=c.dims[s])!=null&&r.includes(u)&&o.setAttribute(`data-${s}`,u)}}function Xe(e,t,n){for(let[r,i]of Object.entries(t)){let c=e[r];if(typeof c!="string"||!i.arms||!i.arms.includes(c))continue;let a=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let l of a)l.setAttribute("data-sentient-arm",c)}}function Ze(e,t,n,r){var l,o;let i=new Set,c=(l=r==null?void 0:r.contentAndOps)!=null?l:!0,a=[];for(let[s,u]of Object.entries(t)){if(an(u.locator,n))continue;let d;if(u.locator){let g=de(u.locator,n);d=g?[g]:[]}else u.target?d=Array.from(n.querySelectorAll(u.target)):d=[n.documentElement];(u.locator||u.target)&&d.length===0&&a.push(s);let f=e[s];for(let g of d){if(f!==void 0)if(typeof f=="string")g.setAttribute("data-sentient-arm",f),c&&((o=r==null?void 0:r.onApplied)==null||o.call(r,s,f,g));else for(let[S,O]of Object.entries(f))g.setAttribute(`data-${S}`,O);u.blocks&&!Xr(n)&&(vn(g,u.blocks,typeof f=="string"?f:void 0,n),i.add(g)),c&&(typeof u.content=="string"&&(g.textContent=u.content),u.ops&&pn(g,u.ops,s,n).anchorMiss&&!a.includes(s)&&a.push(s))}}return Ve(n,i),a}var Yr=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Xr(e){var t,n,r;try{let i=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return i?i.webdriver===!0?!0:Yr.test((r=i.userAgent)!=null?r:""):!1}catch(i){return!1}}var Zr=800;function Qe(e,t,n){let r=[];return n.forEach(({slotId:i,arm:c,el:a},l)=>{r.push(_e((f,g={})=>{try{e.track({projectId:t,componentId:i,variantId:c,eventType:"micro_signal",payload:X({signalType:f},g)})}catch(S){}},a,void 0,{tabLoss:l===0}));let o=null,s=0,u=()=>{s=Date.now(),o=setTimeout(()=>{try{e.track({projectId:t,componentId:i,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-s}})}catch(f){}o=null},Zr)},d=()=>{o!==null&&(clearTimeout(o),o=null)};a.addEventListener("mouseenter",u),a.addEventListener("mouseleave",d),r.push(()=>{a.removeEventListener("mouseenter",u),a.removeEventListener("mouseleave",d),o!==null&&clearTimeout(o)})}),()=>{for(let i of r)i()}}function Qr(e){var n,r,i;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function eo(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function to(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}function wn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function no(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(i=>typeof i=="string")):new Set}catch(n){return new Set}}function ro(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function ft(e,t,n,r){var L,v;let i=(L=n.defaultView)!=null?L:typeof window!="undefined"?window:null,c=to(r),a=no(i,c),l=m=>{let A=wn(m);if(!a.has(A))try{m.slotId?t.componentGoal(m.slotId,m.goalId):t.goal(m.goalId),a.add(A),ro(i,c,a)}catch(x){}},o=e.filter(m=>m.event==="click"),s=e.filter(m=>m.event==="form_submit"),u=e.filter(m=>m.event==="url_reached"),d=e.filter(m=>m.event==="scroll_depth"),f=(m,A)=>{if(!m.locator)return!1;let x=de(m.locator,n);return!!x&&(x===A||x.contains(A))},g=m=>{let A=m.target;if(!(!A||typeof A.closest!="function"))for(let x of o)f(x,A)&&l(x)},S=m=>{let A=m.target;if(A)for(let x of s)f(x,A)&&l(x)},O=()=>{if(u.length===0)return;let m=Qr(n);for(let A of u)A.urlPattern&&eo(A.urlPattern,m)&&l(A)},k=()=>{var x;let m=n.documentElement,A=m.scrollHeight>0?(m.scrollTop+m.clientHeight)/m.scrollHeight:0;for(let K of d)A>=((x=K.threshold)!=null?x:.75)&&l(K);d.every(K=>a.has(wn(K)))&&n.removeEventListener("scroll",k)};return n.addEventListener("click",g,!0),n.addEventListener("submit",S,!0),(v=n.defaultView)==null||v.addEventListener("popstate",O),O(),d.length>0&&(n.addEventListener("scroll",k,{passive:!0}),k()),{checkUrl:O,teardown:()=>{var m;n.removeEventListener("click",g,!0),n.removeEventListener("submit",S,!0),(m=n.defaultView)==null||m.removeEventListener("popstate",O),d.length>0&&n.removeEventListener("scroll",k)}}}var bn="__snt_editor_token";function Sn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(bn):null}catch(e){return null}}function An(e){try{sessionStorage.setItem(bn,e)}catch(t){}}var mt="0.17.2",Ln=5e3,oo=50,io=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),q=null,B=null,le={},fe=null,F=null,Re=null,U=null,re=null,N=null,ye=null,xn=!1,gt=null,et=null,nt=null,De=!1,rt=!1,tt=!1;function Tn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function Se(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ae(e,t){return q?(q.personaAttributes&&N&&Je(N.persona,N.band,e),Ye(le,q.slots,e),Xe(le,q.slots,e),fe?Ze(le,fe,e,t):(Ve(e,new Set),[])):[]}function Rn(e){var n;let t=new Map;for(let r of(n=q==null?void 0:q.sections)!=null?n:[])try{let i=e.querySelectorAll(r);i.length===1&&t.set(r,i[0])}catch(i){}return t}function ht(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Rn(t);if(n.size!==e.length)return;let r=[];for(let a of e){let l=n.get(a);if(!l)return;r.push(l)}let i=r[0].parentNode;if(!i||!r.every(a=>a.parentNode===i))return;let c=r.slice().sort((a,l)=>a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let a=0;a<r.length;a++){let l=r[a];c[a]!==l&&(i.insertBefore(l,c[a]),c.splice(c.indexOf(l),1),c.splice(a,0,l))}}catch(n){}}function so(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Be(){return!!(q&&B&&q.sectionCapture!==!1&&(q.consent!==!1||rt)&&!he())}function ao(){if(!B||!q||!Be()||re)return;let e=[];Ae(document,{contentAndOps:De,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),vt();try{U==null||U(),U=Qe(B,q.apiKey,e)}catch(t){}}function vt(){if(typeof document=="undefined"||!Be())return;let e;try{if(et&&et.length>0){let t=new Map;for(let n of et){if(n.urlMatch!==window.location.pathname)continue;let r=de(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{re=on(B,X({apiKey:q.apiKey,apiBase:q.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),nt=window.location.pathname}catch(t){}}function wt(){try{let e=[];if(U==null||U(),U=null,Ae(document,{contentAndOps:De,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),ht(ye,document),e.length>0&&Be())try{U=Qe(B,q.apiKey,e)}catch(t){}try{typeof window!="undefined"&&nt!==null&&window.location.pathname!==nt&&Be()&&(re==null||re(),re=null,vt())}catch(t){}}catch(e){}}function En(){gt===null&&(gt=setTimeout(()=>{gt=null,wt();try{F==null||F.checkUrl()}catch(e){}},oo))}function kn(){if(!(xn||typeof window=="undefined"||typeof history=="undefined")){xn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,i,c){let a=n.call(this,r,i,c!=null?c:null);return En(),a}};e("pushState"),e("replaceState"),window.addEventListener("popstate",En)}catch(e){}}}function yt(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function Pn(e){return new URLSearchParams(e).get("sentient_editor")}function lo(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function co(e,t){var n,r,i,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let o=document.createElement("meta");o.name="referrer",o.content="no-referrer",o.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(o)}catch(o){}let a=(i=e.editorSrc)!=null?i:lo();if(!a){On();return}let l=document.createElement("script");l.src=a,l.async=!0,l.onerror=()=>On(),((c=document.head)!=null?c:document.documentElement).appendChild(l)}catch(a){}}var In="sentient-editor-load-notice";function On(){var e;try{if(typeof document=="undefined"||document.getElementById(In))return;let t=document.createElement("div");t.id=In,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{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)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function Dn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let i=r.indexOf(":"),c=i===-1?"":r.slice(0,i),a=i===-1?"":r.slice(i+1);if(!(!c||!a))if(a.includes("=")){let l={};for(let o of a.split(",")){let[s,u]=o.split("=");s&&u&&(l[s]=u)}Object.keys(l).length&&(n[c]=l)}else n[c]=a}return Object.keys(n).length?n:null}function Bn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var _n="sentient-persona-preview-banner";function Cn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(_n))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),i=document.createElement("div");i.id=_n,i.setAttribute("role","status"),Object.assign(i.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let a=document.createElement("button");a.type="button",a.textContent="Exit preview",Object.assign(a.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),a.addEventListener("click",()=>{try{let l=new URL(window.location.href);l.searchParams.delete("sentient_persona"),window.location.href=l.pathname+l.search+l.hash}catch(l){}}),i.appendChild(c),i.appendChild(a),((n=document.body)!=null?n:document.documentElement).appendChild(i)}catch(r){}}async function uo(e,t){var s,u,d,f,g,S,O,k,L,v;let n=(s=e.apiBase)!=null?s:"https://api.sentient-ui.com",i=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([m,A])=>({id:m,dims:A.dims}))},c=await Tn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(i)}).then(m=>m.ok?m.json():null).catch(()=>null),Ln);if(!c){Pe(e),Se(e,"persona preview: explain unavailable \u2014 page left as-is");return}let a=c;le=(d=a.slots)!=null?d:{},fe=(f=a.slotConfig)!=null?f:null,Te(a.palette);let l=(O=(S=(g=a.personaAttributes)==null?void 0:g.persona)!=null?S:a.persona)!=null?O:t,o=(L=(k=a.personaAttributes)==null?void 0:k.confidence)!=null?L:"high";N={persona:l,band:o},Ae(document),De=!0,Pe(e),a.recognized===!1?Cn(t,!0):Cn((v=a.personaDisplay)!=null?v:l)}function Pe(e){let t={goal(n,r){try{B==null||B.goal(n,r)}catch(i){}},componentGoal(n,r){try{B==null||B.componentGoal(n,r)}catch(i){}},grantConsent(){try{!B&&tt?(B=Ce({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),Re&&Re.length>0&&(F==null||F.teardown(),F=ft(Re,B,document,e.apiKey))):dt(e.apiKey),tt=!1}catch(n){}rt=!0;try{ao()}catch(n){}},revokeConsent(){try{re==null||re(),re=null,nt=null,U==null||U(),U=null,F==null||F.teardown(),F=null,rt=!1,tt=!0,B==null||B.destroy(),B=null}catch(n){}},reapply:wt,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=N==null?void 0:N.persona)!=null?n:null,band:(r=N==null?void 0:N.band)!=null?r:null,slots:le,matchCounts:yt(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of io.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function Mn(){var e,t,n,r,i,c,a;try{let l=Fe(window.sentient);if(!l)return;q=l,De=!1,ye=null,Te(null),rt=!1,tt=!1,Re=null;let o=typeof window!="undefined"?Pn(window.location.search):null;if(o){An(o);try{let x=new URL(window.location.href);x.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",x.pathname+x.search+x.hash)}catch(x){}}let s=o!=null?o:Sn();if(s){co(l,s),Pe(l),Se(l,"editor mode");return}let u=typeof window!="undefined"?Dn(window.location.search):null;if(u){le=u,N=null,Ae(document),kn(),Pe(l),Se(l,"preview mode",u);return}let d=typeof window!="undefined"?Bn(window.location.search):null;if(d){await uo(l,d),Se(l,"persona preview",d);return}let f=(e=l.registry)!=null?e:Object.keys(l.slots).length===0,g=He(l.apiKey);g&&(N={persona:g.persona,band:g.band},le=g.slots,g.slotConfig&&(fe=g.slotConfig),g.palette&&Te(g.palette),Ae(document,{contentAndOps:!1}),g.layoutOrder&&(ye=g.layoutOrder,ht(ye,document)));let S=Ce({apiKey:l.apiKey,context:l.context,consent:l.consent,preConsentBehavior:l.preConsentBehavior,debug:l.debug,persona:l.persona});B=S,Pe(l),kn();let O=Object.entries(l.slots).map(([x,K])=>({id:x,dims:K.dims})),k=mt!=="0.0.0-dev"?{v:mt}:{},L=Array.from(Rn(document).keys()),v=await Tn(S.decide(X(X(X({slots:O},k),L.length>=2?{sections:L}:{}),f?{slotsFrom:"registry"}:{})),Ln);if(!v){Se(l,"decide timeout/null \u2014 snapshot state stands",yt(l));return}let m=S.getPersona();m?N={persona:m.persona,band:m.band}:v.persona&&(N={persona:v.persona,band:"low"}),le=v.slots,f?fe=(t=v.slotConfig)!=null?t:null:v.slotConfig&&(fe=v.slotConfig),v.palette&&Te(v.palette);let A=[];if(so(l,Ae(document,{onApplied:(x,K,b)=>A.push({slotId:x,arm:K,el:b})})),ye=(n=v.layoutOrder)!=null?n:ye,ht(ye,document),De=!0,Re=(r=v.goals)!=null?r:null,v.goals&&v.goals.length>0&&l.consent!==!1&&B)try{F==null||F.teardown(),F=ft(v.goals,B,document,l.apiKey)}catch(x){}if(et=(i=v.sectionMap)!=null?i:null,Be()){vt();try{U==null||U(),U=Qe(B,l.apiKey,A)}catch(x){}}Se(l,"applied",{persona:N,slots:le,matches:yt(l)}),Oe(l.apiKey,X(X({v:1,persona:(c=N==null?void 0:N.persona)!=null?c:v.persona,band:(a=N==null?void 0:N.band)!=null?a:"low",slots:v.slots,layoutOrder:v.layoutOrder,savedAt:Date.now()},fe?{slotConfig:fe}:{}),v.palette?{palette:v.palette}:{}))}catch(l){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Mn())}return Gn(po);})();
1
+ "use strict";var SentientSnippet=(()=>{var Ue=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames,Ot=Object.getOwnPropertySymbols;var Tt=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Lt=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t)=>{for(var n in t||(t={}))Tt.call(t,n)&&Lt(e,n,t[n]);if(Ot)for(var n of Ot(t))Yn.call(t,n)&&Lt(e,n,t[n]);return e};var Rt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pt=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Xn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Tt.call(e,o)&&o!==n&&Ue(e,o,{get:()=>t[o],enumerable:!(r=Vn(t,o))||r.enumerable});return e};var Zn=e=>Xn(Ue({},"__esModule",{value:!0}),e);var Qn,er,tr,Dt,nr,rr,Bt,L,Le,ze=Rt(()=>{"use strict";Qn=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Bt=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))nr.call(t,n)&&Bt(e,n,t[n]);if(Dt)for(var n of Dt(t))rr.call(t,n)&&Bt(e,n,t[n]);return e},Le=(e,t)=>er(e,tr(t))});var Ft={};Pt(Ft,{LOCAL_ENGINE_AVAILABLE:()=>cr,createLocalEngine:()=>ur});function ur(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var cr,Wt=Rt(()=>{"use strict";cr=!1});var bo={};Pt(bo,{applyPersonaAttributes:()=>tt,applyRegistrySlots:()=>ot,applySlotArms:()=>rt,applySlotAttributes:()=>nt,parseEditorToken:()=>zn,parsePersonaPreview:()=>Wn,parsePreview:()=>Fn,parseSnippetConfig:()=>Xe,reapply:()=>It,run:()=>Hn,version:()=>At});ze();var or=["buyer","researcher","deal_seeker","browser"];var ir={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function qe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Mt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function ut(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return qe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[c,i]of Object.entries((n=e.dims)!=null?n:{}))o[c]=(r=i[0])!=null?r:"";return qe(o)}function Kt(e,t){var n,r;return e.dims!=null?(r=(n=Mt(t))!=null?n:Mt(ut(e)))!=null?r:{}:t}function ye(e){return e>=.3?e<.7?"medium":"high":"low"}var xo=or.map(e=>({key:e,displayName:ir[e]}));function Fe(e){return e?`_${e.slice(0,12)}`:""}var sr="_snt_uid";function Nt(e){return`${sr}${Fe(e)}`}var ar=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function $t(e){return lr(e)!==null}function lr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=ar.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function jt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Gt(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Ut(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function zt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function dt(e){return L(L(L({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function pt(e){let t=dt(e);return Kt(t,ut(t))}function qt(e){return typeof e=="string"?e:qe(e)}ze();function Xt(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var dr="_snt_uid",pr=365,We="_snt_uid";function fr(){return Xt()}function Ht(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function gr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function ft(e){try{return localStorage.getItem(e)}catch(t){return null}}function Vt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Jt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function mr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function hr(e){try{sessionStorage.removeItem(e)}catch(t){}}function yr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function vr(e){try{localStorage.removeItem(e)}catch(t){}}function wr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var br={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Zt(e){var t,n,r,o,c,i,a;if(typeof window=="undefined")return br;let l=Fe(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Nt(e==null?void 0:e.apiKey),s=`${We}${l}`,d=`${We}_tomb${l}`,y=((n=e==null?void 0:e.cookieTTLDays)!=null?n:pr)*24*60*60,m=w=>w&&w.length>0?w:null,g=()=>{var w,k;return l&&!(e!=null&&e.cookieName)&&ft(d)===null?(k=(w=m(Ht(dr)))!=null?w:m(ft(We)))!=null?k:m(Jt(We)):null},p=(a=(i=(c=(o=(r=m(Ht(u)))!=null?r:m(ft(s)))!=null?o:m(Jt(s)))!=null?c:g())!=null?i:m(e==null?void 0:e.ssrSessionId))!=null?a:fr();gr(u,p,y);let A=Vt(s,p),_=yr(u),I=A?!1:mr(s,p),v=!A&&!_&&!I;return{getSessionId:()=>p,isEphemeral:()=>v,destroy:()=>{p=null,wr(u),vr(s),hr(s),l&&!(e!=null&&e.cookieName)&&Vt(d,"1")}}}function Re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function yt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Qt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function xe(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let i=JSON.parse(c);return Array.isArray(i)?i:[]}catch(c){return[]}})(),o=new Map;for(let c of r)o.set(c.id,c);for(let c of e)o.set(c.id,c);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function en(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),c=r.filter(i=>!o.has(i.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var Sr=500,Ar=56*1024;function tn(e){return`_snt_retry_${e.slice(0,12)}`}var xr={push:()=>{},flush:()=>{},destroy:()=>{}};function Er(e){var t,n,r;if(typeof window=="undefined")return xr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,a=e.ingestUrl,l=e.apiKey,u=tn(l),s=[],d=new Set,y=[],m=f=>{for(let b of f)g.delete(b),!d.has(b)&&(d.add(b),y.push(b));for(;y.length>Sr;){let b=y.shift();b&&d.delete(b)}en(f,u)},g=new Set,p=()=>{for(;s.length>i;){let f=s.shift();f&&g.delete(f.id)}},A=f=>{d.has(f.id)||g.has(f.id)||(g.add(f.id),s.push(f),p())},_=f=>{for(let b of f)d.has(b.id)||(g.add(b.id),s.push(b));p()},I=Qt(u,i);for(let f of I)A(f);let v=0,w=0,k=(f,b=!0)=>{if(f.length===0)return;let C=JSON.stringify(f),W=f.map(me=>me.id),G;try{G=fetch(a,{method:"POST",keepalive:!0,body:C,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(me){xe(f,i,u),_(f),w++,v=Date.now()+Re(w);return}let _e=me=>{if(yt(me)!=="retry"){if(!me.ok&&b){let re=f.filter(oe=>oe.eventType!=="pageview");if(re.length>0&&re.length<f.length){m(f.filter(oe=>oe.eventType==="pageview").map(oe=>oe.id)),k(re,!1);return}}m(W),w=0,v=0;return}xe(f,i,u),_(f),w++,v=Date.now()+Re(w)};G instanceof Promise?G.then(_e).catch(()=>{xe(f,i,u),_(f),w++,v=Date.now()+Re(w)}):_e(G)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,E=f=>N?N.encode(f).length:f.length,P=f=>{let b=[],C=2;for(let W of f){let G=E(JSON.stringify(W))+1;if(b.length>0&&C+G>Ar||b.length>=c)break;b.push(W),C+=G}return b},j=()=>{try{if(Date.now()<v)return;for(;s.length>0&&!(Date.now()<v);){let f=s.filter(C=>!d.has(C.id));if(s.length=0,f.length===0)break;let b=P(f);if(b.length===0)break;b.length<f.length&&s.push(...f.slice(b.length)),k(b)}}catch(f){}},O=!0,X=null;X=setInterval(()=>{O&&j()},o);let ee=()=>{document.visibilityState==="hidden"&&j()},x=()=>{j()};return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",x),{push(f){A(f),s.length>=c&&j()},flush:j,destroy(){O=!1,X!==null&&(clearInterval(X),X=null),document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",x),j()}}}var kr=200;function nn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ir={send:()=>{},flush:()=>{},destroy:()=>{}};function _r(e){var t,n,r;if(typeof window=="undefined")return Ir;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,a=nn(e.apiKey),l=[],u=new Set,s=new Set,d=[],y=0,m=0,g=!1,p=E=>{for(u.delete(E.id),s.has(E.id)||(s.add(E.id),d.push(E.id));d.length>kr;){let P=d.shift();P&&s.delete(P)}en([E.id],a)},A=E=>{xe([E],c,a),!s.has(E.id)&&!u.has(E.id)&&(u.add(E.id),l.push(E)),Date.now()>=y&&(m++,y=Date.now()+Re(m))},_=E=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:E.body,headers:e.headers})}catch(O){A(E);return}let j=O=>{var X;let ee=yt(O);if(ee==="retry"){A(E);return}ee==="dropped"&&((X=e.onDrop)==null||X.call(e,E,O.status)),p(E),m=0,y=0};P instanceof Promise?P.then(j).catch(()=>A(E)):j(P)},I=()=>{try{if(g||Date.now()<y)return;let E=0;for(;l.length>0&&E<i&&!(Date.now()<y);){let P=l.shift();u.delete(P.id),!s.has(P.id)&&(E++,_(P))}}catch(E){}},v=Qt(a,c);for(let E of v)u.has(E.id)||(u.add(E.id),l.push(E));v.length>0&&xe(v,c,a);let w=setInterval(I,o),k=()=>{document.visibilityState==="hidden"&&I()},N=()=>I();return document.addEventListener("visibilitychange",k),window.addEventListener("pagehide",N),{send(E){if(!g&&!(s.has(E.id)||u.has(E.id))){if(Date.now()<y){xe([E],c,a),u.add(E.id),l.push(E);return}_(E)}},flush:I,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",k),window.removeEventListener("pagehide",N),I(),g=!0}}}var Cr=1800*1e3;function He(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Or(e=Cr,t){let n=new Map,r=`_snt_asgn${Fe(t)}_`,o=(l,u)=>`${r}${encodeURIComponent(l)}:${encodeURIComponent(u)}`,c=l=>{let u=l.slice(r.length),s=u.indexOf(":");if(s<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,s)),segment:decodeURIComponent(u.slice(s+1))}}catch(d){return null}},i=()=>{try{let l=[];for(let u=0;u<localStorage.length;u++){let s=localStorage.key(u);s!=null&&s.startsWith(r)&&l.push(s)}return l}catch(l){return[]}},a=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of i())try{let u=localStorage.getItem(l);if(!u)continue;let s=JSON.parse(u);if(a(s)){localStorage.removeItem(l);continue}let d=c(l);if(!d)continue;n.set(He(d.componentId,d.segment),s)}catch(u){}})(),{get(l,u){let s=n.get(He(l,u));return s?a(s)?(n.delete(He(l,u)),null):s:null},set(l,u,s){let d=He(l,u);n.set(d,s);try{localStorage.setItem(o(l,u),JSON.stringify(s))}catch(y){}},clear(){n.clear();for(let l of i())try{localStorage.removeItem(l)}catch(u){}}}}var Ye="_snt_snap:",Lr=["low","medium","high"];function Pe(e){try{let t=localStorage.getItem(Ye+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Lr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function De(e,t){try{localStorage.setItem(Ye+e,JSON.stringify(t))}catch(n){}}var mt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",rn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Yt=!1,Ve=!1;function Tr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Rr(e){var t;let n=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Tr(),c=Promise.resolve().then(()=>(Wt(),Ft)).then(s=>{let d=s;return d.LOCAL_ENGINE_AVAILABLE?(Yt||(Yt=!0,console.info(rn)),d):(Ve||(Ve=!0,console.error(mt)),null)}).catch(()=>(Ve||(Ve=!0,console.error(mt)),null)),i=null,a={low:.15,medium:.5,high:.85},l=(()=>{var s;if(e.initialPersona)return L({},e.initialPersona);let d=Pe(e.apiKey||"local");return d?{persona:d.persona,confidence:(s=a[d.band])!=null?s:.15}:null})();function u(s){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=s.persona,d.dataset.sentientConfidence=ye(s.confidence))}return{isLocal:!0,async decide(s){var d,y,m;let g=await c;if(!g)return null;let p=g.createLocalEngine({sessionId:r,forcedPersona:o}).decide(s);return i=Le(L({},p),{layoutOrder:(y=(d=p.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?y:null,slots:L(L({},(m=i==null?void 0:i.slots)!=null?m:{}),p.slots)}),De(e.apiKey||"local",{v:1,persona:i.persona,band:ye(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(p),p},getSlotResult(s){var d,y,m;return(m=(y=i==null?void 0:i.slots[s])!=null?y:(d=e.initialSlots)==null?void 0:d[s])!=null?m:null},getPersona(){let s=i!=null?i:l;return s?{persona:s.persona,confidence:s.confidence,band:ye(s.confidence)}:null},async assign(s,d){var y;let m=await c;return!m||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(y=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:s,variantIds:d}]}).assignments[s])!=null?y:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Be(e,t,n,r){let o=[];{let c=!1,i=[],a=()=>{if(c)return;let l=Date.now();for(i.push(l);i.length>0&&l-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",a),o.push(()=>t.removeEventListener("click",a))}{let c=!1,i=a=>{if(c||!(a.target instanceof Node)||!t.contains(a.target)&&t!==a.target)return;c=!0;let l=typeof window!="undefined"?window.getSelection():null,u=l?l.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,a=null,l=()=>{a!==null&&(clearTimeout(a),a=null)},u=()=>{c||!i||(l(),a=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},s=()=>{l(),u()},d=m=>{for(let g of m)i=g.intersectionRatio>.3,i?u():l()},y=new IntersectionObserver(d,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",s,{passive:!0}),o.push(()=>{y.disconnect(),window.removeEventListener("scroll",s),l()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),a=()=>{if(c||document.visibilityState!=="hidden")return;let l=Date.now()-i;l<15e3&&(c=!0,e("tab_loss",{timeOnPage:l}))};document.addEventListener("visibilitychange",a),o.push(()=>document.removeEventListener("visibilitychange",a))}return()=>{for(let c of o)c()}}var on="https://api.sentient-ui.com/v1/events",Q=new Map,sn=null;function Pr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Dr=3;function gt(){return Xt()}function Je(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Br(){let e=new WeakMap,t=new Map,n=!1,r=(a,l,u)=>{let s=a.get(l);return u===null?s?!0:(a.set(l,new Set),!1):s?s.has(u)?!0:(s.add(u),!1):(a.set(l,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{if(!o)return;let a=window.event;return typeof Event=="function"&&a instanceof Event?a:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let a=!1,l=()=>{a||(a=!0,n=!1,t.clear())};if(setTimeout(l,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),l()},u.port2.postMessage(0)}};return{firedBefore(a,l){let u=c();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,a,l)}let s=r(t,a,l);return!s&&!n&&(n=!0,i()),s}}}var an=new Set;function Mr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let u=Je();!u||u===c||(c=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},a=[];for(let u of["pushState","replaceState"]){let s=r[u],d=function(...y){let m=s.apply(this,y);return i(),m};r[u]=d,a.push([u,s,d])}window.addEventListener("popstate",i);let l=Je();return l&&an.has(`${t}:${l}`)?c=l:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,s,d]of a)r[u]===d&&(r[u]=s)}}}var Te={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Kr(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function ln(e){return e.replace(/\/events\/?$/,"")}function ve(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function vt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:sn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=Q.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:c,reinit:i}=r;if(!c){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&ve())return;let a=(i!=null?i:Me)(Le(L({},o),{consent:!0}));c(a);let l=(t=Q.get(n))==null?void 0:t.dispose;Q.set(n,{config:Le(L({},o),{consent:!0}),upgrade:null,dispose:l})}function Nr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=ln((t=e.ingestUrl)!=null?t:on),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(s,d,y){if(!n)return Promise.resolve(null);let m=c.get(s);return m?Promise.resolve(m):ht(i,s,async()=>{try{let g=new URLSearchParams({componentId:s});for(let _ of d!=null?d:[])g.append("variantIds[]",_);let p=await fetch(`${r}/winner?${g.toString()}`,{headers:o});if(!p.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let A={variantId:(await p.json()).variantId,assignmentTtlMs:0};return c.set(s,A),A}catch(g){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:s=>a.track(s),goal:((s,d,y,m)=>a.goal(s,d,y,m)),componentGoal:(s,d,y)=>a.componentGoal(s,d,y),identify:s=>a.identify(s),getAssignment:(s,d)=>a.getAssignment(s,d),assign:(s,d,y,m)=>a.assign(s,d,y,m),decide:s=>a.decide(s),getSlotResult:s=>a.getSlotResult(s),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function u(s){a=s}return{proxy:l,setInner:u}}function ht(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Me(e){var t,n,r,o,c,i,a,l,u;if(typeof window=="undefined")return Te;sn=e.apiKey||"local";let s=Q.get(e.apiKey||"local");if(s!=null&&s.dispose)try{s.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&ve(),y=e.consent===!1||d,m=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!m&&e.localMode!==!1)return Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?Te:Rr(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Te;let{proxy:h,setInner:S}=Nr(e);return Q.set(e.apiKey,{config:e,upgrade:d?null:S}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Te;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Te;let g=(t=e.ingestUrl)!=null?t:on,p=Date.now(),A=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),_=Or(void 0,e.apiKey),I=Er({ingestUrl:g,apiKey:e.apiKey}),v=ln(g),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},k=new Set,N=_r({url:`${v}/goals`,apiKey:e.apiKey,headers:w,onDrop:(h,S)=>{if(!e.debug){if(k.has(S))return;k.add(S)}console.warn(`[sentient] goal dropped (HTTP ${S}) \u2014 this will not be retried. `+(S===400?"The session was not found: call init() and let the session upsert complete before firing goals.":S===401||S===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),E=jt((n=navigator.userAgent)!=null?n:""),P=window.location.origin,j=Gt((r=document.referrer)!=null?r:"",P),O=(o=e.sessionSegment)!=null?o:`${E}:${j}`,X=new Map,ee=new Map,x=new Map,f=null,b=h=>{for(let S of h)x.has(S.id)||x.set(S.id,pt(S))};if(e.initialSlots)for(let[h,S]of Object.entries(e.initialSlots))x.set(h,S);let C=Pe(e.apiKey);if(C)for(let[h,S]of Object.entries(C.slots))x.has(h)||x.set(h,S);let W={low:.15,medium:.5,high:.85};if(e.initialPersona)f=L({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?f={persona:h.sentientPersona,confidence:(i=W[(c=h.sentientConfidence)!=null?c:"low"])!=null?i:.15}:C&&(f={persona:C.persona,confidence:(a=W[C.band])!=null?a:.15})}if(e.initialAssignments)for(let[h,S]of Object.entries(e.initialAssignments))_.set(h,O,{variantId:S,assignedAt:Date.now(),segment:O,confidence:1});let G=Promise.resolve(),_e=A.getSessionId();if(_e){let h=Ut((l=document.referrer)!=null?l:""),S=L(L(L({sessionId:_e,deviceClass:E,trafficSource:j,referrerDomain:h,utmParams:Kr(),timeOfDay:zt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||$t((u=navigator.userAgent)!=null?u:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let z=0;;z++){try{let M=await fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(S),headers:w});if(M.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(M.ok||yt(M)==="dropped")return}catch(M){}if(z>=Dr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(M=>setTimeout(M,Re(z+1)))}};try{G=D()}catch(z){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:I});let me=Br(),re=null,oe=!1,Ae={goal(h,S={},D=1,z=0){var M,B,H,V,J,he,ce;let Ce=A.getSessionId();if(!Ce)return;let Y=Pr(S)?S:{metadata:S},Oe=[h,(M=Y.externalId)!=null?M:"",(B=Y.stepIndex)!=null?B:z,(H=Y.weight)!=null?H:D].join("\0"),T=Y.value!==void 0?`${Y.value}\0${(V=Y.currency)!=null?V:""}`:null;if(me.firedBefore(Oe,T)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let ie=gt(),Ge={sessionId:Ce,name:h,metadata:(J=Y.metadata)!=null?J:{},weight:(he=Y.weight)!=null?he:D,stepIndex:(ce=Y.stepIndex)!=null?ce:z,goalId:ie,value:Y.value,currency:Y.currency,externalId:Y.externalId};e.debug&&console.log("[sentient] goal",Ge);let q={id:ie,body:JSON.stringify(Ge)};G.then(()=>N.send(q))},componentGoal(h,S,D){var z,M,B;let H=A.getSessionId();if(!H)return;let V=_.get(h,O),J=V?null:(z=x.get(h))!=null?z:null;if(!V&&J===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let he=V?V.variantId:qt(J),ce={id:gt(),sessionId:H,projectId:e.apiKey,componentId:h,variantId:he,eventType:"goal_achieved",goalType:S,payload:L({reward:(M=D==null?void 0:D.reward)!=null?M:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(B=D==null?void 0:D.metadata)!=null?B:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:Je()};e.debug&&console.log("[sentient] componentGoal",ce),G.then(()=>I.push(ce))},identify(h){let S=A.getSessionId();S&&G.then(()=>{fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:S,userId:h,ephemeral:A.isEphemeral()}),headers:w}).catch(()=>{})})},track(h){let S=A.getSessionId();if(!S)return;let D=Le(L({path:Je()},h),{id:gt(),sessionId:S,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",D),G.then(()=>I.push(D))},getAssignment(h,S){return _.get(h,S)},async assign(h,S,D,z){let M=A.getSessionId();if(!M)return null;let B=_.get(h,O);if(B&&(S!=null&&S.length||B.content!==void 0)){let H=B.ttlMs&&B.ttlMs>0?Math.max(0,B.assignedAt+B.ttlMs-Date.now()):0;return{variantId:B.variantId,assignmentTtlMs:H,content:B.content}}return ht(X,h,async()=>{await G;try{let H={sessionId:M,componentId:h,variantIds:S};z!==void 0?H.agentDataByVariant=z:D!==void 0&&(H.agentData=D);let V=await fetch(`${v}/assign`,{method:"POST",body:JSON.stringify(H),headers:w});if(!V.ok)return null;let J=await V.json();return _.set(h,O,L({variantId:J.variantId,assignedAt:Date.now(),segment:O,confidence:1,content:J.content},J.assignmentTtlMs&&J.assignmentTtlMs>0?{ttlMs:J.assignmentTtlMs}:{})),J}catch(H){return null}})},async decide(h){var S,D;let z=A.getSessionId();if(!z)return null;let M=(S=h.slots)!=null?S:[],B={sessionId:z};h.sections&&h.sections.length>0&&(B.sections=h.sections.map(V=>({id:V}))),B.components=(D=h.components)!=null?D:[],M.length>0&&(B.slots=M.map(dt)),h.slotsFrom==="registry"&&(B.slotsFrom="registry"),h.v&&(B.v=h.v),e.persona&&(B.persona=e.persona);let H=JSON.stringify(B);return ht(ee,H,async()=>{var V,J,he,ce,Ce,Y;await G;try{let Oe=await fetch(`${v}/decide`,{method:"POST",body:H,headers:w});if(!Oe.ok)return b(M),null;let T=await Oe.json(),ie={};for(let q of M){let ue=(V=T.slots)==null?void 0:V[q.id];if(ue!==void 0){ie[q.id]=ue,x.set(q.id,ue);continue}let _t=x.get(q.id);if(_t!==void 0)ie[q.id]=_t;else{let Ct=pt(q);ie[q.id]=Ct,x.set(q.id,Ct)}}if(T.slots)for(let[q,ue]of Object.entries(T.slots))q in ie||(ie[q]=ue,x.set(q,ue));let Ge=f!=null&&f.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&Ge)?f={persona:T.persona,confidence:(J=T.confidence)!=null?J:0}:f||(f={persona:"unknown",confidence:0});for(let[q,ue]of Object.entries((he=T.assignments)!=null?he:{}))_.set(q,O,{variantId:ue,assignedAt:Date.now(),segment:O,confidence:1});return De(e.apiKey,L(L({v:1,persona:f.persona,band:ye(f.confidence),slots:Object.fromEntries(x),layoutOrder:(ce=T.layoutOrder)!=null?ce:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.palette?{palette:T.palette}:{})),L(L(L(L({layoutOrder:(Ce=T.layoutOrder)!=null?Ce:null,assignments:(Y=T.assignments)!=null?Y:{},slots:ie,persona:f.persona,confidence:f.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(Oe){return b(M),null}})},getSlotResult(h){var S;return(S=x.get(h))!=null?S:null},getPersona(){return f?{persona:f.persona,confidence:f.confidence,band:ye(f.confidence)}:null},async fetchWeights(){var h;try{let S=await fetch(`${v}/weights`,{headers:w});return S.ok?(h=(await S.json()).components)!=null?h:[]:[]}catch(S){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),A.destroy(),_.clear(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey);try{localStorage.removeItem(Ye+e.apiKey),localStorage.removeItem(tn(e.apiKey)),localStorage.removeItem(nn(e.apiKey))}catch(S){}e.debug&&console.log("[sentient] destroyed")}};if(Q.set(e.apiKey,{config:e,upgrade:null,dispose:Ae.dispose}),re=Mr(Ae,e.apiKey,h=>{G.then(()=>{oe||an.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=Ae)}return Ae}var cn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],$r=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],jr=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function Gr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function un(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of $r)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of jr)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function dn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Gr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function pn(e){return un(dn(e)).type}ze();var Ur="section, header, footer, nav, main > div, [data-sentient-section]",zr=2e4;function qr(e){let t=Array.from(e.querySelectorAll(Ur)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function Fr(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var fn=()=>{};function gn(e,t){var n,r,o,c,i,a,l,u,s;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||ve()||!t.apiKey||!t.apiKey.startsWith("pk_"))return fn;let y=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),m=qr(d);if(m.length===0)return fn;let g=new Map,p=new Map,A=new Map;for(let x of m){let f=x.getAttribute("data-sentient-type"),b=f&&cn.includes(f)?f:null,C=(c=b!=null?b:(o=t.typeOf)==null?void 0:o.call(t,x))!=null?c:pn(x),W=`nc-${C}`;g.set(x,W),p.set(W,C),b?A.set(W,"markup"):A.has(W)||A.set(W,"auto")}let _=(u=(l=(a=(i=d.defaultView)!=null?i:typeof window!="undefined"?window:void 0)==null?void 0:a.location)==null?void 0:l.pathname)!=null?u:"/";Fr(t.apiKey,y,_,[...p.entries()].map(([x,f])=>{var b;return{componentId:x,semanticType:f,source:(b=A.get(x))!=null?b:"auto"}}));let I=new Map,v=x=>{let f=I.get(x);return f||(f={ms:0,scroll:0,enterAt:null,intersecting:!1},I.set(x,f)),f},w=new IntersectionObserver(x=>{for(let f of x){let b=g.get(f.target);if(!b)continue;let C=v(b);f.isIntersecting?(C.intersecting=!0,C.enterAt=Date.now(),f.intersectionRatio>C.scroll&&(C.scroll=f.intersectionRatio)):(C.intersecting=!1,C.enterAt!=null&&(C.ms+=Date.now()-C.enterAt,C.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let x of g.keys())w.observe(x);let k=()=>{let x=Date.now();for(let[f,b]of I)if(b.enterAt!=null&&(b.ms+=x-b.enterAt,b.enterAt=null),!(b.ms<=0)){try{e.track({projectId:t.apiKey,componentId:f,eventType:"dwell",payload:{dwell_time:Math.round(b.ms),scroll_depth:Number(b.scroll.toFixed(2))}})}catch(C){}b.ms=0}},N=()=>{if(d.hidden)k();else{let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)}},E=!1,P=x=>{if(k(),x!=null&&x.persisted){E=!0;return}try{w.disconnect()}catch(f){}},j=x=>{if(!(x!=null&&x.persisted)||!E)return;E=!1;let f=Date.now();for(let b of I.values())b.enterAt=b.intersecting&&!d.hidden?f:null};d.addEventListener("visibilitychange",N);let O=(s=d.defaultView)!=null?s:typeof window!="undefined"?window:void 0;O==null||O.addEventListener("pagehide",P),O==null||O.addEventListener("pageshow",j);let X=setInterval(()=>{if(d.hidden||E)return;k();let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)},zr),ee=[];return t.microSignals&&[...g.entries()].forEach(([x,f],b)=>{ee.push(Be((C,W={})=>{try{e.track({projectId:t.apiKey,componentId:f,eventType:"micro_signal",payload:L({signalType:C},W)})}catch(G){}},x,void 0,{tabLoss:b===0}))}),()=>{k(),clearInterval(X),d.removeEventListener("visibilitychange",N),O==null||O.removeEventListener("pagehide",P),O==null||O.removeEventListener("pageshow",j);for(let x of ee)x();try{w.disconnect()}catch(x){}}}var Wr=["landing","ecommerce","saas","marketplace"];function Hr(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(c=>typeof c=="string"))return null;n[r]=o}return n}function Vr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Jr(e){try{return e()}catch(t){return}}function Xe(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=Wr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let l=a,u=Hr(l.dims);if(!u||l.target!==void 0&&typeof l.target!="string")continue;let s=l.arms!==void 0?Vr(l.arms):null,d={dims:u};typeof l.target=="string"&&(d.target=l.target),s&&(d.arms=s),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?Jr(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),Array.isArray(t.sections)){let i=t.sections.filter(a=>typeof a=="string"&&a.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function Ze(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Yr(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:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function mn(e,t){return!!(e!=null&&e.urlMatch)&&!Ze(t).includes(e.urlMatch)}var Xr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var o;if(e.urlMatch&&!Ze(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Xr.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Yr(r,e.fingerprint)?null:r}var hn={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"},Zr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function yn(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(!Zr.test((r=n[1])!=null?r:""))return!1;return!0}var vn=/^https:\/\//i,wn=new Map,pe=null;function Qr(e){return e.replace(/["\\]/g,"\\$&")}function eo(e){var t;(!pe||!pe.isConnected)&&(pe=e.querySelector("style[data-sentient-ops]"),pe||(pe=e.createElement("style"),pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(pe))),pe.textContent=[...wn.entries()].map(([n,r])=>`[data-snt-e="${Qr(n)}"]{${r}}`).join(`
2
+ `)}function bn(e,t,n,r){var a;let o=!1,c=(a=t.moveBefore)!=null?a:t.moveAfter;if(c){let l=de(c,r);!l||l===e||l.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&vn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&vn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[l,u]of Object.entries(t.style)){let s=hn[l];s&&typeof u=="string"&&yn(u)&&i.push(`${s}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),wn.set(n,i.join(";")),eo(r)),{anchorMiss:o}}var Ke="data-sentient-block-arm",te=null;function Ne(e){te=e!=null?e:null}var ae="data-sentient-blocks-hid",Qe={none:"0",sm:"8px",md:"16px",lg:"24px"},wt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Sn={sm:"0.875em",md:"1em",lg:"1.25em"},to={sm:"1.25em",md:"1.5em",lg:"2em"},no={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},An={sm:"8px",md:"16px",lg:"32px"},ro={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},oo={normal:"400",medium:"500",bold:"700"};function se(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function xn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function En(e,t){var n,r,o,c,i,a,l,u,s,d,y,m;try{switch(e.type){case"stack":case"grid":{let g=t.createElement("div");if(e.type==="stack"){let p=e;se(g,{display:"flex","flex-direction":p.direction,gap:(r=Qe[(n=p.gap)!=null?n:"md"])!=null?r:Qe.md,"align-items":p.align?wt[p.align]:void 0,"justify-content":p.justify?wt[p.justify]:void 0,"flex-wrap":p.wrap?"wrap":void 0})}else{let p=e,A=(c=Qe[(o=p.gap)!=null?o:"md"])!=null?c:Qe.md;se(g,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${p.columns-1} * ${A}) / ${p.columns})), 1fr))`,gap:A,"align-items":p.align?wt[p.align]:void 0})}for(let p of(i=e.children)!=null?i:[]){let A=En(p,t);A&&g.appendChild(A)}return g}case"text":{let g=t.createElement("p");return g.textContent=e.value,se(g,Z({margin:"0","font-size":e.size?Sn[e.size]:void 0,"font-weight":e.weight?oo[e.weight]:void 0,"text-align":e.align},xn(e.tone)))}case"heading":{let g=t.createElement(`h${e.level}`);return g.textContent=e.value,se(g,{margin:"0","font-size":to[(a=e.size)!=null?a:"md"],"text-align":e.align})}case"button":{let g=t.createElement("a");g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag);let p=(l=e.emphasis)!=null?l:"primary";return se(g,{display:"inline-block",padding:no[(u=e.size)!=null?u:"md"],"border-radius":(s=te==null?void 0:te.radius)!=null?s:"8px",font:"inherit","font-size":e.size?Sn[e.size]:void 0,"text-decoration":p==="ghost"?"underline":"none",cursor:"pointer",background:p==="primary"?(d=te==null?void 0:te.primaryBg)!=null?d:"#111827":"transparent",color:p==="primary"?(y=te==null?void 0:te.primaryText)!=null?y:"#ffffff":"inherit",border:p==="secondary"?"1px solid currentColor":"none"})}case"link":{let g=t.createElement("a");return g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag),se(g,{color:"inherit","text-decoration":"underline"})}case"image":{let g=t.createElement("img");return g.src=e.src,g.alt=e.alt,se(g,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?ro[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let g=t.createElement("span");return g.textContent=e.value,se(g,Z({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},xn(e.tone)))}case"spacer":return se(t.createElement("div"),{height:(m=An[e.size])!=null?m:An.md});default:return null}}catch(g){return null}}function kn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke);a!==null&&(t[a]===void 0?i.remove():o.add(a))}for(let[i,a]of Object.entries(t)){if(o.has(i))continue;let l=En(a,r);if(!l)continue;let u=r.createElement("div");u.setAttribute(Ke,i),u.style.display="none",u.appendChild(l),e.appendChild(u)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke),l=i;a!==null?l.style.display=c&&a===n?"":"none":c?l.hasAttribute(ae)||(l.setAttribute(ae,l.style.display),l.style.display="none"):l.hasAttribute(ae)&&(l.style.display=l.getAttribute(ae),l.removeAttribute(ae))}}catch(o){}}function io(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ke)!==null){n.remove();continue}n.hasAttribute(ae)&&(n.style.display=n.getAttribute(ae),n.removeAttribute(ae))}}catch(t){}}function et(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ke}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ae}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||io(r)}catch(n){}}function bt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function tt(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function nt(e,t,n){var r;for(let[o,c]of Object.entries(t)){let i=e[o];if(!i||typeof i=="string")continue;let a=bt(c.target,n);for(let l of a)for(let[u,s]of Object.entries(i))(r=c.dims[u])!=null&&r.includes(s)&&l.setAttribute(`data-${u}`,s)}}function rt(e,t,n){for(let[r,o]of Object.entries(t)){let c=e[r];if(typeof c!="string"||!o.arms||!o.arms.includes(c))continue;let i=bt(o.target,n);for(let a of i)a.setAttribute("data-sentient-arm",c)}}function ot(e,t,n,r){var a,l;let o=new Set,c=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,i=[];for(let[u,s]of Object.entries(t)){if(mn(s.locator,n))continue;let d;if(s.locator){let m=de(s.locator,n);d=m?[m]:[]}else d=bt(s.target,n);(s.locator||s.target)&&d.length===0&&i.push(u);let y=e[u];for(let m of d){if(y!==void 0)if(typeof y=="string")m.setAttribute("data-sentient-arm",y),c&&((l=r==null?void 0:r.onApplied)==null||l.call(r,u,y,m));else for(let[g,p]of Object.entries(y))m.setAttribute(`data-${g}`,p);s.blocks&&!ao(n)&&(kn(m,s.blocks,typeof y=="string"?y:void 0,n),o.add(m)),c&&(typeof s.content=="string"&&(m.textContent=s.content),s.ops&&bn(m,s.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return et(n,o),i}var so=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function ao(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:so.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var lo=800;function it(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},a)=>{r.push(Be((y,m={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:Z({signalType:y},m)})}catch(g){}},i,void 0,{tabLoss:a===0}));let l=null,u=0,s=()=>{u=Date.now(),l=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(y){}l=null},lo)},d=()=>{l!==null&&(clearTimeout(l),l=null)};i.addEventListener("mouseenter",s),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",s),i.removeEventListener("mouseleave",d),l!==null&&clearTimeout(l)})}),()=>{for(let o of r)o()}}function co(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function _n(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var uo="_snt_fired_goals";function Cn(e,t){try{e==null||e.sessionStorage.removeItem(_n(t)),e==null||e.sessionStorage.removeItem(uo)}catch(n){}}function In(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function po(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function fo(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function st(e,t,n,r){var _,I;let o=(_=n.defaultView)!=null?_:typeof window!="undefined"?window:null,c=_n(r),i=po(o,c),a=v=>{let w=In(v);if(!i.has(w))try{v.slotId?t.componentGoal(v.slotId,v.goalId):t.goal(v.goalId),i.add(w),fo(o,c,i)}catch(k){}},l=e.filter(v=>v.event==="click"),u=e.filter(v=>v.event==="form_submit"),s=e.filter(v=>v.event==="url_reached"),d=e.filter(v=>v.event==="scroll_depth"),y=(v,w)=>{if(!v.locator)return!1;let k=de(v.locator,n);return!!k&&(k===w||k.contains(w))},m=v=>{let w=v.target;if(!(!w||typeof w.closest!="function"))for(let k of l)y(k,w)&&a(k)},g=v=>{let w=v.target;if(w)for(let k of u)y(k,w)&&a(k)},p=()=>{if(s.length===0)return;let v=Ze(n);for(let w of s)w.urlPattern&&co(w.urlPattern,v)&&a(w)},A=()=>{var k;let v=n.documentElement,w=v.scrollHeight>0?(v.scrollTop+v.clientHeight)/v.scrollHeight:0;for(let N of d)w>=((k=N.threshold)!=null?k:.75)&&a(N);d.every(N=>i.has(In(N)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",m,!0),n.addEventListener("submit",g,!0),(I=n.defaultView)==null||I.addEventListener("popstate",p),p(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:p,teardown:()=>{var v;n.removeEventListener("click",m,!0),n.removeEventListener("submit",g,!0),(v=n.defaultView)==null||v.removeEventListener("popstate",p),d.length>0&&n.removeEventListener("scroll",A)}}}var On="__snt_editor_token";function Ln(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(On):null}catch(e){return null}}function Tn(e){try{sessionStorage.setItem(On,e)}catch(t){}}var At="0.18.0",$n=5e3,go=50,jn=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),F=null,R=null,le={},ge=null,$=null,fe=null,U=null,ne=null,K=null,we=null,Rn=!1,St=null,at=null,ct=null,Ee=!1,$e=!1,Se=!1;function Gn(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function be(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function ke(e,t){return F?(F.personaAttributes&&K&&tt(K.persona,K.band,e),nt(le,F.slots,e),rt(le,F.slots,e),ge?ot(le,ge,e,t):(et(e,new Set),[])):[]}function Un(e){var n;let t=new Map;for(let r of(n=F==null?void 0:F.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function xt(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Un(t);if(n.size!==e.length)return;let r=[];for(let i of e){let a=n.get(i);if(!a)return;r.push(a)}let o=r[0].parentNode;if(!o||!r.every(i=>i.parentNode===o))return;let c=r.slice().sort((i,a)=>i.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let i=0;i<r.length;i++){let a=r[i];c[i]!==a&&(o.insertBefore(a,c[i]),c.splice(c.indexOf(a),1),c.splice(i,0,a))}}catch(n){}}function mo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(F&&R&&F.sectionCapture!==!1&&(F.consent!==!1||$e)&&!ve())}function ho(){if(!R||!F||!Ie()||ne)return;let e=[];ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),kt();try{U==null||U(),U=it(R,F.apiKey,e)}catch(t){}}function kt(){if(typeof document=="undefined"||!Ie())return;let e;try{if(at&&at.length>0){let t=new Map;for(let n of at){if(n.urlMatch!==window.location.pathname)continue;let r=de(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ne=gn(R,Z({apiKey:F.apiKey,apiBase:F.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),ct=window.location.pathname}catch(t){}}function It(){try{let e=[];if(U==null||U(),U=null,ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),xt(we,document),e.length>0&&Ie())try{U=it(R,F.apiKey,e)}catch(t){}try{typeof window!="undefined"&&ct!==null&&window.location.pathname!==ct&&Ie()&&(ne==null||ne(),ne=null,kt())}catch(t){}}catch(e){}}function Pn(){St===null&&(St=setTimeout(()=>{St=null,It();try{$==null||$.checkUrl()}catch(e){}},go))}function Et(){if(!(Rn||typeof window=="undefined"||typeof history=="undefined")){Rn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,c){let i=n.call(this,r,o,c!=null?c:null);return Pn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Pn)}catch(e){}}}function lt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function zn(e){return new URLSearchParams(e).get("sentient_editor")}function yo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function vo(e,t){var n,r,o,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let l=document.createElement("meta");l.name="referrer",l.content="no-referrer",l.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(l)}catch(l){}let i=(o=e.editorSrc)!=null?o:yo();if(!i){Bn();return}let a=document.createElement("script");a.src=i,a.async=!0,a.onerror=()=>Bn(),((c=document.head)!=null?c:document.documentElement).appendChild(a)}catch(i){}}var Dn="sentient-editor-load-notice",qn={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Bn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Dn))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Dn,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,qn,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function Fn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),c=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!c||!i))if(i.includes("=")){let a={};for(let l of i.split(",")){let[u,s]=l.split("=");u&&s&&(a[u]=s)}Object.keys(a).length&&(n[c]=a)}else n[c]=i}return Object.keys(n).length?n:null}function Wn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Mn="sentient-persona-preview-banner";function Kn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Mn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Mn,o.setAttribute("role","status"),Object.assign(o.style,qn,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let a=new URL(window.location.href);a.searchParams.delete("sentient_persona"),window.location.href=a.pathname+a.search+a.hash}catch(a){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function wo(e,t){var u,s,d,y,m,g,p,A,_,I;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((s=e.registry)!=null?s:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([v,w])=>({id:v,dims:w.dims}))},c=await Gn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(v=>v.ok?v.json():null).catch(()=>null),$n);if(!c){je(e),be(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;le=(d=i.slots)!=null?d:{},ge=(y=i.slotConfig)!=null?y:null,Ne(i.palette);let a=(p=(g=(m=i.personaAttributes)==null?void 0:m.persona)!=null?g:i.persona)!=null?p:t,l=(_=(A=i.personaAttributes)==null?void 0:A.confidence)!=null?_:"high";K={persona:a,band:l},ke(document),Ee=!0,Et(),je(e),i.recognized===!1?Kn(t,!0):Kn((I=i.personaDisplay)!=null?I:a)}function je(e){let t={goal(n,r){try{R==null||R.goal(n,r)}catch(o){}},componentGoal(n,r){try{R==null||R.componentGoal(n,r)}catch(o){}},grantConsent(){try{!R&&Se?(R=Me({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))):(vt(e.apiKey),R&&fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))),Se=!1}catch(n){}$e=!0;try{ho()}catch(n){}},revokeConsent(){try{ne==null||ne(),ne=null,ct=null,U==null||U(),U=null,$==null||$.teardown(),$=null,Cn(typeof window!="undefined"?window:null,e.apiKey),$e=!1,Se=!0,R==null||R.destroy(),R=null}catch(n){}},reapply:It,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=K==null?void 0:K.persona)!=null?n:null,band:(r=K==null?void 0:K.band)!=null?r:null,slots:le,matchCounts:lt(e),consent:!Se&&(e.consent!==!1||$e)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of jn.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Nn(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},jn.length=0}catch(t){}}async function Hn(){var e;try{let t=Xe(window.sentient);if(!t){Nn();return}F=t,Ee=!1,we=null,Ne(null),$e=!1,Se=!1,fe=null;let n=typeof window!="undefined"?zn(window.location.search):null;if(n){Tn(n);try{let p=new URL(window.location.href);p.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",p.pathname+p.search+p.hash)}catch(p){}}let r=n!=null?n:Ln();if(r){vo(t,r),je(t),be(t,"editor mode");return}let o=typeof window!="undefined"?Fn(window.location.search):null;if(o){le=o,K=null,ke(document),Et(),je(t),be(t,"preview mode",o);return}let c=typeof window!="undefined"?Wn(window.location.search):null;if(c){await wo(t,c),be(t,"persona preview",c);return}let i=(e=t.registry)!=null?e:Object.keys(t.slots).length===0,a=Pe(t.apiKey);a&&(K={persona:a.persona,band:a.band},le=a.slots,a.slotConfig&&(ge=a.slotConfig),a.palette&&Ne(a.palette),ke(document,{contentAndOps:!1}),a.layoutOrder&&(we=a.layoutOrder,xt(we,document)));let l=Me({apiKey:t.apiKey,context:t.context,consent:t.consent,preConsentBehavior:t.preConsentBehavior,debug:t.debug,persona:t.persona});R=l,je(t),Et();let u=Object.entries(t.slots).map(([p,A])=>({id:p,dims:A.dims})),s=At!=="0.0.0-dev"?{v:At}:{},d=Array.from(Un(document).keys()),y=l.decide(Z(Z(Z({slots:u},s),d.length>=2?{sections:d}:{}),i?{slotsFrom:"registry"}:{})),m=await Gn(y,$n),g=p=>{var I,v,w,k,N,E;let A=l.getPersona();A?K={persona:A.persona,band:A.band}:p.persona&&(K={persona:p.persona,band:"low"}),le=p.slots,i?ge=(I=p.slotConfig)!=null?I:null:p.slotConfig&&(ge=p.slotConfig),p.palette&&Ne(p.palette),we=(v=p.layoutOrder)!=null?v:we;let _=()=>{let P=[];if(mo(t,ke(document,{onApplied:(j,O,X)=>P.push({slotId:j,arm:O,el:X})})),xt(we,document),Ee=!0,Ie())try{U==null||U(),U=it(R,t.apiKey,P)}catch(j){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_,{once:!0}):_(),fe=(w=p.goals)!=null?w:null,p.goals&&p.goals.length>0&&t.consent!==!1&&R)try{$==null||$.teardown(),$=st(p.goals,R,document,t.apiKey)}catch(P){}at=(k=p.sectionMap)!=null?k:null,Ie()&&kt(),be(t,"applied",{persona:K,slots:le,matches:lt(t)}),!Se&&De(t.apiKey,Z(Z({v:1,persona:(N=K==null?void 0:K.persona)!=null?N:p.persona,band:(E=K==null?void 0:K.band)!=null?E:"low",slots:p.slots,layoutOrder:p.layoutOrder,savedAt:Date.now()},ge?{slotConfig:ge}:{}),p.palette?{palette:p.palette}:{}))};if(!m){be(t,"decide timeout/null \u2014 snapshot state stands",lt(t)),y.then(p=>{!p||Ee||Se||R!==l||(g(p),be(t,"late decide applied",lt(t)))}).catch(()=>{});return}g(m)}catch(t){Nn()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Hn())}return Zn(bo);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.17.2",
3
+ "version": "0.18.0",
4
4
  "private": false,
5
5
  "description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "tsx": "^4.19.2",
25
25
  "typescript": "^5.7.2",
26
26
  "vitest": "^2.1.8",
27
- "@sentientui/core": "0.21.3"
27
+ "@sentientui/core": "0.22.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",