@sentientui/react 0.42.1 → 0.42.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.mjs +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Fr=Object.create;var Ve=Object.defineProperty,Vr=Object.defineProperties,Mr=Object.getOwnPropertyDescriptor,$r=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols,Br=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable;var en=(e,t,n)=>t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))vt.call(t,n)&&en(e,n,t[n]);if(He)for(var n of He(t))tn.call(t,n)&&en(e,n,t[n]);return e},V=(e,t)=>Vr(e,$r(t));var Me=(e,t)=>{var n={};for(var r in e)vt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&He)for(var r of He(e))t.indexOf(r)<0&&tn.call(e,r)&&(n[r]=e[r]);return n};var Ur=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},nn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jr(t))!vt.call(e,i)&&i!==n&&Ve(e,i,{get:()=>t[i],enumerable:!(r=Mr(t,i))||r.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?Fr(Br(e)):{},nn(t||!e||!e.__esModule?Ve(n,"default",{value:e,enumerable:!0}):n,e)),Wr=e=>nn(Ve({},"__esModule",{value:!0}),e);var xi={};Ur(xi,{Adaptive:()=>ar,AdaptiveGroup:()=>Cr,AdaptiveProvider:()=>Tn,AdaptiveSlot:()=>Ie,AdaptiveText:()=>lr,SentientPersonaScript:()=>yr,buildAgentFeed:()=>Er,consentWatcher:()=>Ir.consentWatcher,defineAgentContent:()=>Gr,detectSegment:()=>Mt.deriveSessionSegment,getAgentContent:()=>$t,grantConsent:()=>Tr.grantConsent,renderAgentJsonLd:()=>Pr,renderAgentJsonLdBody:()=>jt,renderAgentMarkdown:()=>Nr,renderBlocks:()=>xe,renderCompose:()=>ot,useAdaptive:()=>Ar,useAdaptiveApiBaseUrl:()=>jn,useAdaptiveGoal:()=>De,useAdaptivePersona:()=>hr,useAdaptiveTokens:()=>xr,useAssignment:()=>rt,useGoal:()=>gr,useInitialAssignments:()=>Ze,useLayoutOrder:()=>Ln,usePageGoal:()=>cr,useSentient:()=>M,useSessionSegment:()=>Te});module.exports=Wr(xi);var C=require("react"),Ye=require("@sentientui/core");var rn=new Map,ze=new Map;function on(e,t){let n=ze.get(e);return n||(n=new Set,ze.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ze.delete(e)}}function sn(e,t){rn.set(e,t);let n=ze.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function St(e){var t;return(t=rn.get(e))!=null?t:null}var Kr={on:!1,listeners:new Set};function an(){if(typeof window=="undefined")return Kr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ht(){return an().on}function ln(e){let t=an().listeners;return t.add(e),()=>{t.delete(e)}}function un(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var bt="sentient:overrides-changed";function cn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function wt(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(bt))}function Q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(bt,e),()=>window.removeEventListener(bt,e))}function dn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function te(e){return typeof e=="string"?{type:"click"}:e}function pe(e){return typeof e=="string"?e:e.type}function ue(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var xt=new Set,kt=!1;function fn(e){if(xt.has(e))return!0;if(xt.add(e),!kt){kt=!0;let t=()=>{kt=!1,xt.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Jr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function gn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Jr(r))return!0;r=r.parentElement}return!1}function ce(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,S=[];return t.steps.forEach(({goal:c,name:w,weight:x},m)=>{let y=(h=!1)=>{s.has(m)||h&&r!==void 0&&fn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(c.type==="click"){let h=v=>{let f=v.target;f instanceof Element&&gn(f,e,c.selector)&&y()};e.addEventListener("click",h),S.push(()=>e.removeEventListener("click",h));return}if(c.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),S.push(()=>e.removeEventListener("submit",h));return}if(c.type==="scroll_depth"){let h=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),S.push(()=>v.disconnect())}}),()=>{for(let c of S)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,S)=>S)),l=()=>{r!==void 0&&fn(r)||n.fireGoal()},a=(s,S=!1)=>{o.delete(s),o.size===0&&(S?l():n.fireGoal())},u=[];return i.forEach((s,S)=>{if(s.type==="click"){let c=w=>{let x=w.target;x instanceof Element&&gn(x,e,s.selector)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=c){t.type==="composite"?a(S,!0):l(),w.disconnect();break}},{threshold:[c]});w.observe(e),u.push(()=>w.disconnect());return}}),()=>{for(let s of u)s()}}var mn=new Set,pn=new Set;function Hr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var Xr=12;function zr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===Xr||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function de(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Hr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(pn.has(a))return;pn.add(a);let u=o&&!mn.has(l)?zr(n,o):null,s=u!==null&&u.length>=2;s&&mn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ye(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var qr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function he(){if(typeof window=="undefined")return qr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function $e(){he().version+=1;for(let e of he().listeners)e()}var yn=()=>{};function vn(e){return F()?(he().components.set(e.id,e),$e(),()=>{he().components.delete(e.id),$e()}):yn}function Oe(e){return F()?(he().slots.set(e.id,e),$e(),()=>{he().slots.delete(e.id),$e()}):yn}function Rt(e){F()&&(he().sections=[...e],$e())}var Sn="0.42.1",At=Sn!=="0.0.0-dev"?{name:"react",version:Sn}:void 0;function Yr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ge(e,t){Yr()[e]=t}function hn(e){window.__sentient_vocabulary_override=e}function bn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Zr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ee(e,t){Zr()[e]=t}function wn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var _t="__snt_editor_token",Pe=null,Ct=!1;function xn(){return Ct}function Qr(){try{return sessionStorage.getItem(_t)}catch(e){return null}}function qe(e){if(Pe)return Pe;let t=typeof window=="undefined"?null:wn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Qr();return Ct=!!n,Pe=Promise.resolve(n?{token:n,fresh:!1}:null),Pe}return Ct=!0,Pe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(_t,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Pe}function kn(){try{sessionStorage.removeItem(_t)}catch(e){}}var Rn="sentient_preview_cell",An="sentient_refresh_region",Ot="sentient-cell-preview-bar",be="__preview__",Ne=null;function Cn(e){if((Ne==null?void 0:Ne.slotId)!==e)return null;let t=Ne;return Ne=null,t}function _n(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>we(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>we("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function On(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ot))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(Rn),n=u.get(An)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=qe(r);if(!xn())return;if(n){Ne={slotId:n,session:i,base:r},Ge(n,{kind:"arms"}),Ee(n,be),wt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(we(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){we(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&hn(s.vocabulary),s.compose!=null)Ge(l,{kind:"arms",compose:{[be]:s.compose}}),Ee(l,be);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ge(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Ee(l,be);else if(s.blocks!=null)Ge(l,{kind:"arms",blocks:{[be]:s.blocks}}),Ee(l,be);else if(s.content!=null)Ge(l,{kind:"arms",content:s.content}),Ee(l,be);else{we("Nothing to preview in that square yet.");return}wt(),we(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var S;try{(S=document.querySelector(`[data-sentient-slot="${l}"]`))==null||S.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>we("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function we(e){var i;if(document.getElementById(Ot))return;let t=document.createElement("div");t.id=Ot,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{kn();let o=new URL(window.location.href);o.searchParams.delete(Rn),o.searchParams.delete(An),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Gn=!1;function En(e){if(Gn||typeof window=="undefined")return;Gn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");qe(t).then(n=>{!n||!("token"in n)||!n.fresh||ei(t,n.token)})}function ei(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Bn=require("react/jsx-runtime");function ti(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Ye.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Nn="https://api.sentient-ui.com/v1",Y=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Nn,debug:!1}),Pn=!1,Gt=new Set;function ni(e,t,n){let r=(0,C.useRef)(n);r.current=n;let[i,o]=(0,C.useState)(null),[l,a]=(0,C.useState)(!1),u=(0,C.useRef)(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(V(p({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,C.useEffect)(()=>{let S=u.current;if(S===void 0||typeof window=="undefined")return;let c,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let y=x(typeof S=="object"&&S.cmp===void 0&&S.check?p(V(p({},S),{check:()=>u.current.check()}),S.refused?{refused:()=>{var f,b;return((b=(f=u.current).refused)==null?void 0:b.call(f))===!0}}:{}):S),h=!1,v=()=>{let f=y.refused()&&y.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=y.read();b!==null&&Gt.add(t),o(b!=null?b:Gt.has(t)?!1:null)};v(),c=y.subscribe(v)}),()=>{w=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function Tn(e){var N,G,R,A,d;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:ti()}),[i,o]=(0,C.useState)(ht());(0,C.useEffect)(()=>ln(()=>o(ht())),[]),(0,C.useEffect)(()=>{On(e.apiBaseUrl),En(e.apiBaseUrl)},[]);let l=(0,C.useRef)(()=>{}),a=ni(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(N=a.granted)!=null?N:Gt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,S=(0,C.useRef)(s);S.current=s;let c=(0,C.useRef)(null),w=(0,C.useRef)(!1),x=(0,C.useRef)([]),m=(0,C.useRef)(!1);l.current=()=>{var I;x.current=[],m.current=!0;let g=c.current;g!=null&&g.gated?g.dispose():(I=g==null?void 0:g.takeHeld)==null||I.call(g)},(0,C.useEffect)(()=>{var K,J;if(S.current&&u===!1&&(x.current=[]),u===!1&&w.current&&(S.current&&((K=c.current)==null||K.destroy()),c.current=null,w.current=!1),u===!1&&!e.preConsentBehavior){S.current&&((J=c.current)==null||J.destroy()),c.current=null,n(null);return}let g=u!==!1;g&&(m.current=!1);let I=j=>{!g&&m.current&&j.gated&&j.dispose()},T=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},At?{sdk:At}:{}),_=!1,P=null,U=null,W=j=>{for(let ae of x.current.splice(0))setTimeout(()=>{if(c.current!==j){m.current||x.current.push(ae);return}try{ae(j)}catch(Fe){}},0)},X=j=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:ae})=>{_||(U=ae(j,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:j})=>{_||(P=j(V(p({},T),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),I(P),c.current=P,w.current=g,W(P),n(P),X(P))}):(P=(0,Ye.init)(T),I(P),c.current=P,w.current=g,W(P),n(P),X(P)),()=>{var j,ae;_=!0,U==null||U(),x.current=x.current.concat((ae=(j=P==null?void 0:P.takeHeld)==null?void 0:j.call(P))!=null?ae:[]),P==null||P.dispose()}},[u]),(0,C.useEffect)(()=>{if(!t)return;let g=!1,I=async()=>{if(g)return;let _;try{_=await t.fetchWeights()}catch(P){return}if(!g)for(let P of _){let U={componentId:P.componentId,updatedAt:P.updatedAt,variants:P.variants.map(W=>{var X;return{variantId:W.variantId,pulls:W.pulls,avgReward:(X=W.avgReward)!=null?X:0}})};sn(P.componentId,U)}};I();let T=setInterval(()=>{I()},6e4);return()=>{g=!0,clearInterval(T)}},[t]);let y=(G=e.ssrFallback)!=null?G:"first",h=((R=e.apiBaseUrl)!=null?R:Nn).replace(/\/$/,""),v=(0,C.useRef)(null);(0,C.useEffect)(()=>{var T;if(typeof process!="undefined"&&((T=process.env)==null?void 0:T.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},I=v.current;if(v.current=g,I!==null)for(let _ of["apiKey","context","country","persona","apiBaseUrl"])Object.is(I[_],g[_])||console.warn(`[sentient] AdaptiveProvider: \`${_}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,C.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||dn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;(0,C.useEffect)(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),(0,C.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){Rt(g);return}e.declaredSections&&e.declaredSections.length>0&&Rt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||Pn||(Pn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,C.useEffect)(()=>{if(!F())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let I=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),_=>_.getAttribute("data-sentient-id"))),T=g.filter(_=>!I.has(_));T.length>0&&console.warn(`[SentientUI] Declared section${T.length>1?"s":""} ${T.map(_=>`"${_}"`).join(", ")} ${T.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=(0,C.useMemo)(()=>t&&i?un(t):t,[t,i]),E=(0,C.useMemo)(()=>{var g,I,T,_,P,U,W,X,K;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(I=e.initialUnified)!=null?I:ri,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(T=e.initialLayoutOrder)!=null?T:null,initialSlots:(_=e.initialSlots)!=null?_:{},initialSlotConfig:(P=e.initialSlotConfig)!=null?P:{},initialPalette:(U=e.initialPalette)!=null?U:null,initialVocabulary:(W=e.initialVocabulary)!=null?W:null,initialPersona:(X=e.initialPersona)!=null?X:null,apiBaseUrl:h,debug:(K=e.debug)!=null?K:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,Bn.jsx)(Y.Provider,{value:E,children:e.children})}function M(){return(0,C.useContext)(Y).client}function re(){return(0,C.useContext)(Y).apiKey}function Ze(){return(0,C.useContext)(Y).initialAssignments}var ri=[];function Qe(){return(0,C.useContext)(Y).initialUnified}function Te(){return(0,C.useContext)(Y).sessionSegment}function In(){return(0,C.useContext)(Y).ssrFallback}function et(){return(0,C.useContext)(Y).onAssignment}function Dn(){return(0,C.useContext)(Y).debug}function Ln(){let e=(0,C.useContext)(Y).initialLayoutOrder,t=(0,C.useSyncExternalStore)(Q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function tt(){return(0,C.useContext)(Y).initialSlots}function Fn(){return(0,C.useContext)(Y).initialPersona}function Vn(){return(0,C.useContext)(Y).initialSlotConfig}function Mn(){return(0,C.useContext)(Y).initialPalette}function $n(){return(0,C.useContext)(Y).initialVocabulary}function jn(){return(0,C.useContext)(Y).apiBaseUrl}var ge=require("react");var B=require("react"),Un=require("@sentientui/core");var ie=require("react"),nt=require("@sentientui/policy");function ve(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function rt(e,t,n,r,i){let o=Ze(),l=In(),a=M(),u=Te(),s=et(),S=Dn(),c=(0,ie.useRef)(null),w=(0,ie.useSyncExternalStore)(Q,()=>ve(e),()=>null),x=w&&t.includes(w)?w:null,m=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{S&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[S,x,e]);let[y,h]=(0,ie.useState)(()=>{var k,E;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let N=o[e];return N&&t.includes(N)?{variantId:N,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=St(e);if(b){let N=(0,nt.pickFromWeights)(b.variants,t);if(N)return{variantId:N,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return(0,ie.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let b=St(e);if(b&&y.settled&&y.variantId&&y.variantId===(0,nt.pickFromWeights)(b.variants,t)){v(y.variantId);return}h(E=>{var N;return E.variantId?E:{variantId:(N=t[0])!=null?N:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),(0,ie.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(N=>{var G;if(!b&&N){if(N.unified===!0){k==null||k();return}!t.includes(N.variantId)&&!N.content||(h({variantId:N.variantId,content:(G=N.content)!=null?G:null,isLoading:!1,settled:!0}),v(N.variantId))}}),()=>{b=!0}},[x,a,e,u]),(0,ie.useEffect)(()=>{if(!x&&a)return on(e,f=>{var E;let b=a.getAssignment(e,u);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(E=b.content)!=null?E:null,isLoading:!1,settled:!0}),v(b.variantId);return}let k=(0,nt.pickFromWeights)(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function it(e,t,n){let r=M(),i=re(),o=Object.keys(t).join("\0"),l=(0,B.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:S}=rt(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,w]=(0,B.useState)(null),x=(0,B.useRef)(null),m=(0,B.useCallback)(d=>{x.current=d,w(d)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=(0,B.useMemo)(()=>y?te(y):null,[h]),f=y?pe(y):"";(0,B.useEffect)(()=>vn({id:e,variantIds:l,goal:f}),[e,l,f]);let b=(0,B.useRef)(null);(0,B.useEffect)(()=>{s||S&&(!r||!a||!i||!c||b.current!==a&&(b.current=a,ye(r,i,e,a)))},[r,a,i,e,c,s,S]);let k=(0,B.useRef)(!1),E=(0,B.useRef)(new Set);(0,B.useEffect)(()=>{k.current=!1,E.current=new Set},[a,v]);let N=n.funnel;(0,B.useEffect)(()=>{s||!S||!r||!v||de(r,i,e,N,v)},[r,i,e,N,v,s,S]);let G=n.cursorSignal===!0;(0,B.useEffect)(()=>{if(!G||s||!S||!r||!a||!c)return;let d=null,g=0,I=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},T=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",I),c.addEventListener("mouseleave",T),()=>{c.removeEventListener("mouseenter",I),c.removeEventListener("mouseleave",T),d!==null&&clearTimeout(d)}},[G,r,a,i,e,c,s,S]);let R=(0,B.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c)return;let d=Date.now();return(0,Un.attachMicroSignalDetectors)((g,I={})=>{var W,X,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},I)});let T=(W=R.current)==null?void 0:W[g];if(!T||E.current.has(g))return;E.current.add(g);let _=typeof T=="string"?T:T.name,P=typeof T=="string"?1:(X=T.weight)!=null?X:1,U=typeof T=="string"?0:(K=T.stepIndex)!=null?K:0;r.goal(_,{metadata:p({signalType:g},I),weight:P,stepIndex:U})},c,d)},[r,a,i,e,c,A,s,S]),(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c||!v)return;let d=ue(v);return ce(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:I}}),r.goal(g,{metadata:{},weight:I,stepIndex:T})}},f)},[r,a,i,e,c,v,f,s,S]),{client:r,variantIds:l,variantId:a,content:u,settled:S,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}var L=require("react"),Re=require("@sentientui/core"),Ft=require("@sentientui/core/region");var ee=require("react"),Kn=require("@sentientui/core");var Wn=new Set,ii={kind:"arms"};function Jn(e,t){var E,N,G;let n=M(),r=(0,ee.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,ee.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,ee.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=tt(),a=Vn(),u=Mn(),s=$n(),S=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":(0,Kn.armOfResult)(R),x=(0,ee.useCallback)(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);(0,ee.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,ee.useSyncExternalStore)(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=S===void 0?a[e]:void 0,y=S===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(E=u!=null?u:n==null?void 0:n.getSitePalette())!=null?E:null,v=(G=s!=null?s:(N=n==null?void 0:n.getStyleVocabulary)==null?void 0:N.call(n))!=null?G:null,f=(()=>{var R,A,d;if(S!==void 0)return{config:S,arm:w(c),palette:h,vocabulary:(R=bn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:ii,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(m!==void 0)return{config:m,arm:w((A=l[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:h,vocabulary:v,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,ee.useEffect)(()=>{var P,U,W,X,K;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&(U=(P=r.current)==null?void 0:P.call(r))!=null?U:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(W=i.current)==null?void 0:W.call(i),I=R&&(K=(X=o.current)==null?void 0:X.call(o))!=null?K:null,T=p(p({},g?{render:{[e]:g}}:{}),I?{skeletons:{[e]:I}}:{}),_=Object.keys(T).length>0;return n.requestSlots?_?n.requestSlots([e],d,T):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(I?n.reportSlots([e],d!=null?d:{},{[e]:I}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,k,f.source,e,b]),(0,ee.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Wn.has(e)||(Wn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var je=require("react");var $=require("react/jsx-runtime");function Et(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var Se={none:"0",sm:"8px",md:"16px",lg:"24px"},Pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},qn={sm:"0.875em",md:"1em",lg:"1.25em"},oi={sm:"1.25em",md:"1.5em",lg:"2em"},Hn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Xn={sm:"8px",md:"16px",lg:"32px"},si={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ai={normal:"400",medium:"500",bold:"700"};function zn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Yn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return V(p({display:"inline-block",padding:(i=Hn[n!=null?n:"md"])!=null?i:Hn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:qn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function li({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return(0,$.jsxs)("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let S=new FormData(s.currentTarget),c={};for(let y of e.fields)c[y.name]=String((w=S.get(y.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,c)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var S,c;return(0,$.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,$.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,$.jsx)("select",{name:s.name,required:s.required,style:r,children:((S=s.options)!=null?S:[]).map(w=>(0,$.jsx)("option",{value:w,children:w},w))}):(0,$.jsx)("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,$.jsx)("button",{type:"submit",style:Yn(n,t.palette),children:e.submitLabel})]})}function ui(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Zn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=ci(e,t),r=Zn(e.like,t);return n&&r?(0,je.cloneElement)(n,{style:V(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ci(e,t){var n,r,i,o,l,a,u,s,S,c,w,x,m,y,h,v,f,b,k,E,N,G,R;try{let A=ui(e,t);switch(e.type){case"stack":{let d=(r=Se[(n=e.gap)!=null?n:"md"])!=null?r:Se.md,g=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:g?"md":void 0;return(0,$.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Pt[e.align]}:{}),e.justify?{justifyContent:Pt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(o=Se[I])!=null?o:Se.md}:{}),g?V(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(S=(s=t.palette)==null?void 0:s.border)!=null?S:"currentColor"}`,borderRadius:(w=(c=t.palette)==null?void 0:c.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((T,_)=>{let P=xe(T,t);return P===null?null:(0,$.jsx)(je.Fragment,{children:P},_)})}))}case"grid":{let d=(y=Se[(m=e.gap)!=null?m:"md"])!=null?y:Se.md;return(0,$.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Pt[e.align]}:{}),e.pad?{padding:(h=Se[e.pad])!=null?h:Se.md}:{}),children:((v=e.children)!=null?v:[]).map((g,I)=>{let T=xe(g,t);return T===null?null:(0,$.jsx)(je.Fragment,{children:T},I)})}))}case"text":return A?(0,$.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:qn[e.size]}:{}),e.weight?{fontWeight:ai[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),zn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?(0,$.jsx)(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)(d,{style:p(p({margin:0,fontSize:oi[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return(0,$.jsx)("a",V(p(p({href:Et(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Yn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,$.jsx)("a",V(p(p({href:Et(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,$.jsx)("img",V(p({src:Et(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:si[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,$.jsx)("span",{className:A,children:e.value}):(0,$.jsx)("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(k=t.palette)==null?void 0:k.border)!=null?E:"currentColor"}`},zn(e.tone,t.palette)),children:e.value});case"spacer":return(0,$.jsx)("div",{style:{height:(N=Xn[e.size])!=null?N:Xn.md}});case"divider":return(0,$.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(G=t.palette)==null?void 0:G.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,$.jsx)(li,{node:e,opts:t});default:return null}}catch(A){return null}}function ot(e,t){var o,l,a,u;let n=xe(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Zn((u=e.surface)==null?void 0:u.like,t);return r?(0,$.jsx)("div",V(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}var fe=require("react"),st=require("@sentientui/core/region");function at(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function lt(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ke(e){return at(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ke(n),0):(0,fe.isValidElement)(e)?ke(lt(e)):0}function di(e,t){return Array.isArray(t)?(0,fe.cloneElement)(e,void 0,...t):(0,fe.cloneElement)(e,void 0,t)}function Nt(e,t){if(at(e))return t;if(Array.isArray(e))return e.map(n=>Nt(n,t));if((0,fe.isValidElement)(e)){let n=lt(e);return ke(n)===0?e:di(e,Nt(n,t))}return e}function Qn(e,t){return ke(e)===1?Nt(e,t):null}var ne=e=>e.join("/");function Tt(e,t,n){if(at(e)){n.leafPaths.push(t),n.texts.push((0,st.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Tt(r,[...t,i],n));return}(0,fe.isValidElement)(e)&&(n.elements.set(ne(t),e),Tt(lt(e),[...t,"c"],n))}function Dt(e){let t={leafPaths:[],texts:[],elements:new Map};return Tt(e,[],t),t}function fi(e){return Dt(e).texts}function er(e){let t=fi(e);return t.length===0?null:(0,st.skeletonFingerprint)(t)}function gi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function tr(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[gi(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(ne));l=l.filter(s=>u.has(ne(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function It(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Lt(e,t){let n=Dt(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=tr(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(ne(a)):void 0,s=!!u&&(typeof u.type=="string"||It(u)!==void 0);return V(p({},o),{restylable:s})});return V(p({},e),{nodes:i})}function nr(e,t,n){var m;let r=Dt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let o=tr(r,n),l=new Map;n.forEach((y,h)=>{l.has(y)||l.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[ne(y),h])),u=new Set,s=new Map,S=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),f=o[v];if(h.hidden&&(f?u.add(ne(f)):S=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(ne(f)):void 0,E=b?It(r.elements.get(ne(b))):void 0;!f||E===void 0||It(k)===void 0?S=!0:s.set(ne(f),E)}}let c=new Map(Object.entries((m=t.order)!=null?m:{})),w=(y,h)=>{var v;if(at(y)){let f=a.get(ne(h));if(f===void 0)return y;let b=n[f],k=(v=t.nodes[String(b)])==null?void 0:v.text;return k===void 0?y:l.get(b)===f?k:""}if(Array.isArray(y)){let f=y.map((b,k)=>w(b,[...h,k]));for(let[b,k]of c){let E=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||ne(A.slice(0,-1))!==ne(h)?-1:A[A.length-1]});if(E.some(R=>R<0))continue;let N=[...E].sort((R,A)=>R-A),G=[...f];N.forEach((R,A)=>{f[R]=G[E[A]]}),c.delete(b)}return f}if((0,fe.isValidElement)(y)){let f=ne(h);if(u.has(f))return null;let b=lt(y);if(ke(b)===0)return y;let k=w(b,[...h,"c"]),E=s.get(f),N=E!==void 0?{className:E}:void 0;return Array.isArray(k)?(0,fe.cloneElement)(y,N,...k):(0,fe.cloneElement)(y,N,k)}return y},x=w(e,[]);return S||c.size>0?null:x}var sr=require("react/jsx-runtime"),rr=new Set,ir=new Set,or=new Set,ut="authored.";function Ie({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:S,agentDataByVariant:c,agentData:w,variantsOnly:x=!1}){var zt,qt;let m=M(),y=re(),h=(0,L.useRef)(null),[v,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{f(!0)},[]);let b=S===!0&&(!v||!m),k=(0,L.useMemo)(()=>er(t),[t]),E=n?Object.keys(n).join("|"):"",N=(0,L.useMemo)(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ke(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!x}:{}),[k,t,r,E,x]),G=()=>{var q;let O=h.current;if(!O||!a)return null;let D=(0,Ft.captureRegionSkeleton)(O);return D.skeleton?(q=Lt(D.skeleton,t))!=null?q:V(p({},D.skeleton),{editable:!1,nodes:D.skeleton.nodes.map(H=>V(p({},H),{restylable:!1}))}):{status:D.reason}},R=(0,L.useSyncExternalStore)(Q,()=>n?ve(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${ut}${R}`:x?`${ut}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:I,vocabulary:T,source:_}=Jn(e,{forcedArm:A,baselineText:a?()=>{var O,D;return(D=(O=h.current)==null?void 0:O.textContent)!=null?D:null}:void 0,render:()=>N,skeleton:G,defer:b}),P=g!==""?(zt=d==null?void 0:d.blocks)==null?void 0:zt[g]:void 0,U=g!==""?(qt=d==null?void 0:d.compose)==null?void 0:qt[g]:void 0,W=(P!==void 0&&(0,Re.containsFormBlock)(P)||U!==void 0&&(0,Re.containsFormBlock)(U.tree))&&!r;(0,L.useEffect)(()=>{!W||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[W,e]);let X=O=>{!m||_==="override"||(_!=="seeded"&&m.componentGoal(e,O),m.goal(O,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},K=t,J=!1,j=g.startsWith(ut)?g.slice(ut.length):null;if((d==null?void 0:d.blocked)==="variant_history")J=!0;else if(j!==null)n&&Object.prototype.hasOwnProperty.call(n,j)?K=n[j]:J=!0;else if(U!==void 0){let O=W?null:ot(U,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if(P!==void 0){let O=W?null:xe(P,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if((d==null?void 0:d.edits)!==void 0&&_!=="none"){let O=d.edits,D=O.fp===k?nr(t,O.edits,O.leafToNode):null;D===null?J=!0:K=D}else if((d==null?void 0:d.content)!==void 0&&_!=="none"){let O=Qn(t,d.content);O===null?J=!0:K=O}let ae=J&&P===void 0&&U===void 0&&(d==null?void 0:d.edits)===void 0&&j===null&&(d==null?void 0:d.blocked)===void 0;(0,L.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||or.has(e)||(or.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Fe=j!==null&&!J?j:null;(0,L.useEffect)(()=>{var le;if(!Fe||!a||!m)return;let O=h.current;if(!O)return;let D=(0,Ft.captureRegionSkeleton)(O),q=D.skeleton?Lt(D.skeleton,n==null?void 0:n[Fe]):null,H=(le=O.textContent)==null?void 0:le.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Fe},H?{text:H}:{}),q?{skeleton:q}:{})]})},[Fe,m,e,b]);let Bt=J&&(d==null?void 0:d.edits)!==void 0&&(_==="preloaded"||_==="client");(0,L.useEffect)(()=>{var O;!Bt||!(d!=null&&d.edits)||(O=m==null?void 0:m.reportDrift)==null||O.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Bt,e,k,m]);let We=K===t;(0,L.useEffect)(()=>{var D;if(!(d!=null&&d.needsSkeleton)||!We)return;let O=G();O&&((D=m==null?void 0:m.reportSkeleton)==null||D.call(m,e,O))},[d==null?void 0:d.needsSkeleton,We,e,m,b]),(0,L.useEffect)(()=>{if(!We)return;let O=Cn(e);if(!O)return;let D=G();_n(O,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,We,b]),(0,L.useEffect)(()=>{!ae||!F()||ir.has(e)||(ir.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[ae,e]);let gt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";(0,L.useEffect)(()=>Oe({id:e,arms:gt===""?void 0:gt.split("|")}),[e,gt]);let Ut=(0,L.useRef)(null);(0,L.useEffect)(()=>{!m||_==="none"||_==="seeded"||_==="override"||g===""||J||Ut.current!==g&&(Ut.current=g,ye(m,y,e,g))},[m,y,e,g,_,J]);let me=_!=="none"&&_!=="seeded"&&!J,mt=me?g:"",Wt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,L.useEffect)(()=>{if(!m||!i||_==="override")return;let O=h.current;if(!O)return;let D=pe(i),q=ue(i),H=!1;return ce(O,te(i),{fireGoal:()=>{H||(H=!0,me&&(q!==void 0?m.componentGoal(e,D,{value:q}):m.componentGoal(e,D)),m.goal(D,p({metadata:{componentId:e,arm:mt},weight:1,stepIndex:0},q!==void 0?{value:q}:{})))},fireStep:(le,Je,yt)=>{me&&m.componentGoal(e,le,{reward:Je}),m.goal(le,{metadata:{componentId:e,arm:mt},weight:Je,stepIndex:yt})}},D)},[m,e,Wt,g,_,J,me,mt,b]);let pt=(0,L.useMemo)(()=>i?te(i):null,[Wt]);(0,L.useEffect)(()=>{_==="override"||!m||!pt||de(m,y,e,u,pt)},[m,y,e,u,pt,_]);let Kt=(0,L.useRef)(s);Kt.current=s;let Jt=(0,L.useRef)(new Set),Dr=s?JSON.stringify(s):"";(0,L.useEffect)(()=>{if(!m||_==="override"||!me||g==="")return;let O=h.current;if(O)return(0,Re.attachMicroSignalDetectors)((D,q={})=>{var Yt,Zt,Qt;m.track({projectId:y,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:D},q)});let H=(Yt=Kt.current)==null?void 0:Yt[D];if(!H||Jt.current.has(D))return;Jt.current.add(D);let le=typeof H=="string"?H:H.name,Je=typeof H=="string"?1:(Zt=H.weight)!=null?Zt:1,yt=typeof H=="string"?0:(Qt=H.stepIndex)!=null?Qt:0;m.goal(le,{metadata:p({componentId:e,arm:g,signalType:D},q),weight:Je,stepIndex:yt})},O,Date.now())},[m,y,e,g,_,me,Dr,b]);let Ht=(0,L.useRef)({agentData:w,agentDataByVariant:c});Ht.current={agentData:w,agentDataByVariant:c};let Xt=(0,L.useRef)(null);(0,L.useEffect)(()=>{var le;if(!m||_==="override"||!me||g===""||Xt.current===g)return;let{agentData:O,agentDataByVariant:D}=Ht.current,q=j!=null?j:g,H=D!==void 0?Object.prototype.hasOwnProperty.call(D,q)?D[q]:void 0:O;H!==void 0&&(Xt.current=g,(le=m.reportAgentData)==null||le.call(m,e,g,H))},[m,e,g,me,j,_]);let Ke=(0,L.useRef)(null);(0,L.useEffect)(()=>{let O=h.current;if(O){if(Ke.current===null){Ke.current=g;return}Ke.current!==g&&(Ke.current=g,(0,Re.reveal)(O))}},[g,b]);let Lr=(0,L.useMemo)(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:(0,sr.jsx)(l,V(p({ref:h,className:o},Lr),{children:K}))}var Ae=require("react/jsx-runtime");function mi(e){var S,c;let{client:t,variantId:n,content:r,ref:i}=it(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{l(!0)},[]);let a=(S=e.as)!=null?S:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return F()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var pi=(0,ge.memo)(mi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function ar(e){if(e.variants===void 0)return(0,Ae.jsx)(Ie,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Me(n,["variants"]);return(0,Ae.jsx)(Ie,V(p({},i),{children:t.children,variants:r}))}return(0,Ae.jsx)(yi,p({},t))}function yi(e){var c;let[t,n]=(0,ge.useState)(null),{id:r}=e,i=(0,ge.useCallback)(()=>n(r),[r]),o=M(),l=Qe().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return(0,Ae.jsx)(pi,V(p({},e),{onUnified:i}));let w=e,{variants:a,children:u}=w,s=Me(w,["variants","children"]),S=Object.keys(a)[0];return(0,Ae.jsx)(Ie,V(p({},s),{variants:a,variantsOnly:!0,children:S!==void 0?a[S]:null}))}var z=require("react");var ur=require("react/jsx-runtime");function lr({id:e,default:t,component:n="span",className:r,goal:i}){var N;let o=M(),l=re(),a=et(),u=Te(),s=(0,z.useRef)(null),S=(0,z.useRef)(null),c=(0,z.useSyncExternalStore)(Q,()=>ve(e),()=>null),[w,x]=(0,z.useState)(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.content)!=null?R:null}),[m,y]=(0,z.useState)(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(c||!o)return;let G=o.getAssignment(e,u);if((G==null?void 0:G.content)!==void 0){y(G.variantId),x(G.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,u,c]),(0,z.useEffect)(()=>{c||!o||!m||!l||s.current!==m&&(s.current=m,o.track({projectId:l,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,l,e,a,c]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,z.useMemo)(()=>i===void 0?null:te(i),[h]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,z.useRef)(!1);(0,z.useEffect)(()=>{b.current=!1},[m,h]),(0,z.useEffect)(()=>{c||!o||!l||de(o,l,e,void 0,v)},[o,l,e,v,c]),(0,z.useEffect)(()=>{if(c||!o||!m||!l||!v||!f)return;let G=S.current;if(!G)return;let R=ue(v);return ce(G,v,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,l,e,v,f,c]);let k=w!=null?w:t;if(c){let G=o==null?void 0:o.getAssignment(e,u);k=G&&G.variantId===c&&(N=G.content)!=null?N:t}return(0,ur.jsx)(n,{ref:G=>{S.current=G},className:r,children:k})}var ct=require("react");function Be(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function De(e){let t=M(),n=(0,ct.useRef)(new Set);return(0,ct.useCallback)((r,i)=>{if(!ve(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,Be(i))}},[t,e])}var Ue=require("react");function cr(e,t={}){let u=t,{componentId:n}=u,r=Me(u,["componentId"]),i=M(),o=De(n!=null?n:""),l=(0,Ue.useRef)(!1),a=(0,Ue.useRef)(r);a.current=r,(0,Ue.useEffect)(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,Be(a.current))}},[i,n,e,o])}var Le=require("react");var dr=new Set,fr=new Map;function vi(e,t,n,r){let i=r;if(r){let l=fr.get(t);l&&l!==n?(F()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):fr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;dr.has(o)||(dr.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function gr(e,t={}){let{primary:n=!1,componentId:r}=t,i=M(),o=re(),l=De(r!=null?r:""),a=(0,Le.useRef)(!1);return(0,Le.useEffect)(()=>{!i||i.gated||!o||vi(i,o,e,n)},[i,o,e,n]),(0,Le.useCallback)(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,Be(u))},[i,r,l,e])}var mr=require("@sentientui/core"),pr=require("@sentientui/policy"),vr=require("react/jsx-runtime");function Vt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Si(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Vt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Vt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Vt((0,pr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,mr.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function yr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,vr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Si(e)}})}var se=require("react"),wr=require("@sentientui/policy");var oe=require("react"),Ce=require("@sentientui/core"),Sr=require("@sentientui/policy");function dt(e,t){let n=M(),r=tt(),[,i]=(0,oe.useReducer)(c=>c+1,0),o=(0,oe.useSyncExternalStore)(Q,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;(0,oe.useEffect)(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(w=>{!c&&w&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,Ce.armOfResult)(o),source:"override"};if(l!==void 0)return{result:l,arm:(0,Ce.armOfResult)(l),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ce.armOfResult)(a),source:w?"client":"seeded"}}let c=(0,Ce.baselineResultFor)(t);return{result:c,arm:(0,Ce.armOfResult)(c),source:"baseline"}})(),S=s.source==="preloaded"||s.source==="override";return(0,oe.useEffect)(()=>{var w;if(!n||n.isLocal===!0||S||!n.decideSlots)return;let c=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,S]),s}function hi(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function hr(){let e=M(),t=Fn();(0,oe.useSyncExternalStore)(Q,cn,()=>0);let[n,r]=(0,oe.useState)(!1);(0,oe.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,Sr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=hi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var br=new Set;function bi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function xr(e,t,n){let r=M(),i=re(),o=JSON.stringify(t),l=(0,se.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=dt(e,l),S=(0,se.useMemo)(()=>typeof a=="string"?{}:a,[u]);if(F()&&!br.has(e)){br.add(e);let y=(0,wr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),h=Object.values(t).reduce((v,f)=>v*f.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,se.useEffect)(()=>Oe({id:e,dims:t}),[e]);let w=(0,se.useRef)(null);(0,se.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===u||(w.current=u,ye(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;(0,se.useEffect)(()=>{var y;!r||s==="override"||de(r,i,e,x,te((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,x,c,s]),(0,se.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${bi(e)}"]`);if(!y){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=pe(n.goal),v=ue(n.goal),f=!1;return ce(y,te(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,k,E)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:u},weight:k,stepIndex:E})}},h)},[r,e,c,u,s]);let m=(0,se.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(S))y[`data-${h}`]=v;return y},[e,S]);return{tokens:S,props:m}}var _e=require("react");var kr=new Set,Rr=new Set;function Ar(e,t){var m,y;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=it(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",S=t.variants[s],c=Qe().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;(0,_e.useEffect)(()=>{!c||!F()||Rr.has(e)||(Rr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),(0,_e.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!u.current&&!kr.has(e)&&(kr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=(0,_e.useCallback)((h,v)=>{var b,k;if(o)return;let f=h!=null?h:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(b=v==null?void 0:v.metadata)!=null?b:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=(0,_e.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:S,bind:x,fireGoal:w}}var Z=require("react");var _r=require("react/jsx-runtime"),ft=new Set;function Cr(e){var f;let t=M(),n=re(),r=(0,Z.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Z.useMemo)(()=>Object.keys(e.arrangements),[i]),l=(0,Z.useMemo)(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=dt(e.id,l);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!ft.has(e.id+":baseline")&&(ft.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Z.Children.toArray(e.children).filter(Z.isValidElement),S=new Map;for(let b of s)S.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let c=e.arrangements[a],w=c!==void 0&&c.length===s.length&&c.every(b=>S.has(b));F()&&c!==void 0&&!w&&!ft.has(e.id+":keys")&&(ft.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?c.map(b=>S.get(b)):s;(0,Z.useEffect)(()=>Oe({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||m.current===a||(m.current=a,ye(t,n,e.id,a))},[t,n,e.id,a,u]);let y=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Z.useEffect)(()=>{var b;!t||u==="override"||de(t,n,e.id,y,te((b=e.goal)!=null?b:"click"))},[t,n,e.id,y,h,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Z.useEffect)(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let b=r.current;if(!b)return;let k=pe(e.goal),E=ue(e.goal),N=!1;return ce(b,te(e.goal),{fireGoal:()=>{N||(N=!0,E!==void 0?t.componentGoal(e.id,k,{value:E}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},E!==void 0?{value:E}:{})))},fireStep:(G,R,A)=>{t.componentGoal(e.id,G,{reward:R}),t.goal(G,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,v,a,u]),(0,_r.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Mt=require("@sentientui/core");var wi=["page","blocks","layoutOrder"],Or=new Map;function Gr(e,t){Or.set(e,t)}function $t(e){return Or.get(e)}function Er(e){var i,o;let t=(o=(i=e.content)!=null?i:$t(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))wi.includes(l)||(n[l]=a);let r=V(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Pr(e){return`<script type="application/ld+json">${jt(e)}</script>`}function jt(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Nr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
"use strict";var Fr=Object.create;var Ve=Object.defineProperty,Vr=Object.defineProperties,Mr=Object.getOwnPropertyDescriptor,$r=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols,Br=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable;var en=(e,t,n)=>t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))vt.call(t,n)&&en(e,n,t[n]);if(He)for(var n of He(t))tn.call(t,n)&&en(e,n,t[n]);return e},V=(e,t)=>Vr(e,$r(t));var Me=(e,t)=>{var n={};for(var r in e)vt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&He)for(var r of He(e))t.indexOf(r)<0&&tn.call(e,r)&&(n[r]=e[r]);return n};var Ur=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},nn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jr(t))!vt.call(e,i)&&i!==n&&Ve(e,i,{get:()=>t[i],enumerable:!(r=Mr(t,i))||r.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?Fr(Br(e)):{},nn(t||!e||!e.__esModule?Ve(n,"default",{value:e,enumerable:!0}):n,e)),Wr=e=>nn(Ve({},"__esModule",{value:!0}),e);var xi={};Ur(xi,{Adaptive:()=>ar,AdaptiveGroup:()=>Cr,AdaptiveProvider:()=>Tn,AdaptiveSlot:()=>Ie,AdaptiveText:()=>lr,SentientPersonaScript:()=>yr,buildAgentFeed:()=>Er,consentWatcher:()=>Ir.consentWatcher,defineAgentContent:()=>Gr,detectSegment:()=>Mt.deriveSessionSegment,getAgentContent:()=>$t,grantConsent:()=>Tr.grantConsent,renderAgentJsonLd:()=>Pr,renderAgentJsonLdBody:()=>jt,renderAgentMarkdown:()=>Nr,renderBlocks:()=>xe,renderCompose:()=>ot,useAdaptive:()=>Ar,useAdaptiveApiBaseUrl:()=>jn,useAdaptiveGoal:()=>De,useAdaptivePersona:()=>hr,useAdaptiveTokens:()=>xr,useAssignment:()=>rt,useGoal:()=>gr,useInitialAssignments:()=>Ze,useLayoutOrder:()=>Ln,usePageGoal:()=>cr,useSentient:()=>M,useSessionSegment:()=>Te});module.exports=Wr(xi);var C=require("react"),Ye=require("@sentientui/core");var rn=new Map,ze=new Map;function on(e,t){let n=ze.get(e);return n||(n=new Set,ze.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ze.delete(e)}}function sn(e,t){rn.set(e,t);let n=ze.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function St(e){var t;return(t=rn.get(e))!=null?t:null}var Kr={on:!1,listeners:new Set};function an(){if(typeof window=="undefined")return Kr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ht(){return an().on}function ln(e){let t=an().listeners;return t.add(e),()=>{t.delete(e)}}function un(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var bt="sentient:overrides-changed";function cn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function wt(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(bt))}function Q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(bt,e),()=>window.removeEventListener(bt,e))}function dn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function te(e){return typeof e=="string"?{type:"click"}:e}function pe(e){return typeof e=="string"?e:e.type}function ue(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var xt=new Set,kt=!1;function fn(e){if(xt.has(e))return!0;if(xt.add(e),!kt){kt=!0;let t=()=>{kt=!1,xt.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Jr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function gn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Jr(r))return!0;r=r.parentElement}return!1}function ce(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,S=[];return t.steps.forEach(({goal:c,name:w,weight:x},m)=>{let y=(h=!1)=>{s.has(m)||h&&r!==void 0&&fn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(c.type==="click"){let h=v=>{let f=v.target;f instanceof Element&&gn(f,e,c.selector)&&y()};e.addEventListener("click",h),S.push(()=>e.removeEventListener("click",h));return}if(c.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),S.push(()=>e.removeEventListener("submit",h));return}if(c.type==="scroll_depth"){let h=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),S.push(()=>v.disconnect())}}),()=>{for(let c of S)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,S)=>S)),l=()=>{r!==void 0&&fn(r)||n.fireGoal()},a=(s,S=!1)=>{o.delete(s),o.size===0&&(S?l():n.fireGoal())},u=[];return i.forEach((s,S)=>{if(s.type==="click"){let c=w=>{let x=w.target;x instanceof Element&&gn(x,e,s.selector)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=c){t.type==="composite"?a(S,!0):l(),w.disconnect();break}},{threshold:[c]});w.observe(e),u.push(()=>w.disconnect());return}}),()=>{for(let s of u)s()}}var mn=new Set,pn=new Set;function Hr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var Xr=12;function zr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===Xr||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function de(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Hr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(pn.has(a))return;pn.add(a);let u=o&&!mn.has(l)?zr(n,o):null,s=u!==null&&u.length>=2;s&&mn.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ye(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var qr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function he(){if(typeof window=="undefined")return qr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function $e(){he().version+=1;for(let e of he().listeners)e()}var yn=()=>{};function vn(e){return F()?(he().components.set(e.id,e),$e(),()=>{he().components.delete(e.id),$e()}):yn}function Oe(e){return F()?(he().slots.set(e.id,e),$e(),()=>{he().slots.delete(e.id),$e()}):yn}function Rt(e){F()&&(he().sections=[...e],$e())}var Sn="0.42.3",At=Sn!=="0.0.0-dev"?{name:"react",version:Sn}:void 0;function Yr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ge(e,t){Yr()[e]=t}function hn(e){window.__sentient_vocabulary_override=e}function bn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Zr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ee(e,t){Zr()[e]=t}function wn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var _t="__snt_editor_token",Pe=null,Ct=!1;function xn(){return Ct}function Qr(){try{return sessionStorage.getItem(_t)}catch(e){return null}}function qe(e){if(Pe)return Pe;let t=typeof window=="undefined"?null:wn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Qr();return Ct=!!n,Pe=Promise.resolve(n?{token:n,fresh:!1}:null),Pe}return Ct=!0,Pe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(_t,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Pe}function kn(){try{sessionStorage.removeItem(_t)}catch(e){}}var Rn="sentient_preview_cell",An="sentient_refresh_region",Ot="sentient-cell-preview-bar",be="__preview__",Ne=null;function Cn(e){if((Ne==null?void 0:Ne.slotId)!==e)return null;let t=Ne;return Ne=null,t}function _n(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>we(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>we("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function On(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ot))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(Rn),n=u.get(An)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=qe(r);if(!xn())return;if(n){Ne={slotId:n,session:i,base:r},Ge(n,{kind:"arms"}),Ee(n,be),wt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(we(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){we(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&hn(s.vocabulary),s.compose!=null)Ge(l,{kind:"arms",compose:{[be]:s.compose}}),Ee(l,be);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ge(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Ee(l,be);else if(s.blocks!=null)Ge(l,{kind:"arms",blocks:{[be]:s.blocks}}),Ee(l,be);else if(s.content!=null)Ge(l,{kind:"arms",content:s.content}),Ee(l,be);else{we("Nothing to preview in that square yet.");return}wt(),we(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var S;try{(S=document.querySelector(`[data-sentient-slot="${l}"]`))==null||S.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>we("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function we(e){var i;if(document.getElementById(Ot))return;let t=document.createElement("div");t.id=Ot,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{kn();let o=new URL(window.location.href);o.searchParams.delete(Rn),o.searchParams.delete(An),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Gn=!1;function En(e){if(Gn||typeof window=="undefined")return;Gn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");qe(t).then(n=>{!n||!("token"in n)||!n.fresh||ei(t,n.token)})}function ei(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Bn=require("react/jsx-runtime");function ti(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Ye.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Nn="https://api.sentient-ui.com/v1",Y=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Nn,debug:!1}),Pn=!1,Gt=new Set;function ni(e,t,n){let r=(0,C.useRef)(n);r.current=n;let[i,o]=(0,C.useState)(null),[l,a]=(0,C.useState)(!1),u=(0,C.useRef)(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(V(p({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,C.useEffect)(()=>{let S=u.current;if(S===void 0||typeof window=="undefined")return;let c,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let y=x(typeof S=="object"&&S.cmp===void 0&&S.check?p(V(p({},S),{check:()=>u.current.check()}),S.refused?{refused:()=>{var f,b;return((b=(f=u.current).refused)==null?void 0:b.call(f))===!0}}:{}):S),h=!1,v=()=>{let f=y.refused()&&y.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=y.read();b!==null&&Gt.add(t),o(b!=null?b:Gt.has(t)?!1:null)};v(),c=y.subscribe(v)}),()=>{w=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function Tn(e){var N,G,R,A,d;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:ti()}),[i,o]=(0,C.useState)(ht());(0,C.useEffect)(()=>ln(()=>o(ht())),[]),(0,C.useEffect)(()=>{On(e.apiBaseUrl),En(e.apiBaseUrl)},[]);let l=(0,C.useRef)(()=>{}),a=ni(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(N=a.granted)!=null?N:Gt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,S=(0,C.useRef)(s);S.current=s;let c=(0,C.useRef)(null),w=(0,C.useRef)(!1),x=(0,C.useRef)([]),m=(0,C.useRef)(!1);l.current=()=>{var I;x.current=[],m.current=!0;let g=c.current;g!=null&&g.gated?g.dispose():(I=g==null?void 0:g.takeHeld)==null||I.call(g)},(0,C.useEffect)(()=>{var K,J;if(S.current&&u===!1&&(x.current=[]),u===!1&&w.current&&(S.current&&((K=c.current)==null||K.destroy()),c.current=null,w.current=!1),u===!1&&!e.preConsentBehavior){S.current&&((J=c.current)==null||J.destroy()),c.current=null,n(null);return}let g=u!==!1;g&&(m.current=!1);let I=j=>{!g&&m.current&&j.gated&&j.dispose()},T=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},At?{sdk:At}:{}),_=!1,P=null,U=null,W=j=>{for(let ae of x.current.splice(0))setTimeout(()=>{if(c.current!==j){m.current||x.current.push(ae);return}try{ae(j)}catch(Fe){}},0)},X=j=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:ae})=>{_||(U=ae(j,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:j})=>{_||(P=j(V(p({},T),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),I(P),c.current=P,w.current=g,W(P),n(P),X(P))}):(P=(0,Ye.init)(T),I(P),c.current=P,w.current=g,W(P),n(P),X(P)),()=>{var j,ae;_=!0,U==null||U(),x.current=x.current.concat((ae=(j=P==null?void 0:P.takeHeld)==null?void 0:j.call(P))!=null?ae:[]),P==null||P.dispose()}},[u]),(0,C.useEffect)(()=>{if(!t)return;let g=!1,I=async()=>{if(g)return;let _;try{_=await t.fetchWeights()}catch(P){return}if(!g)for(let P of _){let U={componentId:P.componentId,updatedAt:P.updatedAt,variants:P.variants.map(W=>{var X;return{variantId:W.variantId,pulls:W.pulls,avgReward:(X=W.avgReward)!=null?X:0}})};sn(P.componentId,U)}};I();let T=setInterval(()=>{I()},6e4);return()=>{g=!0,clearInterval(T)}},[t]);let y=(G=e.ssrFallback)!=null?G:"first",h=((R=e.apiBaseUrl)!=null?R:Nn).replace(/\/$/,""),v=(0,C.useRef)(null);(0,C.useEffect)(()=>{var T;if(typeof process!="undefined"&&((T=process.env)==null?void 0:T.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},I=v.current;if(v.current=g,I!==null)for(let _ of["apiKey","context","country","persona","apiBaseUrl"])Object.is(I[_],g[_])||console.warn(`[sentient] AdaptiveProvider: \`${_}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,C.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||dn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;(0,C.useEffect)(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),(0,C.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){Rt(g);return}e.declaredSections&&e.declaredSections.length>0&&Rt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||Pn||(Pn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,C.useEffect)(()=>{if(!F())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let I=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),_=>_.getAttribute("data-sentient-id"))),T=g.filter(_=>!I.has(_));T.length>0&&console.warn(`[SentientUI] Declared section${T.length>1?"s":""} ${T.map(_=>`"${_}"`).join(", ")} ${T.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=(0,C.useMemo)(()=>t&&i?un(t):t,[t,i]),E=(0,C.useMemo)(()=>{var g,I,T,_,P,U,W,X,K;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(I=e.initialUnified)!=null?I:ri,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(T=e.initialLayoutOrder)!=null?T:null,initialSlots:(_=e.initialSlots)!=null?_:{},initialSlotConfig:(P=e.initialSlotConfig)!=null?P:{},initialPalette:(U=e.initialPalette)!=null?U:null,initialVocabulary:(W=e.initialVocabulary)!=null?W:null,initialPersona:(X=e.initialPersona)!=null?X:null,apiBaseUrl:h,debug:(K=e.debug)!=null?K:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,Bn.jsx)(Y.Provider,{value:E,children:e.children})}function M(){return(0,C.useContext)(Y).client}function re(){return(0,C.useContext)(Y).apiKey}function Ze(){return(0,C.useContext)(Y).initialAssignments}var ri=[];function Qe(){return(0,C.useContext)(Y).initialUnified}function Te(){return(0,C.useContext)(Y).sessionSegment}function In(){return(0,C.useContext)(Y).ssrFallback}function et(){return(0,C.useContext)(Y).onAssignment}function Dn(){return(0,C.useContext)(Y).debug}function Ln(){let e=(0,C.useContext)(Y).initialLayoutOrder,t=(0,C.useSyncExternalStore)(Q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function tt(){return(0,C.useContext)(Y).initialSlots}function Fn(){return(0,C.useContext)(Y).initialPersona}function Vn(){return(0,C.useContext)(Y).initialSlotConfig}function Mn(){return(0,C.useContext)(Y).initialPalette}function $n(){return(0,C.useContext)(Y).initialVocabulary}function jn(){return(0,C.useContext)(Y).apiBaseUrl}var ge=require("react");var B=require("react"),Un=require("@sentientui/core");var ie=require("react"),nt=require("@sentientui/policy");function ve(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function rt(e,t,n,r,i){let o=Ze(),l=In(),a=M(),u=Te(),s=et(),S=Dn(),c=(0,ie.useRef)(null),w=(0,ie.useSyncExternalStore)(Q,()=>ve(e),()=>null),x=w&&t.includes(w)?w:null,m=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{S&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[S,x,e]);let[y,h]=(0,ie.useState)(()=>{var k,E;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let N=o[e];return N&&t.includes(N)?{variantId:N,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=St(e);if(b){let N=(0,nt.pickFromWeights)(b.variants,t);if(N)return{variantId:N,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return(0,ie.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let b=St(e);if(b&&y.settled&&y.variantId&&y.variantId===(0,nt.pickFromWeights)(b.variants,t)){v(y.variantId);return}h(E=>{var N;return E.variantId?E:{variantId:(N=t[0])!=null?N:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),(0,ie.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(N=>{var G;if(!b&&N){if(N.unified===!0){k==null||k();return}!t.includes(N.variantId)&&!N.content||(h({variantId:N.variantId,content:(G=N.content)!=null?G:null,isLoading:!1,settled:!0}),v(N.variantId))}}),()=>{b=!0}},[x,a,e,u]),(0,ie.useEffect)(()=>{if(!x&&a)return on(e,f=>{var E;let b=a.getAssignment(e,u);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(E=b.content)!=null?E:null,isLoading:!1,settled:!0}),v(b.variantId);return}let k=(0,nt.pickFromWeights)(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function it(e,t,n){let r=M(),i=re(),o=Object.keys(t).join("\0"),l=(0,B.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:S}=rt(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,w]=(0,B.useState)(null),x=(0,B.useRef)(null),m=(0,B.useCallback)(d=>{x.current=d,w(d)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=(0,B.useMemo)(()=>y?te(y):null,[h]),f=y?pe(y):"";(0,B.useEffect)(()=>vn({id:e,variantIds:l,goal:f}),[e,l,f]);let b=(0,B.useRef)(null);(0,B.useEffect)(()=>{s||S&&(!r||!a||!i||!c||b.current!==a&&(b.current=a,ye(r,i,e,a)))},[r,a,i,e,c,s,S]);let k=(0,B.useRef)(!1),E=(0,B.useRef)(new Set);(0,B.useEffect)(()=>{k.current=!1,E.current=new Set},[a,v]);let N=n.funnel;(0,B.useEffect)(()=>{s||!S||!r||!v||de(r,i,e,N,v)},[r,i,e,N,v,s,S]);let G=n.cursorSignal===!0;(0,B.useEffect)(()=>{if(!G||s||!S||!r||!a||!c)return;let d=null,g=0,I=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},T=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",I),c.addEventListener("mouseleave",T),()=>{c.removeEventListener("mouseenter",I),c.removeEventListener("mouseleave",T),d!==null&&clearTimeout(d)}},[G,r,a,i,e,c,s,S]);let R=(0,B.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c)return;let d=Date.now();return(0,Un.attachMicroSignalDetectors)((g,I={})=>{var W,X,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},I)});let T=(W=R.current)==null?void 0:W[g];if(!T||E.current.has(g))return;E.current.add(g);let _=typeof T=="string"?T:T.name,P=typeof T=="string"?1:(X=T.weight)!=null?X:1,U=typeof T=="string"?0:(K=T.stepIndex)!=null?K:0;r.goal(_,{metadata:p({signalType:g},I),weight:P,stepIndex:U})},c,d)},[r,a,i,e,c,A,s,S]),(0,B.useEffect)(()=>{if(s||!S||!r||!a||!c||!v)return;let d=ue(v);return ce(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:I}}),r.goal(g,{metadata:{},weight:I,stepIndex:T})}},f)},[r,a,i,e,c,v,f,s,S]),{client:r,variantIds:l,variantId:a,content:u,settled:S,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}var L=require("react"),Re=require("@sentientui/core"),Ft=require("@sentientui/core/region");var ee=require("react"),Kn=require("@sentientui/core");var Wn=new Set,ii={kind:"arms"};function Jn(e,t){var E,N,G;let n=M(),r=(0,ee.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,ee.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,ee.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=tt(),a=Vn(),u=Mn(),s=$n(),S=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":(0,Kn.armOfResult)(R),x=(0,ee.useCallback)(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);(0,ee.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,ee.useSyncExternalStore)(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=S===void 0?a[e]:void 0,y=S===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(E=u!=null?u:n==null?void 0:n.getSitePalette())!=null?E:null,v=(G=s!=null?s:(N=n==null?void 0:n.getStyleVocabulary)==null?void 0:N.call(n))!=null?G:null,f=(()=>{var R,A,d;if(S!==void 0)return{config:S,arm:w(c),palette:h,vocabulary:(R=bn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:ii,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(m!==void 0)return{config:m,arm:w((A=l[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:h,vocabulary:v,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,ee.useEffect)(()=>{var P,U,W,X,K;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&(U=(P=r.current)==null?void 0:P.call(r))!=null?U:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(W=i.current)==null?void 0:W.call(i),I=R&&(K=(X=o.current)==null?void 0:X.call(o))!=null?K:null,T=p(p({},g?{render:{[e]:g}}:{}),I?{skeletons:{[e]:I}}:{}),_=Object.keys(T).length>0;return n.requestSlots?_?n.requestSlots([e],d,T):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(I?n.reportSlots([e],d!=null?d:{},{[e]:I}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,k,f.source,e,b]),(0,ee.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Wn.has(e)||(Wn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var je=require("react");var $=require("react/jsx-runtime");function Et(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var Se={none:"0",sm:"8px",md:"16px",lg:"24px"},Pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},qn={sm:"0.875em",md:"1em",lg:"1.25em"},oi={sm:"1.25em",md:"1.5em",lg:"2em"},Hn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Xn={sm:"8px",md:"16px",lg:"32px"},si={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ai={normal:"400",medium:"500",bold:"700"};function zn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Yn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return V(p({display:"inline-block",padding:(i=Hn[n!=null?n:"md"])!=null?i:Hn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:qn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function li({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return(0,$.jsxs)("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let S=new FormData(s.currentTarget),c={};for(let y of e.fields)c[y.name]=String((w=S.get(y.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,c)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var S,c;return(0,$.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,$.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,$.jsx)("select",{name:s.name,required:s.required,style:r,children:((S=s.options)!=null?S:[]).map(w=>(0,$.jsx)("option",{value:w,children:w},w))}):(0,$.jsx)("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,$.jsx)("button",{type:"submit",style:Yn(n,t.palette),children:e.submitLabel})]})}function ui(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Zn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=ci(e,t),r=Zn(e.like,t);return n&&r?(0,je.cloneElement)(n,{style:V(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ci(e,t){var n,r,i,o,l,a,u,s,S,c,w,x,m,y,h,v,f,b,k,E,N,G,R;try{let A=ui(e,t);switch(e.type){case"stack":{let d=(r=Se[(n=e.gap)!=null?n:"md"])!=null?r:Se.md,g=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:g?"md":void 0;return(0,$.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Pt[e.align]}:{}),e.justify?{justifyContent:Pt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(o=Se[I])!=null?o:Se.md}:{}),g?V(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(S=(s=t.palette)==null?void 0:s.border)!=null?S:"currentColor"}`,borderRadius:(w=(c=t.palette)==null?void 0:c.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((T,_)=>{let P=xe(T,t);return P===null?null:(0,$.jsx)(je.Fragment,{children:P},_)})}))}case"grid":{let d=(y=Se[(m=e.gap)!=null?m:"md"])!=null?y:Se.md;return(0,$.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Pt[e.align]}:{}),e.pad?{padding:(h=Se[e.pad])!=null?h:Se.md}:{}),children:((v=e.children)!=null?v:[]).map((g,I)=>{let T=xe(g,t);return T===null?null:(0,$.jsx)(je.Fragment,{children:T},I)})}))}case"text":return A?(0,$.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:qn[e.size]}:{}),e.weight?{fontWeight:ai[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),zn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?(0,$.jsx)(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,$.jsx)(d,{style:p(p({margin:0,fontSize:oi[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return(0,$.jsx)("a",V(p(p({href:Et(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Yn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,$.jsx)("a",V(p(p({href:Et(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,$.jsx)("img",V(p({src:Et(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:si[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,$.jsx)("span",{className:A,children:e.value}):(0,$.jsx)("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(k=t.palette)==null?void 0:k.border)!=null?E:"currentColor"}`},zn(e.tone,t.palette)),children:e.value});case"spacer":return(0,$.jsx)("div",{style:{height:(N=Xn[e.size])!=null?N:Xn.md}});case"divider":return(0,$.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(G=t.palette)==null?void 0:G.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,$.jsx)(li,{node:e,opts:t});default:return null}}catch(A){return null}}function ot(e,t){var o,l,a,u;let n=xe(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Zn((u=e.surface)==null?void 0:u.like,t);return r?(0,$.jsx)("div",V(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}var fe=require("react"),st=require("@sentientui/core/region");function at(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function lt(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ke(e){return at(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ke(n),0):(0,fe.isValidElement)(e)?ke(lt(e)):0}function di(e,t){return Array.isArray(t)?(0,fe.cloneElement)(e,void 0,...t):(0,fe.cloneElement)(e,void 0,t)}function Nt(e,t){if(at(e))return t;if(Array.isArray(e))return e.map(n=>Nt(n,t));if((0,fe.isValidElement)(e)){let n=lt(e);return ke(n)===0?e:di(e,Nt(n,t))}return e}function Qn(e,t){return ke(e)===1?Nt(e,t):null}var ne=e=>e.join("/");function Tt(e,t,n){if(at(e)){n.leafPaths.push(t),n.texts.push((0,st.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Tt(r,[...t,i],n));return}(0,fe.isValidElement)(e)&&(n.elements.set(ne(t),e),Tt(lt(e),[...t,"c"],n))}function Dt(e){let t={leafPaths:[],texts:[],elements:new Map};return Tt(e,[],t),t}function fi(e){return Dt(e).texts}function er(e){let t=fi(e);return t.length===0?null:(0,st.skeletonFingerprint)(t)}function gi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function tr(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[gi(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(ne));l=l.filter(s=>u.has(ne(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function It(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Lt(e,t){let n=Dt(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=tr(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(ne(a)):void 0,s=!!u&&(typeof u.type=="string"||It(u)!==void 0);return V(p({},o),{restylable:s})});return V(p({},e),{nodes:i})}function nr(e,t,n){var m;let r=Dt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let o=tr(r,n),l=new Map;n.forEach((y,h)=>{l.has(y)||l.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[ne(y),h])),u=new Set,s=new Map,S=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),f=o[v];if(h.hidden&&(f?u.add(ne(f)):S=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(ne(f)):void 0,E=b?It(r.elements.get(ne(b))):void 0;!f||E===void 0||It(k)===void 0?S=!0:s.set(ne(f),E)}}let c=new Map(Object.entries((m=t.order)!=null?m:{})),w=(y,h)=>{var v;if(at(y)){let f=a.get(ne(h));if(f===void 0)return y;let b=n[f],k=(v=t.nodes[String(b)])==null?void 0:v.text;return k===void 0?y:l.get(b)===f?k:""}if(Array.isArray(y)){let f=y.map((b,k)=>w(b,[...h,k]));for(let[b,k]of c){let E=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||ne(A.slice(0,-1))!==ne(h)?-1:A[A.length-1]});if(E.some(R=>R<0))continue;let N=[...E].sort((R,A)=>R-A),G=[...f];N.forEach((R,A)=>{f[R]=G[E[A]]}),c.delete(b)}return f}if((0,fe.isValidElement)(y)){let f=ne(h);if(u.has(f))return null;let b=lt(y);if(ke(b)===0)return y;let k=w(b,[...h,"c"]),E=s.get(f),N=E!==void 0?{className:E}:void 0;return Array.isArray(k)?(0,fe.cloneElement)(y,N,...k):(0,fe.cloneElement)(y,N,k)}return y},x=w(e,[]);return S||c.size>0?null:x}var sr=require("react/jsx-runtime"),rr=new Set,ir=new Set,or=new Set,ut="authored.";function Ie({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:S,agentDataByVariant:c,agentData:w,variantsOnly:x=!1}){var zt,qt;let m=M(),y=re(),h=(0,L.useRef)(null),[v,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{f(!0)},[]);let b=S===!0&&(!v||!m),k=(0,L.useMemo)(()=>er(t),[t]),E=n?Object.keys(n).join("|"):"",N=(0,L.useMemo)(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ke(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!x}:{}),[k,t,r,E,x]),G=()=>{var q;let O=h.current;if(!O||!a)return null;let D=(0,Ft.captureRegionSkeleton)(O);return D.skeleton?(q=Lt(D.skeleton,t))!=null?q:V(p({},D.skeleton),{editable:!1,nodes:D.skeleton.nodes.map(H=>V(p({},H),{restylable:!1}))}):{status:D.reason}},R=(0,L.useSyncExternalStore)(Q,()=>n?ve(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${ut}${R}`:x?`${ut}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:I,vocabulary:T,source:_}=Jn(e,{forcedArm:A,baselineText:a?()=>{var O,D;return(D=(O=h.current)==null?void 0:O.textContent)!=null?D:null}:void 0,render:()=>N,skeleton:G,defer:b}),P=g!==""?(zt=d==null?void 0:d.blocks)==null?void 0:zt[g]:void 0,U=g!==""?(qt=d==null?void 0:d.compose)==null?void 0:qt[g]:void 0,W=(P!==void 0&&(0,Re.containsFormBlock)(P)||U!==void 0&&(0,Re.containsFormBlock)(U.tree))&&!r;(0,L.useEffect)(()=>{!W||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[W,e]);let X=O=>{!m||_==="override"||(_!=="seeded"&&m.componentGoal(e,O),m.goal(O,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},K=t,J=!1,j=g.startsWith(ut)?g.slice(ut.length):null;if((d==null?void 0:d.blocked)==="variant_history")J=!0;else if(j!==null)n&&Object.prototype.hasOwnProperty.call(n,j)?K=n[j]:J=!0;else if(U!==void 0){let O=W?null:ot(U,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if(P!==void 0){let O=W?null:xe(P,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if((d==null?void 0:d.edits)!==void 0&&_!=="none"){let O=d.edits,D=O.fp===k?nr(t,O.edits,O.leafToNode):null;D===null?J=!0:K=D}else if((d==null?void 0:d.content)!==void 0&&_!=="none"){let O=Qn(t,d.content);O===null?J=!0:K=O}let ae=J&&P===void 0&&U===void 0&&(d==null?void 0:d.edits)===void 0&&j===null&&(d==null?void 0:d.blocked)===void 0;(0,L.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||or.has(e)||(or.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Fe=j!==null&&!J?j:null;(0,L.useEffect)(()=>{var le;if(!Fe||!a||!m)return;let O=h.current;if(!O)return;let D=(0,Ft.captureRegionSkeleton)(O),q=D.skeleton?Lt(D.skeleton,n==null?void 0:n[Fe]):null,H=(le=O.textContent)==null?void 0:le.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Fe},H?{text:H}:{}),q?{skeleton:q}:{})]})},[Fe,m,e,b]);let Bt=J&&(d==null?void 0:d.edits)!==void 0&&(_==="preloaded"||_==="client");(0,L.useEffect)(()=>{var O;!Bt||!(d!=null&&d.edits)||(O=m==null?void 0:m.reportDrift)==null||O.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Bt,e,k,m]);let We=K===t;(0,L.useEffect)(()=>{var D;if(!(d!=null&&d.needsSkeleton)||!We)return;let O=G();O&&((D=m==null?void 0:m.reportSkeleton)==null||D.call(m,e,O))},[d==null?void 0:d.needsSkeleton,We,e,m,b]),(0,L.useEffect)(()=>{if(!We)return;let O=Cn(e);if(!O)return;let D=G();_n(O,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,We,b]),(0,L.useEffect)(()=>{!ae||!F()||ir.has(e)||(ir.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[ae,e]);let gt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";(0,L.useEffect)(()=>Oe({id:e,arms:gt===""?void 0:gt.split("|")}),[e,gt]);let Ut=(0,L.useRef)(null);(0,L.useEffect)(()=>{!m||_==="none"||_==="seeded"||_==="override"||g===""||J||Ut.current!==g&&(Ut.current=g,ye(m,y,e,g))},[m,y,e,g,_,J]);let me=_!=="none"&&_!=="seeded"&&!J,mt=me?g:"",Wt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,L.useEffect)(()=>{if(!m||!i||_==="override")return;let O=h.current;if(!O)return;let D=pe(i),q=ue(i),H=!1;return ce(O,te(i),{fireGoal:()=>{H||(H=!0,me&&(q!==void 0?m.componentGoal(e,D,{value:q}):m.componentGoal(e,D)),m.goal(D,p({metadata:{componentId:e,arm:mt},weight:1,stepIndex:0},q!==void 0?{value:q}:{})))},fireStep:(le,Je,yt)=>{me&&m.componentGoal(e,le,{reward:Je}),m.goal(le,{metadata:{componentId:e,arm:mt},weight:Je,stepIndex:yt})}},D)},[m,e,Wt,g,_,J,me,mt,b]);let pt=(0,L.useMemo)(()=>i?te(i):null,[Wt]);(0,L.useEffect)(()=>{_==="override"||!m||!pt||de(m,y,e,u,pt)},[m,y,e,u,pt,_]);let Kt=(0,L.useRef)(s);Kt.current=s;let Jt=(0,L.useRef)(new Set),Dr=s?JSON.stringify(s):"";(0,L.useEffect)(()=>{if(!m||_==="override"||!me||g==="")return;let O=h.current;if(O)return(0,Re.attachMicroSignalDetectors)((D,q={})=>{var Yt,Zt,Qt;m.track({projectId:y,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:D},q)});let H=(Yt=Kt.current)==null?void 0:Yt[D];if(!H||Jt.current.has(D))return;Jt.current.add(D);let le=typeof H=="string"?H:H.name,Je=typeof H=="string"?1:(Zt=H.weight)!=null?Zt:1,yt=typeof H=="string"?0:(Qt=H.stepIndex)!=null?Qt:0;m.goal(le,{metadata:p({componentId:e,arm:g,signalType:D},q),weight:Je,stepIndex:yt})},O,Date.now())},[m,y,e,g,_,me,Dr,b]);let Ht=(0,L.useRef)({agentData:w,agentDataByVariant:c});Ht.current={agentData:w,agentDataByVariant:c};let Xt=(0,L.useRef)(null);(0,L.useEffect)(()=>{var le;if(!m||_==="override"||!me||g===""||Xt.current===g)return;let{agentData:O,agentDataByVariant:D}=Ht.current,q=j!=null?j:g,H=D!==void 0?Object.prototype.hasOwnProperty.call(D,q)?D[q]:void 0:O;H!==void 0&&(Xt.current=g,(le=m.reportAgentData)==null||le.call(m,e,g,H))},[m,e,g,me,j,_]);let Ke=(0,L.useRef)(null);(0,L.useEffect)(()=>{let O=h.current;if(O){if(Ke.current===null){Ke.current=g;return}Ke.current!==g&&(Ke.current=g,(0,Re.reveal)(O))}},[g,b]);let Lr=(0,L.useMemo)(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:(0,sr.jsx)(l,V(p({ref:h,className:o},Lr),{children:K}))}var Ae=require("react/jsx-runtime");function mi(e){var S,c;let{client:t,variantId:n,content:r,ref:i}=it(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{l(!0)},[]);let a=(S=e.as)!=null?S:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return F()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var pi=(0,ge.memo)(mi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function ar(e){if(e.variants===void 0)return(0,Ae.jsx)(Ie,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Me(n,["variants"]);return(0,Ae.jsx)(Ie,V(p({},i),{children:t.children,variants:r}))}return(0,Ae.jsx)(yi,p({},t))}function yi(e){var c;let[t,n]=(0,ge.useState)(null),{id:r}=e,i=(0,ge.useCallback)(()=>n(r),[r]),o=M(),l=Qe().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return(0,Ae.jsx)(pi,V(p({},e),{onUnified:i}));let w=e,{variants:a,children:u}=w,s=Me(w,["variants","children"]),S=Object.keys(a)[0];return(0,Ae.jsx)(Ie,V(p({},s),{variants:a,variantsOnly:!0,children:S!==void 0?a[S]:null}))}var z=require("react");var ur=require("react/jsx-runtime");function lr({id:e,default:t,component:n="span",className:r,goal:i}){var N;let o=M(),l=re(),a=et(),u=Te(),s=(0,z.useRef)(null),S=(0,z.useRef)(null),c=(0,z.useSyncExternalStore)(Q,()=>ve(e),()=>null),[w,x]=(0,z.useState)(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.content)!=null?R:null}),[m,y]=(0,z.useState)(()=>{var G,R;return(R=(G=o==null?void 0:o.getAssignment(e,u))==null?void 0:G.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(c||!o)return;let G=o.getAssignment(e,u);if((G==null?void 0:G.content)!==void 0){y(G.variantId),x(G.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,u,c]),(0,z.useEffect)(()=>{c||!o||!m||!l||s.current!==m&&(s.current=m,o.track({projectId:l,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,l,e,a,c]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,z.useMemo)(()=>i===void 0?null:te(i),[h]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,z.useRef)(!1);(0,z.useEffect)(()=>{b.current=!1},[m,h]),(0,z.useEffect)(()=>{c||!o||!l||de(o,l,e,void 0,v)},[o,l,e,v,c]),(0,z.useEffect)(()=>{if(c||!o||!m||!l||!v||!f)return;let G=S.current;if(!G)return;let R=ue(v);return ce(G,v,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,l,e,v,f,c]);let k=w!=null?w:t;if(c){let G=o==null?void 0:o.getAssignment(e,u);k=G&&G.variantId===c&&(N=G.content)!=null?N:t}return(0,ur.jsx)(n,{ref:G=>{S.current=G},className:r,children:k})}var ct=require("react");function Be(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function De(e){let t=M(),n=(0,ct.useRef)(new Set);return(0,ct.useCallback)((r,i)=>{if(!ve(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,Be(i))}},[t,e])}var Ue=require("react");function cr(e,t={}){let u=t,{componentId:n}=u,r=Me(u,["componentId"]),i=M(),o=De(n!=null?n:""),l=(0,Ue.useRef)(!1),a=(0,Ue.useRef)(r);a.current=r,(0,Ue.useEffect)(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,Be(a.current))}},[i,n,e,o])}var Le=require("react");var dr=new Set,fr=new Map;function vi(e,t,n,r){let i=r;if(r){let l=fr.get(t);l&&l!==n?(F()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):fr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;dr.has(o)||(dr.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function gr(e,t={}){let{primary:n=!1,componentId:r}=t,i=M(),o=re(),l=De(r!=null?r:""),a=(0,Le.useRef)(!1);return(0,Le.useEffect)(()=>{!i||i.gated||!o||vi(i,o,e,n)},[i,o,e,n]),(0,Le.useCallback)(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,Be(u))},[i,r,l,e])}var mr=require("@sentientui/core"),pr=require("@sentientui/policy"),vr=require("react/jsx-runtime");function Vt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Si(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Vt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Vt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Vt((0,pr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,mr.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function yr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,vr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Si(e)}})}var se=require("react"),wr=require("@sentientui/policy");var oe=require("react"),Ce=require("@sentientui/core"),Sr=require("@sentientui/policy");function dt(e,t){let n=M(),r=tt(),[,i]=(0,oe.useReducer)(c=>c+1,0),o=(0,oe.useSyncExternalStore)(Q,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;(0,oe.useEffect)(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(w=>{!c&&w&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,Ce.armOfResult)(o),source:"override"};if(l!==void 0)return{result:l,arm:(0,Ce.armOfResult)(l),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ce.armOfResult)(a),source:w?"client":"seeded"}}let c=(0,Ce.baselineResultFor)(t);return{result:c,arm:(0,Ce.armOfResult)(c),source:"baseline"}})(),S=s.source==="preloaded"||s.source==="override";return(0,oe.useEffect)(()=>{var w;if(!n||n.isLocal===!0||S||!n.decideSlots)return;let c=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,S]),s}function hi(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function hr(){let e=M(),t=Fn();(0,oe.useSyncExternalStore)(Q,cn,()=>0);let[n,r]=(0,oe.useState)(!1);(0,oe.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,Sr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=hi();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var br=new Set;function bi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function xr(e,t,n){let r=M(),i=re(),o=JSON.stringify(t),l=(0,se.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=dt(e,l),S=(0,se.useMemo)(()=>typeof a=="string"?{}:a,[u]);if(F()&&!br.has(e)){br.add(e);let y=(0,wr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),h=Object.values(t).reduce((v,f)=>v*f.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,se.useEffect)(()=>Oe({id:e,dims:t}),[e]);let w=(0,se.useRef)(null);(0,se.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===u||(w.current=u,ye(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;(0,se.useEffect)(()=>{var y;!r||s==="override"||de(r,i,e,x,te((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,x,c,s]),(0,se.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${bi(e)}"]`);if(!y){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=pe(n.goal),v=ue(n.goal),f=!1;return ce(y,te(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,k,E)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:u},weight:k,stepIndex:E})}},h)},[r,e,c,u,s]);let m=(0,se.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(S))y[`data-${h}`]=v;return y},[e,S]);return{tokens:S,props:m}}var _e=require("react");var kr=new Set,Rr=new Set;function Ar(e,t){var m,y;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=it(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",S=t.variants[s],c=Qe().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;(0,_e.useEffect)(()=>{!c||!F()||Rr.has(e)||(Rr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),(0,_e.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!u.current&&!kr.has(e)&&(kr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=(0,_e.useCallback)((h,v)=>{var b,k;if(o)return;let f=h!=null?h:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(b=v==null?void 0:v.metadata)!=null?b:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=(0,_e.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:S,bind:x,fireGoal:w}}var Z=require("react");var _r=require("react/jsx-runtime"),ft=new Set;function Cr(e){var f;let t=M(),n=re(),r=(0,Z.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Z.useMemo)(()=>Object.keys(e.arrangements),[i]),l=(0,Z.useMemo)(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=dt(e.id,l);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!ft.has(e.id+":baseline")&&(ft.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Z.Children.toArray(e.children).filter(Z.isValidElement),S=new Map;for(let b of s)S.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let c=e.arrangements[a],w=c!==void 0&&c.length===s.length&&c.every(b=>S.has(b));F()&&c!==void 0&&!w&&!ft.has(e.id+":keys")&&(ft.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?c.map(b=>S.get(b)):s;(0,Z.useEffect)(()=>Oe({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||m.current===a||(m.current=a,ye(t,n,e.id,a))},[t,n,e.id,a,u]);let y=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Z.useEffect)(()=>{var b;!t||u==="override"||de(t,n,e.id,y,te((b=e.goal)!=null?b:"click"))},[t,n,e.id,y,h,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Z.useEffect)(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let b=r.current;if(!b)return;let k=pe(e.goal),E=ue(e.goal),N=!1;return ce(b,te(e.goal),{fireGoal:()=>{N||(N=!0,E!==void 0?t.componentGoal(e.id,k,{value:E}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},E!==void 0?{value:E}:{})))},fireStep:(G,R,A)=>{t.componentGoal(e.id,G,{reward:R}),t.goal(G,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,v,a,u]),(0,_r.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Mt=require("@sentientui/core");var wi=["page","blocks","layoutOrder"],Or=new Map;function Gr(e,t){Or.set(e,t)}function $t(e){return Or.get(e)}function Er(e){var i,o;let t=(o=(i=e.content)!=null?i:$t(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))wi.includes(l)||(n[l]=a);let r=V(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Pr(e){return`<script type="application/ld+json">${jt(e)}</script>`}function jt(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Nr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
4
|
`}var Tr=require("@sentientui/core"),Ir=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useGoal,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var hr=Object.defineProperty,br=Object.defineProperties;var wr=Object.getOwnPropertyDescriptors;var Ve=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Xt=(e,t,n)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))zt.call(t,n)&&Xt(e,n,t[n]);if(Ve)for(var n of Ve(t))qt.call(t,n)&&Xt(e,n,t[n]);return e},L=(e,t)=>br(e,wr(t));var Ce=(e,t)=>{var n={};for(var r in e)zt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ve)for(var r of Ve(e))t.indexOf(r)<0&&qt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Nr,useContext as X,useEffect as ee,useMemo as An,useRef as se,useState as Oe,useSyncExternalStore as Tr}from"react";import{deriveSessionSegment as Ir,init as Dr}from"@sentientui/core";var Yt=new Map,Me=new Map;function Zt(e,t){let n=Me.get(e);return n||(n=new Set,Me.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Me.delete(e)}}function Qt(e,t){Yt.set(e,t);let n=Me.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function lt(e){var t;return(t=Yt.get(e))!=null?t:null}var xr={on:!1,listeners:new Set};function en(){if(typeof window=="undefined")return xr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ut(){return en().on}function tn(e){let t=en().listeners;return t.add(e),()=>{t.delete(e)}}function nn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ct="sentient:overrides-changed";function rn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function dt(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ct))}function q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ct,e),()=>window.removeEventListener(ct,e))}function on(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Y(e){return typeof e=="string"?{type:"click"}:e}function le(e){return typeof e=="string"?e:e.type}function re(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ft=new Set,gt=!1;function sn(e){if(ft.has(e))return!0;if(ft.add(e),!gt){gt=!0;let t=()=>{gt=!1,ft.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function kr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function an(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(kr(r))return!0;r=r.parentElement}return!1}function ie(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,S=[];return t.steps.forEach(({goal:c,name:w,weight:x},m)=>{let y=(h=!1)=>{s.has(m)||h&&r!==void 0&&sn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(c.type==="click"){let h=v=>{let f=v.target;f instanceof Element&&an(f,e,c.selector)&&y()};e.addEventListener("click",h),S.push(()=>e.removeEventListener("click",h));return}if(c.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),S.push(()=>e.removeEventListener("submit",h));return}if(c.type==="scroll_depth"){let h=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),S.push(()=>v.disconnect())}}),()=>{for(let c of S)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,S)=>S)),l=()=>{r!==void 0&&sn(r)||n.fireGoal()},a=(s,S=!1)=>{o.delete(s),o.size===0&&(S?l():n.fireGoal())},u=[];return i.forEach((s,S)=>{if(s.type==="click"){let c=w=>{let x=w.target;x instanceof Element&&an(x,e,s.selector)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=c){t.type==="composite"?a(S,!0):l(),w.disconnect();break}},{threshold:[c]});w.observe(e),u.push(()=>w.disconnect());return}}),()=>{for(let s of u)s()}}var ln=new Set,un=new Set;function Rr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var Ar=12;function Cr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===Ar||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function oe(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Rr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(un.has(a))return;un.add(a);let u=o&&!ln.has(l)?Cr(n,o):null,s=u!==null&&u.length>=2;s&&ln.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ue(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var _r={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function fe(){if(typeof window=="undefined")return _r;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function _e(){fe().version+=1;for(let e of fe().listeners)e()}var cn=()=>{};function dn(e){return D()?(fe().components.set(e.id,e),_e(),()=>{fe().components.delete(e.id),_e()}):cn}function Se(e){return D()?(fe().slots.set(e.id,e),_e(),()=>{fe().slots.delete(e.id),_e()}):cn}function mt(e){D()&&(fe().sections=[...e],_e())}var fn="0.42.1",pt=fn!=="0.0.0-dev"?{name:"react",version:fn}:void 0;function Or(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){Or()[e]=t}function gn(e){window.__sentient_vocabulary_override=e}function mn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Gr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){Gr()[e]=t}function pn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var vt="__snt_editor_token",we=null,yt=!1;function yn(){return yt}function Er(){try{return sessionStorage.getItem(vt)}catch(e){return null}}function $e(e){if(we)return we;let t=typeof window=="undefined"?null:pn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Er();return yt=!!n,we=Promise.resolve(n?{token:n,fresh:!1}:null),we}return yt=!0,we=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(vt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),we}function vn(){try{sessionStorage.removeItem(vt)}catch(e){}}var Sn="sentient_preview_cell",hn="sentient_refresh_region",St="sentient-cell-preview-bar",ge="__preview__",xe=null;function bn(e){if((xe==null?void 0:xe.slotId)!==e)return null;let t=xe;return xe=null,t}function wn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>me(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>me("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function xn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(St))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(Sn),n=u.get(hn)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=$e(r);if(!yn())return;if(n){xe={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,ge),dt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(me(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){me(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&gn(s.vocabulary),s.compose!=null)he(l,{kind:"arms",compose:{[ge]:s.compose}}),be(l,ge);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))he(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),be(l,ge);else if(s.blocks!=null)he(l,{kind:"arms",blocks:{[ge]:s.blocks}}),be(l,ge);else if(s.content!=null)he(l,{kind:"arms",content:s.content}),be(l,ge);else{me("Nothing to preview in that square yet.");return}dt(),me(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var S;try{(S=document.querySelector(`[data-sentient-slot="${l}"]`))==null||S.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>me("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function me(e){var i;if(document.getElementById(St))return;let t=document.createElement("div");t.id=St,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{vn();let o=new URL(window.location.href);o.searchParams.delete(Sn),o.searchParams.delete(hn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var kn=!1;function Rn(e){if(kn||typeof window=="undefined")return;kn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");$e(t).then(n=>{!n||!("token"in n)||!n.fresh||Pr(t,n.token)})}function Pr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Br}from"react/jsx-runtime";function Lr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Ir({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var _n="https://api.sentient-ui.com/v1",H=Nr({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:_n,debug:!1}),Cn=!1,ht=new Set;function Fr(e,t,n){let r=se(n);r.current=n;let[i,o]=Oe(null),[l,a]=Oe(!1),u=se(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(L(p({},e),{check:typeof e.check,refused:typeof e.refused}));return ee(()=>{let S=u.current;if(S===void 0||typeof window=="undefined")return;let c,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let y=x(typeof S=="object"&&S.cmp===void 0&&S.check?p(L(p({},S),{check:()=>u.current.check()}),S.refused?{refused:()=>{var f,b;return((b=(f=u.current).refused)==null?void 0:b.call(f))===!0}}:{}):S),h=!1,v=()=>{let f=y.refused()&&y.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=y.read();b!==null&&ht.add(t),o(b!=null?b:ht.has(t)?!1:null)};v(),c=y.subscribe(v)}),()=>{w=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function Vr(e){var P,O,R,A,d;let[t,n]=Oe(null),[r]=Oe(()=>{var g;return(g=e.sessionSegment)!=null?g:Lr()}),[i,o]=Oe(ut());ee(()=>tn(()=>o(ut())),[]),ee(()=>{xn(e.apiBaseUrl),Rn(e.apiBaseUrl)},[]);let l=se(()=>{}),a=Fr(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(P=a.granted)!=null?P:ht.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,S=se(s);S.current=s;let c=se(null),w=se(!1),x=se([]),m=se(!1);l.current=()=>{var T;x.current=[],m.current=!0;let g=c.current;g!=null&&g.gated?g.dispose():(T=g==null?void 0:g.takeHeld)==null||T.call(g)},ee(()=>{var B,U;if(S.current&&u===!1&&(x.current=[]),u===!1&&w.current&&(S.current&&((B=c.current)==null||B.destroy()),c.current=null,w.current=!1),u===!1&&!e.preConsentBehavior){S.current&&((U=c.current)==null||U.destroy()),c.current=null,n(null);return}let g=u!==!1;g&&(m.current=!1);let T=V=>{!g&&m.current&&V.gated&&V.dispose()},N=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},pt?{sdk:pt}:{}),C=!1,E=null,$=null,j=V=>{for(let te of x.current.splice(0))setTimeout(()=>{if(c.current!==V){m.current||x.current.push(te);return}try{te(V)}catch(Ae){}},0)},K=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:te})=>{C||($=te(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{C||(E=V(L(p({},N),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),T(E),c.current=E,w.current=g,j(E),n(E),K(E))}):(E=Dr(N),T(E),c.current=E,w.current=g,j(E),n(E),K(E)),()=>{var V,te;C=!0,$==null||$(),x.current=x.current.concat((te=(V=E==null?void 0:E.takeHeld)==null?void 0:V.call(E))!=null?te:[]),E==null||E.dispose()}},[u]),ee(()=>{if(!t)return;let g=!1,T=async()=>{if(g)return;let C;try{C=await t.fetchWeights()}catch(E){return}if(!g)for(let E of C){let $={componentId:E.componentId,updatedAt:E.updatedAt,variants:E.variants.map(j=>{var K;return{variantId:j.variantId,pulls:j.pulls,avgReward:(K=j.avgReward)!=null?K:0}})};Qt(E.componentId,$)}};T();let N=setInterval(()=>{T()},6e4);return()=>{g=!0,clearInterval(N)}},[t]);let y=(O=e.ssrFallback)!=null?O:"first",h=((R=e.apiBaseUrl)!=null?R:_n).replace(/\/$/,""),v=se(null);ee(()=>{var N;if(typeof process!="undefined"&&((N=process.env)==null?void 0:N.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},T=v.current;if(v.current=g,T!==null)for(let C of["apiKey","context","country","persona","apiBaseUrl"])Object.is(T[C],g[C])||console.warn(`[sentient] AdaptiveProvider: \`${C}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),ee(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||on({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;ee(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),ee(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){mt(g);return}e.declaredSections&&e.declaredSections.length>0&&mt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),ee(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||Cn||(Cn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),ee(()=>{if(!D())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let T=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),C=>C.getAttribute("data-sentient-id"))),N=g.filter(C=>!T.has(C));N.length>0&&console.warn(`[SentientUI] Declared section${N.length>1?"s":""} ${N.map(C=>`"${C}"`).join(", ")} ${N.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=An(()=>t&&i?nn(t):t,[t,i]),G=An(()=>{var g,T,N,C,E,$,j,K,B;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(T=e.initialUnified)!=null?T:Mr,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(N=e.initialLayoutOrder)!=null?N:null,initialSlots:(C=e.initialSlots)!=null?C:{},initialSlotConfig:(E=e.initialSlotConfig)!=null?E:{},initialPalette:($=e.initialPalette)!=null?$:null,initialVocabulary:(j=e.initialVocabulary)!=null?j:null,initialPersona:(K=e.initialPersona)!=null?K:null,apiBaseUrl:h,debug:(B=e.debug)!=null?B:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Br(H.Provider,{value:G,children:e.children})}function F(){return X(H).client}function Q(){return X(H).apiKey}function bt(){return X(H).initialAssignments}var Mr=[];function je(){return X(H).initialUnified}function Ge(){return X(H).sessionSegment}function On(){return X(H).ssrFallback}function Be(){return X(H).onAssignment}function Gn(){return X(H).debug}function $r(){let e=X(H).initialLayoutOrder,t=Tr(q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ue(){return X(H).initialSlots}function En(){return X(H).initialPersona}function Pn(){return X(H).initialSlotConfig}function Nn(){return X(H).initialPalette}function Tn(){return X(H).initialVocabulary}function jr(){return X(H).apiBaseUrl}import{memo as mi,useCallback as pi,useEffect as yi,useState as nr}from"react";import{useCallback as Kr,useEffect as pe,useMemo as Dn,useRef as Ee,useState as Jr}from"react";import{attachMicroSignalDetectors as Hr}from"@sentientui/core";import{useEffect as We,useRef as In,useState as Ur,useSyncExternalStore as Wr}from"react";import{pickFromWeights as wt}from"@sentientui/policy";function ce(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function xt(e,t,n,r,i){let o=bt(),l=On(),a=F(),u=Ge(),s=Be(),S=Gn(),c=In(null),w=Wr(q,()=>ce(e),()=>null),x=w&&t.includes(w)?w:null,m=In(null);We(()=>{S&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[S,x,e]);let[y,h]=Ur(()=>{var k,G;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let P=o[e];return P&&t.includes(P)?{variantId:P,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=lt(e);if(b){let P=wt(b.variants,t);if(P)return{variantId:P,content:null,isLoading:!1,settled:!0}}return{variantId:(G=t[0])!=null?G:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return We(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let b=lt(e);if(b&&y.settled&&y.variantId&&y.variantId===wt(b.variants,t)){v(y.variantId);return}h(G=>{var P;return G.variantId?G:{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),We(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(P=>{var O;if(!b&&P){if(P.unified===!0){k==null||k();return}!t.includes(P.variantId)&&!P.content||(h({variantId:P.variantId,content:(O=P.content)!=null?O:null,isLoading:!1,settled:!0}),v(P.variantId))}}),()=>{b=!0}},[x,a,e,u]),We(()=>{if(!x&&a)return Zt(e,f=>{var G;let b=a.getAssignment(e,u);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(G=b.content)!=null?G:null,isLoading:!1,settled:!0}),v(b.variantId);return}let k=wt(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function Ke(e,t,n){let r=F(),i=Q(),o=Object.keys(t).join("\0"),l=Dn(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:S}=xt(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,w]=Jr(null),x=Ee(null),m=Kr(d=>{x.current=d,w(d)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=Dn(()=>y?Y(y):null,[h]),f=y?le(y):"";pe(()=>dn({id:e,variantIds:l,goal:f}),[e,l,f]);let b=Ee(null);pe(()=>{s||S&&(!r||!a||!i||!c||b.current!==a&&(b.current=a,ue(r,i,e,a)))},[r,a,i,e,c,s,S]);let k=Ee(!1),G=Ee(new Set);pe(()=>{k.current=!1,G.current=new Set},[a,v]);let P=n.funnel;pe(()=>{s||!S||!r||!v||oe(r,i,e,P,v)},[r,i,e,P,v,s,S]);let O=n.cursorSignal===!0;pe(()=>{if(!O||s||!S||!r||!a||!c)return;let d=null,g=0,T=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},N=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",T),c.addEventListener("mouseleave",N),()=>{c.removeEventListener("mouseenter",T),c.removeEventListener("mouseleave",N),d!==null&&clearTimeout(d)}},[O,r,a,i,e,c,s,S]);let R=Ee(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return pe(()=>{if(s||!S||!r||!a||!c)return;let d=Date.now();return Hr((g,T={})=>{var j,K,B;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},T)});let N=(j=R.current)==null?void 0:j[g];if(!N||G.current.has(g))return;G.current.add(g);let C=typeof N=="string"?N:N.name,E=typeof N=="string"?1:(K=N.weight)!=null?K:1,$=typeof N=="string"?0:(B=N.stepIndex)!=null?B:0;r.goal(C,{metadata:p({signalType:g},T),weight:E,stepIndex:$})},c,d)},[r,a,i,e,c,A,s,S]),pe(()=>{if(s||!S||!r||!a||!c||!v)return;let d=re(v);return ie(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,T,N)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:T}}),r.goal(g,{metadata:{},weight:T,stepIndex:N})}},f)},[r,a,i,e,c,v,f,s,S]),{client:r,variantIds:l,variantId:a,content:u,settled:S,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}import{useEffect as z,useMemo as Ye,useRef as ve,useState as ui,useSyncExternalStore as ci}from"react";import{attachMicroSignalDetectors as di,containsFormBlock as Yn,reveal as fi}from"@sentientui/core";import{captureRegionSkeleton as Zn}from"@sentientui/core/region";import{useCallback as Xr,useEffect as Ln,useRef as kt,useSyncExternalStore as Je}from"react";import{armOfResult as zr}from"@sentientui/core";var Fn=new Set,qr={kind:"arms"};function Vn(e,t){var G,P,O;let n=F(),r=kt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=kt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=kt(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=Ue(),a=Pn(),u=Nn(),s=Tn(),S=Je(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=Je(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":zr(R),x=Xr(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);Je(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),Je(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=S===void 0?a[e]:void 0,y=S===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(G=u!=null?u:n==null?void 0:n.getSitePalette())!=null?G:null,v=(O=s!=null?s:(P=n==null?void 0:n.getStyleVocabulary)==null?void 0:P.call(n))!=null?O:null,f=(()=>{var R,A,d;if(S!==void 0)return{config:S,arm:w(c),palette:h,vocabulary:(R=mn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:qr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(m!==void 0)return{config:m,arm:w((A=l[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:h,vocabulary:v,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return Ln(()=>{var E,$,j,K,B;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&($=(E=r.current)==null?void 0:E.call(r))!=null?$:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(j=i.current)==null?void 0:j.call(i),T=R&&(B=(K=o.current)==null?void 0:K.call(o))!=null?B:null,N=p(p({},g?{render:{[e]:g}}:{}),T?{skeletons:{[e]:T}}:{}),C=Object.keys(N).length>0;return n.requestSlots?C?n.requestSlots([e],d,N):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(T?n.reportSlots([e],d!=null?d:{},{[e]:T}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var U;return(U=n.cancelSlots)==null?void 0:U.call(n,[e])}},[n,k,f.source,e,b]),Ln(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Fn.has(e)||(Fn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}import{cloneElement as Yr,Fragment as Mn}from"react";import{jsx as M,jsxs as Un}from"react/jsx-runtime";function Rt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var de={none:"0",sm:"8px",md:"16px",lg:"24px"},At={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Wn={sm:"0.875em",md:"1em",lg:"1.25em"},Zr={sm:"1.25em",md:"1.5em",lg:"2em"},$n={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},jn={sm:"8px",md:"16px",lg:"32px"},Qr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ei={normal:"400",medium:"500",bold:"700"};function Bn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Kn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return L(p({display:"inline-block",padding:(i=$n[n!=null?n:"md"])!=null?i:$n.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Wn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ti({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return Un("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let S=new FormData(s.currentTarget),c={};for(let y of e.fields)c[y.name]=String((w=S.get(y.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,c)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var S,c;return Un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?M("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?M("select",{name:s.name,required:s.required,style:r,children:((S=s.options)!=null?S:[]).map(w=>M("option",{value:w,children:w},w))}):M("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),M("button",{type:"submit",style:Kn(n,t.palette),children:e.submitLabel})]})}function ni(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Jn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ke(e,t){var i;let n=ri(e,t),r=Jn(e.like,t);return n&&r?Yr(n,{style:L(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ri(e,t){var n,r,i,o,l,a,u,s,S,c,w,x,m,y,h,v,f,b,k,G,P,O,R;try{let A=ni(e,t);switch(e.type){case"stack":{let d=(r=de[(n=e.gap)!=null?n:"md"])!=null?r:de.md,g=e.surface==="raised"&&!A,T=(i=e.pad)!=null?i:g?"md":void 0;return M("div",L(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:At[e.align]}:{}),e.justify?{justifyContent:At[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),T?{padding:(o=de[T])!=null?o:de.md}:{}),g?L(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(S=(s=t.palette)==null?void 0:s.border)!=null?S:"currentColor"}`,borderRadius:(w=(c=t.palette)==null?void 0:c.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((N,C)=>{let E=ke(N,t);return E===null?null:M(Mn,{children:E},C)})}))}case"grid":{let d=(y=de[(m=e.gap)!=null?m:"md"])!=null?y:de.md;return M("div",L(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:At[e.align]}:{}),e.pad?{padding:(h=de[e.pad])!=null?h:de.md}:{}),children:((v=e.children)!=null?v:[]).map((g,T)=>{let N=ke(g,t);return N===null?null:M(Mn,{children:N},T)})}))}case"text":return A?M("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:Wn[e.size]}:{}),e.weight?{fontWeight:ei[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?M(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M(d,{style:p(p({margin:0,fontSize:Zr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return M("a",L(p(p({href:Rt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Kn(d,t.palette,e.size)}),{children:e.label}))}case"link":return M("a",L(p(p({href:Rt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return M("img",L(p({src:Rt(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Qr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?M("span",{className:A,children:e.value}):M("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(G=(k=t.palette)==null?void 0:k.border)!=null?G:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return M("div",{style:{height:(P=jn[e.size])!=null?P:jn.md}});case"divider":return M("hr",{style:{border:"none",borderTop:`1px solid ${(R=(O=t.palette)==null?void 0:O.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return M(ti,{node:e,opts:t});default:return null}}catch(A){return null}}function Ct(e,t){var o,l,a,u;let n=ke(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Jn((u=e.surface)==null?void 0:u.like,t);return r?M("div",L(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as He,isValidElement as Xe}from"react";import{normalizeLeafText as ii,skeletonFingerprint as oi}from"@sentientui/core/region";function ze(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function qe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ye(e){return ze(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ye(n),0):Xe(e)?ye(qe(e)):0}function si(e,t){return Array.isArray(t)?He(e,void 0,...t):He(e,void 0,t)}function _t(e,t){if(ze(e))return t;if(Array.isArray(e))return e.map(n=>_t(n,t));if(Xe(e)){let n=qe(e);return ye(n)===0?e:si(e,_t(n,t))}return e}function Hn(e,t){return ye(e)===1?_t(e,t):null}var Z=e=>e.join("/");function Ot(e,t,n){if(ze(e)){n.leafPaths.push(t),n.texts.push(ii(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Ot(r,[...t,i],n));return}Xe(e)&&(n.elements.set(Z(t),e),Ot(qe(e),[...t,"c"],n))}function Et(e){let t={leafPaths:[],texts:[],elements:new Map};return Ot(e,[],t),t}function ai(e){return Et(e).texts}function Xn(e){let t=ai(e);return t.length===0?null:oi(t)}function li(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function zn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[li(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(Z));l=l.filter(s=>u.has(Z(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function Gt(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Pt(e,t){let n=Et(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=zn(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(Z(a)):void 0,s=!!u&&(typeof u.type=="string"||Gt(u)!==void 0);return L(p({},o),{restylable:s})});return L(p({},e),{nodes:i})}function qn(e,t,n){var m;let r=Et(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let o=zn(r,n),l=new Map;n.forEach((y,h)=>{l.has(y)||l.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[Z(y),h])),u=new Set,s=new Map,S=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),f=o[v];if(h.hidden&&(f?u.add(Z(f)):S=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(Z(f)):void 0,G=b?Gt(r.elements.get(Z(b))):void 0;!f||G===void 0||Gt(k)===void 0?S=!0:s.set(Z(f),G)}}let c=new Map(Object.entries((m=t.order)!=null?m:{})),w=(y,h)=>{var v;if(ze(y)){let f=a.get(Z(h));if(f===void 0)return y;let b=n[f],k=(v=t.nodes[String(b)])==null?void 0:v.text;return k===void 0?y:l.get(b)===f?k:""}if(Array.isArray(y)){let f=y.map((b,k)=>w(b,[...h,k]));for(let[b,k]of c){let G=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||Z(A.slice(0,-1))!==Z(h)?-1:A[A.length-1]});if(G.some(R=>R<0))continue;let P=[...G].sort((R,A)=>R-A),O=[...f];P.forEach((R,A)=>{f[R]=O[G[A]]}),c.delete(b)}return f}if(Xe(y)){let f=Z(h);if(u.has(f))return null;let b=qe(y);if(ye(b)===0)return y;let k=w(b,[...h,"c"]),G=s.get(f),P=G!==void 0?{className:G}:void 0;return Array.isArray(k)?He(y,P,...k):He(y,P,k)}return y},x=w(e,[]);return S||c.size>0?null:x}import{jsx as gi}from"react/jsx-runtime";var Qn=new Set,er=new Set,tr=new Set,Ze="authored.";function Pe({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:S,agentDataByVariant:c,agentData:w,variantsOnly:x=!1}){var Ut,Wt;let m=F(),y=Q(),h=ve(null),[v,f]=ui(!1);z(()=>{f(!0)},[]);let b=S===!0&&(!v||!m),k=Ye(()=>Xn(t),[t]),G=n?Object.keys(n).join("|"):"",P=Ye(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ye(t)===1,ops:!1},G!==""?{authored:G.split("|"),children:!x}:{}),[k,t,r,G,x]),O=()=>{var J;let _=h.current;if(!_||!a)return null;let I=Zn(_);return I.skeleton?(J=Pt(I.skeleton,t))!=null?J:L(p({},I.skeleton),{editable:!1,nodes:I.skeleton.nodes.map(W=>L(p({},W),{restylable:!1}))}):{status:I.reason}},R=ci(q,()=>n?ce(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${Ze}${R}`:x?`${Ze}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:T,vocabulary:N,source:C}=Vn(e,{forcedArm:A,baselineText:a?()=>{var _,I;return(I=(_=h.current)==null?void 0:_.textContent)!=null?I:null}:void 0,render:()=>P,skeleton:O,defer:b}),E=g!==""?(Ut=d==null?void 0:d.blocks)==null?void 0:Ut[g]:void 0,$=g!==""?(Wt=d==null?void 0:d.compose)==null?void 0:Wt[g]:void 0,j=(E!==void 0&&Yn(E)||$!==void 0&&Yn($.tree))&&!r;z(()=>{!j||!D()||Qn.has(e)||(Qn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[j,e]);let K=_=>{!m||C==="override"||(C!=="seeded"&&m.componentGoal(e,_),m.goal(_,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},B=t,U=!1,V=g.startsWith(Ze)?g.slice(Ze.length):null;if((d==null?void 0:d.blocked)==="variant_history")U=!0;else if(V!==null)n&&Object.prototype.hasOwnProperty.call(n,V)?B=n[V]:U=!0;else if($!==void 0){let _=j?null:Ct($,{palette:T,vocabulary:N,onFormSubmit:r,onFormGoal:K});_===null?U=!0:B=_}else if(E!==void 0){let _=j?null:ke(E,{palette:T,vocabulary:N,onFormSubmit:r,onFormGoal:K});_===null?U=!0:B=_}else if((d==null?void 0:d.edits)!==void 0&&C!=="none"){let _=d.edits,I=_.fp===k?qn(t,_.edits,_.leafToNode):null;I===null?U=!0:B=I}else if((d==null?void 0:d.content)!==void 0&&C!=="none"){let _=Hn(t,d.content);_===null?U=!0:B=_}let te=U&&E===void 0&&$===void 0&&(d==null?void 0:d.edits)===void 0&&V===null&&(d==null?void 0:d.blocked)===void 0;z(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||tr.has(e)||(tr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Ae=V!==null&&!U?V:null;z(()=>{var ne;if(!Ae||!a||!m)return;let _=h.current;if(!_)return;let I=Zn(_),J=I.skeleton?Pt(I.skeleton,n==null?void 0:n[Ae]):null,W=(ne=_.textContent)==null?void 0:ne.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Ae},W?{text:W}:{}),J?{skeleton:J}:{})]})},[Ae,m,e,b]);let Lt=U&&(d==null?void 0:d.edits)!==void 0&&(C==="preloaded"||C==="client");z(()=>{var _;!Lt||!(d!=null&&d.edits)||(_=m==null?void 0:m.reportDrift)==null||_.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Lt,e,k,m]);let De=B===t;z(()=>{var I;if(!(d!=null&&d.needsSkeleton)||!De)return;let _=O();_&&((I=m==null?void 0:m.reportSkeleton)==null||I.call(m,e,_))},[d==null?void 0:d.needsSkeleton,De,e,m,b]),z(()=>{if(!De)return;let _=bn(e);if(!_)return;let I=O();wn(_,I&&"status"in I?{status:I.status}:{skeleton:I})},[e,De,b]),z(()=>{!te||!D()||er.has(e)||(er.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[te,e]);let it=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";z(()=>Se({id:e,arms:it===""?void 0:it.split("|")}),[e,it]);let Ft=ve(null);z(()=>{!m||C==="none"||C==="seeded"||C==="override"||g===""||U||Ft.current!==g&&(Ft.current=g,ue(m,y,e,g))},[m,y,e,g,C,U]);let ae=C!=="none"&&C!=="seeded"&&!U,ot=ae?g:"",Vt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);z(()=>{if(!m||!i||C==="override")return;let _=h.current;if(!_)return;let I=le(i),J=re(i),W=!1;return ie(_,Y(i),{fireGoal:()=>{W||(W=!0,ae&&(J!==void 0?m.componentGoal(e,I,{value:J}):m.componentGoal(e,I)),m.goal(I,p({metadata:{componentId:e,arm:ot},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(ne,Fe,at)=>{ae&&m.componentGoal(e,ne,{reward:Fe}),m.goal(ne,{metadata:{componentId:e,arm:ot},weight:Fe,stepIndex:at})}},I)},[m,e,Vt,g,C,U,ae,ot,b]);let st=Ye(()=>i?Y(i):null,[Vt]);z(()=>{C==="override"||!m||!st||oe(m,y,e,u,st)},[m,y,e,u,st,C]);let Mt=ve(s);Mt.current=s;let $t=ve(new Set),vr=s?JSON.stringify(s):"";z(()=>{if(!m||C==="override"||!ae||g==="")return;let _=h.current;if(_)return di((I,J={})=>{var Kt,Jt,Ht;m.track({projectId:y,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:I},J)});let W=(Kt=Mt.current)==null?void 0:Kt[I];if(!W||$t.current.has(I))return;$t.current.add(I);let ne=typeof W=="string"?W:W.name,Fe=typeof W=="string"?1:(Jt=W.weight)!=null?Jt:1,at=typeof W=="string"?0:(Ht=W.stepIndex)!=null?Ht:0;m.goal(ne,{metadata:p({componentId:e,arm:g,signalType:I},J),weight:Fe,stepIndex:at})},_,Date.now())},[m,y,e,g,C,ae,vr,b]);let jt=ve({agentData:w,agentDataByVariant:c});jt.current={agentData:w,agentDataByVariant:c};let Bt=ve(null);z(()=>{var ne;if(!m||C==="override"||!ae||g===""||Bt.current===g)return;let{agentData:_,agentDataByVariant:I}=jt.current,J=V!=null?V:g,W=I!==void 0?Object.prototype.hasOwnProperty.call(I,J)?I[J]:void 0:_;W!==void 0&&(Bt.current=g,(ne=m.reportAgentData)==null||ne.call(m,e,g,W))},[m,e,g,ae,V,C]);let Le=ve(null);z(()=>{let _=h.current;if(_){if(Le.current===null){Le.current=g;return}Le.current!==g&&(Le.current=g,fi(_))}},[g,b]);let Sr=Ye(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:gi(l,L(p({ref:h,className:o},Sr),{children:B}))}import{jsx as Re}from"react/jsx-runtime";function vi(e){var S,c;let{client:t,variantId:n,content:r,ref:i}=Ke(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=nr(!1);yi(()=>{l(!0)},[]);let a=(S=e.as)!=null?S:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return D()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Re(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var Si=mi(vi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function hi(e){if(e.variants===void 0)return Re(Pe,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Ce(n,["variants"]);return Re(Pe,L(p({},i),{children:t.children,variants:r}))}return Re(bi,p({},t))}function bi(e){var c;let[t,n]=nr(null),{id:r}=e,i=pi(()=>n(r),[r]),o=F(),l=je().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return Re(Si,L(p({},e),{onUnified:i}));let w=e,{variants:a,children:u}=w,s=Ce(w,["variants","children"]),S=Object.keys(a)[0];return Re(Pe,L(p({},s),{variants:a,variantsOnly:!0,children:S!==void 0?a[S]:null}))}import{useEffect as Ne,useMemo as wi,useRef as Nt,useState as rr,useSyncExternalStore as xi}from"react";import{jsx as Ri}from"react/jsx-runtime";function ki({id:e,default:t,component:n="span",className:r,goal:i}){var P;let o=F(),l=Q(),a=Be(),u=Ge(),s=Nt(null),S=Nt(null),c=xi(q,()=>ce(e),()=>null),[w,x]=rr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,u))==null?void 0:O.content)!=null?R:null}),[m,y]=rr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,u))==null?void 0:O.variantId)!=null?R:null});Ne(()=>{if(c||!o)return;let O=o.getAssignment(e,u);if((O==null?void 0:O.content)!==void 0){y(O.variantId),x(O.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,u,c]),Ne(()=>{c||!o||!m||!l||s.current!==m&&(s.current=m,o.track({projectId:l,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,l,e,a,c]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=wi(()=>i===void 0?null:Y(i),[h]),f=i===void 0?null:typeof i=="string"?i:v.type,b=Nt(!1);Ne(()=>{b.current=!1},[m,h]),Ne(()=>{c||!o||!l||oe(o,l,e,void 0,v)},[o,l,e,v,c]),Ne(()=>{if(c||!o||!m||!l||!v||!f)return;let O=S.current;if(!O)return;let R=re(v);return ie(O,v,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,l,e,v,f,c]);let k=w!=null?w:t;if(c){let O=o==null?void 0:o.getAssignment(e,u);k=O&&O.variantId===c&&(P=O.content)!=null?P:t}return Ri(n,{ref:O=>{S.current=O},className:r,children:k})}import{useCallback as Ai,useRef as Ci}from"react";function Te(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function Ie(e){let t=F(),n=Ci(new Set);return Ai((r,i)=>{if(!ce(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,Te(i))}},[t,e])}import{useEffect as _i,useRef as ir}from"react";function Oi(e,t={}){let u=t,{componentId:n}=u,r=Ce(u,["componentId"]),i=F(),o=Ie(n!=null?n:""),l=ir(!1),a=ir(r);a.current=r,_i(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,Te(a.current))}},[i,n,e,o])}import{useCallback as Gi,useEffect as Ei,useRef as Pi}from"react";var or=new Set,sr=new Map;function Ni(e,t,n,r){let i=r;if(r){let l=sr.get(t);l&&l!==n?(D()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):sr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;or.has(o)||(or.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function Ti(e,t={}){let{primary:n=!1,componentId:r}=t,i=F(),o=Q(),l=Ie(r!=null?r:""),a=Pi(!1);return Ei(()=>{!i||i.gated||!o||Ni(i,o,e,n)},[i,o,e,n]),Gi(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,Te(u))},[i,r,l,e])}import{renderPrePaintScript as Ii}from"@sentientui/core";import{confidenceBand as Di}from"@sentientui/policy";import{jsx as Vi}from"react/jsx-runtime";function Tt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Li(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Tt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Tt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Tt(Di(e.persona.confidence))+");}catch(e){}})();":Ii(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Fi(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Vi("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Li(e)}})}import{useEffect as tt,useMemo as Dt,useRef as Ki}from"react";import{validateSlotDecl as Ji}from"@sentientui/policy";import{useEffect as It,useReducer as Mi,useState as $i,useSyncExternalStore as ar}from"react";import{armOfResult as Qe,baselineResultFor as ji}from"@sentientui/core";import{confidenceBand as Bi}from"@sentientui/policy";function et(e,t){let n=F(),r=Ue(),[,i]=Mi(c=>c+1,0),o=ar(q,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;It(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(w=>{!c&&w&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:Qe(o),source:"override"};if(l!==void 0)return{result:l,arm:Qe(l),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:Qe(a),source:w?"client":"seeded"}}let c=ji(t);return{result:c,arm:Qe(c),source:"baseline"}})(),S=s.source==="preloaded"||s.source==="override";return It(()=>{var w;if(!n||n.isLocal===!0||S||!n.decideSlots)return;let c=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,S]),s}function Ui(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Wi(){let e=F(),t=En();ar(q,rn,()=>0);let[n,r]=$i(!1);It(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Bi(a.confidence)});if(!n)return t?i(t):null;let o=Ui();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var lr=new Set;function Hi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Xi(e,t,n){let r=F(),i=Q(),o=JSON.stringify(t),l=Dt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=et(e,l),S=Dt(()=>typeof a=="string"?{}:a,[u]);if(D()&&!lr.has(e)){lr.add(e);let y=Ji({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),h=Object.values(t).reduce((v,f)=>v*f.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);tt(()=>Se({id:e,dims:t}),[e]);let w=Ki(null);tt(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===u||(w.current=u,ue(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;tt(()=>{var y;!r||s==="override"||oe(r,i,e,x,Y((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,x,c,s]),tt(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${Hi(e)}"]`);if(!y){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=le(n.goal),v=re(n.goal),f=!1;return ie(y,Y(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,k,G)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:u},weight:k,stepIndex:G})}},h)},[r,e,c,u,s]);let m=Dt(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(S))y[`data-${h}`]=v;return y},[e,S]);return{tokens:S,props:m}}import{useCallback as zi,useEffect as ur,useMemo as qi}from"react";var cr=new Set,dr=new Set;function Yi(e,t){var m,y;if(D()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=Ke(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",S=t.variants[s],c=je().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;ur(()=>{!c||!D()||dr.has(e)||(dr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),ur(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!u.current&&!cr.has(e)&&(cr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=zi((h,v)=>{var b,k;if(o)return;let f=h!=null?h:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(b=v==null?void 0:v.metadata)!=null?b:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=qi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:S,bind:x,fireGoal:w}}import{Children as Zi,isValidElement as Qi,useEffect as nt,useMemo as fr,useRef as gr}from"react";import{jsx as to}from"react/jsx-runtime";var rt=new Set;function eo(e){var f;let t=F(),n=Q(),r=gr(null),i=Object.keys(e.arrangements).join(" "),o=fr(()=>Object.keys(e.arrangements),[i]),l=fr(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=et(e.id,l);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!rt.has(e.id+":baseline")&&(rt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Zi.toArray(e.children).filter(Qi),S=new Map;for(let b of s)S.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let c=e.arrangements[a],w=c!==void 0&&c.length===s.length&&c.every(b=>S.has(b));D()&&c!==void 0&&!w&&!rt.has(e.id+":keys")&&(rt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?c.map(b=>S.get(b)):s;nt(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=gr(null);nt(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||m.current===a||(m.current=a,ue(t,n,e.id,a))},[t,n,e.id,a,u]);let y=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);nt(()=>{var b;!t||u==="override"||oe(t,n,e.id,y,Y((b=e.goal)!=null?b:"click"))},[t,n,e.id,y,h,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return nt(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let b=r.current;if(!b)return;let k=le(e.goal),G=re(e.goal),P=!1;return ie(b,Y(e.goal),{fireGoal:()=>{P||(P=!0,G!==void 0?t.componentGoal(e.id,k,{value:G}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},G!==void 0?{value:G}:{})))},fireStep:(O,R,A)=>{t.componentGoal(e.id,O,{reward:R}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,v,a,u]),to("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as no}from"@sentientui/core";var ro=["page","blocks","layoutOrder"],mr=new Map;function io(e,t){mr.set(e,t)}function pr(e){return mr.get(e)}function oo(e){var i,o;let t=(o=(i=e.content)!=null?i:pr(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))ro.includes(l)||(n[l]=a);let r=L(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function so(e){return`<script type="application/ld+json">${yr(e)}</script>`}function yr(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function ao(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
var hr=Object.defineProperty,br=Object.defineProperties;var wr=Object.getOwnPropertyDescriptors;var Ve=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Xt=(e,t,n)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))zt.call(t,n)&&Xt(e,n,t[n]);if(Ve)for(var n of Ve(t))qt.call(t,n)&&Xt(e,n,t[n]);return e},L=(e,t)=>br(e,wr(t));var Ce=(e,t)=>{var n={};for(var r in e)zt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ve)for(var r of Ve(e))t.indexOf(r)<0&&qt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Nr,useContext as X,useEffect as ee,useMemo as An,useRef as se,useState as Oe,useSyncExternalStore as Tr}from"react";import{deriveSessionSegment as Ir,init as Dr}from"@sentientui/core";var Yt=new Map,Me=new Map;function Zt(e,t){let n=Me.get(e);return n||(n=new Set,Me.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Me.delete(e)}}function Qt(e,t){Yt.set(e,t);let n=Me.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function lt(e){var t;return(t=Yt.get(e))!=null?t:null}var xr={on:!1,listeners:new Set};function en(){if(typeof window=="undefined")return xr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ut(){return en().on}function tn(e){let t=en().listeners;return t.add(e),()=>{t.delete(e)}}function nn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ct="sentient:overrides-changed";function rn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function dt(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ct))}function q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ct,e),()=>window.removeEventListener(ct,e))}function on(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Y(e){return typeof e=="string"?{type:"click"}:e}function le(e){return typeof e=="string"?e:e.type}function re(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ft=new Set,gt=!1;function sn(e){if(ft.has(e))return!0;if(ft.add(e),!gt){gt=!0;let t=()=>{gt=!1,ft.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function kr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function an(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(kr(r))return!0;r=r.parentElement}return!1}function ie(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,S=[];return t.steps.forEach(({goal:c,name:w,weight:x},m)=>{let y=(h=!1)=>{s.has(m)||h&&r!==void 0&&sn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(c.type==="click"){let h=v=>{let f=v.target;f instanceof Element&&an(f,e,c.selector)&&y()};e.addEventListener("click",h),S.push(()=>e.removeEventListener("click",h));return}if(c.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),S.push(()=>e.removeEventListener("submit",h));return}if(c.type==="scroll_depth"){let h=Math.max(0,Math.min(1,c.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),S.push(()=>v.disconnect())}}),()=>{for(let c of S)c()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,S)=>S)),l=()=>{r!==void 0&&sn(r)||n.fireGoal()},a=(s,S=!1)=>{o.delete(s),o.size===0&&(S?l():n.fireGoal())},u=[];return i.forEach((s,S)=>{if(s.type==="click"){let c=w=>{let x=w.target;x instanceof Element&&an(x,e,s.selector)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("click",c),u.push(()=>e.removeEventListener("click",c));return}if(s.type==="form_submit"){let c=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(S):n.fireGoal())};e.addEventListener("submit",c),u.push(()=>e.removeEventListener("submit",c));return}if(s.type==="scroll_depth"){let c=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=c){t.type==="composite"?a(S,!0):l(),w.disconnect();break}},{threshold:[c]});w.observe(e),u.push(()=>w.disconnect());return}}),()=>{for(let s of u)s()}}var ln=new Set,un=new Set;function Rr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var Ar=12;function Cr(e,t){let n=new Set,r=[];for(let o of t.steps){let l=o.name;!l||l.length>128||l.startsWith("funnel:")||n.has(l)||r.length===Ar||(n.add(l),r.push({goalId:l,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,l)=>o.weight-l.weight);return(r.length<t.steps.length||i.some((o,l)=>o!==r[l]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function oe(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,l=r!=null?r:o?Rr(n):void 0;if(!l)return;let a=`${l}|${n}`;if(un.has(a))return;un.add(a);let u=o&&!ln.has(l)?Cr(n,o):null,s=u!==null&&u.length>=2;s&&ln.add(l),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:l,steps:u}:{funnelId:l}})}function ue(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var _r={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function fe(){if(typeof window=="undefined")return _r;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function _e(){fe().version+=1;for(let e of fe().listeners)e()}var cn=()=>{};function dn(e){return D()?(fe().components.set(e.id,e),_e(),()=>{fe().components.delete(e.id),_e()}):cn}function Se(e){return D()?(fe().slots.set(e.id,e),_e(),()=>{fe().slots.delete(e.id),_e()}):cn}function mt(e){D()&&(fe().sections=[...e],_e())}var fn="0.42.3",pt=fn!=="0.0.0-dev"?{name:"react",version:fn}:void 0;function Or(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){Or()[e]=t}function gn(e){window.__sentient_vocabulary_override=e}function mn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Gr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){Gr()[e]=t}function pn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var vt="__snt_editor_token",we=null,yt=!1;function yn(){return yt}function Er(){try{return sessionStorage.getItem(vt)}catch(e){return null}}function $e(e){if(we)return we;let t=typeof window=="undefined"?null:pn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Er();return yt=!!n,we=Promise.resolve(n?{token:n,fresh:!1}:null),we}return yt=!0,we=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(vt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),we}function vn(){try{sessionStorage.removeItem(vt)}catch(e){}}var Sn="sentient_preview_cell",hn="sentient_refresh_region",St="sentient-cell-preview-bar",ge="__preview__",xe=null;function bn(e){if((xe==null?void 0:xe.slotId)!==e)return null;let t=xe;return xe=null,t}function wn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>me(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>me("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function xn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(St))return;let t,n;try{let u=new URLSearchParams(window.location.search);t=u.get(Sn),n=u.get(hn)}catch(u){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=$e(r);if(!yn())return;if(n){xe={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,ge),dt();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let l=t.slice(0,o),a=t.slice(o+1);i.then(u=>u?"token"in u?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(l)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${u.token}`}}):(me(u.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async u=>{if(!u)return;if(!u.ok){me(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await u.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&gn(s.vocabulary),s.compose!=null)he(l,{kind:"arms",compose:{[ge]:s.compose}}),be(l,ge);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))he(l,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),be(l,ge);else if(s.blocks!=null)he(l,{kind:"arms",blocks:{[ge]:s.blocks}}),be(l,ge);else if(s.content!=null)he(l,{kind:"arms",content:s.content}),be(l,ge);else{me("Nothing to preview in that square yet.");return}dt(),me(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var S;try{(S=document.querySelector(`[data-sentient-slot="${l}"]`))==null||S.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>me("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function me(e){var i;if(document.getElementById(St))return;let t=document.createElement("div");t.id=St,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{vn();let o=new URL(window.location.href);o.searchParams.delete(Sn),o.searchParams.delete(hn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var kn=!1;function Rn(e){if(kn||typeof window=="undefined")return;kn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");$e(t).then(n=>{!n||!("token"in n)||!n.fresh||Pr(t,n.token)})}function Pr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Br}from"react/jsx-runtime";function Lr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Ir({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var _n="https://api.sentient-ui.com/v1",H=Nr({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:_n,debug:!1}),Cn=!1,ht=new Set;function Fr(e,t,n){let r=se(n);r.current=n;let[i,o]=Oe(null),[l,a]=Oe(!1),u=se(e);u.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(L(p({},e),{check:typeof e.check,refused:typeof e.refused}));return ee(()=>{let S=u.current;if(S===void 0||typeof window=="undefined")return;let c,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let y=x(typeof S=="object"&&S.cmp===void 0&&S.check?p(L(p({},S),{check:()=>u.current.check()}),S.refused?{refused:()=>{var f,b;return((b=(f=u.current).refused)==null?void 0:b.call(f))===!0}}:{}):S),h=!1,v=()=>{let f=y.refused()&&y.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=y.read();b!==null&&ht.add(t),o(b!=null?b:ht.has(t)?!1:null)};v(),c=y.subscribe(v)}),()=>{w=!0,c==null||c()}},[s,t]),{granted:i,refused:l}}function Vr(e){var P,O,R,A,d;let[t,n]=Oe(null),[r]=Oe(()=>{var g;return(g=e.sessionSegment)!=null?g:Lr()}),[i,o]=Oe(ut());ee(()=>tn(()=>o(ut())),[]),ee(()=>{xn(e.apiBaseUrl),Rn(e.apiBaseUrl)},[]);let l=se(()=>{}),a=Fr(e.consentFrom,e.apiKey,()=>l.current()),u=e.consentFrom?(P=a.granted)!=null?P:ht.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,S=se(s);S.current=s;let c=se(null),w=se(!1),x=se([]),m=se(!1);l.current=()=>{var T;x.current=[],m.current=!0;let g=c.current;g!=null&&g.gated?g.dispose():(T=g==null?void 0:g.takeHeld)==null||T.call(g)},ee(()=>{var B,U;if(S.current&&u===!1&&(x.current=[]),u===!1&&w.current&&(S.current&&((B=c.current)==null||B.destroy()),c.current=null,w.current=!1),u===!1&&!e.preConsentBehavior){S.current&&((U=c.current)==null||U.destroy()),c.current=null,n(null);return}let g=u!==!1;g&&(m.current=!1);let T=V=>{!g&&m.current&&V.gated&&V.dispose()},N=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:u,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},pt?{sdk:pt}:{}),C=!1,E=null,$=null,j=V=>{for(let te of x.current.splice(0))setTimeout(()=>{if(c.current!==V){m.current||x.current.push(te);return}try{te(V)}catch(Ae){}},0)},K=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:te})=>{C||($=te(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{C||(E=V(L(p({},N),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),T(E),c.current=E,w.current=g,j(E),n(E),K(E))}):(E=Dr(N),T(E),c.current=E,w.current=g,j(E),n(E),K(E)),()=>{var V,te;C=!0,$==null||$(),x.current=x.current.concat((te=(V=E==null?void 0:E.takeHeld)==null?void 0:V.call(E))!=null?te:[]),E==null||E.dispose()}},[u]),ee(()=>{if(!t)return;let g=!1,T=async()=>{if(g)return;let C;try{C=await t.fetchWeights()}catch(E){return}if(!g)for(let E of C){let $={componentId:E.componentId,updatedAt:E.updatedAt,variants:E.variants.map(j=>{var K;return{variantId:j.variantId,pulls:j.pulls,avgReward:(K=j.avgReward)!=null?K:0}})};Qt(E.componentId,$)}};T();let N=setInterval(()=>{T()},6e4);return()=>{g=!0,clearInterval(N)}},[t]);let y=(O=e.ssrFallback)!=null?O:"first",h=((R=e.apiBaseUrl)!=null?R:_n).replace(/\/$/,""),v=se(null);ee(()=>{var N;if(typeof process!="undefined"&&((N=process.env)==null?void 0:N.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},T=v.current;if(v.current=g,T!==null)for(let C of["apiKey","context","country","persona","apiBaseUrl"])Object.is(T[C],g[C])||console.warn(`[sentient] AdaptiveProvider: \`${C}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),ee(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||on({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;ee(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),ee(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){mt(g);return}e.declaredSections&&e.declaredSections.length>0&&mt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),ee(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||Cn||(Cn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),ee(()=>{if(!D())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let T=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),C=>C.getAttribute("data-sentient-id"))),N=g.filter(C=>!T.has(C));N.length>0&&console.warn(`[SentientUI] Declared section${N.length>1?"s":""} ${N.map(C=>`"${C}"`).join(", ")} ${N.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=An(()=>t&&i?nn(t):t,[t,i]),G=An(()=>{var g,T,N,C,E,$,j,K,B;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(T=e.initialUnified)!=null?T:Mr,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(N=e.initialLayoutOrder)!=null?N:null,initialSlots:(C=e.initialSlots)!=null?C:{},initialSlotConfig:(E=e.initialSlotConfig)!=null?E:{},initialPalette:($=e.initialPalette)!=null?$:null,initialVocabulary:(j=e.initialVocabulary)!=null?j:null,initialPersona:(K=e.initialPersona)!=null?K:null,apiBaseUrl:h,debug:(B=e.debug)!=null?B:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Br(H.Provider,{value:G,children:e.children})}function F(){return X(H).client}function Q(){return X(H).apiKey}function bt(){return X(H).initialAssignments}var Mr=[];function je(){return X(H).initialUnified}function Ge(){return X(H).sessionSegment}function On(){return X(H).ssrFallback}function Be(){return X(H).onAssignment}function Gn(){return X(H).debug}function $r(){let e=X(H).initialLayoutOrder,t=Tr(q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ue(){return X(H).initialSlots}function En(){return X(H).initialPersona}function Pn(){return X(H).initialSlotConfig}function Nn(){return X(H).initialPalette}function Tn(){return X(H).initialVocabulary}function jr(){return X(H).apiBaseUrl}import{memo as mi,useCallback as pi,useEffect as yi,useState as nr}from"react";import{useCallback as Kr,useEffect as pe,useMemo as Dn,useRef as Ee,useState as Jr}from"react";import{attachMicroSignalDetectors as Hr}from"@sentientui/core";import{useEffect as We,useRef as In,useState as Ur,useSyncExternalStore as Wr}from"react";import{pickFromWeights as wt}from"@sentientui/policy";function ce(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function xt(e,t,n,r,i){let o=bt(),l=On(),a=F(),u=Ge(),s=Be(),S=Gn(),c=In(null),w=Wr(q,()=>ce(e),()=>null),x=w&&t.includes(w)?w:null,m=In(null);We(()=>{S&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[S,x,e]);let[y,h]=Ur(()=>{var k,G;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let P=o[e];return P&&t.includes(P)?{variantId:P,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=lt(e);if(b){let P=wt(b.variants,t);if(P)return{variantId:P,content:null,isLoading:!1,settled:!0}}return{variantId:(G=t[0])!=null?G:null,content:null,isLoading:!1,settled:!1}}),v=f=>{s&&c.current!==f&&(c.current=f,s(e,f))};return We(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,u);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),v(f.variantId);return}let b=lt(e);if(b&&y.settled&&y.variantId&&y.variantId===wt(b.variants,t)){v(y.variantId);return}h(G=>{var P;return G.variantId?G:{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,u]),We(()=>{if(x||!a)return;let f=a.getAssignment(e,u);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(P=>{var O;if(!b&&P){if(P.unified===!0){k==null||k();return}!t.includes(P.variantId)&&!P.content||(h({variantId:P.variantId,content:(O=P.content)!=null?O:null,isLoading:!1,settled:!0}),v(P.variantId))}}),()=>{b=!0}},[x,a,e,u]),We(()=>{if(!x&&a)return Zt(e,f=>{var G;let b=a.getAssignment(e,u);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(G=b.content)!=null?G:null,isLoading:!1,settled:!0}),v(b.variantId);return}let k=wt(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),v(k))})},[x,a,e,u]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function Ke(e,t,n){let r=F(),i=Q(),o=Object.keys(t).join("\0"),l=Dn(()=>Object.keys(t),[o]),{variantId:a,content:u,isOverride:s=!1,settled:S}=xt(e,l,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[c,w]=Jr(null),x=Ee(null),m=Kr(d=>{x.current=d,w(d)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=Dn(()=>y?Y(y):null,[h]),f=y?le(y):"";pe(()=>dn({id:e,variantIds:l,goal:f}),[e,l,f]);let b=Ee(null);pe(()=>{s||S&&(!r||!a||!i||!c||b.current!==a&&(b.current=a,ue(r,i,e,a)))},[r,a,i,e,c,s,S]);let k=Ee(!1),G=Ee(new Set);pe(()=>{k.current=!1,G.current=new Set},[a,v]);let P=n.funnel;pe(()=>{s||!S||!r||!v||oe(r,i,e,P,v)},[r,i,e,P,v,s,S]);let O=n.cursorSignal===!0;pe(()=>{if(!O||s||!S||!r||!a||!c)return;let d=null,g=0,T=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},N=()=>{d!==null&&(clearTimeout(d),d=null)};return c.addEventListener("mouseenter",T),c.addEventListener("mouseleave",N),()=>{c.removeEventListener("mouseenter",T),c.removeEventListener("mouseleave",N),d!==null&&clearTimeout(d)}},[O,r,a,i,e,c,s,S]);let R=Ee(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return pe(()=>{if(s||!S||!r||!a||!c)return;let d=Date.now();return Hr((g,T={})=>{var j,K,B;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},T)});let N=(j=R.current)==null?void 0:j[g];if(!N||G.current.has(g))return;G.current.add(g);let C=typeof N=="string"?N:N.name,E=typeof N=="string"?1:(K=N.weight)!=null?K:1,$=typeof N=="string"?0:(B=N.stepIndex)!=null?B:0;r.goal(C,{metadata:p({signalType:g},T),weight:E,stepIndex:$})},c,d)},[r,a,i,e,c,A,s,S]),pe(()=>{if(s||!S||!r||!a||!c||!v)return;let d=re(v);return ie(c,v,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,T,N)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:T}}),r.goal(g,{metadata:{},weight:T,stepIndex:N})}},f)},[r,a,i,e,c,v,f,s,S]),{client:r,variantIds:l,variantId:a,content:u,settled:S,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}import{useEffect as z,useMemo as Ye,useRef as ve,useState as ui,useSyncExternalStore as ci}from"react";import{attachMicroSignalDetectors as di,containsFormBlock as Yn,reveal as fi}from"@sentientui/core";import{captureRegionSkeleton as Zn}from"@sentientui/core/region";import{useCallback as Xr,useEffect as Ln,useRef as kt,useSyncExternalStore as Je}from"react";import{armOfResult as zr}from"@sentientui/core";var Fn=new Set,qr={kind:"arms"};function Vn(e,t){var G,P,O;let n=F(),r=kt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=kt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=kt(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let l=Ue(),a=Pn(),u=Nn(),s=Tn(),S=Je(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),c=Je(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":zr(R),x=Xr(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);Je(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),Je(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=S===void 0?a[e]:void 0,y=S===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(G=u!=null?u:n==null?void 0:n.getSitePalette())!=null?G:null,v=(O=s!=null?s:(P=n==null?void 0:n.getStyleVocabulary)==null?void 0:P.call(n))!=null?O:null,f=(()=>{var R,A,d;if(S!==void 0)return{config:S,arm:w(c),palette:h,vocabulary:(R=mn())!=null?R:v,source:"override"};if(t!=null&&t.forcedArm)return{config:qr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(m!==void 0)return{config:m,arm:w((A=l[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:l[e]),palette:h,vocabulary:v,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return Ln(()=>{var E,$,j,K,B;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&($=(E=r.current)==null?void 0:E.call(r))!=null?$:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(j=i.current)==null?void 0:j.call(i),T=R&&(B=(K=o.current)==null?void 0:K.call(o))!=null?B:null,N=p(p({},g?{render:{[e]:g}}:{}),T?{skeletons:{[e]:T}}:{}),C=Object.keys(N).length>0;return n.requestSlots?C?n.requestSlots([e],d,N):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(T?n.reportSlots([e],d!=null?d:{},{[e]:T}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var U;return(U=n.cancelSlots)==null?void 0:U.call(n,[e])}},[n,k,f.source,e,b]),Ln(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Fn.has(e)||(Fn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}import{cloneElement as Yr,Fragment as Mn}from"react";import{jsx as M,jsxs as Un}from"react/jsx-runtime";function Rt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var de={none:"0",sm:"8px",md:"16px",lg:"24px"},At={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Wn={sm:"0.875em",md:"1em",lg:"1.25em"},Zr={sm:"1.25em",md:"1.5em",lg:"2em"},$n={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},jn={sm:"8px",md:"16px",lg:"32px"},Qr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ei={normal:"400",medium:"500",bold:"700"};function Bn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Kn(e,t,n){var i,o,l,a;let r=t==null?void 0:t.accent;return L(p({display:"inline-block",padding:(i=$n[n!=null?n:"md"])!=null?i:$n.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Wn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(l=t==null?void 0:t.primaryBg)!=null?l:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ti({node:e,opts:t}){var i,o,l,a,u;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(l=(o=t.palette)==null?void 0:o.border)!=null?l:"currentColor"}`,borderRadius:(u=(a=t.palette)==null?void 0:a.radius)!=null?u:"8px"};return Un("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let S=new FormData(s.currentTarget),c={};for(let y of e.fields)c[y.name]=String((w=S.get(y.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,c)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var S,c;return Un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?M("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?M("select",{name:s.name,required:s.required,style:r,children:((S=s.options)!=null?S:[]).map(w=>M("option",{value:w,children:w},w))}):M("input",{name:s.name,type:(c=s.inputType)!=null?c:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),M("button",{type:"submit",style:Kn(n,t.palette),children:e.submitLabel})]})}function ni(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Jn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ke(e,t){var i;let n=ri(e,t),r=Jn(e.like,t);return n&&r?Yr(n,{style:L(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ri(e,t){var n,r,i,o,l,a,u,s,S,c,w,x,m,y,h,v,f,b,k,G,P,O,R;try{let A=ni(e,t);switch(e.type){case"stack":{let d=(r=de[(n=e.gap)!=null?n:"md"])!=null?r:de.md,g=e.surface==="raised"&&!A,T=(i=e.pad)!=null?i:g?"md":void 0;return M("div",L(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:At[e.align]}:{}),e.justify?{justifyContent:At[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),T?{padding:(o=de[T])!=null?o:de.md}:{}),g?L(p(p({},(l=t.palette)!=null&&l.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((u=t.palette)!=null&&u.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(S=(s=t.palette)==null?void 0:s.border)!=null?S:"currentColor"}`,borderRadius:(w=(c=t.palette)==null?void 0:c.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((N,C)=>{let E=ke(N,t);return E===null?null:M(Mn,{children:E},C)})}))}case"grid":{let d=(y=de[(m=e.gap)!=null?m:"md"])!=null?y:de.md;return M("div",L(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:At[e.align]}:{}),e.pad?{padding:(h=de[e.pad])!=null?h:de.md}:{}),children:((v=e.children)!=null?v:[]).map((g,T)=>{let N=ke(g,t);return N===null?null:M(Mn,{children:N},T)})}))}case"text":return A?M("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:Wn[e.size]}:{}),e.weight?{fontWeight:ei[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?M(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M(d,{style:p(p({margin:0,fontSize:Zr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return M("a",L(p(p({href:Rt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Kn(d,t.palette,e.size)}),{children:e.label}))}case"link":return M("a",L(p(p({href:Rt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return M("img",L(p({src:Rt(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Qr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?M("span",{className:A,children:e.value}):M("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(G=(k=t.palette)==null?void 0:k.border)!=null?G:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return M("div",{style:{height:(P=jn[e.size])!=null?P:jn.md}});case"divider":return M("hr",{style:{border:"none",borderTop:`1px solid ${(R=(O=t.palette)==null?void 0:O.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return M(ti,{node:e,opts:t});default:return null}}catch(A){return null}}function Ct(e,t){var o,l,a,u;let n=ke(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(l=t.vocabulary)==null?void 0:l.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Jn((u=e.surface)==null?void 0:u.like,t);return r?M("div",L(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as He,isValidElement as Xe}from"react";import{normalizeLeafText as ii,skeletonFingerprint as oi}from"@sentientui/core/region";function ze(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function qe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ye(e){return ze(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ye(n),0):Xe(e)?ye(qe(e)):0}function si(e,t){return Array.isArray(t)?He(e,void 0,...t):He(e,void 0,t)}function _t(e,t){if(ze(e))return t;if(Array.isArray(e))return e.map(n=>_t(n,t));if(Xe(e)){let n=qe(e);return ye(n)===0?e:si(e,_t(n,t))}return e}function Hn(e,t){return ye(e)===1?_t(e,t):null}var Z=e=>e.join("/");function Ot(e,t,n){if(ze(e)){n.leafPaths.push(t),n.texts.push(ii(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Ot(r,[...t,i],n));return}Xe(e)&&(n.elements.set(Z(t),e),Ot(qe(e),[...t,"c"],n))}function Et(e){let t={leafPaths:[],texts:[],elements:new Map};return Ot(e,[],t),t}function ai(e){return Et(e).texts}function Xn(e){let t=ai(e);return t.length===0?null:oi(t)}function li(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function zn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,u)=>a===i?[li(e.leafPaths[u])]:[]);if(o.length===0){r.push(null);continue}let l=o[0];for(let a of o.slice(1)){let u=new Set(a.map(Z));l=l.filter(s=>u.has(Z(s)))}r.push(l.length>0?l[l.length-1]:null)}return r}function Gt(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Pt(e,t){let n=Et(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,l)=>o!==e.leaves[l]))return null;let r=zn(n,e.leafToNode),i=e.nodes.map((o,l)=>{let a=r[l],u=a?n.elements.get(Z(a)):void 0,s=!!u&&(typeof u.type=="string"||Gt(u)!==void 0);return L(p({},o),{restylable:s})});return L(p({},e),{nodes:i})}function qn(e,t,n){var m;let r=Et(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let o=zn(r,n),l=new Map;n.forEach((y,h)=>{l.has(y)||l.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[Z(y),h])),u=new Set,s=new Map,S=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),f=o[v];if(h.hidden&&(f?u.add(Z(f)):S=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(Z(f)):void 0,G=b?Gt(r.elements.get(Z(b))):void 0;!f||G===void 0||Gt(k)===void 0?S=!0:s.set(Z(f),G)}}let c=new Map(Object.entries((m=t.order)!=null?m:{})),w=(y,h)=>{var v;if(ze(y)){let f=a.get(Z(h));if(f===void 0)return y;let b=n[f],k=(v=t.nodes[String(b)])==null?void 0:v.text;return k===void 0?y:l.get(b)===f?k:""}if(Array.isArray(y)){let f=y.map((b,k)=>w(b,[...h,k]));for(let[b,k]of c){let G=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||Z(A.slice(0,-1))!==Z(h)?-1:A[A.length-1]});if(G.some(R=>R<0))continue;let P=[...G].sort((R,A)=>R-A),O=[...f];P.forEach((R,A)=>{f[R]=O[G[A]]}),c.delete(b)}return f}if(Xe(y)){let f=Z(h);if(u.has(f))return null;let b=qe(y);if(ye(b)===0)return y;let k=w(b,[...h,"c"]),G=s.get(f),P=G!==void 0?{className:G}:void 0;return Array.isArray(k)?He(y,P,...k):He(y,P,k)}return y},x=w(e,[]);return S||c.size>0?null:x}import{jsx as gi}from"react/jsx-runtime";var Qn=new Set,er=new Set,tr=new Set,Ze="authored.";function Pe({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:l="div",reportBaselineText:a=!0,funnel:u,microSignalGoals:s,clientOnly:S,agentDataByVariant:c,agentData:w,variantsOnly:x=!1}){var Ut,Wt;let m=F(),y=Q(),h=ve(null),[v,f]=ui(!1);z(()=>{f(!0)},[]);let b=S===!0&&(!v||!m),k=Ye(()=>Xn(t),[t]),G=n?Object.keys(n).join("|"):"",P=Ye(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ye(t)===1,ops:!1},G!==""?{authored:G.split("|"),children:!x}:{}),[k,t,r,G,x]),O=()=>{var J;let _=h.current;if(!_||!a)return null;let I=Zn(_);return I.skeleton?(J=Pt(I.skeleton,t))!=null?J:L(p({},I.skeleton),{editable:!1,nodes:I.skeleton.nodes.map(W=>L(p({},W),{restylable:!1}))}):{status:I.reason}},R=ci(q,()=>n?ce(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${Ze}${R}`:x?`${Ze}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:T,vocabulary:N,source:C}=Vn(e,{forcedArm:A,baselineText:a?()=>{var _,I;return(I=(_=h.current)==null?void 0:_.textContent)!=null?I:null}:void 0,render:()=>P,skeleton:O,defer:b}),E=g!==""?(Ut=d==null?void 0:d.blocks)==null?void 0:Ut[g]:void 0,$=g!==""?(Wt=d==null?void 0:d.compose)==null?void 0:Wt[g]:void 0,j=(E!==void 0&&Yn(E)||$!==void 0&&Yn($.tree))&&!r;z(()=>{!j||!D()||Qn.has(e)||(Qn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[j,e]);let K=_=>{!m||C==="override"||(C!=="seeded"&&m.componentGoal(e,_),m.goal(_,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},B=t,U=!1,V=g.startsWith(Ze)?g.slice(Ze.length):null;if((d==null?void 0:d.blocked)==="variant_history")U=!0;else if(V!==null)n&&Object.prototype.hasOwnProperty.call(n,V)?B=n[V]:U=!0;else if($!==void 0){let _=j?null:Ct($,{palette:T,vocabulary:N,onFormSubmit:r,onFormGoal:K});_===null?U=!0:B=_}else if(E!==void 0){let _=j?null:ke(E,{palette:T,vocabulary:N,onFormSubmit:r,onFormGoal:K});_===null?U=!0:B=_}else if((d==null?void 0:d.edits)!==void 0&&C!=="none"){let _=d.edits,I=_.fp===k?qn(t,_.edits,_.leafToNode):null;I===null?U=!0:B=I}else if((d==null?void 0:d.content)!==void 0&&C!=="none"){let _=Hn(t,d.content);_===null?U=!0:B=_}let te=U&&E===void 0&&$===void 0&&(d==null?void 0:d.edits)===void 0&&V===null&&(d==null?void 0:d.blocked)===void 0;z(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||tr.has(e)||(tr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Ae=V!==null&&!U?V:null;z(()=>{var ne;if(!Ae||!a||!m)return;let _=h.current;if(!_)return;let I=Zn(_),J=I.skeleton?Pt(I.skeleton,n==null?void 0:n[Ae]):null,W=(ne=_.textContent)==null?void 0:ne.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Ae},W?{text:W}:{}),J?{skeleton:J}:{})]})},[Ae,m,e,b]);let Lt=U&&(d==null?void 0:d.edits)!==void 0&&(C==="preloaded"||C==="client");z(()=>{var _;!Lt||!(d!=null&&d.edits)||(_=m==null?void 0:m.reportDrift)==null||_.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Lt,e,k,m]);let De=B===t;z(()=>{var I;if(!(d!=null&&d.needsSkeleton)||!De)return;let _=O();_&&((I=m==null?void 0:m.reportSkeleton)==null||I.call(m,e,_))},[d==null?void 0:d.needsSkeleton,De,e,m,b]),z(()=>{if(!De)return;let _=bn(e);if(!_)return;let I=O();wn(_,I&&"status"in I?{status:I.status}:{skeleton:I})},[e,De,b]),z(()=>{!te||!D()||er.has(e)||(er.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[te,e]);let it=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";z(()=>Se({id:e,arms:it===""?void 0:it.split("|")}),[e,it]);let Ft=ve(null);z(()=>{!m||C==="none"||C==="seeded"||C==="override"||g===""||U||Ft.current!==g&&(Ft.current=g,ue(m,y,e,g))},[m,y,e,g,C,U]);let ae=C!=="none"&&C!=="seeded"&&!U,ot=ae?g:"",Vt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);z(()=>{if(!m||!i||C==="override")return;let _=h.current;if(!_)return;let I=le(i),J=re(i),W=!1;return ie(_,Y(i),{fireGoal:()=>{W||(W=!0,ae&&(J!==void 0?m.componentGoal(e,I,{value:J}):m.componentGoal(e,I)),m.goal(I,p({metadata:{componentId:e,arm:ot},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(ne,Fe,at)=>{ae&&m.componentGoal(e,ne,{reward:Fe}),m.goal(ne,{metadata:{componentId:e,arm:ot},weight:Fe,stepIndex:at})}},I)},[m,e,Vt,g,C,U,ae,ot,b]);let st=Ye(()=>i?Y(i):null,[Vt]);z(()=>{C==="override"||!m||!st||oe(m,y,e,u,st)},[m,y,e,u,st,C]);let Mt=ve(s);Mt.current=s;let $t=ve(new Set),vr=s?JSON.stringify(s):"";z(()=>{if(!m||C==="override"||!ae||g==="")return;let _=h.current;if(_)return di((I,J={})=>{var Kt,Jt,Ht;m.track({projectId:y,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:I},J)});let W=(Kt=Mt.current)==null?void 0:Kt[I];if(!W||$t.current.has(I))return;$t.current.add(I);let ne=typeof W=="string"?W:W.name,Fe=typeof W=="string"?1:(Jt=W.weight)!=null?Jt:1,at=typeof W=="string"?0:(Ht=W.stepIndex)!=null?Ht:0;m.goal(ne,{metadata:p({componentId:e,arm:g,signalType:I},J),weight:Fe,stepIndex:at})},_,Date.now())},[m,y,e,g,C,ae,vr,b]);let jt=ve({agentData:w,agentDataByVariant:c});jt.current={agentData:w,agentDataByVariant:c};let Bt=ve(null);z(()=>{var ne;if(!m||C==="override"||!ae||g===""||Bt.current===g)return;let{agentData:_,agentDataByVariant:I}=jt.current,J=V!=null?V:g,W=I!==void 0?Object.prototype.hasOwnProperty.call(I,J)?I[J]:void 0:_;W!==void 0&&(Bt.current=g,(ne=m.reportAgentData)==null||ne.call(m,e,g,W))},[m,e,g,ae,V,C]);let Le=ve(null);z(()=>{let _=h.current;if(_){if(Le.current===null){Le.current=g;return}Le.current!==g&&(Le.current=g,fi(_))}},[g,b]);let Sr=Ye(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:gi(l,L(p({ref:h,className:o},Sr),{children:B}))}import{jsx as Re}from"react/jsx-runtime";function vi(e){var S,c;let{client:t,variantId:n,content:r,ref:i}=Ke(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,l]=nr(!1);yi(()=>{l(!0)},[]);let a=(S=e.as)!=null?S:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let u=(c=e.variants[n])!=null?c:null,s=u===null?r:null;return D()&&u===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Re(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:u!=null?u:s})}var Si=mi(vi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function hi(e){if(e.variants===void 0)return Re(Pe,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Ce(n,["variants"]);return Re(Pe,L(p({},i),{children:t.children,variants:r}))}return Re(bi,p({},t))}function bi(e){var c;let[t,n]=nr(null),{id:r}=e,i=pi(()=>n(r),[r]),o=F(),l=je().includes(r)||((c=o==null?void 0:o.isUnified)==null?void 0:c.call(o,r))===!0;if(t!==r&&!l)return Re(Si,L(p({},e),{onUnified:i}));let w=e,{variants:a,children:u}=w,s=Ce(w,["variants","children"]),S=Object.keys(a)[0];return Re(Pe,L(p({},s),{variants:a,variantsOnly:!0,children:S!==void 0?a[S]:null}))}import{useEffect as Ne,useMemo as wi,useRef as Nt,useState as rr,useSyncExternalStore as xi}from"react";import{jsx as Ri}from"react/jsx-runtime";function ki({id:e,default:t,component:n="span",className:r,goal:i}){var P;let o=F(),l=Q(),a=Be(),u=Ge(),s=Nt(null),S=Nt(null),c=xi(q,()=>ce(e),()=>null),[w,x]=rr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,u))==null?void 0:O.content)!=null?R:null}),[m,y]=rr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,u))==null?void 0:O.variantId)!=null?R:null});Ne(()=>{if(c||!o)return;let O=o.getAssignment(e,u);if((O==null?void 0:O.content)!==void 0){y(O.variantId),x(O.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,u,c]),Ne(()=>{c||!o||!m||!l||s.current!==m&&(s.current=m,o.track({projectId:l,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,l,e,a,c]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=wi(()=>i===void 0?null:Y(i),[h]),f=i===void 0?null:typeof i=="string"?i:v.type,b=Nt(!1);Ne(()=>{b.current=!1},[m,h]),Ne(()=>{c||!o||!l||oe(o,l,e,void 0,v)},[o,l,e,v,c]),Ne(()=>{if(c||!o||!m||!l||!v||!f)return;let O=S.current;if(!O)return;let R=re(v);return ie(O,v,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:l,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,l,e,v,f,c]);let k=w!=null?w:t;if(c){let O=o==null?void 0:o.getAssignment(e,u);k=O&&O.variantId===c&&(P=O.content)!=null?P:t}return Ri(n,{ref:O=>{S.current=O},className:r,children:k})}import{useCallback as Ai,useRef as Ci}from"react";function Te(e){var t,n;return p(p(p({metadata:(t=e==null?void 0:e.metadata)!=null?t:{},weight:(n=e==null?void 0:e.reward)!=null?n:1,stepIndex:0},(e==null?void 0:e.value)!==void 0?{value:e.value}:{}),(e==null?void 0:e.currency)!==void 0?{currency:e.currency}:{}),(e==null?void 0:e.externalId)!==void 0?{externalId:e.externalId}:{})}function Ie(e){let t=F(),n=Ci(new Set);return Ai((r,i)=>{if(!ce(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,Te(i))}},[t,e])}import{useEffect as _i,useRef as ir}from"react";function Oi(e,t={}){let u=t,{componentId:n}=u,r=Ce(u,["componentId"]),i=F(),o=Ie(n!=null?n:""),l=ir(!1),a=ir(r);a.current=r,_i(()=>{if(!(!i||l.current||i.gated)){if(l.current=!0,n){o(e,a.current);return}i.goal(e,Te(a.current))}},[i,n,e,o])}import{useCallback as Gi,useEffect as Ei,useRef as Pi}from"react";var or=new Set,sr=new Map;function Ni(e,t,n,r){let i=r;if(r){let l=sr.get(t);l&&l!==n?(D()&&console.warn(`[SentientUI] useGoal('${n}'): '${l}' is already primary on this page`),i=!1):sr.set(t,n)}let o=`${t}|${n}|${i?"primary":""}`;or.has(o)||(or.add(o),e.track({projectId:t,componentId:"__session__",eventType:"goal_declared",payload:i?{goalId:n,primary:!0}:{goalId:n}}))}function Ti(e,t={}){let{primary:n=!1,componentId:r}=t,i=F(),o=Q(),l=Ie(r!=null?r:""),a=Pi(!1);return Ei(()=>{!i||i.gated||!o||Ni(i,o,e,n)},[i,o,e,n]),Gi(u=>{if(u!=null&&u.once){if(a.current)return;a.current=!0}if(r){l(e,u);return}i==null||i.goal(e,Te(u))},[i,r,l,e])}import{renderPrePaintScript as Ii}from"@sentientui/core";import{confidenceBand as Di}from"@sentientui/policy";import{jsx as Vi}from"react/jsx-runtime";function Tt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Li(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Tt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Tt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Tt(Di(e.persona.confidence))+");}catch(e){}})();":Ii(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Fi(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Vi("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Li(e)}})}import{useEffect as tt,useMemo as Dt,useRef as Ki}from"react";import{validateSlotDecl as Ji}from"@sentientui/policy";import{useEffect as It,useReducer as Mi,useState as $i,useSyncExternalStore as ar}from"react";import{armOfResult as Qe,baselineResultFor as ji}from"@sentientui/core";import{confidenceBand as Bi}from"@sentientui/policy";function et(e,t){let n=F(),r=Ue(),[,i]=Mi(c=>c+1,0),o=ar(q,()=>{var c;return typeof window!="undefined"?(c=window.__sentient_slot_overrides)==null?void 0:c[e]:void 0},()=>{}),l=o===void 0?r[e]:void 0,a=o===void 0&&l===void 0&&n?n.getSlotResult(e):null,u=(n==null?void 0:n.isLocal)===!0&&o===void 0&&l===void 0&&a===null;It(()=>{if(!u||!n)return;let c=!1;return n.decide({slots:[t]}).then(w=>{!c&&w&&i()}),()=>{c=!0}},[n,e,u]);let s=(()=>{if(o!==void 0)return{result:o,arm:Qe(o),source:"override"};if(l!==void 0)return{result:l,arm:Qe(l),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:Qe(a),source:w?"client":"seeded"}}let c=ji(t);return{result:c,arm:Qe(c),source:"baseline"}})(),S=s.source==="preloaded"||s.source==="override";return It(()=>{var w;if(!n||n.isLocal===!0||S||!n.decideSlots)return;let c=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),c==null||c()}},[n,e,S]),s}function Ui(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Wi(){let e=F(),t=En();ar(q,rn,()=>0);let[n,r]=$i(!1);It(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Bi(a.confidence)});if(!n)return t?i(t):null;let o=Ui();if(o)return i(o);if(t)return i(t);let l=e?e.getPersona():null;return l?i(l):null}var lr=new Set;function Hi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Xi(e,t,n){let r=F(),i=Q(),o=JSON.stringify(t),l=Dt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:u,source:s}=et(e,l),S=Dt(()=>typeof a=="string"?{}:a,[u]);if(D()&&!lr.has(e)){lr.add(e);let y=Ji({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),h=Object.values(t).reduce((v,f)=>v*f.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);tt(()=>Se({id:e,dims:t}),[e]);let w=Ki(null);tt(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===u||(w.current=u,ue(r,i,e,u))},[r,i,e,u,s]);let x=n==null?void 0:n.funnel;tt(()=>{var y;!r||s==="override"||oe(r,i,e,x,Y((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,x,c,s]),tt(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${Hi(e)}"]`);if(!y){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=le(n.goal),v=re(n.goal),f=!1;return ie(y,Y(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,k,G)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:u},weight:k,stepIndex:G})}},h)},[r,e,c,u,s]);let m=Dt(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(S))y[`data-${h}`]=v;return y},[e,S]);return{tokens:S,props:m}}import{useCallback as zi,useEffect as ur,useMemo as qi}from"react";var cr=new Set,dr=new Set;function Yi(e,t){var m,y;if(D()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:l,ref:a,nodeRef:u}=Ke(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",S=t.variants[s],c=je().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;ur(()=>{!c||!D()||dr.has(e)||(dr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[c,e]),ur(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!u.current&&!cr.has(e)&&(cr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=zi((h,v)=>{var b,k;if(o)return;let f=h!=null?h:l;f&&(n==null||n.componentGoal(e,f,v),n==null||n.goal(f,p(p(p({metadata:(b=v==null?void 0:v.metadata)!=null?b:{},weight:(k=v==null?void 0:v.reward)!=null?k:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,l,o]),x=qi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:S,bind:x,fireGoal:w}}import{Children as Zi,isValidElement as Qi,useEffect as nt,useMemo as fr,useRef as gr}from"react";import{jsx as to}from"react/jsx-runtime";var rt=new Set;function eo(e){var f;let t=F(),n=Q(),r=gr(null),i=Object.keys(e.arrangements).join(" "),o=fr(()=>Object.keys(e.arrangements),[i]),l=fr(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:u}=et(e.id,l);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!rt.has(e.id+":baseline")&&(rt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Zi.toArray(e.children).filter(Qi),S=new Map;for(let b of s)S.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let c=e.arrangements[a],w=c!==void 0&&c.length===s.length&&c.every(b=>S.has(b));D()&&c!==void 0&&!w&&!rt.has(e.id+":keys")&&(rt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?c.map(b=>S.get(b)):s;nt(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=gr(null);nt(()=>{!t||u==="baseline"||u==="seeded"||u==="override"||m.current===a||(m.current=a,ue(t,n,e.id,a))},[t,n,e.id,a,u]);let y=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);nt(()=>{var b;!t||u==="override"||oe(t,n,e.id,y,Y((b=e.goal)!=null?b:"click"))},[t,n,e.id,y,h,u]);let v=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return nt(()=>{if(!t||e.goal===void 0||u==="override"||u==="baseline"||u==="seeded")return;let b=r.current;if(!b)return;let k=le(e.goal),G=re(e.goal),P=!1;return ie(b,Y(e.goal),{fireGoal:()=>{P||(P=!0,G!==void 0?t.componentGoal(e.id,k,{value:G}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},G!==void 0?{value:G}:{})))},fireStep:(O,R,A)=>{t.componentGoal(e.id,O,{reward:R}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,v,a,u]),to("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as no}from"@sentientui/core";var ro=["page","blocks","layoutOrder"],mr=new Map;function io(e,t){mr.set(e,t)}function pr(e){return mr.get(e)}function oo(e){var i,o;let t=(o=(i=e.content)!=null?i:pr(e.page))!=null?o:{},n={};for(let[l,a]of Object.entries(t))ro.includes(l)||(n[l]=a);let r=L(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function so(e){return`<script type="application/ld+json">${yr(e)}</script>`}function yr(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function ao(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
4
|
`}import{grantConsent as vl}from"@sentientui/core";import{consentWatcher as bl}from"@sentientui/core/consent";export{hi as Adaptive,eo as AdaptiveGroup,Vr as AdaptiveProvider,Pe as AdaptiveSlot,ki as AdaptiveText,Fi as SentientPersonaScript,oo as buildAgentFeed,bl as consentWatcher,io as defineAgentContent,no as detectSegment,pr as getAgentContent,vl as grantConsent,so as renderAgentJsonLd,yr as renderAgentJsonLdBody,ao as renderAgentMarkdown,ke as renderBlocks,Ct as renderCompose,Yi as useAdaptive,jr as useAdaptiveApiBaseUrl,Ie as useAdaptiveGoal,Wi as useAdaptivePersona,Xi as useAdaptiveTokens,xt as useAssignment,Ti as useGoal,bt as useInitialAssignments,$r as useLayoutOrder,Oi as usePageGoal,F as useSentient,Ge as useSessionSegment};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/testing/react.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Ve=Object.create;var G=Object.defineProperty,De=Object.defineProperties,Ne=Object.getOwnPropertyDescriptor,Le=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,se=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ae=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&ae(e,n,t[n]);if(se)for(var n of se(t))We.call(t,n)&&ae(e,n,t[n]);return e},$=(e,t)=>De(e,Le(t));var Ue=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ge(t))!le.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Ne(t,a))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?Ve(Fe(e)):{},ce(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),$e=e=>ce(G({},"__esModule",{value:!0}),e);var ot={};Ue(ot,{renderWithSentient:()=>rt});module.exports=$e(ot);var Oe=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Me=new Map,Ke=new Map;function de(e,t){Me.set(e,t);let n=Ke.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Be={on:!1,listeners:new Set};function ue(){if(typeof window=="undefined")return Be;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function H(){return ue().on}function fe(e){let t=ue().listeners;return t.add(e),()=>{t.delete(e)}}function ge(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(He))}function pe(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var je={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return je;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function ze(){j().version+=1;for(let e of j().listeners)e()}function z(e){W()&&(j().sections=[...e],ze())}var me="0.42.1",J=me!=="0.0.0-dev"?{name:"react",version:me}:void 0;function Je(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Je()[e]=t}function ye(e){window.__sentient_vocabulary_override=e}function Xe(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){Xe()[e]=t}function ve(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,X=!1;function he(){return X}function qe(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:ve("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:qe();return X=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return X=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function _e(){try{sessionStorage.removeItem(q)}catch(e){}}var Se="sentient_preview_cell",we="sentient_refresh_region",Y="sentient-cell-preview-bar",P="__preview__",Ye=null;function be(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(Se),n=l.get(we)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!he())return;if(n){Ye={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,P),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(l.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async l=>{if(!l)return;if(!l.ok){U(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ye(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[P]:c.compose}}),V(g,P);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,P);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[P]:c.blocks}}),V(g,P);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,P);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{_e();let d=new URL(window.location.href);d.searchParams.delete(Se),d.searchParams.delete(we),window.location.assign(d.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var Ce=!1;function xe(e){if(Ce||typeof window=="undefined")return;Ce=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Qe(t,n.token)})}function Qe(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Ae=require("react/jsx-runtime");function Ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",et=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Re,debug:!1}),ke=!1,Q=new Set;function tt(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify($(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,R=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(R)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v($(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var _,S;return((S=(_=l.current).refused)==null?void 0:S.call(_))===!0}}:{}):p),w=!1,N=()=>{let _=E.refused()&&E.read()!==!0;_&&!w&&(I(t),i.current()),w=_,O(_);let S=E.read();S!==null&&Q.add(t),d(S!=null?S:Q.has(t)?!1:null)};N(),y=E.subscribe(N)}),()=>{R=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function Ee(e){var ee,te,ne,ie,re;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:Ze()}),[a,d]=(0,o.useState)(H());(0,o.useEffect)(()=>fe(()=>d(H())),[]),(0,o.useEffect)(()=>{be(e.apiBaseUrl),xe(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=tt(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(ee=O.granted)!=null?ee:Q.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),R=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var L,oe;if(p.current&&l===!1&&(x.current=[]),l===!1&&R.current&&(p.current&&((L=y.current)==null||L.destroy()),y.current=null,R.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((oe=y.current)==null||oe.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=h=>{!r&&I.current&&h.gated&&h.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!1,s=null,b=null,C=h=>{for(let A of x.current.splice(0))setTimeout(()=>{if(y.current!==h){I.current||x.current.push(A);return}try{A(h)}catch(st){}},0)},k=h=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{u||(b=A(h,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:h})=>{u||(s=h($(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,R.current=r,C(s),n(s),k(s))}):(s=(0,B.init)(m),f(s),y.current=s,R.current=r,C(s),n(s),k(s)),()=>{var h,A;u=!0,b==null||b(),x.current=x.current.concat((A=(h=s==null?void 0:s.takeHeld)==null?void 0:h.call(s))!=null?A:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};de(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(te=e.ssrFallback)!=null?te:"first",w=((ne=e.apiBaseUrl)!=null?ne:Re).replace(/\/$/,""),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},f=N.current;if(N.current=r,f!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||pe({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ie=e.identity)==null?void 0:ie.userId,S=(re=e.identity)==null?void 0:re.userHash;(0,o.useEffect)(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||ke||(ke=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,o.useEffect)(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Z=(0,o.useMemo)(()=>t&&a?ge(t):t,[t,a]),Te=(0,o.useMemo)(()=>{var r,f,m,u,s,b,C,k,L;return{client:Z,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:nt,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:w,debug:(L=e.debug)!=null?L:!1}},[Z,e.apiKey,e.initialAssignments,e.initialUnified,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return(0,Ae.jsx)(et.Provider,{value:Te,children:e.children})}var nt=[];function it(e){return e<.3?"low":e<.7?"medium":"high"}function Pe(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",it((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;F()}var Ie=require("react/jsx-runtime");function rt(e,t={},n){return Pe(t),(0,Oe.render)((0,Ie.jsx)(Ee,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
|
|
2
|
+
"use strict";var Ve=Object.create;var G=Object.defineProperty,De=Object.defineProperties,Ne=Object.getOwnPropertyDescriptor,Le=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,se=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ae=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&ae(e,n,t[n]);if(se)for(var n of se(t))We.call(t,n)&&ae(e,n,t[n]);return e},$=(e,t)=>De(e,Le(t));var Ue=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ge(t))!le.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Ne(t,a))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?Ve(Fe(e)):{},ce(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),$e=e=>ce(G({},"__esModule",{value:!0}),e);var ot={};Ue(ot,{renderWithSentient:()=>rt});module.exports=$e(ot);var Oe=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Me=new Map,Ke=new Map;function de(e,t){Me.set(e,t);let n=Ke.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Be={on:!1,listeners:new Set};function ue(){if(typeof window=="undefined")return Be;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function H(){return ue().on}function fe(e){let t=ue().listeners;return t.add(e),()=>{t.delete(e)}}function ge(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(He))}function pe(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var je={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return je;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function ze(){j().version+=1;for(let e of j().listeners)e()}function z(e){W()&&(j().sections=[...e],ze())}var me="0.42.3",J=me!=="0.0.0-dev"?{name:"react",version:me}:void 0;function Je(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Je()[e]=t}function ye(e){window.__sentient_vocabulary_override=e}function Xe(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){Xe()[e]=t}function ve(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,X=!1;function he(){return X}function qe(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:ve("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:qe();return X=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return X=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function _e(){try{sessionStorage.removeItem(q)}catch(e){}}var Se="sentient_preview_cell",we="sentient_refresh_region",Y="sentient-cell-preview-bar",P="__preview__",Ye=null;function be(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(Se),n=l.get(we)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!he())return;if(n){Ye={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,P),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(l.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async l=>{if(!l)return;if(!l.ok){U(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ye(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[P]:c.compose}}),V(g,P);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,P);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[P]:c.blocks}}),V(g,P);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,P);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{_e();let d=new URL(window.location.href);d.searchParams.delete(Se),d.searchParams.delete(we),window.location.assign(d.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var Ce=!1;function xe(e){if(Ce||typeof window=="undefined")return;Ce=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Qe(t,n.token)})}function Qe(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Ae=require("react/jsx-runtime");function Ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",et=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Re,debug:!1}),ke=!1,Q=new Set;function tt(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify($(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,R=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(R)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v($(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var _,S;return((S=(_=l.current).refused)==null?void 0:S.call(_))===!0}}:{}):p),w=!1,N=()=>{let _=E.refused()&&E.read()!==!0;_&&!w&&(I(t),i.current()),w=_,O(_);let S=E.read();S!==null&&Q.add(t),d(S!=null?S:Q.has(t)?!1:null)};N(),y=E.subscribe(N)}),()=>{R=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function Ee(e){var ee,te,ne,ie,re;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:Ze()}),[a,d]=(0,o.useState)(H());(0,o.useEffect)(()=>fe(()=>d(H())),[]),(0,o.useEffect)(()=>{be(e.apiBaseUrl),xe(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=tt(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(ee=O.granted)!=null?ee:Q.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),R=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var L,oe;if(p.current&&l===!1&&(x.current=[]),l===!1&&R.current&&(p.current&&((L=y.current)==null||L.destroy()),y.current=null,R.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((oe=y.current)==null||oe.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=h=>{!r&&I.current&&h.gated&&h.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!1,s=null,b=null,C=h=>{for(let A of x.current.splice(0))setTimeout(()=>{if(y.current!==h){I.current||x.current.push(A);return}try{A(h)}catch(st){}},0)},k=h=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{u||(b=A(h,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:h})=>{u||(s=h($(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,R.current=r,C(s),n(s),k(s))}):(s=(0,B.init)(m),f(s),y.current=s,R.current=r,C(s),n(s),k(s)),()=>{var h,A;u=!0,b==null||b(),x.current=x.current.concat((A=(h=s==null?void 0:s.takeHeld)==null?void 0:h.call(s))!=null?A:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};de(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(te=e.ssrFallback)!=null?te:"first",w=((ne=e.apiBaseUrl)!=null?ne:Re).replace(/\/$/,""),N=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},f=N.current;if(N.current=r,f!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||pe({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ie=e.identity)==null?void 0:ie.userId,S=(re=e.identity)==null?void 0:re.userHash;(0,o.useEffect)(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||ke||(ke=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,o.useEffect)(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Z=(0,o.useMemo)(()=>t&&a?ge(t):t,[t,a]),Te=(0,o.useMemo)(()=>{var r,f,m,u,s,b,C,k,L;return{client:Z,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:nt,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:w,debug:(L=e.debug)!=null?L:!1}},[Z,e.apiKey,e.initialAssignments,e.initialUnified,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return(0,Ae.jsx)(et.Provider,{value:Te,children:e.children})}var nt=[];function it(e){return e<.3?"low":e<.7?"medium":"high"}function Pe(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",it((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;F()}var Ie=require("react/jsx-runtime");function rt(e,t={},n){return Pe(t),(0,Oe.render)((0,Ie.jsx)(Ee,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
|
|
3
3
|
//# sourceMappingURL=react.js.map
|
package/dist/testing/react.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var Ae=Object.defineProperty,Pe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var se=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&se(e,n,t[n]);if(oe)for(var n of oe(t))Te.call(t,n)&&se(e,n,t[n]);return e},M=(e,t)=>Pe(e,Oe(t));import{render as Ze}from"@testing-library/react";import{createContext as Be,useContext as At,useEffect as h,useMemo as be,useRef as x,useState as $,useSyncExternalStore as Pt}from"react";import{deriveSessionSegment as He,init as je}from"@sentientui/core";var Ve=new Map,De=new Map;function ae(e,t){Ve.set(e,t);let n=De.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var Ne={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Ne;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Le="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Le))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ge={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return Ge;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Fe(){H().version+=1;for(let e of H().listeners)e()}function j(e){W()&&(H().sections=[...e],Fe())}var fe="0.42.1",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function We(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){We()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function Ue(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ue()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",N=null,J=!1;function me(){return J}function $e(){try{return sessionStorage.getItem(X)}catch(e){return null}}function K(e){if(N)return N;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:$e();return J=!!n,N=Promise.resolve(n?{token:n,fresh:!1}:null),N}return J=!0,N=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(X,i)}catch(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),N}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",he="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Me=null;function _e(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ve),n=s.get(he)}catch(s){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!me())return;if(n){Me={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){U(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&ge(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let c=new URL(window.location.href);c.searchParams.delete(ve),c.searchParams.delete(he),window.location.assign(c.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se=!1;function we(e){if(Se||typeof window=="undefined")return;Se=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Ke(t,n.token)})}function Ke(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Ye}from"react/jsx-runtime";function ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return He({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xe="https://api.sentient-ui.com/v1",Je=Be({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:xe,debug:!1}),Ce=!1,Y=new Set;function Xe(e,t,n){let i=x(n);i.current=n;let[l,c]=$(null),[f,I]=$(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(y({},e),{check:typeof e.check,refused:typeof e.refused}));return h(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:k,forgetVisitor:T})=>{if(E)return;let A=k(typeof g=="object"&&g.cmp===void 0&&g.check?y(M(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var _,S;return((S=(_=s.current).refused)==null?void 0:S.call(_))===!0}}:{}):g),w=!1,L=()=>{let _=A.refused()&&A.read()!==!0;_&&!w&&(T(t),i.current()),w=_,I(_);let S=A.read();S!==null&&Y.add(t),c(S!=null?S:Y.has(t)?!1:null)};L(),m=A.subscribe(L)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function ke(e){var Z,ee,te,ne,ie;let[t,n]=$(null),[i]=$(()=>{var r;return(r=e.sessionSegment)!=null?r:ze()}),[l,c]=$(B());h(()=>ce(()=>c(B())),[]),h(()=>{_e(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let f=x(()=>{}),I=Xe(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Z=I.granted)!=null?Z:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),k=x([]),T=x(!1);f.current=()=>{var u;k.current=[],T.current=!0;let r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},h(()=>{var G,re;if(g.current&&s===!1&&(k.current=[]),s===!1&&E.current&&(g.current&&((G=m.current)==null||G.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((re=m.current)==null||re.destroy()),m.current=null,n(null);return}let r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,o=null,b=null,C=v=>{for(let P of k.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||k.current.push(P);return}try{P(v)}catch(tt){}},0)},R=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{d||(o=v(M(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),R(o))}):(o=je(p),u(o),m.current=o,E.current=r,C(o),n(o),R(o)),()=>{var v,P;d=!0,b==null||b(),k.current=k.current.concat((P=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?P:[]),o==null||o.dispose()}},[s]),h(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(p)}},[t]);let A=(ee=e.ssrFallback)!=null?ee:"first",w=((te=e.apiBaseUrl)!=null?te:xe).replace(/\/$/,""),L=x(null);h(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},u=L.current;if(L.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),h(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ne=e.identity)==null?void 0:ne.userId,S=(ie=e.identity)==null?void 0:ie.userHash;h(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),h(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){j(r);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),h(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||Ce||(Ce=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),h(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Q=be(()=>t&&l?de(t):t,[t,l]),Ee=be(()=>{var r,u,p,d,o,b,C,R,G;return{client:Q,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:qe,sessionSegment:i,ssrFallback:A,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:w,debug:(G=e.debug)!=null?G:!1}},[Q,e.apiKey,e.initialAssignments,e.initialUnified,i,A,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return Ye(Je.Provider,{value:Ee,children:e.children})}var qe=[];function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function Re(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Qe((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;F()}import{jsx as et}from"react/jsx-runtime";function Jt(e,t={},n){return Re(t),Ze(et(ke,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Jt as renderWithSentient};
|
|
2
|
+
var Ae=Object.defineProperty,Pe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var se=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&se(e,n,t[n]);if(oe)for(var n of oe(t))Te.call(t,n)&&se(e,n,t[n]);return e},M=(e,t)=>Pe(e,Oe(t));import{render as Ze}from"@testing-library/react";import{createContext as Be,useContext as At,useEffect as h,useMemo as be,useRef as x,useState as $,useSyncExternalStore as Pt}from"react";import{deriveSessionSegment as He,init as je}from"@sentientui/core";var Ve=new Map,De=new Map;function ae(e,t){Ve.set(e,t);let n=De.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var Ne={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Ne;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Le="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Le))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ge={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return Ge;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Fe(){H().version+=1;for(let e of H().listeners)e()}function j(e){W()&&(H().sections=[...e],Fe())}var fe="0.42.3",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function We(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){We()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function Ue(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ue()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",N=null,J=!1;function me(){return J}function $e(){try{return sessionStorage.getItem(X)}catch(e){return null}}function K(e){if(N)return N;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:$e();return J=!!n,N=Promise.resolve(n?{token:n,fresh:!1}:null),N}return J=!0,N=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(X,i)}catch(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),N}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",he="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Me=null;function _e(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ve),n=s.get(he)}catch(s){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!me())return;if(n){Me={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){U(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&ge(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let c=new URL(window.location.href);c.searchParams.delete(ve),c.searchParams.delete(he),window.location.assign(c.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se=!1;function we(e){if(Se||typeof window=="undefined")return;Se=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Ke(t,n.token)})}function Ke(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Ye}from"react/jsx-runtime";function ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return He({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xe="https://api.sentient-ui.com/v1",Je=Be({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:xe,debug:!1}),Ce=!1,Y=new Set;function Xe(e,t,n){let i=x(n);i.current=n;let[l,c]=$(null),[f,I]=$(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(y({},e),{check:typeof e.check,refused:typeof e.refused}));return h(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:k,forgetVisitor:T})=>{if(E)return;let A=k(typeof g=="object"&&g.cmp===void 0&&g.check?y(M(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var _,S;return((S=(_=s.current).refused)==null?void 0:S.call(_))===!0}}:{}):g),w=!1,L=()=>{let _=A.refused()&&A.read()!==!0;_&&!w&&(T(t),i.current()),w=_,I(_);let S=A.read();S!==null&&Y.add(t),c(S!=null?S:Y.has(t)?!1:null)};L(),m=A.subscribe(L)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function ke(e){var Z,ee,te,ne,ie;let[t,n]=$(null),[i]=$(()=>{var r;return(r=e.sessionSegment)!=null?r:ze()}),[l,c]=$(B());h(()=>ce(()=>c(B())),[]),h(()=>{_e(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let f=x(()=>{}),I=Xe(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Z=I.granted)!=null?Z:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),k=x([]),T=x(!1);f.current=()=>{var u;k.current=[],T.current=!0;let r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},h(()=>{var G,re;if(g.current&&s===!1&&(k.current=[]),s===!1&&E.current&&(g.current&&((G=m.current)==null||G.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((re=m.current)==null||re.destroy()),m.current=null,n(null);return}let r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,o=null,b=null,C=v=>{for(let P of k.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||k.current.push(P);return}try{P(v)}catch(tt){}},0)},R=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{d||(o=v(M(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),R(o))}):(o=je(p),u(o),m.current=o,E.current=r,C(o),n(o),R(o)),()=>{var v,P;d=!0,b==null||b(),k.current=k.current.concat((P=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?P:[]),o==null||o.dispose()}},[s]),h(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(p)}},[t]);let A=(ee=e.ssrFallback)!=null?ee:"first",w=((te=e.apiBaseUrl)!=null?te:xe).replace(/\/$/,""),L=x(null);h(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},u=L.current;if(L.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),h(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ne=e.identity)==null?void 0:ne.userId,S=(ie=e.identity)==null?void 0:ie.userHash;h(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),h(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){j(r);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),h(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||Ce||(Ce=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),h(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Q=be(()=>t&&l?de(t):t,[t,l]),Ee=be(()=>{var r,u,p,d,o,b,C,R,G;return{client:Q,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:qe,sessionSegment:i,ssrFallback:A,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:w,debug:(G=e.debug)!=null?G:!1}},[Q,e.apiKey,e.initialAssignments,e.initialUnified,i,A,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return Ye(Je.Provider,{value:Ee,children:e.children})}var qe=[];function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function Re(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Qe((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;F()}import{jsx as et}from"react/jsx-runtime";function Jt(e,t={},n){return Re(t),Ze(et(ke,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Jt as renderWithSentient};
|
|
3
3
|
//# sourceMappingURL=react.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/react",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"llms.txt"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@sentientui/
|
|
82
|
-
"@sentientui/
|
|
81
|
+
"@sentientui/core": "0.41.2",
|
|
82
|
+
"@sentientui/policy": "0.17.1"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@testing-library/react": ">=14.0.0 <17.0.0",
|