@sentientui/snippet 0.11.5 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- "use strict";var SentientSnippet=(()=>{var et=Object.defineProperty,Jt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptor,Zt=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertyNames,It=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Mt=(e,t,n)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,z=(e,t)=>{for(var n in t||(t={}))_t.call(t,n)&&Mt(e,n,t[n]);if(It)for(var n of It(t))te.call(t,n)&&Mt(e,n,t[n]);return e},nt=(e,t)=>Jt(e,Zt(t));var ee=(e,t)=>{for(var n in t)et(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Qt(t))!_t.call(e,s)&&s!==n&&et(e,s,{get:()=>t[s],enumerable:!(r=Xt(t,s))||r.enumerable});return e};var oe=e=>ne(et({},"__esModule",{value:!0}),e);var Se={};ee(Se,{buildStyleOps:()=>Ft,clearTargetHighlights:()=>dt,computeMoveAnchors:()=>at,deriveSlotId:()=>st,drawTargetHighlights:()=>Gt,mount:()=>Wt,styleFieldError:()=>Ut});function re(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function ie(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(),s=t.text.trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var se=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ot(e,t){var s;if(e.urlMatch&&!re(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)&&se.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 r=n[0];return e.fingerprint&&!ie(r,e.fingerprint)?null:r}function Ht(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let r=0;r<e.length;r++){let s=e[r],d=s>="0"&&s<="9";r===0&&d||r===1&&d&&e[0]==="-"?n+=`\\3${s} `:r===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function ae(e,t){if(e.id)return`#${Ht(e.id)}`;let n=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){n.unshift(`#${Ht(r.id)}`);break}let d=r.tagName.toLowerCase(),c=r.parentElement;if(c){let y=Array.from(c.children).filter(v=>v.tagName===r.tagName);y.length>1&&(d+=`:nth-of-type(${y.indexOf(r)+1})`)}n.unshift(d),r=r.parentElement,s++}return n.join(" > ")}function V(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 c=e.getAttribute(d);if(c){n.dataAttr={name:d,value:c};break}}n.selector=ae(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=z({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function rt(e,t,n){return ot(e,n)===t}var le="__snt_editor_token";function xt(){try{sessionStorage.removeItem(le)}catch(e){}}var de=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function zt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!de.test((t=n[1])!=null?t:""))return!1;return!0}function Pt(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 it(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function st(e,t,n){var y,v;let r=t.id||((y=t.dataAttr)==null?void 0:y.value)||((v=n.textContent)!=null?v:"").trim()||n.tagName,s=it(r)||"el",d=Pt(JSON.stringify(t));return`${e}-${s}-${d}`.slice(0,128)}var ce="sentient-editor-highlight",ue="sentient-editor-selection",O="sentient-editor-panel",lt="sentient-editor-toast",Nt="sentient-editor-styles",yt="sentient-editor-target-highlight",pe=10,fe="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",ge="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Dt(){var t;if(document.getElementById(Nt))return;let e=document.createElement("style");e.id=Nt,e.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var ut=Object.defineProperty,ie=Object.defineProperties,se=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertyNames,zt=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var Nt=(e,t,n)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t)=>{for(var n in t||(t={}))Dt.call(t,n)&&Nt(e,n,t[n]);if(zt)for(var n of zt(t))ce.call(t,n)&&Nt(e,n,t[n]);return e},pt=(e,t)=>ie(e,ae(t));var de=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0})},ue=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of le(t))!Dt.call(e,i)&&i!==n&&ut(e,i,{get:()=>t[i],enumerable:!(o=se(t,i))||o.enumerable});return e};var pe=e=>ue(ut({},"__esModule",{value:!0}),e);var He={};de(He,{buildStyleOps:()=>Qt,clearTargetHighlights:()=>st,computeMoveAnchors:()=>yt,deriveSlotId:()=>bt,drawTargetHighlights:()=>Kt,mount:()=>te,styleFieldError:()=>Jt});function fe(e){var n,o,i;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function ge(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(),i=t.text.trim().toLowerCase();if(!(o===i||o.startsWith(i)||i.startsWith(o)))return!1}return!0}var me=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function D(e,t){var i;if(e.urlMatch&&!fe(t).includes(e.urlMatch))return null;let n=[];if(e.id){let a=t.getElementById(e.id);n=a?[a]:[]}if(n.length===0&&((i=e.dataAttr)!=null&&i.name)&&me.test(e.dataAttr.name))try{let a=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${a}"]`))}catch(a){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(a){n=[]}if(n.length!==1)return null;let o=n[0];return e.fingerprint&&!ge(o,e.fingerprint)?null:o}function jt(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 i=e[o],a=i>="0"&&i<="9";o===0&&a||o===1&&a&&e[0]==="-"?n+=`\\3${i} `:o===0&&i==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(i)?n+=i:n+=`\\${i}`}return n}function he(e,t){if(e.id)return`#${jt(e.id)}`;let n=[],o=e,i=0;for(;o&&o!==t.body&&o!==t.documentElement&&i<6;){if(o.id){n.unshift(`#${jt(o.id)}`);break}let a=o.tagName.toLowerCase(),d=o.parentElement;if(d){let h=Array.from(d.children).filter(p=>p.tagName===o.tagName);h.length>1&&(a+=`:nth-of-type(${h.indexOf(o)+1})`)}n.unshift(a),o=o.parentElement,i++}return n.join(" > ")}function it(e,t){var i;let n={v:1};e.id&&(n.id=e.id);for(let a of["data-framer-name","data-w-id","data-sentient-name"]){let d=e.getAttribute(a);if(d){n.dataAttr={name:a,value:d};break}}n.selector=he(e,t);let o=((i=e.textContent)!=null?i:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=Z({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function ft(e,t,n){return D(e,n)===t}var be="__snt_editor_token";function gt(){try{sessionStorage.removeItem(be)}catch(e){}}var Gt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},ye=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function mt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!ye.test((t=n[1])!=null?t:""))return!1;return!0}var Ft=/^https:\/\//i,Ut=new Map,H=null;function xe(e){return e.replace(/["\\]/g,"\\$&")}function ve(e){var t;(!H||!H.isConnected)&&(H=e.querySelector("style[data-sentient-ops]"),H||(H=e.createElement("style"),H.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(H))),H.textContent=[...Ut.entries()].map(([n,o])=>`[data-snt-e="${xe(n)}"]{${o}}`).join(`
2
+ `)}function Wt(e,t,n,o){var h;let i=!1,a=(h=t.moveBefore)!=null?h:t.moveAfter;if(a){let p=D(a,o);!p||p===e||p.parentElement!==e.parentElement||!e.parentElement?i=!0:t.moveBefore?e.parentElement.insertBefore(e,p):e.parentElement.insertBefore(e,p.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Ft.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Ft.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let d=[];if(t.hidden&&d.push("display:none !important"),t.style)for(let[p,B]of Object.entries(t.style)){let E=Gt[p];E&&typeof B=="string"&&mt(B)&&d.push(`${E}:${B.trim()} !important`)}return d.length>0&&(e.setAttribute("data-snt-e",n),Ut.set(n,d.join(";")),ve(o)),{anchorMiss:i}}function Vt(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 ht(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function bt(e,t,n){var h,p;let o=t.id||((h=t.dataAttr)==null?void 0:h.value)||((p=n.textContent)!=null?p:"").trim()||n.tagName,i=ht(o)||"el",a=Vt(JSON.stringify(t));return`${e}-${i}-${a}`.slice(0,128)}var Ee="sentient-editor-highlight",ke="sentient-editor-selection",X="sentient-editor-panel",xt="sentient-editor-toast",qt="sentient-editor-styles",Lt="sentient-editor-target-highlight",we=10,Se="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Le="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Zt(){var t;if(document.getElementById(qt))return;let e=document.createElement("style");e.id=qt,e.textContent=`
2
3
  @keyframes sntedi-in {
3
4
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
4
5
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -11,13 +12,13 @@
11
12
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
12
13
  50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
13
14
  }
14
- #${O} {
15
+ #${X} {
15
16
  animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both,
16
17
  sntedi-attn 1.7s ease-in-out 0.42s 3;
17
18
  }
18
- #${O} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
19
- #${lt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
19
+ #${X} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
+ #${xt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
20
21
  @media (prefers-reduced-motion: reduce) {
21
- #${O}, #${O} .sntedi-dot, #${lt} { animation: none !important; }
22
+ #${X}, #${X} .sntedi-dot, #${xt} { animation: none !important; }
22
23
  }
23
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Ot(e){var r,s;Dt(),(r=document.getElementById(lt))==null||r.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=lt;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 me(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function he(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 N(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?"ok":r.status===401?"expired":"error"}catch(r){return"error"}}async function be(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 Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}function dt(e=document){for(let t of Array.from(e.querySelectorAll(`.${yt}`)))t.remove()}function Gt(e,t=document){var r;dt(t);let n=0;for(let s of e){if(n>=pe)break;let d=ot(s.locator,t);if(!d)continue;let c=d.getBoundingClientRect(),y=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});y.className=yt;let v=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${c.left}px`,top:`${Math.max(0,c.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);v.className=yt,((r=t.body)!=null?r:t.documentElement).append(y,v),n+=1}}function at(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,s=n?V(n,t):null,d=r?V(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&s&&rt(s,n,t)?s:null,nextLocator:r&&d&&rt(d,r,t)?d:null}}var jt=["color","background","fontSize","fontWeight","borderRadius","textAlign"],xe=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,ye=new Set(["left","center","right","justify","start","end"]),ve=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ke=/^(rgb|rgba|hsl|hsla)\(/i;function Ee(e){return ve.test(e)||ke.test(e)}function Ut(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 ye.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ee(t)?null:"Enter a colour, e.g. #1a1a1a.";default:return null}}function Ft(e){let t={},n={};for(let r of jt){let s=e[r];if(typeof s!="string")continue;let d=s.trim();if(d==="")continue;if(!zt(d)){n[r]="That value isn\u2019t allowed.";continue}let c=Ut(r,d);if(c){n[r]=c;continue}t[r]=d}return{style:t,errors:n}}function l(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function Wt(e){var $t;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=ce;let r=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});r.id=ue;let s=()=>{if(!t||!t.isConnected){r.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(r.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},d=()=>s();Dt();let c=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)"});c.id=O;let y=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});y.className="sntedi-dot";let v=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});v.append(y,l("span",{},"SentientUI editor"));let Yt=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),ct=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"}),ut=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),pt=o=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},o),R=l("button",b("#6366f1"),"Test different text here"),P=l("button",b("#374151"),"Change style"),D=l("button",b("#374151"),"Track clicks as a goal"),G=l("button",b("#374151"),"Track form submissions as a goal"),vt=l("button",b("#374151"),"Track page visits as a goal"),C=l("button",b("#374151"),"Move up"),T=l("button",b("#374151"),"Move down"),K=l("button",b("#6366f1"),"Save this arrangement"),J=l("button",b("#374151"),"Undo"),kt=l("button",nt(z({},b("transparent")),{opacity:"0.6"}),"Close editor"),B=l("button",b("#10b981"),"Publish now \u2014 go live"),A=l("button",b("#10b981"),"Start tracking now");for(let o of[R,P,D,C,T])o.disabled=!0;let Et=[R,P,D,G,C,T];for(let o of Et)o.style.display="none";K.style.display="none",J.style.display="none",B.style.display="none",A.style.display="none",c.append(v,Yt,ct,ut,pt("Content & style"),R,P,pt("Track a goal"),D,G,vt,pt("Move"),C,T,K,J,B,A,kt),(($t=document.body)!=null?$t:document.documentElement).append(n,r,c);let w=l("div",{marginTop:"10px"});c.append(w);let j=()=>{w.textContent=""},wt=(o,i,a)=>{var _;j();let p={},g={},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 f of o){let L=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},f.label);if(w.append(L),f.type==="select"){let m=l("select",h);m.setAttribute("data-field",f.key);let H=document.createElement("option");H.value="",H.textContent="\u2014 no change \u2014",m.append(H);for(let Rt of(_=f.options)!=null?_:[]){let bt=document.createElement("option");bt.value=Rt,bt.textContent=Rt,m.append(bt)}p[f.key]=()=>m.value,w.append(m)}else if(f.type==="color"){let m=l("input",nt(z({},h),{padding:"2px",height:"34px"}));m.type="color",m.setAttribute("data-field",f.key);let H=!1;m.addEventListener("input",()=>{H=!0}),p[f.key]=()=>H?m.value:"",w.append(m)}else{let m=l("input",h);m.setAttribute("data-field",f.key),f.value!==void 0&&(m.value=f.value),p[f.key]=()=>m.value,w.append(m)}let $=l("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});$.setAttribute("data-feedback",f.key),g[f.key]=$,w.append($)}let E=(f,L)=>{let $=g[f];$&&($.textContent=L!=null?L:"",$.style.display=L?"block":"none")},S=l("button",b("#6366f1"),i),q=l("button",nt(z({},b("transparent")),{opacity:"0.6"}),"Cancel");S.onclick=()=>a(Object.fromEntries(Object.entries(p).map(([f,L])=>[f,L()])),E),q.onclick=j,w.append(S,q)},u=(o,i=!0)=>{ut.textContent=o,ut.style.color=i?"#a7f3d0":"#fca5a5"},X=(o,i)=>{o==="ok"?u(i,!0):u(o==="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)},Z=null,ft=o=>{Z=o,B.style.display="block"};B.onclick=async()=>{if(!Z)return;B.disabled=!0,u("Publishing\u2026");let o=await N(e,`/v1/editor/slots/${encodeURIComponent(Z)}/publish`,{});B.disabled=!1,o==="ok"?(u("\u2713 Published \u2014 live for new visitors.",!0),B.style.display="none",Z=null):u(o==="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 x=null,U=!1,F=null,W=null,k=null,I=null,Y=null,Q=null,M=!1,St=(o,i)=>U?o?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Lt=()=>{C.disabled=!U||!k,T.disabled=!U||!I,C.title=C.disabled?St(k,"above"):"",T.title=T.disabled?St(I,"below"):""},gt=o=>{K.style.display=o?"block":"none",J.style.display=o?"block":"none",Lt()},Ct=()=>{if(M&&t&&Y&&Y.insertBefore(t,Q),M=!1,Y=null,Q=null,t){let o=at(t,document);F=o.prevEl,W=o.nextEl,k=o.prevLocator,I=o.nextLocator}s(),gt(!1)},Tt=o=>{let i=o.target;if(!i||c.contains(i)||i===n)return;dt(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`})},qt=o=>{var a;let i=((a=o.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},Bt=o=>{let i=o.target;if(!i||c.contains(i))return;o.preventDefault(),o.stopPropagation(),Ct(),j(),t=i,x=V(i,document);let a=rt(x,i,document);U=a,s(),ct.style.display="block",ct.textContent=`Selected: ${qt(i)}`,u(a?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",a);for(let E of Et)E.style.display="block";let p=i.childElementCount===0;R.disabled=!a||!p,R.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.":"",P.disabled=!a,D.disabled=!a;let g=i.closest("form");G.style.display=g?"block":"none",G.disabled=!g;let h=at(i,document);F=h.prevEl,W=h.nextEl,k=h.prevLocator,I=h.nextLocator,Lt()};R.onclick=()=>{var a,p;if(!t||!x)return;let o=x,i=(p=(a=t.textContent)==null?void 0:a.trim())!=null?p:"";wt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async g=>{let h=g.alt.trim();if(!h){u("\u26A0 Enter alternative wording to test.",!1);return}if(h===g.current.trim()){u("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let E=st("text",o,t);u("Saving\u2026");let S=await N(e,`/v1/editor/slots/${encodeURIComponent(E)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:g.current}},{id:"b",displayName:"Alternative",ops:{text:g.alt}}]}});S==="ok"&&(j(),ft(E)),X(S,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let tt=null,Vt=o=>{tt=o,A.style.display="block"};A.onclick=async()=>{if(!tt)return;A.disabled=!0,u("Activating\u2026");let o=await N(e,`/v1/editor/goals/${encodeURIComponent(tt)}/publish`,{});A.disabled=!1,o==="ok"?(u("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),A.style.display="none",tt=null):u(o==="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=(o,i)=>`${it(o)||"goal"}-${Pt(i)}`.slice(0,128),ht=async(o,i)=>{u("Saving\u2026");let a=await N(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);a==="ok"&&Vt(o),X(a,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};D.onclick=()=>{var i;if(!t||!x)return;let o=mt(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(x));ht(o,{event:"click",locator:x})},G.onclick=()=>{var p,g;let o=t==null?void 0:t.closest("form");if(!o)return;let i=V(o,document),a=(g=(p=o.getAttribute("id"))!=null?p:o.getAttribute("name"))!=null?g:"form-submitted";ht(mt(a,JSON.stringify(i)),{event:"form_submit",locator:i})},vt.onclick=()=>{let o=window.location.pathname||"/",i=it(o)?`reached-${it(o)}`:"page-visited";ht(mt(i,o),{event:"url_reached",urlPattern:o})},P.onclick=()=>{if(!t||!x)return;let o=x;wt([{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:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(i,a)=>{var q;let{style:p,errors:g}=Ft(i),h=!1;for(let _ of jt)a(_,(q=g[_])!=null?q:null),g[_]&&(h=!0);if(h){u("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(p).length===0){u("\u26A0 Enter at least one style change.",!1);return}let E=st("style",o,t);u("Saving\u2026");let S=await N(e,`/v1/editor/slots/${encodeURIComponent(E)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:p}}]}});S==="ok"&&(j(),ft(E)),X(S,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let At=o=>{if(!t)return;let i=t.parentElement;if(!i)return;M||(Y=i,Q=t.nextSibling,M=!0),o==="up"&&F?i.insertBefore(t,F):o==="down"&&W&&i.insertBefore(t,W.nextSibling);let a=at(t,document);F=a.prevEl,W=a.nextEl,k=a.prevLocator,I=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),gt(!0),u("Previewing the new position \u2014 keep moving, save, or undo.")};C.onclick=()=>At("up"),T.onclick=()=>At("down"),J.onclick=()=>{Ct(),u("Move undone \u2014 back to the original position.")},K.onclick=async()=>{if(!t||!x||!M||!U)return;let o=k?"moveAfter":"moveBefore",i=k!=null?k:I;if(!i){u("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=st("move",x,t);u("Saving\u2026");let p=await N(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:x,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});p==="ok"&&(M=!1,Y=null,Q=null,gt(!1),ft(a)),X(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let Kt=()=>{var o;document.removeEventListener("mousemove",Tt,!0),document.removeEventListener("click",Bt,!0),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d),dt(document),n.remove(),r.remove(),c.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),xt()};kt.onclick=Kt,document.addEventListener("mousemove",Tt,!0),document.addEventListener("click",Bt,!0),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d)}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"}}async function we(){if(typeof document=="undefined")return;let e=me();if(!e)return;let t=await he(e);if(!t.ok){t.unauthorized?(xt(),Ot(fe)):Ot(ge);return}if(document.getElementById(O))return;Wt(e);let n=await be(e);Gt(n,document)}we();return oe(Se);})();
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Yt(e){var o,i;Zt(),(o=document.getElementById(xt))==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=xt;let n=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,l("div",{},e)),((i=document.body)!=null?i:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function Ce(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Te(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 K(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"}}var Ct=[];async function Ae(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 Ct=Array.isArray(n.fonts)?n.fonts.filter(o=>typeof o=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}function st(e=document){for(let t of Array.from(e.querySelectorAll(`.${Lt}`)))t.remove()}function Kt(e,t=document){var o;st(t);let n=0;for(let i of e){if(n>=we)break;let a=D(i.locator,t);if(!a)continue;let d=a.getBoundingClientRect(),h=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${d.top}px`,width:`${d.width}px`,height:`${d.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});h.className=Lt;let p=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${Math.max(0,d.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},i.label);p.className=Lt,((o=t.body)!=null?o:t.documentElement).append(h,p),n+=1}}function yt(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,i=n?it(n,t):null,a=o?it(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&i&&ft(i,n,t)?i:null,nextLocator:o&&a&&ft(a,o,t)?a:null}}var Xt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Be=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,$e=new Set(["left","center","right","justify","start","end"]),Re=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,_e=/^(rgb|rgba|hsl|hsla)\(/i;function Ie(e){return Re.test(e)||_e.test(e)}function Jt(e,t){switch(e){case"fontSize":case"borderRadius":return Be.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 $e.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ie(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 Qt(e){let t={},n={};for(let o of Xt){let i=e[o];if(typeof i!="string")continue;let a=i.trim();if(a==="")continue;if(!mt(a)){n[o]="That value isn\u2019t allowed.";continue}let d=Jt(o,a);if(d){n[o]=d;continue}t[o]=a}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 te(e){var Ht;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=Ee;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=ke;let i=()=>{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`})},a=()=>i();Zt();let d=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)"});d.id=X;let h=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});h.className="sntedi-dot";let p=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});p.append(h,l("span",{},"SentientUI editor"));let B=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),E=!1,j=l("button",x("#374151"),"Pause selecting");j.onclick=()=>{E=!E,j.textContent=E?"Resume selecting":"Pause selecting",E?(n.style.display="none",st(document),u("Selection paused \u2014 browse normally, then resume.")):u("Click any element on the page to adapt it.")};let G=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"}),F=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),U=r=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),C=l("button",x("#6366f1"),"Test different text here"),$=l("button",x("#374151"),"Change style"),R=l("button",x("#374151"),"Track clicks as a goal"),_=l("button",x("#374151"),"Track form submissions as a goal"),J=l("button",x("#374151"),"Track page visits as a goal"),w=l("button",x("#374151"),"Move up"),f=l("button",x("#374151"),"Move down"),S=l("button",x("#6366f1"),"Save this arrangement"),L=l("button",x("#374151"),"Undo"),Tt=l("button",pt(Z({},x("transparent")),{opacity:"0.6"}),"Close editor"),O=l("button",x("#10b981"),"Publish now \u2014 go live"),z=l("button",x("#10b981"),"Start tracking now");for(let r of[C,$,R,w,f])r.disabled=!0;let At=[C,$,R,_,w,f];for(let r of At)r.style.display="none";S.style.display="none",L.style.display="none",O.style.display="none",z.style.display="none",d.append(p,B,j,G,F,U("Content & style"),C,$,U("Track a goal"),R,_,J,U("Move"),w,f,S,L,O,z,Tt),((Ht=document.body)!=null?Ht:document.documentElement).append(n,o,d);let I=l("div",{marginTop:"10px"});d.append(I);let Q=()=>{I.textContent=""},Bt=(r,s,c)=>{var Y;Q();let g={},b={},v={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 m of r){let P=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},m.label);if(I.append(P),m.type==="select"){let y=l("select",v);y.setAttribute("data-field",m.key);let V=document.createElement("option");V.value="",V.textContent="\u2014 no change \u2014",y.append(V);for(let Ot of(Y=m.options)!=null?Y:[]){let St=document.createElement("option");St.value=Ot,St.textContent=Ot,y.append(St)}g[m.key]=()=>y.value,I.append(y)}else if(m.type==="color"){let y=l("input",pt(Z({},v),{padding:"2px",height:"34px"}));y.type="color",y.setAttribute("data-field",m.key);let V=!1;y.addEventListener("input",()=>{V=!0}),g[m.key]=()=>V?y.value:"",I.append(y)}else{let y=l("input",v);y.setAttribute("data-field",m.key),m.value!==void 0&&(y.value=m.value),g[m.key]=()=>y.value,I.append(y)}let N=l("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});N.setAttribute("data-feedback",m.key),b[m.key]=N,I.append(N)}let A=(m,P)=>{let N=b[m];N&&(N.textContent=P!=null?P:"",N.style.display=P?"block":"none")},M=l("button",x("#6366f1"),s),rt=l("button",pt(Z({},x("transparent")),{opacity:"0.6"}),"Cancel");M.onclick=()=>c(Object.fromEntries(Object.entries(g).map(([m,P])=>[m,P()])),A),rt.onclick=Q,I.append(M,rt)},u=(r,s=!0)=>{F.textContent=r,F.style.color=s?"#a7f3d0":"#fca5a5"},at=(r,s)=>{r==="ok"?u(s,!0):u(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)},lt=null,vt=r=>{lt=r,O.style.display="block"};O.onclick=async()=>{if(!lt)return;O.disabled=!0,u("Publishing\u2026");let r=await K(e,`/v1/editor/slots/${encodeURIComponent(lt)}/publish`,{});O.disabled=!1,r==="ok"?(u("\u2713 Published \u2014 live for new visitors.",!0),O.style.display="none",lt=null):u(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 k=null,tt=!1,et=null,nt=null,T=null,W=null,ot=null,ct=null,q=!1,$t=(r,s)=>tt?r?"":`Nothing to swap with ${s} \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.",Rt=()=>{w.disabled=!tt||!T,f.disabled=!tt||!W,w.title=w.disabled?$t(T,"above"):"",f.title=f.disabled?$t(W,"below"):""},Et=r=>{S.style.display=r?"block":"none",L.style.display=r?"block":"none",Rt()},_t=()=>{if(q&&t&&ot&&ot.insertBefore(t,ct),q=!1,ot=null,ct=null,t){let r=yt(t,document);et=r.prevEl,nt=r.nextEl,T=r.prevLocator,W=r.nextLocator}i(),Et(!1)},It=r=>{if(E)return;let s=r.target;if(!s||d.contains(s)||s===n)return;st(document);let c=s.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`})},ne=r=>{var c;let s=((c=r.textContent)!=null?c:"").trim().replace(/\s+/g," ");return s?s.length>40?`${s.slice(0,37)}\u2026`:s:r.tagName.toLowerCase()},Mt=r=>{if(E)return;let s=r.target;if(!s||d.contains(s))return;r.preventDefault(),r.stopPropagation(),_t(),Q(),t=s,k=it(s,document);let c=ft(k,s,document);tt=c,i(),G.style.display="block",G.textContent=`Selected: ${ne(s)}`,u(c?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",c);for(let A of At)A.style.display="block";let g=s.childElementCount===0;C.disabled=!c||!g,C.title=c?g?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",$.disabled=!c,R.disabled=!c;let b=s.closest("form");_.style.display=b?"block":"none",_.disabled=!b;let v=yt(s,document);et=v.prevEl,nt=v.nextEl,T=v.prevLocator,W=v.nextLocator,Rt()};C.onclick=()=>{var c,g;if(!t||!k)return;let r=k,s=(g=(c=t.textContent)==null?void 0:c.trim())!=null?g:"";Bt([{key:"current",label:"Current wording",value:s},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async b=>{let v=b.alt.trim();if(!v){u("\u26A0 Enter alternative wording to test.",!1);return}if(v===b.current.trim()){u("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let A=bt("text",r,t);u("Saving\u2026");let M=await K(e,`/v1/editor/slots/${encodeURIComponent(A)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:b.current}},{id:"b",displayName:"Alternative",ops:{text:b.alt}}]}});M==="ok"&&(Q(),vt(A)),at(M,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let dt=null,oe=r=>{dt=r,z.style.display="block"};z.onclick=async()=>{if(!dt)return;z.disabled=!0,u("Activating\u2026");let r=await K(e,`/v1/editor/goals/${encodeURIComponent(dt)}/publish`,{});z.disabled=!1,r==="ok"?(u("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),z.style.display="none",dt=null):u(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 kt=(r,s)=>`${ht(r)||"goal"}-${Vt(s)}`.slice(0,128),wt=async(r,s)=>{u("Saving\u2026");let c=await K(e,`/v1/editor/goals/${encodeURIComponent(r)}`,s);c==="ok"&&oe(r),at(c,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};R.onclick=()=>{var s;if(!t||!k)return;let r=kt(((s=t.textContent)!=null?s:"").trim()||"element-clicked",JSON.stringify(k));wt(r,{event:"click",locator:k})},_.onclick=()=>{var g,b;let r=t==null?void 0:t.closest("form");if(!r)return;let s=it(r,document),c=(b=(g=r.getAttribute("id"))!=null?g:r.getAttribute("name"))!=null?b:"form-submitted";wt(kt(c,JSON.stringify(s)),{event:"form_submit",locator:s})},J.onclick=()=>{let r=window.location.pathname||"/",s=ht(r)?`reached-${ht(r)}`:"page-visited";wt(kt(s,r),{event:"url_reached",urlPattern:r})},$.onclick=()=>{if(!t||!k)return;let r=k;Bt([{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:Ct.length?`Font (this site has: ${Ct.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(s,c)=>{var rt;let{style:g,errors:b}=Qt(s),v=!1;for(let Y of Xt)c(Y,(rt=b[Y])!=null?rt:null),b[Y]&&(v=!0);if(v){u("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(g).length===0){u("\u26A0 Enter at least one style change.",!1);return}let A=bt("style",r,t);u("Saving\u2026");let M=await K(e,`/v1/editor/slots/${encodeURIComponent(A)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:g}}]}});M==="ok"&&(Q(),vt(A)),at(M,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Pt=r=>{if(!t)return;let s=t.parentElement;if(!s)return;q||(ot=s,ct=t.nextSibling,q=!0),r==="up"&&et?s.insertBefore(t,et):r==="down"&&nt&&s.insertBefore(t,nt.nextSibling);let c=yt(t,document);et=c.prevEl,nt=c.nextEl,T=c.prevLocator,W=c.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(g){}i(),Et(!0),u("Previewing the new position \u2014 keep moving, save, or undo.")};w.onclick=()=>Pt("up"),f.onclick=()=>Pt("down"),L.onclick=()=>{_t(),u("Move undone \u2014 back to the original position.")},S.onclick=async()=>{if(!t||!k||!q||!tt)return;let r=T?"moveAfter":"moveBefore",s=T!=null?T:W;if(!s){u("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let c=bt("move",k,t);u("Saving\u2026");let g=await K(e,`/v1/editor/slots/${encodeURIComponent(c)}`,{kind:"arms",target:k,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:s}}]}});g==="ok"&&(q=!1,ot=null,ct=null,Et(!1),vt(c)),at(g,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let re=()=>{var r;document.removeEventListener("mousemove",It,!0),document.removeEventListener("click",Mt,!0),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a),st(document),n.remove(),o.remove(),d.remove(),window.__sentientEditor=null,(r=document.querySelector("meta[data-sentient-editor]"))==null||r.remove(),gt()};Tt.onclick=re,document.addEventListener("mousemove",It,!0),document.addEventListener("click",Mt,!0),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)}function x(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 ee="sentient-preview-bar";async function Me(e,t){var B,E,j,G,F,U,C,$,R,_,J,w;let n=null;try{let f=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});f.ok&&(n=(E=((B=(await f.json()).slots)!=null?B:[]).find(L=>L.slot_id===t&&L.kind==="arms"))!=null?E:null)}catch(f){}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=ee;let i=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");i.onclick=()=>{gt();let f=new URL(location.href);for(let S of["sentient_editor","sentient_preview","sentient_arm"])f.searchParams.delete(S);location.assign(f.toString())};let a=(U=(F=(j=n==null?void 0:n.draft_config)==null?void 0:j.arms)!=null?F:(G=n==null?void 0:n.published_config)==null?void 0:G.arms)!=null?U:[];if(!n||a.length===0){o.append(l("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),i),((C=document.body)!=null?C:document.documentElement).append(o);return}let d=new URLSearchParams(location.search).get("sentient_arm"),h=(R=($=a.find(f=>f.id===d))!=null?$:a[1])!=null?R:a[0];o.append(l("span",{fontWeight:"700"},`Previewing: ${(_=n.display_name)!=null?_:n.slot_id}`));let p=n.target&&typeof n.target=="object"?D(n.target,document):null;if(!p)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{Wt(p,h.ops,`preview-${n.slot_id}`,document);try{p.scrollIntoView({block:"center"})}catch(f){}for(let f of a){let S=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:f.id===h.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(J=f.displayName)!=null?J:f.id);S.onclick=()=>{let L=new URL(location.href);L.searchParams.set("sentient_arm",f.id),location.assign(L.toString())},o.append(S)}}o.append(i),((w=document.body)!=null?w:document.documentElement).append(o)}async function Pe(){if(typeof document=="undefined")return;let e=Ce();if(!e)return;let t=await Te(e);if(!t.ok){t.unauthorized?(gt(),Yt(Se)):Yt(Le);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(ee)||await Me(e,n);return}if(document.getElementById(X))return;te(e);let o=await Ae(e);Kt(o,document)}Pe();return pe(He);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var Se=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable;var et=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ie=(e,t)=>{for(var n in t||(t={}))tt.call(t,n)&&et(e,n,t[n]);if(Qe)for(var n of Qe(t))sn.call(t,n)&&et(e,n,t[n]);return e};var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var rt=(e,t)=>{for(var n in t)Se(e,n,{get:t[n],enumerable:!0})},an=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of on(t))!tt.call(e,o)&&o!==n&&Se(e,o,{get:()=>t[o],enumerable:!(r=rn(t,o))||r.enumerable});return e};var ln=e=>an(Se({},"__esModule",{value:!0}),e);var cn,un,dn,ot,pn,fn,it,E,he,xe=nt(()=>{"use strict";cn=Object.defineProperty,un=Object.defineProperties,dn=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,pn=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable,it=(e,t,n)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))pn.call(t,n)&&it(e,n,t[n]);if(ot)for(var n of ot(t))fn.call(t,n)&&it(e,n,t[n]);return e},he=(e,t)=>un(e,dn(t))});var gt={};rt(gt,{LOCAL_ENGINE_AVAILABLE:()=>hn,createLocalEngine:()=>yn});function yn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var hn,mt=nt(()=>{"use strict";hn=!1});var pr={};rt(pr,{applyPersonaAttributes:()=>Re,applyRegistrySlots:()=>Pe,applySlotArms:()=>Le,applySlotAttributes:()=>Te,parseEditorToken:()=>Xt,parsePersonaPreview:()=>Qt,parsePreview:()=>Zt,parseSnippetConfig:()=>_e,reapply:()=>Xe,run:()=>tn,version:()=>Fe});xe();function Ae(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function st(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 $e(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 Ae(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[i,s]of Object.entries((n=e.dims)!=null?n:{}))o[i]=(r=s[0])!=null?r:"";return Ae(o)}function at(e,t){var n,r;return e.dims!=null?(r=(n=st(t))!=null?n:st($e(e)))!=null?r:{}:t}function se(e){return e>=.3?e<.7?"medium":"high":"low"}var gn=["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 mn(e)!==null}function mn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=gn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function ct(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 ut(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 dt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function pt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ke(e){return E(E(E({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 Be(e){let t=Ke(e);return at(t,$e(t))}function ft(e){return typeof e=="string"?e:Ae(e)}xe();function vt(){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 vn="_snt_uid",bn=365,ce="_snt_uid";function wn(){return vt()}function Sn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function xn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function An(e){try{return localStorage.getItem(e)}catch(t){return null}}function kn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function In(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function En(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function On(e){try{sessionStorage.removeItem(e)}catch(t){}}function Cn(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 _n(e){try{localStorage.removeItem(e)}catch(t){}}function Rn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Tn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function bt(e){var t,n,r,o,i,s;if(typeof window=="undefined")return Tn;let l=(t=e==null?void 0:e.cookieName)!=null?t:vn,a=((n=e==null?void 0:e.cookieTTLDays)!=null?n:bn)*24*60*60,c=v=>v&&v.length>0?v:null,u=(s=(i=(o=(r=c(Sn(l)))!=null?r:c(An(ce)))!=null?o:c(In(ce)))!=null?i:c(e==null?void 0:e.ssrSessionId))!=null?s:wn();xn(l,u,a);let p=kn(ce,u),y=Cn(l),g=p?!1:En(ce,u),w=!p&&!y&&!g;return{getSessionId:()=>u,isEphemeral:()=>w,destroy:()=>{u=null,Rn(l),_n(ce),On(ce)}}}function wt(e){return`_snt_retry_${e.slice(0,12)}`}var Ln={push:()=>{},flush:()=>{},destroy:()=>{}};function Pn(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(t),r.slice(-e)):[]}catch(n){return[]}}function Ue(e,t,n){try{let r=(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let l=JSON.parse(s);return Array.isArray(l)?l:[]}catch(s){return[]}})(),o=new Map;for(let s of r)o.set(s.id,s);for(let s of e)o.set(s.id,s);let i=[...o.values()].slice(-t);localStorage.setItem(n,JSON.stringify(i))}catch(r){}}function Dn(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),i=r.filter(s=>!o.has(s.id));if(i.length===r.length)return;i.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(i))}catch(n){}}function Mn(e){var t,n,r;if(typeof window=="undefined")return Ln;let o=(t=e.flushIntervalMs)!=null?t:5e3,i=(n=e.maxBatchSize)!=null?n:20,s=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,a=e.apiKey,c=wt(a),u=[],p=new Set,y=[],g=f=>{for(let x of f)w.delete(x),!p.has(x)&&(p.add(x),y.push(x));for(;y.length>500;){let x=y.shift();x&&p.delete(x)}Dn(f,c)},w=new Set,v=f=>{p.has(f.id)||w.has(f.id)||(w.add(f.id),u.push(f))},A=f=>{for(let x of f)p.has(x.id)||(w.add(x.id),u.push(x))},P=Pn(s,c);for(let f of P)v(f);let S=0,I=0,j=f=>{if(f.length===0)return;let x=JSON.stringify(f),M=f.map(d=>d.id),z;try{z=fetch(l,{method:"POST",keepalive:!0,body:x,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(d){Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6));return}let G=d=>{if(d.ok||d.status>=400&&d.status<500&&d.status!==429){g(M),I=0,S=0;return}Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))};z instanceof Promise?z.then(G).catch(()=>{Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))}):G(z)},H=typeof TextEncoder!="undefined"?new TextEncoder:null,le=f=>H?H.encode(f).length:f.length,ne=f=>{let x=[],M=2;for(let z of f){let G=le(JSON.stringify(z))+1;if(x.length>0&&M+G>57344||x.length>=i)break;x.push(z),M+=G}return x},C=()=>{try{if(Date.now()<S)return;for(;u.length>0&&!(Date.now()<S);){let f=u.filter(M=>!p.has(M.id));if(u.length=0,f.length===0)break;let x=ne(f);if(x.length===0)break;x.length<f.length&&u.push(...f.slice(x.length)),j(x)}}catch(f){}},Y=!0,h=null;h=setInterval(()=>{Y&&C()},o);let m=()=>{document.visibilityState==="hidden"&&C()},k=()=>{C()};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",k),{push(f){v(f),u.length>=i&&C()},flush:C,destroy(){Y=!1,h!==null&&(clearInterval(h),h=null),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",k),C()}}}var ze="_snt_asgn_";function ke(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function jn(e,t){return`${ze}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ht(e){let t=e.slice(ze.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(r){return null}}function Ge(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(ze)&&e.push(n)}return e}catch(e){return[]}}function Nn(e=18e5){let t=new Map,n=r=>r.assignedAt+(r.ttlMs&&r.ttlMs>0?r.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let r of Ge())try{let o=localStorage.getItem(r);if(!o)continue;let i=JSON.parse(o);if(n(i)){localStorage.removeItem(r);continue}let s=ht(r);if(!s)continue;t.set(ke(s.componentId,s.segment),i)}catch(o){}})(),{get(r,o){let i=t.get(ke(r,o));return i?n(i)?(t.delete(ke(r,o)),null):i:null},set(r,o,i){let s=ke(r,o);t.set(s,i);try{localStorage.setItem(jn(r,o),JSON.stringify(i))}catch(l){}},invalidate(r){let o=`${encodeURIComponent(r)}:`;for(let i of[...t.keys()])i.startsWith(o)&&t.delete(i);for(let i of Ge()){let s=ht(i);if((s==null?void 0:s.componentId)===r)try{localStorage.removeItem(i)}catch(l){}}},clear(){t.clear();for(let r of Ge())try{localStorage.removeItem(r)}catch(o){}}}}var Ee="_snt_snap:",$n=["low","medium","high"];function Oe(e){try{let t=localStorage.getItem(Ee+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"||!$n.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 ye(e,t){try{localStorage.setItem(Ee+e,JSON.stringify(t))}catch(n){}}var We="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",St="[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,Ie=!1;function Kn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Bn(e){var t;let n=bt({ssrSessionId:e.ssrSessionId}),r=(t=n.getSessionId())!=null?t:"local",o=Kn(),i=Promise.resolve().then(()=>(mt(),gt)).then(a=>{let c=a;return c.LOCAL_ENGINE_AVAILABLE?(yt||(yt=!0,console.info(St)),c):(Ie||(Ie=!0,console.error(We)),null)}).catch(()=>(Ie||(Ie=!0,console.error(We)),null)),s=null;function l(a){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=a.persona,c.dataset.sentientConfidence=se(a.confidence))}return{isLocal:!0,async decide(a){var c,u,p;let y=await i;if(!y)return null;let g=y.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return s=he(E({},g),{layoutOrder:(u=(c=g.layoutOrder)!=null?c:s==null?void 0:s.layoutOrder)!=null?u:null,slots:E(E({},(p=s==null?void 0:s.slots)!=null?p:{}),g.slots)}),ye(e.apiKey||"local",{v:1,persona:s.persona,band:se(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(a){var c,u,p;return(p=(u=s==null?void 0:s.slots[a])!=null?u:(c=e.initialSlots)==null?void 0:c[a])!=null?p:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:se(s.confidence)}:null},async assign(a,c){var u;let p=await i;return!p||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(u=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:c}]}).assignments[a])!=null?u:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function ve(e,t,n,r){let o=[];{let i=!1,s=[],l=()=>{if(i)return;let a=Date.now();for(s.push(a);s.length>0&&a-s[0]>500;)s.shift();s.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",l),o.push(()=>t.removeEventListener("click",l))}{let i=!1,s=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let a=typeof window!="undefined"?window.getSelection():null,c=a?a.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",s),o.push(()=>document.removeEventListener("copy",s))}{let i=!1,s=!1,l=null,a=()=>{l!==null&&(clearTimeout(l),l=null)},c=()=>{i||!s||(a(),l=setTimeout(()=>{!i&&s&&(i=!0,e("scroll_hesitation"))},3e3))},u=()=>{a(),c()},p=g=>{for(let w of g)s=w.intersectionRatio>.3,s?c():a()},y=new IntersectionObserver(p,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{y.disconnect(),window.removeEventListener("scroll",u),a()})}if((r==null?void 0:r.tabLoss)!==!1){let i=!1,s=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let a=Date.now()-s;a<15e3&&(i=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of o)i()}}var xt="https://api.sentient-ui.com/v1/events",N=new Map,At=null;function qe(){return vt()}var ue={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 Un(){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 kt(e){return e.replace(/\/events\/?$/,"")}function ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function Je(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:At;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=N.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:i}=r;if(!i||o.respectDoNotTrack!==!1&&ae())return;let s=Ce(he(E({},o),{consent:!0}));i(s);let l=(t=N.get(n))==null?void 0:t.dispose;N.set(n,{config:he(E({},o),{consent:!0}),upgrade:null,dispose:l})}function Gn(e){var t;let n=kt((t=e.ingestUrl)!=null?t:xt),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(l,a,c){try{let u=new URLSearchParams({componentId:l});for(let y of a!=null?a:[])u.append("variantIds[]",y);let p=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return p.ok?{variantId:(await p.json()).variantId,assignmentTtlMs:0}:a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}catch(u){return a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},i={track:l=>o.track(l),goal:(l,a,c,u)=>o.goal(l,a,c,u),componentGoal:(l,a,c)=>o.componentGoal(l,a,c),identify:l=>o.identify(l),getAssignment:(l,a)=>o.getAssignment(l,a),assign:(l,a,c,u)=>o.assign(l,a,c,u),decide:l=>o.decide(l),getSlotResult:l=>o.getSlotResult(l),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function s(l){o=l}return{proxy:i,setInner:s}}function Ce(e){var t,n,r,o,i,s,l,a,c;if(typeof window=="undefined")return ue;At=e.apiKey;let u=N.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(d){}let p=e.respectDoNotTrack!==!1&&ae(),y=e.consent===!1||p,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return y?(N.set(e.apiKey||"local",{config:e,upgrade:null}),ue):(N.set(e.apiKey||"local",{config:e,upgrade:null}),Bn(e));if(y){if(e.preConsentBehavior==="statistical_winner"){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."),ue;let{proxy:d,setInner:b}=Gn(e);return N.set(e.apiKey,{config:e,upgrade:p?null:b}),d}return N.set(e.apiKey,{config:e,upgrade:null}),ue}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."),ue;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ue;let w=(t=e.ingestUrl)!=null?t:xt,v=Date.now(),A=bt({ssrSessionId:e.ssrSessionId}),P=Nn(),S=Mn({ingestUrl:w,apiKey:e.apiKey}),I=kt(w),j={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},H=ct((n=navigator.userAgent)!=null?n:""),le=typeof window!="undefined"?window.location.origin:void 0,ne=ut((r=document.referrer)!=null?r:"",le),C=(o=e.sessionSegment)!=null?o:`${H}:${ne}`,Y=new Map,h=new Map,m=null,k=d=>{for(let b of d)h.has(b.id)||h.set(b.id,Be(b))};if(e.initialSlots)for(let[d,b]of Object.entries(e.initialSlots))h.set(d,b);let f=Oe(e.apiKey);if(f)for(let[d,b]of Object.entries(f.slots))h.has(d)||h.set(d,b);let x={low:.15,medium:.5,high:.85};if(e.initialPersona)m=E({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?m={persona:d.sentientPersona,confidence:(s=x[(i=d.sentientConfidence)!=null?i:"low"])!=null?s:.15}:f&&(m={persona:f.persona,confidence:(l=x[f.band])!=null?l:.15})}if(e.initialAssignments)for(let[d,b]of Object.entries(e.initialAssignments))P.set(d,C,{variantId:b,assignedAt:Date.now(),segment:C,confidence:1});let M=Promise.resolve(),z=A.getSessionId();if(z){let d=dt((a=document.referrer)!=null?a:""),b=E(E({sessionId:z,deviceClass:H,trafficSource:ne,referrerDomain:d,utmParams:Un(),timeOfDay:pt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||lt((c=navigator.userAgent)!=null?c:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{M=fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(b),headers:j}).then(R=>{R.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")}).catch(()=>{})}catch(R){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:S});let G={goal(d,b={},R=1,J=0){let q=A.getSessionId();if(!q)return;let D=qe();M.then(()=>{fetch(`${I}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:q,name:d,metadata:b,weight:R,stepIndex:J,goalId:D}),headers:j}).catch(()=>{})})},componentGoal(d,b,R){var J,q,D;let Z=A.getSessionId();if(!Z)return;let V=P.get(d,C),K=V?null:(J=h.get(d))!=null?J:null;if(!V&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${d}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=V?V.variantId:ft(K),B={id:qe(),sessionId:Z,projectId:e.apiKey,componentId:d,variantId:re,eventType:"goal_achieved",goalType:b,payload:E({reward:(q=R==null?void 0:R.reward)!=null?q:1},(D=R==null?void 0:R.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-v};e.debug&&console.log("[sentient] componentGoal",B),M.then(()=>S.push(B))},identify(d){let b=A.getSessionId();b&&M.then(()=>{fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:b,userId:d,ephemeral:A.isEphemeral()}),headers:j}).catch(()=>{})})},track(d){let b=A.getSessionId();if(!b)return;let R=he(E({},d),{id:qe(),sessionId:b,timestamp:Date.now(),timeInSession:Date.now()-v});e.debug&&console.log("[sentient] track",R),M.then(()=>S.push(R))},getAssignment(d,b){return P.get(d,b)},async assign(d,b,R,J){let q=A.getSessionId();if(!q)return null;let D=P.get(d,C);if(D&&(b!=null&&b.length||D.content!==void 0)){let K=D.ttlMs&&D.ttlMs>0?Math.max(0,D.assignedAt+D.ttlMs-Date.now()):0;return{variantId:D.variantId,assignmentTtlMs:K,content:D.content}}let Z=Y.get(d);if(Z)return Z;let V=(async()=>{await M;try{let K={sessionId:q,componentId:d,variantIds:b};J!==void 0?K.agentDataByVariant=J:R!==void 0&&(K.agentData=R);let re=await fetch(`${I}/assign`,{method:"POST",body:JSON.stringify(K),headers:j});if(!re.ok)return null;let B=await re.json();return P.set(d,C,E({variantId:B.variantId,assignedAt:Date.now(),segment:C,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{Y.delete(d)}})();return Y.set(d,V),V},async decide(d){var b,R,J,q,D,Z,V,K,re;let B=A.getSessionId();if(!B)return null;let fe=(b=d.slots)!=null?b:[];await M;try{let oe={sessionId:B};d.sections&&d.sections.length>0&&(oe.sections=d.sections.map(U=>({id:U}))),oe.components=(R=d.components)!=null?R:[],fe.length>0&&(oe.slots=fe.map(Ke)),d.slotsFrom==="registry"&&(oe.slotsFrom="registry"),d.v&&(oe.v=d.v);let Ze=await fetch(`${I}/decide`,{method:"POST",body:JSON.stringify(oe),headers:j});if(!Ze.ok)return k(fe),null;let _=await Ze.json(),ge={};for(let U of fe)ge[U.id]=(q=(J=_.slots)==null?void 0:J[U.id])!=null?q:Be(U);if(_.slots)for(let[U,me]of Object.entries(_.slots))U in ge||(ge[U]=me);for(let[U,me]of Object.entries(ge))h.set(U,me);let nn=m!=null&&m.persona!=="unknown";_.persona&&!(_.persona==="unknown"&&nn)?m={persona:_.persona,confidence:(D=_.confidence)!=null?D:0}:m||(m={persona:"unknown",confidence:0});for(let[U,me]of Object.entries((Z=_.assignments)!=null?Z:{}))P.set(U,C,{variantId:me,assignedAt:Date.now(),segment:C,confidence:1});return ye(e.apiKey,E({v:1,persona:m.persona,band:se(m.confidence),slots:Object.fromEntries(h),layoutOrder:(V=_.layoutOrder)!=null?V:null,savedAt:Date.now()},_.slotConfig?{slotConfig:_.slotConfig}:{})),E(E(E({layoutOrder:(K=_.layoutOrder)!=null?K:null,assignments:(re=_.assignments)!=null?re:{},slots:ge,persona:m.persona,confidence:m.confidence},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.goals?{goals:_.goals}:{}),_.sectionMap?{sectionMap:_.sectionMap}:{})}catch(oe){return k(fe),null}},getSlotResult(d){var b;return(b=h.get(d))!=null?b:null},getPersona(){return m?{persona:m.persona,confidence:m.confidence,band:se(m.confidence)}:null},async fetchWeights(){var d;try{let b=await fetch(`${I}/weights`,{headers:j});return b.ok?(d=(await b.json()).components)!=null?d:[]:[]}catch(b){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var d;S.destroy(),((d=N.get(e.apiKey))==null?void 0:d.dispose)===G.dispose&&N.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var d;S.destroy(),A.destroy(),((d=N.get(e.apiKey))==null?void 0:d.dispose)===G.dispose&&N.delete(e.apiKey);try{localStorage.removeItem(Ee+e.apiKey),localStorage.removeItem(wt(e.apiKey))}catch(b){}e.debug&&console.log("[sentient] destroyed")}};if(N.set(e.apiKey,{config:e,upgrade:null,dispose:G.dispose}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=G)}return G}var It=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],qn=[["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]],Wn=[["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 zn(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Et(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 qn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Wn)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 Ot(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:zn(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function Ct(e){return Et(Ot(e)).type}xe();var Rt="section, header, footer, nav, main > div, [data-sentient-section]";function Jn(e){var t;return((t=e.parentElement)==null?void 0:t.closest(Rt))!=null}function Vn(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 _t=()=>{};function Tt(e,t){var n,r,o,i,s,l,a,c,u;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||ae()||!t.apiKey)return _t;let y=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Array.from(p.querySelectorAll(Rt)).filter(h=>!Jn(h));if(g.length===0)return _t;let w=new Map,v=new Map,A=new Map;for(let h of g){let m=h.getAttribute("data-sentient-type"),k=m&&It.includes(m)?m:null,f=(i=k!=null?k:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?i:Ct(h),x=`nc-${f}`;w.set(h,x),v.set(x,f),k?A.set(x,"markup"):A.has(x)||A.set(x,"auto")}let P=(c=(a=(l=(s=p.defaultView)!=null?s:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:a.pathname)!=null?c:"/";Vn(t.apiKey,y,P,[...v.entries()].map(([h,m])=>{var k;return{componentId:h,semanticType:m,source:(k=A.get(h))!=null?k:"auto"}}));let S=new Map,I=h=>{let m=S.get(h);return m||(m={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(h,m)),m},j=new IntersectionObserver(h=>{for(let m of h){let k=w.get(m.target);if(!k)continue;let f=I(k);m.isIntersecting?(f.intersecting=!0,f.enterAt=Date.now(),m.intersectionRatio>f.scroll&&(f.scroll=m.intersectionRatio)):(f.intersecting=!1,f.enterAt!=null&&(f.ms+=Date.now()-f.enterAt,f.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of w.keys())j.observe(h);let H=()=>{let h=Date.now();for(let[m,k]of S)if(k.enterAt!=null&&(k.ms+=h-k.enterAt,k.enterAt=null),!(k.ms<=0)){try{e.track({projectId:t.apiKey,componentId:m,eventType:"dwell",payload:{dwell_time:Math.round(k.ms),scroll_depth:Number(k.scroll.toFixed(2))}})}catch(f){}k.ms=0}},le=()=>{if(p.hidden)H();else{let h=Date.now();for(let m of S.values())m.intersecting&&(m.enterAt=h)}},ne=()=>{H();try{j.disconnect()}catch(h){}};p.addEventListener("visibilitychange",le);let C=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0;C==null||C.addEventListener("pagehide",ne);let Y=[];return t.microSignals&&[...w.entries()].forEach(([h,m],k)=>{Y.push(ve((f,x={})=>{try{e.track({projectId:t.apiKey,componentId:m,eventType:"micro_signal",payload:E({signalType:f},x)})}catch(M){}},h,void 0,{tabLoss:k===0}))}),()=>{H(),p.removeEventListener("visibilitychange",le),C==null||C.removeEventListener("pagehide",ne);for(let h of Y)h();try{j.disconnect()}catch(h){}}}var Fn=["landing","ecommerce","saas","marketplace"];function Hn(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(i=>typeof i=="string"))return null;n[r]=o}return n}function Yn(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function _e(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=Fn.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let l=s,a=Hn(l.dims);if(!a||l.target!==void 0&&typeof l.target!="string")continue;let c=l.arms!==void 0?Yn(l.arms):null,u={dims:a};typeof l.target=="string"&&(u.target=l.target),c&&(u.arms=c),r[i]=u}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};return 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),o}function Lt(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 Xn(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 Pt(e,t){return!!(e!=null&&e.urlMatch)&&!Lt(t).includes(e.urlMatch)}var Zn=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Q(e,t){var o;if(e.urlMatch&&!Lt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let i=t.getElementById(e.id);n=i?[i]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Zn.test(e.dataAttr.name))try{let i=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${i}"]`))}catch(i){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(i){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Xn(r,e.fingerprint)?null:r}var Dt={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"},Qn=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Mt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Qn.test((t=n[1])!=null?t:""))return!1;return!0}var jt=/^https:\/\//i,Nt=new Map,ee=null;function er(e){return e.replace(/["\\]/g,"\\$&")}function tr(e){var t;(!ee||!ee.isConnected)&&(ee=e.querySelector("style[data-sentient-ops]"),ee||(ee=e.createElement("style"),ee.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ee))),ee.textContent=[...Nt.entries()].map(([n,r])=>`[data-snt-e="${er(n)}"]{${r}}`).join(`
2
- `)}function $t(e,t,n,r){var l;let o=!1,i=(l=t.moveBefore)!=null?l:t.moveAfter;if(i){let a=Q(i,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&jt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&jt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let s=[];if(t.hidden&&s.push("display:none !important"),t.style)for(let[a,c]of Object.entries(t.style)){let u=Dt[a];u&&typeof c=="string"&&Mt(c)&&s.push(`${u}:${c.trim()} !important`)}return s.length>0&&(e.setAttribute("data-snt-e",n),Nt.set(n,s.join(";")),tr(r)),{anchorMiss:o}}function Re(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Te(e,t,n){var r;for(let[o,i]of Object.entries(t)){let s=e[o];if(!s||typeof s=="string")continue;let l=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let a of l)for(let[c,u]of Object.entries(s))(r=i.dims[c])!=null&&r.includes(u)&&a.setAttribute(`data-${c}`,u)}}function Le(e,t,n){for(let[r,o]of Object.entries(t)){let i=e[r];if(typeof i!="string"||!o.arms||!o.arms.includes(i))continue;let s=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let l of s)l.setAttribute("data-sentient-arm",i)}}function Pe(e,t,n,r){var s,l;let o=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[a,c]of Object.entries(t)){if(Pt(c.locator,n))continue;let u;if(c.locator){let y=Q(c.locator,n);u=y?[y]:[]}else c.target?u=Array.from(n.querySelectorAll(c.target)):u=[n.documentElement];(c.locator||c.target)&&u.length===0&&i.push(a);let p=e[a];for(let y of u){if(p!==void 0)if(typeof p=="string")y.setAttribute("data-sentient-arm",p),o&&((l=r==null?void 0:r.onApplied)==null||l.call(r,a,p,y));else for(let[g,w]of Object.entries(p))y.setAttribute(`data-${g}`,w);o&&(typeof c.content=="string"&&(y.textContent=c.content),c.ops&&$t(y,c.ops,a,n).anchorMiss&&!i.includes(a)&&i.push(a))}}return i}var nr=800;function De(e,t,n){let r=[];return n.forEach(({slotId:o,arm:i,el:s},l)=>{r.push(ve((y,g={})=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"micro_signal",payload:ie({signalType:y},g)})}catch(w){}},s,void 0,{tabLoss:l===0}));let a=null,c=0,u=()=>{c=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-c}})}catch(y){}a=null},nr)},p=()=>{a!==null&&(clearTimeout(a),a=null)};s.addEventListener("mouseenter",u),s.addEventListener("mouseleave",p),r.push(()=>{s.removeEventListener("mouseenter",u),s.removeEventListener("mouseleave",p),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function rr(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 or(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 Kt(e,t,n){var y;let r=new Set,o=g=>{if(!r.has(g.goalId)){r.add(g.goalId);try{g.slotId?t.componentGoal(g.slotId,g.goalId):t.goal(g.goalId)}catch(w){}}},i=e.filter(g=>g.event==="click"),s=e.filter(g=>g.event==="form_submit"),l=e.filter(g=>g.event==="url_reached"),a=(g,w)=>{if(!g.locator)return!1;let v=Q(g.locator,n);return!!v&&(v===w||v.contains(w))},c=g=>{let w=g.target;if(!(!w||typeof w.closest!="function"))for(let v of i)a(v,w)&&o(v)},u=g=>{let w=g.target;if(w)for(let v of s)a(v,w)&&o(v)},p=()=>{if(l.length===0)return;let g=rr(n);for(let w of l)w.urlPattern&&or(w.urlPattern,g)&&o(w)};return n.addEventListener("click",c,!0),n.addEventListener("submit",u,!0),(y=n.defaultView)==null||y.addEventListener("popstate",p),p(),{checkUrl:p,teardown:()=>{var g;n.removeEventListener("click",c,!0),n.removeEventListener("submit",u,!0),(g=n.defaultView)==null||g.removeEventListener("popstate",p)}}}var Bt="__snt_editor_token";function Ut(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Bt):null}catch(e){return null}}function Gt(e){try{sessionStorage.setItem(Bt,e)}catch(t){}}var Fe="0.11.5",Ht=5e3,ir=50,$=null,T=null,X={},te=null,W=null,L=null,F=null,O=null,qt=!1,Ve=null,Me=null,je=null,be=!1,Ne=!1;function Yt(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function de(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function pe(e,t){return $?($.personaAttributes&&O&&Re(O.persona,O.band,e),Te(X,$.slots,e),Le(X,$.slots,e),te?Pe(X,te,e,t):[]):[]}function sr(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 we(){return!!($&&T&&$.sectionCapture!==!1&&($.consent!==!1||Ne)&&!ae())}function ar(){if(!T||!$||!we()||F)return;let e=[];pe(document,{contentAndOps:be,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Ye();try{L==null||L(),L=De(T,$.apiKey,e)}catch(t){}}function Ye(){if(typeof document=="undefined"||!we())return;let e;try{if(Me&&Me.length>0){let t=new Map;for(let n of Me){if(n.urlMatch!==window.location.pathname)continue;let r=Q(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{F=Tt(T,ie({apiKey:$.apiKey,apiBase:$.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),je=window.location.pathname}catch(t){}}function Xe(){try{let e=[];if(L==null||L(),L=null,pe(document,{contentAndOps:be,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&we())try{L=De(T,$.apiKey,e)}catch(t){}try{typeof window!="undefined"&&je!==null&&window.location.pathname!==je&&we()&&(F==null||F(),F=null,Ye())}catch(t){}}catch(e){}}function Wt(){Ve===null&&(Ve=setTimeout(()=>{Ve=null,Xe();try{W==null||W.checkUrl()}catch(e){}},ir))}function zt(){if(!(qt||typeof window=="undefined"||typeof history=="undefined")){qt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,i){let s=n.call(this,r,o,i!=null?i:null);return Wt(),s}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Wt)}catch(e){}}}function He(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 Xt(e){return new URLSearchParams(e).get("sentient_editor")}function lr(){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 cr(e,t){var n,r,o,i;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let a=document.createElement("meta");a.name="referrer",a.content="no-referrer",a.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let s=(o=e.editorSrc)!=null?o:lr();if(!s){Vt();return}let l=document.createElement("script");l.src=s,l.async=!0,l.onerror=()=>Vt(),((i=document.head)!=null?i:document.documentElement).appendChild(l)}catch(s){}}var Jt="sentient-editor-load-notice";function Vt(){var e;try{if(typeof document=="undefined"||document.getElementById(Jt))return;let t=document.createElement("div");t.id=Jt,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 Zt(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(":"),i=o===-1?"":r.slice(0,o),s=o===-1?"":r.slice(o+1);if(!(!i||!s))if(s.includes("=")){let l={};for(let a of s.split(",")){let[c,u]=a.split("=");c&&u&&(l[c]=u)}Object.keys(l).length&&(n[i]=l)}else n[i]=s}return Object.keys(n).length?n:null}function Qt(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Ft="sentient-persona-preview-banner";function ur(e){var t;try{if(typeof document=="undefined"||document.getElementById(Ft))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=Ft,r.setAttribute("role","status"),Object.assign(r.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 o=document.createElement("span");o.textContent=`Previewing as ${n}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),r.appendChild(o),r.appendChild(i),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function dr(e,t){var c,u,p,y,g,w,v,A,P;let n=(c=e.apiBase)!=null?c:"https://api.sentient-ui.com",o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([S,I])=>({id:S,dims:I.dims}))},i=await Yt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(S=>S.ok?S.json():null).catch(()=>null),Ht);if(!i){de(e,"persona preview: explain unavailable \u2014 page left as-is");return}let s=i;X=(p=s.slots)!=null?p:{},te=(y=s.slotConfig)!=null?y:null;let l=(v=(w=(g=s.personaAttributes)==null?void 0:g.persona)!=null?w:s.persona)!=null?v:t,a=(P=(A=s.personaAttributes)==null?void 0:A.confidence)!=null?P:"high";O={persona:l,band:a},pe(document),be=!0,en(e),ur(l)}function en(e){let t={goal(n,r){try{T==null||T.goal(n,r)}catch(o){}},componentGoal(n,r){try{T==null||T.componentGoal(n,r)}catch(o){}},grantConsent(){try{Je(e.apiKey)}catch(n){}Ne=!0;try{ar()}catch(n){}},revokeConsent(){try{F==null||F(),F=null,je=null,L==null||L(),L=null,W==null||W.teardown(),W=null,Ne=!1,T==null||T.destroy()}catch(n){}},reapply:Xe,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=O==null?void 0:O.persona)!=null?n:null,band:(r=O==null?void 0:O.band)!=null?r:null,slots:X,matchCounts:He(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function tn(){var e,t,n,r,o;try{let i=_e(window.sentient);if(!i)return;$=i,be=!1,Ne=!1;let s=typeof window!="undefined"?Xt(window.location.search):null;if(s){Gt(s);try{let S=new URL(window.location.href);S.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",S.pathname+S.search+S.hash)}catch(S){}}let l=s!=null?s:Ut();if(l){cr(i,l),de(i,"editor mode");return}let a=typeof window!="undefined"?Zt(window.location.search):null;if(a){X=a,O=null,pe(document),zt(),de(i,"preview mode",a);return}let c=typeof window!="undefined"?Qt(window.location.search):null;if(c){await dr(i,c),de(i,"persona preview",c);return}let u=(e=i.registry)!=null?e:Object.keys(i.slots).length===0,p=Oe(i.apiKey);p&&(O={persona:p.persona,band:p.band},X=p.slots,p.slotConfig&&(te=p.slotConfig),pe(document,{contentAndOps:!1}));let y=Ce({apiKey:i.apiKey,context:i.context,consent:i.consent,preConsentBehavior:i.preConsentBehavior,debug:i.debug});T=y,en(i),zt();let g=Object.entries(i.slots).map(([S,I])=>({id:S,dims:I.dims})),w=Fe!=="0.0.0-dev"?{v:Fe}:{},v=await Yt(y.decide(ie(ie({slots:g},w),u?{slotsFrom:"registry"}:{})),Ht);if(!v){de(i,"decide timeout/null \u2014 snapshot state stands",He(i));return}let A=y.getPersona();A?O={persona:A.persona,band:A.band}:v.persona&&(O={persona:v.persona,band:"low"}),X=v.slots,u?te=(t=v.slotConfig)!=null?t:null:v.slotConfig&&(te=v.slotConfig);let P=[];if(sr(i,pe(document,{onApplied:(S,I,j)=>P.push({slotId:S,arm:I,el:j})})),be=!0,v.goals&&v.goals.length>0&&i.consent!==!1&&T)try{W==null||W.teardown(),W=Kt(v.goals,T,document)}catch(S){}if(Me=(n=v.sectionMap)!=null?n:null,we()){Ye();try{L==null||L(),L=De(T,i.apiKey,P)}catch(S){}}de(i,"applied",{persona:O,slots:X,matches:He(i)}),ye(i.apiKey,ie({v:1,persona:(r=O==null?void 0:O.persona)!=null?r:v.persona,band:(o=O==null?void 0:O.band)!=null?o:"low",slots:v.slots,layoutOrder:v.layoutOrder,savedAt:Date.now()},te?{slotConfig:te}:{}))}catch(i){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,tn())}return ln(pr);})();
1
+ "use strict";var SentientSnippet=(()=>{var we=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames,Ye=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,nn=Object.prototype.propertyIsEnumerable;var Ze=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ie=(e,t)=>{for(var n in t||(t={}))Xe.call(t,n)&&Ze(e,n,t[n]);if(Ye)for(var n of Ye(t))nn.call(t,n)&&Ze(e,n,t[n]);return e};var Qe=(e,t)=>()=>(e&&(t=e(e=0)),t);var et=(e,t)=>{for(var n in t)we(e,n,{get:t[n],enumerable:!0})},rn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of tn(t))!Xe.call(e,o)&&o!==n&&we(e,o,{get:()=>t[o],enumerable:!(r=en(t,o))||r.enumerable});return e};var on=e=>rn(we({},"__esModule",{value:!0}),e);var sn,an,ln,tt,cn,un,nt,I,me,Se=Qe(()=>{"use strict";sn=Object.defineProperty,an=Object.defineProperties,ln=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,cn=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable,nt=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))cn.call(t,n)&&nt(e,n,t[n]);if(tt)for(var n of tt(t))un.call(t,n)&&nt(e,n,t[n]);return e},me=(e,t)=>an(e,ln(t))});var dt={};et(dt,{LOCAL_ENGINE_AVAILABLE:()=>fn,createLocalEngine:()=>gn});function gn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var fn,pt=Qe(()=>{"use strict";fn=!1});var ur={};et(ur,{applyPersonaAttributes:()=>_e,applyRegistrySlots:()=>Pe,applySlotArms:()=>Te,applySlotAttributes:()=>Re,parseEditorToken:()=>Ft,parsePersonaPreview:()=>Yt,parsePreview:()=>Ht,parseSnippetConfig:()=>Ce,reapply:()=>Fe,run:()=>Xt,version:()=>ze});Se();function xe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function rt(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 Ne(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 xe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[s,a]of Object.entries((n=e.dims)!=null?n:{}))o[s]=(r=a[0])!=null?r:"";return xe(o)}function ot(e,t){var n,r;return e.dims!=null?(r=(n=rt(t))!=null?n:rt(Ne(e)))!=null?r:{}:t}function se(e){return e>=.3?e<.7?"medium":"high":"low"}var dn=["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 it(e){return pn(e)!==null}function pn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=dn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function st(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 at(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 lt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ct(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function $e(e){return I(I(I({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 Ke(e){let t=$e(e);return ot(t,Ne(t))}function ut(e){return typeof e=="string"?e:xe(e)}Se();function gt(){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)})}function mt(e){return e?`_${e.slice(0,12)}`:""}var mn="_snt_uid",hn=365,yn="_snt_uid";function vn(){return gt()}function bn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function wn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Sn(e){try{return localStorage.getItem(e)}catch(t){return null}}function xn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function An(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function kn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function En(e){try{sessionStorage.removeItem(e)}catch(t){}}function In(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 On(e){try{localStorage.removeItem(e)}catch(t){}}function Cn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var _n={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ht(e){var t,n,r,o,s,a;if(typeof window=="undefined")return _n;let c=mt(e==null?void 0:e.apiKey),i=(t=e==null?void 0:e.cookieName)!=null?t:`${mn}${c}`,l=`${yn}${c}`,u=((n=e==null?void 0:e.cookieTTLDays)!=null?n:hn)*24*60*60,d=C=>C&&C.length>0?C:null,m=(a=(s=(o=(r=d(bn(i)))!=null?r:d(Sn(l)))!=null?o:d(An(l)))!=null?s:d(e==null?void 0:e.ssrSessionId))!=null?a:vn();wn(i,m,u);let g=xn(l,m),b=In(i),w=g?!1:kn(l,m),A=!g&&!b&&!w;return{getSessionId:()=>m,isEphemeral:()=>A,destroy:()=>{m=null,Cn(i),On(l),En(l)}}}function yt(e){return`_snt_retry_${e.slice(0,12)}`}var Rn={push:()=>{},flush:()=>{},destroy:()=>{}};function Tn(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(t),r.slice(-e)):[]}catch(n){return[]}}function Be(e,t,n){try{let r=(()=>{try{let a=localStorage.getItem(n);if(!a)return[];let c=JSON.parse(a);return Array.isArray(c)?c:[]}catch(a){return[]}})(),o=new Map;for(let a of r)o.set(a.id,a);for(let a of e)o.set(a.id,a);let s=[...o.values()].slice(-t);localStorage.setItem(n,JSON.stringify(s))}catch(r){}}function Pn(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),s=r.filter(a=>!o.has(a.id));if(s.length===r.length)return;s.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(s))}catch(n){}}function Ln(e){var t,n,r;if(typeof window=="undefined")return Rn;let o=(t=e.flushIntervalMs)!=null?t:5e3,s=(n=e.maxBatchSize)!=null?n:20,a=(r=e.maxRetrySize)!=null?r:100,c=e.ingestUrl,i=e.apiKey,l=yt(i),u=[],d=new Set,m=[],g=f=>{for(let x of f)b.delete(x),!d.has(x)&&(d.add(x),m.push(x));for(;m.length>500;){let x=m.shift();x&&d.delete(x)}Pn(f,l)},b=new Set,w=f=>{d.has(f.id)||b.has(f.id)||(b.add(f.id),u.push(f))},A=f=>{for(let x of f)d.has(x.id)||(b.add(x.id),u.push(x))},C=Tn(a,l);for(let f of C)w(f);let S=0,E=0,j=f=>{if(f.length===0)return;let x=JSON.stringify(f),M=f.map(p=>p.id),z;try{z=fetch(c,{method:"POST",keepalive:!0,body:x,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(p){Be(f,a,l),A(f),E++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6));return}let G=p=>{if(p.ok||p.status>=400&&p.status<500&&p.status!==429){g(M),E=0,S=0;return}Be(f,a,l),A(f),E++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))};z instanceof Promise?z.then(G).catch(()=>{Be(f,a,l),A(f),E++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))}):G(z)},H=typeof TextEncoder!="undefined"?new TextEncoder:null,le=f=>H?H.encode(f).length:f.length,ne=f=>{let x=[],M=2;for(let z of f){let G=le(JSON.stringify(z))+1;if(x.length>0&&M+G>57344||x.length>=s)break;x.push(z),M+=G}return x},_=()=>{try{if(Date.now()<S)return;for(;u.length>0&&!(Date.now()<S);){let f=u.filter(M=>!d.has(M.id));if(u.length=0,f.length===0)break;let x=ne(f);if(x.length===0)break;x.length<f.length&&u.push(...f.slice(x.length)),j(x)}}catch(f){}},Y=!0,y=null;y=setInterval(()=>{Y&&_()},o);let h=()=>{document.visibilityState==="hidden"&&_()},k=()=>{_()};return document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",k),{push(f){w(f),u.length>=s&&_()},flush:_,destroy(){Y=!1,y!==null&&(clearInterval(y),y=null),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",k),_()}}}var Dn=1800*1e3;function Ae(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Mn(e=Dn,t){let n=new Map,r=`_snt_asgn${mt(t)}_`,o=(i,l)=>`${r}${encodeURIComponent(i)}:${encodeURIComponent(l)}`,s=i=>{let l=i.slice(r.length),u=l.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(l.slice(0,u)),segment:decodeURIComponent(l.slice(u+1))}}catch(d){return null}},a=()=>{try{let i=[];for(let l=0;l<localStorage.length;l++){let u=localStorage.key(l);u!=null&&u.startsWith(r)&&i.push(u)}return i}catch(i){return[]}},c=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of a())try{let l=localStorage.getItem(i);if(!l)continue;let u=JSON.parse(l);if(c(u)){localStorage.removeItem(i);continue}let d=s(i);if(!d)continue;n.set(Ae(d.componentId,d.segment),u)}catch(l){}})(),{get(i,l){let u=n.get(Ae(i,l));return u?c(u)?(n.delete(Ae(i,l)),null):u:null},set(i,l,u){let d=Ae(i,l);n.set(d,u);try{localStorage.setItem(o(i,l),JSON.stringify(u))}catch(m){}},invalidate(i){let l=`${encodeURIComponent(i)}:`;for(let u of[...n.keys()])u.startsWith(l)&&n.delete(u);for(let u of a()){let d=s(u);if((d==null?void 0:d.componentId)===i)try{localStorage.removeItem(u)}catch(m){}}},clear(){n.clear();for(let i of a())try{localStorage.removeItem(i)}catch(l){}}}}var Ee="_snt_snap:",jn=["low","medium","high"];function Ie(e){try{let t=localStorage.getItem(Ee+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"||!jn.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 he(e,t){try{localStorage.setItem(Ee+e,JSON.stringify(t))}catch(n){}}var Ge="[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.",ft=!1,ke=!1;function Nn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function $n(e){var t;let n=ht({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Nn(),s=Promise.resolve().then(()=>(pt(),dt)).then(i=>{let l=i;return l.LOCAL_ENGINE_AVAILABLE?(ft||(ft=!0,console.info(vt)),l):(ke||(ke=!0,console.error(Ge)),null)}).catch(()=>(ke||(ke=!0,console.error(Ge)),null)),a=null;function c(i){let l=document.documentElement;l.dataset.sentientPersona===void 0&&(l.dataset.sentientPersona=i.persona,l.dataset.sentientConfidence=se(i.confidence))}return{isLocal:!0,async decide(i){var l,u,d;let m=await s;if(!m)return null;let g=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide(i);return a=me(I({},g),{layoutOrder:(u=(l=g.layoutOrder)!=null?l:a==null?void 0:a.layoutOrder)!=null?u:null,slots:I(I({},(d=a==null?void 0:a.slots)!=null?d:{}),g.slots)}),he(e.apiKey||"local",{v:1,persona:a.persona,band:se(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),c(g),g},getSlotResult(i){var l,u,d;return(d=(u=a==null?void 0:a.slots[i])!=null?u:(l=e.initialSlots)==null?void 0:l[i])!=null?d:null},getPersona(){return a?{persona:a.persona,confidence:a.confidence,band:se(a.confidence)}:null},async assign(i,l){var u;let d=await s;return!d||!l||l.length===0?l!=null&&l[0]?{variantId:l[0],assignmentTtlMs:0}:null:{variantId:(u=d.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:i,variantIds:l}]}).assignments[i])!=null?u:l[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function ye(e,t,n,r){let o=[];{let s=!1,a=[],c=()=>{if(s)return;let i=Date.now();for(a.push(i);a.length>0&&i-a[0]>500;)a.shift();a.length>=3&&(s=!0,e("rage_click"))};t.addEventListener("click",c),o.push(()=>t.removeEventListener("click",c))}{let s=!1,a=c=>{if(s||!(c.target instanceof Node)||!t.contains(c.target)&&t!==c.target)return;s=!0;let i=typeof window!="undefined"?window.getSelection():null,l=i?i.toString().length:0;e("text_copy",{selectionLength:l})};document.addEventListener("copy",a),o.push(()=>document.removeEventListener("copy",a))}{let s=!1,a=!1,c=null,i=()=>{c!==null&&(clearTimeout(c),c=null)},l=()=>{s||!a||(i(),c=setTimeout(()=>{!s&&a&&(s=!0,e("scroll_hesitation"))},3e3))},u=()=>{i(),l()},d=g=>{for(let b of g)a=b.intersectionRatio>.3,a?l():i()},m=new IntersectionObserver(d,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{m.disconnect(),window.removeEventListener("scroll",u),i()})}if((r==null?void 0:r.tabLoss)!==!1){let s=!1,a=n!=null?n:Date.now(),c=()=>{if(s||document.visibilityState!=="hidden")return;let i=Date.now()-a;i<15e3&&(s=!0,e("tab_loss",{timeOnPage:i}))};document.addEventListener("visibilitychange",c),o.push(()=>document.removeEventListener("visibilitychange",c))}return()=>{for(let s of o)s()}}var bt="https://api.sentient-ui.com/v1/events",N=new Map,wt=null;function Ue(){return gt()}var ce={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 Kn(){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 St(e){return e.replace(/\/events\/?$/,"")}function ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function qe(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:wt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=N.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:s}=r;if(!s||o.respectDoNotTrack!==!1&&ae())return;let a=Oe(me(I({},o),{consent:!0}));s(a);let c=(t=N.get(n))==null?void 0:t.dispose;N.set(n,{config:me(I({},o),{consent:!0}),upgrade:null,dispose:c})}function Bn(e){var t;let n=St((t=e.ingestUrl)!=null?t:bt),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(c,i,l){try{let u=new URLSearchParams({componentId:c});for(let m of i!=null?i:[])u.append("variantIds[]",m);let d=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return d.ok?{variantId:(await d.json()).variantId,assignmentTtlMs:0}:i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}catch(u){return i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},s={track:c=>o.track(c),goal:(c,i,l,u)=>o.goal(c,i,l,u),componentGoal:(c,i,l)=>o.componentGoal(c,i,l),identify:c=>o.identify(c),getAssignment:(c,i)=>o.getAssignment(c,i),assign:(c,i,l,u)=>o.assign(c,i,l,u),decide:c=>o.decide(c),getSlotResult:c=>o.getSlotResult(c),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function a(c){o=c}return{proxy:s,setInner:a}}function Oe(e){var t,n,r,o,s,a,c,i,l;if(typeof window=="undefined")return ce;wt=e.apiKey;let u=N.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(p){}let d=e.respectDoNotTrack!==!1&&ae(),m=e.consent===!1||d,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return m?(N.set(e.apiKey||"local",{config:e,upgrade:null}),ce):(N.set(e.apiKey||"local",{config:e,upgrade:null}),$n(e));if(m){if(e.preConsentBehavior==="statistical_winner"){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."),ce;let{proxy:p,setInner:v}=Bn(e);return N.set(e.apiKey,{config:e,upgrade:d?null:v}),p}return N.set(e.apiKey,{config:e,upgrade:null}),ce}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."),ce;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ce;let b=(t=e.ingestUrl)!=null?t:bt,w=Date.now(),A=ht({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),C=Mn(void 0,e.apiKey),S=Ln({ingestUrl:b,apiKey:e.apiKey}),E=St(b),j={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},H=st((n=navigator.userAgent)!=null?n:""),le=typeof window!="undefined"?window.location.origin:void 0,ne=at((r=document.referrer)!=null?r:"",le),_=(o=e.sessionSegment)!=null?o:`${H}:${ne}`,Y=new Map,y=new Map,h=null,k=p=>{for(let v of p)y.has(v.id)||y.set(v.id,Ke(v))};if(e.initialSlots)for(let[p,v]of Object.entries(e.initialSlots))y.set(p,v);let f=Ie(e.apiKey);if(f)for(let[p,v]of Object.entries(f.slots))y.has(p)||y.set(p,v);let x={low:.15,medium:.5,high:.85};if(e.initialPersona)h=I({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?h={persona:p.sentientPersona,confidence:(a=x[(s=p.sentientConfidence)!=null?s:"low"])!=null?a:.15}:f&&(h={persona:f.persona,confidence:(c=x[f.band])!=null?c:.15})}if(e.initialAssignments)for(let[p,v]of Object.entries(e.initialAssignments))C.set(p,_,{variantId:v,assignedAt:Date.now(),segment:_,confidence:1});let M=Promise.resolve(),z=A.getSessionId();if(z){let p=lt((i=document.referrer)!=null?i:""),v=I(I({sessionId:z,deviceClass:H,trafficSource:ne,referrerDomain:p,utmParams:Kn(),timeOfDay:ct(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||it((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{M=fetch(`${E}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(v),headers:j}).then(T=>{T.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")}).catch(()=>{})}catch(T){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:S});let G={goal(p,v={},T=1,J=0){let q=A.getSessionId();if(!q)return;let D=Ue();M.then(()=>{fetch(`${E}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:q,name:p,metadata:v,weight:T,stepIndex:J,goalId:D}),headers:j}).catch(()=>{})})},componentGoal(p,v,T){var J,q,D;let X=A.getSessionId();if(!X)return;let V=C.get(p,_),K=V?null:(J=y.get(p))!=null?J:null;if(!V&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=V?V.variantId:ut(K),B={id:Ue(),sessionId:X,projectId:e.apiKey,componentId:p,variantId:re,eventType:"goal_achieved",goalType:v,payload:I({reward:(q=T==null?void 0:T.reward)!=null?q:1},(D=T==null?void 0:T.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-w};e.debug&&console.log("[sentient] componentGoal",B),M.then(()=>S.push(B))},identify(p){let v=A.getSessionId();v&&M.then(()=>{fetch(`${E}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:p,ephemeral:A.isEphemeral()}),headers:j}).catch(()=>{})})},track(p){let v=A.getSessionId();if(!v)return;let T=me(I({},p),{id:Ue(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-w});e.debug&&console.log("[sentient] track",T),M.then(()=>S.push(T))},getAssignment(p,v){return C.get(p,v)},async assign(p,v,T,J){let q=A.getSessionId();if(!q)return null;let D=C.get(p,_);if(D&&(v!=null&&v.length||D.content!==void 0)){let K=D.ttlMs&&D.ttlMs>0?Math.max(0,D.assignedAt+D.ttlMs-Date.now()):0;return{variantId:D.variantId,assignmentTtlMs:K,content:D.content}}let X=Y.get(p);if(X)return X;let V=(async()=>{await M;try{let K={sessionId:q,componentId:p,variantIds:v};J!==void 0?K.agentDataByVariant=J:T!==void 0&&(K.agentData=T);let re=await fetch(`${E}/assign`,{method:"POST",body:JSON.stringify(K),headers:j});if(!re.ok)return null;let B=await re.json();return C.set(p,_,I({variantId:B.variantId,assignedAt:Date.now(),segment:_,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{Y.delete(p)}})();return Y.set(p,V),V},async decide(p){var v,T,J,q,D,X,V,K,re;let B=A.getSessionId();if(!B)return null;let pe=(v=p.slots)!=null?v:[];await M;try{let oe={sessionId:B};p.sections&&p.sections.length>0&&(oe.sections=p.sections.map(U=>({id:U}))),oe.components=(T=p.components)!=null?T:[],pe.length>0&&(oe.slots=pe.map($e)),p.slotsFrom==="registry"&&(oe.slotsFrom="registry"),p.v&&(oe.v=p.v);let He=await fetch(`${E}/decide`,{method:"POST",body:JSON.stringify(oe),headers:j});if(!He.ok)return k(pe),null;let R=await He.json(),fe={};for(let U of pe)fe[U.id]=(q=(J=R.slots)==null?void 0:J[U.id])!=null?q:Ke(U);if(R.slots)for(let[U,ge]of Object.entries(R.slots))U in fe||(fe[U]=ge);for(let[U,ge]of Object.entries(fe))y.set(U,ge);let Qt=h!=null&&h.persona!=="unknown";R.persona&&!(R.persona==="unknown"&&Qt)?h={persona:R.persona,confidence:(D=R.confidence)!=null?D:0}:h||(h={persona:"unknown",confidence:0});for(let[U,ge]of Object.entries((X=R.assignments)!=null?X:{}))C.set(U,_,{variantId:ge,assignedAt:Date.now(),segment:_,confidence:1});return he(e.apiKey,I({v:1,persona:h.persona,band:se(h.confidence),slots:Object.fromEntries(y),layoutOrder:(V=R.layoutOrder)!=null?V:null,savedAt:Date.now()},R.slotConfig?{slotConfig:R.slotConfig}:{})),I(I(I({layoutOrder:(K=R.layoutOrder)!=null?K:null,assignments:(re=R.assignments)!=null?re:{},slots:fe,persona:h.persona,confidence:h.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{}),R.sectionMap?{sectionMap:R.sectionMap}:{})}catch(oe){return k(pe),null}},getSlotResult(p){var v;return(v=y.get(p))!=null?v:null},getPersona(){return h?{persona:h.persona,confidence:h.confidence,band:se(h.confidence)}:null},async fetchWeights(){var p;try{let v=await fetch(`${E}/weights`,{headers:j});return v.ok?(p=(await v.json()).components)!=null?p:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;S.destroy(),((p=N.get(e.apiKey))==null?void 0:p.dispose)===G.dispose&&N.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;S.destroy(),A.destroy(),((p=N.get(e.apiKey))==null?void 0:p.dispose)===G.dispose&&N.delete(e.apiKey);try{localStorage.removeItem(Ee+e.apiKey),localStorage.removeItem(yt(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if(N.set(e.apiKey,{config:e,upgrade:null,dispose:G.dispose}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=G)}return G}var xt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Un=[["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]],Gn=[["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 qn(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function At(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 Un)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Gn)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 kt(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:qn(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function Et(e){return At(kt(e)).type}Se();var Ot="section, header, footer, nav, main > div, [data-sentient-section]";function Wn(e){var t;return((t=e.parentElement)==null?void 0:t.closest(Ot))!=null}function zn(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 It=()=>{};function Ct(e,t){var n,r,o,s,a,c,i,l,u;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||ae()||!t.apiKey)return It;let m=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Array.from(d.querySelectorAll(Ot)).filter(y=>!Wn(y));if(g.length===0)return It;let b=new Map,w=new Map,A=new Map;for(let y of g){let h=y.getAttribute("data-sentient-type"),k=h&&xt.includes(h)?h:null,f=(s=k!=null?k:(o=t.typeOf)==null?void 0:o.call(t,y))!=null?s:Et(y),x=`nc-${f}`;b.set(y,x),w.set(x,f),k?A.set(x,"markup"):A.has(x)||A.set(x,"auto")}let C=(l=(i=(c=(a=d.defaultView)!=null?a:typeof window!="undefined"?window:void 0)==null?void 0:c.location)==null?void 0:i.pathname)!=null?l:"/";zn(t.apiKey,m,C,[...w.entries()].map(([y,h])=>{var k;return{componentId:y,semanticType:h,source:(k=A.get(y))!=null?k:"auto"}}));let S=new Map,E=y=>{let h=S.get(y);return h||(h={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(y,h)),h},j=new IntersectionObserver(y=>{for(let h of y){let k=b.get(h.target);if(!k)continue;let f=E(k);h.isIntersecting?(f.intersecting=!0,f.enterAt=Date.now(),h.intersectionRatio>f.scroll&&(f.scroll=h.intersectionRatio)):(f.intersecting=!1,f.enterAt!=null&&(f.ms+=Date.now()-f.enterAt,f.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let y of b.keys())j.observe(y);let H=()=>{let y=Date.now();for(let[h,k]of S)if(k.enterAt!=null&&(k.ms+=y-k.enterAt,k.enterAt=null),!(k.ms<=0)){try{e.track({projectId:t.apiKey,componentId:h,eventType:"dwell",payload:{dwell_time:Math.round(k.ms),scroll_depth:Number(k.scroll.toFixed(2))}})}catch(f){}k.ms=0}},le=()=>{if(d.hidden)H();else{let y=Date.now();for(let h of S.values())h.intersecting&&(h.enterAt=y)}},ne=()=>{H();try{j.disconnect()}catch(y){}};d.addEventListener("visibilitychange",le);let _=(u=d.defaultView)!=null?u:typeof window!="undefined"?window:void 0;_==null||_.addEventListener("pagehide",ne);let Y=[];return t.microSignals&&[...b.entries()].forEach(([y,h],k)=>{Y.push(ye((f,x={})=>{try{e.track({projectId:t.apiKey,componentId:h,eventType:"micro_signal",payload:I({signalType:f},x)})}catch(M){}},y,void 0,{tabLoss:k===0}))}),()=>{H(),d.removeEventListener("visibilitychange",le),_==null||_.removeEventListener("pagehide",ne);for(let y of Y)y();try{j.disconnect()}catch(y){}}}var Jn=["landing","ecommerce","saas","marketplace"];function Vn(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(s=>typeof s=="string"))return null;n[r]=o}return n}function Fn(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ce(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=Jn.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[s,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let c=a,i=Vn(c.dims);if(!i||c.target!==void 0&&typeof c.target!="string")continue;let l=c.arms!==void 0?Fn(c.arms):null,u={dims:i};typeof c.target=="string"&&(u.target=c.target),l&&(u.arms=l),r[s]=u}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};return 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),o}function _t(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 Hn(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 Rt(e,t){return!!(e!=null&&e.urlMatch)&&!_t(t).includes(e.urlMatch)}var Yn=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Q(e,t){var o;if(e.urlMatch&&!_t(t).includes(e.urlMatch))return null;let n=[];if(e.id){let s=t.getElementById(e.id);n=s?[s]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Yn.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(s){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Hn(r,e.fingerprint)?null:r}var Tt={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"},Zn=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Pt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Zn.test((t=n[1])!=null?t:""))return!1;return!0}var Lt=/^https:\/\//i,Dt=new Map,ee=null;function Xn(e){return e.replace(/["\\]/g,"\\$&")}function Qn(e){var t;(!ee||!ee.isConnected)&&(ee=e.querySelector("style[data-sentient-ops]"),ee||(ee=e.createElement("style"),ee.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ee))),ee.textContent=[...Dt.entries()].map(([n,r])=>`[data-snt-e="${Xn(n)}"]{${r}}`).join(`
2
+ `)}function Mt(e,t,n,r){var c;let o=!1,s=(c=t.moveBefore)!=null?c:t.moveAfter;if(s){let i=Q(s,r);!i||i===e||i.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,i):e.parentElement.insertBefore(e,i.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Lt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Lt.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[i,l]of Object.entries(t.style)){let u=Tt[i];u&&typeof l=="string"&&Pt(l)&&a.push(`${u}:${l.trim()} !important`)}return a.length>0&&(e.setAttribute("data-snt-e",n),Dt.set(n,a.join(";")),Qn(r)),{anchorMiss:o}}function _e(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Re(e,t,n){var r;for(let[o,s]of Object.entries(t)){let a=e[o];if(!a||typeof a=="string")continue;let c=s.target?Array.from(n.querySelectorAll(s.target)):[n.documentElement];for(let i of c)for(let[l,u]of Object.entries(a))(r=s.dims[l])!=null&&r.includes(u)&&i.setAttribute(`data-${l}`,u)}}function Te(e,t,n){for(let[r,o]of Object.entries(t)){let s=e[r];if(typeof s!="string"||!o.arms||!o.arms.includes(s))continue;let a=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let c of a)c.setAttribute("data-sentient-arm",s)}}function Pe(e,t,n,r){var a,c;let o=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,s=[];for(let[i,l]of Object.entries(t)){if(Rt(l.locator,n))continue;let u;if(l.locator){let m=Q(l.locator,n);u=m?[m]:[]}else l.target?u=Array.from(n.querySelectorAll(l.target)):u=[n.documentElement];(l.locator||l.target)&&u.length===0&&s.push(i);let d=e[i];for(let m of u){if(d!==void 0)if(typeof d=="string")m.setAttribute("data-sentient-arm",d),o&&((c=r==null?void 0:r.onApplied)==null||c.call(r,i,d,m));else for(let[g,b]of Object.entries(d))m.setAttribute(`data-${g}`,b);o&&(typeof l.content=="string"&&(m.textContent=l.content),l.ops&&Mt(m,l.ops,i,n).anchorMiss&&!s.includes(i)&&s.push(i))}}return s}var er=800;function Le(e,t,n){let r=[];return n.forEach(({slotId:o,arm:s,el:a},c)=>{r.push(ye((m,g={})=>{try{e.track({projectId:t,componentId:o,variantId:s,eventType:"micro_signal",payload:ie({signalType:m},g)})}catch(b){}},a,void 0,{tabLoss:c===0}));let i=null,l=0,u=()=>{l=Date.now(),i=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-l}})}catch(m){}i=null},er)},d=()=>{i!==null&&(clearTimeout(i),i=null)};a.addEventListener("mouseenter",u),a.addEventListener("mouseleave",d),r.push(()=>{a.removeEventListener("mouseenter",u),a.removeEventListener("mouseleave",d),i!==null&&clearTimeout(i)})}),()=>{for(let o of r)o()}}function tr(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 nr(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 jt(e,t,n){var m;let r=new Set,o=g=>{if(!r.has(g.goalId)){r.add(g.goalId);try{g.slotId?t.componentGoal(g.slotId,g.goalId):t.goal(g.goalId)}catch(b){}}},s=e.filter(g=>g.event==="click"),a=e.filter(g=>g.event==="form_submit"),c=e.filter(g=>g.event==="url_reached"),i=(g,b)=>{if(!g.locator)return!1;let w=Q(g.locator,n);return!!w&&(w===b||w.contains(b))},l=g=>{let b=g.target;if(!(!b||typeof b.closest!="function"))for(let w of s)i(w,b)&&o(w)},u=g=>{let b=g.target;if(b)for(let w of a)i(w,b)&&o(w)},d=()=>{if(c.length===0)return;let g=tr(n);for(let b of c)b.urlPattern&&nr(b.urlPattern,g)&&o(b)};return n.addEventListener("click",l,!0),n.addEventListener("submit",u,!0),(m=n.defaultView)==null||m.addEventListener("popstate",d),d(),{checkUrl:d,teardown:()=>{var g;n.removeEventListener("click",l,!0),n.removeEventListener("submit",u,!0),(g=n.defaultView)==null||g.removeEventListener("popstate",d)}}}var Nt="__snt_editor_token";function $t(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Nt):null}catch(e){return null}}function Kt(e){try{sessionStorage.setItem(Nt,e)}catch(t){}}var ze="0.12.0",Jt=5e3,rr=50,$=null,P=null,Z={},te=null,W=null,L=null,F=null,O=null,Bt=!1,We=null,De=null,Me=null,ve=!1,je=!1;function Vt(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function ue(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function de(e,t){return $?($.personaAttributes&&O&&_e(O.persona,O.band,e),Re(Z,$.slots,e),Te(Z,$.slots,e),te?Pe(Z,te,e,t):[]):[]}function or(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!!($&&P&&$.sectionCapture!==!1&&($.consent!==!1||je)&&!ae())}function ir(){if(!P||!$||!be()||F)return;let e=[];de(document,{contentAndOps:ve,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Ve();try{L==null||L(),L=Le(P,$.apiKey,e)}catch(t){}}function Ve(){if(typeof document=="undefined"||!be())return;let e;try{if(De&&De.length>0){let t=new Map;for(let n of De){if(n.urlMatch!==window.location.pathname)continue;let r=Q(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{F=Ct(P,ie({apiKey:$.apiKey,apiBase:$.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Me=window.location.pathname}catch(t){}}function Fe(){try{let e=[];if(L==null||L(),L=null,de(document,{contentAndOps:ve,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&be())try{L=Le(P,$.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Me!==null&&window.location.pathname!==Me&&be()&&(F==null||F(),F=null,Ve())}catch(t){}}catch(e){}}function Ut(){We===null&&(We=setTimeout(()=>{We=null,Fe();try{W==null||W.checkUrl()}catch(e){}},rr))}function Gt(){if(!(Bt||typeof window=="undefined"||typeof history=="undefined")){Bt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,s){let a=n.call(this,r,o,s!=null?s:null);return Ut(),a}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Ut)}catch(e){}}}function Je(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 Ft(e){return new URLSearchParams(e).get("sentient_editor")}function sr(){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 ar(e,t){var n,r,o,s;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let i=document.createElement("meta");i.name="referrer",i.content="no-referrer",i.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(i)}catch(i){}let a=(o=e.editorSrc)!=null?o:sr();if(!a){Wt();return}let c=document.createElement("script");c.src=a,c.async=!0,c.onerror=()=>Wt(),((s=document.head)!=null?s:document.documentElement).appendChild(c)}catch(a){}}var qt="sentient-editor-load-notice";function Wt(){var e;try{if(typeof document=="undefined"||document.getElementById(qt))return;let t=document.createElement("div");t.id=qt,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 Ht(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(":"),s=o===-1?"":r.slice(0,o),a=o===-1?"":r.slice(o+1);if(!(!s||!a))if(a.includes("=")){let c={};for(let i of a.split(",")){let[l,u]=i.split("=");l&&u&&(c[l]=u)}Object.keys(c).length&&(n[s]=c)}else n[s]=a}return Object.keys(n).length?n:null}function Yt(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var zt="sentient-persona-preview-banner";function lr(e){var t;try{if(typeof document=="undefined"||document.getElementById(zt))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=zt,r.setAttribute("role","status"),Object.assign(r.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 o=document.createElement("span");o.textContent=`Previewing as ${n}`;let s=document.createElement("button");s.type="button",s.textContent="Exit preview",Object.assign(s.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),s.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){}}),r.appendChild(o),r.appendChild(s),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function cr(e,t){var l,u,d,m,g,b,w,A,C;let n=(l=e.apiBase)!=null?l:"https://api.sentient-ui.com",o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([S,E])=>({id:S,dims:E.dims}))},s=await Vt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(S=>S.ok?S.json():null).catch(()=>null),Jt);if(!s){ue(e,"persona preview: explain unavailable \u2014 page left as-is");return}let a=s;Z=(d=a.slots)!=null?d:{},te=(m=a.slotConfig)!=null?m:null;let c=(w=(b=(g=a.personaAttributes)==null?void 0:g.persona)!=null?b:a.persona)!=null?w:t,i=(C=(A=a.personaAttributes)==null?void 0:A.confidence)!=null?C:"high";O={persona:c,band:i},de(document),ve=!0,Zt(e),lr(c)}function Zt(e){let t={goal(n,r){try{P==null||P.goal(n,r)}catch(o){}},componentGoal(n,r){try{P==null||P.componentGoal(n,r)}catch(o){}},grantConsent(){try{qe(e.apiKey)}catch(n){}je=!0;try{ir()}catch(n){}},revokeConsent(){try{F==null||F(),F=null,Me=null,L==null||L(),L=null,W==null||W.teardown(),W=null,je=!1,P==null||P.destroy()}catch(n){}},reapply:Fe,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=O==null?void 0:O.persona)!=null?n:null,band:(r=O==null?void 0:O.band)!=null?r:null,slots:Z,matchCounts:Je(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function Xt(){var e,t,n,r,o;try{let s=Ce(window.sentient);if(!s)return;$=s,ve=!1,je=!1;let a=typeof window!="undefined"?Ft(window.location.search):null;if(a){Kt(a);try{let S=new URL(window.location.href);S.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",S.pathname+S.search+S.hash)}catch(S){}}let c=a!=null?a:$t();if(c){ar(s,c),ue(s,"editor mode");return}let i=typeof window!="undefined"?Ht(window.location.search):null;if(i){Z=i,O=null,de(document),Gt(),ue(s,"preview mode",i);return}let l=typeof window!="undefined"?Yt(window.location.search):null;if(l){await cr(s,l),ue(s,"persona preview",l);return}let u=(e=s.registry)!=null?e:Object.keys(s.slots).length===0,d=Ie(s.apiKey);d&&(O={persona:d.persona,band:d.band},Z=d.slots,d.slotConfig&&(te=d.slotConfig),de(document,{contentAndOps:!1}));let m=Oe({apiKey:s.apiKey,context:s.context,consent:s.consent,preConsentBehavior:s.preConsentBehavior,debug:s.debug});P=m,Zt(s),Gt();let g=Object.entries(s.slots).map(([S,E])=>({id:S,dims:E.dims})),b=ze!=="0.0.0-dev"?{v:ze}:{},w=await Vt(m.decide(ie(ie({slots:g},b),u?{slotsFrom:"registry"}:{})),Jt);if(!w){ue(s,"decide timeout/null \u2014 snapshot state stands",Je(s));return}let A=m.getPersona();A?O={persona:A.persona,band:A.band}:w.persona&&(O={persona:w.persona,band:"low"}),Z=w.slots,u?te=(t=w.slotConfig)!=null?t:null:w.slotConfig&&(te=w.slotConfig);let C=[];if(or(s,de(document,{onApplied:(S,E,j)=>C.push({slotId:S,arm:E,el:j})})),ve=!0,w.goals&&w.goals.length>0&&s.consent!==!1&&P)try{W==null||W.teardown(),W=jt(w.goals,P,document)}catch(S){}if(De=(n=w.sectionMap)!=null?n:null,be()){Ve();try{L==null||L(),L=Le(P,s.apiKey,C)}catch(S){}}ue(s,"applied",{persona:O,slots:Z,matches:Je(s)}),he(s.apiKey,ie({v:1,persona:(r=O==null?void 0:O.persona)!=null?r:w.persona,band:(o=O==null?void 0:O.band)!=null?o:"low",slots:w.slots,layoutOrder:w.layoutOrder,savedAt:Date.now()},te?{slotConfig:te}:{}))}catch(s){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Xt())}return on(ur);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.11.5",
3
+ "version": "0.12.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.16.7"
27
+ "@sentientui/core": "0.16.9"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",