@sentientui/core 0.21.2 → 0.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { a5 as SentientConfig, a4 as SentientClient } from './index-BvHshOSe.js';
2
- export { A as AssignResult, a as Assignment, b as AssignmentCache, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, a0 as PageNode, a1 as QueueConfig, a6 as SentientEvent, a7 as SessionConfig, a8 as SessionManager, am as sanitizePageUrl } from './index-BvHshOSe.js';
1
+ import { a6 as SentientConfig, a5 as SentientClient } from './index-BcRtGYVH.js';
2
+ export { A as AssignResult, a as Assignment, b as AssignmentCache, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, a1 as PageNode, a2 as QueueConfig, a7 as SentientEvent, a8 as SessionConfig, a9 as SessionManager, an as sanitizePageUrl } from './index-BcRtGYVH.js';
3
3
  export { j as deriveSessionSegment, k as detectDeviceClass, l as detectTimeOfDay, m as detectTrafficSource, r as referrerDomainFromReferer } from './session-meta-BVvq5RBB.js';
4
4
  import '@sentientui/policy';
5
5
 
@@ -1,2 +1,2 @@
1
- "use strict";var gt=Object.create;var fe=Object.defineProperty,ft=Object.defineProperties,mt=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,Ue=Object.getOwnPropertySymbols,St=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var $e=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Be.call(t,n)&&$e(e,n,t[n]);if(Ue)for(var n of Ue(t))vt.call(t,n)&&$e(e,n,t[n]);return e},X=(e,t)=>ft(e,yt(t));var wt=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},Fe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ht(t))!Be.call(e,u)&&u!==n&&fe(e,u,{get:()=>t[u],enumerable:!(r=mt(t,u))||r.enumerable});return e};var bt=(e,t,n)=>(n=e!=null?gt(St(e)):{},Fe(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e)),It=e=>Fe(fe({},"__esModule",{value:!0}),e);var Rn={};wt(Rn,{deriveSessionSegment:()=>_e,detectDeviceClass:()=>se,detectTimeOfDay:()=>ce,detectTrafficSource:()=>ie,init:()=>kn,referrerDomainFromReferer:()=>ae,sanitizePageUrl:()=>Le});module.exports=It(Rn);function ye(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function oe(e){return e?`_${e.slice(0,12)}`:""}var xt="_snt_uid",Et=365,Ct="_snt_uid";function Tt(){return ye()}function At(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function kt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Rt(e){try{return localStorage.getItem(e)}catch(t){return null}}function _t(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Dt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Ot(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Pt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Nt(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Mt(e){try{localStorage.removeItem(e)}catch(t){}}function Lt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Gt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function he(e){var f,g,m,v,T,E;if(typeof window=="undefined")return Gt;let t=oe(e==null?void 0:e.apiKey),n=(f=e==null?void 0:e.cookieName)!=null?f:`${xt}${t}`,r=`${Ct}${t}`,l=((g=e==null?void 0:e.cookieTTLDays)!=null?g:Et)*24*60*60,i=_=>_&&_.length>0?_:null,d=(E=(T=(v=(m=i(At(n)))!=null?m:i(Rt(r)))!=null?v:i(Dt(r)))!=null?T:i(e==null?void 0:e.ssrSessionId))!=null?E:Tt();kt(n,d,l);let s=_t(r,d),o=Nt(n),a=s?!1:Ot(r,d),c=!s&&!o&&!a;return{getSessionId:()=>d,isEphemeral:()=>c,destroy:()=>{d=null,Lt(n),Mt(r),Pt(r)}}}function Z(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function re(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 Se(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function ee(e,t,n){try{let r=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let i=JSON.parse(l);return Array.isArray(i)?i:[]}catch(l){return[]}})(),u=new Map;for(let l of r)u.set(l.id,l);for(let l of e)u.set(l.id,l);localStorage.setItem(n,JSON.stringify([...u.values()].slice(-t)))}catch(r){}}function ve(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let u=new Set(e),l=r.filter(i=>!u.has(i.id));if(l.length===r.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var Kt=500,Ut=56*1024;function ke(e){return`_snt_retry_${e.slice(0,12)}`}var $t={push:()=>{},flush:()=>{},destroy:()=>{}};function je(e){var U,M,Q;if(typeof window=="undefined")return $t;let t=(U=e.flushIntervalMs)!=null?U:5e3,n=(M=e.maxBatchSize)!=null?M:20,r=(Q=e.maxRetrySize)!=null?Q:100,u=e.ingestUrl,l=e.apiKey,i=ke(l),d=[],s=new Set,o=[],a=h=>{for(let I of h)c.delete(I),!s.has(I)&&(s.add(I),o.push(I));for(;o.length>Kt;){let I=o.shift();I&&s.delete(I)}ve(h,i)},c=new Set,f=h=>{s.has(h.id)||c.has(h.id)||(c.add(h.id),d.push(h))},g=h=>{for(let I of h)s.has(I.id)||(c.add(I.id),d.push(I))},m=Se(i,r);for(let h of m)f(h);let v=0,T=0,E=(h,I=!0)=>{if(h.length===0)return;let q=JSON.stringify(h),te=h.map(H=>H.id),F;try{F=fetch(u,{method:"POST",keepalive:!0,body:q,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(H){ee(h,r,i),g(h),T++,v=Date.now()+Z(T);return}let le=H=>{if(re(H)!=="retry"){if(!H.ok&&I){let ne=h.filter(V=>V.eventType!=="pageview");if(ne.length>0&&ne.length<h.length){a(h.filter(V=>V.eventType==="pageview").map(V=>V.id)),E(ne,!1);return}}a(te),T=0,v=0;return}ee(h,r,i),g(h),T++,v=Date.now()+Z(T)};F instanceof Promise?F.then(le).catch(()=>{ee(h,r,i),g(h),T++,v=Date.now()+Z(T)}):le(F)},_=typeof TextEncoder!="undefined"?new TextEncoder:null,N=h=>_?_.encode(h).length:h.length,k=h=>{let I=[],q=2;for(let te of h){let F=N(JSON.stringify(te))+1;if(I.length>0&&q+F>Ut||I.length>=n)break;I.push(te),q+=F}return I},L=()=>{try{if(Date.now()<v)return;for(;d.length>0&&!(Date.now()<v);){let h=d.filter(q=>!s.has(q.id));if(d.length=0,h.length===0)break;let I=k(h);if(I.length===0)break;I.length<h.length&&d.push(...h.slice(I.length)),E(I)}}catch(h){}},K=!0,S=null;S=setInterval(()=>{K&&L()},t);let A=()=>{document.visibilityState==="hidden"&&L()},J=()=>{L()};return document.addEventListener("visibilitychange",A),window.addEventListener("pagehide",J),{push(h){f(h),d.length>=n&&L()},flush:L,destroy(){K=!1,S!==null&&(clearInterval(S),S=null),document.removeEventListener("visibilitychange",A),window.removeEventListener("pagehide",J),L()}}}var Bt=200;function Re(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ft={send:()=>{},flush:()=>{},destroy:()=>{}};function We(e){var k,L,K;if(typeof window=="undefined")return Ft;let t=(k=e.flushIntervalMs)!=null?k:5e3,n=(L=e.maxRetrySize)!=null?L:100,r=(K=e.maxPerFlush)!=null?K:5,u=Re(e.apiKey),l=[],i=new Set,d=new Set,s=[],o=0,a=0,c=!1,f=S=>{for(i.delete(S.id),d.has(S.id)||(d.add(S.id),s.push(S.id));s.length>Bt;){let A=s.shift();A&&d.delete(A)}ve([S.id],u)},g=S=>{ee([S],n,u),!d.has(S.id)&&!i.has(S.id)&&(i.add(S.id),l.push(S)),Date.now()>=o&&(a++,o=Date.now()+Z(a))},m=S=>{let A;try{A=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(U){g(S);return}let J=U=>{var Q;let M=re(U);if(M==="retry"){g(S);return}M==="dropped"&&((Q=e.onDrop)==null||Q.call(e,S,U.status)),f(S),a=0,o=0};A instanceof Promise?A.then(J).catch(()=>g(S)):J(A)},v=()=>{try{if(c||Date.now()<o)return;let S=0;for(;l.length>0&&S<r&&!(Date.now()<o);){let A=l.shift();i.delete(A.id),!d.has(A.id)&&(S++,m(A))}}catch(S){}},T=Se(u,n);for(let S of T)i.has(S.id)||(i.add(S.id),l.push(S));T.length>0&&ee(T,n,u);let E=setInterval(v,t),_=()=>{document.visibilityState==="hidden"&&v()},N=()=>v();return document.addEventListener("visibilitychange",_),window.addEventListener("pagehide",N),{send(S){if(!c&&!(d.has(S.id)||i.has(S.id))){if(Date.now()<o){ee([S],n,u),i.add(S.id),l.push(S);return}m(S)}},flush:v,destroy(){clearInterval(E),document.removeEventListener("visibilitychange",_),window.removeEventListener("pagehide",N),v(),c=!0}}}var jt=1800*1e3;function we(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ze(e=jt,t){let n=new Map,r=`_snt_asgn${oe(t)}_`,u=(o,a)=>`${r}${encodeURIComponent(o)}:${encodeURIComponent(a)}`,l=o=>{let a=o.slice(r.length),c=a.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(a.slice(0,c)),segment:decodeURIComponent(a.slice(c+1))}}catch(f){return null}},i=()=>{try{let o=[];for(let a=0;a<localStorage.length;a++){let c=localStorage.key(a);c!=null&&c.startsWith(r)&&o.push(c)}return o}catch(o){return[]}},d=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of i())try{let a=localStorage.getItem(o);if(!a)continue;let c=JSON.parse(a);if(d(c)){localStorage.removeItem(o);continue}let f=l(o);if(!f)continue;n.set(we(f.componentId,f.segment),c)}catch(a){}})(),{get(o,a){let c=n.get(we(o,a));return c?d(c)?(n.delete(we(o,a)),null):c:null},set(o,a,c){let f=we(o,a);n.set(f,c);try{localStorage.setItem(u(o,a),JSON.stringify(c))}catch(g){}},invalidate(o){let a=`${encodeURIComponent(o)}:`;for(let c of[...n.keys()])c.startsWith(a)&&n.delete(c);for(let c of i()){let f=l(c);if((f==null?void 0:f.componentId)===o)try{localStorage.removeItem(c)}catch(g){}}},clear(){n.clear();for(let o of i())try{localStorage.removeItem(o)}catch(a){}}}}var Qe=["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 be(e){return qe(e)!==null}function qe(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Qe.find(r=>t.includes(r.toLowerCase())))!=null?n:null}function se(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 ie(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(u){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function ae(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ce(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function _e(e){let t=Wt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Wt(e,t){var l,i,d,s,o,a,c;let n=(i=(l=t==null?void 0:t.userAgent)==null?void 0:l.trim())!=null?i:"",r=(s=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?s:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(a=t==null?void 0:t.utmParams)!=null?a:{},deviceClass:n?se(n):"desktop",trafficSource:r?ie(r,t==null?void 0:t.appOrigin):"direct",referrerDomain:ae(r),timeOfDay:ce(u),dayOfWeek:(c=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?c:"sun",automation:(t==null?void 0:t.webdriver)===!0||be(n)}}var de=require("@sentientui/policy");function De(e){return b(b(b({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=De(e);return(0,de.slotResultFor)(t,(0,de.slotBaselineArm)(t))}function Je(e){return typeof e=="string"?e:(0,de.canonicalArm)(e)}var Ie="_snt_snap:",zt=["low","medium","high"];function He(e){try{let t=localStorage.getItem(Ie+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!zt.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function xe(e,t){try{localStorage.setItem(Ie+e,JSON.stringify(t))}catch(n){}}var Ne=require("@sentientui/policy");var Ce=require("@sentientui/policy");var Ve="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Qt="[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.",Ye=!1,Ee=!1;function qt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Xe(e){var d;let t=he({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(d=t.getSessionId())!=null?d:"local",r=qt(),u=import("@sentientui/core/local").then(s=>{let o=s;return o.LOCAL_ENGINE_AVAILABLE?(Ye||(Ye=!0,console.info(Qt)),o):(Ee||(Ee=!0,console.error(Ve)),null)}).catch(()=>(Ee||(Ee=!0,console.error(Ve)),null)),l=null;function i(s){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=s.persona,o.dataset.sentientConfidence=(0,Ce.confidenceBand)(s.confidence))}return{isLocal:!0,async decide(s){var c,f,g;let o=await u;if(!o)return null;let a=o.createLocalEngine({sessionId:n,forcedPersona:r}).decide(s);return l=X(b({},a),{layoutOrder:(f=(c=a.layoutOrder)!=null?c:l==null?void 0:l.layoutOrder)!=null?f:null,slots:b(b({},(g=l==null?void 0:l.slots)!=null?g:{}),a.slots)}),xe(e.apiKey||"local",{v:1,persona:l.persona,band:(0,Ce.confidenceBand)(l.confidence),slots:l.slots,layoutOrder:l.layoutOrder,savedAt:Date.now()}),i(a),a},getSlotResult(s){var o,a,c;return(c=(a=l==null?void 0:l.slots[s])!=null?a:(o=e.initialSlots)==null?void 0:o[s])!=null?c:null},getPersona(){return l?{persona:l.persona,confidence:l.confidence,band:(0,Ce.confidenceBand)(l.confidence)}:null},async assign(s,o){var f;let a=await u;return!a||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(f=a.createLocalEngine({sessionId:n,forcedPersona:r}).decide({components:[{id:s,variantIds:o}]}).assignments[s])!=null?f:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Ze="https://api.sentient-ui.com/v1/events",z=new Map,Jt=null;function Ht(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Vt=3;function Pe(){return ye()}function Te(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Yt(e){if(typeof MessageChannel=="function"){let t=new MessageChannel;t.port1.onmessage=()=>{e.clear(),t.port1.close(),t.port2.close()},t.port2.postMessage(0)}else setTimeout(()=>e.clear(),0)}var et=new Set;function Xt(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let u=!1,l,i=()=>{if(u)return;let o=Te();!o||o===l||(l=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},d=[];for(let o of["pushState","replaceState"]){let a=r[o],c=function(...f){let g=a.apply(this,f);return i(),g};r[o]=c,d.push([o,a,c])}window.addEventListener("popstate",i);let s=Te();return s&&et.has(`${t}:${s}`)?l=s:i(),()=>{if(!u){u=!0,window.removeEventListener("popstate",i);for(let[o,a,c]of d)r[o]===c&&(r[o]=a)}}}var me={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Zt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function tt(e){return e.replace(/\/events\/?$/,"")}function Me(){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 en(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=tt((d=e.ingestUrl)!=null?d:Ze),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(s,o,a){if(!t)return null;try{let c=new URLSearchParams({componentId:s});for(let m of o!=null?o:[])c.append("variantIds[]",m);let f=await fetch(`${n}/winner?${c.toString()}`,{headers:r});return f.ok?{variantId:(await f.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(c){return o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:s=>u.track(s),goal:((s,o,a,c)=>u.goal(s,o,a,c)),componentGoal:(s,o,a)=>u.componentGoal(s,o,a),identify:s=>u.identify(s),getAssignment:(s,o)=>u.getAssignment(s,o),assign:(s,o,a,c)=>u.assign(s,o,a,c),decide:s=>u.decide(s),getSlotResult:s=>u.getSlotResult(s),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function i(s){u=s}return{proxy:l,setInner:i}}function nt(e){var I,q,te,F,le,H,ne,V,Ke;if(typeof window=="undefined")return me;Jt=e.apiKey;let t=z.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(p){}let n=e.respectDoNotTrack!==!1&&Me(),r=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return r?(z.set(e.apiKey||"local",{config:e,upgrade:null}),me):(z.set(e.apiKey||"local",{config:e,upgrade:null}),Xe(e));if(r){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."),z.set(e.apiKey,{config:e,upgrade:null}),me;let{proxy:p,setInner:y}=en(e);return z.set(e.apiKey,{config:e,upgrade:n?null:y}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),me;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),me;let l=(I=e.ingestUrl)!=null?I:Ze,i=Date.now(),d=he({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),s=ze(void 0,e.apiKey),o=je({ingestUrl:l,apiKey:e.apiKey}),a=tt(l),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},f=new Set,g=We({url:`${a}/goals`,apiKey:e.apiKey,headers:c,onDrop:(p,y)=>{if(!e.debug){if(f.has(y))return;f.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),m=se((q=navigator.userAgent)!=null?q:""),v=typeof window!="undefined"?window.location.origin:void 0,T=ie((te=document.referrer)!=null?te:"",v),E=(F=e.sessionSegment)!=null?F:`${m}:${T}`,_=new Map,N=new Map,k=null,L=p=>{for(let y of p)N.has(y.id)||N.set(y.id,Oe(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))N.set(p,y);let K=He(e.apiKey);if(K)for(let[p,y]of Object.entries(K.slots))N.has(p)||N.set(p,y);let S={low:.15,medium:.5,high:.85};if(e.initialPersona)k=b({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?k={persona:p.sentientPersona,confidence:(H=S[(le=p.sentientConfidence)!=null?le:"low"])!=null?H:.15}:K&&(k={persona:K.persona,confidence:(ne=S[K.band])!=null?ne:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))s.set(p,E,{variantId:y,assignedAt:Date.now(),segment:E,confidence:1});let A=Promise.resolve(),J=d.getSessionId();if(J){let p=ae((V=document.referrer)!=null?V:""),y=b(b(b({sessionId:J,deviceClass:m,trafficSource:T,referrerDomain:p,utmParams:Zt(),timeOfDay:ce(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||be((Ke=navigator.userAgent)!=null?Ke:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),w=async()=>{for(let D=0;;D++){try{let R=await fetch(`${a}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:c});if(R.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(R.ok||re(R)==="dropped")return}catch(R){}if(D>=Vt){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(R=>setTimeout(R,Z(D+1)))}};try{A=w()}catch(D){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let U=new Set,M=null,Q=!1,h={goal(p,y={},w=1,D=0){var P,ue,B,pe,x,Y;let R=d.getSessionId();if(!R)return;let C=Ht(y)?y:{metadata:y},j=`${p}\0${(P=C.externalId)!=null?P:""}\0${(ue=C.stepIndex)!=null?ue:D}\0${(B=C.weight)!=null?B:w}`;if(U.has(j)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}U.add(j),U.size===1&&Yt(U);let $=Pe(),O={sessionId:R,name:p,metadata:(pe=C.metadata)!=null?pe:{},weight:(x=C.weight)!=null?x:w,stepIndex:(Y=C.stepIndex)!=null?Y:D,goalId:$,value:C.value,currency:C.currency,externalId:C.externalId};e.debug&&console.log("[sentient] goal",O);let W={id:$,body:JSON.stringify(O)};A.then(()=>g.send(W))},componentGoal(p,y,w){var O,W,P;let D=d.getSessionId();if(!D)return;let R=s.get(p,E),C=R?null:(O=N.get(p))!=null?O:null;if(!R&&C===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let j=R?R.variantId:Je(C),$={id:Pe(),sessionId:D,projectId:e.apiKey,componentId:p,variantId:j,eventType:"goal_achieved",goalType:y,payload:b({reward:(W=w==null?void 0:w.reward)!=null?W:1,goalValue:w==null?void 0:w.value,currency:w==null?void 0:w.currency},(P=w==null?void 0:w.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-i,path:Te()};e.debug&&console.log("[sentient] componentGoal",$),A.then(()=>o.push($))},identify(p){let y=d.getSessionId();y&&A.then(()=>{fetch(`${a}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:d.isEphemeral()}),headers:c}).catch(()=>{})})},track(p){let y=d.getSessionId();if(!y)return;let w=X(b({path:Te()},p),{id:Pe(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-i});e.debug&&console.log("[sentient] track",w),A.then(()=>o.push(w))},getAssignment(p,y){return s.get(p,y)},async assign(p,y,w,D){let R=d.getSessionId();if(!R)return null;let C=s.get(p,E);if(C&&(y!=null&&y.length||C.content!==void 0)){let O=C.ttlMs&&C.ttlMs>0?Math.max(0,C.assignedAt+C.ttlMs-Date.now()):0;return{variantId:C.variantId,assignmentTtlMs:O,content:C.content}}let j=_.get(p);if(j)return j;let $=(async()=>{await A;try{let O={sessionId:R,componentId:p,variantIds:y};D!==void 0?O.agentDataByVariant=D:w!==void 0&&(O.agentData=w);let W=await fetch(`${a}/assign`,{method:"POST",body:JSON.stringify(O),headers:c});if(!W.ok)return null;let P=await W.json();return s.set(p,E,b({variantId:P.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:P.content},P.assignmentTtlMs&&P.assignmentTtlMs>0?{ttlMs:P.assignmentTtlMs}:{})),P}catch(O){return null}finally{_.delete(p)}})();return _.set(p,$),$},async decide(p){var D,R,C,j,$,O,W,P,ue;let y=d.getSessionId();if(!y)return null;let w=(D=p.slots)!=null?D:[];await A;try{let B={sessionId:y};p.sections&&p.sections.length>0&&(B.sections=p.sections.map(G=>({id:G}))),B.components=(R=p.components)!=null?R:[],w.length>0&&(B.slots=w.map(De)),p.slotsFrom==="registry"&&(B.slotsFrom="registry"),p.v&&(B.v=p.v),e.persona&&(B.persona=e.persona);let pe=await fetch(`${a}/decide`,{method:"POST",body:JSON.stringify(B),headers:c});if(!pe.ok)return L(w),null;let x=await pe.json(),Y={};for(let G of w)Y[G.id]=(j=(C=x.slots)==null?void 0:C[G.id])!=null?j:Oe(G);if(x.slots)for(let[G,ge]of Object.entries(x.slots))G in Y||(Y[G]=ge);for(let[G,ge]of Object.entries(Y))N.set(G,ge);let pt=k!=null&&k.persona!=="unknown";x.persona&&!(x.persona==="unknown"&&pt)?k={persona:x.persona,confidence:($=x.confidence)!=null?$:0}:k||(k={persona:"unknown",confidence:0});for(let[G,ge]of Object.entries((O=x.assignments)!=null?O:{}))s.set(G,E,{variantId:ge,assignedAt:Date.now(),segment:E,confidence:1});return xe(e.apiKey,b(b({v:1,persona:k.persona,band:(0,Ne.confidenceBand)(k.confidence),slots:Object.fromEntries(N),layoutOrder:(W=x.layoutOrder)!=null?W:null,savedAt:Date.now()},x.slotConfig?{slotConfig:x.slotConfig}:{}),x.palette?{palette:x.palette}:{})),b(b(b(b({layoutOrder:(P=x.layoutOrder)!=null?P:null,assignments:(ue=x.assignments)!=null?ue:{},slots:Y,persona:k.persona,confidence:k.confidence},x.slotConfig?{slotConfig:x.slotConfig}:{}),x.goals?{goals:x.goals}:{}),x.sectionMap?{sectionMap:x.sectionMap}:{}),x.palette?{palette:x.palette}:{})}catch(B){return L(w),null}},getSlotResult(p){var y;return(y=N.get(p))!=null?y:null},getPersona(){return k?{persona:k.persona,confidence:k.confidence,band:(0,Ne.confidenceBand)(k.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${a}/weights`,{headers:c});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;M==null||M(),Q=!0,o.destroy(),g.destroy(),((p=z.get(e.apiKey))==null?void 0:p.dispose)===h.dispose&&z.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;M==null||M(),Q=!0,o.destroy(),g.destroy(),d.destroy(),((p=z.get(e.apiKey))==null?void 0:p.dispose)===h.dispose&&z.delete(e.apiKey);try{localStorage.removeItem(Ie+e.apiKey),localStorage.removeItem(ke(e.apiKey)),localStorage.removeItem(Re(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(z.set(e.apiKey,{config:e,upgrade:null,dispose:h.dispose}),M=Xt(h,e.apiKey,p=>{A.then(()=>{Q||et.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=h)}return h}var ot="_snt_graph_edges",tn={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function nn(e){var t;return(t=tn[e])!=null?t:[]}function on(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function rn(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var sn=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function an(e){return sn.has(e)?e:"generic"}function Le(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function cn(e,t,n){let r=`${e}:${t}:${n.join(",")}`,u=5381;for(let l=0;l<r.length;l++)u=(u<<5)+u+r.charCodeAt(l)&4294967295;return(u>>>0).toString(16).padStart(8,"0")}function rt(e){let t=new Map,n=new Map,r=`_snt_graph_nodes${oe(e==null?void 0:e.apiKey)}`,u=()=>{typeof window!="undefined"&&rn(r,[...t.values()])},l=i=>{var d;try{let s=JSON.parse(i);t.clear();for(let o of(d=s.pageNodes)!=null?d:[])t.set(o.componentId,o)}catch(s){}};if(typeof window!="undefined"){let i=on(r,[]);for(let d of i)t.set(d.componentId,d);try{localStorage.removeItem(ot)}catch(d){}}return{addPageNode(i){t.set(i.componentId,i),u()},addStructuralEdge(i){let d=`${i.fromComponentId}->${i.toComponentId}`;n.set(d,i)},syncOnce(){var d,s;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let i=[...t.values()];if(i.length!==0)try{let o=new Map;for(let m of i){let v=(d=o.get(m.semanticType))!=null?d:[];v.push(m),o.set(m.semanticType,v)}let a=[],c=new Set;for(let m of i)for(let v of nn(m.semanticType)){let T=(s=o.get(v))!=null?s:[];for(let E of T){if(E.componentId===m.componentId)continue;let _=`semantic:${m.componentId}->${E.componentId}`;c.has(_)||(c.add(_),a.push({fromComponentId:m.componentId,toComponentId:E.componentId,type:"semantic",weight:.4,confidence:.9}))}}let f=new Set(i.map(m=>m.componentId));for(let m of n.values()){if(!f.has(m.fromComponentId)||!f.has(m.toComponentId))continue;let v=`structural:${m.fromComponentId}->${m.toComponentId}`;c.has(v)||(c.add(v),a.push({fromComponentId:m.fromComponentId,toComponentId:m.toComponentId,type:"structural",weight:m.weight,confidence:1}))}let g=X(b(b({pageUrl:Le(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:i.map(m=>{let v=an(m.semanticType);return{componentId:m.componentId,semanticType:v,answers:m.answers,contentHash:cn(m.componentId,v,m.answers),prominenceScore:m.prominenceScore,depthInPage:m.depth}}),edges:a});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:b({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(g)}).catch(()=>{})}catch(o){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:l,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(r),localStorage.removeItem(ot)}catch(i){}}}}var st=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],dn=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],ln=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function un(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function pn(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of dn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of ln)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function gn(e){var n,r;let t=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((r=e.className)!=null?r:"")}`,headingText:un(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function it(e){return pn(gn(e)).type}var fn=new Set(["SECTION","ARTICLE","MAIN","DIV"]),mn="h1, h2, h3",at=30,yn=1500,hn={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function ct(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function Sn(e){var t,n,r;try{let u=e;for(let l of Object.keys(u)){if(!l.startsWith("__reactFiber")&&!l.startsWith("__reactInternalInstance"))continue;let i=u[l],d=(r=(t=i==null?void 0:i.type)==null?void 0:t.displayName)!=null?r:(n=i==null?void 0:i.type)==null?void 0:n.name;if(d&&d.length>1)return d}}catch(u){}}function vn(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var dt=new Set(st);function wn(e){let t=e.getAttribute("data-sentient-type");if(t&&dt.has(t))return t;let n=e.getAttribute("role");return n&&dt.has(n)?n:it(e)}function bn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)&4294967295;return(t>>>0).toString(16).padStart(8,"0")}function In(e){let t=[],n=e;for(;n;){let r=n.parentElement;if(!r){t.push(n.tagName.toLowerCase());break}let u=Array.prototype.indexOf.call(r.children,n);t.push(`${n.tagName.toLowerCase()}[${u}]`),n=r}return t.reverse().join("/")}function xn(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${bn(In(e))}`}function En(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Ge(e,t){var r,u,l;let n=e.querySelector(mn);return{componentId:xn(e),semanticType:wn(e),ariaLabel:(r=e.getAttribute("aria-label"))!=null?r:void 0,headingText:(l=(u=n==null?void 0:n.textContent)==null?void 0:u.trim())!=null?l:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:En(e),reactComponentName:Sn(e),dataAttributes:vn(e)}}function lt(e){var l;let t=[],n=new Set,r="__root__",u=new Map;for(let[i,d]of e){let s=i.parentElement,o=r;for(;s;){if(e.has(s)){o=e.get(s);let c=e.get(i),f=`${o}->${c}`;!n.has(f)&&o!==c&&(n.add(f),t.push({fromComponentId:o,toComponentId:c,weight:.6}));break}s=s.parentElement}let a=(l=u.get(o))!=null?l:[];a.push(i),u.set(o,a)}for(let i of u.values()){if(i.length<2)continue;let d=i.length>at?i.slice(0,at):i;for(let s=0;s<d.length;s++)for(let o=s+1;o<d.length;o++){if(t.length>=yn)return t;let a=e.get(d[s]),c=e.get(d[o]);if(a===c)continue;let f=`${a}->${c}::sib`,g=`${c}->${a}::sib`;n.has(f)||(n.add(f),t.push({fromComponentId:a,toComponentId:c,weight:.3})),n.has(g)||(n.add(g),t.push({fromComponentId:c,toComponentId:a,weight:.3}))}}return t}function Cn(e){let t=[],n=new Set,r=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(i=>{if(i instanceof Element&&!n.has(i)){n.add(i);let d=Ge(i,e);t.push(d),r.set(i,d.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(i=>{if(!(i instanceof Element)||n.has(i))return;let d=i.hasAttribute("aria-label"),s=i.hasAttribute("data-sentient-id");if(!d&&!s)return;n.add(i);let o=Ge(i,e);t.push(o),r.set(i,o.componentId)}),{nodes:t,edges:lt(r),elementToId:r}}function ut(){if(typeof window=="undefined")return hn;let e=null,t=0,n=null,r=new Map,u=s=>{try{let o=window.getComputedStyle(s),a=parseFloat(o.fontSize)||12,c=parseFloat(o.zIndex)||0,f=s.getBoundingClientRect(),g=Math.max(f.top,0),m=window.innerHeight||1,v=1/(g/m+1),T=ct(a,12,48)*.4+v*.4+ct(c,0,100)*.2;return Math.max(0,Math.min(1,T))}catch(o){return .5}};return{scan:()=>new Promise(s=>{let o=()=>{let{nodes:a,edges:c,elementToId:f}=Cn(u);r.clear();for(let[g,m]of f)r.set(g,m);s({nodes:a,edges:c,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(o,{timeout:100}):o()}catch(a){o()}}),observe:s=>{n=s;try{e=new MutationObserver(o=>{let a=[],c=new Set;for(let g of o)g.type==="childList"&&g.addedNodes.forEach(m=>{if(!(m instanceof Element)||!fn.has(m.tagName))return;let v=m.hasAttribute("data-sentient-id"),T=m.hasAttribute("aria-label");if(!v&&!T)return;let E=Ge(m,u);a.push(E),c.add(E.componentId),r.set(m,E.componentId)});if(a.length===0||!n)return;for(let g of[...r.keys()])g.isConnected||r.delete(g);let f=lt(r).filter(g=>c.has(g.fromComponentId)||c.has(g.toComponentId));n({nodes:a,edges:f,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(o){}},getProminenceScore:u,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(s){}t=0,n=null,r.clear()}}}var Tn="https://api.sentient-ui.com/v1/events";function An(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var Ae=new Map;function kn(e){var c;let t=nt(e),n=e.respectDoNotTrack!==!1&&Me(),r=e.consent===!1||n;if(!e.graph||!e.apiKey||r||typeof window=="undefined")return t;let u=Ae.get(e.apiKey);if(u)try{u()}catch(f){}let l=ut(),i=(c=e.ingestUrl)!=null?c:Tn,d=rt({syncUrl:i.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:An()});l.scan().then(f=>{for(let g of f.nodes)d.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:e.captureDomText&&g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of f.edges)d.addStructuralEdge(g);d.syncOnce()});let s=null,o=()=>{s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,d.syncOnce()},500)};l.observe(f=>{for(let g of f.nodes)d.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:e.captureDomText&&g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of f.edges)d.addStructuralEdge(g);o()});let a=()=>{s!==null&&(clearTimeout(s),s=null),l.destroy(),d.destroy(),Ae.get(e.apiKey)===a&&Ae.delete(e.apiKey)};return Ae.set(e.apiKey,a),X(b({},t),{getGraph:()=>d.snapshot(),dispose:()=>{a(),t.dispose()},destroy:()=>{a(),t.destroy()}})}0&&(module.exports={deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,init,referrerDomainFromReferer,sanitizePageUrl});
1
+ "use strict";var vt=Object.create;var fe=Object.defineProperty,wt=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertyNames,je=Object.getOwnPropertySymbols,xt=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable;var We=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&We(e,n,t[n]);if(je)for(var n of je(t))Ct.call(t,n)&&We(e,n,t[n]);return e},X=(e,t)=>wt(e,It(t));var At=(e,t)=>{for(var n in t)fe(e,n,{get:t[n],enumerable:!0})},Qe=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Et(t))!ze.call(e,l)&&l!==n&&fe(e,l,{get:()=>t[l],enumerable:!(s=bt(t,l))||s.enumerable});return e};var Tt=(e,t,n)=>(n=e!=null?vt(xt(e)):{},Qe(t||!e||!e.__esModule?fe(n,"default",{value:e,enumerable:!0}):n,e)),kt=e=>Qe(fe({},"__esModule",{value:!0}),e);var On={};At(On,{deriveSessionSegment:()=>Pe,detectDeviceClass:()=>se,detectTimeOfDay:()=>ce,detectTrafficSource:()=>ie,init:()=>_n,referrerDomainFromReferer:()=>ae,sanitizePageUrl:()=>$e});module.exports=kt(On);function he(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function ne(e){return e?`_${e.slice(0,12)}`:""}var _e="_snt_uid";function Se(e){return`${_e}${ne(e)}`}var Rt="_snt_uid",_t=365,Oe="_snt_uid";function Ot(){return he()}function qe(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Dt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(s){}}function Je(e){try{return localStorage.getItem(e)}catch(t){return null}}function Nt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function He(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Pt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Mt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Lt(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Gt(e){try{localStorage.removeItem(e)}catch(t){}}function Kt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Ut={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ve(e){var g,m,v,T,A,D,_;if(typeof window=="undefined")return Ut;let t=ne(e==null?void 0:e.apiKey),n=(g=e==null?void 0:e.cookieName)!=null?g:Se(e==null?void 0:e.apiKey),s=`${Oe}${t}`,u=((m=e==null?void 0:e.cookieTTLDays)!=null?m:_t)*24*60*60,a=b=>b&&b.length>0?b:null,d=()=>{var b,N;return t&&!(e!=null&&e.cookieName)?(N=(b=a(qe(Rt)))!=null?b:a(Je(Oe)))!=null?N:a(He(Oe)):null},o=(_=(D=(A=(T=(v=a(qe(n)))!=null?v:a(Je(s)))!=null?T:a(He(s)))!=null?A:d())!=null?D:a(e==null?void 0:e.ssrSessionId))!=null?_:Ot();Dt(n,o,u);let r=Nt(s,o),i=Lt(n),c=r?!1:Pt(s,o),f=!r&&!i&&!c;return{getSessionId:()=>o,isEphemeral:()=>f,destroy:()=>{o=null,Kt(n),Gt(s),Mt(s)}}}function Z(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function oe(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 we(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 ee(e,t,n){try{let s=(()=>{try{let u=localStorage.getItem(n);if(!u)return[];let a=JSON.parse(u);return Array.isArray(a)?a:[]}catch(u){return[]}})(),l=new Map;for(let u of s)l.set(u.id,u);for(let u of e)l.set(u.id,u);localStorage.setItem(n,JSON.stringify([...l.values()].slice(-t)))}catch(s){}}function be(e,t){try{let n=localStorage.getItem(t);if(!n)return;let s=JSON.parse(n);if(!Array.isArray(s))return;let l=new Set(e),u=s.filter(a=>!l.has(a.id));if(u.length===s.length)return;u.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(u))}catch(n){}}var $t=500,Bt=56*1024;function De(e){return`_snt_retry_${e.slice(0,12)}`}var Ft={push:()=>{},flush:()=>{},destroy:()=>{}};function Ye(e){var J,G,W;if(typeof window=="undefined")return Ft;let t=(J=e.flushIntervalMs)!=null?J:5e3,n=(G=e.maxBatchSize)!=null?G:20,s=(W=e.maxRetrySize)!=null?W:100,l=e.ingestUrl,u=e.apiKey,a=De(u),d=[],o=new Set,r=[],i=h=>{for(let x of h)c.delete(x),!o.has(x)&&(o.add(x),r.push(x));for(;r.length>$t;){let x=r.shift();x&&o.delete(x)}be(h,a)},c=new Set,f=h=>{o.has(h.id)||c.has(h.id)||(c.add(h.id),d.push(h))},g=h=>{for(let x of h)o.has(x.id)||(c.add(x.id),d.push(x))},m=we(a,s);for(let h of m)f(h);let v=0,T=0,A=(h,x=!0)=>{if(h.length===0)return;let z=JSON.stringify(h),te=h.map(H=>H.id),B;try{B=fetch(l,{method:"POST",keepalive:!0,body:z,headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`}})}catch(H){ee(h,s,a),g(h),T++,v=Date.now()+Z(T);return}let le=H=>{if(oe(H)!=="retry"){if(!H.ok&&x){let re=h.filter(Y=>Y.eventType!=="pageview");if(re.length>0&&re.length<h.length){i(h.filter(Y=>Y.eventType==="pageview").map(Y=>Y.id)),A(re,!1);return}}i(te),T=0,v=0;return}ee(h,s,a),g(h),T++,v=Date.now()+Z(T)};B instanceof Promise?B.then(le).catch(()=>{ee(h,s,a),g(h),T++,v=Date.now()+Z(T)}):le(B)},D=typeof TextEncoder!="undefined"?new TextEncoder:null,_=h=>D?D.encode(h).length:h.length,b=h=>{let x=[],z=2;for(let te of h){let B=_(JSON.stringify(te))+1;if(x.length>0&&z+B>Bt||x.length>=n)break;x.push(te),z+=B}return x},N=()=>{try{if(Date.now()<v)return;for(;d.length>0&&!(Date.now()<v);){let h=d.filter(z=>!o.has(z.id));if(d.length=0,h.length===0)break;let x=b(h);if(x.length===0)break;x.length<h.length&&d.push(...h.slice(x.length)),A(x)}}catch(h){}},K=!0,S=null;S=setInterval(()=>{K&&N()},t);let k=()=>{document.visibilityState==="hidden"&&N()},q=()=>{N()};return document.addEventListener("visibilitychange",k),window.addEventListener("pagehide",q),{push(h){f(h),d.length>=n&&N()},flush:N,destroy(){K=!1,S!==null&&(clearInterval(S),S=null),document.removeEventListener("visibilitychange",k),window.removeEventListener("pagehide",q),N()}}}var jt=200;function Ne(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Wt={send:()=>{},flush:()=>{},destroy:()=>{}};function Ve(e){var b,N,K;if(typeof window=="undefined")return Wt;let t=(b=e.flushIntervalMs)!=null?b:5e3,n=(N=e.maxRetrySize)!=null?N:100,s=(K=e.maxPerFlush)!=null?K:5,l=Ne(e.apiKey),u=[],a=new Set,d=new Set,o=[],r=0,i=0,c=!1,f=S=>{for(a.delete(S.id),d.has(S.id)||(d.add(S.id),o.push(S.id));o.length>jt;){let k=o.shift();k&&d.delete(k)}be([S.id],l)},g=S=>{ee([S],n,l),!d.has(S.id)&&!a.has(S.id)&&(a.add(S.id),u.push(S)),Date.now()>=r&&(i++,r=Date.now()+Z(i))},m=S=>{let k;try{k=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(J){g(S);return}let q=J=>{var W;let G=oe(J);if(G==="retry"){g(S);return}G==="dropped"&&((W=e.onDrop)==null||W.call(e,S,J.status)),f(S),i=0,r=0};k instanceof Promise?k.then(q).catch(()=>g(S)):q(k)},v=()=>{try{if(c||Date.now()<r)return;let S=0;for(;u.length>0&&S<s&&!(Date.now()<r);){let k=u.shift();a.delete(k.id),!d.has(k.id)&&(S++,m(k))}}catch(S){}},T=we(l,n);for(let S of T)a.has(S.id)||(a.add(S.id),u.push(S));T.length>0&&ee(T,n,l);let A=setInterval(v,t),D=()=>{document.visibilityState==="hidden"&&v()},_=()=>v();return document.addEventListener("visibilitychange",D),window.addEventListener("pagehide",_),{send(S){if(!c&&!(d.has(S.id)||a.has(S.id))){if(Date.now()<r){ee([S],n,l),a.add(S.id),u.push(S);return}m(S)}},flush:v,destroy(){clearInterval(A),document.removeEventListener("visibilitychange",D),window.removeEventListener("pagehide",_),v(),c=!0}}}var zt=1800*1e3;function Ie(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Xe(e=zt,t){let n=new Map,s=`_snt_asgn${ne(t)}_`,l=(r,i)=>`${s}${encodeURIComponent(r)}:${encodeURIComponent(i)}`,u=r=>{let i=r.slice(s.length),c=i.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,c)),segment:decodeURIComponent(i.slice(c+1))}}catch(f){return null}},a=()=>{try{let r=[];for(let i=0;i<localStorage.length;i++){let c=localStorage.key(i);c!=null&&c.startsWith(s)&&r.push(c)}return r}catch(r){return[]}},d=r=>r.assignedAt+(r.ttlMs&&r.ttlMs>0?r.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let r of a())try{let i=localStorage.getItem(r);if(!i)continue;let c=JSON.parse(i);if(d(c)){localStorage.removeItem(r);continue}let f=u(r);if(!f)continue;n.set(Ie(f.componentId,f.segment),c)}catch(i){}})(),{get(r,i){let c=n.get(Ie(r,i));return c?d(c)?(n.delete(Ie(r,i)),null):c:null},set(r,i,c){let f=Ie(r,i);n.set(f,c);try{localStorage.setItem(l(r,i),JSON.stringify(c))}catch(g){}},invalidate(r){let i=`${encodeURIComponent(r)}:`;for(let c of[...n.keys()])c.startsWith(i)&&n.delete(c);for(let c of a()){let f=u(c);if((f==null?void 0:f.componentId)===r)try{localStorage.removeItem(c)}catch(g){}}},clear(){n.clear();for(let r of a())try{localStorage.removeItem(r)}catch(i){}}}}var Ze=["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 Ee(e){return et(e)!==null}function et(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ze.find(s=>t.includes(s.toLowerCase())))!=null?n:null}function se(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 ie(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(l){}let s=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(s)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(s)?"social":"referral"}catch(n){return"direct"}}function ae(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ce(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Pe(e){let t=Qt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Qt(e,t){var u,a,d,o,r,i,c;let n=(a=(u=t==null?void 0:t.userAgent)==null?void 0:u.trim())!=null?a:"",s=(o=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?o:"",l=(r=t==null?void 0:t.now)!=null?r:new Date;return{sessionId:e,ephemeral:!1,utmParams:(i=t==null?void 0:t.utmParams)!=null?i:{},deviceClass:n?se(n):"desktop",trafficSource:s?ie(s,t==null?void 0:t.appOrigin):"direct",referrerDomain:ae(s),timeOfDay:ce(l),dayOfWeek:(c=["sun","mon","tue","wed","thu","fri","sat"][l.getDay()])!=null?c:"sun",automation:(t==null?void 0:t.webdriver)===!0||Ee(n)}}var de=require("@sentientui/policy");function Me(e){return I(I(I({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function Le(e){let t=Me(e);return(0,de.slotResultFor)(t,(0,de.slotBaselineArm)(t))}function tt(e){return typeof e=="string"?e:(0,de.canonicalArm)(e)}var xe="_snt_snap:",qt=["low","medium","high"];function nt(e){try{let t=localStorage.getItem(xe+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!qt.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function Ce(e,t){try{localStorage.setItem(xe+e,JSON.stringify(t))}catch(n){}}var Ke=require("@sentientui/policy");var Te=require("@sentientui/policy");var rt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Jt="[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.",ot=!1,Ae=!1;function Ht(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function st(e){var d;let t=ve({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(d=t.getSessionId())!=null?d:"local",s=Ht(),l=import("@sentientui/core/local").then(o=>{let r=o;return r.LOCAL_ENGINE_AVAILABLE?(ot||(ot=!0,console.info(Jt)),r):(Ae||(Ae=!0,console.error(rt)),null)}).catch(()=>(Ae||(Ae=!0,console.error(rt)),null)),u=null;function a(o){let r=document.documentElement;r.dataset.sentientPersona===void 0&&(r.dataset.sentientPersona=o.persona,r.dataset.sentientConfidence=(0,Te.confidenceBand)(o.confidence))}return{isLocal:!0,async decide(o){var c,f,g;let r=await l;if(!r)return null;let i=r.createLocalEngine({sessionId:n,forcedPersona:s}).decide(o);return u=X(I({},i),{layoutOrder:(f=(c=i.layoutOrder)!=null?c:u==null?void 0:u.layoutOrder)!=null?f:null,slots:I(I({},(g=u==null?void 0:u.slots)!=null?g:{}),i.slots)}),Ce(e.apiKey||"local",{v:1,persona:u.persona,band:(0,Te.confidenceBand)(u.confidence),slots:u.slots,layoutOrder:u.layoutOrder,savedAt:Date.now()}),a(i),i},getSlotResult(o){var r,i,c;return(c=(i=u==null?void 0:u.slots[o])!=null?i:(r=e.initialSlots)==null?void 0:r[o])!=null?c:null},getPersona(){return u?{persona:u.persona,confidence:u.confidence,band:(0,Te.confidenceBand)(u.confidence)}:null},async assign(o,r){var f;let i=await l;return!i||!r||r.length===0?r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null:{variantId:(f=i.createLocalEngine({sessionId:n,forcedPersona:s}).decide({components:[{id:o,variantIds:r}]}).assignments[o])!=null?f:r[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var it="https://api.sentient-ui.com/v1/events",j=new Map,Yt=null;function Vt(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Xt=3;function Ge(){return he()}function ke(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Zt(){let e=new WeakMap,t=new Map,n=!1,s=(d,o,r)=>{let i=d.get(o);return r===null?i?!0:(d.set(o,new Set),!1):i?i.has(r)?!0:(i.add(r),!1):(d.set(o,new Set([r])),!1)},l=typeof window!="undefined"&&"event"in window,u=()=>{if(!l)return;let d=window.event;return typeof Event=="function"&&d instanceof Event?d:void 0},a=()=>{if(l){Promise.resolve().then(()=>{n=!1,t.clear()});return}let d=!1,o=()=>{d||(d=!0,n=!1,t.clear())};if(setTimeout(o,0),typeof MessageChannel=="function"){let r=new MessageChannel;r.port1.onmessage=()=>{r.port1.close(),r.port2.close(),o()},r.port2.postMessage(0)}};return{firedBefore(d,o){let r=u();if(r){let c=e.get(r);return c||(c=new Map,e.set(r,c)),s(c,d,o)}let i=s(t,d,o);return!i&&!n&&(n=!0,a()),i}}}var at=new Set;function en(e,t,n){let s=typeof window=="undefined"?null:window.history;if(!s)return()=>{};let l=!1,u,a=()=>{if(l)return;let r=ke();!r||r===u||(u=r,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${r}`))},d=[];for(let r of["pushState","replaceState"]){let i=s[r],c=function(...f){let g=i.apply(this,f);return a(),g};s[r]=c,d.push([r,i,c])}window.addEventListener("popstate",a);let o=ke();return o&&at.has(`${t}:${o}`)?u=o:a(),()=>{if(!l){l=!0,window.removeEventListener("popstate",a);for(let[r,i,c]of d)s[r]===c&&(s[r]=i)}}}var me={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function tn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,s]of t)n.startsWith("utm_")&&(e[n]=s);return e}catch(e){return{}}}function ct(e){return e.replace(/\/events\/?$/,"")}function Ue(){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 nn(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=ct((d=e.ingestUrl)!=null?d:it),s={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},l={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(o,r,i){if(!t)return null;try{let c=new URLSearchParams({componentId:o});for(let m of r!=null?r:[])c.append("variantIds[]",m);let f=await fetch(`${n}/winner?${c.toString()}`,{headers:s});return f.ok?{variantId:(await f.json()).variantId,assignmentTtlMs:0}:r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null}catch(c){return r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},u={track:o=>l.track(o),goal:((o,r,i,c)=>l.goal(o,r,i,c)),componentGoal:(o,r,i)=>l.componentGoal(o,r,i),identify:o=>l.identify(o),getAssignment:(o,r)=>l.getAssignment(o,r),assign:(o,r,i,c)=>l.assign(o,r,i,c),decide:o=>l.decide(o),getSlotResult:o=>l.getSlotResult(o),getPersona:()=>l.getPersona(),fetchWeights:()=>l.fetchWeights(),getGraph:()=>l.getGraph(),dispose:()=>l.dispose(),destroy:()=>l.destroy()};function a(o){l=o}return{proxy:u,setInner:a}}function dt(e){var x,z,te,B,le,H,re,Y,Fe;if(typeof window=="undefined")return me;Yt=e.apiKey;let t=j.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(p){}let n=e.respectDoNotTrack!==!1&&Ue(),s=e.consent===!1||n,l=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!l&&e.localMode!==!1)return s?(j.set(e.apiKey||"local",{config:e,upgrade:null}),me):(j.set(e.apiKey||"local",{config:e,upgrade:null}),st(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."),j.set(e.apiKey,{config:e,upgrade:null}),me;let{proxy:p,setInner:y}=nn(e);return j.set(e.apiKey,{config:e,upgrade:n?null:y}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),me;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),me;let u=(x=e.ingestUrl)!=null?x:it,a=Date.now(),d=ve({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),o=Xe(void 0,e.apiKey),r=Ye({ingestUrl:u,apiKey:e.apiKey}),i=ct(u),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},f=new Set,g=Ve({url:`${i}/goals`,apiKey:e.apiKey,headers:c,onDrop:(p,y)=>{if(!e.debug){if(f.has(y))return;f.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),m=se((z=navigator.userAgent)!=null?z:""),v=typeof window!="undefined"?window.location.origin:void 0,T=ie((te=document.referrer)!=null?te:"",v),A=(B=e.sessionSegment)!=null?B:`${m}:${T}`,D=new Map,_=new Map,b=null,N=p=>{for(let y of p)_.has(y.id)||_.set(y.id,Le(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))_.set(p,y);let K=nt(e.apiKey);if(K)for(let[p,y]of Object.entries(K.slots))_.has(p)||_.set(p,y);let S={low:.15,medium:.5,high:.85};if(e.initialPersona)b=I({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?b={persona:p.sentientPersona,confidence:(H=S[(le=p.sentientConfidence)!=null?le:"low"])!=null?H:.15}:K&&(b={persona:K.persona,confidence:(re=S[K.band])!=null?re:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))o.set(p,A,{variantId:y,assignedAt:Date.now(),segment:A,confidence:1});let k=Promise.resolve(),q=d.getSessionId();if(q){let p=ae((Y=document.referrer)!=null?Y:""),y=I(I(I({sessionId:q,deviceClass:m,trafficSource:T,referrerDomain:p,utmParams:tn(),timeOfDay:ce(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ee((Fe=navigator.userAgent)!=null?Fe:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),w=async()=>{for(let O=0;;O++){try{let R=await fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:c});if(R.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(R.ok||oe(R)==="dropped")return}catch(R){}if(O>=Xt){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(R=>setTimeout(R,Z(O+1)))}};try{k=w()}catch(O){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:r});let J=Zt(),G=null,W=!1,h={goal(p,y={},w=1,O=0){var ue,$,pe,C,V,ye,M;let R=d.getSessionId();if(!R)return;let E=Vt(y)?y:{metadata:y},Q=[p,(ue=E.externalId)!=null?ue:"",($=E.stepIndex)!=null?$:O,(pe=E.weight)!=null?pe:w].join("\0"),F=E.value!==void 0?`${E.value}\0${(C=E.currency)!=null?C:""}`:null;if(J.firedBefore(Q,F)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let P=Ge(),U={sessionId:R,name:p,metadata:(V=E.metadata)!=null?V:{},weight:(ye=E.weight)!=null?ye:w,stepIndex:(M=E.stepIndex)!=null?M:O,goalId:P,value:E.value,currency:E.currency,externalId:E.externalId};e.debug&&console.log("[sentient] goal",U);let L={id:P,body:JSON.stringify(U)};k.then(()=>g.send(L))},componentGoal(p,y,w){var P,U,L;let O=d.getSessionId();if(!O)return;let R=o.get(p,A),E=R?null:(P=_.get(p))!=null?P:null;if(!R&&E===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let Q=R?R.variantId:tt(E),F={id:Ge(),sessionId:O,projectId:e.apiKey,componentId:p,variantId:Q,eventType:"goal_achieved",goalType:y,payload:I({reward:(U=w==null?void 0:w.reward)!=null?U:1,goalValue:w==null?void 0:w.value,currency:w==null?void 0:w.currency},(L=w==null?void 0:w.metadata)!=null?L:{}),timestamp:Date.now(),timeInSession:Date.now()-a,path:ke()};e.debug&&console.log("[sentient] componentGoal",F),k.then(()=>r.push(F))},identify(p){let y=d.getSessionId();y&&k.then(()=>{fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:d.isEphemeral()}),headers:c}).catch(()=>{})})},track(p){let y=d.getSessionId();if(!y)return;let w=X(I({path:ke()},p),{id:Ge(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-a});e.debug&&console.log("[sentient] track",w),k.then(()=>r.push(w))},getAssignment(p,y){return o.get(p,y)},async assign(p,y,w,O){let R=d.getSessionId();if(!R)return null;let E=o.get(p,A);if(E&&(y!=null&&y.length||E.content!==void 0)){let P=E.ttlMs&&E.ttlMs>0?Math.max(0,E.assignedAt+E.ttlMs-Date.now()):0;return{variantId:E.variantId,assignmentTtlMs:P,content:E.content}}let Q=D.get(p);if(Q)return Q;let F=(async()=>{await k;try{let P={sessionId:R,componentId:p,variantIds:y};O!==void 0?P.agentDataByVariant=O:w!==void 0&&(P.agentData=w);let U=await fetch(`${i}/assign`,{method:"POST",body:JSON.stringify(P),headers:c});if(!U.ok)return null;let L=await U.json();return o.set(p,A,I({variantId:L.variantId,assignedAt:Date.now(),segment:A,confidence:1,content:L.content},L.assignmentTtlMs&&L.assignmentTtlMs>0?{ttlMs:L.assignmentTtlMs}:{})),L}catch(P){return null}finally{D.delete(p)}})();return D.set(p,F),F},async decide(p){var O,R,E,Q,F,P,U,L,ue;let y=d.getSessionId();if(!y)return null;let w=(O=p.slots)!=null?O:[];await k;try{let $={sessionId:y};p.sections&&p.sections.length>0&&($.sections=p.sections.map(M=>({id:M}))),$.components=(R=p.components)!=null?R:[],w.length>0&&($.slots=w.map(Me)),p.slotsFrom==="registry"&&($.slotsFrom="registry"),p.v&&($.v=p.v),e.persona&&($.persona=e.persona);let pe=await fetch(`${i}/decide`,{method:"POST",body:JSON.stringify($),headers:c});if(!pe.ok)return N(w),null;let C=await pe.json(),V={};for(let M of w)V[M.id]=(Q=(E=C.slots)==null?void 0:E[M.id])!=null?Q:Le(M);if(C.slots)for(let[M,ge]of Object.entries(C.slots))M in V||(V[M]=ge);for(let[M,ge]of Object.entries(V))_.set(M,ge);let ye=b!=null&&b.persona!=="unknown";C.persona&&!(C.persona==="unknown"&&ye)?b={persona:C.persona,confidence:(F=C.confidence)!=null?F:0}:b||(b={persona:"unknown",confidence:0});for(let[M,ge]of Object.entries((P=C.assignments)!=null?P:{}))o.set(M,A,{variantId:ge,assignedAt:Date.now(),segment:A,confidence:1});return Ce(e.apiKey,I(I({v:1,persona:b.persona,band:(0,Ke.confidenceBand)(b.confidence),slots:Object.fromEntries(_),layoutOrder:(U=C.layoutOrder)!=null?U:null,savedAt:Date.now()},C.slotConfig?{slotConfig:C.slotConfig}:{}),C.palette?{palette:C.palette}:{})),I(I(I(I({layoutOrder:(L=C.layoutOrder)!=null?L:null,assignments:(ue=C.assignments)!=null?ue:{},slots:V,persona:b.persona,confidence:b.confidence},C.slotConfig?{slotConfig:C.slotConfig}:{}),C.goals?{goals:C.goals}:{}),C.sectionMap?{sectionMap:C.sectionMap}:{}),C.palette?{palette:C.palette}:{})}catch($){return N(w),null}},getSlotResult(p){var y;return(y=_.get(p))!=null?y:null},getPersona(){return b?{persona:b.persona,confidence:b.confidence,band:(0,Ke.confidenceBand)(b.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${i}/weights`,{headers:c});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;G==null||G(),W=!0,r.destroy(),g.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===h.dispose&&j.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;G==null||G(),W=!0,r.destroy(),g.destroy(),d.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===h.dispose&&j.delete(e.apiKey);try{localStorage.removeItem(xe+e.apiKey),localStorage.removeItem(De(e.apiKey)),localStorage.removeItem(Ne(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(j.set(e.apiKey,{config:e,upgrade:null,dispose:h.dispose}),G=en(h,e.apiKey,p=>{k.then(()=>{W||at.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=h)}return h}var lt="_snt_graph_edges",rn={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function on(e){var t;return(t=rn[e])!=null?t:[]}function sn(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function an(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var cn=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function dn(e){return cn.has(e)?e:"generic"}function $e(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function ln(e,t,n){let s=`${e}:${t}:${n.join(",")}`,l=5381;for(let u=0;u<s.length;u++)l=(l<<5)+l+s.charCodeAt(u)&4294967295;return(l>>>0).toString(16).padStart(8,"0")}function ut(e){let t=new Map,n=new Map,s=`_snt_graph_nodes${ne(e==null?void 0:e.apiKey)}`,l=()=>{typeof window!="undefined"&&an(s,[...t.values()])},u=a=>{var d;try{let o=JSON.parse(a);t.clear();for(let r of(d=o.pageNodes)!=null?d:[])t.set(r.componentId,r)}catch(o){}};if(typeof window!="undefined"){let a=sn(s,[]);for(let d of a)t.set(d.componentId,d);try{localStorage.removeItem(lt)}catch(d){}}return{addPageNode(a){t.set(a.componentId,a),l()},addStructuralEdge(a){let d=`${a.fromComponentId}->${a.toComponentId}`;n.set(d,a)},syncOnce(){var d,o;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let a=[...t.values()];if(a.length!==0)try{let r=new Map;for(let m of a){let v=(d=r.get(m.semanticType))!=null?d:[];v.push(m),r.set(m.semanticType,v)}let i=[],c=new Set;for(let m of a)for(let v of on(m.semanticType)){let T=(o=r.get(v))!=null?o:[];for(let A of T){if(A.componentId===m.componentId)continue;let D=`semantic:${m.componentId}->${A.componentId}`;c.has(D)||(c.add(D),i.push({fromComponentId:m.componentId,toComponentId:A.componentId,type:"semantic",weight:.4,confidence:.9}))}}let f=new Set(a.map(m=>m.componentId));for(let m of n.values()){if(!f.has(m.fromComponentId)||!f.has(m.toComponentId))continue;let v=`structural:${m.fromComponentId}->${m.toComponentId}`;c.has(v)||(c.add(v),i.push({fromComponentId:m.fromComponentId,toComponentId:m.toComponentId,type:"structural",weight:m.weight,confidence:1}))}let g=X(I(I({pageUrl:$e(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:a.map(m=>{let v=dn(m.semanticType);return{componentId:m.componentId,semanticType:v,answers:m.answers,contentHash:ln(m.componentId,v,m.answers),prominenceScore:m.prominenceScore,depthInPage:m.depth}}),edges:i});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:I({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(g)}).catch(()=>{})}catch(r){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:u,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(s),localStorage.removeItem(lt)}catch(a){}}}}var pt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],un=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],pn=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function gn(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function fn(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,s]of un)if(s.test(t))return{type:n,strength:"strong"};for(let[n,s]of pn)if(s.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function mn(e){var n,s;let t=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((s=e.className)!=null?s:"")}`,headingText:gn(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function gt(e){return fn(mn(e)).type}var yn=new Set(["SECTION","ARTICLE","MAIN","DIV"]),hn="h1, h2, h3",ft=30,Sn=1500,vn={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function mt(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function wn(e){var t,n,s;try{let l=e;for(let u of Object.keys(l)){if(!u.startsWith("__reactFiber")&&!u.startsWith("__reactInternalInstance"))continue;let a=l[u],d=(s=(t=a==null?void 0:a.type)==null?void 0:t.displayName)!=null?s:(n=a==null?void 0:a.type)==null?void 0:n.name;if(d&&d.length>1)return d}}catch(l){}}function bn(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var yt=new Set(pt);function In(e){let t=e.getAttribute("data-sentient-type");if(t&&yt.has(t))return t;let n=e.getAttribute("role");return n&&yt.has(n)?n:gt(e)}function En(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)&4294967295;return(t>>>0).toString(16).padStart(8,"0")}function xn(e){let t=[],n=e;for(;n;){let s=n.parentElement;if(!s){t.push(n.tagName.toLowerCase());break}let l=Array.prototype.indexOf.call(s.children,n);t.push(`${n.tagName.toLowerCase()}[${l}]`),n=s}return t.reverse().join("/")}function Cn(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${En(xn(e))}`}function An(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Be(e,t){var s,l,u;let n=e.querySelector(hn);return{componentId:Cn(e),semanticType:In(e),ariaLabel:(s=e.getAttribute("aria-label"))!=null?s:void 0,headingText:(u=(l=n==null?void 0:n.textContent)==null?void 0:l.trim())!=null?u:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:An(e),reactComponentName:wn(e),dataAttributes:bn(e)}}function ht(e){var u;let t=[],n=new Set,s="__root__",l=new Map;for(let[a,d]of e){let o=a.parentElement,r=s;for(;o;){if(e.has(o)){r=e.get(o);let c=e.get(a),f=`${r}->${c}`;!n.has(f)&&r!==c&&(n.add(f),t.push({fromComponentId:r,toComponentId:c,weight:.6}));break}o=o.parentElement}let i=(u=l.get(r))!=null?u:[];i.push(a),l.set(r,i)}for(let a of l.values()){if(a.length<2)continue;let d=a.length>ft?a.slice(0,ft):a;for(let o=0;o<d.length;o++)for(let r=o+1;r<d.length;r++){if(t.length>=Sn)return t;let i=e.get(d[o]),c=e.get(d[r]);if(i===c)continue;let f=`${i}->${c}::sib`,g=`${c}->${i}::sib`;n.has(f)||(n.add(f),t.push({fromComponentId:i,toComponentId:c,weight:.3})),n.has(g)||(n.add(g),t.push({fromComponentId:c,toComponentId:i,weight:.3}))}}return t}function Tn(e){let t=[],n=new Set,s=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(a=>{if(a instanceof Element&&!n.has(a)){n.add(a);let d=Be(a,e);t.push(d),s.set(a,d.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(a=>{if(!(a instanceof Element)||n.has(a))return;let d=a.hasAttribute("aria-label"),o=a.hasAttribute("data-sentient-id");if(!d&&!o)return;n.add(a);let r=Be(a,e);t.push(r),s.set(a,r.componentId)}),{nodes:t,edges:ht(s),elementToId:s}}function St(){if(typeof window=="undefined")return vn;let e=null,t=0,n=null,s=new Map,l=o=>{try{let r=window.getComputedStyle(o),i=parseFloat(r.fontSize)||12,c=parseFloat(r.zIndex)||0,f=o.getBoundingClientRect(),g=Math.max(f.top,0),m=window.innerHeight||1,v=1/(g/m+1),T=mt(i,12,48)*.4+v*.4+mt(c,0,100)*.2;return Math.max(0,Math.min(1,T))}catch(r){return .5}};return{scan:()=>new Promise(o=>{let r=()=>{let{nodes:i,edges:c,elementToId:f}=Tn(l);s.clear();for(let[g,m]of f)s.set(g,m);o({nodes:i,edges:c,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(r,{timeout:100}):r()}catch(i){r()}}),observe:o=>{n=o;try{e=new MutationObserver(r=>{let i=[],c=new Set;for(let g of r)g.type==="childList"&&g.addedNodes.forEach(m=>{if(!(m instanceof Element)||!yn.has(m.tagName))return;let v=m.hasAttribute("data-sentient-id"),T=m.hasAttribute("aria-label");if(!v&&!T)return;let A=Be(m,l);i.push(A),c.add(A.componentId),s.set(m,A.componentId)});if(i.length===0||!n)return;for(let g of[...s.keys()])g.isConnected||s.delete(g);let f=ht(s).filter(g=>c.has(g.fromComponentId)||c.has(g.toComponentId));n({nodes:i,edges:f,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(r){}},getProminenceScore:l,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(o){}t=0,n=null,s.clear()}}}var kn="https://api.sentient-ui.com/v1/events";function Rn(e){var n;let t=s=>{try{let l=document.cookie.match(new RegExp(`(?:^|; )${s}=([^;]*)`));return l?decodeURIComponent(l[1]):void 0}catch(l){return}};return(n=e?t(Se(e)):void 0)!=null?n:t(_e)}var Re=new Map;function _n(e){var c;let t=dt(e),n=e.respectDoNotTrack!==!1&&Ue(),s=e.consent===!1||n;if(!e.graph||!e.apiKey||s||typeof window=="undefined")return t;let l=Re.get(e.apiKey);if(l)try{l()}catch(f){}let u=St(),a=(c=e.ingestUrl)!=null?c:kn,d=ut({syncUrl:a.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:Rn(e.apiKey)});u.scan().then(f=>{for(let g of f.nodes)d.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:e.captureDomText&&g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of f.edges)d.addStructuralEdge(g);d.syncOnce()});let o=null,r=()=>{o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,d.syncOnce()},500)};u.observe(f=>{for(let g of f.nodes)d.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:e.captureDomText&&g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of f.edges)d.addStructuralEdge(g);r()});let i=()=>{o!==null&&(clearTimeout(o),o=null),u.destroy(),d.destroy(),Re.get(e.apiKey)===i&&Re.delete(e.apiKey)};return Re.set(e.apiKey,i),X(I({},t),{getGraph:()=>d.snapshot(),dispose:()=>{i(),t.dispose()},destroy:()=>{i(),t.destroy()}})}0&&(module.exports={deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,init,referrerDomainFromReferer,sanitizePageUrl});
2
2
  //# sourceMappingURL=index-graph.js.map