@sentientui/core 0.21.1 → 0.21.2

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,2 +1,2 @@
1
- import{a as b,d as v}from"./chunk-CD2A55US.mjs";import{B as A,a as T,z as N}from"./chunk-K6W474ZY.mjs";import{g as $,h as k,i as U,j as L,k as j}from"./chunk-MYT7OJBV.mjs";import{a as y,b as I}from"./chunk-TMCGHANO.mjs";var x="_snt_graph_edges",K={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function z(e){var t;return(t=K[e])!=null?t:[]}function F(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function q(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var B=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function H(e){return B.has(e)?e:"generic"}function _(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function J(e,t,n){let d=`${e}:${t}:${n.join(",")}`,p=5381;for(let m=0;m<d.length;m++)p=(p<<5)+p+d.charCodeAt(m)&4294967295;return(p>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,n=new Map,d=`_snt_graph_nodes${T(e==null?void 0:e.apiKey)}`,p=()=>{typeof window!="undefined"&&q(d,[...t.values()])},m=o=>{var a;try{let i=JSON.parse(o);t.clear();for(let c of(a=i.pageNodes)!=null?a:[])t.set(c.componentId,c)}catch(i){}};if(typeof window!="undefined"){let o=F(d,[]);for(let a of o)t.set(a.componentId,a);try{localStorage.removeItem(x)}catch(a){}}return{addPageNode(o){t.set(o.componentId,o),p()},addStructuralEdge(o){let a=`${o.fromComponentId}->${o.toComponentId}`;n.set(a,o)},syncOnce(){var a,i;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let o=[...t.values()];if(o.length!==0)try{let c=new Map;for(let s of o){let f=(a=c.get(s.semanticType))!=null?a:[];f.push(s),c.set(s.semanticType,f)}let u=[],l=new Set;for(let s of o)for(let f of z(s.semanticType)){let S=(i=c.get(f))!=null?i:[];for(let h of S){if(h.componentId===s.componentId)continue;let w=`semantic:${s.componentId}->${h.componentId}`;l.has(w)||(l.add(w),u.push({fromComponentId:s.componentId,toComponentId:h.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(o.map(s=>s.componentId));for(let s of n.values()){if(!g.has(s.fromComponentId)||!g.has(s.toComponentId))continue;let f=`structural:${s.fromComponentId}->${s.toComponentId}`;l.has(f)||(l.add(f),u.push({fromComponentId:s.fromComponentId,toComponentId:s.toComponentId,type:"structural",weight:s.weight,confidence:1}))}let r=I(y(y({pageUrl:_(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:o.map(s=>{let f=H(s.semanticType);return{componentId:s.componentId,semanticType:f,answers:s.answers,contentHash:J(s.componentId,f,s.answers),prominenceScore:s.prominenceScore,depthInPage:s.depth}}),edges:u});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:y({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(r)}).catch(()=>{})}catch(c){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:m,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(d),localStorage.removeItem(x)}catch(o){}}}}var V=new Set(["SECTION","ARTICLE","MAIN","DIV"]),W="h1, h2, h3",O=30,Y=1500,Q={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function R(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function X(e){var t,n,d;try{let p=e;for(let m of Object.keys(p)){if(!m.startsWith("__reactFiber")&&!m.startsWith("__reactInternalInstance"))continue;let o=p[m],a=(d=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?d:(n=o==null?void 0:o.type)==null?void 0:n.name;if(a&&a.length>1)return a}}catch(p){}}function Z(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var P=new Set(b);function ee(e){let t=e.getAttribute("data-sentient-type");if(t&&P.has(t))return t;let n=e.getAttribute("role");return n&&P.has(n)?n:v(e)}function te(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 ne(e){let t=[],n=e;for(;n;){let d=n.parentElement;if(!d){t.push(n.tagName.toLowerCase());break}let p=Array.prototype.indexOf.call(d.children,n);t.push(`${n.tagName.toLowerCase()}[${p}]`),n=d}return t.reverse().join("/")}function oe(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${te(ne(e))}`}function re(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function C(e,t){var d,p,m;let n=e.querySelector(W);return{componentId:oe(e),semanticType:ee(e),ariaLabel:(d=e.getAttribute("aria-label"))!=null?d:void 0,headingText:(m=(p=n==null?void 0:n.textContent)==null?void 0:p.trim())!=null?m:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:re(e),reactComponentName:X(e),dataAttributes:Z(e)}}function D(e){var m;let t=[],n=new Set,d="__root__",p=new Map;for(let[o,a]of e){let i=o.parentElement,c=d;for(;i;){if(e.has(i)){c=e.get(i);let l=e.get(o),g=`${c}->${l}`;!n.has(g)&&c!==l&&(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.6}));break}i=i.parentElement}let u=(m=p.get(c))!=null?m:[];u.push(o),p.set(c,u)}for(let o of p.values()){if(o.length<2)continue;let a=o.length>O?o.slice(0,O):o;for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){if(t.length>=Y)return t;let u=e.get(a[i]),l=e.get(a[c]);if(u===l)continue;let g=`${u}->${l}::sib`,r=`${l}->${u}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:u,toComponentId:l,weight:.3})),n.has(r)||(n.add(r),t.push({fromComponentId:l,toComponentId:u,weight:.3}))}}return t}function se(e){let t=[],n=new Set,d=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let a=C(o,e);t.push(a),d.set(o,a.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let a=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!a&&!i)return;n.add(o);let c=C(o,e);t.push(c),d.set(o,c.componentId)}),{nodes:t,edges:D(d),elementToId:d}}function G(){if(typeof window=="undefined")return Q;let e=null,t=0,n=null,d=new Map,p=i=>{try{let c=window.getComputedStyle(i),u=parseFloat(c.fontSize)||12,l=parseFloat(c.zIndex)||0,g=i.getBoundingClientRect(),r=Math.max(g.top,0),s=window.innerHeight||1,f=1/(r/s+1),S=R(u,12,48)*.4+f*.4+R(l,0,100)*.2;return Math.max(0,Math.min(1,S))}catch(c){return .5}};return{scan:()=>new Promise(i=>{let c=()=>{let{nodes:u,edges:l,elementToId:g}=se(p);d.clear();for(let[r,s]of g)d.set(r,s);i({nodes:u,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(c,{timeout:100}):c()}catch(u){c()}}),observe:i=>{n=i;try{e=new MutationObserver(c=>{let u=[],l=new Set;for(let r of c)r.type==="childList"&&r.addedNodes.forEach(s=>{if(!(s instanceof Element)||!V.has(s.tagName))return;let f=s.hasAttribute("data-sentient-id"),S=s.hasAttribute("aria-label");if(!f&&!S)return;let h=C(s,p);u.push(h),l.add(h.componentId),d.set(s,h.componentId)});if(u.length===0||!n)return;for(let r of[...d.keys()])r.isConnected||d.delete(r);let g=D(d).filter(r=>l.has(r.fromComponentId)||l.has(r.toComponentId));n({nodes:u,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(c){}},getProminenceScore:p,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(i){}t=0,n=null,d.clear()}}}var ae="https://api.sentient-ui.com/v1/events";function ie(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var E=new Map;function he(e){var l;let t=A(e),n=e.respectDoNotTrack!==!1&&N(),d=e.consent===!1||n;if(!e.graph||!e.apiKey||d||typeof window=="undefined")return t;let p=E.get(e.apiKey);if(p)try{p()}catch(g){}let m=G(),o=(l=e.ingestUrl)!=null?l:ae,a=M({syncUrl:o.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ie()});m.scan().then(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);a.syncOnce()});let i=null,c=()=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.syncOnce()},500)};m.observe(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);c()});let u=()=>{i!==null&&(clearTimeout(i),i=null),m.destroy(),a.destroy(),E.get(e.apiKey)===u&&E.delete(e.apiKey)};return E.set(e.apiKey,u),I(y({},t),{getGraph:()=>a.snapshot(),dispose:()=>{u(),t.dispose()},destroy:()=>{u(),t.destroy()}})}export{j as deriveSessionSegment,$ as detectDeviceClass,L as detectTimeOfDay,k as detectTrafficSource,he as init,U as referrerDomainFromReferer,_ as sanitizePageUrl};
1
+ import{a as b,d as v}from"./chunk-CD2A55US.mjs";import{B as A,a as T,z as N}from"./chunk-NA6AFNTM.mjs";import{g as $,h as k,i as U,j as L,k as j}from"./chunk-MYT7OJBV.mjs";import{a as y,b as I}from"./chunk-TMCGHANO.mjs";var x="_snt_graph_edges",K={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function z(e){var t;return(t=K[e])!=null?t:[]}function F(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function q(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var B=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function H(e){return B.has(e)?e:"generic"}function _(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function J(e,t,n){let d=`${e}:${t}:${n.join(",")}`,p=5381;for(let m=0;m<d.length;m++)p=(p<<5)+p+d.charCodeAt(m)&4294967295;return(p>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,n=new Map,d=`_snt_graph_nodes${T(e==null?void 0:e.apiKey)}`,p=()=>{typeof window!="undefined"&&q(d,[...t.values()])},m=o=>{var a;try{let i=JSON.parse(o);t.clear();for(let c of(a=i.pageNodes)!=null?a:[])t.set(c.componentId,c)}catch(i){}};if(typeof window!="undefined"){let o=F(d,[]);for(let a of o)t.set(a.componentId,a);try{localStorage.removeItem(x)}catch(a){}}return{addPageNode(o){t.set(o.componentId,o),p()},addStructuralEdge(o){let a=`${o.fromComponentId}->${o.toComponentId}`;n.set(a,o)},syncOnce(){var a,i;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let o=[...t.values()];if(o.length!==0)try{let c=new Map;for(let s of o){let f=(a=c.get(s.semanticType))!=null?a:[];f.push(s),c.set(s.semanticType,f)}let u=[],l=new Set;for(let s of o)for(let f of z(s.semanticType)){let S=(i=c.get(f))!=null?i:[];for(let h of S){if(h.componentId===s.componentId)continue;let w=`semantic:${s.componentId}->${h.componentId}`;l.has(w)||(l.add(w),u.push({fromComponentId:s.componentId,toComponentId:h.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(o.map(s=>s.componentId));for(let s of n.values()){if(!g.has(s.fromComponentId)||!g.has(s.toComponentId))continue;let f=`structural:${s.fromComponentId}->${s.toComponentId}`;l.has(f)||(l.add(f),u.push({fromComponentId:s.fromComponentId,toComponentId:s.toComponentId,type:"structural",weight:s.weight,confidence:1}))}let r=I(y(y({pageUrl:_(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:o.map(s=>{let f=H(s.semanticType);return{componentId:s.componentId,semanticType:f,answers:s.answers,contentHash:J(s.componentId,f,s.answers),prominenceScore:s.prominenceScore,depthInPage:s.depth}}),edges:u});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:y({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(r)}).catch(()=>{})}catch(c){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:m,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(d),localStorage.removeItem(x)}catch(o){}}}}var V=new Set(["SECTION","ARTICLE","MAIN","DIV"]),W="h1, h2, h3",O=30,Y=1500,Q={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function R(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function X(e){var t,n,d;try{let p=e;for(let m of Object.keys(p)){if(!m.startsWith("__reactFiber")&&!m.startsWith("__reactInternalInstance"))continue;let o=p[m],a=(d=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?d:(n=o==null?void 0:o.type)==null?void 0:n.name;if(a&&a.length>1)return a}}catch(p){}}function Z(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var P=new Set(b);function ee(e){let t=e.getAttribute("data-sentient-type");if(t&&P.has(t))return t;let n=e.getAttribute("role");return n&&P.has(n)?n:v(e)}function te(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 ne(e){let t=[],n=e;for(;n;){let d=n.parentElement;if(!d){t.push(n.tagName.toLowerCase());break}let p=Array.prototype.indexOf.call(d.children,n);t.push(`${n.tagName.toLowerCase()}[${p}]`),n=d}return t.reverse().join("/")}function oe(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${te(ne(e))}`}function re(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function C(e,t){var d,p,m;let n=e.querySelector(W);return{componentId:oe(e),semanticType:ee(e),ariaLabel:(d=e.getAttribute("aria-label"))!=null?d:void 0,headingText:(m=(p=n==null?void 0:n.textContent)==null?void 0:p.trim())!=null?m:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:re(e),reactComponentName:X(e),dataAttributes:Z(e)}}function D(e){var m;let t=[],n=new Set,d="__root__",p=new Map;for(let[o,a]of e){let i=o.parentElement,c=d;for(;i;){if(e.has(i)){c=e.get(i);let l=e.get(o),g=`${c}->${l}`;!n.has(g)&&c!==l&&(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.6}));break}i=i.parentElement}let u=(m=p.get(c))!=null?m:[];u.push(o),p.set(c,u)}for(let o of p.values()){if(o.length<2)continue;let a=o.length>O?o.slice(0,O):o;for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){if(t.length>=Y)return t;let u=e.get(a[i]),l=e.get(a[c]);if(u===l)continue;let g=`${u}->${l}::sib`,r=`${l}->${u}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:u,toComponentId:l,weight:.3})),n.has(r)||(n.add(r),t.push({fromComponentId:l,toComponentId:u,weight:.3}))}}return t}function se(e){let t=[],n=new Set,d=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let a=C(o,e);t.push(a),d.set(o,a.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let a=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!a&&!i)return;n.add(o);let c=C(o,e);t.push(c),d.set(o,c.componentId)}),{nodes:t,edges:D(d),elementToId:d}}function G(){if(typeof window=="undefined")return Q;let e=null,t=0,n=null,d=new Map,p=i=>{try{let c=window.getComputedStyle(i),u=parseFloat(c.fontSize)||12,l=parseFloat(c.zIndex)||0,g=i.getBoundingClientRect(),r=Math.max(g.top,0),s=window.innerHeight||1,f=1/(r/s+1),S=R(u,12,48)*.4+f*.4+R(l,0,100)*.2;return Math.max(0,Math.min(1,S))}catch(c){return .5}};return{scan:()=>new Promise(i=>{let c=()=>{let{nodes:u,edges:l,elementToId:g}=se(p);d.clear();for(let[r,s]of g)d.set(r,s);i({nodes:u,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(c,{timeout:100}):c()}catch(u){c()}}),observe:i=>{n=i;try{e=new MutationObserver(c=>{let u=[],l=new Set;for(let r of c)r.type==="childList"&&r.addedNodes.forEach(s=>{if(!(s instanceof Element)||!V.has(s.tagName))return;let f=s.hasAttribute("data-sentient-id"),S=s.hasAttribute("aria-label");if(!f&&!S)return;let h=C(s,p);u.push(h),l.add(h.componentId),d.set(s,h.componentId)});if(u.length===0||!n)return;for(let r of[...d.keys()])r.isConnected||d.delete(r);let g=D(d).filter(r=>l.has(r.fromComponentId)||l.has(r.toComponentId));n({nodes:u,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(c){}},getProminenceScore:p,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(i){}t=0,n=null,d.clear()}}}var ae="https://api.sentient-ui.com/v1/events";function ie(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var E=new Map;function he(e){var l;let t=A(e),n=e.respectDoNotTrack!==!1&&N(),d=e.consent===!1||n;if(!e.graph||!e.apiKey||d||typeof window=="undefined")return t;let p=E.get(e.apiKey);if(p)try{p()}catch(g){}let m=G(),o=(l=e.ingestUrl)!=null?l:ae,a=M({syncUrl:o.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ie()});m.scan().then(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);a.syncOnce()});let i=null,c=()=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.syncOnce()},500)};m.observe(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);c()});let u=()=>{i!==null&&(clearTimeout(i),i=null),m.destroy(),a.destroy(),E.get(e.apiKey)===u&&E.delete(e.apiKey)};return E.set(e.apiKey,u),I(y({},t),{getGraph:()=>a.snapshot(),dispose:()=>{u(),t.dispose()},destroy:()=>{u(),t.destroy()}})}export{j as deriveSessionSegment,$ as detectDeviceClass,L as detectTimeOfDay,k as detectTrafficSource,he as init,U as referrerDomainFromReferer,_ as sanitizePageUrl};
2
2
  //# sourceMappingURL=index-graph.mjs.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var lt=Object.create;var ue=Object.defineProperty,ct=Object.defineProperties,dt=Object.getOwnPropertyDescriptor,ut=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertyNames,$e=Object.getOwnPropertySymbols,gt=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var Fe=(e,t,n)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))We.call(t,n)&&Fe(e,n,t[n]);if($e)for(var n of $e(t))ft.call(t,n)&&Fe(e,n,t[n]);return e},te=(e,t)=>ct(e,ut(t));var mt=(e,t)=>{for(var n in t)ue(e,n,{get:t[n],enumerable:!0})},je=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of pt(t))!We.call(e,u)&&u!==n&&ue(e,u,{get:()=>t[u],enumerable:!(c=dt(t,u))||c.enumerable});return e};var yt=(e,t,n)=>(n=e!=null?lt(gt(e)):{},je(t||!e||!e.__esModule?ue(n,"default",{value:e,enumerable:!0}):n,e)),ht=e=>je(ue({},"__esModule",{value:!0}),e);var pn={};mt(pn,{AGENT_INTENTS:()=>_e,BLOCK_ALIGNS:()=>Wt,BLOCK_EMPHASES:()=>Jt,BLOCK_FITS:()=>Yt,BLOCK_GAPS:()=>Ft,BLOCK_GRID_COLUMNS:()=>qt,BLOCK_HEADING_LEVELS:()=>Zt,BLOCK_JUSTIFIES:()=>jt,BLOCK_RATIOS:()=>Xt,BLOCK_SIZES:()=>Ht,BLOCK_TEXT_ALIGNS:()=>Vt,BLOCK_TONES:()=>Qt,BLOCK_WEIGHTS:()=>zt,LOCAL_MODE_BANNER:()=>Ke,MAX_BLOCK_ARMS:()=>on,MAX_BLOCK_CHILDREN:()=>nn,MAX_BLOCK_DEPTH:()=>tn,MAX_BLOCK_NODES:()=>en,MAX_BLOCK_TEXT_LEN:()=>rn,PROD_KEYLESS_ERROR:()=>Be,SNAPSHOT_STORAGE_KEY_PREFIX:()=>Z,agentIntent:()=>Je,agentUaList:()=>pe,armOfResult:()=>Ae,attachMicroSignalDetectors:()=>tt,baselineResultFor:()=>se,baselineSlots:()=>Ye,classifiedAgents:()=>Ve,deriveSessionSegment:()=>Xe,detectDeviceClass:()=>fe,detectTimeOfDay:()=>he,detectTrafficSource:()=>me,grantConsent:()=>dn,init:()=>it,isDoNotTrackEnabled:()=>Ue,matchedAgentToken:()=>Me,readSnapshot:()=>Oe,referrerDomainFromReferer:()=>ye,renderPrePaintScript:()=>qe,toWireSlot:()=>Se,uaTokenMatch:()=>ge,writeSnapshot:()=>ie});module.exports=ht(pn);function xe(){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 we(e){return e?`_${e.slice(0,12)}`:""}var St="_snt_uid",vt=365,xt="_snt_uid";function wt(){return xe()}function bt(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(c){}}function Et(e){try{return localStorage.getItem(e)}catch(t){return null}}function It(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Ct(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function _t(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function At(e){try{sessionStorage.removeItem(e)}catch(t){}}function Ot(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 Tt(e){try{localStorage.removeItem(e)}catch(t){}}function Rt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Bt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function be(e){var y,k,R,_,E,P;if(typeof window=="undefined")return Bt;let t=we(e==null?void 0:e.apiKey),n=(y=e==null?void 0:e.cookieName)!=null?y:`${St}${t}`,c=`${xt}${t}`,s=((k=e==null?void 0:e.cookieTTLDays)!=null?k:vt)*24*60*60,p=C=>C&&C.length>0?C:null,d=(P=(E=(_=(R=p(bt(n)))!=null?R:p(Et(c)))!=null?_:p(Ct(c)))!=null?E:p(e==null?void 0:e.ssrSessionId))!=null?P:wt();kt(n,d,s);let r=It(c,d),o=Ot(n),i=r?!1:_t(c,d),a=!r&&!o&&!i;return{getSessionId:()=>d,isEphemeral:()=>a,destroy:()=>{d=null,Rt(n),Tt(c),At(c)}}}function ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ke(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 Ee(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(e),c.slice(-t)):[]}catch(n){return[]}}function oe(e,t,n){try{let c=(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let p=JSON.parse(s);return Array.isArray(p)?p:[]}catch(s){return[]}})(),u=new Map;for(let s of c)u.set(s.id,s);for(let s of e)u.set(s.id,s);localStorage.setItem(n,JSON.stringify([...u.values()].slice(-t)))}catch(c){}}function Ie(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let u=new Set(e),s=c.filter(p=>!u.has(p.id));if(s.length===c.length)return;s.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(s))}catch(n){}}var Lt=500,Dt=56*1024;function De(e){return`_snt_retry_${e.slice(0,12)}`}var Pt={push:()=>{},flush:()=>{},destroy:()=>{}};function He(e){var B,j,H;if(typeof window=="undefined")return Pt;let t=(B=e.flushIntervalMs)!=null?B:5e3,n=(j=e.maxBatchSize)!=null?j:20,c=(H=e.maxRetrySize)!=null?H:100,u=e.ingestUrl,s=e.apiKey,p=De(s),d=[],r=new Set,o=[],i=f=>{for(let S of f)a.delete(S),!r.has(S)&&(r.add(S),o.push(S));for(;o.length>Lt;){let S=o.shift();S&&r.delete(S)}Ie(f,p)},a=new Set,y=f=>{r.has(f.id)||a.has(f.id)||(a.add(f.id),d.push(f))},k=f=>{for(let S of f)r.has(S.id)||(a.add(S.id),d.push(S))},R=Ee(p,c);for(let f of R)y(f);let _=0,E=0,P=(f,S=!0)=>{if(f.length===0)return;let z=JSON.stringify(f),q=f.map(J=>J.id),$;try{$=fetch(u,{method:"POST",keepalive:!0,body:z,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(J){oe(f,c,p),k(f),E++,_=Date.now()+ne(E);return}let ae=J=>{if(ke(J)!=="retry"){if(!J.ok&&S){let ee=f.filter(V=>V.eventType!=="pageview");if(ee.length>0&&ee.length<f.length){i(f.filter(V=>V.eventType==="pageview").map(V=>V.id)),P(ee,!1);return}}i(q),E=0,_=0;return}oe(f,c,p),k(f),E++,_=Date.now()+ne(E)};$ instanceof Promise?$.then(ae).catch(()=>{oe(f,c,p),k(f),E++,_=Date.now()+ne(E)}):ae($)},C=typeof TextEncoder!="undefined"?new TextEncoder:null,I=f=>C?C.encode(f).length:f.length,Y=f=>{let S=[],z=2;for(let q of f){let $=I(JSON.stringify(q))+1;if(S.length>0&&z+$>Dt||S.length>=n)break;S.push(q),z+=$}return S},A=()=>{try{if(Date.now()<_)return;for(;d.length>0&&!(Date.now()<_);){let f=d.filter(z=>!r.has(z.id));if(d.length=0,f.length===0)break;let S=Y(f);if(S.length===0)break;S.length<f.length&&d.push(...f.slice(S.length)),P(S)}}catch(f){}},m=!0,x=null;x=setInterval(()=>{m&&A()},t);let Q=()=>{document.visibilityState==="hidden"&&A()},K=()=>{A()};return document.addEventListener("visibilitychange",Q),window.addEventListener("pagehide",K),{push(f){y(f),d.length>=n&&A()},flush:A,destroy(){m=!1,x!==null&&(clearInterval(x),x=null),document.removeEventListener("visibilitychange",Q),window.removeEventListener("pagehide",K),A()}}}var Mt=200;function Pe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Kt={send:()=>{},flush:()=>{},destroy:()=>{}};function ze(e){var I,Y,A;if(typeof window=="undefined")return Kt;let t=(I=e.flushIntervalMs)!=null?I:5e3,n=(Y=e.maxRetrySize)!=null?Y:100,c=(A=e.maxPerFlush)!=null?A:5,u=Pe(e.apiKey),s=[],p=new Set,d=new Set,r=[],o=0,i=0,a=!1,y=m=>{for(p.delete(m.id),d.has(m.id)||(d.add(m.id),r.push(m.id));r.length>Mt;){let x=r.shift();x&&d.delete(x)}Ie([m.id],u)},k=m=>{oe([m],n,u),!d.has(m.id)&&!p.has(m.id)&&(p.add(m.id),s.push(m)),i++,o=Date.now()+ne(i)},R=m=>{let x;try{x=fetch(e.url,{method:"POST",keepalive:!0,body:m.body,headers:e.headers})}catch(K){k(m);return}let Q=K=>{var j;let B=ke(K);if(B==="retry"){k(m);return}B==="dropped"&&((j=e.onDrop)==null||j.call(e,m,K.status)),y(m),i=0,o=0};x instanceof Promise?x.then(Q).catch(()=>k(m)):Q(x)},_=()=>{try{if(a||Date.now()<o)return;let m=0;for(;s.length>0&&m<c&&!(Date.now()<o);){let x=s.shift();p.delete(x.id),!d.has(x.id)&&(m++,R(x))}}catch(m){}};for(let m of Ee(u,n))p.has(m.id)||(p.add(m.id),s.push(m));let E=setInterval(_,t),P=()=>{document.visibilityState==="hidden"&&_()},C=()=>_();return document.addEventListener("visibilitychange",P),window.addEventListener("pagehide",C),{send(m){if(!a&&!(d.has(m.id)||p.has(m.id))){if(Date.now()<o){p.add(m.id),s.push(m);return}R(m)}},flush:_,destroy(){clearInterval(E),document.removeEventListener("visibilitychange",P),window.removeEventListener("pagehide",C),_(),a=!0}}}var Nt=1800*1e3;function Ce(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Qe(e=Nt,t){let n=new Map,c=`_snt_asgn${we(t)}_`,u=(o,i)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(i)}`,s=o=>{let i=o.slice(c.length),a=i.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,a)),segment:decodeURIComponent(i.slice(a+1))}}catch(y){return null}},p=()=>{try{let o=[];for(let i=0;i<localStorage.length;i++){let a=localStorage.key(i);a!=null&&a.startsWith(c)&&o.push(a)}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 p())try{let i=localStorage.getItem(o);if(!i)continue;let a=JSON.parse(i);if(d(a)){localStorage.removeItem(o);continue}let y=s(o);if(!y)continue;n.set(Ce(y.componentId,y.segment),a)}catch(i){}})(),{get(o,i){let a=n.get(Ce(o,i));return a?d(a)?(n.delete(Ce(o,i)),null):a:null},set(o,i,a){let y=Ce(o,i);n.set(y,a);try{localStorage.setItem(u(o,i),JSON.stringify(a))}catch(k){}},invalidate(o){let i=`${encodeURIComponent(o)}:`;for(let a of[...n.keys()])a.startsWith(i)&&n.delete(a);for(let a of p()){let y=s(a);if((y==null?void 0:y.componentId)===o)try{localStorage.removeItem(a)}catch(k){}}},clear(){n.clear();for(let o of p())try{localStorage.removeItem(o)}catch(i){}}}}var pe=["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 ge(e){return Me(e)!==null}function Me(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=pe.find(c=>t.includes(c.toLowerCase())))!=null?n:null}var _e={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Je(e){if(!e)return"other";let t=pe.find(n=>n.toLowerCase()===e.toLowerCase());return t&&_e[t]||"other"}function Ve(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of pe)e[(t=_e[n])!=null?t:"other"].push(n);return e}function fe(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function me(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 c=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(c)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(c)?"social":"referral"}catch(n){return"direct"}}function ye(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function he(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Xe(e){let t=Gt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Gt(e,t){var s,p,d,r,o,i,a;let n=(p=(s=t==null?void 0:t.userAgent)==null?void 0:s.trim())!=null?p:"",c=(r=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?r:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(i=t==null?void 0:t.utmParams)!=null?i:{},deviceClass:n?fe(n):"desktop",trafficSource:c?me(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:ye(c),timeOfDay:he(u),dayOfWeek:(a=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?a:"sun",automation:(t==null?void 0:t.webdriver)===!0||ge(n)}}var re=require("@sentientui/policy");function Se(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 se(e){let t=Se(e);return(0,re.slotResultFor)(t,(0,re.slotBaselineArm)(t))}function Ye(e){let t={};for(let n of e)t[n.id]=se(n);return t}function Ae(e){return typeof e=="string"?e:(0,re.canonicalArm)(e)}var Z="_snt_snap:",Ut=["low","medium","high"];function Oe(e){try{let t=localStorage.getItem(Z+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"||!Ut.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 ie(e,t){try{localStorage.setItem(Z+e,JSON.stringify(t))}catch(n){}}function qe(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(Z+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var Ge=require("@sentientui/policy");var Re=require("@sentientui/policy");var Be="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ke="[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.",Ze=!1,Te=!1;function $t(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function et(e){var d;let t=be({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(d=t.getSessionId())!=null?d:"local",c=$t(),u=import("@sentientui/core/local").then(r=>{let o=r;return o.LOCAL_ENGINE_AVAILABLE?(Ze||(Ze=!0,console.info(Ke)),o):(Te||(Te=!0,console.error(Be)),null)}).catch(()=>(Te||(Te=!0,console.error(Be)),null)),s=null;function p(r){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=r.persona,o.dataset.sentientConfidence=(0,Re.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var a,y,k;let o=await u;if(!o)return null;let i=o.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return s=te(b({},i),{layoutOrder:(y=(a=i.layoutOrder)!=null?a:s==null?void 0:s.layoutOrder)!=null?y:null,slots:b(b({},(k=s==null?void 0:s.slots)!=null?k:{}),i.slots)}),ie(e.apiKey||"local",{v:1,persona:s.persona,band:(0,Re.confidenceBand)(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),p(i),i},getSlotResult(r){var o,i,a;return(a=(i=s==null?void 0:s.slots[r])!=null?i:(o=e.initialSlots)==null?void 0:o[r])!=null?a:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:(0,Re.confidenceBand)(s.confidence)}:null},async assign(r,o){var y;let i=await u;return!i||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(y=i.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:o}]}).assignments[r])!=null?y:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Ft=["none","sm","md","lg"],Wt=["start","center","end","stretch"],jt=["start","center","end","between"],Ht=["sm","md","lg"],zt=["normal","medium","bold"],Qt=["default","muted","accent"],Jt=["primary","secondary","ghost"],Vt=["left","center","right"],Xt=["auto","square","landscape","wide"],Yt=["cover","contain"],qt=[2,3,4],Zt=[2,3,4],en=64,tn=5,nn=12,on=4,rn=500;function tt(e,t,n,c){let u=[];{let d=!1,r=[],o=()=>{if(d)return;let i=Date.now();for(r.push(i);r.length>0&&i-r[0]>500;)r.shift();r.length>=3&&(d=!0,e("rage_click"))};t.addEventListener("click",o),u.push(()=>t.removeEventListener("click",o))}{let s=!1,p=d=>{if(s||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;s=!0;let r=typeof window!="undefined"?window.getSelection():null,o=r?r.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",p),u.push(()=>document.removeEventListener("copy",p))}{let s=!1,p=!1,d=null,r=()=>{d!==null&&(clearTimeout(d),d=null)},o=()=>{s||!p||(r(),d=setTimeout(()=>{!s&&p&&(s=!0,e("scroll_hesitation"))},3e3))},i=()=>{r(),o()},a=k=>{for(let R of k)p=R.intersectionRatio>.3,p?o():r()},y=new IntersectionObserver(a,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",i,{passive:!0}),u.push(()=>{y.disconnect(),window.removeEventListener("scroll",i),r()})}if((c==null?void 0:c.tabLoss)!==!1){let s=!1,p=n!=null?n:Date.now(),d=()=>{if(s||document.visibilityState!=="hidden")return;let r=Date.now()-p;r<15e3&&(s=!0,e("tab_loss",{timeOnPage:r}))};document.addEventListener("visibilitychange",d),u.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let s of u)s()}}var nt="https://api.sentient-ui.com/v1/events",D=new Map,ot=null;function sn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Ne(){return xe()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function an(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 rt=new Set;function ln(e,t,n){let c=typeof window=="undefined"?null:window.history;if(!c)return()=>{};let u=!1,s,p=()=>{if(u)return;let o=Le();!o||o===s||(s=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},d=[];for(let o of["pushState","replaceState"]){let i=c[o],a=function(...y){let k=i.apply(this,y);return p(),k};c[o]=a,d.push([o,i,a])}window.addEventListener("popstate",p);let r=Le();return r&&rt.has(`${t}:${r}`)?s=r:p(),()=>{if(!u){u=!0,window.removeEventListener("popstate",p);for(let[o,i,a]of d)c[o]===a&&(c[o]=i)}}}var ve={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 cn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,c]of t)n.startsWith("utm_")&&(e[n]=c);return e}catch(e){return{}}}function st(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 dn(e){var d;if(typeof window=="undefined")return;let t=e!=null?e:ot;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=D.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:u}=n;if(!u||c.respectDoNotTrack!==!1&&Ue())return;let s=it(te(b({},c),{consent:!0}));u(s);let p=(d=D.get(t))==null?void 0:d.dispose;D.set(t,{config:te(b({},c),{consent:!0}),upgrade:null,dispose:p})}function un(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=st((d=e.ingestUrl)!=null?d:nt),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,i){if(!t)return null;try{let a=new URLSearchParams({componentId:r});for(let R of o!=null?o:[])a.append("variantIds[]",R);let y=await fetch(`${n}/winner?${a.toString()}`,{headers:c});return y.ok?{variantId:(await y.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(a){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:()=>{}},s={track:r=>u.track(r),goal:((r,o,i,a)=>u.goal(r,o,i,a)),componentGoal:(r,o,i)=>u.componentGoal(r,o,i),identify:r=>u.identify(r),getAssignment:(r,o)=>u.getAssignment(r,o),assign:(r,o,i,a)=>u.assign(r,o,i,a),decide:r=>u.decide(r),getSlotResult:r=>u.getSlotResult(r),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function p(r){u=r}return{proxy:s,setInner:p}}function it(e){var f,S,z,q,$,ae,J,ee,V;if(typeof window=="undefined")return ve;ot=e.apiKey;let t=D.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(l){}let n=e.respectDoNotTrack!==!1&&Ue(),c=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return c?(D.set(e.apiKey||"local",{config:e,upgrade:null}),ve):(D.set(e.apiKey||"local",{config:e,upgrade:null}),et(e));if(c){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."),D.set(e.apiKey,{config:e,upgrade:null}),ve;let{proxy:l,setInner:g}=un(e);return D.set(e.apiKey,{config:e,upgrade:n?null:g}),l}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."),ve;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ve;let s=(f=e.ingestUrl)!=null?f:nt,p=Date.now(),d=be({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=Qe(void 0,e.apiKey),o=He({ingestUrl:s,apiKey:e.apiKey}),i=st(s),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},y=ze({url:`${i}/goals`,apiKey:e.apiKey,headers:a,onDrop:(l,g)=>{e.debug&&console.warn(`[sentient] goal dropped (HTTP ${g}) \u2014 this will not be retried. `+(g===400?"The session was not found: call init() and let the session upsert complete before firing goals.":g===401||g===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),l)}}),k=fe((S=navigator.userAgent)!=null?S:""),R=typeof window!="undefined"?window.location.origin:void 0,_=me((z=document.referrer)!=null?z:"",R),E=(q=e.sessionSegment)!=null?q:`${k}:${_}`,P=new Map,C=new Map,I=null,Y=l=>{for(let g of l)C.has(g.id)||C.set(g.id,se(g))};if(e.initialSlots)for(let[l,g]of Object.entries(e.initialSlots))C.set(l,g);let A=Oe(e.apiKey);if(A)for(let[l,g]of Object.entries(A.slots))C.has(l)||C.set(l,g);let m={low:.15,medium:.5,high:.85};if(e.initialPersona)I=b({},e.initialPersona);else{let l=document.documentElement.dataset;l.sentientPersona?I={persona:l.sentientPersona,confidence:(ae=m[($=l.sentientConfidence)!=null?$:"low"])!=null?ae:.15}:A&&(I={persona:A.persona,confidence:(J=m[A.band])!=null?J:.15})}if(e.initialAssignments)for(let[l,g]of Object.entries(e.initialAssignments))r.set(l,E,{variantId:g,assignedAt:Date.now(),segment:E,confidence:1});let x=Promise.resolve(),Q=d.getSessionId();if(Q){let l=ye((ee=document.referrer)!=null?ee:""),g=b(b(b({sessionId:Q,deviceClass:k,trafficSource:_,referrerDomain:l,utmParams:cn(),timeOfDay:he(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||ge((V=navigator.userAgent)!=null?V:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{});try{x=fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(g),headers:a}).then(h=>{h.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(h){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let K=new Set,B=null,j=!1,H={goal(l,g={},h=1,N=0){var T,le,U,ce,v,X;let L=d.getSessionId();if(!L)return;let w=sn(g)?g:{metadata:g},F=`${l}\0${(T=w.externalId)!=null?T:""}\0${(le=w.stepIndex)!=null?le:N}\0${(U=w.weight)!=null?U:h}`;if(K.has(F)){e.debug&&console.log(`[sentient] goal("${l}") already recorded for this action \u2014 not sent twice`);return}K.add(F),K.size===1&&an(K);let G=Ne(),O={sessionId:L,name:l,metadata:(ce=w.metadata)!=null?ce:{},weight:(v=w.weight)!=null?v:h,stepIndex:(X=w.stepIndex)!=null?X:N,goalId:G,value:w.value,currency:w.currency,externalId:w.externalId};e.debug&&console.log("[sentient] goal",O);let W={id:G,body:JSON.stringify(O)};x.then(()=>y.send(W))},componentGoal(l,g,h){var O,W,T;let N=d.getSessionId();if(!N)return;let L=r.get(l,E),w=L?null:(O=C.get(l))!=null?O:null;if(!L&&w===null){e.debug&&console.warn(`[sentient] componentGoal("${l}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let F=L?L.variantId:Ae(w),G={id:Ne(),sessionId:N,projectId:e.apiKey,componentId:l,variantId:F,eventType:"goal_achieved",goalType:g,payload:b({reward:(W=h==null?void 0:h.reward)!=null?W:1,goalValue:h==null?void 0:h.value,currency:h==null?void 0:h.currency},(T=h==null?void 0:h.metadata)!=null?T:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:Le()};e.debug&&console.log("[sentient] componentGoal",G),x.then(()=>o.push(G))},identify(l){let g=d.getSessionId();g&&x.then(()=>{fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:g,userId:l,ephemeral:d.isEphemeral()}),headers:a}).catch(()=>{})})},track(l){let g=d.getSessionId();if(!g)return;let h=te(b({path:Le()},l),{id:Ne(),sessionId:g,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",h),x.then(()=>o.push(h))},getAssignment(l,g){return r.get(l,g)},async assign(l,g,h,N){let L=d.getSessionId();if(!L)return null;let w=r.get(l,E);if(w&&(g!=null&&g.length||w.content!==void 0)){let O=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:O,content:w.content}}let F=P.get(l);if(F)return F;let G=(async()=>{await x;try{let O={sessionId:L,componentId:l,variantIds:g};N!==void 0?O.agentDataByVariant=N:h!==void 0&&(O.agentData=h);let W=await fetch(`${i}/assign`,{method:"POST",body:JSON.stringify(O),headers:a});if(!W.ok)return null;let T=await W.json();return r.set(l,E,b({variantId:T.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:T.content},T.assignmentTtlMs&&T.assignmentTtlMs>0?{ttlMs:T.assignmentTtlMs}:{})),T}catch(O){return null}finally{P.delete(l)}})();return P.set(l,G),G},async decide(l){var N,L,w,F,G,O,W,T,le;let g=d.getSessionId();if(!g)return null;let h=(N=l.slots)!=null?N:[];await x;try{let U={sessionId:g};l.sections&&l.sections.length>0&&(U.sections=l.sections.map(M=>({id:M}))),U.components=(L=l.components)!=null?L:[],h.length>0&&(U.slots=h.map(Se)),l.slotsFrom==="registry"&&(U.slotsFrom="registry"),l.v&&(U.v=l.v),e.persona&&(U.persona=e.persona);let ce=await fetch(`${i}/decide`,{method:"POST",body:JSON.stringify(U),headers:a});if(!ce.ok)return Y(h),null;let v=await ce.json(),X={};for(let M of h)X[M.id]=(F=(w=v.slots)==null?void 0:w[M.id])!=null?F:se(M);if(v.slots)for(let[M,de]of Object.entries(v.slots))M in X||(X[M]=de);for(let[M,de]of Object.entries(X))C.set(M,de);let at=I!=null&&I.persona!=="unknown";v.persona&&!(v.persona==="unknown"&&at)?I={persona:v.persona,confidence:(G=v.confidence)!=null?G:0}:I||(I={persona:"unknown",confidence:0});for(let[M,de]of Object.entries((O=v.assignments)!=null?O:{}))r.set(M,E,{variantId:de,assignedAt:Date.now(),segment:E,confidence:1});return ie(e.apiKey,b(b({v:1,persona:I.persona,band:(0,Ge.confidenceBand)(I.confidence),slots:Object.fromEntries(C),layoutOrder:(W=v.layoutOrder)!=null?W:null,savedAt:Date.now()},v.slotConfig?{slotConfig:v.slotConfig}:{}),v.palette?{palette:v.palette}:{})),b(b(b(b({layoutOrder:(T=v.layoutOrder)!=null?T:null,assignments:(le=v.assignments)!=null?le:{},slots:X,persona:I.persona,confidence:I.confidence},v.slotConfig?{slotConfig:v.slotConfig}:{}),v.goals?{goals:v.goals}:{}),v.sectionMap?{sectionMap:v.sectionMap}:{}),v.palette?{palette:v.palette}:{})}catch(U){return Y(h),null}},getSlotResult(l){var g;return(g=C.get(l))!=null?g:null},getPersona(){return I?{persona:I.persona,confidence:I.confidence,band:(0,Ge.confidenceBand)(I.confidence)}:null},async fetchWeights(){var l;try{let g=await fetch(`${i}/weights`,{headers:a});return g.ok?(l=(await g.json()).components)!=null?l:[]:[]}catch(g){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var l;B==null||B(),j=!0,o.destroy(),y.destroy(),((l=D.get(e.apiKey))==null?void 0:l.dispose)===H.dispose&&D.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var l;B==null||B(),j=!0,o.destroy(),y.destroy(),d.destroy(),((l=D.get(e.apiKey))==null?void 0:l.dispose)===H.dispose&&D.delete(e.apiKey);try{localStorage.removeItem(Z+e.apiKey),localStorage.removeItem(De(e.apiKey)),localStorage.removeItem(Pe(e.apiKey))}catch(g){}e.debug&&console.log("[sentient] destroyed")}};if(D.set(e.apiKey,{config:e,upgrade:null,dispose:H.dispose}),B=ln(H,e.apiKey,l=>{x.then(()=>{j||rt.add(l)})}),e.debug){let l=window;l.__sentient&&(l.__sentient.client=H)}return H}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
1
+ "use strict";var ct=Object.create;var pe=Object.defineProperty,dt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,Fe=Object.getOwnPropertySymbols,ft=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var We=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))je.call(t,n)&&We(e,n,t[n]);if(Fe)for(var n of Fe(t))mt.call(t,n)&&We(e,n,t[n]);return e},oe=(e,t)=>dt(e,pt(t));var yt=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},He=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of gt(t))!je.call(e,u)&&u!==n&&pe(e,u,{get:()=>t[u],enumerable:!(c=ut(t,u))||c.enumerable});return e};var ht=(e,t,n)=>(n=e!=null?ct(ft(e)):{},He(t||!e||!e.__esModule?pe(n,"default",{value:e,enumerable:!0}):n,e)),St=e=>He(pe({},"__esModule",{value:!0}),e);var fn={};yt(fn,{AGENT_INTENTS:()=>_e,BLOCK_ALIGNS:()=>jt,BLOCK_EMPHASES:()=>Vt,BLOCK_FITS:()=>qt,BLOCK_GAPS:()=>Wt,BLOCK_GRID_COLUMNS:()=>Zt,BLOCK_HEADING_LEVELS:()=>en,BLOCK_JUSTIFIES:()=>Ht,BLOCK_RATIOS:()=>Yt,BLOCK_SIZES:()=>zt,BLOCK_TEXT_ALIGNS:()=>Xt,BLOCK_TONES:()=>Jt,BLOCK_WEIGHTS:()=>Qt,LOCAL_MODE_BANNER:()=>Ke,MAX_BLOCK_ARMS:()=>rn,MAX_BLOCK_CHILDREN:()=>on,MAX_BLOCK_DEPTH:()=>nn,MAX_BLOCK_NODES:()=>tn,MAX_BLOCK_TEXT_LEN:()=>sn,PROD_KEYLESS_ERROR:()=>Be,SNAPSHOT_STORAGE_KEY_PREFIX:()=>te,agentIntent:()=>Ve,agentUaList:()=>ge,armOfResult:()=>Ae,attachMicroSignalDetectors:()=>nt,baselineResultFor:()=>ie,baselineSlots:()=>qe,classifiedAgents:()=>Xe,deriveSessionSegment:()=>Ye,detectDeviceClass:()=>me,detectTimeOfDay:()=>Se,detectTrafficSource:()=>ye,grantConsent:()=>pn,init:()=>at,isDoNotTrackEnabled:()=>Ue,matchedAgentToken:()=>Me,readSnapshot:()=>Te,referrerDomainFromReferer:()=>he,renderPrePaintScript:()=>Ze,toWireSlot:()=>ve,uaTokenMatch:()=>fe,writeSnapshot:()=>ae});module.exports=St(fn);function we(){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 be(e){return e?`_${e.slice(0,12)}`:""}var vt="_snt_uid",xt=365,wt="_snt_uid";function bt(){return we()}function kt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Et(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function It(e){try{return localStorage.getItem(e)}catch(t){return null}}function Ct(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 At(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Tt(e){try{sessionStorage.removeItem(e)}catch(t){}}function Ot(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 Rt(e){try{localStorage.removeItem(e)}catch(t){}}function Bt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Dt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ke(e){var y,x,B,C,_,A;if(typeof window=="undefined")return Dt;let t=be(e==null?void 0:e.apiKey),n=(y=e==null?void 0:e.cookieName)!=null?y:`${vt}${t}`,c=`${wt}${t}`,s=((x=e==null?void 0:e.cookieTTLDays)!=null?x:xt)*24*60*60,p=L=>L&&L.length>0?L:null,d=(A=(_=(C=(B=p(kt(n)))!=null?B:p(It(c)))!=null?C:p(_t(c)))!=null?_:p(e==null?void 0:e.ssrSessionId))!=null?A:bt();Et(n,d,s);let r=Ct(c,d),o=Ot(n),i=r?!1:At(c,d),a=!r&&!o&&!i;return{getSessionId:()=>d,isEphemeral:()=>a,destroy:()=>{d=null,Bt(n),Rt(c),Tt(c)}}}function q(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 Ee(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(e),c.slice(-t)):[]}catch(n){return[]}}function Z(e,t,n){try{let c=(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let p=JSON.parse(s);return Array.isArray(p)?p:[]}catch(s){return[]}})(),u=new Map;for(let s of c)u.set(s.id,s);for(let s of e)u.set(s.id,s);localStorage.setItem(n,JSON.stringify([...u.values()].slice(-t)))}catch(c){}}function Ie(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let u=new Set(e),s=c.filter(p=>!u.has(p.id));if(s.length===c.length)return;s.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(s))}catch(n){}}var Lt=500,Pt=56*1024;function Le(e){return`_snt_retry_${e.slice(0,12)}`}var Mt={push:()=>{},flush:()=>{},destroy:()=>{}};function ze(e){var U,P,z;if(typeof window=="undefined")return Mt;let t=(U=e.flushIntervalMs)!=null?U:5e3,n=(P=e.maxBatchSize)!=null?P:20,c=(z=e.maxRetrySize)!=null?z:100,u=e.ingestUrl,s=e.apiKey,p=Le(s),d=[],r=new Set,o=[],i=f=>{for(let S of f)a.delete(S),!r.has(S)&&(r.add(S),o.push(S));for(;o.length>Lt;){let S=o.shift();S&&r.delete(S)}Ie(f,p)},a=new Set,y=f=>{r.has(f.id)||a.has(f.id)||(a.add(f.id),d.push(f))},x=f=>{for(let S of f)r.has(S.id)||(a.add(S.id),d.push(S))},B=Ee(p,c);for(let f of B)y(f);let C=0,_=0,A=(f,S=!0)=>{if(f.length===0)return;let Q=JSON.stringify(f),ee=f.map(V=>V.id),W;try{W=fetch(u,{method:"POST",keepalive:!0,body:Q,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(V){Z(f,c,p),x(f),_++,C=Date.now()+q(_);return}let le=V=>{if(re(V)!=="retry"){if(!V.ok&&S){let ne=f.filter(X=>X.eventType!=="pageview");if(ne.length>0&&ne.length<f.length){i(f.filter(X=>X.eventType==="pageview").map(X=>X.id)),A(ne,!1);return}}i(ee),_=0,C=0;return}Z(f,c,p),x(f),_++,C=Date.now()+q(_)};W instanceof Promise?W.then(le).catch(()=>{Z(f,c,p),x(f),_++,C=Date.now()+q(_)}):le(W)},L=typeof TextEncoder!="undefined"?new TextEncoder:null,D=f=>L?L.encode(f).length:f.length,E=f=>{let S=[],Q=2;for(let ee of f){let W=D(JSON.stringify(ee))+1;if(S.length>0&&Q+W>Pt||S.length>=n)break;S.push(ee),Q+=W}return S},K=()=>{try{if(Date.now()<C)return;for(;d.length>0&&!(Date.now()<C);){let f=d.filter(Q=>!r.has(Q.id));if(d.length=0,f.length===0)break;let S=E(f);if(S.length===0)break;S.length<f.length&&d.push(...f.slice(S.length)),A(S)}}catch(f){}},G=!0,m=null;m=setInterval(()=>{G&&K()},t);let k=()=>{document.visibilityState==="hidden"&&K()},J=()=>{K()};return document.addEventListener("visibilitychange",k),window.addEventListener("pagehide",J),{push(f){y(f),d.length>=n&&K()},flush:K,destroy(){G=!1,m!==null&&(clearInterval(m),m=null),document.removeEventListener("visibilitychange",k),window.removeEventListener("pagehide",J),K()}}}var Kt=200;function Pe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Nt={send:()=>{},flush:()=>{},destroy:()=>{}};function Qe(e){var E,K,G;if(typeof window=="undefined")return Nt;let t=(E=e.flushIntervalMs)!=null?E:5e3,n=(K=e.maxRetrySize)!=null?K:100,c=(G=e.maxPerFlush)!=null?G:5,u=Pe(e.apiKey),s=[],p=new Set,d=new Set,r=[],o=0,i=0,a=!1,y=m=>{for(p.delete(m.id),d.has(m.id)||(d.add(m.id),r.push(m.id));r.length>Kt;){let k=r.shift();k&&d.delete(k)}Ie([m.id],u)},x=m=>{Z([m],n,u),!d.has(m.id)&&!p.has(m.id)&&(p.add(m.id),s.push(m)),Date.now()>=o&&(i++,o=Date.now()+q(i))},B=m=>{let k;try{k=fetch(e.url,{method:"POST",keepalive:!0,body:m.body,headers:e.headers})}catch(U){x(m);return}let J=U=>{var z;let P=re(U);if(P==="retry"){x(m);return}P==="dropped"&&((z=e.onDrop)==null||z.call(e,m,U.status)),y(m),i=0,o=0};k instanceof Promise?k.then(J).catch(()=>x(m)):J(k)},C=()=>{try{if(a||Date.now()<o)return;let m=0;for(;s.length>0&&m<c&&!(Date.now()<o);){let k=s.shift();p.delete(k.id),!d.has(k.id)&&(m++,B(k))}}catch(m){}},_=Ee(u,n);for(let m of _)p.has(m.id)||(p.add(m.id),s.push(m));_.length>0&&Z(_,n,u);let A=setInterval(C,t),L=()=>{document.visibilityState==="hidden"&&C()},D=()=>C();return document.addEventListener("visibilitychange",L),window.addEventListener("pagehide",D),{send(m){if(!a&&!(d.has(m.id)||p.has(m.id))){if(Date.now()<o){Z([m],n,u),p.add(m.id),s.push(m);return}B(m)}},flush:C,destroy(){clearInterval(A),document.removeEventListener("visibilitychange",L),window.removeEventListener("pagehide",D),C(),a=!0}}}var Gt=1800*1e3;function Ce(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Je(e=Gt,t){let n=new Map,c=`_snt_asgn${be(t)}_`,u=(o,i)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(i)}`,s=o=>{let i=o.slice(c.length),a=i.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,a)),segment:decodeURIComponent(i.slice(a+1))}}catch(y){return null}},p=()=>{try{let o=[];for(let i=0;i<localStorage.length;i++){let a=localStorage.key(i);a!=null&&a.startsWith(c)&&o.push(a)}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 p())try{let i=localStorage.getItem(o);if(!i)continue;let a=JSON.parse(i);if(d(a)){localStorage.removeItem(o);continue}let y=s(o);if(!y)continue;n.set(Ce(y.componentId,y.segment),a)}catch(i){}})(),{get(o,i){let a=n.get(Ce(o,i));return a?d(a)?(n.delete(Ce(o,i)),null):a:null},set(o,i,a){let y=Ce(o,i);n.set(y,a);try{localStorage.setItem(u(o,i),JSON.stringify(a))}catch(x){}},invalidate(o){let i=`${encodeURIComponent(o)}:`;for(let a of[...n.keys()])a.startsWith(i)&&n.delete(a);for(let a of p()){let y=s(a);if((y==null?void 0:y.componentId)===o)try{localStorage.removeItem(a)}catch(x){}}},clear(){n.clear();for(let o of p())try{localStorage.removeItem(o)}catch(i){}}}}var ge=["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 fe(e){return Me(e)!==null}function Me(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ge.find(c=>t.includes(c.toLowerCase())))!=null?n:null}var _e={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Ve(e){if(!e)return"other";let t=ge.find(n=>n.toLowerCase()===e.toLowerCase());return t&&_e[t]||"other"}function Xe(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of ge)e[(t=_e[n])!=null?t:"other"].push(n);return e}function me(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 ye(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 c=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(c)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(c)?"social":"referral"}catch(n){return"direct"}}function he(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function Se(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ye(e){let t=Ut("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Ut(e,t){var s,p,d,r,o,i,a;let n=(p=(s=t==null?void 0:t.userAgent)==null?void 0:s.trim())!=null?p:"",c=(r=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?r:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(i=t==null?void 0:t.utmParams)!=null?i:{},deviceClass:n?me(n):"desktop",trafficSource:c?ye(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:he(c),timeOfDay:Se(u),dayOfWeek:(a=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?a:"sun",automation:(t==null?void 0:t.webdriver)===!0||fe(n)}}var se=require("@sentientui/policy");function ve(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 ie(e){let t=ve(e);return(0,se.slotResultFor)(t,(0,se.slotBaselineArm)(t))}function qe(e){let t={};for(let n of e)t[n.id]=ie(n);return t}function Ae(e){return typeof e=="string"?e:(0,se.canonicalArm)(e)}var te="_snt_snap:",$t=["low","medium","high"];function Te(e){try{let t=localStorage.getItem(te+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"||!$t.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 ae(e,t){try{localStorage.setItem(te+e,JSON.stringify(t))}catch(n){}}function Ze(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(te+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var Ge=require("@sentientui/policy");var Re=require("@sentientui/policy");var Be="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ke="[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.",et=!1,Oe=!1;function Ft(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function tt(e){var d;let t=ke({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(d=t.getSessionId())!=null?d:"local",c=Ft(),u=import("@sentientui/core/local").then(r=>{let o=r;return o.LOCAL_ENGINE_AVAILABLE?(et||(et=!0,console.info(Ke)),o):(Oe||(Oe=!0,console.error(Be)),null)}).catch(()=>(Oe||(Oe=!0,console.error(Be)),null)),s=null;function p(r){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=r.persona,o.dataset.sentientConfidence=(0,Re.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var a,y,x;let o=await u;if(!o)return null;let i=o.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return s=oe(b({},i),{layoutOrder:(y=(a=i.layoutOrder)!=null?a:s==null?void 0:s.layoutOrder)!=null?y:null,slots:b(b({},(x=s==null?void 0:s.slots)!=null?x:{}),i.slots)}),ae(e.apiKey||"local",{v:1,persona:s.persona,band:(0,Re.confidenceBand)(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),p(i),i},getSlotResult(r){var o,i,a;return(a=(i=s==null?void 0:s.slots[r])!=null?i:(o=e.initialSlots)==null?void 0:o[r])!=null?a:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:(0,Re.confidenceBand)(s.confidence)}:null},async assign(r,o){var y;let i=await u;return!i||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(y=i.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:o}]}).assignments[r])!=null?y:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var Wt=["none","sm","md","lg"],jt=["start","center","end","stretch"],Ht=["start","center","end","between"],zt=["sm","md","lg"],Qt=["normal","medium","bold"],Jt=["default","muted","accent"],Vt=["primary","secondary","ghost"],Xt=["left","center","right"],Yt=["auto","square","landscape","wide"],qt=["cover","contain"],Zt=[2,3,4],en=[2,3,4],tn=64,nn=5,on=12,rn=4,sn=500;function nt(e,t,n,c){let u=[];{let d=!1,r=[],o=()=>{if(d)return;let i=Date.now();for(r.push(i);r.length>0&&i-r[0]>500;)r.shift();r.length>=3&&(d=!0,e("rage_click"))};t.addEventListener("click",o),u.push(()=>t.removeEventListener("click",o))}{let s=!1,p=d=>{if(s||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;s=!0;let r=typeof window!="undefined"?window.getSelection():null,o=r?r.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",p),u.push(()=>document.removeEventListener("copy",p))}{let s=!1,p=!1,d=null,r=()=>{d!==null&&(clearTimeout(d),d=null)},o=()=>{s||!p||(r(),d=setTimeout(()=>{!s&&p&&(s=!0,e("scroll_hesitation"))},3e3))},i=()=>{r(),o()},a=x=>{for(let B of x)p=B.intersectionRatio>.3,p?o():r()},y=new IntersectionObserver(a,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",i,{passive:!0}),u.push(()=>{y.disconnect(),window.removeEventListener("scroll",i),r()})}if((c==null?void 0:c.tabLoss)!==!1){let s=!1,p=n!=null?n:Date.now(),d=()=>{if(s||document.visibilityState!=="hidden")return;let r=Date.now()-p;r<15e3&&(s=!0,e("tab_loss",{timeOnPage:r}))};document.addEventListener("visibilitychange",d),u.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let s of u)s()}}var ot="https://api.sentient-ui.com/v1/events",M=new Map,rt=null;function an(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var ln=3;function Ne(){return we()}function De(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function cn(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 st=new Set;function dn(e,t,n){let c=typeof window=="undefined"?null:window.history;if(!c)return()=>{};let u=!1,s,p=()=>{if(u)return;let o=De();!o||o===s||(s=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},d=[];for(let o of["pushState","replaceState"]){let i=c[o],a=function(...y){let x=i.apply(this,y);return p(),x};c[o]=a,d.push([o,i,a])}window.addEventListener("popstate",p);let r=De();return r&&st.has(`${t}:${r}`)?s=r:p(),()=>{if(!u){u=!0,window.removeEventListener("popstate",p);for(let[o,i,a]of d)c[o]===a&&(c[o]=i)}}}var xe={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function un(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,c]of t)n.startsWith("utm_")&&(e[n]=c);return e}catch(e){return{}}}function it(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 pn(e){var d;if(typeof window=="undefined")return;let t=e!=null?e:rt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=M.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:u}=n;if(!u||c.respectDoNotTrack!==!1&&Ue())return;let s=at(oe(b({},c),{consent:!0}));u(s);let p=(d=M.get(t))==null?void 0:d.dispose;M.set(t,{config:oe(b({},c),{consent:!0}),upgrade:null,dispose:p})}function gn(e){var d;let t=e.preConsentBehavior==="statistical_winner",n=it((d=e.ingestUrl)!=null?d:ot),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,i){if(!t)return null;try{let a=new URLSearchParams({componentId:r});for(let B of o!=null?o:[])a.append("variantIds[]",B);let y=await fetch(`${n}/winner?${a.toString()}`,{headers:c});return y.ok?{variantId:(await y.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(a){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:()=>{}},s={track:r=>u.track(r),goal:((r,o,i,a)=>u.goal(r,o,i,a)),componentGoal:(r,o,i)=>u.componentGoal(r,o,i),identify:r=>u.identify(r),getAssignment:(r,o)=>u.getAssignment(r,o),assign:(r,o,i,a)=>u.assign(r,o,i,a),decide:r=>u.decide(r),getSlotResult:r=>u.getSlotResult(r),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function p(r){u=r}return{proxy:s,setInner:p}}function at(e){var S,Q,ee,W,le,V,ne,X,$e;if(typeof window=="undefined")return xe;rt=e.apiKey;let t=M.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(l){}let n=e.respectDoNotTrack!==!1&&Ue(),c=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return c?(M.set(e.apiKey||"local",{config:e,upgrade:null}),xe):(M.set(e.apiKey||"local",{config:e,upgrade:null}),tt(e));if(c){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."),M.set(e.apiKey,{config:e,upgrade:null}),xe;let{proxy:l,setInner:g}=gn(e);return M.set(e.apiKey,{config:e,upgrade:n?null:g}),l}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."),xe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),xe;let s=(S=e.ingestUrl)!=null?S:ot,p=Date.now(),d=ke({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=Je(void 0,e.apiKey),o=ze({ingestUrl:s,apiKey:e.apiKey}),i=it(s),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},y=new Set,x=Qe({url:`${i}/goals`,apiKey:e.apiKey,headers:a,onDrop:(l,g)=>{if(!e.debug){if(y.has(g))return;y.add(g)}console.warn(`[sentient] goal dropped (HTTP ${g}) \u2014 this will not be retried. `+(g===400?"The session was not found: call init() and let the session upsert complete before firing goals.":g===401||g===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),l)}}),B=me((Q=navigator.userAgent)!=null?Q:""),C=typeof window!="undefined"?window.location.origin:void 0,_=ye((ee=document.referrer)!=null?ee:"",C),A=(W=e.sessionSegment)!=null?W:`${B}:${_}`,L=new Map,D=new Map,E=null,K=l=>{for(let g of l)D.has(g.id)||D.set(g.id,ie(g))};if(e.initialSlots)for(let[l,g]of Object.entries(e.initialSlots))D.set(l,g);let G=Te(e.apiKey);if(G)for(let[l,g]of Object.entries(G.slots))D.has(l)||D.set(l,g);let m={low:.15,medium:.5,high:.85};if(e.initialPersona)E=b({},e.initialPersona);else{let l=document.documentElement.dataset;l.sentientPersona?E={persona:l.sentientPersona,confidence:(V=m[(le=l.sentientConfidence)!=null?le:"low"])!=null?V:.15}:G&&(E={persona:G.persona,confidence:(ne=m[G.band])!=null?ne:.15})}if(e.initialAssignments)for(let[l,g]of Object.entries(e.initialAssignments))r.set(l,A,{variantId:g,assignedAt:Date.now(),segment:A,confidence:1});let k=Promise.resolve(),J=d.getSessionId();if(J){let l=he((X=document.referrer)!=null?X:""),g=b(b(b({sessionId:J,deviceClass:B,trafficSource:_,referrerDomain:l,utmParams:un(),timeOfDay:Se(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||fe(($e=navigator.userAgent)!=null?$e:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),h=async()=>{for(let T=0;;T++){try{let I=await fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(g),headers:a});if(I.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(I.ok||re(I)==="dropped")return}catch(I){}if(T>=ln){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(I=>setTimeout(I,q(T+1)))}};try{k=h()}catch(T){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let U=new Set,P=null,z=!1,f={goal(l,g={},h=1,T=0){var R,ce,F,de,v,Y;let I=d.getSessionId();if(!I)return;let w=an(g)?g:{metadata:g},j=`${l}\0${(R=w.externalId)!=null?R:""}\0${(ce=w.stepIndex)!=null?ce:T}\0${(F=w.weight)!=null?F:h}`;if(U.has(j)){e.debug&&console.log(`[sentient] goal("${l}") already recorded for this action \u2014 not sent twice`);return}U.add(j),U.size===1&&cn(U);let $=Ne(),O={sessionId:I,name:l,metadata:(de=w.metadata)!=null?de:{},weight:(v=w.weight)!=null?v:h,stepIndex:(Y=w.stepIndex)!=null?Y:T,goalId:$,value:w.value,currency:w.currency,externalId:w.externalId};e.debug&&console.log("[sentient] goal",O);let H={id:$,body:JSON.stringify(O)};k.then(()=>x.send(H))},componentGoal(l,g,h){var O,H,R;let T=d.getSessionId();if(!T)return;let I=r.get(l,A),w=I?null:(O=D.get(l))!=null?O:null;if(!I&&w===null){e.debug&&console.warn(`[sentient] componentGoal("${l}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let j=I?I.variantId:Ae(w),$={id:Ne(),sessionId:T,projectId:e.apiKey,componentId:l,variantId:j,eventType:"goal_achieved",goalType:g,payload:b({reward:(H=h==null?void 0:h.reward)!=null?H:1,goalValue:h==null?void 0:h.value,currency:h==null?void 0:h.currency},(R=h==null?void 0:h.metadata)!=null?R:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:De()};e.debug&&console.log("[sentient] componentGoal",$),k.then(()=>o.push($))},identify(l){let g=d.getSessionId();g&&k.then(()=>{fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:g,userId:l,ephemeral:d.isEphemeral()}),headers:a}).catch(()=>{})})},track(l){let g=d.getSessionId();if(!g)return;let h=oe(b({path:De()},l),{id:Ne(),sessionId:g,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",h),k.then(()=>o.push(h))},getAssignment(l,g){return r.get(l,g)},async assign(l,g,h,T){let I=d.getSessionId();if(!I)return null;let w=r.get(l,A);if(w&&(g!=null&&g.length||w.content!==void 0)){let O=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:O,content:w.content}}let j=L.get(l);if(j)return j;let $=(async()=>{await k;try{let O={sessionId:I,componentId:l,variantIds:g};T!==void 0?O.agentDataByVariant=T:h!==void 0&&(O.agentData=h);let H=await fetch(`${i}/assign`,{method:"POST",body:JSON.stringify(O),headers:a});if(!H.ok)return null;let R=await H.json();return r.set(l,A,b({variantId:R.variantId,assignedAt:Date.now(),segment:A,confidence:1,content:R.content},R.assignmentTtlMs&&R.assignmentTtlMs>0?{ttlMs:R.assignmentTtlMs}:{})),R}catch(O){return null}finally{L.delete(l)}})();return L.set(l,$),$},async decide(l){var T,I,w,j,$,O,H,R,ce;let g=d.getSessionId();if(!g)return null;let h=(T=l.slots)!=null?T:[];await k;try{let F={sessionId:g};l.sections&&l.sections.length>0&&(F.sections=l.sections.map(N=>({id:N}))),F.components=(I=l.components)!=null?I:[],h.length>0&&(F.slots=h.map(ve)),l.slotsFrom==="registry"&&(F.slotsFrom="registry"),l.v&&(F.v=l.v),e.persona&&(F.persona=e.persona);let de=await fetch(`${i}/decide`,{method:"POST",body:JSON.stringify(F),headers:a});if(!de.ok)return K(h),null;let v=await de.json(),Y={};for(let N of h)Y[N.id]=(j=(w=v.slots)==null?void 0:w[N.id])!=null?j:ie(N);if(v.slots)for(let[N,ue]of Object.entries(v.slots))N in Y||(Y[N]=ue);for(let[N,ue]of Object.entries(Y))D.set(N,ue);let lt=E!=null&&E.persona!=="unknown";v.persona&&!(v.persona==="unknown"&&lt)?E={persona:v.persona,confidence:($=v.confidence)!=null?$:0}:E||(E={persona:"unknown",confidence:0});for(let[N,ue]of Object.entries((O=v.assignments)!=null?O:{}))r.set(N,A,{variantId:ue,assignedAt:Date.now(),segment:A,confidence:1});return ae(e.apiKey,b(b({v:1,persona:E.persona,band:(0,Ge.confidenceBand)(E.confidence),slots:Object.fromEntries(D),layoutOrder:(H=v.layoutOrder)!=null?H:null,savedAt:Date.now()},v.slotConfig?{slotConfig:v.slotConfig}:{}),v.palette?{palette:v.palette}:{})),b(b(b(b({layoutOrder:(R=v.layoutOrder)!=null?R:null,assignments:(ce=v.assignments)!=null?ce:{},slots:Y,persona:E.persona,confidence:E.confidence},v.slotConfig?{slotConfig:v.slotConfig}:{}),v.goals?{goals:v.goals}:{}),v.sectionMap?{sectionMap:v.sectionMap}:{}),v.palette?{palette:v.palette}:{})}catch(F){return K(h),null}},getSlotResult(l){var g;return(g=D.get(l))!=null?g:null},getPersona(){return E?{persona:E.persona,confidence:E.confidence,band:(0,Ge.confidenceBand)(E.confidence)}:null},async fetchWeights(){var l;try{let g=await fetch(`${i}/weights`,{headers:a});return g.ok?(l=(await g.json()).components)!=null?l:[]:[]}catch(g){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var l;P==null||P(),z=!0,o.destroy(),x.destroy(),((l=M.get(e.apiKey))==null?void 0:l.dispose)===f.dispose&&M.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var l;P==null||P(),z=!0,o.destroy(),x.destroy(),d.destroy(),((l=M.get(e.apiKey))==null?void 0:l.dispose)===f.dispose&&M.delete(e.apiKey);try{localStorage.removeItem(te+e.apiKey),localStorage.removeItem(Le(e.apiKey)),localStorage.removeItem(Pe(e.apiKey))}catch(g){}e.debug&&console.log("[sentient] destroyed")}};if(M.set(e.apiKey,{config:e,upgrade:null,dispose:f.dispose}),P=dn(f,e.apiKey,l=>{k.then(()=>{z||st.add(l)})}),e.debug){let l=window;l.__sentient&&(l.__sentient.client=f)}return f}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
2
2
  //# sourceMappingURL=index.js.map