@sentientui/core 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index-engagement.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var E=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var G=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e)=>{for(var n in e||(e={}))F.call(e,n)&&G(t,n,e[n]);if(B)for(var n of B(e))V.call(e,n)&&G(t,n,e[n]);return t};var z=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},H=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let g of Q(e))!F.call(t,g)&&g!==n&&E(t,g,{get:()=>e[g],enumerable:!(i=q(e,g))||i.enumerable});return t};var X=t=>H(E({},"__esModule",{value:!0}),t);var Se={};z(Se,{SEMANTIC_TYPES:()=>x,classifyFeatures:()=>
|
|
1
|
+
"use strict";var E=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var G=(t,e,n)=>e in t?E(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e)=>{for(var n in e||(e={}))F.call(e,n)&&G(t,n,e[n]);if(B)for(var n of B(e))V.call(e,n)&&G(t,n,e[n]);return t};var z=(t,e)=>{for(var n in e)E(t,n,{get:e[n],enumerable:!0})},H=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let g of Q(e))!F.call(t,g)&&g!==n&&E(t,g,{get:()=>e[g],enumerable:!(i=q(e,g))||i.enumerable});return t};var X=t=>H(E({},"__esModule",{value:!0}),t);var Se={};z(Se,{SEMANTIC_TYPES:()=>x,classifyFeatures:()=>A,classifySection:()=>C,featuresFromElement:()=>k,startEngagementCapture:()=>J});module.exports=X(Se);var x=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Z=[["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]],ee=[["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 te(t){var n;let e=t.querySelector("h1, h2, h3");return((n=e==null?void 0:e.textContent)!=null?n:"").slice(0,160)}function A(t){if(t.tag==="nav"||t.tag==="footer")return{type:"navigation",strength:"weak"};let e=`${t.idClass} ${t.headingText}`.toLowerCase();for(let[n,i]of Z)if(i.test(e))return{type:n,strength:"strong"};for(let[n,i]of ee)if(i.test(t.bodyText))return{type:n,strength:"strong"};return t.actionCount>=1&&t.textLength>0&&t.textLength<200?{type:"cta",strength:"weak"}:t.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(e)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function k(t){var n,i;let e=((n=t.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:t.tagName.toLowerCase(),idClass:`${t.id} ${String((i=t.className)!=null?i:"")}`,headingText:te(t),bodyText:e.slice(0,2e3),actionCount:t.querySelectorAll('a, button, [role="button"]').length,textLength:e.length}}function C(t){return A(k(t)).type}var T=require("@sentientui/policy");var me=require("@sentientui/policy");var re=require("@sentientui/policy");function _(t,e,n){var g;let i=[];{let a=!1,c=[],p=()=>{if(a)return;let f=Date.now();for(c.push(f);c.length>0&&f-c[0]>500;)c.shift();c.length>=3&&(a=!0,t("rage_click"))};e.addEventListener("click",p),i.push(()=>e.removeEventListener("click",p))}{let l=!1,u=a=>{if(l||!(a.target instanceof Node)||!e.contains(a.target)&&e!==a.target)return;l=!0;let c=typeof window!="undefined"?window.getSelection():null,p=c?c.toString().length:0;t("text_copy",{selectionLength:p})};document.addEventListener("copy",u),i.push(()=>document.removeEventListener("copy",u))}{let l=!1,u=!1,a=null,c=()=>{a!==null&&(clearTimeout(a),a=null)},p=()=>{l||!u||(c(),a=setTimeout(()=>{!l&&u&&(l=!0,t("scroll_hesitation"))},3e3))},f=()=>{c(),p()},m=b=>{for(let w of b)u=w.intersectionRatio>.3,u?p():c()};typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)!=="production"&&(window.__lastIOCallback=m);let y=new IntersectionObserver(m,{threshold:[.3]});y.observe(e),window.addEventListener("scroll",f,{passive:!0}),i.push(()=>{y.disconnect(),window.removeEventListener("scroll",f),c()})}{let l=!1,u=n!=null?n:Date.now(),a=()=>{if(l||document.visibilityState!=="hidden")return;let c=Date.now()-u;c<15e3&&(l=!0,t("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",a),i.push(()=>document.removeEventListener("visibilitychange",a))}return()=>{for(let l of i)l()}}function W(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}var Y="section, header, footer, nav, main > div, [data-sentient-section]";function ye(t){var e;return((e=t.parentElement)==null?void 0:e.closest(Y))!=null}function he(t,e,n,i){try{fetch(`${e}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({pageUrl:n,sections:i})}).catch(()=>{})}catch(g){}}var I=()=>{};function J(t,e){var O,D,L,P,N,M,U,K,$;let n=(O=e.doc)!=null?O:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||W()||!e.apiKey)return I;let i=(D=e.apiBase)!=null?D:"https://api.sentient-ui.com",g=Array.from(n.querySelectorAll(Y)).filter(o=>!ye(o));if(g.length===0)return I;let l=new Map,u=new Map,a=new Map;for(let o of g){let r=o.getAttribute("data-sentient-type"),s=r&&x.includes(r)?r:null,d=(P=s!=null?s:(L=e.typeOf)==null?void 0:L.call(e,o))!=null?P:C(o),S=`nc-${d}`;l.set(o,S),u.set(S,d),s?a.set(S,"markup"):a.has(S)||a.set(S,"auto")}let c=(K=(U=(M=(N=n.defaultView)!=null?N:typeof window!="undefined"?window:void 0)==null?void 0:M.location)==null?void 0:U.pathname)!=null?K:"/";he(e.apiKey,i,c,[...u.entries()].map(([o,r])=>{var s;return{componentId:o,semanticType:r,source:(s=a.get(o))!=null?s:"auto"}}));let p=new Map,f=o=>{let r=p.get(o);return r||(r={ms:0,scroll:0,enterAt:null,intersecting:!1},p.set(o,r)),r},m=new IntersectionObserver(o=>{for(let r of o){let s=l.get(r.target);if(!s)continue;let d=f(s);r.isIntersecting?(d.intersecting=!0,d.enterAt=Date.now(),r.intersectionRatio>d.scroll&&(d.scroll=r.intersectionRatio)):(d.intersecting=!1,d.enterAt!=null&&(d.ms+=Date.now()-d.enterAt,d.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let o of l.keys())m.observe(o);let y=()=>{let o=Date.now();for(let[r,s]of p)if(s.enterAt!=null&&(s.ms+=o-s.enterAt,s.enterAt=null),!(s.ms<=0)){try{t.track({projectId:e.apiKey,componentId:r,eventType:"dwell",payload:{dwell_time:Math.round(s.ms),scroll_depth:Number(s.scroll.toFixed(2))}})}catch(d){}s.ms=0}},b=()=>{if(n.hidden)y();else{let o=Date.now();for(let r of p.values())r.intersecting&&(r.enterAt=o)}},w=()=>{y();try{m.disconnect()}catch(o){}};n.addEventListener("visibilitychange",b);let h=($=n.defaultView)!=null?$:typeof window!="undefined"?window:void 0;h==null||h.addEventListener("pagehide",w);let R=[];if(e.microSignals)for(let[o,r]of l)R.push(_((s,d={})=>{try{t.track({projectId:e.apiKey,componentId:r,eventType:"micro_signal",payload:v({signalType:s},d)})}catch(S){}},o));return()=>{y(),n.removeEventListener("visibilitychange",b),h==null||h.removeEventListener("pagehide",w);for(let o of R)o();try{m.disconnect()}catch(o){}}}0&&(module.exports={SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as v,b as B,c as F,d as h}from"./chunk-KZHVBFG7.mjs";import{g as _,h as K}from"./chunk-CWUFS37B.mjs";import"./chunk-P5ZTJLZE.mjs";import{a as x}from"./chunk-HGGX55FR.mjs";var L="section, header, footer, nav, main > div, [data-sentient-section]";function R(s){var o;return((o=s.parentElement)==null?void 0:o.closest(L))!=null}function V(s,o,r,f){try{fetch(`${o}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${s}`},body:JSON.stringify({pageUrl:r,sections:f})}).catch(()=>{})}catch(m){}}var u=()=>{};function $(s,o){var b,A,C,O,I,k,M,N,D;let r=(b=o.doc)!=null?b:typeof document!="undefined"?document:void 0;if(!r||typeof IntersectionObserver=="undefined"||K()||!o.apiKey)return u;let f=(A=o.apiBase)!=null?A:"https://api.sentient-ui.com",m=Array.from(r.querySelectorAll(L)).filter(e=>!R(e));if(m.length===0)return u;let l=new Map,E=new Map,d=new Map;for(let e of m){let t=e.getAttribute("data-sentient-type"),n=t&&v.includes(t)?t:null,i=(O=n!=null?n:(C=o.typeOf)==null?void 0:C.call(o,e))!=null?O:h(e),a=`nc-${i}`;l.set(e,a),E.set(a,i),n?d.set(a,"markup"):d.has(a)||d.set(a,"auto")}let P=(N=(M=(k=(I=r.defaultView)!=null?I:typeof window!="undefined"?window:void 0)==null?void 0:k.location)==null?void 0:M.pathname)!=null?N:"/";V(o.apiKey,f,P,[...E.entries()].map(([e,t])=>{var n;return{componentId:e,semanticType:t,source:(n=d.get(e))!=null?n:"auto"}}));let p=new Map,j=e=>{let t=p.get(e);return t||(t={ms:0,scroll:0,enterAt:null,intersecting:!1},p.set(e,t)),t},y=new IntersectionObserver(e=>{for(let t of e){let n=l.get(t.target);if(!n)continue;let i=j(n);t.isIntersecting?(i.intersecting=!0,i.enterAt=Date.now(),t.intersectionRatio>i.scroll&&(i.scroll=t.intersectionRatio)):(i.intersecting=!1,i.enterAt!=null&&(i.ms+=Date.now()-i.enterAt,i.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let e of l.keys())y.observe(e);let g=()=>{let e=Date.now();for(let[t,n]of p)if(n.enterAt!=null&&(n.ms+=e-n.enterAt,n.enterAt=null),!(n.ms<=0)){try{s.track({projectId:o.apiKey,componentId:t,eventType:"dwell",payload:{dwell_time:Math.round(n.ms),scroll_depth:Number(n.scroll.toFixed(2))}})}catch(i){}n.ms=0}},S=()=>{if(r.hidden)g();else{let e=Date.now();for(let t of p.values())t.intersecting&&(t.enterAt=e)}},w=()=>{g();try{y.disconnect()}catch(e){}};r.addEventListener("visibilitychange",S);let c=(D=r.defaultView)!=null?D:typeof window!="undefined"?window:void 0;c==null||c.addEventListener("pagehide",w);let T=[];if(o.microSignals)for(let[e,t]of l)T.push(_((n,i={})=>{try{s.track({projectId:o.apiKey,componentId:t,eventType:"micro_signal",payload:x({signalType:n},i)})}catch(a){}},e));return()=>{g(),r.removeEventListener("visibilitychange",S),c==null||c.removeEventListener("pagehide",w);for(let e of T)e();try{y.disconnect()}catch(e){}}}export{v as SEMANTIC_TYPES,B as classifyFeatures,h as classifySection,F as featuresFromElement,$ as startEngagementCapture};
|
package/dist/index-graph.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var et=Object.create;var oe=Object.defineProperty,tt=Object.defineProperties,nt=Object.getOwnPropertyDescriptor,ot=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols,st=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var Ne=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Ne(e,n,t[n]);if(De)for(var n of De(t))it.call(t,n)&&Ne(e,n,t[n]);return e},F=(e,t)=>tt(e,ot(t));var at=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},Le=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of rt(t))!Pe.call(e,d)&&d!==n&&oe(e,d,{get:()=>t[d],enumerable:!(a=nt(t,d))||a.enumerable});return e};var ct=(e,t,n)=>(n=e!=null?et(st(e)):{},Le(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e)),dt=e=>Le(oe({},"__esModule",{value:!0}),e);var nn={};at(nn,{deriveSessionSegment:()=>ve,detectDeviceClass:()=>W,detectTimeOfDay:()=>z,detectTrafficSource:()=>q,init:()=>tn,referrerDomainFromReferer:()=>J});module.exports=dt(nn);var lt="_snt_uid";var j="_snt_uid";function ut(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function gt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function pt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(a){}}function ft(e){try{return localStorage.getItem(e)}catch(t){return null}}function mt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function yt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function ht(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function St(e){try{sessionStorage.removeItem(e)}catch(t){}}function vt(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function bt(e){try{localStorage.removeItem(e)}catch(t){}}function Et(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var wt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ce(e){var c,l,g,y,f,m;if(typeof window=="undefined")return wt;let t=(c=e==null?void 0:e.cookieName)!=null?c:lt,a=((l=e==null?void 0:e.cookieTTLDays)!=null?l:365)*24*60*60,d=(m=(f=(y=(g=gt(t))!=null?g:ft(j))!=null?y:yt(j))!=null?f:e==null?void 0:e.ssrSessionId)!=null?m:ut();pt(t,d,a);let s=mt(j,d),o=vt(t),r=s?!1:ht(j,d),i=!s&&!o&&!r;return{getSessionId:()=>d,isEphemeral:()=>i,destroy:()=>{d=null,Et(t),bt(j),St(j)}}}function ye(e){return`_snt_retry_${e.slice(0,12)}`}var It={push:()=>{},flush:()=>{},destroy:()=>{}};function Ct(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let a=JSON.parse(n);return Array.isArray(a)?(localStorage.removeItem(t),a.slice(-e)):[]}catch(n){return[]}}function me(e,t,n){try{let d=[...(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let o=JSON.parse(s);return Array.isArray(o)?o:[]}catch(s){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(d))}catch(a){}}function Me(e){var X,Z,ee;if(typeof window=="undefined")return It;let t=(X=e.flushIntervalMs)!=null?X:5e3,n=(Z=e.maxBatchSize)!=null?Z:20,a=(ee=e.maxRetrySize)!=null?ee:100,d=e.ingestUrl,s=e.apiKey,o=ye(s),r=[],i=new Set,c=[],l=h=>{for(let v of h)g.delete(v),!i.has(v)&&(i.add(v),c.push(v));for(;c.length>500;){let v=c.shift();v&&i.delete(v)}},g=new Set,y=h=>{i.has(h.id)||g.has(h.id)||(g.add(h.id),r.push(h))},f=Ct(a,o);for(let h of f)y(h);let m=0,E=0,I=h=>{if(h.length===0)return;let v=JSON.stringify(h),A=h.map(u=>u.id),k;try{k=fetch(d,{method:"POST",keepalive:!0,body:v,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(u){me(h,a,o);for(let p of A)g.delete(p);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6));return}let L=u=>{if(u.ok||u.status>=400&&u.status<500&&u.status!==429){l(A),E=0,m=0;return}me(h,a,o);for(let p of A)g.delete(p);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))};k instanceof Promise?k.then(L).catch(()=>{me(h,a,o);for(let u of A)g.delete(u);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))}):L(k)},w=typeof TextEncoder!="undefined"?new TextEncoder:null,ae=h=>w?w.encode(h).length:h.length,G=h=>{let v=[],A=2;for(let k of h){let L=ae(JSON.stringify(k))+1;if(v.length>0&&A+L>57344||v.length>=n)break;v.push(k),A+=L}return v},N=()=>{try{if(Date.now()<m)return;for(;r.length>0;){let h=r.filter(A=>!i.has(A.id));if(r.length=0,h.length===0)break;let v=G(h);if(v.length===0)break;v.length<h.length&&r.push(...h.slice(v.length)),I(v)}}catch(h){}},R=!0,$=null;$=setInterval(()=>{R&&N()},t);let Q=()=>{document.visibilityState==="hidden"&&N()},V=()=>{N()};return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",V),{push(h){y(h),r.length>=n&&N()},flush:N,destroy(){R=!1,$!==null&&(clearInterval($),$=null),document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",V),N()}}}var Se="_snt_asgn_";function de(e,t){return`${e}:${t}`}function xt(e,t){return`${Se}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ue(e){let t=e.slice(Se.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(a){return null}}function he(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Se)&&e.push(n)}return e}catch(e){return[]}}function Ge(e=18e5){let t=new Map,n=d=>d.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let d of he())try{let s=localStorage.getItem(d);if(!s)continue;let o=JSON.parse(s);if(n(o)){localStorage.removeItem(d);continue}let r=Ue(d);if(!r)continue;t.set(de(r.componentId,r.segment),o)}catch(s){}})(),{get(d,s){let o=t.get(de(d,s));return o?n(o)?(t.delete(de(d,s)),null):o:null},set(d,s,o){let r=de(d,s);t.set(r,o);try{localStorage.setItem(xt(d,s),JSON.stringify(o))}catch(i){}},invalidate(d){let s=`${d}:`;for(let o of[...t.keys()])o.startsWith(s)&&t.delete(o);for(let o of he()){let r=Ue(o);if((r==null?void 0:r.componentId)===d)try{localStorage.removeItem(o)}catch(i){}}},clear(){t.clear();for(let d of he())try{localStorage.removeItem(d)}catch(s){}}}}var $e=["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 le(e){return Ke(e)!==null}function Ke(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=$e.find(a=>t.includes(a.toLowerCase())))!=null?n:null}function W(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 q(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(d){}let a=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(a)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(a)?"social":"referral"}catch(n){return"direct"}}function J(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function z(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function ve(e){let t=At("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function At(e,t){var s,o,r,i,c,l,g;let n=(o=(s=t==null?void 0:t.userAgent)==null?void 0:s.trim())!=null?o:"",a=(i=(r=t==null?void 0:t.referer)==null?void 0:r.trim())!=null?i:"",d=(c=t==null?void 0:t.now)!=null?c:new Date;return{sessionId:e,ephemeral:!1,utmParams:(l=t==null?void 0:t.utmParams)!=null?l:{},deviceClass:n?W(n):"desktop",trafficSource:a?q(a,t==null?void 0:t.appOrigin):"direct",referrerDomain:J(a),timeOfDay:z(d),dayOfWeek:(g=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?g:"sun",automation:(t==null?void 0:t.webdriver)===!0||le(n)}}var Y=require("@sentientui/policy");function ue(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 ge(e){let t=ue(e);return(0,Y.slotResultFor)(t,(0,Y.slotBaselineArm)(t))}function be(e){return typeof e=="string"?e:(0,Y.canonicalArm)(e)}var re="_snt_snap:",Tt=["low","medium","high"];function Ee(e){try{let t=localStorage.getItem(re+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"||!Tt.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 se(e,t){try{localStorage.setItem(re+e,JSON.stringify(t))}catch(n){}}var Ce=require("@sentientui/policy");var fe=require("@sentientui/policy");var we="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Fe="[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.",Be=!1,pe=!1;function _t(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function je(e){var r;let t=ce({ssrSessionId:e.ssrSessionId}),n=(r=t.getSessionId())!=null?r:"local",a=_t(),d=import("@sentientui/core/local").then(i=>{let c=i;return c.LOCAL_ENGINE_AVAILABLE?(Be||(Be=!0,console.info(Fe)),c):(pe||(pe=!0,console.error(we)),null)}).catch(()=>(pe||(pe=!0,console.error(we)),null)),s=null;function o(i){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=i.persona,c.dataset.sentientConfidence=(0,fe.confidenceBand)(i.confidence))}return{isLocal:!0,async decide(i){var g,y,f;let c=await d;if(!c)return null;let l=c.createLocalEngine({sessionId:n,forcedPersona:a}).decide(i);return s=F(b({},l),{layoutOrder:(y=(g=l.layoutOrder)!=null?g:s==null?void 0:s.layoutOrder)!=null?y:null,slots:b(b({},(f=s==null?void 0:s.slots)!=null?f:{}),l.slots)}),se(e.apiKey||"local",{v:1,persona:s.persona,band:(0,fe.confidenceBand)(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),o(l),l},getSlotResult(i){var c,l,g;return(g=(l=s==null?void 0:s.slots[i])!=null?l:(c=e.initialSlots)==null?void 0:c[i])!=null?g:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:(0,fe.confidenceBand)(s.confidence)}:null},async assign(i,c){var y;let l=await d;return!l||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(y=l.createLocalEngine({sessionId:n,forcedPersona:a}).decide({components:[{id:i,variantIds:c}]}).assignments[i])!=null?y:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var We="https://api.sentient-ui.com/v1/events",ie=new Map,Rt=null;function Ie(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var H={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 kt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,a]of t)n.startsWith("utm_")&&(e[n]=a);return e}catch(e){return{}}}function qe(e){return e.replace(/\/events\/?$/,"")}function xe(){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 Ot(e){var o;let t=qe((o=e.ingestUrl)!=null?o:We),n={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,i,c){try{let l=new URLSearchParams({componentId:r});for(let f of i!=null?i:[])l.append("variantIds[]",f);let g=await fetch(`${t}/winner?${l.toString()}`,{headers:n});return g.ok?{variantId:(await g.json()).variantId,assignmentTtlMs:0}:i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}catch(l){return i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},d={track:r=>a.track(r),goal:(r,i,c,l)=>a.goal(r,i,c,l),componentGoal:(r,i,c)=>a.componentGoal(r,i,c),identify:r=>a.identify(r),getAssignment:(r,i)=>a.getAssignment(r,i),assign:(r,i,c,l)=>a.assign(r,i,c,l),decide:r=>a.decide(r),getSlotResult:r=>a.getSlotResult(r),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function s(r){a=r}return{proxy:d,setInner:s}}function Je(e){var V,X,Z,ee,h,v,A,k,L;if(typeof window=="undefined")return H;Rt=e.apiKey;let t=e.respectDoNotTrack!==!1&&xe(),n=e.consent===!1||t,a=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!a&&e.localMode!==!1)return n?(ie.set(e.apiKey||"local",{config:e,upgrade:null}),H):(ie.set(e.apiKey||"local",{config:e,upgrade:null}),je(e));if(n){if(e.preConsentBehavior==="statistical_winner"){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),H;let{proxy:u,setInner:p}=Ot(e);return ie.set(e.apiKey,{config:e,upgrade:t?null:p}),u}return ie.set(e.apiKey,{config:e,upgrade:null}),H}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."),H;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),H;let d=(V=e.ingestUrl)!=null?V:We,s=Date.now(),o=ce({ssrSessionId:e.ssrSessionId}),r=Ge(),i=Me({ingestUrl:d,apiKey:e.apiKey}),c=qe(d),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=W((X=navigator.userAgent)!=null?X:""),y=typeof window!="undefined"?window.location.origin:void 0,f=q((Z=document.referrer)!=null?Z:"",y),m=(ee=e.sessionSegment)!=null?ee:`${g}:${f}`,E=new Map,I=new Map,w=null,ae=u=>{for(let p of u)I.has(p.id)||I.set(p.id,ge(p))};if(e.initialSlots)for(let[u,p]of Object.entries(e.initialSlots))I.set(u,p);let G=Ee(e.apiKey);if(G)for(let[u,p]of Object.entries(G.slots))I.has(u)||I.set(u,p);let N={low:.15,medium:.5,high:.85};if(e.initialPersona)w=b({},e.initialPersona);else{let u=document.documentElement.dataset;u.sentientPersona?w={persona:u.sentientPersona,confidence:(v=N[(h=u.sentientConfidence)!=null?h:"low"])!=null?v:.15}:G&&(w={persona:G.persona,confidence:(A=N[G.band])!=null?A:.15})}if(e.initialAssignments)for(let[u,p]of Object.entries(e.initialAssignments))r.set(u,m,{variantId:p,assignedAt:Date.now(),segment:m,confidence:1});let R=Promise.resolve(),$=o.getSessionId();if($){let u=J((k=document.referrer)!=null?k:""),p=b(b({sessionId:$,deviceClass:g,trafficSource:f,referrerDomain:u,utmParams:kt(),timeOfDay:z(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||le((L=navigator.userAgent)!=null?L:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{R=fetch(`${c}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(p),headers:l}).then(S=>{S.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(S){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:i});let Q={goal(u,p={},S=1,O=0){let x=o.getSessionId();if(!x)return;let T=Ie();R.then(()=>{fetch(`${c}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:x,name:u,metadata:p,weight:S,stepIndex:O,goalId:T}),headers:l}).catch(()=>{})})},componentGoal(u,p,S){var D,U,P;let O=o.getSessionId();if(!O)return;let x=r.get(u,m),T=x?null:(D=I.get(u))!=null?D:null;if(!x&&T===null){e.debug&&console.warn(`[sentient] componentGoal("${u}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let K=x?x.variantId:be(T),M={id:Ie(),sessionId:O,projectId:e.apiKey,componentId:u,variantId:K,eventType:"goal_achieved",goalType:p,payload:b({reward:(U=S==null?void 0:S.reward)!=null?U:1},(P=S==null?void 0:S.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-s};e.debug&&console.log("[sentient] componentGoal",M),R.then(()=>i.push(M))},identify(u){let p=o.getSessionId();p&&R.then(()=>{fetch(`${c}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:p,userId:u,ephemeral:o.isEphemeral()}),headers:l}).catch(()=>{})})},track(u){let p=o.getSessionId();if(!p)return;let S=F(b({},u),{id:Ie(),sessionId:p,timestamp:Date.now(),timeInSession:Date.now()-s});e.debug&&console.log("[sentient] track",S),R.then(()=>i.push(S))},getAssignment(u,p){return r.get(u,p)},async assign(u,p,S,O){let x=o.getSessionId();if(!x)return null;let T=r.get(u,m);if(T&&(p!=null&&p.length||T.content!==void 0))return{variantId:T.variantId,assignmentTtlMs:0,content:T.content};let K=E.get(u);if(K)return K;let M=(async()=>{await R;try{let D={sessionId:x,componentId:u,variantIds:p};O!==void 0?D.agentDataByVariant=O:S!==void 0&&(D.agentData=S);let U=await fetch(`${c}/assign`,{method:"POST",body:JSON.stringify(D),headers:l});if(!U.ok)return null;let P=await U.json();return r.set(u,m,{variantId:P.variantId,assignedAt:Date.now(),segment:m,confidence:1,content:P.content}),P}catch(D){return null}finally{E.delete(u)}})();return E.set(u,M),M},async decide(u){var O,x,T,K,M,D,U,P,Re,ke;let p=o.getSessionId();if(!p)return null;let S=(O=u.slots)!=null?O:[];await R;try{let B={sessionId:p};u.sections&&u.sections.length>0&&(B.sections=u.sections.map(_=>({id:_}))),B.components=(x=u.components)!=null?x:[],S.length>0&&(B.slots=S.map(ue)),u.slotsFrom==="registry"&&(B.slotsFrom="registry"),u.v&&(B.v=u.v);let Oe=await fetch(`${c}/decide`,{method:"POST",body:JSON.stringify(B),headers:l});if(!Oe.ok)return ae(S),null;let C=await Oe.json(),te={};for(let _ of S)te[_.id]=(K=(T=C.slots)==null?void 0:T[_.id])!=null?K:ge(_);if(C.slots)for(let[_,ne]of Object.entries(C.slots))_ in te||(te[_]=ne);for(let[_,ne]of Object.entries(te))I.set(_,ne);w={persona:(M=C.persona)!=null?M:"unknown",confidence:(D=C.confidence)!=null?D:0};for(let[_,ne]of Object.entries((U=C.assignments)!=null?U:{}))r.set(_,m,{variantId:ne,assignedAt:Date.now(),segment:m,confidence:1});return se(e.apiKey,b({v:1,persona:w.persona,band:(0,Ce.confidenceBand)(w.confidence),slots:Object.fromEntries(I),layoutOrder:(P=C.layoutOrder)!=null?P:null,savedAt:Date.now()},C.slotConfig?{slotConfig:C.slotConfig}:{})),b(b({layoutOrder:(Re=C.layoutOrder)!=null?Re:null,assignments:(ke=C.assignments)!=null?ke:{},slots:te,persona:w.persona,confidence:w.confidence},C.slotConfig?{slotConfig:C.slotConfig}:{}),C.goals?{goals:C.goals}:{})}catch(B){return ae(S),null}},getSlotResult(u){var p;return(p=I.get(u))!=null?p:null},getPersona(){return w?{persona:w.persona,confidence:w.confidence,band:(0,Ce.confidenceBand)(w.confidence)}:null},async fetchWeights(){var u;try{let p=await fetch(`${c}/weights`,{headers:l});return p.ok?(u=(await p.json()).components)!=null?u:[]:[]}catch(p){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){i.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){i.destroy(),o.destroy();try{localStorage.removeItem(re+e.apiKey),localStorage.removeItem(ye(e.apiKey))}catch(u){}e.debug&&console.log("[sentient] destroyed")}};if(ie.set(e.apiKey,{config:e,upgrade:null}),e.debug){let u=window;u.__sentient&&(u.__sentient.client=Q)}return Q}var ze=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Dt=[["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]],Nt=[["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 Pt(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function Lt(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,a]of Dt)if(a.test(t))return{type:n,strength:"strong"};for(let[n,a]of Nt)if(a.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 Mt(e){var n,a;let t=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((a=e.className)!=null?a:"")}`,headingText:Pt(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function Ye(e){return Lt(Mt(e)).type}var Ut=new Set(["SECTION","ARTICLE","MAIN","DIV"]),Gt="h1, h2, h3",$t={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function Ae(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function Kt(e){var t,n,a;try{let d=e;for(let s of Object.keys(d)){if(!s.startsWith("__reactFiber")&&!s.startsWith("__reactInternalInstance"))continue;let o=d[s],r=(a=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?a:(n=o==null?void 0:o.type)==null?void 0:n.name;if(r&&r.length>1)return r}}catch(d){}}function Bt(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var He=new Set(ze);function Ft(e){let t=e.getAttribute("data-sentient-type");if(t&&He.has(t))return t;let n=e.getAttribute("role");return n&&He.has(n)?n:Ye(e)}function jt(e){var t,n;return(n=(t=e.getAttribute("data-sentient-id"))!=null?t:e.getAttribute("id"))!=null?n:e.tagName.toLowerCase()}function Wt(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Te(e,t){var a,d,s;let n=e.querySelector(Gt);return{componentId:jt(e),semanticType:Ft(e),ariaLabel:(a=e.getAttribute("aria-label"))!=null?a:void 0,headingText:(s=(d=n==null?void 0:n.textContent)==null?void 0:d.trim())!=null?s:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:Wt(e),reactComponentName:Kt(e),dataAttributes:Bt(e)}}function Qe(e){var s;let t=[],n=new Set,a="__root__",d=new Map;for(let[o,r]of e){let i=o.parentElement,c=a;for(;i;){if(e.has(i)){c=e.get(i);let g=e.get(o),y=`${c}->${g}`;!n.has(y)&&c!==g&&(n.add(y),t.push({fromComponentId:c,toComponentId:g,weight:.6}));break}i=i.parentElement}let l=(s=d.get(c))!=null?s:[];l.push(o),d.set(c,l)}for(let o of d.values())if(!(o.length<2))for(let r=0;r<o.length;r++)for(let i=r+1;i<o.length;i++){let c=e.get(o[r]),l=e.get(o[i]);if(c===l)continue;let g=`${c}->${l}::sib`,y=`${l}->${c}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.3})),n.has(y)||(n.add(y),t.push({fromComponentId:l,toComponentId:c,weight:.3}))}return t}function qt(e){let t=[],n=new Set,a=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let r=Te(o,e);t.push(r),a.set(o,r.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let r=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!r&&!i)return;n.add(o);let c=Te(o,e);t.push(c),a.set(o,c.componentId)}),{nodes:t,edges:Qe(a)}}function Ve(){if(typeof window=="undefined")return $t;let e=null,t=0,n=null,a=r=>{try{let i=window.getComputedStyle(r),c=parseFloat(i.fontSize)||12,l=parseFloat(i.zIndex)||0,g=r.getBoundingClientRect(),y=Math.max(g.top,0),f=window.innerHeight||1,m=1/(y/f+1),E=Ae(c,12,48)*.4+Ae(m,0,1)*.4+Ae(l,0,100)*.2;return Math.max(0,Math.min(1,E))}catch(i){return .5}};return{scan:()=>new Promise(r=>{let i=()=>{let{nodes:c,edges:l}=qt(a);r({nodes:c,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(i,{timeout:100}):i()}catch(c){i()}}),observe:r=>{n=r;try{e=new MutationObserver(i=>{let c=[],l=new Map;for(let g of i)g.type==="childList"&&g.addedNodes.forEach(y=>{if(!(y instanceof Element)||!Ut.has(y.tagName))return;let f=y.hasAttribute("data-sentient-id"),m=y.hasAttribute("aria-label");if(!f&&!m)return;let E=Te(y,a);c.push(E),l.set(y,E.componentId)});c.length>0&&n&&n({nodes:c,edges:Qe(l),addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(i){}},getProminenceScore:a,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(r){}t=0,n=null}}}var _e="_snt_graph_nodes",Xe="_snt_graph_edges",Jt={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function zt(e){var t;return(t=Jt[e])!=null?t:[]}function Yt(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function Ht(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var Qt=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Vt(e){return Qt.has(e)?e:"generic"}function Xt(e,t,n){let a=`${e}:${t}:${n.join(",")}`,d=5381;for(let s=0;s<a.length;s++)d=(d<<5)+d+a.charCodeAt(s)&4294967295;return(d>>>0).toString(16).padStart(8,"0")}function Ze(e){let t=new Map,n=new Map,a=()=>{typeof window!="undefined"&&Ht(_e,[...t.values()])},d=s=>{var o;try{let r=JSON.parse(s);t.clear();for(let i of(o=r.pageNodes)!=null?o:[])t.set(i.componentId,i)}catch(r){}};if(typeof window!="undefined"){let s=Yt(_e,[]);for(let o of s)t.set(o.componentId,o);try{localStorage.removeItem(Xe)}catch(o){}}return{addPageNode(s){t.set(s.componentId,s),a()},addStructuralEdge(s){let o=`${s.fromComponentId}->${s.toComponentId}`;n.set(o,s)},syncOnce(){var o,r;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let s=[...t.values()];if(s.length!==0)try{let i=new Map;for(let f of s){let m=(o=i.get(f.semanticType))!=null?o:[];m.push(f),i.set(f.semanticType,m)}let c=[],l=new Set;for(let f of s)for(let m of zt(f.semanticType)){let E=(r=i.get(m))!=null?r:[];for(let I of E){if(I.componentId===f.componentId)continue;let w=`semantic:${f.componentId}->${I.componentId}`;l.has(w)||(l.add(w),c.push({fromComponentId:f.componentId,toComponentId:I.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(s.map(f=>f.componentId));for(let f of n.values()){if(!g.has(f.fromComponentId)||!g.has(f.toComponentId))continue;let m=`structural:${f.fromComponentId}->${f.toComponentId}`;l.has(m)||(l.add(m),c.push({fromComponentId:f.fromComponentId,toComponentId:f.toComponentId,type:"structural",weight:f.weight,confidence:1}))}let y={pageUrl:window.location.href,nodes:s.map(f=>{let m=Vt(f.semanticType);return{componentId:f.componentId,semanticType:m,answers:f.answers,contentHash:Xt(f.componentId,m,f.answers),prominenceScore:f.prominenceScore,depthInPage:f.depth}}),edges:c};fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:b({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(y)}).catch(()=>{})}catch(i){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:d,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(_e),localStorage.removeItem(Xe)}catch(s){}}}}var Zt="https://api.sentient-ui.com/v1/events";function en(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}function tn(e){var c;let t=Je(e),n=e.respectDoNotTrack!==!1&&xe(),a=e.consent===!1||n;if(!e.graph||a||typeof window=="undefined")return t;let d=Ve(),s=(c=e.ingestUrl)!=null?c:Zt,o=Ze({syncUrl:s.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:en()});try{let l=localStorage.getItem("_snt_graph_nodes");l&&o.restore(JSON.stringify({pageNodes:JSON.parse(l)}))}catch(l){}d.scan().then(l=>{for(let g of l.nodes)o.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of l.edges)o.addStructuralEdge(g);o.syncOnce()});let r=null,i=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,o.syncOnce()},500)};return d.observe(l=>{for(let g of l.nodes)o.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of l.edges)o.addStructuralEdge(g);i()}),F(b({},t),{getGraph:()=>o.snapshot(),dispose:()=>{r!==null&&clearTimeout(r),d.destroy(),o.destroy(),t.dispose()},destroy:()=>{r!==null&&clearTimeout(r),d.destroy(),o.destroy(),t.destroy()}})}0&&(module.exports={deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,init,referrerDomainFromReferer});
|
|
1
|
+
"use strict";var et=Object.create;var oe=Object.defineProperty,tt=Object.defineProperties,nt=Object.getOwnPropertyDescriptor,ot=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols,st=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable;var Ne=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Ne(e,n,t[n]);if(De)for(var n of De(t))it.call(t,n)&&Ne(e,n,t[n]);return e},F=(e,t)=>tt(e,ot(t));var at=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},Le=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of rt(t))!Pe.call(e,d)&&d!==n&&oe(e,d,{get:()=>t[d],enumerable:!(a=nt(t,d))||a.enumerable});return e};var ct=(e,t,n)=>(n=e!=null?et(st(e)):{},Le(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e)),dt=e=>Le(oe({},"__esModule",{value:!0}),e);var nn={};at(nn,{deriveSessionSegment:()=>ve,detectDeviceClass:()=>W,detectTimeOfDay:()=>z,detectTrafficSource:()=>q,init:()=>tn,referrerDomainFromReferer:()=>J});module.exports=dt(nn);var lt="_snt_uid";var j="_snt_uid";function ut(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function gt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function pt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(a){}}function ft(e){try{return localStorage.getItem(e)}catch(t){return null}}function mt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function yt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function ht(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function St(e){try{sessionStorage.removeItem(e)}catch(t){}}function vt(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function bt(e){try{localStorage.removeItem(e)}catch(t){}}function Et(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var wt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ce(e){var c,l,g,y,f,m;if(typeof window=="undefined")return wt;let t=(c=e==null?void 0:e.cookieName)!=null?c:lt,a=((l=e==null?void 0:e.cookieTTLDays)!=null?l:365)*24*60*60,d=(m=(f=(y=(g=gt(t))!=null?g:ft(j))!=null?y:yt(j))!=null?f:e==null?void 0:e.ssrSessionId)!=null?m:ut();pt(t,d,a);let s=mt(j,d),o=vt(t),r=s?!1:ht(j,d),i=!s&&!o&&!r;return{getSessionId:()=>d,isEphemeral:()=>i,destroy:()=>{d=null,Et(t),bt(j),St(j)}}}function ye(e){return`_snt_retry_${e.slice(0,12)}`}var It={push:()=>{},flush:()=>{},destroy:()=>{}};function Ct(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let a=JSON.parse(n);return Array.isArray(a)?(localStorage.removeItem(t),a.slice(-e)):[]}catch(n){return[]}}function me(e,t,n){try{let d=[...(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let o=JSON.parse(s);return Array.isArray(o)?o:[]}catch(s){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(d))}catch(a){}}function Me(e){var X,Z,ee;if(typeof window=="undefined")return It;let t=(X=e.flushIntervalMs)!=null?X:5e3,n=(Z=e.maxBatchSize)!=null?Z:20,a=(ee=e.maxRetrySize)!=null?ee:100,d=e.ingestUrl,s=e.apiKey,o=ye(s),r=[],i=new Set,c=[],l=h=>{for(let v of h)g.delete(v),!i.has(v)&&(i.add(v),c.push(v));for(;c.length>500;){let v=c.shift();v&&i.delete(v)}},g=new Set,y=h=>{i.has(h.id)||g.has(h.id)||(g.add(h.id),r.push(h))},f=Ct(a,o);for(let h of f)y(h);let m=0,E=0,I=h=>{if(h.length===0)return;let v=JSON.stringify(h),A=h.map(u=>u.id),k;try{k=fetch(d,{method:"POST",keepalive:!0,body:v,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(u){me(h,a,o);for(let p of A)g.delete(p);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6));return}let L=u=>{if(u.ok||u.status>=400&&u.status<500&&u.status!==429){l(A),E=0,m=0;return}me(h,a,o);for(let p of A)g.delete(p);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))};k instanceof Promise?k.then(L).catch(()=>{me(h,a,o);for(let u of A)g.delete(u);E++,m=Date.now()+Math.min(6e4,1e3*2**Math.min(E,6))}):L(k)},w=typeof TextEncoder!="undefined"?new TextEncoder:null,ae=h=>w?w.encode(h).length:h.length,G=h=>{let v=[],A=2;for(let k of h){let L=ae(JSON.stringify(k))+1;if(v.length>0&&A+L>57344||v.length>=n)break;v.push(k),A+=L}return v},N=()=>{try{if(Date.now()<m)return;for(;r.length>0;){let h=r.filter(A=>!i.has(A.id));if(r.length=0,h.length===0)break;let v=G(h);if(v.length===0)break;v.length<h.length&&r.push(...h.slice(v.length)),I(v)}}catch(h){}},R=!0,K=null;K=setInterval(()=>{R&&N()},t);let Q=()=>{document.visibilityState==="hidden"&&N()},V=()=>{N()};return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",V),{push(h){y(h),r.length>=n&&N()},flush:N,destroy(){R=!1,K!==null&&(clearInterval(K),K=null),document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",V),N()}}}var Se="_snt_asgn_";function de(e,t){return`${e}:${t}`}function xt(e,t){return`${Se}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ue(e){let t=e.slice(Se.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(a){return null}}function he(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Se)&&e.push(n)}return e}catch(e){return[]}}function Ge(e=18e5){let t=new Map,n=d=>d.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let d of he())try{let s=localStorage.getItem(d);if(!s)continue;let o=JSON.parse(s);if(n(o)){localStorage.removeItem(d);continue}let r=Ue(d);if(!r)continue;t.set(de(r.componentId,r.segment),o)}catch(s){}})(),{get(d,s){let o=t.get(de(d,s));return o?n(o)?(t.delete(de(d,s)),null):o:null},set(d,s,o){let r=de(d,s);t.set(r,o);try{localStorage.setItem(xt(d,s),JSON.stringify(o))}catch(i){}},invalidate(d){let s=`${d}:`;for(let o of[...t.keys()])o.startsWith(s)&&t.delete(o);for(let o of he()){let r=Ue(o);if((r==null?void 0:r.componentId)===d)try{localStorage.removeItem(o)}catch(i){}}},clear(){t.clear();for(let d of he())try{localStorage.removeItem(d)}catch(s){}}}}var Ke=["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 le(e){return $e(e)!==null}function $e(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ke.find(a=>t.includes(a.toLowerCase())))!=null?n:null}function W(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 q(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(d){}let a=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(a)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(a)?"social":"referral"}catch(n){return"direct"}}function J(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function z(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function ve(e){let t=At("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function At(e,t){var s,o,r,i,c,l,g;let n=(o=(s=t==null?void 0:t.userAgent)==null?void 0:s.trim())!=null?o:"",a=(i=(r=t==null?void 0:t.referer)==null?void 0:r.trim())!=null?i:"",d=(c=t==null?void 0:t.now)!=null?c:new Date;return{sessionId:e,ephemeral:!1,utmParams:(l=t==null?void 0:t.utmParams)!=null?l:{},deviceClass:n?W(n):"desktop",trafficSource:a?q(a,t==null?void 0:t.appOrigin):"direct",referrerDomain:J(a),timeOfDay:z(d),dayOfWeek:(g=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?g:"sun",automation:(t==null?void 0:t.webdriver)===!0||le(n)}}var Y=require("@sentientui/policy");function ue(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 ge(e){let t=ue(e);return(0,Y.slotResultFor)(t,(0,Y.slotBaselineArm)(t))}function be(e){return typeof e=="string"?e:(0,Y.canonicalArm)(e)}var re="_snt_snap:",Tt=["low","medium","high"];function Ee(e){try{let t=localStorage.getItem(re+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"||!Tt.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 se(e,t){try{localStorage.setItem(re+e,JSON.stringify(t))}catch(n){}}var Ce=require("@sentientui/policy");var fe=require("@sentientui/policy");var we="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Fe="[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.",Be=!1,pe=!1;function _t(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function je(e){var r;let t=ce({ssrSessionId:e.ssrSessionId}),n=(r=t.getSessionId())!=null?r:"local",a=_t(),d=import("@sentientui/core/local").then(i=>{let c=i;return c.LOCAL_ENGINE_AVAILABLE?(Be||(Be=!0,console.info(Fe)),c):(pe||(pe=!0,console.error(we)),null)}).catch(()=>(pe||(pe=!0,console.error(we)),null)),s=null;function o(i){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=i.persona,c.dataset.sentientConfidence=(0,fe.confidenceBand)(i.confidence))}return{isLocal:!0,async decide(i){var g,y,f;let c=await d;if(!c)return null;let l=c.createLocalEngine({sessionId:n,forcedPersona:a}).decide(i);return s=F(b({},l),{layoutOrder:(y=(g=l.layoutOrder)!=null?g:s==null?void 0:s.layoutOrder)!=null?y:null,slots:b(b({},(f=s==null?void 0:s.slots)!=null?f:{}),l.slots)}),se(e.apiKey||"local",{v:1,persona:s.persona,band:(0,fe.confidenceBand)(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),o(l),l},getSlotResult(i){var c,l,g;return(g=(l=s==null?void 0:s.slots[i])!=null?l:(c=e.initialSlots)==null?void 0:c[i])!=null?g:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:(0,fe.confidenceBand)(s.confidence)}:null},async assign(i,c){var y;let l=await d;return!l||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(y=l.createLocalEngine({sessionId:n,forcedPersona:a}).decide({components:[{id:i,variantIds:c}]}).assignments[i])!=null?y:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var We="https://api.sentient-ui.com/v1/events",ie=new Map,Rt=null;function Ie(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var H={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 kt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,a]of t)n.startsWith("utm_")&&(e[n]=a);return e}catch(e){return{}}}function qe(e){return e.replace(/\/events\/?$/,"")}function xe(){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 Ot(e){var o;let t=qe((o=e.ingestUrl)!=null?o:We),n={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,i,c){try{let l=new URLSearchParams({componentId:r});for(let f of i!=null?i:[])l.append("variantIds[]",f);let g=await fetch(`${t}/winner?${l.toString()}`,{headers:n});return g.ok?{variantId:(await g.json()).variantId,assignmentTtlMs:0}:i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}catch(l){return i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},d={track:r=>a.track(r),goal:(r,i,c,l)=>a.goal(r,i,c,l),componentGoal:(r,i,c)=>a.componentGoal(r,i,c),identify:r=>a.identify(r),getAssignment:(r,i)=>a.getAssignment(r,i),assign:(r,i,c,l)=>a.assign(r,i,c,l),decide:r=>a.decide(r),getSlotResult:r=>a.getSlotResult(r),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function s(r){a=r}return{proxy:d,setInner:s}}function Je(e){var V,X,Z,ee,h,v,A,k,L;if(typeof window=="undefined")return H;Rt=e.apiKey;let t=e.respectDoNotTrack!==!1&&xe(),n=e.consent===!1||t,a=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!a&&e.localMode!==!1)return n?(ie.set(e.apiKey||"local",{config:e,upgrade:null}),H):(ie.set(e.apiKey||"local",{config:e,upgrade:null}),je(e));if(n){if(e.preConsentBehavior==="statistical_winner"){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),H;let{proxy:u,setInner:p}=Ot(e);return ie.set(e.apiKey,{config:e,upgrade:t?null:p}),u}return ie.set(e.apiKey,{config:e,upgrade:null}),H}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."),H;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),H;let d=(V=e.ingestUrl)!=null?V:We,s=Date.now(),o=ce({ssrSessionId:e.ssrSessionId}),r=Ge(),i=Me({ingestUrl:d,apiKey:e.apiKey}),c=qe(d),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=W((X=navigator.userAgent)!=null?X:""),y=typeof window!="undefined"?window.location.origin:void 0,f=q((Z=document.referrer)!=null?Z:"",y),m=(ee=e.sessionSegment)!=null?ee:`${g}:${f}`,E=new Map,I=new Map,w=null,ae=u=>{for(let p of u)I.has(p.id)||I.set(p.id,ge(p))};if(e.initialSlots)for(let[u,p]of Object.entries(e.initialSlots))I.set(u,p);let G=Ee(e.apiKey);if(G)for(let[u,p]of Object.entries(G.slots))I.has(u)||I.set(u,p);let N={low:.15,medium:.5,high:.85};if(e.initialPersona)w=b({},e.initialPersona);else{let u=document.documentElement.dataset;u.sentientPersona?w={persona:u.sentientPersona,confidence:(v=N[(h=u.sentientConfidence)!=null?h:"low"])!=null?v:.15}:G&&(w={persona:G.persona,confidence:(A=N[G.band])!=null?A:.15})}if(e.initialAssignments)for(let[u,p]of Object.entries(e.initialAssignments))r.set(u,m,{variantId:p,assignedAt:Date.now(),segment:m,confidence:1});let R=Promise.resolve(),K=o.getSessionId();if(K){let u=J((k=document.referrer)!=null?k:""),p=b(b({sessionId:K,deviceClass:g,trafficSource:f,referrerDomain:u,utmParams:kt(),timeOfDay:z(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||le((L=navigator.userAgent)!=null?L:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{R=fetch(`${c}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(p),headers:l}).then(S=>{S.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(S){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:i});let Q={goal(u,p={},S=1,O=0){let x=o.getSessionId();if(!x)return;let T=Ie();R.then(()=>{fetch(`${c}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:x,name:u,metadata:p,weight:S,stepIndex:O,goalId:T}),headers:l}).catch(()=>{})})},componentGoal(u,p,S){var D,U,P;let O=o.getSessionId();if(!O)return;let x=r.get(u,m),T=x?null:(D=I.get(u))!=null?D:null;if(!x&&T===null){e.debug&&console.warn(`[sentient] componentGoal("${u}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let $=x?x.variantId:be(T),M={id:Ie(),sessionId:O,projectId:e.apiKey,componentId:u,variantId:$,eventType:"goal_achieved",goalType:p,payload:b({reward:(U=S==null?void 0:S.reward)!=null?U:1},(P=S==null?void 0:S.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-s};e.debug&&console.log("[sentient] componentGoal",M),R.then(()=>i.push(M))},identify(u){let p=o.getSessionId();p&&R.then(()=>{fetch(`${c}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:p,userId:u,ephemeral:o.isEphemeral()}),headers:l}).catch(()=>{})})},track(u){let p=o.getSessionId();if(!p)return;let S=F(b({},u),{id:Ie(),sessionId:p,timestamp:Date.now(),timeInSession:Date.now()-s});e.debug&&console.log("[sentient] track",S),R.then(()=>i.push(S))},getAssignment(u,p){return r.get(u,p)},async assign(u,p,S,O){let x=o.getSessionId();if(!x)return null;let T=r.get(u,m);if(T&&(p!=null&&p.length||T.content!==void 0))return{variantId:T.variantId,assignmentTtlMs:0,content:T.content};let $=E.get(u);if($)return $;let M=(async()=>{await R;try{let D={sessionId:x,componentId:u,variantIds:p};O!==void 0?D.agentDataByVariant=O:S!==void 0&&(D.agentData=S);let U=await fetch(`${c}/assign`,{method:"POST",body:JSON.stringify(D),headers:l});if(!U.ok)return null;let P=await U.json();return r.set(u,m,{variantId:P.variantId,assignedAt:Date.now(),segment:m,confidence:1,content:P.content}),P}catch(D){return null}finally{E.delete(u)}})();return E.set(u,M),M},async decide(u){var O,x,T,$,M,D,U,P,Re,ke;let p=o.getSessionId();if(!p)return null;let S=(O=u.slots)!=null?O:[];await R;try{let B={sessionId:p};u.sections&&u.sections.length>0&&(B.sections=u.sections.map(_=>({id:_}))),B.components=(x=u.components)!=null?x:[],S.length>0&&(B.slots=S.map(ue)),u.slotsFrom==="registry"&&(B.slotsFrom="registry"),u.v&&(B.v=u.v);let Oe=await fetch(`${c}/decide`,{method:"POST",body:JSON.stringify(B),headers:l});if(!Oe.ok)return ae(S),null;let C=await Oe.json(),te={};for(let _ of S)te[_.id]=($=(T=C.slots)==null?void 0:T[_.id])!=null?$:ge(_);if(C.slots)for(let[_,ne]of Object.entries(C.slots))_ in te||(te[_]=ne);for(let[_,ne]of Object.entries(te))I.set(_,ne);w={persona:(M=C.persona)!=null?M:"unknown",confidence:(D=C.confidence)!=null?D:0};for(let[_,ne]of Object.entries((U=C.assignments)!=null?U:{}))r.set(_,m,{variantId:ne,assignedAt:Date.now(),segment:m,confidence:1});return se(e.apiKey,b({v:1,persona:w.persona,band:(0,Ce.confidenceBand)(w.confidence),slots:Object.fromEntries(I),layoutOrder:(P=C.layoutOrder)!=null?P:null,savedAt:Date.now()},C.slotConfig?{slotConfig:C.slotConfig}:{})),b(b({layoutOrder:(Re=C.layoutOrder)!=null?Re:null,assignments:(ke=C.assignments)!=null?ke:{},slots:te,persona:w.persona,confidence:w.confidence},C.slotConfig?{slotConfig:C.slotConfig}:{}),C.goals?{goals:C.goals}:{})}catch(B){return ae(S),null}},getSlotResult(u){var p;return(p=I.get(u))!=null?p:null},getPersona(){return w?{persona:w.persona,confidence:w.confidence,band:(0,Ce.confidenceBand)(w.confidence)}:null},async fetchWeights(){var u;try{let p=await fetch(`${c}/weights`,{headers:l});return p.ok?(u=(await p.json()).components)!=null?u:[]:[]}catch(p){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){i.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){i.destroy(),o.destroy();try{localStorage.removeItem(re+e.apiKey),localStorage.removeItem(ye(e.apiKey))}catch(u){}e.debug&&console.log("[sentient] destroyed")}};if(ie.set(e.apiKey,{config:e,upgrade:null}),e.debug){let u=window;u.__sentient&&(u.__sentient.client=Q)}return Q}var ze=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Dt=[["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]],Nt=[["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 Pt(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function Lt(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,a]of Dt)if(a.test(t))return{type:n,strength:"strong"};for(let[n,a]of Nt)if(a.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 Mt(e){var n,a;let t=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((a=e.className)!=null?a:"")}`,headingText:Pt(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length}}function Ye(e){return Lt(Mt(e)).type}var Ut=new Set(["SECTION","ARTICLE","MAIN","DIV"]),Gt="h1, h2, h3",Kt={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function Ae(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function $t(e){var t,n,a;try{let d=e;for(let s of Object.keys(d)){if(!s.startsWith("__reactFiber")&&!s.startsWith("__reactInternalInstance"))continue;let o=d[s],r=(a=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?a:(n=o==null?void 0:o.type)==null?void 0:n.name;if(r&&r.length>1)return r}}catch(d){}}function Bt(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var He=new Set(ze);function Ft(e){let t=e.getAttribute("data-sentient-type");if(t&&He.has(t))return t;let n=e.getAttribute("role");return n&&He.has(n)?n:Ye(e)}function jt(e){var t,n;return(n=(t=e.getAttribute("data-sentient-id"))!=null?t:e.getAttribute("id"))!=null?n:e.tagName.toLowerCase()}function Wt(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Te(e,t){var a,d,s;let n=e.querySelector(Gt);return{componentId:jt(e),semanticType:Ft(e),ariaLabel:(a=e.getAttribute("aria-label"))!=null?a:void 0,headingText:(s=(d=n==null?void 0:n.textContent)==null?void 0:d.trim())!=null?s:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:Wt(e),reactComponentName:$t(e),dataAttributes:Bt(e)}}function Qe(e){var s;let t=[],n=new Set,a="__root__",d=new Map;for(let[o,r]of e){let i=o.parentElement,c=a;for(;i;){if(e.has(i)){c=e.get(i);let g=e.get(o),y=`${c}->${g}`;!n.has(y)&&c!==g&&(n.add(y),t.push({fromComponentId:c,toComponentId:g,weight:.6}));break}i=i.parentElement}let l=(s=d.get(c))!=null?s:[];l.push(o),d.set(c,l)}for(let o of d.values())if(!(o.length<2))for(let r=0;r<o.length;r++)for(let i=r+1;i<o.length;i++){let c=e.get(o[r]),l=e.get(o[i]);if(c===l)continue;let g=`${c}->${l}::sib`,y=`${l}->${c}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.3})),n.has(y)||(n.add(y),t.push({fromComponentId:l,toComponentId:c,weight:.3}))}return t}function qt(e){let t=[],n=new Set,a=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let r=Te(o,e);t.push(r),a.set(o,r.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let r=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!r&&!i)return;n.add(o);let c=Te(o,e);t.push(c),a.set(o,c.componentId)}),{nodes:t,edges:Qe(a)}}function Ve(){if(typeof window=="undefined")return Kt;let e=null,t=0,n=null,a=r=>{try{let i=window.getComputedStyle(r),c=parseFloat(i.fontSize)||12,l=parseFloat(i.zIndex)||0,g=r.getBoundingClientRect(),y=Math.max(g.top,0),f=window.innerHeight||1,m=1/(y/f+1),E=Ae(c,12,48)*.4+Ae(m,0,1)*.4+Ae(l,0,100)*.2;return Math.max(0,Math.min(1,E))}catch(i){return .5}};return{scan:()=>new Promise(r=>{let i=()=>{let{nodes:c,edges:l}=qt(a);r({nodes:c,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(i,{timeout:100}):i()}catch(c){i()}}),observe:r=>{n=r;try{e=new MutationObserver(i=>{let c=[],l=new Map;for(let g of i)g.type==="childList"&&g.addedNodes.forEach(y=>{if(!(y instanceof Element)||!Ut.has(y.tagName))return;let f=y.hasAttribute("data-sentient-id"),m=y.hasAttribute("aria-label");if(!f&&!m)return;let E=Te(y,a);c.push(E),l.set(y,E.componentId)});c.length>0&&n&&n({nodes:c,edges:Qe(l),addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(i){}},getProminenceScore:a,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(r){}t=0,n=null}}}var _e="_snt_graph_nodes",Xe="_snt_graph_edges",Jt={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function zt(e){var t;return(t=Jt[e])!=null?t:[]}function Yt(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function Ht(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var Qt=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Vt(e){return Qt.has(e)?e:"generic"}function Xt(e,t,n){let a=`${e}:${t}:${n.join(",")}`,d=5381;for(let s=0;s<a.length;s++)d=(d<<5)+d+a.charCodeAt(s)&4294967295;return(d>>>0).toString(16).padStart(8,"0")}function Ze(e){let t=new Map,n=new Map,a=()=>{typeof window!="undefined"&&Ht(_e,[...t.values()])},d=s=>{var o;try{let r=JSON.parse(s);t.clear();for(let i of(o=r.pageNodes)!=null?o:[])t.set(i.componentId,i)}catch(r){}};if(typeof window!="undefined"){let s=Yt(_e,[]);for(let o of s)t.set(o.componentId,o);try{localStorage.removeItem(Xe)}catch(o){}}return{addPageNode(s){t.set(s.componentId,s),a()},addStructuralEdge(s){let o=`${s.fromComponentId}->${s.toComponentId}`;n.set(o,s)},syncOnce(){var o,r;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let s=[...t.values()];if(s.length!==0)try{let i=new Map;for(let f of s){let m=(o=i.get(f.semanticType))!=null?o:[];m.push(f),i.set(f.semanticType,m)}let c=[],l=new Set;for(let f of s)for(let m of zt(f.semanticType)){let E=(r=i.get(m))!=null?r:[];for(let I of E){if(I.componentId===f.componentId)continue;let w=`semantic:${f.componentId}->${I.componentId}`;l.has(w)||(l.add(w),c.push({fromComponentId:f.componentId,toComponentId:I.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(s.map(f=>f.componentId));for(let f of n.values()){if(!g.has(f.fromComponentId)||!g.has(f.toComponentId))continue;let m=`structural:${f.fromComponentId}->${f.toComponentId}`;l.has(m)||(l.add(m),c.push({fromComponentId:f.fromComponentId,toComponentId:f.toComponentId,type:"structural",weight:f.weight,confidence:1}))}let y={pageUrl:window.location.href,nodes:s.map(f=>{let m=Vt(f.semanticType);return{componentId:f.componentId,semanticType:m,answers:f.answers,contentHash:Xt(f.componentId,m,f.answers),prominenceScore:f.prominenceScore,depthInPage:f.depth}}),edges:c};fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:b({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(y)}).catch(()=>{})}catch(i){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:d,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(_e),localStorage.removeItem(Xe)}catch(s){}}}}var Zt="https://api.sentient-ui.com/v1/events";function en(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}function tn(e){var c;let t=Je(e),n=e.respectDoNotTrack!==!1&&xe(),a=e.consent===!1||n;if(!e.graph||!e.apiKey||a||typeof window=="undefined")return t;let d=Ve(),s=(c=e.ingestUrl)!=null?c:Zt,o=Ze({syncUrl:s.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:en()});try{let l=localStorage.getItem("_snt_graph_nodes");l&&o.restore(JSON.stringify({pageNodes:JSON.parse(l)}))}catch(l){}d.scan().then(l=>{for(let g of l.nodes)o.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of l.edges)o.addStructuralEdge(g);o.syncOnce()});let r=null,i=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,o.syncOnce()},500)};return d.observe(l=>{for(let g of l.nodes)o.addPageNode({id:g.componentId,componentId:g.componentId,semanticType:g.semanticType,answers:g.headingText?[g.headingText]:[],prominenceScore:g.prominenceScore,depth:g.depth});for(let g of l.edges)o.addStructuralEdge(g);i()}),F(b({},t),{getGraph:()=>o.snapshot(),dispose:()=>{r!==null&&clearTimeout(r),d.destroy(),o.destroy(),t.dispose()},destroy:()=>{r!==null&&clearTimeout(r),d.destroy(),o.destroy(),t.destroy()}})}0&&(module.exports={deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,init,referrerDomainFromReferer});
|
package/dist/index-graph.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as v,d as w}from"./chunk-KZHVBFG7.mjs";import{h as N,j as T}from"./chunk-CWUFS37B.mjs";import{d as R,e as P,f as D,g as k,h as G}from"./chunk-P5ZTJLZE.mjs";import{a as h,b}from"./chunk-HGGX55FR.mjs";var $=new Set(["SECTION","ARTICLE","MAIN","DIV"]),L="h1, h2, h3",U={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function S(e,t,o){return o<=t?0:Math.max(0,Math.min(1,(e-t)/(o-t)))}function j(e){var t,o,g;try{let u=e;for(let s of Object.keys(u)){if(!s.startsWith("__reactFiber")&&!s.startsWith("__reactInternalInstance"))continue;let n=u[s],r=(g=(t=n==null?void 0:n.type)==null?void 0:t.displayName)!=null?g:(o=n==null?void 0:n.type)==null?void 0:o.name;if(r&&r.length>1)return r}}catch(u){}}function F(e){let t={};for(let o of Array.from(e.attributes))o.name.startsWith("data-")&&(t[o.name]=o.value);return t}var A=new Set(v);function K(e){let t=e.getAttribute("data-sentient-type");if(t&&A.has(t))return t;let o=e.getAttribute("role");return o&&A.has(o)?o:w(e)}function q(e){var t,o;return(o=(t=e.getAttribute("data-sentient-id"))!=null?t:e.getAttribute("id"))!=null?o:e.tagName.toLowerCase()}function z(e){let t=0,o=e.parentElement;for(;o;)t++,o=o.parentElement;return t}function I(e,t){var g,u,s;let o=e.querySelector(L);return{componentId:q(e),semanticType:K(e),ariaLabel:(g=e.getAttribute("aria-label"))!=null?g:void 0,headingText:(s=(u=o==null?void 0:o.textContent)==null?void 0:u.trim())!=null?s:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:z(e),reactComponentName:j(e),dataAttributes:F(e)}}function _(e){var s;let t=[],o=new Set,g="__root__",u=new Map;for(let[n,r]of e){let i=n.parentElement,c=g;for(;i;){if(e.has(i)){c=e.get(i);let a=e.get(n),m=`${c}->${a}`;!o.has(m)&&c!==a&&(o.add(m),t.push({fromComponentId:c,toComponentId:a,weight:.6}));break}i=i.parentElement}let d=(s=u.get(c))!=null?s:[];d.push(n),u.set(c,d)}for(let n of u.values())if(!(n.length<2))for(let r=0;r<n.length;r++)for(let i=r+1;i<n.length;i++){let c=e.get(n[r]),d=e.get(n[i]);if(c===d)continue;let a=`${c}->${d}::sib`,m=`${d}->${c}::sib`;o.has(a)||(o.add(a),t.push({fromComponentId:c,toComponentId:d,weight:.3})),o.has(m)||(o.add(m),t.push({fromComponentId:d,toComponentId:c,weight:.3}))}return t}function B(e){let t=[],o=new Set,g=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(n=>{if(n instanceof Element&&!o.has(n)){o.add(n);let r=I(n,e);t.push(r),g.set(n,r.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(n=>{if(!(n instanceof Element)||o.has(n))return;let r=n.hasAttribute("aria-label"),i=n.hasAttribute("data-sentient-id");if(!r&&!i)return;o.add(n);let c=I(n,e);t.push(c),g.set(n,c.componentId)}),{nodes:t,edges:_(g)}}function x(){if(typeof window=="undefined")return U;let e=null,t=0,o=null,g=r=>{try{let i=window.getComputedStyle(r),c=parseFloat(i.fontSize)||12,d=parseFloat(i.zIndex)||0,a=r.getBoundingClientRect(),m=Math.max(a.top,0),p=window.innerHeight||1,l=1/(m/p+1),f=S(c,12,48)*.4+S(l,0,1)*.4+S(d,0,100)*.2;return Math.max(0,Math.min(1,f))}catch(i){return .5}};return{scan:()=>new Promise(r=>{let i=()=>{let{nodes:c,edges:d}=B(g);r({nodes:c,edges:d,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(i,{timeout:100}):i()}catch(c){i()}}),observe:r=>{o=r;try{e=new MutationObserver(i=>{let c=[],d=new Map;for(let a of i)a.type==="childList"&&a.addedNodes.forEach(m=>{if(!(m instanceof Element)||!$.has(m.tagName))return;let p=m.hasAttribute("data-sentient-id"),l=m.hasAttribute("aria-label");if(!p&&!l)return;let f=I(m,g);c.push(f),d.set(m,f.componentId)});c.length>0&&o&&o({nodes:c,edges:_(d),addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(i){}},getProminenceScore:g,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(r){}t=0,o=null}}}var E="_snt_graph_nodes",O="_snt_graph_edges",H={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function J(e){var t;return(t=H[e])!=null?t:[]}function V(e,t){try{let o=localStorage.getItem(e);return o?JSON.parse(o):t}catch(o){return t}}function Y(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(o){}}var W=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Q(e){return W.has(e)?e:"generic"}function X(e,t,o){let g=`${e}:${t}:${o.join(",")}`,u=5381;for(let s=0;s<g.length;s++)u=(u<<5)+u+g.charCodeAt(s)&4294967295;return(u>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,o=new Map,g=()=>{typeof window!="undefined"&&Y(E,[...t.values()])},u=s=>{var n;try{let r=JSON.parse(s);t.clear();for(let i of(n=r.pageNodes)!=null?n:[])t.set(i.componentId,i)}catch(r){}};if(typeof window!="undefined"){let s=V(E,[]);for(let n of s)t.set(n.componentId,n);try{localStorage.removeItem(O)}catch(n){}}return{addPageNode(s){t.set(s.componentId,s),g()},addStructuralEdge(s){let n=`${s.fromComponentId}->${s.toComponentId}`;o.set(n,s)},syncOnce(){var n,r;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let s=[...t.values()];if(s.length!==0)try{let i=new Map;for(let p of s){let l=(n=i.get(p.semanticType))!=null?n:[];l.push(p),i.set(p.semanticType,l)}let c=[],d=new Set;for(let p of s)for(let l of J(p.semanticType)){let f=(r=i.get(l))!=null?r:[];for(let y of f){if(y.componentId===p.componentId)continue;let C=`semantic:${p.componentId}->${y.componentId}`;d.has(C)||(d.add(C),c.push({fromComponentId:p.componentId,toComponentId:y.componentId,type:"semantic",weight:.4,confidence:.9}))}}let a=new Set(s.map(p=>p.componentId));for(let p of o.values()){if(!a.has(p.fromComponentId)||!a.has(p.toComponentId))continue;let l=`structural:${p.fromComponentId}->${p.toComponentId}`;d.has(l)||(d.add(l),c.push({fromComponentId:p.fromComponentId,toComponentId:p.toComponentId,type:"structural",weight:p.weight,confidence:1}))}let m={pageUrl:window.location.href,nodes:s.map(p=>{let l=Q(p.semanticType);return{componentId:p.componentId,semanticType:l,answers:p.answers,contentHash:X(p.componentId,l,p.answers),prominenceScore:p.prominenceScore,depthInPage:p.depth}}),edges:c};fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:h({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(m)}).catch(()=>{})}catch(i){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:u,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(E),localStorage.removeItem(O)}catch(s){}}}}var Z="https://api.sentient-ui.com/v1/events";function ee(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}function ce(e){var c;let t=T(e),o=e.respectDoNotTrack!==!1&&N(),g=e.consent===!1||o;if(!e.graph||g||typeof window=="undefined")return t;let u=x(),s=(c=e.ingestUrl)!=null?c:Z,n=M({syncUrl:s.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ee()});try{let d=localStorage.getItem("_snt_graph_nodes");d&&n.restore(JSON.stringify({pageNodes:JSON.parse(d)}))}catch(d){}u.scan().then(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);n.syncOnce()});let r=null,i=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,n.syncOnce()},500)};return u.observe(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);i()}),b(h({},t),{getGraph:()=>n.snapshot(),dispose:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.dispose()},destroy:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.destroy()}})}export{G as deriveSessionSegment,R as detectDeviceClass,k as detectTimeOfDay,P as detectTrafficSource,ce as init,D as referrerDomainFromReferer};
|
|
1
|
+
import{a as v,d as w}from"./chunk-KZHVBFG7.mjs";import{h as N,j as T}from"./chunk-CWUFS37B.mjs";import{d as R,e as P,f as D,g as k,h as G}from"./chunk-P5ZTJLZE.mjs";import{a as h,b}from"./chunk-HGGX55FR.mjs";var $=new Set(["SECTION","ARTICLE","MAIN","DIV"]),L="h1, h2, h3",U={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function S(e,t,o){return o<=t?0:Math.max(0,Math.min(1,(e-t)/(o-t)))}function j(e){var t,o,g;try{let u=e;for(let s of Object.keys(u)){if(!s.startsWith("__reactFiber")&&!s.startsWith("__reactInternalInstance"))continue;let n=u[s],r=(g=(t=n==null?void 0:n.type)==null?void 0:t.displayName)!=null?g:(o=n==null?void 0:n.type)==null?void 0:o.name;if(r&&r.length>1)return r}}catch(u){}}function F(e){let t={};for(let o of Array.from(e.attributes))o.name.startsWith("data-")&&(t[o.name]=o.value);return t}var A=new Set(v);function K(e){let t=e.getAttribute("data-sentient-type");if(t&&A.has(t))return t;let o=e.getAttribute("role");return o&&A.has(o)?o:w(e)}function q(e){var t,o;return(o=(t=e.getAttribute("data-sentient-id"))!=null?t:e.getAttribute("id"))!=null?o:e.tagName.toLowerCase()}function z(e){let t=0,o=e.parentElement;for(;o;)t++,o=o.parentElement;return t}function I(e,t){var g,u,s;let o=e.querySelector(L);return{componentId:q(e),semanticType:K(e),ariaLabel:(g=e.getAttribute("aria-label"))!=null?g:void 0,headingText:(s=(u=o==null?void 0:o.textContent)==null?void 0:u.trim())!=null?s:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:z(e),reactComponentName:j(e),dataAttributes:F(e)}}function _(e){var s;let t=[],o=new Set,g="__root__",u=new Map;for(let[n,r]of e){let i=n.parentElement,c=g;for(;i;){if(e.has(i)){c=e.get(i);let a=e.get(n),m=`${c}->${a}`;!o.has(m)&&c!==a&&(o.add(m),t.push({fromComponentId:c,toComponentId:a,weight:.6}));break}i=i.parentElement}let d=(s=u.get(c))!=null?s:[];d.push(n),u.set(c,d)}for(let n of u.values())if(!(n.length<2))for(let r=0;r<n.length;r++)for(let i=r+1;i<n.length;i++){let c=e.get(n[r]),d=e.get(n[i]);if(c===d)continue;let a=`${c}->${d}::sib`,m=`${d}->${c}::sib`;o.has(a)||(o.add(a),t.push({fromComponentId:c,toComponentId:d,weight:.3})),o.has(m)||(o.add(m),t.push({fromComponentId:d,toComponentId:c,weight:.3}))}return t}function B(e){let t=[],o=new Set,g=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(n=>{if(n instanceof Element&&!o.has(n)){o.add(n);let r=I(n,e);t.push(r),g.set(n,r.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(n=>{if(!(n instanceof Element)||o.has(n))return;let r=n.hasAttribute("aria-label"),i=n.hasAttribute("data-sentient-id");if(!r&&!i)return;o.add(n);let c=I(n,e);t.push(c),g.set(n,c.componentId)}),{nodes:t,edges:_(g)}}function x(){if(typeof window=="undefined")return U;let e=null,t=0,o=null,g=r=>{try{let i=window.getComputedStyle(r),c=parseFloat(i.fontSize)||12,d=parseFloat(i.zIndex)||0,a=r.getBoundingClientRect(),m=Math.max(a.top,0),p=window.innerHeight||1,l=1/(m/p+1),f=S(c,12,48)*.4+S(l,0,1)*.4+S(d,0,100)*.2;return Math.max(0,Math.min(1,f))}catch(i){return .5}};return{scan:()=>new Promise(r=>{let i=()=>{let{nodes:c,edges:d}=B(g);r({nodes:c,edges:d,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(i,{timeout:100}):i()}catch(c){i()}}),observe:r=>{o=r;try{e=new MutationObserver(i=>{let c=[],d=new Map;for(let a of i)a.type==="childList"&&a.addedNodes.forEach(m=>{if(!(m instanceof Element)||!$.has(m.tagName))return;let p=m.hasAttribute("data-sentient-id"),l=m.hasAttribute("aria-label");if(!p&&!l)return;let f=I(m,g);c.push(f),d.set(m,f.componentId)});c.length>0&&o&&o({nodes:c,edges:_(d),addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(i){}},getProminenceScore:g,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(r){}t=0,o=null}}}var E="_snt_graph_nodes",O="_snt_graph_edges",H={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function J(e){var t;return(t=H[e])!=null?t:[]}function V(e,t){try{let o=localStorage.getItem(e);return o?JSON.parse(o):t}catch(o){return t}}function Y(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(o){}}var W=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Q(e){return W.has(e)?e:"generic"}function X(e,t,o){let g=`${e}:${t}:${o.join(",")}`,u=5381;for(let s=0;s<g.length;s++)u=(u<<5)+u+g.charCodeAt(s)&4294967295;return(u>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,o=new Map,g=()=>{typeof window!="undefined"&&Y(E,[...t.values()])},u=s=>{var n;try{let r=JSON.parse(s);t.clear();for(let i of(n=r.pageNodes)!=null?n:[])t.set(i.componentId,i)}catch(r){}};if(typeof window!="undefined"){let s=V(E,[]);for(let n of s)t.set(n.componentId,n);try{localStorage.removeItem(O)}catch(n){}}return{addPageNode(s){t.set(s.componentId,s),g()},addStructuralEdge(s){let n=`${s.fromComponentId}->${s.toComponentId}`;o.set(n,s)},syncOnce(){var n,r;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let s=[...t.values()];if(s.length!==0)try{let i=new Map;for(let p of s){let l=(n=i.get(p.semanticType))!=null?n:[];l.push(p),i.set(p.semanticType,l)}let c=[],d=new Set;for(let p of s)for(let l of J(p.semanticType)){let f=(r=i.get(l))!=null?r:[];for(let y of f){if(y.componentId===p.componentId)continue;let C=`semantic:${p.componentId}->${y.componentId}`;d.has(C)||(d.add(C),c.push({fromComponentId:p.componentId,toComponentId:y.componentId,type:"semantic",weight:.4,confidence:.9}))}}let a=new Set(s.map(p=>p.componentId));for(let p of o.values()){if(!a.has(p.fromComponentId)||!a.has(p.toComponentId))continue;let l=`structural:${p.fromComponentId}->${p.toComponentId}`;d.has(l)||(d.add(l),c.push({fromComponentId:p.fromComponentId,toComponentId:p.toComponentId,type:"structural",weight:p.weight,confidence:1}))}let m={pageUrl:window.location.href,nodes:s.map(p=>{let l=Q(p.semanticType);return{componentId:p.componentId,semanticType:l,answers:p.answers,contentHash:X(p.componentId,l,p.answers),prominenceScore:p.prominenceScore,depthInPage:p.depth}}),edges:c};fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:h({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(m)}).catch(()=>{})}catch(i){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:u,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(E),localStorage.removeItem(O)}catch(s){}}}}var Z="https://api.sentient-ui.com/v1/events";function ee(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}function ce(e){var c;let t=T(e),o=e.respectDoNotTrack!==!1&&N(),g=e.consent===!1||o;if(!e.graph||!e.apiKey||g||typeof window=="undefined")return t;let u=x(),s=(c=e.ingestUrl)!=null?c:Z,n=M({syncUrl:s.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ee()});try{let d=localStorage.getItem("_snt_graph_nodes");d&&n.restore(JSON.stringify({pageNodes:JSON.parse(d)}))}catch(d){}u.scan().then(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);n.syncOnce()});let r=null,i=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,n.syncOnce()},500)};return u.observe(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);i()}),b(h({},t),{getGraph:()=>n.snapshot(),dispose:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.dispose()},destroy:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.destroy()}})}export{G as deriveSessionSegment,R as detectDeviceClass,k as detectTimeOfDay,P as detectTrafficSource,ce as init,D as referrerDomainFromReferer};
|