@sentientui/core 0.20.1 → 0.21.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/chunk-K6W474ZY.mjs +2 -0
- package/dist/chunk-K6W474ZY.mjs.map +1 -0
- package/dist/{index-DqALhS-k.d.cts → index-BheP9F8h.d.cts} +140 -1
- package/dist/{index-og9t6fz3.d.ts → index-BvHshOSe.d.ts} +140 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-graph.d.cts +2 -2
- package/dist/index-graph.d.ts +2 -2
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-local.d.cts +1 -1
- package/dist/index-local.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-WKU4J5I2.mjs +0 -2
- package/dist/chunk-WKU4J5I2.mjs.map +0 -1
package/dist/index-graph.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var pt=Object.create;var ge=Object.defineProperty,gt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertyNames,Ke=Object.getOwnPropertySymbols,ht=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Ue=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))$e.call(t,n)&&Ue(e,n,t[n]);if(Ke)for(var n of Ke(t))St.call(t,n)&&Ue(e,n,t[n]);return e},Y=(e,t)=>gt(e,mt(t));var vt=(e,t)=>{for(var n in t)ge(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of yt(t))!$e.call(e,u)&&u!==n&&ge(e,u,{get:()=>t[u],enumerable:!(o=ft(t,u))||o.enumerable});return e};var wt=(e,t,n)=>(n=e!=null?pt(ht(e)):{},Be(t||!e||!e.__esModule?ge(n,"default",{value:e,enumerable:!0}):n,e)),bt=e=>Be(ge({},"__esModule",{value:!0}),e);var Tn={};vt(Tn,{deriveSessionSegment:()=>_e,detectDeviceClass:()=>oe,detectTimeOfDay:()=>ae,detectTrafficSource:()=>se,init:()=>An,referrerDomainFromReferer:()=>ie,sanitizePageUrl:()=>Le});module.exports=bt(Tn);function me(){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 te(e){return e?`_${e.slice(0,12)}`:""}var It="_snt_uid",xt=365,Et="_snt_uid";function Ct(){return me()}function At(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Tt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(o){}}function kt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Rt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function _t(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Dt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Ot(e){try{sessionStorage.removeItem(e)}catch(t){}}function Pt(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 Nt(e){try{localStorage.removeItem(e)}catch(t){}}function Mt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Lt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ye(e){var f,g,m,v,b,R;if(typeof window=="undefined")return Lt;let t=te(e==null?void 0:e.apiKey),n=(f=e==null?void 0:e.cookieName)!=null?f:`${It}${t}`,o=`${Et}${t}`,l=((g=e==null?void 0:e.cookieTTLDays)!=null?g:xt)*24*60*60,i=A=>A&&A.length>0?A:null,d=(R=(b=(v=(m=i(At(n)))!=null?m:i(kt(o)))!=null?v:i(_t(o)))!=null?b:i(e==null?void 0:e.ssrSessionId))!=null?R:Ct();Tt(n,d,l);let s=Rt(o,d),r=Pt(n),a=s?!1:Dt(o,d),c=!s&&!r&&!a;return{getSessionId:()=>d,isEphemeral:()=>c,destroy:()=>{d=null,Mt(n),Nt(o),Ot(o)}}}function ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function he(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 o=JSON.parse(n);return Array.isArray(o)?(localStorage.removeItem(e),o.slice(-t)):[]}catch(n){return[]}}function re(e,t,n){try{let o=(()=>{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 o)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(o){}}function ve(e,t){try{let n=localStorage.getItem(t);if(!n)return;let o=JSON.parse(n);if(!Array.isArray(o))return;let u=new Set(e),l=o.filter(i=>!u.has(i.id));if(l.length===o.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var Gt=500,Kt=56*1024;function ke(e){return`_snt_retry_${e.slice(0,12)}`}var Ut={push:()=>{},flush:()=>{},destroy:()=>{}};function Fe(e){var P,W,z;if(typeof window=="undefined")return Ut;let t=(P=e.flushIntervalMs)!=null?P:5e3,n=(W=e.maxBatchSize)!=null?W:20,o=(z=e.maxRetrySize)!=null?z:100,u=e.ingestUrl,l=e.apiKey,i=ke(l),d=[],s=new Set,r=[],a=h=>{for(let I of h)c.delete(I),!s.has(I)&&(s.add(I),r.push(I));for(;r.length>Gt;){let I=r.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,o);for(let h of m)f(h);let v=0,b=0,R=(h,I=!0)=>{if(h.length===0)return;let Q=JSON.stringify(h),Z=h.map(J=>J.id),$;try{$=fetch(u,{method:"POST",keepalive:!0,body:Q,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(J){re(h,o,i),g(h),b++,v=Date.now()+ne(b);return}let de=J=>{if(he(J)!=="retry"){if(!J.ok&&I){let ee=h.filter(H=>H.eventType!=="pageview");if(ee.length>0&&ee.length<h.length){a(h.filter(H=>H.eventType==="pageview").map(H=>H.id)),R(ee,!1);return}}a(Z),b=0,v=0;return}re(h,o,i),g(h),b++,v=Date.now()+ne(b)};$ instanceof Promise?$.then(de).catch(()=>{re(h,o,i),g(h),b++,v=Date.now()+ne(b)}):de($)},A=typeof TextEncoder!="undefined"?new TextEncoder:null,k=h=>A?A.encode(h).length:h.length,X=h=>{let I=[],Q=2;for(let Z of h){let $=k(JSON.stringify(Z))+1;if(I.length>0&&Q+$>Kt||I.length>=n)break;I.push(Z),Q+=$}return I},_=()=>{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=X(h);if(I.length===0)break;I.length<h.length&&d.push(...h.slice(I.length)),R(I)}}catch(h){}},S=!0,E=null;E=setInterval(()=>{S&&_()},t);let q=()=>{document.visibilityState==="hidden"&&_()},L=()=>{_()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",L),{push(h){f(h),d.length>=n&&_()},flush:_,destroy(){S=!1,E!==null&&(clearInterval(E),E=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",L),_()}}}var $t=200;function Re(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Bt={send:()=>{},flush:()=>{},destroy:()=>{}};function je(e){var k,X,_;if(typeof window=="undefined")return Bt;let t=(k=e.flushIntervalMs)!=null?k:5e3,n=(X=e.maxRetrySize)!=null?X:100,o=(_=e.maxPerFlush)!=null?_:5,u=Re(e.apiKey),l=[],i=new Set,d=new Set,s=[],r=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>$t;){let E=s.shift();E&&d.delete(E)}ve([S.id],u)},g=S=>{re([S],n,u),!d.has(S.id)&&!i.has(S.id)&&(i.add(S.id),l.push(S)),a++,r=Date.now()+ne(a)},m=S=>{let E;try{E=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(L){g(S);return}let q=L=>{var W;let P=he(L);if(P==="retry"){g(S);return}P==="dropped"&&((W=e.onDrop)==null||W.call(e,S,L.status)),f(S),a=0,r=0};E instanceof Promise?E.then(q).catch(()=>g(S)):q(E)},v=()=>{try{if(c||Date.now()<r)return;let S=0;for(;l.length>0&&S<o&&!(Date.now()<r);){let E=l.shift();i.delete(E.id),!d.has(E.id)&&(S++,m(E))}}catch(S){}};for(let S of Se(u,n))i.has(S.id)||(i.add(S.id),l.push(S));let b=setInterval(v,t),R=()=>{document.visibilityState==="hidden"&&v()},A=()=>v();return document.addEventListener("visibilitychange",R),window.addEventListener("pagehide",A),{send(S){if(!c&&!(d.has(S.id)||i.has(S.id))){if(Date.now()<r){i.add(S.id),l.push(S);return}m(S)}},flush:v,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",R),window.removeEventListener("pagehide",A),v(),c=!0}}}var Ft=1800*1e3;function we(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function We(e=Ft,t){let n=new Map,o=`_snt_asgn${te(t)}_`,u=(r,a)=>`${o}${encodeURIComponent(r)}:${encodeURIComponent(a)}`,l=r=>{let a=r.slice(o.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 r=[];for(let a=0;a<localStorage.length;a++){let c=localStorage.key(a);c!=null&&c.startsWith(o)&&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 i())try{let a=localStorage.getItem(r);if(!a)continue;let c=JSON.parse(a);if(d(c)){localStorage.removeItem(r);continue}let f=l(r);if(!f)continue;n.set(we(f.componentId,f.segment),c)}catch(a){}})(),{get(r,a){let c=n.get(we(r,a));return c?d(c)?(n.delete(we(r,a)),null):c:null},set(r,a,c){let f=we(r,a);n.set(f,c);try{localStorage.setItem(u(r,a),JSON.stringify(c))}catch(g){}},invalidate(r){let a=`${encodeURIComponent(r)}:`;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)===r)try{localStorage.removeItem(c)}catch(g){}}},clear(){n.clear();for(let r of i())try{localStorage.removeItem(r)}catch(a){}}}}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 be(e){return Qe(e)!==null}function Qe(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ze.find(o=>t.includes(o.toLowerCase())))!=null?n:null}function oe(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 se(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 o=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(o)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(o)?"social":"referral"}catch(n){return"direct"}}function ie(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ae(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function _e(e){let t=jt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function jt(e,t){var l,i,d,s,r,a,c;let n=(i=(l=t==null?void 0:t.userAgent)==null?void 0:l.trim())!=null?i:"",o=(s=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?s:"",u=(r=t==null?void 0:t.now)!=null?r:new Date;return{sessionId:e,ephemeral:!1,utmParams:(a=t==null?void 0:t.utmParams)!=null?a:{},deviceClass:n?oe(n):"desktop",trafficSource:o?se(o,t==null?void 0:t.appOrigin):"direct",referrerDomain:ie(o),timeOfDay:ae(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 ce=require("@sentientui/policy");function De(e){return x(x(x({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,ce.slotResultFor)(t,(0,ce.slotBaselineArm)(t))}function qe(e){return typeof e=="string"?e:(0,ce.canonicalArm)(e)}var Ie="_snt_snap:",Wt=["low","medium","high"];function Je(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"||!Wt.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 He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",zt="[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.",Ve=!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 Ye(e){var d;let t=ye({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(d=t.getSessionId())!=null?d:"local",o=Qt(),u=import("@sentientui/core/local").then(s=>{let r=s;return r.LOCAL_ENGINE_AVAILABLE?(Ve||(Ve=!0,console.info(zt)),r):(Ee||(Ee=!0,console.error(He)),null)}).catch(()=>(Ee||(Ee=!0,console.error(He)),null)),l=null;function i(s){let r=document.documentElement;r.dataset.sentientPersona===void 0&&(r.dataset.sentientPersona=s.persona,r.dataset.sentientConfidence=(0,Ce.confidenceBand)(s.confidence))}return{isLocal:!0,async decide(s){var c,f,g;let r=await u;if(!r)return null;let a=r.createLocalEngine({sessionId:n,forcedPersona:o}).decide(s);return l=Y(x({},a),{layoutOrder:(f=(c=a.layoutOrder)!=null?c:l==null?void 0:l.layoutOrder)!=null?f:null,slots:x(x({},(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 r,a,c;return(c=(a=l==null?void 0:l.slots[s])!=null?a:(r=e.initialSlots)==null?void 0:r[s])!=null?c:null},getPersona(){return l?{persona:l.persona,confidence:l.confidence,band:(0,Ce.confidenceBand)(l.confidence)}:null},async assign(s,r){var f;let a=await u;return!a||!r||r.length===0?r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null:{variantId:(f=a.createLocalEngine({sessionId:n,forcedPersona:o}).decide({components:[{id:s,variantIds:r}]}).assignments[s])!=null?f:r[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Xe="https://api.sentient-ui.com/v1/events",j=new Map,qt=null;function Jt(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Pe(){return me()}function Ae(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Ht(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 Ze=new Set;function Vt(e,t,n){let o=typeof window=="undefined"?null:window.history;if(!o)return()=>{};let u=!1,l,i=()=>{if(u)return;let r=Ae();!r||r===l||(l=r,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${r}`))},d=[];for(let r of["pushState","replaceState"]){let a=o[r],c=function(...f){let g=a.apply(this,f);return i(),g};o[r]=c,d.push([r,a,c])}window.addEventListener("popstate",i);let s=Ae();return s&&Ze.has(`${t}:${s}`)?l=s:i(),()=>{if(!u){u=!0,window.removeEventListener("popstate",i);for(let[r,a,c]of d)o[r]===c&&(o[r]=a)}}}var fe={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 Yt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,o]of t)n.startsWith("utm_")&&(e[n]=o);return e}catch(e){return{}}}function et(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 Xt(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=et((d=e.ingestUrl)!=null?d:Xe),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(s,r,a){if(!t)return null;try{let c=new URLSearchParams({componentId:s});for(let m of r!=null?r:[])c.append("variantIds[]",m);let f=await fetch(`${n}/winner?${c.toString()}`,{headers:o});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:()=>{}},l={track:s=>u.track(s),goal:((s,r,a,c)=>u.goal(s,r,a,c)),componentGoal:(s,r,a)=>u.componentGoal(s,r,a),identify:s=>u.identify(s),getAssignment:(s,r)=>u.getAssignment(s,r),assign:(s,r,a,c)=>u.assign(s,r,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 tt(e){var h,I,Q,Z,$,de,J,ee,H;if(typeof window=="undefined")return fe;qt=e.apiKey;let t=j.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(p){}let n=e.respectDoNotTrack!==!1&&Me(),o=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return o?(j.set(e.apiKey||"local",{config:e,upgrade:null}),fe):(j.set(e.apiKey||"local",{config:e,upgrade:null}),Ye(e));if(o){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}),fe;let{proxy:p,setInner:y}=Xt(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."),fe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),fe;let l=(h=e.ingestUrl)!=null?h:Xe,i=Date.now(),d=ye({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),s=We(void 0,e.apiKey),r=Fe({ingestUrl:l,apiKey:e.apiKey}),a=et(l),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},f=je({url:`${a}/goals`,apiKey:e.apiKey,headers:c,onDrop:(p,y)=>{e.debug&&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)}}),g=oe((I=navigator.userAgent)!=null?I:""),m=typeof window!="undefined"?window.location.origin:void 0,v=se((Q=document.referrer)!=null?Q:"",m),b=(Z=e.sessionSegment)!=null?Z:`${g}:${v}`,R=new Map,A=new Map,k=null,X=p=>{for(let y of p)A.has(y.id)||A.set(y.id,Oe(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))A.set(p,y);let _=Je(e.apiKey);if(_)for(let[p,y]of Object.entries(_.slots))A.has(p)||A.set(p,y);let S={low:.15,medium:.5,high:.85};if(e.initialPersona)k=x({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?k={persona:p.sentientPersona,confidence:(de=S[($=p.sentientConfidence)!=null?$:"low"])!=null?de:.15}:_&&(k={persona:_.persona,confidence:(J=S[_.band])!=null?J:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))s.set(p,b,{variantId:y,assignedAt:Date.now(),segment:b,confidence:1});let E=Promise.resolve(),q=d.getSessionId();if(q){let p=ie((ee=document.referrer)!=null?ee:""),y=x(x(x({sessionId:q,deviceClass:g,trafficSource:v,referrerDomain:p,utmParams:Yt(),timeOfDay:ae(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||be((H=navigator.userAgent)!=null?H:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{});try{E=fetch(`${a}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:c}).then(w=>{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")}).catch(()=>{})}catch(w){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:r});let L=new Set,P=null,W=!1,z={goal(p,y={},w=1,G=0){var O,le,U,ue,T,V;let N=d.getSessionId();if(!N)return;let C=Jt(y)?y:{metadata:y},B=`${p}\0${(O=C.externalId)!=null?O:""}\0${(le=C.stepIndex)!=null?le:G}\0${(U=C.weight)!=null?U:w}`;if(L.has(B)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}L.add(B),L.size===1&&Ht(L);let K=Pe(),D={sessionId:N,name:p,metadata:(ue=C.metadata)!=null?ue:{},weight:(T=C.weight)!=null?T:w,stepIndex:(V=C.stepIndex)!=null?V:G,goalId:K,value:C.value,currency:C.currency,externalId:C.externalId};e.debug&&console.log("[sentient] goal",D);let F={id:K,body:JSON.stringify(D)};E.then(()=>f.send(F))},componentGoal(p,y,w){var D,F,O;let G=d.getSessionId();if(!G)return;let N=s.get(p,b),C=N?null:(D=A.get(p))!=null?D:null;if(!N&&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 B=N?N.variantId:qe(C),K={id:Pe(),sessionId:G,projectId:e.apiKey,componentId:p,variantId:B,eventType:"goal_achieved",goalType:y,payload:x({reward:(F=w==null?void 0:w.reward)!=null?F:1,goalValue:w==null?void 0:w.value,currency:w==null?void 0:w.currency},(O=w==null?void 0:w.metadata)!=null?O:{}),timestamp:Date.now(),timeInSession:Date.now()-i,path:Ae()};e.debug&&console.log("[sentient] componentGoal",K),E.then(()=>r.push(K))},identify(p){let y=d.getSessionId();y&&E.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=Y(x({path:Ae()},p),{id:Pe(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-i});e.debug&&console.log("[sentient] track",w),E.then(()=>r.push(w))},getAssignment(p,y){return s.get(p,y)},async assign(p,y,w,G){let N=d.getSessionId();if(!N)return null;let C=s.get(p,b);if(C&&(y!=null&&y.length||C.content!==void 0)){let D=C.ttlMs&&C.ttlMs>0?Math.max(0,C.assignedAt+C.ttlMs-Date.now()):0;return{variantId:C.variantId,assignmentTtlMs:D,content:C.content}}let B=R.get(p);if(B)return B;let K=(async()=>{await E;try{let D={sessionId:N,componentId:p,variantIds:y};G!==void 0?D.agentDataByVariant=G:w!==void 0&&(D.agentData=w);let F=await fetch(`${a}/assign`,{method:"POST",body:JSON.stringify(D),headers:c});if(!F.ok)return null;let O=await F.json();return s.set(p,b,x({variantId:O.variantId,assignedAt:Date.now(),segment:b,confidence:1,content:O.content},O.assignmentTtlMs&&O.assignmentTtlMs>0?{ttlMs:O.assignmentTtlMs}:{})),O}catch(D){return null}finally{R.delete(p)}})();return R.set(p,K),K},async decide(p){var G,N,C,B,K,D,F,O,le;let y=d.getSessionId();if(!y)return null;let w=(G=p.slots)!=null?G:[];await E;try{let U={sessionId:y};p.sections&&p.sections.length>0&&(U.sections=p.sections.map(M=>({id:M}))),U.components=(N=p.components)!=null?N:[],w.length>0&&(U.slots=w.map(De)),p.slotsFrom==="registry"&&(U.slotsFrom="registry"),p.v&&(U.v=p.v),e.persona&&(U.persona=e.persona);let ue=await fetch(`${a}/decide`,{method:"POST",body:JSON.stringify(U),headers:c});if(!ue.ok)return X(w),null;let T=await ue.json(),V={};for(let M of w)V[M.id]=(B=(C=T.slots)==null?void 0:C[M.id])!=null?B:Oe(M);if(T.slots)for(let[M,pe]of Object.entries(T.slots))M in V||(V[M]=pe);for(let[M,pe]of Object.entries(V))A.set(M,pe);let ut=k!=null&&k.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&ut)?k={persona:T.persona,confidence:(K=T.confidence)!=null?K:0}:k||(k={persona:"unknown",confidence:0});for(let[M,pe]of Object.entries((D=T.assignments)!=null?D:{}))s.set(M,b,{variantId:pe,assignedAt:Date.now(),segment:b,confidence:1});return xe(e.apiKey,x({v:1,persona:k.persona,band:(0,Ne.confidenceBand)(k.confidence),slots:Object.fromEntries(A),layoutOrder:(F=T.layoutOrder)!=null?F:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{})),x(x(x({layoutOrder:(O=T.layoutOrder)!=null?O:null,assignments:(le=T.assignments)!=null?le:{},slots:V,persona:k.persona,confidence:k.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{})}catch(U){return X(w),null}},getSlotResult(p){var y;return(y=A.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;P==null||P(),W=!0,r.destroy(),f.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===z.dispose&&j.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;P==null||P(),W=!0,r.destroy(),f.destroy(),d.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===z.dispose&&j.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(j.set(e.apiKey,{config:e,upgrade:null,dispose:z.dispose}),P=Vt(z,e.apiKey,p=>{E.then(()=>{W||Ze.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=z)}return z}var nt="_snt_graph_edges",Zt={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function en(e){var t;return(t=Zt[e])!=null?t:[]}function tn(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function nn(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var rn=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function on(e){return rn.has(e)?e:"generic"}function Le(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function sn(e,t,n){let o=`${e}:${t}:${n.join(",")}`,u=5381;for(let l=0;l<o.length;l++)u=(u<<5)+u+o.charCodeAt(l)&4294967295;return(u>>>0).toString(16).padStart(8,"0")}function rt(e){let t=new Map,n=new Map,o=`_snt_graph_nodes${te(e==null?void 0:e.apiKey)}`,u=()=>{typeof window!="undefined"&&nn(o,[...t.values()])},l=i=>{var d;try{let s=JSON.parse(i);t.clear();for(let r of(d=s.pageNodes)!=null?d:[])t.set(r.componentId,r)}catch(s){}};if(typeof window!="undefined"){let i=tn(o,[]);for(let d of i)t.set(d.componentId,d);try{localStorage.removeItem(nt)}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 r=new Map;for(let m of i){let v=(d=r.get(m.semanticType))!=null?d:[];v.push(m),r.set(m.semanticType,v)}let a=[],c=new Set;for(let m of i)for(let v of en(m.semanticType)){let b=(s=r.get(v))!=null?s:[];for(let R of b){if(R.componentId===m.componentId)continue;let A=`semantic:${m.componentId}->${R.componentId}`;c.has(A)||(c.add(A),a.push({fromComponentId:m.componentId,toComponentId:R.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=Y(x(x({pageUrl:Le(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:i.map(m=>{let v=on(m.semanticType);return{componentId:m.componentId,semanticType:v,answers:m.answers,contentHash:sn(m.componentId,v,m.answers),prominenceScore:m.prominenceScore,depthInPage:m.depth}}),edges:a});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:x({"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:l,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(o),localStorage.removeItem(nt)}catch(i){}}}}var ot=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],an=[["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]],cn=[["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 dn(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function ln(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,o]of an)if(o.test(t))return{type:n,strength:"strong"};for(let[n,o]of cn)if(o.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 un(e){var n,o;let t=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((o=e.className)!=null?o:"")}`,headingText:dn(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function st(e){return ln(un(e)).type}var pn=new Set(["SECTION","ARTICLE","MAIN","DIV"]),gn="h1, h2, h3",it=30,fn=1500,mn={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function at(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function yn(e){var t,n,o;try{let u=e;for(let l of Object.keys(u)){if(!l.startsWith("__reactFiber")&&!l.startsWith("__reactInternalInstance"))continue;let i=u[l],d=(o=(t=i==null?void 0:i.type)==null?void 0:t.displayName)!=null?o:(n=i==null?void 0:i.type)==null?void 0:n.name;if(d&&d.length>1)return d}}catch(u){}}function hn(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var ct=new Set(ot);function Sn(e){let t=e.getAttribute("data-sentient-type");if(t&&ct.has(t))return t;let n=e.getAttribute("role");return n&&ct.has(n)?n:st(e)}function vn(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 wn(e){let t=[],n=e;for(;n;){let o=n.parentElement;if(!o){t.push(n.tagName.toLowerCase());break}let u=Array.prototype.indexOf.call(o.children,n);t.push(`${n.tagName.toLowerCase()}[${u}]`),n=o}return t.reverse().join("/")}function bn(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${vn(wn(e))}`}function In(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Ge(e,t){var o,u,l;let n=e.querySelector(gn);return{componentId:bn(e),semanticType:Sn(e),ariaLabel:(o=e.getAttribute("aria-label"))!=null?o: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:In(e),reactComponentName:yn(e),dataAttributes:hn(e)}}function dt(e){var l;let t=[],n=new Set,o="__root__",u=new Map;for(let[i,d]of e){let s=i.parentElement,r=o;for(;s;){if(e.has(s)){r=e.get(s);let c=e.get(i),f=`${r}->${c}`;!n.has(f)&&r!==c&&(n.add(f),t.push({fromComponentId:r,toComponentId:c,weight:.6}));break}s=s.parentElement}let a=(l=u.get(r))!=null?l:[];a.push(i),u.set(r,a)}for(let i of u.values()){if(i.length<2)continue;let d=i.length>it?i.slice(0,it):i;for(let s=0;s<d.length;s++)for(let r=s+1;r<d.length;r++){if(t.length>=fn)return t;let a=e.get(d[s]),c=e.get(d[r]);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 xn(e){let t=[],n=new Set,o=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),o.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 r=Ge(i,e);t.push(r),o.set(i,r.componentId)}),{nodes:t,edges:dt(o),elementToId:o}}function lt(){if(typeof window=="undefined")return mn;let e=null,t=0,n=null,o=new Map,u=s=>{try{let r=window.getComputedStyle(s),a=parseFloat(r.fontSize)||12,c=parseFloat(r.zIndex)||0,f=s.getBoundingClientRect(),g=Math.max(f.top,0),m=window.innerHeight||1,v=1/(g/m+1),b=at(a,12,48)*.4+v*.4+at(c,0,100)*.2;return Math.max(0,Math.min(1,b))}catch(r){return .5}};return{scan:()=>new Promise(s=>{let r=()=>{let{nodes:a,edges:c,elementToId:f}=xn(u);o.clear();for(let[g,m]of f)o.set(g,m);s({nodes:a,edges:c,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(r,{timeout:100}):r()}catch(a){r()}}),observe:s=>{n=s;try{e=new MutationObserver(r=>{let a=[],c=new Set;for(let g of r)g.type==="childList"&&g.addedNodes.forEach(m=>{if(!(m instanceof Element)||!pn.has(m.tagName))return;let v=m.hasAttribute("data-sentient-id"),b=m.hasAttribute("aria-label");if(!v&&!b)return;let R=Ge(m,u);a.push(R),c.add(R.componentId),o.set(m,R.componentId)});if(a.length===0||!n)return;for(let g of[...o.keys()])g.isConnected||o.delete(g);let f=dt(o).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(r){}},getProminenceScore:u,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(s){}t=0,n=null,o.clear()}}}var En="https://api.sentient-ui.com/v1/events";function Cn(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var Te=new Map;function An(e){var c;let t=tt(e),n=e.respectDoNotTrack!==!1&&Me(),o=e.consent===!1||n;if(!e.graph||!e.apiKey||o||typeof window=="undefined")return t;let u=Te.get(e.apiKey);if(u)try{u()}catch(f){}let l=lt(),i=(c=e.ingestUrl)!=null?c:En,d=rt({syncUrl:i.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:Cn()});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,r=()=>{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);r()});let a=()=>{s!==null&&(clearTimeout(s),s=null),l.destroy(),d.destroy(),Te.get(e.apiKey)===a&&Te.delete(e.apiKey)};return Te.set(e.apiKey,a),Y(x({},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 pt=Object.create;var ge=Object.defineProperty,gt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,mt=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertyNames,Ke=Object.getOwnPropertySymbols,ht=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Ue=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))$e.call(t,n)&&Ue(e,n,t[n]);if(Ke)for(var n of Ke(t))St.call(t,n)&&Ue(e,n,t[n]);return e},Y=(e,t)=>gt(e,mt(t));var vt=(e,t)=>{for(var n in t)ge(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of yt(t))!$e.call(e,u)&&u!==n&&ge(e,u,{get:()=>t[u],enumerable:!(r=ft(t,u))||r.enumerable});return e};var bt=(e,t,n)=>(n=e!=null?pt(ht(e)):{},Be(t||!e||!e.__esModule?ge(n,"default",{value:e,enumerable:!0}):n,e)),wt=e=>Be(ge({},"__esModule",{value:!0}),e);var Tn={};vt(Tn,{deriveSessionSegment:()=>_e,detectDeviceClass:()=>re,detectTimeOfDay:()=>ae,detectTrafficSource:()=>se,init:()=>An,referrerDomainFromReferer:()=>ie,sanitizePageUrl:()=>Le});module.exports=wt(Tn);function me(){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 te(e){return e?`_${e.slice(0,12)}`:""}var It="_snt_uid",xt=365,Et="_snt_uid";function Ct(){return me()}function At(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Tt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function kt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Rt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function _t(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Dt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Ot(e){try{sessionStorage.removeItem(e)}catch(t){}}function Pt(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 Nt(e){try{localStorage.removeItem(e)}catch(t){}}function Mt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Lt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ye(e){var f,g,m,v,I,R;if(typeof window=="undefined")return Lt;let t=te(e==null?void 0:e.apiKey),n=(f=e==null?void 0:e.cookieName)!=null?f:`${It}${t}`,r=`${Et}${t}`,l=((g=e==null?void 0:e.cookieTTLDays)!=null?g:xt)*24*60*60,i=T=>T&&T.length>0?T:null,d=(R=(I=(v=(m=i(At(n)))!=null?m:i(kt(r)))!=null?v:i(_t(r)))!=null?I:i(e==null?void 0:e.ssrSessionId))!=null?R:Ct();Tt(n,d,l);let s=Rt(r,d),o=Pt(n),a=s?!1:Dt(r,d),c=!s&&!o&&!a;return{getSessionId:()=>d,isEphemeral:()=>c,destroy:()=>{d=null,Mt(n),Nt(r),Ot(r)}}}function ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function he(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 oe(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 Gt=500,Kt=56*1024;function ke(e){return`_snt_retry_${e.slice(0,12)}`}var Ut={push:()=>{},flush:()=>{},destroy:()=>{}};function Fe(e){var P,W,z;if(typeof window=="undefined")return Ut;let t=(P=e.flushIntervalMs)!=null?P:5e3,n=(W=e.maxBatchSize)!=null?W:20,r=(z=e.maxRetrySize)!=null?z:100,u=e.ingestUrl,l=e.apiKey,i=ke(l),d=[],s=new Set,o=[],a=h=>{for(let x of h)c.delete(x),!s.has(x)&&(s.add(x),o.push(x));for(;o.length>Gt;){let x=o.shift();x&&s.delete(x)}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 x of h)s.has(x.id)||(c.add(x.id),d.push(x))},m=Se(i,r);for(let h of m)f(h);let v=0,I=0,R=(h,x=!0)=>{if(h.length===0)return;let Q=JSON.stringify(h),Z=h.map(J=>J.id),$;try{$=fetch(u,{method:"POST",keepalive:!0,body:Q,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(J){oe(h,r,i),g(h),I++,v=Date.now()+ne(I);return}let de=J=>{if(he(J)!=="retry"){if(!J.ok&&x){let ee=h.filter(H=>H.eventType!=="pageview");if(ee.length>0&&ee.length<h.length){a(h.filter(H=>H.eventType==="pageview").map(H=>H.id)),R(ee,!1);return}}a(Z),I=0,v=0;return}oe(h,r,i),g(h),I++,v=Date.now()+ne(I)};$ instanceof Promise?$.then(de).catch(()=>{oe(h,r,i),g(h),I++,v=Date.now()+ne(I)}):de($)},T=typeof TextEncoder!="undefined"?new TextEncoder:null,k=h=>T?T.encode(h).length:h.length,X=h=>{let x=[],Q=2;for(let Z of h){let $=k(JSON.stringify(Z))+1;if(x.length>0&&Q+$>Kt||x.length>=n)break;x.push(Z),Q+=$}return x},_=()=>{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 x=X(h);if(x.length===0)break;x.length<h.length&&d.push(...h.slice(x.length)),R(x)}}catch(h){}},S=!0,C=null;C=setInterval(()=>{S&&_()},t);let q=()=>{document.visibilityState==="hidden"&&_()},L=()=>{_()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",L),{push(h){f(h),d.length>=n&&_()},flush:_,destroy(){S=!1,C!==null&&(clearInterval(C),C=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",L),_()}}}var $t=200;function Re(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Bt={send:()=>{},flush:()=>{},destroy:()=>{}};function je(e){var k,X,_;if(typeof window=="undefined")return Bt;let t=(k=e.flushIntervalMs)!=null?k:5e3,n=(X=e.maxRetrySize)!=null?X:100,r=(_=e.maxPerFlush)!=null?_: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>$t;){let C=s.shift();C&&d.delete(C)}ve([S.id],u)},g=S=>{oe([S],n,u),!d.has(S.id)&&!i.has(S.id)&&(i.add(S.id),l.push(S)),a++,o=Date.now()+ne(a)},m=S=>{let C;try{C=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(L){g(S);return}let q=L=>{var W;let P=he(L);if(P==="retry"){g(S);return}P==="dropped"&&((W=e.onDrop)==null||W.call(e,S,L.status)),f(S),a=0,o=0};C instanceof Promise?C.then(q).catch(()=>g(S)):q(C)},v=()=>{try{if(c||Date.now()<o)return;let S=0;for(;l.length>0&&S<r&&!(Date.now()<o);){let C=l.shift();i.delete(C.id),!d.has(C.id)&&(S++,m(C))}}catch(S){}};for(let S of Se(u,n))i.has(S.id)||(i.add(S.id),l.push(S));let I=setInterval(v,t),R=()=>{document.visibilityState==="hidden"&&v()},T=()=>v();return document.addEventListener("visibilitychange",R),window.addEventListener("pagehide",T),{send(S){if(!c&&!(d.has(S.id)||i.has(S.id))){if(Date.now()<o){i.add(S.id),l.push(S);return}m(S)}},flush:v,destroy(){clearInterval(I),document.removeEventListener("visibilitychange",R),window.removeEventListener("pagehide",T),v(),c=!0}}}var Ft=1800*1e3;function be(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function We(e=Ft,t){let n=new Map,r=`_snt_asgn${te(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(be(f.componentId,f.segment),c)}catch(a){}})(),{get(o,a){let c=n.get(be(o,a));return c?d(c)?(n.delete(be(o,a)),null):c:null},set(o,a,c){let f=be(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 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 we(e){return Qe(e)!==null}function Qe(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ze.find(r=>t.includes(r.toLowerCase())))!=null?n:null}function re(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 se(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 ie(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ae(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function _e(e){let t=jt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function jt(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?re(n):"desktop",trafficSource:r?se(r,t==null?void 0:t.appOrigin):"direct",referrerDomain:ie(r),timeOfDay:ae(u),dayOfWeek:(c=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?c:"sun",automation:(t==null?void 0:t.webdriver)===!0||we(n)}}var ce=require("@sentientui/policy");function De(e){return w(w(w({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,ce.slotResultFor)(t,(0,ce.slotBaselineArm)(t))}function qe(e){return typeof e=="string"?e:(0,ce.canonicalArm)(e)}var Ie="_snt_snap:",Wt=["low","medium","high"];function Je(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"||!Wt.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 He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",zt="[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.",Ve=!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 Ye(e){var d;let t=ye({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?(Ve||(Ve=!0,console.info(zt)),o):(Ee||(Ee=!0,console.error(He)),null)}).catch(()=>(Ee||(Ee=!0,console.error(He)),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=Y(w({},a),{layoutOrder:(f=(c=a.layoutOrder)!=null?c:l==null?void 0:l.layoutOrder)!=null?f:null,slots:w(w({},(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 Xe="https://api.sentient-ui.com/v1/events",j=new Map,qt=null;function Jt(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Pe(){return me()}function Ae(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Ht(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 Ze=new Set;function Vt(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let u=!1,l,i=()=>{if(u)return;let o=Ae();!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=Ae();return s&&Ze.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 fe={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 Yt(){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 et(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 Xt(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=et((d=e.ingestUrl)!=null?d:Xe),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 tt(e){var h,x,Q,Z,$,de,J,ee,H;if(typeof window=="undefined")return fe;qt=e.apiKey;let t=j.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?(j.set(e.apiKey||"local",{config:e,upgrade:null}),fe):(j.set(e.apiKey||"local",{config:e,upgrade:null}),Ye(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."),j.set(e.apiKey,{config:e,upgrade:null}),fe;let{proxy:p,setInner:y}=Xt(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."),fe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),fe;let l=(h=e.ingestUrl)!=null?h:Xe,i=Date.now(),d=ye({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),s=We(void 0,e.apiKey),o=Fe({ingestUrl:l,apiKey:e.apiKey}),a=et(l),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},f=je({url:`${a}/goals`,apiKey:e.apiKey,headers:c,onDrop:(p,y)=>{e.debug&&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)}}),g=re((x=navigator.userAgent)!=null?x:""),m=typeof window!="undefined"?window.location.origin:void 0,v=se((Q=document.referrer)!=null?Q:"",m),I=(Z=e.sessionSegment)!=null?Z:`${g}:${v}`,R=new Map,T=new Map,k=null,X=p=>{for(let y of p)T.has(y.id)||T.set(y.id,Oe(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))T.set(p,y);let _=Je(e.apiKey);if(_)for(let[p,y]of Object.entries(_.slots))T.has(p)||T.set(p,y);let S={low:.15,medium:.5,high:.85};if(e.initialPersona)k=w({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?k={persona:p.sentientPersona,confidence:(de=S[($=p.sentientConfidence)!=null?$:"low"])!=null?de:.15}:_&&(k={persona:_.persona,confidence:(J=S[_.band])!=null?J:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))s.set(p,I,{variantId:y,assignedAt:Date.now(),segment:I,confidence:1});let C=Promise.resolve(),q=d.getSessionId();if(q){let p=ie((ee=document.referrer)!=null?ee:""),y=w(w(w({sessionId:q,deviceClass:g,trafficSource:v,referrerDomain:p,utmParams:Yt(),timeOfDay:ae(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||we((H=navigator.userAgent)!=null?H:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{});try{C=fetch(`${a}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:c}).then(b=>{b.status===402&&console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing")}).catch(()=>{})}catch(b){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let L=new Set,P=null,W=!1,z={goal(p,y={},b=1,G=0){var O,le,U,ue,E,V;let N=d.getSessionId();if(!N)return;let A=Jt(y)?y:{metadata:y},B=`${p}\0${(O=A.externalId)!=null?O:""}\0${(le=A.stepIndex)!=null?le:G}\0${(U=A.weight)!=null?U:b}`;if(L.has(B)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}L.add(B),L.size===1&&Ht(L);let K=Pe(),D={sessionId:N,name:p,metadata:(ue=A.metadata)!=null?ue:{},weight:(E=A.weight)!=null?E:b,stepIndex:(V=A.stepIndex)!=null?V:G,goalId:K,value:A.value,currency:A.currency,externalId:A.externalId};e.debug&&console.log("[sentient] goal",D);let F={id:K,body:JSON.stringify(D)};C.then(()=>f.send(F))},componentGoal(p,y,b){var D,F,O;let G=d.getSessionId();if(!G)return;let N=s.get(p,I),A=N?null:(D=T.get(p))!=null?D:null;if(!N&&A===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 B=N?N.variantId:qe(A),K={id:Pe(),sessionId:G,projectId:e.apiKey,componentId:p,variantId:B,eventType:"goal_achieved",goalType:y,payload:w({reward:(F=b==null?void 0:b.reward)!=null?F:1,goalValue:b==null?void 0:b.value,currency:b==null?void 0:b.currency},(O=b==null?void 0:b.metadata)!=null?O:{}),timestamp:Date.now(),timeInSession:Date.now()-i,path:Ae()};e.debug&&console.log("[sentient] componentGoal",K),C.then(()=>o.push(K))},identify(p){let y=d.getSessionId();y&&C.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 b=Y(w({path:Ae()},p),{id:Pe(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-i});e.debug&&console.log("[sentient] track",b),C.then(()=>o.push(b))},getAssignment(p,y){return s.get(p,y)},async assign(p,y,b,G){let N=d.getSessionId();if(!N)return null;let A=s.get(p,I);if(A&&(y!=null&&y.length||A.content!==void 0)){let D=A.ttlMs&&A.ttlMs>0?Math.max(0,A.assignedAt+A.ttlMs-Date.now()):0;return{variantId:A.variantId,assignmentTtlMs:D,content:A.content}}let B=R.get(p);if(B)return B;let K=(async()=>{await C;try{let D={sessionId:N,componentId:p,variantIds:y};G!==void 0?D.agentDataByVariant=G:b!==void 0&&(D.agentData=b);let F=await fetch(`${a}/assign`,{method:"POST",body:JSON.stringify(D),headers:c});if(!F.ok)return null;let O=await F.json();return s.set(p,I,w({variantId:O.variantId,assignedAt:Date.now(),segment:I,confidence:1,content:O.content},O.assignmentTtlMs&&O.assignmentTtlMs>0?{ttlMs:O.assignmentTtlMs}:{})),O}catch(D){return null}finally{R.delete(p)}})();return R.set(p,K),K},async decide(p){var G,N,A,B,K,D,F,O,le;let y=d.getSessionId();if(!y)return null;let b=(G=p.slots)!=null?G:[];await C;try{let U={sessionId:y};p.sections&&p.sections.length>0&&(U.sections=p.sections.map(M=>({id:M}))),U.components=(N=p.components)!=null?N:[],b.length>0&&(U.slots=b.map(De)),p.slotsFrom==="registry"&&(U.slotsFrom="registry"),p.v&&(U.v=p.v),e.persona&&(U.persona=e.persona);let ue=await fetch(`${a}/decide`,{method:"POST",body:JSON.stringify(U),headers:c});if(!ue.ok)return X(b),null;let E=await ue.json(),V={};for(let M of b)V[M.id]=(B=(A=E.slots)==null?void 0:A[M.id])!=null?B:Oe(M);if(E.slots)for(let[M,pe]of Object.entries(E.slots))M in V||(V[M]=pe);for(let[M,pe]of Object.entries(V))T.set(M,pe);let ut=k!=null&&k.persona!=="unknown";E.persona&&!(E.persona==="unknown"&&ut)?k={persona:E.persona,confidence:(K=E.confidence)!=null?K:0}:k||(k={persona:"unknown",confidence:0});for(let[M,pe]of Object.entries((D=E.assignments)!=null?D:{}))s.set(M,I,{variantId:pe,assignedAt:Date.now(),segment:I,confidence:1});return xe(e.apiKey,w(w({v:1,persona:k.persona,band:(0,Ne.confidenceBand)(k.confidence),slots:Object.fromEntries(T),layoutOrder:(F=E.layoutOrder)!=null?F:null,savedAt:Date.now()},E.slotConfig?{slotConfig:E.slotConfig}:{}),E.palette?{palette:E.palette}:{})),w(w(w(w({layoutOrder:(O=E.layoutOrder)!=null?O:null,assignments:(le=E.assignments)!=null?le:{},slots:V,persona:k.persona,confidence:k.confidence},E.slotConfig?{slotConfig:E.slotConfig}:{}),E.goals?{goals:E.goals}:{}),E.sectionMap?{sectionMap:E.sectionMap}:{}),E.palette?{palette:E.palette}:{})}catch(U){return X(b),null}},getSlotResult(p){var y;return(y=T.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;P==null||P(),W=!0,o.destroy(),f.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===z.dispose&&j.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;P==null||P(),W=!0,o.destroy(),f.destroy(),d.destroy(),((p=j.get(e.apiKey))==null?void 0:p.dispose)===z.dispose&&j.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(j.set(e.apiKey,{config:e,upgrade:null,dispose:z.dispose}),P=Vt(z,e.apiKey,p=>{C.then(()=>{W||Ze.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=z)}return z}var nt="_snt_graph_edges",Zt={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function en(e){var t;return(t=Zt[e])!=null?t:[]}function tn(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function nn(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var on=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function rn(e){return on.has(e)?e:"generic"}function Le(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function sn(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 ot(e){let t=new Map,n=new Map,r=`_snt_graph_nodes${te(e==null?void 0:e.apiKey)}`,u=()=>{typeof window!="undefined"&&nn(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=tn(r,[]);for(let d of i)t.set(d.componentId,d);try{localStorage.removeItem(nt)}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 en(m.semanticType)){let I=(s=o.get(v))!=null?s:[];for(let R of I){if(R.componentId===m.componentId)continue;let T=`semantic:${m.componentId}->${R.componentId}`;c.has(T)||(c.add(T),a.push({fromComponentId:m.componentId,toComponentId:R.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=Y(w(w({pageUrl:Le(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:i.map(m=>{let v=rn(m.semanticType);return{componentId:m.componentId,semanticType:v,answers:m.answers,contentHash:sn(m.componentId,v,m.answers),prominenceScore:m.prominenceScore,depthInPage:m.depth}}),edges:a});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:w({"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(nt)}catch(i){}}}}var rt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],an=[["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]],cn=[["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 dn(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function ln(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 an)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of cn)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 un(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:dn(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function st(e){return ln(un(e)).type}var pn=new Set(["SECTION","ARTICLE","MAIN","DIV"]),gn="h1, h2, h3",it=30,fn=1500,mn={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function at(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function yn(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 hn(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var ct=new Set(rt);function Sn(e){let t=e.getAttribute("data-sentient-type");if(t&&ct.has(t))return t;let n=e.getAttribute("role");return n&&ct.has(n)?n:st(e)}function vn(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 bn(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 wn(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${vn(bn(e))}`}function In(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(gn);return{componentId:wn(e),semanticType:Sn(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:In(e),reactComponentName:yn(e),dataAttributes:hn(e)}}function dt(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>it?i.slice(0,it):i;for(let s=0;s<d.length;s++)for(let o=s+1;o<d.length;o++){if(t.length>=fn)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 xn(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:dt(r),elementToId:r}}function lt(){if(typeof window=="undefined")return mn;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),I=at(a,12,48)*.4+v*.4+at(c,0,100)*.2;return Math.max(0,Math.min(1,I))}catch(o){return .5}};return{scan:()=>new Promise(s=>{let o=()=>{let{nodes:a,edges:c,elementToId:f}=xn(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)||!pn.has(m.tagName))return;let v=m.hasAttribute("data-sentient-id"),I=m.hasAttribute("aria-label");if(!v&&!I)return;let R=Ge(m,u);a.push(R),c.add(R.componentId),r.set(m,R.componentId)});if(a.length===0||!n)return;for(let g of[...r.keys()])g.isConnected||r.delete(g);let f=dt(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 En="https://api.sentient-ui.com/v1/events";function Cn(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var Te=new Map;function An(e){var c;let t=tt(e),n=e.respectDoNotTrack!==!1&&Me(),r=e.consent===!1||n;if(!e.graph||!e.apiKey||r||typeof window=="undefined")return t;let u=Te.get(e.apiKey);if(u)try{u()}catch(f){}let l=lt(),i=(c=e.ingestUrl)!=null?c:En,d=ot({syncUrl:i.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:Cn()});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(),Te.get(e.apiKey)===a&&Te.delete(e.apiKey)};return Te.set(e.apiKey,a),Y(w({},t),{getGraph:()=>d.snapshot(),dispose:()=>{a(),t.dispose()},destroy:()=>{a(),t.destroy()}})}0&&(module.exports={deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,init,referrerDomainFromReferer,sanitizePageUrl});
|
|
2
2
|
//# sourceMappingURL=index-graph.js.map
|