@sentientui/core 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Qn=Object.create;var Me=Object.defineProperty,Xn=Object.defineProperties,Jn=Object.getOwnPropertyDescriptor,qn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertyNames,gn=Object.getOwnPropertySymbols,Zn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var pn=(e,t,n)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))fn.call(t,n)&&pn(e,n,t[n]);if(gn)for(var n of gn(t))eo.call(t,n)&&pn(e,n,t[n]);return e},ge=(e,t)=>Xn(e,qn(t));var to=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:!0})},mn=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Yn(t))!fn.call(e,d)&&d!==n&&Me(e,d,{get:()=>t[d],enumerable:!(s=Jn(t,d))||s.enumerable});return e};var yn=(e,t,n)=>(n=e!=null?Qn(Zn(e)):{},mn(t||!e||!e.__esModule?Me(n,"default",{value:e,enumerable:!0}):n,e)),no=e=>mn(Me({},"__esModule",{value:!0}),e);var nr={};to(nr,{AGENT_INTENTS:()=>pt,BLOCK_ALIGNS:()=>wo,BLOCK_EMPHASES:()=>Co,BLOCK_FITS:()=>Oo,BLOCK_GAPS:()=>xo,BLOCK_GRID_COLUMNS:()=>Do,BLOCK_HEADING_LEVELS:()=>Po,BLOCK_JUSTIFIES:()=>Eo,BLOCK_MAX_WIDTHS:()=>Mo,BLOCK_PADS:()=>Lo,BLOCK_RATIOS:()=>Ro,BLOCK_SIZES:()=>_o,BLOCK_SURFACES:()=>Bo,BLOCK_TEXT_ALIGNS:()=>To,BLOCK_TONES:()=>Ao,BLOCK_WEIGHTS:()=>Io,CLASSIC_CRAWLER_TOKENS:()=>Dt,CLICK_ID_KEYS:()=>Bt,FORM_FIELD_KINDS:()=>No,FORM_INPUT_TYPES:()=>Ko,LEGACY_SESSION_COOKIE_NAME:()=>be,LOCAL_MODE_BANNER:()=>Lt,MAX_BLOCK_ARMS:()=>Wo,MAX_BLOCK_CHILDREN:()=>jo,MAX_BLOCK_DEPTH:()=>Fo,MAX_BLOCK_NODES:()=>$o,MAX_BLOCK_TEXT_LEN:()=>Vo,MAX_FORM_FIELDS:()=>Go,MAX_FORM_SELECT_OPTIONS:()=>Uo,MAX_SKELETON_LEAVES:()=>Wr,MAX_SKELETON_NODES:()=>jr,MAX_SKELETON_TEXT:()=>Vr,PAGE_SCOPE_RE:()=>Nt,PROD_KEYLESS_ERROR:()=>vt,REVEAL_MS:()=>Gt,SNAPSHOT_STORAGE_KEY_PREFIX:()=>fe,STAGE_ATTRIBUTE:()=>yt,_registerConsentUpgradeInit:()=>Qo,agentIntent:()=>En,agentUaList:()=>Ue,applyNonce:()=>Ze,armOfResult:()=>mt,attachMicroSignalDetectors:()=>Nn,baselineResultFor:()=>Oe,baselineSlots:()=>An,classifiedAgents:()=>_n,containsFormBlock:()=>Bn,cspNonce:()=>Tt,deriveSessionSegment:()=>In,detectDeviceClass:()=>Fe,detectTimeOfDay:()=>Ve,detectTrafficSource:()=>je,exposedStage:()=>St,extractTrackedParams:()=>ft,forgetGeneration:()=>ie,forgetVisitor:()=>st,grantConsent:()=>er,init:()=>Wn,isDoNotTrackEnabled:()=>Ht,matchedAgentToken:()=>gt,matchedCrawlerToken:()=>Pt,normalizeUrlPattern:()=>Pn,pageScopeMatches:()=>On,readSnapshot:()=>_e,referrerDomainFromReferer:()=>We,renderPrePaintScript:()=>Sn,resetRevealStyles:()=>Ln,reveal:()=>Mn,routeKey:()=>Wt,sessionCookieName:()=>Ee,setCspNonce:()=>Ye,setStageAttribute:()=>ht,toWireSlot:()=>He,uaTokenMatch:()=>$e,urlMatches:()=>Dn,writeSnapshot:()=>Ie});module.exports=no(nr);function ue(e){if(typeof AbortController!="function")return{clear:()=>{}};let t=new AbortController,n=setTimeout(()=>t.abort(),e);return{signal:t.signal,clear:()=>clearTimeout(n)}}function qe(e,t){return new Promise(n=>{let s=setTimeout(()=>n(!1),t),d=()=>{clearTimeout(s),n(!0)};e.then(d,d)})}var Ct;function Ye(e){Ct=typeof e=="string"&&e!==""?e:void 0}function Tt(e=document){if(Ct)return Ct;try{let t=e.querySelector("script[nonce]");return(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"))||void 0}catch(t){return}}function Ze(e,t=document){let n=Tt(t);return n&&e.setAttribute("nonce",n),e}function pe(e){return e?`_${e.slice(0,12)}`:""}var be="_snt_uid";function Ee(e){return`${be}${pe(e)}`}var et="__sntForgetGen",oo=()=>{try{return window[et]}catch(e){return}};function tt(e){var t,n;try{let s=window,d=(t=s[et])!=null?t:s[et]={};d[e]=((n=d[e])!=null?n:0)+1}catch(s){}}function ie(e){var t,n;return(n=(t=oo())==null?void 0:t[e])!=null?n:0}var fe="_snt_snap:";var ro=["low","medium","high"];function _e(e){try{let t=localStorage.getItem(fe+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!ro.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"||!(Date.now()-n.savedAt<2592e6)||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig)))return null;let s=n.vocabulary;return s!==void 0&&(typeof s!="object"||s===null||!Array.isArray(s.entries)||!Array.isArray(s.images))&&delete n.vocabulary,n.stage!==void 0&&typeof n.stage!="string"&&delete n.stage,n}catch(t){return null}}function Ie(e,t){try{localStorage.setItem(fe+e,JSON.stringify(t))}catch(n){}}function Sn(e,t){return'(function(){try{var N=navigator,W=window;if(N.doNotTrack=="1"||N.doNotTrack=="yes"||W.doNotTrack=="1"||N.msDoNotTrack=="1"||N.globalPrivacyControl)return;var r=localStorage.getItem('+JSON.stringify(fe+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;if(!('+2592e6+">Date.now()-s.savedAt))return;var d=document.documentElement;"+(t!=null&&t.stage?'if(typeof s.stage=="string"&&!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",s.stage);':"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}function me(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Ae(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function nt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let s=JSON.parse(n);return Array.isArray(s)?(localStorage.removeItem(e),s.slice(-t)):[]}catch(n){return[]}}function Ne(e,t,n){try{let s=(()=>{try{let g=localStorage.getItem(n);if(!g)return[];let S=JSON.parse(g);return Array.isArray(S)?S:[]}catch(g){return[]}})(),d=new Map;for(let g of s)d.set(g.id,g);for(let g of e)d.set(g.id,g);localStorage.setItem(n,JSON.stringify([...d.values()].slice(-t)))}catch(s){}}function ot(e,t){try{let n=localStorage.getItem(t);if(!n)return;let s=JSON.parse(n);if(!Array.isArray(s))return;let d=new Set(e),g=s.filter(S=>!d.has(S.id));if(g.length===s.length)return;g.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(g))}catch(n){}}var so=500,io=56*1024;function Ke(e){return`_snt_retry_${e.slice(0,12)}`}var ao={push:()=>{},flush:()=>{},destroy:()=>{}};function hn(e){var G,X,F;if(typeof window=="undefined")return ao;let t=(G=e.flushIntervalMs)!=null?G:5e3,n=(X=e.maxBatchSize)!=null?X:20,s=(F=e.maxRetrySize)!=null?F:100,d=e.ingestUrl,g=e.apiKey,S=Ke(g),o=!1,f=ie(g),l=(...x)=>{!o&&ie(g)===f&&Ne(...x)},i=[],u=new Set,h=[],T=x=>{for(let D of x)R.delete(D),!u.has(D)&&(u.add(D),h.push(D));for(;h.length>so;){let D=h.shift();D&&u.delete(D)}ot(x,S)},R=new Set,M=()=>{for(;i.length>s;){let x=i.shift();x&&R.delete(x.id)}},z=x=>{u.has(x.id)||R.has(x.id)||(R.add(x.id),i.push(x),M())},P=x=>{for(let D of x)u.has(D.id)||(R.add(D.id),i.push(D));M()},L=nt(S,s);for(let x of L)z(x);let Q=0,V=0,Y=(x,D=!0)=>{if(x.length===0)return;let ae=JSON.stringify(x),ye=x.map(Se=>Se.id),ne,xe=ue(15e3);try{ne=fetch(d,{method:"POST",keepalive:!0,signal:xe.signal,body:ae,headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`}})}catch(Se){l(x,s,S),P(x),V++,Q=Date.now()+me(V);return}Promise.resolve(ne).then(xe.clear,xe.clear);let Pe=Se=>{if(Ae(Se)!=="retry"){if(!Se.ok&&D){let ke=x.filter(re=>re.eventType!=="pageview");if(ke.length>0&&ke.length<x.length){T(x.filter(re=>re.eventType==="pageview").map(re=>re.id)),Y(ke,!1);return}}T(ye),V=0,Q=0;return}l(x,s,S),P(x),V++,Q=Date.now()+me(V)};ne&&typeof ne.then=="function"?ne.then(Pe).catch(()=>{l(x,s,S),P(x),V++,Q=Date.now()+me(V)}):Pe(ne)},te=typeof TextEncoder!="undefined"?new TextEncoder:null,c=x=>te?te.encode(x).length:x.length,p=x=>{let D=[],ae=2;for(let ye of x){let ne=c(JSON.stringify(ye))+1;if(D.length>0&&ae+ne>io||D.length>=n)break;D.push(ye),ae+=ne}return D},_=()=>{try{if(Date.now()<Q)return;for(;i.length>0&&!(Date.now()<Q);){let x=i.filter(ae=>!u.has(ae.id));if(i.length=0,x.length===0)break;let D=p(x);if(D.length===0)break;D.length<x.length&&i.push(...x.slice(D.length)),Y(D)}}catch(x){}},m=!0,v=null;v=setInterval(()=>{m&&_()},t);let N=()=>{document.visibilityState==="hidden"&&_()},j=()=>{_()};return document.addEventListener("visibilitychange",N),window.addEventListener("pagehide",j),{push(x){z(x),i.length>=n&&_()},flush:_,destroy(x){x!=null&&x.forget&&(o=!0),m=!1,v!==null&&(clearInterval(v),v=null),document.removeEventListener("visibilitychange",N),window.removeEventListener("pagehide",j),_()}}}var lo=200;function Ge(e){return`_snt_goal_retry_${e.slice(0,12)}`}var co={send:()=>{},flush:()=>{},destroy:()=>{}};function bn(e){var c,p,_;if(typeof window=="undefined")return co;let t=(c=e.flushIntervalMs)!=null?c:5e3,n=(p=e.maxRetrySize)!=null?p:100,s=(_=e.maxPerFlush)!=null?_:5,d=Ge(e.apiKey),g=!1,S=ie(e.apiKey),o=(...m)=>{!g&&ie(e.apiKey)===S&&Ne(...m)},f=[],l=new Set,i=new Set,u=[],h=0,T=0,R=!1,M=m=>{for(l.delete(m.id),i.has(m.id)||(i.add(m.id),u.push(m.id));u.length>lo;){let v=u.shift();v&&i.delete(v)}ot([m.id],d)},z=m=>{o([m],n,d),!i.has(m.id)&&!l.has(m.id)&&(l.add(m.id),f.push(m)),Date.now()>=h&&(T++,h=Date.now()+me(T))},P=m=>{let v,N=ue(15e3);try{v=fetch(e.url,{method:"POST",keepalive:!0,signal:N.signal,body:m.body,headers:e.headers})}catch(G){z(m);return}let j=G=>{var F;let X=Ae(G);if(X==="retry"){z(m);return}X==="dropped"&&((F=e.onDrop)==null||F.call(e,m,G.status)),M(m),T=0,h=0};Promise.resolve(v).then(N.clear,N.clear),v&&typeof v.then=="function"?v.then(j).catch(()=>z(m)):j(v)},L=()=>{try{if(R||Date.now()<h)return;let m=0;for(;f.length>0&&m<s&&!(Date.now()<h);){let v=f.shift();l.delete(v.id),!i.has(v.id)&&(m++,P(v))}}catch(m){}},Q=nt(d,n);for(let m of Q)l.has(m.id)||(l.add(m.id),f.push(m));Q.length>0&&Ne(Q,n,d);let V=setInterval(L,t),Y=()=>{document.visibilityState==="hidden"&&L()},te=()=>L();return document.addEventListener("visibilitychange",Y),window.addEventListener("pagehide",te),{send(m){if(R){i.has(m.id)||o([m],n,d);return}if(!(i.has(m.id)||l.has(m.id))){if(Date.now()<h){o([m],n,d),l.add(m.id),f.push(m);return}P(m)}},flush:L,destroy(m){m!=null&&m.forget&&(g=!0),clearInterval(V),document.removeEventListener("visibilitychange",Y),window.removeEventListener("pagehide",te),L(),R=!0}}}function rt(e){let t=(e||"").toLowerCase();if(!t.includes(".")||/^[\d.]+$|:/.test(t))return[];let n=t.split("."),s=[];for(let d=n.length-2;d>=0;d--)s.push(n.slice(d).join("."));return s}function st(e){if(typeof window=="undefined"||!e)return!1;tt(e);let t=!1,n=Ee(e);try{if(new RegExp(`(?:^|; )${n}=`).test(document.cookie)){let S=location.protocol==="https:"?"; Secure":"";for(let o of["",...rt(location.hostname)])document.cookie=`${n}=; max-age=0; SameSite=lax; path=/${o?`; domain=${o}`:""}${S}`;t=!0}}catch(S){}let s=pe(e),d=[n,"_snt_graph_edges",fe+e,Ke(e),Ge(e),`_snt_graph_nodes${s}`],g=[`_snt_asgn${s}_`];for(let S of["localStorage","sessionStorage"])try{let o=window[S];for(let f of d)o.getItem(f)!==null&&(o.removeItem(f),t=!0);for(let f=o.length-1;f>=0;f--){let l=o.key(f);l&&g.some(i=>l.startsWith(i))&&(o.removeItem(l),t=!0)}}catch(o){}try{(new RegExp(`(?:^|; )${be}=[^;]`).test(document.cookie)||localStorage.getItem(be)!==null||sessionStorage.getItem(be)!==null)&&localStorage.setItem(`${be}_tomb${s}`,"1")}catch(S){}return t}function it(){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 kn="_snt_uid",uo=365,Ce="_snt_uid";function go(){return it()}function Te(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function xn(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function ct(e,t,n,s){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=lax; path=/${s?`; domain=${s}`:""}${xn()}`}catch(d){}}function at(e){try{return localStorage.getItem(e)}catch(t){return null}}function vn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Ot(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function po(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function fo(e){try{sessionStorage.removeItem(e)}catch(t){}}function mo(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${xn()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function yo(e){try{localStorage.removeItem(e)}catch(t){}}function lt(e,t){ct(e,"",0,t)}var So={getSessionId:()=>null,isEphemeral:()=>!1,domain:null,destroy:()=>{}};function ho(e,t){if(e===!1)return null;if(typeof e=="string")return e.replace(/^\./,"");for(let n of rt(location.hostname))if(ct(t,"1",10,n),Te(t)==="1")return lt(t,n),n;return null}function dt(e){var P,L,Q,V,Y,te,c;if(typeof window=="undefined")return So;let t=pe(e==null?void 0:e.apiKey),n=(P=e==null?void 0:e.cookieName)!=null?P:Ee(e==null?void 0:e.apiKey),s=`${Ce}${t}`,d=`${Ce}_tomb${t}`,S=((L=e==null?void 0:e.cookieTTLDays)!=null?L:uo)*24*60*60,o=p=>p&&p.length>0?p:null,f=()=>{var p,_;return t&&!(e!=null&&e.cookieName)&&at(d)===null?(_=(p=o(Te(kn)))!=null?p:o(at(Ce)))!=null?_:o(Ot(Ce)):null},l=ho(e==null?void 0:e.cookieDomain,`${n}_dom`),i=o(Te(n)),u=l?(lt(n),o(Te(n))):null,h=(c=(te=(Y=(V=(Q=u!=null?u:i)!=null?Q:o(at(s)))!=null?V:o(Ot(s)))!=null?Y:f())!=null?te:o(e==null?void 0:e.ssrSessionId))!=null?c:go();ct(n,h,S,l),l&&Te(n)!==h&&(l=null,ct(n,h,S));let T=vn(s,h),R=mo(n),M=T?!1:po(s,h),z=!T&&!R&&!M;return{getSessionId:()=>h,isEphemeral:()=>z,domain:l,destroy:()=>{h=null,lt(n),lt(n,l),yo(s),fo(s),t&&!(e!=null&&e.cookieName)&&(Te(kn)!==null||at(Ce)!==null||Ot(Ce)!==null)&&vn(d,"1")}}}var bo=1800*1e3;function ut(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function wn(e=bo,t){let n=new Map,s=`_snt_asgn${pe(t)}_`,d=(l,i)=>`${s}${encodeURIComponent(l)}:${encodeURIComponent(i)}`,g=l=>{let i=l.slice(s.length),u=i.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,u)),segment:decodeURIComponent(i.slice(u+1))}}catch(h){return null}},S=()=>{try{let l=[];for(let i=0;i<localStorage.length;i++){let u=localStorage.key(i);u!=null&&u.startsWith(s)&&l.push(u)}return l}catch(l){return[]}},o=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of S())try{let i=localStorage.getItem(l);if(!i)continue;let u=JSON.parse(i);if(o(u)){localStorage.removeItem(l);continue}let h=g(l);if(!h)continue;n.set(ut(h.componentId,h.segment),u)}catch(i){}})(),{get(l,i){let u=n.get(ut(l,i));return u?o(u)?(n.delete(ut(l,i)),null):u:null},set(l,i,u){let h=ut(l,i);n.set(h,u);try{localStorage.setItem(d(l,i),JSON.stringify(u))}catch(T){}},clear(){n.clear();for(let l of S())try{localStorage.removeItem(l)}catch(i){}}}}var Ue=["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 $e(e){return gt(e)!==null}function gt(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ue.find(s=>t.includes(s.toLowerCase())))!=null?n:null}var Dt=["Googlebot","Bingbot","DuckDuckBot","YandexBot","Baiduspider","Applebot","Slurp","facebookexternalhit","LinkedInBot","Twitterbot"];function Pt(e){var s;let t=gt(e);if(t)return t;if(!e)return null;let n=e.toLowerCase();return(s=Dt.find(d=>n.includes(d.toLowerCase())))!=null?s:null}var pt={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function En(e){if(!e)return"other";let t=Ue.find(n=>n.toLowerCase()===e.toLowerCase());return t&&pt[t]||"other"}function _n(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of Ue)e[(t=pt[n])!=null?t:"other"].push(n);return e}function Fe(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 je(e,t,n){if(!e)return"direct";try{let s=new URL(e);if(t)try{if(new URL(t).host===s.host)return"direct"}catch(g){}let d=s.hostname.toLowerCase();return n&&`.${d}`.endsWith(`.${n}`)?"direct":/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(d)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(d)?"social":"referral"}catch(s){return"direct"}}function We(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Bt=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function ft(e){let t={},n={};try{let s=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([d,g])=>{let S=Array.isArray(g)?g[0]:g;return S===void 0?[]:[[d,S]]});for(let[d,g]of s)d.startsWith("utm_")?d in t||(t[d]=g):Bt.includes(d)&&(d in n||(n[d]=g))}catch(s){}return{utmParams:t,clickIds:n}}function Ve(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function In(e){let t=ko("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function ko(e,t){var S,o,f,l,i,u,h,T;let n=(o=(S=t==null?void 0:t.userAgent)==null?void 0:S.trim())!=null?o:"",s=(l=(f=t==null?void 0:t.referer)==null?void 0:f.trim())!=null?l:"",d=(i=t==null?void 0:t.now)!=null?i:new Date,g=Pt(n);return A(A({sessionId:e,ephemeral:!1,utmParams:(u=t==null?void 0:t.utmParams)!=null?u:{},clickIds:(h=t==null?void 0:t.clickIds)!=null?h:{},deviceClass:n?Fe(n):"desktop",trafficSource:s?je(s,t==null?void 0:t.appOrigin):"direct",referrerDomain:We(s),timeOfDay:Ve(d),dayOfWeek:(T=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?T:"sun",automation:(t==null?void 0:t.webdriver)===!0||$e(n)},g?{agentToken:g}:{}),t!=null&&t.landingPath?{landingPath:t.landingPath.split(/[?#]/)[0]}:{})}var Re=require("@sentientui/policy");function He(e){return A(A(A({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 Oe(e){let t=He(e);return(0,Re.slotResultFor)(t,(0,Re.slotBaselineArm)(t))}function An(e){let t={};for(let n of e)t[n.id]=Oe(n);return t}function mt(e){return typeof e=="string"?e:(0,Re.canonicalArm)(e)}var Cn=require("@sentientui/policy"),yt="data-sentient-stage";function St(e,t){return!t||typeof e!="string"||!(e==="returning"||Cn.STAGE_KEYS.includes(e))?null:t!=="detailed"&&(e==="customer"||e==="lapsed")?"returning":e}function ht(e,t=document){try{e?t.documentElement.setAttribute(yt,e):t.documentElement.removeAttribute(yt)}catch(n){}}var jt=require("@sentientui/policy");var kt=require("@sentientui/policy");var vt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Lt="[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.",Tn=!1,bt=!1;function vo(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Rn(e){var l;let t=dt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(l=t.getSessionId())!=null?l:"local",s=vo(),d=import("@sentientui/core/local").then(i=>{let u=i;return u.LOCAL_ENGINE_AVAILABLE?(Tn||(Tn=!0,console.info(Lt)),u):(bt||(bt=!0,console.error(vt)),null)}).catch(()=>(bt||(bt=!0,console.error(vt)),null)),g=null,S={low:.15,medium:.5,high:.85},o=(()=>{var u;if(e.initialPersona)return A({},e.initialPersona);let i=_e(e.apiKey||"local");return i?{persona:i.persona,confidence:(u=S[i.band])!=null?u:.15}:null})();function f(i){let u=document.documentElement;u.dataset.sentientPersona===void 0&&(u.dataset.sentientPersona=i.persona,u.dataset.sentientConfidence=(0,kt.confidenceBand)(i.confidence))}return{isLocal:!0,async decide(i){var T,R,M;let u=await d;if(!u)return null;let h=u.createLocalEngine({sessionId:n,forcedPersona:s}).decide(i);return g=ge(A({},h),{layoutOrder:(R=(T=h.layoutOrder)!=null?T:g==null?void 0:g.layoutOrder)!=null?R:null,slots:A(A({},(M=g==null?void 0:g.slots)!=null?M:{}),h.slots)}),Ie(e.apiKey||"local",{v:1,persona:g.persona,band:(0,kt.confidenceBand)(g.confidence),slots:g.slots,layoutOrder:g.layoutOrder,savedAt:Date.now()}),f(h),h},getSlotResult(i){var u,h,T;return(T=(h=g==null?void 0:g.slots[i])!=null?h:(u=e.initialSlots)==null?void 0:u[i])!=null?T:null},getSlotConfig(i){var u,h;return(h=(u=e.initialSlotConfig)==null?void 0:u[i])!=null?h:null},getSitePalette(){var i;return(i=e.initialPalette)!=null?i:null},reportSlots(){},getVisitorId:()=>null,getPersona(){let i=g!=null?g:o;return i?{persona:i.persona,confidence:i.confidence,band:(0,kt.confidenceBand)(i.confidence)}:null},async assign(i,u){var R;let h=await d;return!h||!u||u.length===0?u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null:{variantId:(R=h.createLocalEngine({sessionId:n,forcedPersona:s}).decide({components:[{id:i,variantIds:u}]}).assignments[i])!=null?R:u[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>t.destroy()}}var Nt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Mt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function On(e,t){if(e===void 0||!Nt.test(e))return!1;if(e==="*")return!0;let n=Mt(t);if(e.endsWith("/*")){let s=Mt(e.slice(0,-2));return n.startsWith(s==="/"?"/":`${s}/`)&&n!==s}return n===Mt(e)}function Dn(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 Pn(e){if(!/^https?:\/\//i.test(e))return e;try{return new URL(e).pathname||"/"}catch(t){return e}}var xo=["none","sm","md","lg"],wo=["start","center","end","stretch"],Eo=["start","center","end","between"],_o=["sm","md","lg"],Io=["normal","medium","bold"],Ao=["default","muted","accent"],Co=["primary","secondary","ghost"],To=["left","center","right"],Ro=["auto","square","landscape","wide"],Oo=["cover","contain"],Do=[2,3,4],Po=[1,2,3,4],Bo=["default","raised"],Lo=["none","sm","md","lg"],Mo=["measure"],No=["input","textarea","select"],Ko=["text","email","number","tel"],Go=5,Uo=8,$o=64,Fo=5,jo=12,Wo=4,Vo=500;function Bn(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(Bn):!1}var jr=40,Wr=120,Vr=300;var Kt="sentient-reveal",De="sentient-revealed",Gt=240,xt=!1;function Ln(){var e;xt=!1,typeof document!="undefined"&&((e=document.getElementById(Kt))==null||e.remove())}function Ho(e){if(xt||e.getElementById(Kt)){xt=!0;return}let t=Ze(e.createElement("style"),e);t.id=Kt,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${De}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${De}{animation:${De} ${Gt}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),xt=!0}function Mn(e,t={}){var d;let n=(d=t.doc)!=null?d:typeof document!="undefined"?document:void 0;if(!n||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;Ho(n),e.classList.remove(De),e.offsetWidth,e.classList.add(De);let s=()=>{e.classList.remove(De),e.removeEventListener("animationend",s)};return e.addEventListener("animationend",s),!0}function Nn(e,t,n,s){let d=[];{let o=!1,f=[],l=()=>{if(o)return;let i=Date.now();for(f.push(i);f.length>0&&i-f[0]>500;)f.shift();f.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",l),d.push(()=>t.removeEventListener("click",l))}{let g=!1,S=o=>{if(g||!(o.target instanceof Node)||!t.contains(o.target)&&t!==o.target)return;g=!0;let f=typeof window!="undefined"?window.getSelection():null,l=f?f.toString().length:0;e("text_copy",{selectionLength:l})};document.addEventListener("copy",S),d.push(()=>document.removeEventListener("copy",S))}{let g=!1,S=!1,o=null,f=()=>{o!==null&&(clearTimeout(o),o=null)},l=()=>{g||!S||(f(),o=setTimeout(()=>{!g&&S&&(g=!0,e("scroll_hesitation"))},3e3))},i=()=>{f(),l()},u=T=>{for(let R of T)S=R.intersectionRatio>.3,S?l():f()},h=new IntersectionObserver(u,{threshold:[.3]});h.observe(t),window.addEventListener("scroll",i,{passive:!0}),d.push(()=>{h.disconnect(),window.removeEventListener("scroll",i),f()})}if((s==null?void 0:s.tabLoss)!==!1){let g=!1,S=n!=null?n:Date.now(),o=()=>{if(g||document.visibilityState!=="hidden")return;let f=Date.now()-S;f<15e3&&(g=!0,e("tab_loss",{timeOnPage:f}))};document.addEventListener("visibilitychange",o),d.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let g of d)g()}}function zo(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Un="https://api.sentient-ui.com/v1/events",Gn=()=>import("@sentientui/core/internal-traffic"),q=new Map,$n=null;function Qo(e,t){let n=q.get(e);n&&n.upgrade&&(n.reinit=t)}function Xo(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Jo=3;function $t(){return it()}function wt(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function qo(){let e=new WeakMap,t=new Map,n=!1,s=(o,f,l)=>{let i=o.get(f);return l===null?i?!0:(o.set(f,new Set),!1):i?i.has(l)?!0:(i.add(l),!1):(o.set(f,new Set([l])),!1)},d=typeof window!="undefined"&&"event"in window,g=()=>{if(!d)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},S=()=>{if(d){Promise.resolve().then(()=>{n=!1,t.clear()});return}let o=!1,f=()=>{o||(o=!0,n=!1,t.clear())};if(setTimeout(f,0),typeof MessageChannel=="function"){let l=new MessageChannel;l.port1.onmessage=()=>{l.port1.close(),l.port2.close(),f()},l.port2.postMessage(0)}};return{firedBefore(o,f){let l=g();if(l){let u=e.get(l);return u||(u=new Map,e.set(l,u)),s(u,o,f)}let i=s(t,o,f);return!i&&!n&&(n=!0,S()),i}}}var Fn=new Set;function Yo(e,t,n){let s=typeof window=="undefined"?null:window.history;if(!s)return()=>{};let d=!1,g,S=()=>{if(d)return;let l=wt();!l||l===g||(g=l,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${l}`))},o=[];for(let l of["pushState","replaceState"]){let i=s[l],u=function(...h){let T=i.apply(this,h);return S(),T};s[l]=u,o.push([l,i,u])}window.addEventListener("popstate",S);let f=wt();return f&&Fn.has(`${t}:${f}`)?g=f:S(),()=>{if(!d){d=!0,window.removeEventListener("popstate",S);for(let[l,i,u]of o)s[l]===u&&(s[l]=i)}}}var ze={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Zo(){try{return ft(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function jn(e){return e.replace(/\/events\/?$/,"")}function Ht(){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(t=>t==="1"||t==="yes")}function er(e){var f;if(typeof window=="undefined")return;let t=e!=null?e:$n;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=q.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:s,upgrade:d,reinit:g}=n;if(!d){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(s.respectDoNotTrack!==!1&&Ht())return;let S=(g!=null?g:Wn)(ge(A({},s),{consent:!0}));d(S);let o=(f=q.get(t))==null?void 0:f.dispose;q.set(t,{config:ge(A({},s),{consent:!0}),upgrade:null,dispose:o})}function tr(e,t){var te;let n=e.preConsentBehavior==="statistical_winner",s=jn((te=e.ingestUrl)!=null?te:Un),d={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Map,S=new Map,o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(c,p,_){if(!n)return Promise.resolve(null);let m=g.get(c);return m?Promise.resolve(m):Vt(S,c,async()=>{try{let v=new URLSearchParams({componentId:c});for(let X of p!=null?p:[])v.append("variantIds[]",X);let N=ue(5e3),j;try{let X=await fetch(`${s}/winner?${v.toString()}`,{headers:d,signal:N.signal});if(!X.ok)return p!=null&&p[0]?{variantId:p[0],assignmentTtlMs:0}:null;j=await X.json()}finally{N.clear()}let G={variantId:j.variantId,assignmentTtlMs:0};return g.set(c,G),G}catch(v){return p!=null&&p[0]?{variantId:p[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},f=!1,l=new Set,i=[],u=[],h=[],T=()=>{for(let[,,c]of h.splice(0))c(null);R.length=0},R=[],M=!1,z=()=>{if(f)return;M=!0;let c=q.get(e.apiKey);(c==null?void 0:c.upgrade)===Y&&q.set(e.apiKey,{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): client released before consent; call init() again"})},P=[],L=()=>{setTimeout(()=>{var c;try{(c=P.shift())==null||c(o)}catch(p){}P.length&&L()})},Q=c=>{f?P.length?P.push(c):c(o):!t&&!M&&R.length<100?R.push(c):M&&e.debug&&console.warn("[sentient] goal dropped: client released")},V={get gated(){return!f&&!t},get released(){return M&&!f},takeHeld:()=>R.splice(0),track:c=>o.track(c),goal:((c,p,_,m)=>Q(v=>v.goal(c,p,_,m))),componentGoal:(c,p,_)=>o.componentGoal(c,p,_),identify:(c,p)=>o.identify(c,p),getAssignment:(c,p)=>o.getAssignment(c,p),isUnified:c=>{var p,_;return(_=(p=o.isUnified)==null?void 0:p.call(o,c))!=null?_:!1},assign:(c,p,_,m,v)=>o.assign(c,p,_,m,v),decide:c=>f?o.decide(c):M||t?Promise.resolve(null):new Promise(p=>h.push([c,Wt(),p])),getSlotResult:c=>o.getSlotResult(c),isSlotDecided:c=>{var p,_;return(_=(p=o.isSlotDecided)==null?void 0:p.call(o,c))!=null?_:!0},getSlotConfig:c=>o.getSlotConfig(c),getSitePalette:()=>o.getSitePalette(),getStyleVocabulary:()=>{var c,p;return(p=(c=o.getStyleVocabulary)==null?void 0:c.call(o))!=null?p:null},reportSlots:(c,p,_,m)=>o.reportSlots(c,p,_,m),reportSkeleton:(c,p)=>{var _;return(_=o.reportSkeleton)==null?void 0:_.call(o,c,p)},reportAgentData:(c,p,_)=>{var m;return(m=o.reportAgentData)==null?void 0:m.call(o,c,p,_)},reportDrift:(c,p,_,m)=>{var v;return(v=o.reportDrift)==null?void 0:v.call(o,c,p,_,m)},requestSlots:(c,p,_)=>{var m;return f?(m=o.requestSlots)==null?void 0:m.call(o,c,p,_):i.push([c,p,_])},decideSlots:c=>{var p;return f?(p=o.decideSlots)==null?void 0:p.call(o,c):u.push(...c)},cancelSlots:c=>{var _;if(f)return(_=o.cancelSlots)==null?void 0:_.call(o,c);let p=new Set(c);for(let m of i)m[0]=m[0].filter(v=>!p.has(v));u=u.filter(m=>!p.has(m.id))},onSlotsChanged:c=>(l.add(c),()=>{l.delete(c)}),getPersona:()=>o.getPersona(),getVisitorId:()=>{var c,p;return(p=(c=o.getVisitorId)==null?void 0:c.call(o))!=null?p:null},fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>(z(),T(),o.dispose()),destroy:()=>(z(),T(),f?o.destroy():st(e.apiKey))};function Y(c){var _,m,v;o=c,f=!0,R.length&&(P.push(...R.splice(0)),L());let p=Wt();for(let[N,j,G]of h.splice(0))j!==p?G(null):c.decide(N).then(G,()=>G(null));(_=c.onSlotsChanged)==null||_.call(c,()=>l.forEach(N=>N()));for(let[N,j,G]of i.splice(0))N.length>0&&((m=c.requestSlots)==null||m.call(c,N,j,G));u.length>0&&((v=c.decideSlots)==null||v.call(c,u.splice(0)))}return{proxy:V,setInner:Y}}function Wt(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function Vt(e,t,n){let s=e.get(t);if(s)return s;let d=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,d),d}function Wn(e){var Yt,Zt,en,tn,nn,on,rn,sn,an,ln,cn;if(typeof window=="undefined")return ze;e.nonce&&Ye(e.nonce),$n=e.apiKey||"local";let t=q.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(r){}let n=e.respectDoNotTrack!==!1&&Ht(),s=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!d&&e.localMode!==!1)return q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),s?ze:Rn(e);if(s){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),ze;let{proxy:r,setInner:a}=tr(e,n);return q.set(e.apiKey,{config:e,upgrade:n?null:a}),r}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."),ze;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ze;let g=(Yt=e.ingestUrl)!=null?Yt:Un,S=Date.now(),o=dt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey,cookieDomain:e.cookieDomain}),f={},l;try{/sentient_internal=/.test(location.search+document.cookie)&&(l=Gn().then(async r=>{f.internalToken=await r.takeInternalToken(o.domain)||void 0}).catch(()=>{})),(typeof e.internal=="function"?e.internal():e.internal)===!0&&(f.internal=!0)}catch(r){}let i=wn(void 0,e.apiKey),u=!1,h=ie(e.apiKey),T=()=>!u&&ie(e.apiKey)===h,R=new Set((Zt=e.initialUnified)!=null?Zt:[]),M=ge(A({},i),{get:(r,a)=>R.has(r)?null:i.get(r,a),set:(...r)=>{T()&&i.set(...r)}}),z=hn({ingestUrl:g,apiKey:e.apiKey}),P=jn(g),L={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},Q=new Set,V=bn({url:`${P}/goals`,apiKey:e.apiKey,headers:L,onDrop:(r,a)=>{if(!e.debug){if(Q.has(a))return;Q.add(a)}console.warn(`[sentient] goal dropped (HTTP ${a}) \u2014 this will not be retried. `+(a===400?"The session was not found: call init() and let the session upsert complete before firing goals.":a===401||a===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),r)}}),Y=Fe((en=navigator.userAgent)!=null?en:""),te=window.location.origin,c=je((tn=document.referrer)!=null?tn:"",te,o.domain),p=(nn=e.sessionSegment)!=null?nn:`${Y}:${c}`,_=new Map,m=new Map,v=new Map,N=new Set,j=new Map,G=null,X=null,F=null,x=new Set,D=new Set,ae=new Map,ye=new Map,ne=new Set,xe=new Set,Pe=new Set,Se=new Set,ke=null,re=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,zt=new Set,Qe=new Set,Xe=new Set,Be=new Map,Et=null,Je=new Set,Le=new Map,_t=null,Vn=2,Qt=new Map,se=!1,Xt=(r,a,y)=>{var b;let E=new Set,C=1;for(let k of r){a.delete(k);let w=((b=Qt.get(k))!=null?b:0)+1;Qt.set(k,w),w<=Vn&&(E.add(k),w>C&&(C=w))}E.size>0&&setTimeout(()=>{se||y(E)},me(C))},It=r=>{for(let a of r)v.has(a.id)||v.set(a.id,Oe(a))};if(e.initialSlots)for(let[r,a]of Object.entries(e.initialSlots))v.set(r,a),N.add(r);if(e.initialSlotConfig)for(let[r,a]of Object.entries(e.initialSlotConfig))j.set(r,a);e.initialPalette&&(G=e.initialPalette),e.initialVocabulary&&(X=e.initialVocabulary);let le=_e(e.apiKey);if(le){for(let[r,a]of Object.entries(le.slots))v.has(r)||v.set(r,a);for(let[r,a]of Object.entries((on=le.slotConfig)!=null?on:{}))j.has(r)||j.set(r,a);!G&&le.palette&&(G=le.palette),!X&&le.vocabulary&&(X=le.vocabulary)}let Jt={low:.15,medium:.5,high:.85};if(e.initialPersona)F=A({},e.initialPersona);else{let r=document.documentElement.dataset;r.sentientPersona?F={persona:r.sentientPersona,confidence:(sn=Jt[(rn=r.sentientConfidence)!=null?rn:"low"])!=null?sn:.15}:le&&(F={persona:le.persona,confidence:(an=Jt[le.band])!=null?an:.15})}if(e.initialAssignments)for(let[r,a]of Object.entries(e.initialAssignments))M.set(r,p,{variantId:a,assignedAt:Date.now(),segment:p,confidence:1});let he=Promise.resolve(),qt=o.getSessionId();if(qt){let r=We((ln=document.referrer)!=null?ln:""),{utmParams:a,clickIds:y}=Zo(),E=A(A(A(A({sessionId:qt,deviceClass:Y,trafficSource:c,referrerDomain:r,utmParams:a,clickIds:y,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:Ve(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||$e((cn=navigator.userAgent)!=null?cn:"")},e.userId?{userId:e.userId,userHash:e.userHash}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),C=async()=>{l&&await qe(l,2500);for(let b=0;;b++){if(se||!T())return;let k=ue(5e3);try{let w=await fetch(`${P}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(Object.assign(E,f)),headers:L,signal:k.signal});if(w.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(w.ok||Ae(w)==="dropped")return}catch(w){}finally{k.clear()}if(b>=Jo){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(w=>setTimeout(w,me(b+1)))}};try{he=C()}catch(b){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:z});let Hn=qo(),ve=null,At=!1,H={goal(r,a={},y=1,E=0){var W,B,Z,oe,ee,J,I;let C=o.getSessionId();if(!C||se||!T())return;let b=Xo(a)?a:{metadata:a},k=[r,(W=b.externalId)!=null?W:"",(B=b.stepIndex)!=null?B:E,(Z=b.weight)!=null?Z:y].join("\0"),w=b.value!==void 0?`${b.value}\0${(oe=b.currency)!=null?oe:""}`:null;if(Hn.firedBefore(k,w)){e.debug&&console.log(`[sentient] goal("${r}") already recorded for this action \u2014 not sent twice`);return}let K=$t(),O={sessionId:C,name:r,metadata:(ee=b.metadata)!=null?ee:{},weight:(J=b.weight)!=null?J:y,stepIndex:(I=b.stepIndex)!=null?I:E,goalId:K,value:b.value,currency:b.currency,externalId:b.externalId};e.debug&&console.log("[sentient] goal",O);let U={id:K,body:JSON.stringify(O)};he.then(()=>V.send(U))},componentGoal(r,a,y){var K,O,U;let E=o.getSessionId();if(!E||se||!T())return;let C=M.get(r,p),b=C?null:(K=v.get(r))!=null?K:null;if(!C&&b===null){e.debug&&console.warn(`[sentient] componentGoal("${r}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!C&&!N.has(r)){e.debug&&console.warn(`[sentient] componentGoal("${r}"): slot not decided this session \u2014 not attributed`);return}let k=C?C.variantId:mt(b),w={id:$t(),sessionId:E,projectId:e.apiKey,componentId:r,variantId:k,eventType:"goal_achieved",goalType:a,payload:A({reward:(O=y==null?void 0:y.reward)!=null?O:1,goalValue:y==null?void 0:y.value,currency:y==null?void 0:y.currency},(U=y==null?void 0:y.metadata)!=null?U:{}),timestamp:Date.now(),timeInSession:Date.now()-S,path:wt()};e.debug&&console.log("[sentient] componentGoal",w),he.then(()=>{!se&&T()&&z.push(w)})},identify(r,a){let y=o.getSessionId();if(!y||se||!T())return;let E=(a==null?void 0:a.email)!==void 0?Gn().then(C=>C.emailFields(a.email)).catch(()=>({})):{};Promise.all([he,E]).then(([,C])=>{fetch(`${P}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(ge(A(A({sessionId:y,userId:r,userHash:a==null?void 0:a.userHash},C),f),{ephemeral:o.isEphemeral()})),headers:L}).catch(()=>{})})},track(r){let a=o.getSessionId();if(!a||se||!T()||r.eventType==="variant_assigned"&&v.get(r.componentId)!==void 0&&!N.has(r.componentId)&&!M.get(r.componentId,p))return;let y=ge(A({path:wt()},r),{id:$t(),sessionId:a,timestamp:Date.now(),timeInSession:Date.now()-S});e.debug&&console.log("[sentient] track",y),he.then(()=>z.push(y))},getAssignment(r,a){return M.get(r,a)},isUnified:r=>R.has(r),async assign(r,a,y,E,C){var K;let b=o.getSessionId();if(!b)return null;let k=(C==null?void 0:C.unified)===!0;if(k&&R.has(r))return{variantId:(K=a==null?void 0:a[0])!=null?K:"",assignmentTtlMs:0,unified:!0};let w=M.get(r,p);if(w&&(a!=null&&a.length||w.content!==void 0)){let O=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:O,content:w.content}}return Vt(_,k?`${r}\0unified`:r,async()=>{if(!await qe(he,2500)||se||!T())return null;let O=ue(3e4);try{let U={sessionId:b,componentId:r,variantIds:a};E!==void 0?U.agentDataByVariant=E:y!==void 0&&(U.agentData=y),k&&(U.caps={unified:!0});let W=await fetch(`${P}/assign`,{method:"POST",body:JSON.stringify(U),headers:L,signal:O.signal});if(!W.ok)return null;let B=await W.json();return B.unified===!0?k?(R.add(r),{variantId:B.variantId,assignmentTtlMs:0,unified:!0}):null:(M.set(r,p,A({variantId:B.variantId,assignedAt:Date.now(),segment:p,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B)}catch(U){return null}finally{O.clear()}})},async decide(r){var b,k;let a=o.getSessionId();if(!a)return null;let y=(b=r.slots)!=null?b:[],E={sessionId:a};r.sections&&r.sections.length>0&&(E.sections=r.sections.map(w=>({id:w}))),E.components=(k=r.components)!=null?k:[],y.length>0&&(E.slots=y.map(He)),r.slotsFrom==="registry"&&(E.slotsFrom="registry",r.registrySlotIds&&(E.registrySlotIds=r.registrySlotIds),r.bootstrap===!1&&(E.bootstrap=!1),r.render&&Object.keys(r.render).length>0&&(E.render=r.render)),r.v&&(E.v=r.v),typeof r.pp=="number"&&(E.pp=r.pp),e.persona&&(E.persona=e.persona),Object.assign(E,f);let C=JSON.stringify(E);return Vt(m,C,async()=>{var K,O,U,W,B,Z,oe,ee;if(!await qe(he,2500)||se||!T())return It(y),null;let w=ue(3e4);try{let J=await fetch(`${P}/decide`,{method:"POST",body:C,headers:L,signal:w.signal});if(!J.ok)return It(y),null;let I=await J.json(),ce=St(I.stage,e.stageAttributes);e.stageAttributes&&ht(ce);let we={};for(let $ of y){let de=(K=I.slots)==null?void 0:K[$.id];if(de!==void 0){we[$.id]=de,v.set($.id,de),N.add($.id);continue}let dn=v.get($.id);if(dn!==void 0)we[$.id]=dn;else{let un=Oe($);we[$.id]=un,v.set($.id,un)}}if(I.slots)for(let[$,de]of Object.entries(I.slots))$ in we||(we[$]=de,v.set($,de),N.add($));let zn=F!=null&&F.persona!=="unknown";I.persona&&!(I.persona==="unknown"&&zn)?F={persona:I.persona,confidence:(O=I.confidence)!=null?O:0}:F||(F={persona:"unknown",confidence:0});for(let[$,de]of Object.entries((U=I.assignments)!=null?U:{}))M.set($,p,{variantId:de,assignedAt:Date.now(),segment:p,confidence:1});if(I.slotConfig)for(let[$,de]of Object.entries(I.slotConfig))j.set($,de);I.palette&&(G=I.palette),I.vocabulary&&(X=I.vocabulary);for(let $ of(W=r.registrySlotIds)!=null?W:[])(B=I.slotConfig)!=null&&B[$]||(j.delete($),v.delete($),N.delete($));return T()&&Ie(e.apiKey,A(A(A(A({v:1,persona:F.persona,band:(0,jt.confidenceBand)(F.confidence),slots:Object.fromEntries(v),layoutOrder:(Z=I.layoutOrder)!=null?Z:null,savedAt:Date.now()},j.size>0?{slotConfig:Object.fromEntries(j)}:{}),G?{palette:G}:{}),X?{vocabulary:X}:{}),ce?{stage:ce}:{})),A(A(A(A(A(A(A({layoutOrder:(oe=I.layoutOrder)!=null?oe:null,assignments:(ee=I.assignments)!=null?ee:{},slots:we,persona:F.persona,confidence:F.confidence},I.slotConfig?{slotConfig:I.slotConfig}:{}),I.goals?{goals:I.goals}:{}),I.sectionMap?{sectionMap:I.sectionMap}:{}),I.palette?{palette:I.palette}:{}),I.vocabulary?{vocabulary:I.vocabulary}:{}),I.stage?{stage:I.stage}:{}),I.context?{context:I.context}:{})}catch(J){return It(y),null}finally{w.clear()}})},getSlotResult(r){var a;return(a=v.get(r))!=null?a:null},isSlotDecided(r){return N.has(r)},getSlotConfig(r){var a;return(a=j.get(r))!=null?a:null},reportSlots(r,a,y,E){var b;let C={};for(let[k,w]of Object.entries(E!=null?E:{}))for(let K of w){let O=`${k}|${K.key}`;!re.test(k)||Pe.has(O)||(Pe.add(O),((b=C[k])!=null?b:C[k]=[]).push(K))}Object.keys(C).length>0&&fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:Object.keys(C),authoredArms:C})}).catch(()=>{});for(let k of r)if(!(typeof k!="string"||k.length===0)){if(!re.test(k)){zo()&&!zt.has(k)&&(zt.add(k),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(k)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!x.has(k)){x.add(k),D.add(k);let w=a==null?void 0:a[k];if(typeof w=="string"){let O=w.replace(/\s+/g," ").trim().slice(0,400);O!==""&&ae.set(k,O)}let K=y==null?void 0:y[k];K!==void 0&&ye.set(k,K)}}D.size===0||ke!=null||(ke=setTimeout(()=>{ke=null;let k=[...D];D.clear();for(let w=0;w<k.length;w+=20){let K=k.slice(w,w+20),O={},U={};for(let W of K){let B=ae.get(W);B!==void 0&&(O[W]=B,ae.delete(W));let Z=ye.get(W);Z!==void 0&&(U[W]=Z,ye.delete(W))}fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(A(ge(A(A({slotIds:K},Object.keys(O).length>0?{baselineTexts:O}:{}),Object.keys(U).length>0?{baselineSkeletons:U}:{}),{pagePaths:Object.fromEntries(K.map(W=>[W,location.pathname]))}),Object.keys(O).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(r,a){!re.test(r)||ne.has(r)||(ne.add(r),fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:[r],baselineSkeletons:{[r]:a}})}).catch(()=>{}))},reportAgentData(r,a,y){let E=`${r}|${a}`;!re.test(r)||Se.has(E)||(Se.add(E),fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(A(A({slotIds:[r],agentData:{[r]:{[a]:y}}},a.startsWith("authored.")?{authoredArms:{[r]:[{key:a.slice(9)}]}}:{}),o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{}))},reportDrift(r,a,y,E){let C=`${r}|${a}`,b=o.getSessionId();!b||xe.has(C)||(xe.add(C),fetch(`${P}/slots/drift`,{method:"POST",headers:L,body:JSON.stringify({sessionId:b,reports:[{slotId:r,expectedFp:a,observedFp:y,reason:E}]})}).catch(()=>{}))},requestSlots(r,a,y){var E,C;for(let b of r)Xe.has(b)||(Xe.add(b),re.test(b)?Be.set(b,{text:a==null?void 0:a[b],render:(E=y==null?void 0:y.render)==null?void 0:E[b],skeleton:(C=y==null?void 0:y.skeletons)==null?void 0:C[b]}):H.reportSlots([b]));Be.size===0||Et!=null||(Et=setTimeout(()=>{Et=null;let b=[...Be];Be.clear();for(let k=0;k<b.length;k+=50){let w=b.slice(k,k+50),K={};for(let[O,U]of w)U.render&&(K[O]=U.render);H.decide({slotsFrom:"registry",registrySlotIds:w.map(([O])=>O),bootstrap:!1,render:K}).then(O=>{var U,W;if(O){let B={},Z={},oe=[];for(let[ee,J]of w){let I=(U=O.slotConfig)==null?void 0:U[ee];if(I){I.needsSkeleton&&J.skeleton&&((W=H.reportSkeleton)==null||W.call(H,ee,J.skeleton));continue}oe.push(ee),J.text&&(B[ee]=J.text),J.skeleton&&(Z[ee]=J.skeleton)}oe.length>0&&H.reportSlots(oe,B,Z)}else Xt(w.map(([B])=>B),Xe,B=>{var J;let Z={},oe={},ee={};for(let[I,ce]of w)B.has(I)&&(ce.text&&(Z[I]=ce.text),ce.render&&(oe[I]=ce.render),ce.skeleton&&(ee[I]=ce.skeleton));(J=H.requestSlots)==null||J.call(H,[...B],Z,{render:oe,skeletons:ee})});Qe.forEach(B=>B())})}},0))},decideSlots(r){for(let a of r)Je.has(a.id)||(Je.add(a.id),Le.set(a.id,a));Le.size===0||_t!=null||(_t=setTimeout(()=>{_t=null;let a=[...Le.values()];Le.clear();for(let y=0;y<a.length;y+=30){let E=a.slice(y,y+30);H.decide({slots:E}).then(C=>{C||Xt(E.map(b=>b.id),Je,b=>{var k;return(k=H.decideSlots)==null?void 0:k.call(H,E.filter(w=>b.has(w.id)))}),Qe.forEach(b=>b())})}},0))},cancelSlots(r){for(let a of r)Be.delete(a)&&Xe.delete(a),Le.delete(a)&&Je.delete(a)},onSlotsChanged(r){return Qe.add(r),()=>{Qe.delete(r)}},getStyleVocabulary(){return X},getSitePalette(){return G},getVisitorId:()=>T()?o.getSessionId():null,getPersona(){return F?{persona:F.persona,confidence:F.confidence,band:(0,jt.confidenceBand)(F.confidence)}:null},async fetchWeights(){var a;let r=ue(5e3);try{let y=await fetch(`${P}/weights`,{headers:L,signal:r.signal});return y.ok?(a=(await y.json()).components)!=null?a:[]:[]}catch(y){return[]}finally{r.clear()}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){z.flush(),V.flush()},dispose(){var r;ve==null||ve(),At=!0,se=!0,z.destroy(),V.destroy(),((r=q.get(e.apiKey))==null?void 0:r.dispose)===H.dispose&&q.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var r;ve==null||ve(),At=!0,se=!0,u=!0,tt(e.apiKey),z.destroy({forget:!0}),V.destroy({forget:!0}),o.destroy(),M.clear(),((r=q.get(e.apiKey))==null?void 0:r.dispose)===H.dispose&&q.delete(e.apiKey);try{localStorage.removeItem(fe+e.apiKey),localStorage.removeItem(Ke(e.apiKey)),localStorage.removeItem(Ge(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${pe(e.apiKey)}`),localStorage.removeItem("_snt_graph_edges")}catch(a){}e.debug&&console.log("[sentient] destroyed")}};if(q.set(e.apiKey,{config:e,upgrade:null,dispose:H.dispose}),ve=Yo(H,e.apiKey,r=>{he.then(()=>{At||Fn.add(r)})}),e.debug){let r=window;r.__sentient&&(r.__sentient.client=H)}return H}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_MAX_WIDTHS,BLOCK_PADS,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_SURFACES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,CLASSIC_CRAWLER_TOKENS,CLICK_ID_KEYS,FORM_FIELD_KINDS,FORM_INPUT_TYPES,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,MAX_FORM_FIELDS,MAX_FORM_SELECT_OPTIONS,MAX_SKELETON_LEAVES,MAX_SKELETON_NODES,MAX_SKELETON_TEXT,PAGE_SCOPE_RE,PROD_KEYLESS_ERROR,REVEAL_MS,SNAPSHOT_STORAGE_KEY_PREFIX,STAGE_ATTRIBUTE,_registerConsentUpgradeInit,agentIntent,agentUaList,applyNonce,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,containsFormBlock,cspNonce,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,exposedStage,extractTrackedParams,forgetGeneration,forgetVisitor,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,matchedCrawlerToken,normalizeUrlPattern,pageScopeMatches,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,resetRevealStyles,reveal,routeKey,sessionCookieName,setCspNonce,setStageAttribute,toWireSlot,uaTokenMatch,urlMatches,writeSnapshot});
1
+ "use strict";var Qn=Object.create;var Me=Object.defineProperty,Xn=Object.defineProperties,Jn=Object.getOwnPropertyDescriptor,qn=Object.getOwnPropertyDescriptors,Yn=Object.getOwnPropertyNames,gn=Object.getOwnPropertySymbols,Zn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var pn=(e,t,n)=>t in e?Me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))fn.call(t,n)&&pn(e,n,t[n]);if(gn)for(var n of gn(t))eo.call(t,n)&&pn(e,n,t[n]);return e},ge=(e,t)=>Xn(e,qn(t));var to=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:!0})},mn=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Yn(t))!fn.call(e,d)&&d!==n&&Me(e,d,{get:()=>t[d],enumerable:!(s=Jn(t,d))||s.enumerable});return e};var yn=(e,t,n)=>(n=e!=null?Qn(Zn(e)):{},mn(t||!e||!e.__esModule?Me(n,"default",{value:e,enumerable:!0}):n,e)),no=e=>mn(Me({},"__esModule",{value:!0}),e);var nr={};to(nr,{AGENT_INTENTS:()=>pt,BLOCK_ALIGNS:()=>wo,BLOCK_EMPHASES:()=>Co,BLOCK_FITS:()=>Oo,BLOCK_GAPS:()=>xo,BLOCK_GRID_COLUMNS:()=>Do,BLOCK_HEADING_LEVELS:()=>Po,BLOCK_JUSTIFIES:()=>Eo,BLOCK_MAX_WIDTHS:()=>Mo,BLOCK_PADS:()=>Lo,BLOCK_RATIOS:()=>Ro,BLOCK_SIZES:()=>_o,BLOCK_SURFACES:()=>Bo,BLOCK_TEXT_ALIGNS:()=>To,BLOCK_TONES:()=>Ao,BLOCK_WEIGHTS:()=>Io,CLASSIC_CRAWLER_TOKENS:()=>Dt,CLICK_ID_KEYS:()=>Bt,FORM_FIELD_KINDS:()=>No,FORM_INPUT_TYPES:()=>Ko,LEGACY_SESSION_COOKIE_NAME:()=>be,LOCAL_MODE_BANNER:()=>Lt,MAX_BLOCK_ARMS:()=>Wo,MAX_BLOCK_CHILDREN:()=>jo,MAX_BLOCK_DEPTH:()=>Fo,MAX_BLOCK_NODES:()=>$o,MAX_BLOCK_TEXT_LEN:()=>Vo,MAX_FORM_FIELDS:()=>Go,MAX_FORM_SELECT_OPTIONS:()=>Uo,MAX_SKELETON_LEAVES:()=>Wr,MAX_SKELETON_NODES:()=>jr,MAX_SKELETON_TEXT:()=>Vr,PAGE_SCOPE_RE:()=>Nt,PROD_KEYLESS_ERROR:()=>vt,REVEAL_MS:()=>Gt,SNAPSHOT_STORAGE_KEY_PREFIX:()=>fe,STAGE_ATTRIBUTE:()=>yt,_registerConsentUpgradeInit:()=>Qo,agentIntent:()=>En,agentUaList:()=>Ue,applyNonce:()=>Ze,armOfResult:()=>mt,attachMicroSignalDetectors:()=>Nn,baselineResultFor:()=>Oe,baselineSlots:()=>An,classifiedAgents:()=>_n,containsFormBlock:()=>Bn,cspNonce:()=>Tt,deriveSessionSegment:()=>In,detectDeviceClass:()=>Fe,detectTimeOfDay:()=>Ve,detectTrafficSource:()=>je,exposedStage:()=>St,extractTrackedParams:()=>ft,forgetGeneration:()=>ie,forgetVisitor:()=>st,grantConsent:()=>er,init:()=>Wn,isDoNotTrackEnabled:()=>Ht,matchedAgentToken:()=>gt,matchedCrawlerToken:()=>Pt,normalizeUrlPattern:()=>Pn,pageScopeMatches:()=>On,readSnapshot:()=>_e,referrerDomainFromReferer:()=>We,renderPrePaintScript:()=>Sn,resetRevealStyles:()=>Ln,reveal:()=>Mn,routeKey:()=>Wt,sessionCookieName:()=>Ee,setCspNonce:()=>Ye,setStageAttribute:()=>ht,toWireSlot:()=>He,uaTokenMatch:()=>$e,urlMatches:()=>Dn,writeSnapshot:()=>Ie});module.exports=no(nr);function ue(e){if(typeof AbortController!="function")return{clear:()=>{}};let t=new AbortController,n=setTimeout(()=>t.abort(),e);return{signal:t.signal,clear:()=>clearTimeout(n)}}function qe(e,t){return new Promise(n=>{let s=setTimeout(()=>n(!1),t),d=()=>{clearTimeout(s),n(!0)};e.then(d,d)})}var Ct;function Ye(e){Ct=typeof e=="string"&&e!==""?e:void 0}function Tt(e=document){if(Ct)return Ct;try{let t=e.querySelector("script[nonce]");return(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"))||void 0}catch(t){return}}function Ze(e,t=document){let n=Tt(t);return n&&e.setAttribute("nonce",n),e}function pe(e){return e?`_${e.slice(0,12)}`:""}var be="_snt_uid";function Ee(e){return`${be}${pe(e)}`}var et="__sntForgetGen",oo=()=>{try{return window[et]}catch(e){return}};function tt(e){var t,n;try{let s=window,d=(t=s[et])!=null?t:s[et]={};d[e]=((n=d[e])!=null?n:0)+1}catch(s){}}function ie(e){var t,n;return(n=(t=oo())==null?void 0:t[e])!=null?n:0}var fe="_snt_snap:";var ro=["low","medium","high"];function _e(e){try{let t=localStorage.getItem(fe+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!ro.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"||!(Date.now()-n.savedAt<2592e6)||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig)))return null;let s=n.vocabulary;return s!==void 0&&(typeof s!="object"||s===null||!Array.isArray(s.entries)||!Array.isArray(s.images))&&delete n.vocabulary,n.stage!==void 0&&typeof n.stage!="string"&&delete n.stage,n}catch(t){return null}}function Ie(e,t){try{localStorage.setItem(fe+e,JSON.stringify(t))}catch(n){}}function Sn(e,t){return'(function(){try{var N=navigator,W=window;if(N.doNotTrack=="1"||N.doNotTrack=="yes"||W.doNotTrack=="1"||N.msDoNotTrack=="1"||N.globalPrivacyControl)return;var r=localStorage.getItem('+JSON.stringify(fe+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;if(!('+2592e6+">Date.now()-s.savedAt))return;var d=document.documentElement;"+(t!=null&&t.stage?'if(typeof s.stage=="string"&&!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",s.stage);':"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}function me(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Ae(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function nt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let s=JSON.parse(n);return Array.isArray(s)?(localStorage.removeItem(e),s.slice(-t)):[]}catch(n){return[]}}function Ne(e,t,n){try{let s=(()=>{try{let g=localStorage.getItem(n);if(!g)return[];let S=JSON.parse(g);return Array.isArray(S)?S:[]}catch(g){return[]}})(),d=new Map;for(let g of s)d.set(g.id,g);for(let g of e)d.set(g.id,g);localStorage.setItem(n,JSON.stringify([...d.values()].slice(-t)))}catch(s){}}function ot(e,t){try{let n=localStorage.getItem(t);if(!n)return;let s=JSON.parse(n);if(!Array.isArray(s))return;let d=new Set(e),g=s.filter(S=>!d.has(S.id));if(g.length===s.length)return;g.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(g))}catch(n){}}var so=500,io=56*1024;function Ke(e){return`_snt_retry_${e.slice(0,12)}`}var ao={push:()=>{},flush:()=>{},destroy:()=>{}};function hn(e){var G,X,F;if(typeof window=="undefined")return ao;let t=(G=e.flushIntervalMs)!=null?G:5e3,n=(X=e.maxBatchSize)!=null?X:20,s=(F=e.maxRetrySize)!=null?F:100,d=e.ingestUrl,g=e.apiKey,S=Ke(g),o=!1,f=ie(g),l=(...x)=>{!o&&ie(g)===f&&Ne(...x)},i=[],u=new Set,h=[],T=x=>{for(let D of x)R.delete(D),!u.has(D)&&(u.add(D),h.push(D));for(;h.length>so;){let D=h.shift();D&&u.delete(D)}ot(x,S)},R=new Set,M=()=>{for(;i.length>s;){let x=i.shift();x&&R.delete(x.id)}},z=x=>{u.has(x.id)||R.has(x.id)||(R.add(x.id),i.push(x),M())},P=x=>{for(let D of x)u.has(D.id)||(R.add(D.id),i.push(D));M()},L=nt(S,s);for(let x of L)z(x);let Q=0,V=0,Y=(x,D=!0)=>{if(x.length===0)return;let ae=JSON.stringify(x),ye=x.map(Se=>Se.id),ne,xe=ue(15e3);try{ne=fetch(d,{method:"POST",keepalive:!0,signal:xe.signal,body:ae,headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`}})}catch(Se){l(x,s,S),P(x),V++,Q=Date.now()+me(V);return}Promise.resolve(ne).then(xe.clear,xe.clear);let Pe=Se=>{if(Ae(Se)!=="retry"){if(!Se.ok&&D){let ke=x.filter(re=>re.eventType!=="pageview");if(ke.length>0&&ke.length<x.length){T(x.filter(re=>re.eventType==="pageview").map(re=>re.id)),Y(ke,!1);return}}T(ye),V=0,Q=0;return}l(x,s,S),P(x),V++,Q=Date.now()+me(V)};ne&&typeof ne.then=="function"?ne.then(Pe).catch(()=>{l(x,s,S),P(x),V++,Q=Date.now()+me(V)}):Pe(ne)},te=typeof TextEncoder!="undefined"?new TextEncoder:null,c=x=>te?te.encode(x).length:x.length,p=x=>{let D=[],ae=2;for(let ye of x){let ne=c(JSON.stringify(ye))+1;if(D.length>0&&ae+ne>io||D.length>=n)break;D.push(ye),ae+=ne}return D},_=()=>{try{if(Date.now()<Q)return;for(;i.length>0&&!(Date.now()<Q);){let x=i.filter(ae=>!u.has(ae.id));if(i.length=0,x.length===0)break;let D=p(x);if(D.length===0)break;D.length<x.length&&i.push(...x.slice(D.length)),Y(D)}}catch(x){}},m=!0,v=null;v=setInterval(()=>{m&&_()},t);let N=()=>{document.visibilityState==="hidden"&&_()},j=()=>{_()};return document.addEventListener("visibilitychange",N),window.addEventListener("pagehide",j),{push(x){z(x),i.length>=n&&_()},flush:_,destroy(x){x!=null&&x.forget&&(o=!0),m=!1,v!==null&&(clearInterval(v),v=null),document.removeEventListener("visibilitychange",N),window.removeEventListener("pagehide",j),_()}}}var lo=200;function Ge(e){return`_snt_goal_retry_${e.slice(0,12)}`}var co={send:()=>{},flush:()=>{},destroy:()=>{}};function bn(e){var c,p,_;if(typeof window=="undefined")return co;let t=(c=e.flushIntervalMs)!=null?c:5e3,n=(p=e.maxRetrySize)!=null?p:100,s=(_=e.maxPerFlush)!=null?_:5,d=Ge(e.apiKey),g=!1,S=ie(e.apiKey),o=(...m)=>{!g&&ie(e.apiKey)===S&&Ne(...m)},f=[],l=new Set,i=new Set,u=[],h=0,T=0,R=!1,M=m=>{for(l.delete(m.id),i.has(m.id)||(i.add(m.id),u.push(m.id));u.length>lo;){let v=u.shift();v&&i.delete(v)}ot([m.id],d)},z=m=>{o([m],n,d),!i.has(m.id)&&!l.has(m.id)&&(l.add(m.id),f.push(m)),Date.now()>=h&&(T++,h=Date.now()+me(T))},P=m=>{let v,N=ue(15e3);try{v=fetch(e.url,{method:"POST",keepalive:!0,signal:N.signal,body:m.body,headers:e.headers})}catch(G){z(m);return}let j=G=>{var F;let X=Ae(G);if(X==="retry"){z(m);return}X==="dropped"&&((F=e.onDrop)==null||F.call(e,m,G.status)),M(m),T=0,h=0};Promise.resolve(v).then(N.clear,N.clear),v&&typeof v.then=="function"?v.then(j).catch(()=>z(m)):j(v)},L=()=>{try{if(R||Date.now()<h)return;let m=0;for(;f.length>0&&m<s&&!(Date.now()<h);){let v=f.shift();l.delete(v.id),!i.has(v.id)&&(m++,P(v))}}catch(m){}},Q=nt(d,n);for(let m of Q)l.has(m.id)||(l.add(m.id),f.push(m));Q.length>0&&Ne(Q,n,d);let V=setInterval(L,t),Y=()=>{document.visibilityState==="hidden"&&L()},te=()=>L();return document.addEventListener("visibilitychange",Y),window.addEventListener("pagehide",te),{send(m){if(R){i.has(m.id)||o([m],n,d);return}if(!(i.has(m.id)||l.has(m.id))){if(Date.now()<h){o([m],n,d),l.add(m.id),f.push(m);return}P(m)}},flush:L,destroy(m){m!=null&&m.forget&&(g=!0),clearInterval(V),document.removeEventListener("visibilitychange",Y),window.removeEventListener("pagehide",te),L(),R=!0}}}function rt(e){let t=(e||"").toLowerCase();if(!t.includes(".")||/^[\d.]+$|:/.test(t))return[];let n=t.split("."),s=[];for(let d=n.length-2;d>=0;d--)s.push(n.slice(d).join("."));return s}function st(e){if(typeof window=="undefined"||!e)return!1;tt(e);let t=!1,n=Ee(e);try{if(new RegExp(`(?:^|; )${n}=`).test(document.cookie)){let S=location.protocol==="https:"?"; Secure":"";for(let o of["",...rt(location.hostname)])document.cookie=`${n}=; max-age=0; SameSite=lax; path=/${o?`; domain=${o}`:""}${S}`;t=!0}}catch(S){}let s=pe(e),d=[n,"_snt_graph_edges",fe+e,Ke(e),Ge(e),`_snt_graph_nodes${s}`],g=[`_snt_asgn${s}_`];for(let S of["localStorage","sessionStorage"])try{let o=window[S];for(let f of d)o.getItem(f)!==null&&(o.removeItem(f),t=!0);for(let f=o.length-1;f>=0;f--){let l=o.key(f);l&&g.some(i=>l.startsWith(i))&&(o.removeItem(l),t=!0)}}catch(o){}try{(new RegExp(`(?:^|; )${be}=[^;]`).test(document.cookie)||localStorage.getItem(be)!==null||sessionStorage.getItem(be)!==null)&&localStorage.setItem(`${be}_tomb${s}`,"1")}catch(S){}return t}function it(){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 kn="_snt_uid",uo=365,Ce="_snt_uid";function go(){return it()}function Te(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function xn(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function ct(e,t,n,s){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=lax; path=/${s?`; domain=${s}`:""}${xn()}`}catch(d){}}function at(e){try{return localStorage.getItem(e)}catch(t){return null}}function vn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Ot(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function po(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function fo(e){try{sessionStorage.removeItem(e)}catch(t){}}function mo(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${xn()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function yo(e){try{localStorage.removeItem(e)}catch(t){}}function lt(e,t){ct(e,"",0,t)}var So={getSessionId:()=>null,isEphemeral:()=>!1,domain:null,destroy:()=>{}};function ho(e,t){if(e===!1)return null;if(typeof e=="string")return e.replace(/^\./,"");for(let n of rt(location.hostname))if(ct(t,"1",10,n),Te(t)==="1")return lt(t,n),n;return null}function dt(e){var P,L,Q,V,Y,te,c;if(typeof window=="undefined")return So;let t=pe(e==null?void 0:e.apiKey),n=(P=e==null?void 0:e.cookieName)!=null?P:Ee(e==null?void 0:e.apiKey),s=`${Ce}${t}`,d=`${Ce}_tomb${t}`,S=((L=e==null?void 0:e.cookieTTLDays)!=null?L:uo)*24*60*60,o=p=>p&&p.length>0?p:null,f=()=>{var p,_;return t&&!(e!=null&&e.cookieName)&&at(d)===null?(_=(p=o(Te(kn)))!=null?p:o(at(Ce)))!=null?_:o(Ot(Ce)):null},l=ho(e==null?void 0:e.cookieDomain,`${n}_dom`),i=o(Te(n)),u=l?(lt(n),o(Te(n))):null,h=(c=(te=(Y=(V=(Q=u!=null?u:i)!=null?Q:o(at(s)))!=null?V:o(Ot(s)))!=null?Y:f())!=null?te:o(e==null?void 0:e.ssrSessionId))!=null?c:go();ct(n,h,S,l),l&&Te(n)!==h&&(l=null,ct(n,h,S));let T=vn(s,h),R=mo(n),M=T?!1:po(s,h),z=!T&&!R&&!M;return{getSessionId:()=>h,isEphemeral:()=>z,domain:l,destroy:()=>{h=null,lt(n),lt(n,l),yo(s),fo(s),t&&!(e!=null&&e.cookieName)&&(Te(kn)!==null||at(Ce)!==null||Ot(Ce)!==null)&&vn(d,"1")}}}var bo=1800*1e3;function ut(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function wn(e=bo,t){let n=new Map,s=`_snt_asgn${pe(t)}_`,d=(l,i)=>`${s}${encodeURIComponent(l)}:${encodeURIComponent(i)}`,g=l=>{let i=l.slice(s.length),u=i.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,u)),segment:decodeURIComponent(i.slice(u+1))}}catch(h){return null}},S=()=>{try{let l=[];for(let i=0;i<localStorage.length;i++){let u=localStorage.key(i);u!=null&&u.startsWith(s)&&l.push(u)}return l}catch(l){return[]}},o=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of S())try{let i=localStorage.getItem(l);if(!i)continue;let u=JSON.parse(i);if(o(u)){localStorage.removeItem(l);continue}let h=g(l);if(!h)continue;n.set(ut(h.componentId,h.segment),u)}catch(i){}})(),{get(l,i){let u=n.get(ut(l,i));return u?o(u)?(n.delete(ut(l,i)),null):u:null},set(l,i,u){let h=ut(l,i);n.set(h,u);try{localStorage.setItem(d(l,i),JSON.stringify(u))}catch(T){}},clear(){n.clear();for(let l of S())try{localStorage.removeItem(l)}catch(i){}}}}var Ue=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","Claude-Agent","PerplexityBot","Perplexity-User","Google-Agent","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function $e(e){return gt(e)!==null}function gt(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ue.find(s=>t.includes(s.toLowerCase())))!=null?n:null}var Dt=["Googlebot","Bingbot","DuckDuckBot","YandexBot","Baiduspider","Applebot","Slurp","facebookexternalhit","LinkedInBot","Twitterbot"];function Pt(e){var s;let t=gt(e);if(t)return t;if(!e)return null;let n=e.toLowerCase();return(s=Dt.find(d=>n.includes(d.toLowerCase())))!=null?s:null}var pt={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search","Claude-Agent":"user",PerplexityBot:"search","Perplexity-User":"user","Google-Agent":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function En(e){if(!e)return"other";let t=Ue.find(n=>n.toLowerCase()===e.toLowerCase());return t&&pt[t]||"other"}function _n(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of Ue)e[(t=pt[n])!=null?t:"other"].push(n);return e}function Fe(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 je(e,t,n){if(!e)return"direct";try{let s=new URL(e);if(t)try{if(new URL(t).host===s.host)return"direct"}catch(g){}let d=s.hostname.toLowerCase();return n&&`.${d}`.endsWith(`.${n}`)?"direct":/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(d)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(d)?"social":"referral"}catch(s){return"direct"}}function We(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Bt=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function ft(e){let t={},n={};try{let s=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([d,g])=>{let S=Array.isArray(g)?g[0]:g;return S===void 0?[]:[[d,S]]});for(let[d,g]of s)d.startsWith("utm_")?d in t||(t[d]=g):Bt.includes(d)&&(d in n||(n[d]=g))}catch(s){}return{utmParams:t,clickIds:n}}function Ve(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function In(e){let t=ko("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function ko(e,t){var S,o,f,l,i,u,h,T;let n=(o=(S=t==null?void 0:t.userAgent)==null?void 0:S.trim())!=null?o:"",s=(l=(f=t==null?void 0:t.referer)==null?void 0:f.trim())!=null?l:"",d=(i=t==null?void 0:t.now)!=null?i:new Date,g=Pt(n);return A(A({sessionId:e,ephemeral:!1,utmParams:(u=t==null?void 0:t.utmParams)!=null?u:{},clickIds:(h=t==null?void 0:t.clickIds)!=null?h:{},deviceClass:n?Fe(n):"desktop",trafficSource:s?je(s,t==null?void 0:t.appOrigin):"direct",referrerDomain:We(s),timeOfDay:Ve(d),dayOfWeek:(T=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?T:"sun",automation:(t==null?void 0:t.webdriver)===!0||$e(n)},g?{agentToken:g}:{}),t!=null&&t.landingPath?{landingPath:t.landingPath.split(/[?#]/)[0]}:{})}var Re=require("@sentientui/policy");function He(e){return A(A(A({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 Oe(e){let t=He(e);return(0,Re.slotResultFor)(t,(0,Re.slotBaselineArm)(t))}function An(e){let t={};for(let n of e)t[n.id]=Oe(n);return t}function mt(e){return typeof e=="string"?e:(0,Re.canonicalArm)(e)}var Cn=require("@sentientui/policy"),yt="data-sentient-stage";function St(e,t){return!t||typeof e!="string"||!(e==="returning"||Cn.STAGE_KEYS.includes(e))?null:t!=="detailed"&&(e==="customer"||e==="lapsed")?"returning":e}function ht(e,t=document){try{e?t.documentElement.setAttribute(yt,e):t.documentElement.removeAttribute(yt)}catch(n){}}var jt=require("@sentientui/policy");var kt=require("@sentientui/policy");var vt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY (Vite: VITE_SENTIENT_API_KEY) or localMode: true.",Lt="[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.",Tn=!1,bt=!1;function vo(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Rn(e){var l;let t=dt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(l=t.getSessionId())!=null?l:"local",s=vo(),d=import("@sentientui/core/local").then(i=>{let u=i;return u.LOCAL_ENGINE_AVAILABLE?(Tn||(Tn=!0,console.info(Lt)),u):(bt||(bt=!0,console.error(vt)),null)}).catch(()=>(bt||(bt=!0,console.error(vt)),null)),g=null,S={low:.15,medium:.5,high:.85},o=(()=>{var u;if(e.initialPersona)return A({},e.initialPersona);let i=_e(e.apiKey||"local");return i?{persona:i.persona,confidence:(u=S[i.band])!=null?u:.15}:null})();function f(i){let u=document.documentElement;u.dataset.sentientPersona===void 0&&(u.dataset.sentientPersona=i.persona,u.dataset.sentientConfidence=(0,kt.confidenceBand)(i.confidence))}return{isLocal:!0,async decide(i){var T,R,M;let u=await d;if(!u)return null;let h=u.createLocalEngine({sessionId:n,forcedPersona:s}).decide(i);return g=ge(A({},h),{layoutOrder:(R=(T=h.layoutOrder)!=null?T:g==null?void 0:g.layoutOrder)!=null?R:null,slots:A(A({},(M=g==null?void 0:g.slots)!=null?M:{}),h.slots)}),Ie(e.apiKey||"local",{v:1,persona:g.persona,band:(0,kt.confidenceBand)(g.confidence),slots:g.slots,layoutOrder:g.layoutOrder,savedAt:Date.now()}),f(h),h},getSlotResult(i){var u,h,T;return(T=(h=g==null?void 0:g.slots[i])!=null?h:(u=e.initialSlots)==null?void 0:u[i])!=null?T:null},getSlotConfig(i){var u,h;return(h=(u=e.initialSlotConfig)==null?void 0:u[i])!=null?h:null},getSitePalette(){var i;return(i=e.initialPalette)!=null?i:null},reportSlots(){},getVisitorId:()=>null,getPersona(){let i=g!=null?g:o;return i?{persona:i.persona,confidence:i.confidence,band:(0,kt.confidenceBand)(i.confidence)}:null},async assign(i,u){var R;let h=await d;return!h||!u||u.length===0?u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null:{variantId:(R=h.createLocalEngine({sessionId:n,forcedPersona:s}).decide({components:[{id:i,variantIds:u}]}).assignments[i])!=null?R:u[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>t.destroy()}}var Nt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Mt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function On(e,t){if(e===void 0||!Nt.test(e))return!1;if(e==="*")return!0;let n=Mt(t);if(e.endsWith("/*")){let s=Mt(e.slice(0,-2));return n.startsWith(s==="/"?"/":`${s}/`)&&n!==s}return n===Mt(e)}function Dn(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 Pn(e){if(!/^https?:\/\//i.test(e))return e;try{return new URL(e).pathname||"/"}catch(t){return e}}var xo=["none","sm","md","lg"],wo=["start","center","end","stretch"],Eo=["start","center","end","between"],_o=["sm","md","lg"],Io=["normal","medium","bold"],Ao=["default","muted","accent"],Co=["primary","secondary","ghost"],To=["left","center","right"],Ro=["auto","square","landscape","wide"],Oo=["cover","contain"],Do=[2,3,4],Po=[1,2,3,4],Bo=["default","raised"],Lo=["none","sm","md","lg"],Mo=["measure"],No=["input","textarea","select"],Ko=["text","email","number","tel"],Go=5,Uo=8,$o=64,Fo=5,jo=12,Wo=4,Vo=500;function Bn(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(Bn):!1}var jr=40,Wr=120,Vr=300;var Kt="sentient-reveal",De="sentient-revealed",Gt=240,xt=!1;function Ln(){var e;xt=!1,typeof document!="undefined"&&((e=document.getElementById(Kt))==null||e.remove())}function Ho(e){if(xt||e.getElementById(Kt)){xt=!0;return}let t=Ze(e.createElement("style"),e);t.id=Kt,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${De}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${De}{animation:${De} ${Gt}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),xt=!0}function Mn(e,t={}){var d;let n=(d=t.doc)!=null?d:typeof document!="undefined"?document:void 0;if(!n||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;Ho(n),e.classList.remove(De),e.offsetWidth,e.classList.add(De);let s=()=>{e.classList.remove(De),e.removeEventListener("animationend",s)};return e.addEventListener("animationend",s),!0}function Nn(e,t,n,s){let d=[];{let o=!1,f=[],l=()=>{if(o)return;let i=Date.now();for(f.push(i);f.length>0&&i-f[0]>500;)f.shift();f.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",l),d.push(()=>t.removeEventListener("click",l))}{let g=!1,S=o=>{if(g||!(o.target instanceof Node)||!t.contains(o.target)&&t!==o.target)return;g=!0;let f=typeof window!="undefined"?window.getSelection():null,l=f?f.toString().length:0;e("text_copy",{selectionLength:l})};document.addEventListener("copy",S),d.push(()=>document.removeEventListener("copy",S))}{let g=!1,S=!1,o=null,f=()=>{o!==null&&(clearTimeout(o),o=null)},l=()=>{g||!S||(f(),o=setTimeout(()=>{!g&&S&&(g=!0,e("scroll_hesitation"))},3e3))},i=()=>{f(),l()},u=T=>{for(let R of T)S=R.intersectionRatio>.3,S?l():f()},h=new IntersectionObserver(u,{threshold:[.3]});h.observe(t),window.addEventListener("scroll",i,{passive:!0}),d.push(()=>{h.disconnect(),window.removeEventListener("scroll",i),f()})}if((s==null?void 0:s.tabLoss)!==!1){let g=!1,S=n!=null?n:Date.now(),o=()=>{if(g||document.visibilityState!=="hidden")return;let f=Date.now()-S;f<15e3&&(g=!0,e("tab_loss",{timeOnPage:f}))};document.addEventListener("visibilitychange",o),d.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let g of d)g()}}function zo(){try{return process.env.NODE_ENV!=="production"}catch(e){return!0}}var Un="https://api.sentient-ui.com/v1/events",Gn=()=>import("@sentientui/core/internal-traffic"),q=new Map,$n=null;function Qo(e,t){let n=q.get(e);n&&n.upgrade&&(n.reinit=t)}function Xo(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Jo=3;function $t(){return it()}function wt(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function qo(){let e=new WeakMap,t=new Map,n=!1,s=(o,f,l)=>{let i=o.get(f);return l===null?i?!0:(o.set(f,new Set),!1):i?i.has(l)?!0:(i.add(l),!1):(o.set(f,new Set([l])),!1)},d=typeof window!="undefined"&&"event"in window,g=()=>{if(!d)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},S=()=>{if(d){Promise.resolve().then(()=>{n=!1,t.clear()});return}let o=!1,f=()=>{o||(o=!0,n=!1,t.clear())};if(setTimeout(f,0),typeof MessageChannel=="function"){let l=new MessageChannel;l.port1.onmessage=()=>{l.port1.close(),l.port2.close(),f()},l.port2.postMessage(0)}};return{firedBefore(o,f){let l=g();if(l){let u=e.get(l);return u||(u=new Map,e.set(l,u)),s(u,o,f)}let i=s(t,o,f);return!i&&!n&&(n=!0,S()),i}}}var Fn=new Set;function Yo(e,t,n){let s=typeof window=="undefined"?null:window.history;if(!s)return()=>{};let d=!1,g,S=()=>{if(d)return;let l=wt();!l||l===g||(g=l,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${l}`))},o=[];for(let l of["pushState","replaceState"]){let i=s[l],u=function(...h){let T=i.apply(this,h);return S(),T};s[l]=u,o.push([l,i,u])}window.addEventListener("popstate",S);let f=wt();return f&&Fn.has(`${t}:${f}`)?g=f:S(),()=>{if(!d){d=!0,window.removeEventListener("popstate",S);for(let[l,i,u]of o)s[l]===u&&(s[l]=i)}}}var ze={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Zo(){try{return ft(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function jn(e){return e.replace(/\/events\/?$/,"")}function Ht(){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(t=>t==="1"||t==="yes")}function er(e){var f;if(typeof window=="undefined")return;let t=e!=null?e:$n;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=q.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:s,upgrade:d,reinit:g}=n;if(!d){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(s.respectDoNotTrack!==!1&&Ht())return;let S=(g!=null?g:Wn)(ge(A({},s),{consent:!0}));d(S);let o=(f=q.get(t))==null?void 0:f.dispose;q.set(t,{config:ge(A({},s),{consent:!0}),upgrade:null,dispose:o})}function tr(e,t){var te;let n=e.preConsentBehavior==="statistical_winner",s=jn((te=e.ingestUrl)!=null?te:Un),d={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Map,S=new Map,o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(c,p,_){if(!n)return Promise.resolve(null);let m=g.get(c);return m?Promise.resolve(m):Vt(S,c,async()=>{try{let v=new URLSearchParams({componentId:c});for(let X of p!=null?p:[])v.append("variantIds[]",X);let N=ue(5e3),j;try{let X=await fetch(`${s}/winner?${v.toString()}`,{headers:d,signal:N.signal});if(!X.ok)return p!=null&&p[0]?{variantId:p[0],assignmentTtlMs:0}:null;j=await X.json()}finally{N.clear()}let G={variantId:j.variantId,assignmentTtlMs:0};return g.set(c,G),G}catch(v){return p!=null&&p[0]?{variantId:p[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getVisitorId:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},f=!1,l=new Set,i=[],u=[],h=[],T=()=>{for(let[,,c]of h.splice(0))c(null);R.length=0},R=[],M=!1,z=()=>{if(f)return;M=!0;let c=q.get(e.apiKey);(c==null?void 0:c.upgrade)===Y&&q.set(e.apiKey,{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): client released before consent; call init() again"})},P=[],L=()=>{setTimeout(()=>{var c;try{(c=P.shift())==null||c(o)}catch(p){}P.length&&L()})},Q=c=>{f?P.length?P.push(c):c(o):!t&&!M&&R.length<100?R.push(c):M&&e.debug&&console.warn("[sentient] goal dropped: client released")},V={get gated(){return!f&&!t},get released(){return M&&!f},takeHeld:()=>R.splice(0),track:c=>o.track(c),goal:((c,p,_,m)=>Q(v=>v.goal(c,p,_,m))),componentGoal:(c,p,_)=>o.componentGoal(c,p,_),identify:(c,p)=>o.identify(c,p),getAssignment:(c,p)=>o.getAssignment(c,p),isUnified:c=>{var p,_;return(_=(p=o.isUnified)==null?void 0:p.call(o,c))!=null?_:!1},assign:(c,p,_,m,v)=>o.assign(c,p,_,m,v),decide:c=>f?o.decide(c):M||t?Promise.resolve(null):new Promise(p=>h.push([c,Wt(),p])),getSlotResult:c=>o.getSlotResult(c),isSlotDecided:c=>{var p,_;return(_=(p=o.isSlotDecided)==null?void 0:p.call(o,c))!=null?_:!0},getSlotConfig:c=>o.getSlotConfig(c),getSitePalette:()=>o.getSitePalette(),getStyleVocabulary:()=>{var c,p;return(p=(c=o.getStyleVocabulary)==null?void 0:c.call(o))!=null?p:null},reportSlots:(c,p,_,m)=>o.reportSlots(c,p,_,m),reportSkeleton:(c,p)=>{var _;return(_=o.reportSkeleton)==null?void 0:_.call(o,c,p)},reportAgentData:(c,p,_)=>{var m;return(m=o.reportAgentData)==null?void 0:m.call(o,c,p,_)},reportDrift:(c,p,_,m)=>{var v;return(v=o.reportDrift)==null?void 0:v.call(o,c,p,_,m)},requestSlots:(c,p,_)=>{var m;return f?(m=o.requestSlots)==null?void 0:m.call(o,c,p,_):i.push([c,p,_])},decideSlots:c=>{var p;return f?(p=o.decideSlots)==null?void 0:p.call(o,c):u.push(...c)},cancelSlots:c=>{var _;if(f)return(_=o.cancelSlots)==null?void 0:_.call(o,c);let p=new Set(c);for(let m of i)m[0]=m[0].filter(v=>!p.has(v));u=u.filter(m=>!p.has(m.id))},onSlotsChanged:c=>(l.add(c),()=>{l.delete(c)}),getPersona:()=>o.getPersona(),getVisitorId:()=>{var c,p;return(p=(c=o.getVisitorId)==null?void 0:c.call(o))!=null?p:null},fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>(z(),T(),o.dispose()),destroy:()=>(z(),T(),f?o.destroy():st(e.apiKey))};function Y(c){var _,m,v;o=c,f=!0,R.length&&(P.push(...R.splice(0)),L());let p=Wt();for(let[N,j,G]of h.splice(0))j!==p?G(null):c.decide(N).then(G,()=>G(null));(_=c.onSlotsChanged)==null||_.call(c,()=>l.forEach(N=>N()));for(let[N,j,G]of i.splice(0))N.length>0&&((m=c.requestSlots)==null||m.call(c,N,j,G));u.length>0&&((v=c.decideSlots)==null||v.call(c,u.splice(0)))}return{proxy:V,setInner:Y}}function Wt(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function Vt(e,t,n){let s=e.get(t);if(s)return s;let d=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,d),d}function Wn(e){var Yt,Zt,en,tn,nn,on,rn,sn,an,ln,cn;if(typeof window=="undefined")return ze;e.nonce&&Ye(e.nonce),$n=e.apiKey||"local";let t=q.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(r){}let n=e.respectDoNotTrack!==!1&&Ht(),s=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!d&&e.localMode!==!1)return q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),s?ze:Rn(e);if(s){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),ze;let{proxy:r,setInner:a}=tr(e,n);return q.set(e.apiKey,{config:e,upgrade:n?null:a}),r}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."),ze;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ze;let g=(Yt=e.ingestUrl)!=null?Yt:Un,S=Date.now(),o=dt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey,cookieDomain:e.cookieDomain}),f={},l;try{/sentient_internal=/.test(location.search+document.cookie)&&(l=Gn().then(async r=>{f.internalToken=await r.takeInternalToken(o.domain)||void 0}).catch(()=>{})),(typeof e.internal=="function"?e.internal():e.internal)===!0&&(f.internal=!0)}catch(r){}let i=wn(void 0,e.apiKey),u=!1,h=ie(e.apiKey),T=()=>!u&&ie(e.apiKey)===h,R=new Set((Zt=e.initialUnified)!=null?Zt:[]),M=ge(A({},i),{get:(r,a)=>R.has(r)?null:i.get(r,a),set:(...r)=>{T()&&i.set(...r)}}),z=hn({ingestUrl:g,apiKey:e.apiKey}),P=jn(g),L={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},Q=new Set,V=bn({url:`${P}/goals`,apiKey:e.apiKey,headers:L,onDrop:(r,a)=>{if(!e.debug){if(Q.has(a))return;Q.add(a)}console.warn(`[sentient] goal dropped (HTTP ${a}) \u2014 this will not be retried. `+(a===400?"The session was not found: call init() and let the session upsert complete before firing goals.":a===401||a===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),r)}}),Y=Fe((en=navigator.userAgent)!=null?en:""),te=window.location.origin,c=je((tn=document.referrer)!=null?tn:"",te,o.domain),p=(nn=e.sessionSegment)!=null?nn:`${Y}:${c}`,_=new Map,m=new Map,v=new Map,N=new Set,j=new Map,G=null,X=null,F=null,x=new Set,D=new Set,ae=new Map,ye=new Map,ne=new Set,xe=new Set,Pe=new Set,Se=new Set,ke=null,re=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,zt=new Set,Qe=new Set,Xe=new Set,Be=new Map,Et=null,Je=new Set,Le=new Map,_t=null,Vn=2,Qt=new Map,se=!1,Xt=(r,a,y)=>{var b;let E=new Set,C=1;for(let k of r){a.delete(k);let w=((b=Qt.get(k))!=null?b:0)+1;Qt.set(k,w),w<=Vn&&(E.add(k),w>C&&(C=w))}E.size>0&&setTimeout(()=>{se||y(E)},me(C))},It=r=>{for(let a of r)v.has(a.id)||v.set(a.id,Oe(a))};if(e.initialSlots)for(let[r,a]of Object.entries(e.initialSlots))v.set(r,a),N.add(r);if(e.initialSlotConfig)for(let[r,a]of Object.entries(e.initialSlotConfig))j.set(r,a);e.initialPalette&&(G=e.initialPalette),e.initialVocabulary&&(X=e.initialVocabulary);let le=_e(e.apiKey);if(le){for(let[r,a]of Object.entries(le.slots))v.has(r)||v.set(r,a);for(let[r,a]of Object.entries((on=le.slotConfig)!=null?on:{}))j.has(r)||j.set(r,a);!G&&le.palette&&(G=le.palette),!X&&le.vocabulary&&(X=le.vocabulary)}let Jt={low:.15,medium:.5,high:.85};if(e.initialPersona)F=A({},e.initialPersona);else{let r=document.documentElement.dataset;r.sentientPersona?F={persona:r.sentientPersona,confidence:(sn=Jt[(rn=r.sentientConfidence)!=null?rn:"low"])!=null?sn:.15}:le&&(F={persona:le.persona,confidence:(an=Jt[le.band])!=null?an:.15})}if(e.initialAssignments)for(let[r,a]of Object.entries(e.initialAssignments))M.set(r,p,{variantId:a,assignedAt:Date.now(),segment:p,confidence:1});let he=Promise.resolve(),qt=o.getSessionId();if(qt){let r=We((ln=document.referrer)!=null?ln:""),{utmParams:a,clickIds:y}=Zo(),E=A(A(A(A({sessionId:qt,deviceClass:Y,trafficSource:c,referrerDomain:r,utmParams:a,clickIds:y,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:Ve(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||$e((cn=navigator.userAgent)!=null?cn:"")},e.userId?{userId:e.userId,userHash:e.userHash}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),C=async()=>{l&&await qe(l,2500);for(let b=0;;b++){if(se||!T())return;let k=ue(5e3);try{let w=await fetch(`${P}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(Object.assign(E,f)),headers:L,signal:k.signal});if(w.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(w.ok||Ae(w)==="dropped")return}catch(w){}finally{k.clear()}if(b>=Jo){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(w=>setTimeout(w,me(b+1)))}};try{he=C()}catch(b){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:z});let Hn=qo(),ve=null,At=!1,H={goal(r,a={},y=1,E=0){var W,B,Z,oe,ee,J,I;let C=o.getSessionId();if(!C||se||!T())return;let b=Xo(a)?a:{metadata:a},k=[r,(W=b.externalId)!=null?W:"",(B=b.stepIndex)!=null?B:E,(Z=b.weight)!=null?Z:y].join("\0"),w=b.value!==void 0?`${b.value}\0${(oe=b.currency)!=null?oe:""}`:null;if(Hn.firedBefore(k,w)){e.debug&&console.log(`[sentient] goal("${r}") already recorded for this action \u2014 not sent twice`);return}let K=$t(),O={sessionId:C,name:r,metadata:(ee=b.metadata)!=null?ee:{},weight:(J=b.weight)!=null?J:y,stepIndex:(I=b.stepIndex)!=null?I:E,goalId:K,value:b.value,currency:b.currency,externalId:b.externalId};e.debug&&console.log("[sentient] goal",O);let U={id:K,body:JSON.stringify(O)};he.then(()=>V.send(U))},componentGoal(r,a,y){var K,O,U;let E=o.getSessionId();if(!E||se||!T())return;let C=M.get(r,p),b=C?null:(K=v.get(r))!=null?K:null;if(!C&&b===null){e.debug&&console.warn(`[sentient] componentGoal("${r}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!C&&!N.has(r)){e.debug&&console.warn(`[sentient] componentGoal("${r}"): slot not decided this session \u2014 not attributed`);return}let k=C?C.variantId:mt(b),w={id:$t(),sessionId:E,projectId:e.apiKey,componentId:r,variantId:k,eventType:"goal_achieved",goalType:a,payload:A({reward:(O=y==null?void 0:y.reward)!=null?O:1,goalValue:y==null?void 0:y.value,currency:y==null?void 0:y.currency},(U=y==null?void 0:y.metadata)!=null?U:{}),timestamp:Date.now(),timeInSession:Date.now()-S,path:wt()};e.debug&&console.log("[sentient] componentGoal",w),he.then(()=>{!se&&T()&&z.push(w)})},identify(r,a){let y=o.getSessionId();if(!y||se||!T())return;let E=(a==null?void 0:a.email)!==void 0?Gn().then(C=>C.emailFields(a.email)).catch(()=>({})):{};Promise.all([he,E]).then(([,C])=>{fetch(`${P}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(ge(A(A({sessionId:y,userId:r,userHash:a==null?void 0:a.userHash},C),f),{ephemeral:o.isEphemeral()})),headers:L}).catch(()=>{})})},track(r){let a=o.getSessionId();if(!a||se||!T()||r.eventType==="variant_assigned"&&v.get(r.componentId)!==void 0&&!N.has(r.componentId)&&!M.get(r.componentId,p))return;let y=ge(A({path:wt()},r),{id:$t(),sessionId:a,timestamp:Date.now(),timeInSession:Date.now()-S});e.debug&&console.log("[sentient] track",y),he.then(()=>z.push(y))},getAssignment(r,a){return M.get(r,a)},isUnified:r=>R.has(r),async assign(r,a,y,E,C){var K;let b=o.getSessionId();if(!b)return null;let k=(C==null?void 0:C.unified)===!0;if(k&&R.has(r))return{variantId:(K=a==null?void 0:a[0])!=null?K:"",assignmentTtlMs:0,unified:!0};let w=M.get(r,p);if(w&&(a!=null&&a.length||w.content!==void 0)){let O=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:O,content:w.content}}return Vt(_,k?`${r}\0unified`:r,async()=>{if(!await qe(he,2500)||se||!T())return null;let O=ue(3e4);try{let U={sessionId:b,componentId:r,variantIds:a};E!==void 0?U.agentDataByVariant=E:y!==void 0&&(U.agentData=y),k&&(U.caps={unified:!0});let W=await fetch(`${P}/assign`,{method:"POST",body:JSON.stringify(U),headers:L,signal:O.signal});if(!W.ok)return null;let B=await W.json();return B.unified===!0?k?(R.add(r),{variantId:B.variantId,assignmentTtlMs:0,unified:!0}):null:(M.set(r,p,A({variantId:B.variantId,assignedAt:Date.now(),segment:p,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B)}catch(U){return null}finally{O.clear()}})},async decide(r){var b,k;let a=o.getSessionId();if(!a)return null;let y=(b=r.slots)!=null?b:[],E={sessionId:a};r.sections&&r.sections.length>0&&(E.sections=r.sections.map(w=>({id:w}))),E.components=(k=r.components)!=null?k:[],y.length>0&&(E.slots=y.map(He)),r.slotsFrom==="registry"&&(E.slotsFrom="registry",r.registrySlotIds&&(E.registrySlotIds=r.registrySlotIds),r.bootstrap===!1&&(E.bootstrap=!1),r.render&&Object.keys(r.render).length>0&&(E.render=r.render)),r.v&&(E.v=r.v),typeof r.pp=="number"&&(E.pp=r.pp),e.persona&&(E.persona=e.persona),Object.assign(E,f);let C=JSON.stringify(E);return Vt(m,C,async()=>{var K,O,U,W,B,Z,oe,ee;if(!await qe(he,2500)||se||!T())return It(y),null;let w=ue(3e4);try{let J=await fetch(`${P}/decide`,{method:"POST",body:C,headers:L,signal:w.signal});if(!J.ok)return It(y),null;let I=await J.json(),ce=St(I.stage,e.stageAttributes);e.stageAttributes&&ht(ce);let we={};for(let $ of y){let de=(K=I.slots)==null?void 0:K[$.id];if(de!==void 0){we[$.id]=de,v.set($.id,de),N.add($.id);continue}let dn=v.get($.id);if(dn!==void 0)we[$.id]=dn;else{let un=Oe($);we[$.id]=un,v.set($.id,un)}}if(I.slots)for(let[$,de]of Object.entries(I.slots))$ in we||(we[$]=de,v.set($,de),N.add($));let zn=F!=null&&F.persona!=="unknown";I.persona&&!(I.persona==="unknown"&&zn)?F={persona:I.persona,confidence:(O=I.confidence)!=null?O:0}:F||(F={persona:"unknown",confidence:0});for(let[$,de]of Object.entries((U=I.assignments)!=null?U:{}))M.set($,p,{variantId:de,assignedAt:Date.now(),segment:p,confidence:1});if(I.slotConfig)for(let[$,de]of Object.entries(I.slotConfig))j.set($,de);I.palette&&(G=I.palette),I.vocabulary&&(X=I.vocabulary);for(let $ of(W=r.registrySlotIds)!=null?W:[])(B=I.slotConfig)!=null&&B[$]||(j.delete($),v.delete($),N.delete($));return T()&&Ie(e.apiKey,A(A(A(A({v:1,persona:F.persona,band:(0,jt.confidenceBand)(F.confidence),slots:Object.fromEntries(v),layoutOrder:(Z=I.layoutOrder)!=null?Z:null,savedAt:Date.now()},j.size>0?{slotConfig:Object.fromEntries(j)}:{}),G?{palette:G}:{}),X?{vocabulary:X}:{}),ce?{stage:ce}:{})),A(A(A(A(A(A(A({layoutOrder:(oe=I.layoutOrder)!=null?oe:null,assignments:(ee=I.assignments)!=null?ee:{},slots:we,persona:F.persona,confidence:F.confidence},I.slotConfig?{slotConfig:I.slotConfig}:{}),I.goals?{goals:I.goals}:{}),I.sectionMap?{sectionMap:I.sectionMap}:{}),I.palette?{palette:I.palette}:{}),I.vocabulary?{vocabulary:I.vocabulary}:{}),I.stage?{stage:I.stage}:{}),I.context?{context:I.context}:{})}catch(J){return It(y),null}finally{w.clear()}})},getSlotResult(r){var a;return(a=v.get(r))!=null?a:null},isSlotDecided(r){return N.has(r)},getSlotConfig(r){var a;return(a=j.get(r))!=null?a:null},reportSlots(r,a,y,E){var b;let C={};for(let[k,w]of Object.entries(E!=null?E:{}))for(let K of w){let O=`${k}|${K.key}`;!re.test(k)||Pe.has(O)||(Pe.add(O),((b=C[k])!=null?b:C[k]=[]).push(K))}Object.keys(C).length>0&&fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:Object.keys(C),authoredArms:C})}).catch(()=>{});for(let k of r)if(!(typeof k!="string"||k.length===0)){if(!re.test(k)){zo()&&!zt.has(k)&&(zt.add(k),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(k)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!x.has(k)){x.add(k),D.add(k);let w=a==null?void 0:a[k];if(typeof w=="string"){let O=w.replace(/\s+/g," ").trim().slice(0,400);O!==""&&ae.set(k,O)}let K=y==null?void 0:y[k];K!==void 0&&ye.set(k,K)}}D.size===0||ke!=null||(ke=setTimeout(()=>{ke=null;let k=[...D];D.clear();for(let w=0;w<k.length;w+=20){let K=k.slice(w,w+20),O={},U={};for(let W of K){let B=ae.get(W);B!==void 0&&(O[W]=B,ae.delete(W));let Z=ye.get(W);Z!==void 0&&(U[W]=Z,ye.delete(W))}fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(A(ge(A(A({slotIds:K},Object.keys(O).length>0?{baselineTexts:O}:{}),Object.keys(U).length>0?{baselineSkeletons:U}:{}),{pagePaths:Object.fromEntries(K.map(W=>[W,location.pathname]))}),Object.keys(O).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(r,a){!re.test(r)||ne.has(r)||(ne.add(r),fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:[r],baselineSkeletons:{[r]:a}})}).catch(()=>{}))},reportAgentData(r,a,y){let E=`${r}|${a}`;!re.test(r)||Se.has(E)||(Se.add(E),fetch(`${P}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(A(A({slotIds:[r],agentData:{[r]:{[a]:y}}},a.startsWith("authored.")?{authoredArms:{[r]:[{key:a.slice(9)}]}}:{}),o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{}))},reportDrift(r,a,y,E){let C=`${r}|${a}`,b=o.getSessionId();!b||xe.has(C)||(xe.add(C),fetch(`${P}/slots/drift`,{method:"POST",headers:L,body:JSON.stringify({sessionId:b,reports:[{slotId:r,expectedFp:a,observedFp:y,reason:E}]})}).catch(()=>{}))},requestSlots(r,a,y){var E,C;for(let b of r)Xe.has(b)||(Xe.add(b),re.test(b)?Be.set(b,{text:a==null?void 0:a[b],render:(E=y==null?void 0:y.render)==null?void 0:E[b],skeleton:(C=y==null?void 0:y.skeletons)==null?void 0:C[b]}):H.reportSlots([b]));Be.size===0||Et!=null||(Et=setTimeout(()=>{Et=null;let b=[...Be];Be.clear();for(let k=0;k<b.length;k+=50){let w=b.slice(k,k+50),K={};for(let[O,U]of w)U.render&&(K[O]=U.render);H.decide({slotsFrom:"registry",registrySlotIds:w.map(([O])=>O),bootstrap:!1,render:K}).then(O=>{var U,W;if(O){let B={},Z={},oe=[];for(let[ee,J]of w){let I=(U=O.slotConfig)==null?void 0:U[ee];if(I){I.needsSkeleton&&J.skeleton&&((W=H.reportSkeleton)==null||W.call(H,ee,J.skeleton));continue}oe.push(ee),J.text&&(B[ee]=J.text),J.skeleton&&(Z[ee]=J.skeleton)}oe.length>0&&H.reportSlots(oe,B,Z)}else Xt(w.map(([B])=>B),Xe,B=>{var J;let Z={},oe={},ee={};for(let[I,ce]of w)B.has(I)&&(ce.text&&(Z[I]=ce.text),ce.render&&(oe[I]=ce.render),ce.skeleton&&(ee[I]=ce.skeleton));(J=H.requestSlots)==null||J.call(H,[...B],Z,{render:oe,skeletons:ee})});Qe.forEach(B=>B())})}},0))},decideSlots(r){for(let a of r)Je.has(a.id)||(Je.add(a.id),Le.set(a.id,a));Le.size===0||_t!=null||(_t=setTimeout(()=>{_t=null;let a=[...Le.values()];Le.clear();for(let y=0;y<a.length;y+=30){let E=a.slice(y,y+30);H.decide({slots:E}).then(C=>{C||Xt(E.map(b=>b.id),Je,b=>{var k;return(k=H.decideSlots)==null?void 0:k.call(H,E.filter(w=>b.has(w.id)))}),Qe.forEach(b=>b())})}},0))},cancelSlots(r){for(let a of r)Be.delete(a)&&Xe.delete(a),Le.delete(a)&&Je.delete(a)},onSlotsChanged(r){return Qe.add(r),()=>{Qe.delete(r)}},getStyleVocabulary(){return X},getSitePalette(){return G},getVisitorId:()=>T()?o.getSessionId():null,getPersona(){return F?{persona:F.persona,confidence:F.confidence,band:(0,jt.confidenceBand)(F.confidence)}:null},async fetchWeights(){var a;let r=ue(5e3);try{let y=await fetch(`${P}/weights`,{headers:L,signal:r.signal});return y.ok?(a=(await y.json()).components)!=null?a:[]:[]}catch(y){return[]}finally{r.clear()}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){z.flush(),V.flush()},dispose(){var r;ve==null||ve(),At=!0,se=!0,z.destroy(),V.destroy(),((r=q.get(e.apiKey))==null?void 0:r.dispose)===H.dispose&&q.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var r;ve==null||ve(),At=!0,se=!0,u=!0,tt(e.apiKey),z.destroy({forget:!0}),V.destroy({forget:!0}),o.destroy(),M.clear(),((r=q.get(e.apiKey))==null?void 0:r.dispose)===H.dispose&&q.delete(e.apiKey);try{localStorage.removeItem(fe+e.apiKey),localStorage.removeItem(Ke(e.apiKey)),localStorage.removeItem(Ge(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${pe(e.apiKey)}`),localStorage.removeItem("_snt_graph_edges")}catch(a){}e.debug&&console.log("[sentient] destroyed")}};if(q.set(e.apiKey,{config:e,upgrade:null,dispose:H.dispose}),ve=Yo(H,e.apiKey,r=>{he.then(()=>{At||Fn.add(r)})}),e.debug){let r=window;r.__sentient&&(r.__sentient.client=H)}return H}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_MAX_WIDTHS,BLOCK_PADS,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_SURFACES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,CLASSIC_CRAWLER_TOKENS,CLICK_ID_KEYS,FORM_FIELD_KINDS,FORM_INPUT_TYPES,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,MAX_FORM_FIELDS,MAX_FORM_SELECT_OPTIONS,MAX_SKELETON_LEAVES,MAX_SKELETON_NODES,MAX_SKELETON_TEXT,PAGE_SCOPE_RE,PROD_KEYLESS_ERROR,REVEAL_MS,SNAPSHOT_STORAGE_KEY_PREFIX,STAGE_ATTRIBUTE,_registerConsentUpgradeInit,agentIntent,agentUaList,applyNonce,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,containsFormBlock,cspNonce,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,exposedStage,extractTrackedParams,forgetGeneration,forgetVisitor,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,matchedCrawlerToken,normalizeUrlPattern,pageScopeMatches,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,resetRevealStyles,reveal,routeKey,sessionCookieName,setCspNonce,setStageAttribute,toWireSlot,uaTokenMatch,urlMatches,writeSnapshot});
2
2
  //# sourceMappingURL=index.js.map