@sentientui/react 0.34.3 → 0.34.4
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 +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var gn=Object.create;var le=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,vn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Sn=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var Ze=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Ze(e,n,t[n]);if(fe)for(var n of fe(t))Ye.call(t,n)&&Ze(e,n,t[n]);return e},W=(e,t)=>mn(e,vn(t));var Qe=(e,t)=>{var n={};for(var r in e)Pe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fe)for(var r of fe(e))t.indexOf(r)<0&&Ye.call(e,r)&&(n[r]=e[r]);return n};var hn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},et=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yn(t))!Pe.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=pn(t,i))||r.enumerable});return e};var tt=(e,t,n)=>(n=e!=null?gn(Sn(e)):{},et(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>et(le({},"__esModule",{value:!0}),e);var Mn={};hn(Mn,{Adaptive:()=>jt,AdaptiveGroup:()=>on,AdaptiveProvider:()=>wt,AdaptiveSlot:()=>Ae,AdaptiveText:()=>Kt,SentientPersonaScript:()=>zt,buildAgentFeed:()=>cn,defineAgentContent:()=>ln,detectSegment:()=>Ue.deriveSessionSegment,getAgentContent:()=>Je,grantConsent:()=>fn.grantConsent,renderAgentJsonLd:()=>un,renderAgentJsonLdBody:()=>Xe,renderAgentMarkdown:()=>dn,renderBlocks:()=>oe,useAdaptive:()=>rn,useAdaptiveApiBaseUrl:()=>Ot,useAdaptiveGoal:()=>ke,useAdaptivePersona:()=>Yt,useAdaptiveTokens:()=>tn,useAssignment:()=>xe,useInitialAssignments:()=>ve,useLayoutOrder:()=>_t,usePageGoal:()=>Ut,useSentient:()=>E});module.exports=bn(Mn);var C=require("react"),pe=require("@sentientui/core");var nt=new Map,ge=new Map;function rt(e,t){let n=ge.get(e);return n||(n=new Set,ge.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ge.delete(e)}}function it(e,t){nt.set(e,t);let n=ge.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Te(e){var t;return(t=nt.get(e))!=null?t:null}var xn={on:!1,listeners:new Set};function ot(){if(typeof window=="undefined")return xn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function De(){return ot().on}function st(e){let t=ot().listeners;return t.add(e),()=>{t.delete(e)}}function at(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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 lt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ct(){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 $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Le,e),()=>window.removeEventListener(Le,e))}function ut(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function V(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function X(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ie=new Set,Fe=!1;function dt(e){if(Ie.has(e))return!0;if(Ie.add(e),!Fe){Fe=!0;let t=()=>{Fe=!1,Ie.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 wn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ft(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(wn(r))return!0;r=r.parentElement}return!1}function H(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&dt(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&ft(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&dt(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&ft(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var gt=new Set,mt=new Set;function ne(e,t,n,r,i){let f=`${r}|${n}`;if(mt.has(f))return;mt.add(f);let c=i.type==="weighted_composite"&&!gt.has(r);c&>.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function Z(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Cn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ee(){if(typeof window=="undefined")return Cn;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 ce(){ee().version+=1;for(let e of ee().listeners)e()}var pt=()=>{};function vt(e){return G()?(ee().components.set(e.id,e),ce(),()=>{ee().components.delete(e.id),ce()}):pt}function re(e){return G()?(ee().slots.set(e.id,e),ce(),()=>{ee().slots.delete(e.id),ce()}):pt}function Be(e){G()&&(ee().sections=[...e],ce())}var yt="0.34.3",Me=yt!=="0.0.0-dev"?{name:"react",version:yt}:void 0;function An(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function $e(e,t){An()[e]=t}function _n(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ve(e,t){_n()[e]=t}var St="sentient_editor",ht="sentient_preview_cell",je="sentient-cell-preview-bar",Ne="__preview__";function bt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(je))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(St),n=s.get(ht)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){me(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 m=await s.json();if(m.blocks!=null)$e(i,{kind:"arms",blocks:{[Ne]:m.blocks}}),Ve(i,Ne);else if(m.content!=null)$e(i,{kind:"arms",content:m.content}),Ve(i,Ne);else{me("Nothing to preview in that square yet.");return}ct(),me(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},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(je))return;let t=document.createElement("div");t.id=je,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=()=>{let f=new URL(window.location.href);f.searchParams.delete(St),f.searchParams.delete(ht),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Et=require("react/jsx-runtime");function Rn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,pe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xt="https://api.sentient-ui.com/v1",M=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:xt,debug:!1});function kn(e){let[t,n]=(0,C.useState)(!1),r=(0,C.useRef)(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,C.useEffect)(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function wt(e){var h,v;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var p;return(p=e.sessionSegment)!=null?p:Rn()}),[i,f]=(0,C.useState)(De());(0,C.useEffect)(()=>st(()=>f(De())),[]),(0,C.useEffect)(()=>{bt(e.apiBaseUrl)},[]);let c=kn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=(0,C.useRef)(null);(0,C.useEffect)(()=>{var _;if(s===!1&&!e.preConsentBehavior){(_=m.current)==null||_.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Me?{sdk:Me}:{}),a=!1,l=null,y=null,x=k=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{a||(y=A(k,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:k})=>{a||(l=k(W(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=(0,pe.init)(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),(0,C.useEffect)(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let _={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(k=>{var A;return{variantId:k.variantId,pulls:k.pulls,avgReward:(A=k.avgReward)!=null?A:0}})};it(x.componentId,_)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:xt).replace(/\/$/,""),u=(0,C.useRef)(null);(0,C.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),(0,C.useEffect)(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||ut({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,C.useEffect)(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Be(p);return}e.declaredSections&&e.declaredSections.length>0&&Be(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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 g=(0,C.useMemo)(()=>t&&i?at(t):t,[t,i]),b=(0,C.useMemo)(()=>{var p,a,l,y,x,_,k;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(_=e.initialPersona)!=null?_:null,apiBaseUrl:d,debug:(k=e.debug)!=null?k:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,Et.jsx)(M.Provider,{value:b,children:e.children})}function E(){return(0,C.useContext)(M).client}function z(){return(0,C.useContext)(M).apiKey}function ve(){return(0,C.useContext)(M).initialAssignments}function ye(){return(0,C.useContext)(M).sessionSegment}function Ct(){return(0,C.useContext)(M).ssrFallback}function Se(){return(0,C.useContext)(M).onAssignment}function At(){return(0,C.useContext)(M).debug}function _t(){let e=(0,C.useContext)(M).initialLayoutOrder,t=(0,C.useSyncExternalStore)($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function he(){return(0,C.useContext)(M).initialSlots}function Rt(){return(0,C.useContext)(M).initialPersona}function kt(){return(0,C.useContext)(M).initialSlotConfig}function Gt(){return(0,C.useContext)(M).initialPalette}function Ot(){return(0,C.useContext)(M).apiBaseUrl}var se=require("react");var D=require("react"),Pt=require("@sentientui/core");var N=require("react"),be=require("@sentientui/policy");function ie(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 f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function xe(e,t,n,r){let i=ve(),f=Ct(),c=E(),s=ye(),m=Se(),o=At(),d=(0,N.useRef)(null),u=(0,N.useSyncExternalStore)($,()=>ie(e),()=>null),g=u&&t.includes(u)?u:null,b=(0,N.useRef)(null);(0,N.useEffect)(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=(0,N.useState)(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Te(e);if(l){let _=(0,be.pickFromWeights)(l.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return(0,N.useEffect)(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Te(e);if(l&&h.settled&&h.variantId&&h.variantId===(0,be.pickFromWeights)(l.variants,t)){p(h.variantId);return}v(x=>{var _;return x.variantId?x:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),(0,N.useEffect)(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),(0,N.useEffect)(()=>{if(!g&&c)return rt(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=(0,be.pickFromWeights)(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function we(e,t,n){let r=E(),i=z(),f=Object.keys(t).join("\0"),c=(0,D.useMemo)(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=xe(e,c,n.agentData,n.agentDataByVariant),[u,g]=(0,D.useState)(null),b=(0,D.useRef)(null),h=(0,D.useCallback)(w=>{b.current=w,g(w)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=(0,D.useMemo)(()=>v?V(v):null,[p]),l=v?q(v):"";(0,D.useEffect)(()=>vt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=(0,D.useRef)(null);(0,D.useEffect)(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,Z(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=(0,D.useRef)(!1),_=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{x.current=!1,_.current=new Set},[s,a]);let k=n.funnel;(0,D.useEffect)(()=>{o||!d||!r||!k||!a||ne(r,i,e,k,a)},[r,i,e,k,a,o,d]);let A=n.cursorSignal===!0;(0,D.useEffect)(()=>{if(!A||o||!d||!r||!s||!u)return;let w=null,R=0,L=()=>{R=Date.now(),w=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),w=null},800)},I=()=>{w!==null&&(clearTimeout(w),w=null)};return u.addEventListener("mouseenter",L),u.addEventListener("mouseleave",I),()=>{u.removeEventListener("mouseenter",L),u.removeEventListener("mouseleave",I),w!==null&&clearTimeout(w)}},[A,r,s,i,e,u,o,d]);let O=(0,D.useRef)(n.microSignalGoals);O.current=n.microSignalGoals;let P=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u)return;let w=Date.now();return(0,Pt.attachMicroSignalDetectors)((R,L={})=>{var He,ze,qe;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:R},L)});let I=(He=O.current)==null?void 0:He[R];if(!I||_.current.has(R))return;_.current.add(R);let Q=typeof I=="string"?I:I.name,de=typeof I=="string"?1:(ze=I.weight)!=null?ze:1,Ee=typeof I=="string"?0:(qe=I.stepIndex)!=null?qe:0;r.goal(Q,{metadata:S({signalType:R},L),weight:de,stepIndex:Ee})},u,w)},[r,s,i,e,u,P,o,d]),(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u||!a)return;let w=X(a);return H(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},w!==void 0?{goalValue:w}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},w!==void 0?{value:w}:{})))},fireStep:(R,L,I)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:R,payload:{reward:L}}),r.goal(R,{metadata:{},weight:L,stepIndex:I})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}var K=require("react"),Ce=require("@sentientui/core");var j=require("react"),Dt=require("@sentientui/core");var Tt=new Set;function Lt(e,t){var p;let n=E(),r=(0,j.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=he(),f=kt(),c=Gt(),s=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":(0,Dt.armOfResult)(a),d=(0,j.useCallback)(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);(0,j.useSyncExternalStore)(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),(0,j.useSyncExternalStore)(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return(0,j.useEffect)(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var _;return(_=n.cancelSlots)==null?void 0:_.call(n,[e])}},[n,v,h.source,e]),(0,j.useEffect)(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Tt.has(e)||(Tt.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,h.source,e]),h}var We=require("react");var T=require("react/jsx-runtime"),Y={none:"0",sm:"8px",md:"16px",lg:"24px"},Ke={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Mt={sm:"0.875em",md:"1em",lg:"1.25em"},Gn={sm:"1.25em",md:"1.5em",lg:"2em"},It={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ft={sm:"8px",md:"16px",lg:"32px"},On={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},En={normal:"400",medium:"500",bold:"700"};function Bt(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function $t(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return W(S({display:"inline-block",padding:(i=It[n!=null?n:"md"])!=null?i:It.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Mt[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return(0,T.jsxs)("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return(0,T.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,T.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,T.jsx)("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>(0,T.jsx)("option",{value:g,children:g},g))}):(0,T.jsx)("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,T.jsx)("button",{type:"submit",style:$t(n,t.palette),children:e.submitLabel})]})}function oe(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,_,k,A,O;try{switch(e.type){case"stack":{let P=(r=Y[(n=e.gap)!=null?n:"md"])!=null?r:Y.md,w=e.surface==="raised",R=(i=e.pad)!=null?i:w?"md":void 0;return(0,T.jsx)("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.justify?{justifyContent:Ke[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),R?{padding:(f=Y[R])!=null?f:Y.md}:{}),w?W(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((L,I)=>{let Q=oe(L,t);return Q===null?null:(0,T.jsx)(We.Fragment,{children:Q},I)})})}case"grid":{let P=(v=Y[(h=e.gap)!=null?h:"md"])!=null?v:Y.md;return(0,T.jsx)("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${P}) / ${e.columns})), 1fr))`,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.pad?{padding:(p=Y[e.pad])!=null?p:Y.md}:{}),children:((a=e.children)!=null?a:[]).map((w,R)=>{let L=oe(w,t);return L===null?null:(0,T.jsx)(We.Fragment,{children:L},R)})})}case"text":return(0,T.jsx)("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Mt[e.size]}:{}),e.weight?{fontWeight:En[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bt(e.tone,t.palette)),children:e.value});case"heading":{let P=`h${e.level}`;return(0,T.jsx)(P,{style:S(S({margin:0,fontSize:Gn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let P=(y=e.emphasis)!=null?y:"primary";return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:$t(P,t.palette,e.size),children:e.label}))}case"link":return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,T.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:On[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,T.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(x=t.palette)==null?void 0:x.border)!=null?_:"currentColor"}`},Bt(e.tone,t.palette)),children:e.value});case"spacer":return(0,T.jsx)("div",{style:{height:(k=Ft[e.size])!=null?k:Ft.md}});case"divider":return(0,T.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(O=(A=t.palette)==null?void 0:A.border)!=null?O:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,T.jsx)(Pn,{node:e,opts:t});default:return null}}catch(P){return null}}var Nt=require("react/jsx-runtime"),Vt=new Set;function Ae({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var P;let c=E(),s=z(),m=(0,K.useRef)(null),{config:o,arm:d,palette:u,source:g}=Lt(e,{baselineText:f?()=>{var w,R;return(R=(w=m.current)==null?void 0:w.textContent)!=null?R:null}:void 0}),b=d!==""?(P=o==null?void 0:o.blocks)==null?void 0:P[d]:void 0,h=b!==void 0&&(0,Ce.containsFormBlock)(b)&&!n;(0,K.useEffect)(()=>{!h||!G()||Vt.has(e)||(Vt.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.`))},[h,e]);let v=w=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,w),c.goal(w,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let w=h?null:oe(b,{palette:u,onFormSubmit:n,onFormGoal:v});w===null?a=!0:p=w}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,K.useEffect)(()=>re({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=(0,K.useRef)(null);(0,K.useEffect)(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,Z(c,s,e,d))},[c,s,e,d,g,a]);let x=g!=="none"&&g!=="seeded"&&!a,_=x?d:"",k=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,K.useEffect)(()=>{if(!c||!r||g==="override")return;let w=m.current;if(!w)return;let R=q(r),L=X(r),I=!1;return H(w,V(r),{fireGoal:()=>{I||(I=!0,x&&(L!==void 0?c.componentGoal(e,R,{value:L}):c.componentGoal(e,R)),c.goal(R,S({metadata:{componentId:e,arm:_},weight:1,stepIndex:0},L!==void 0?{value:L}:{})))},fireStep:(Q,de,Ee)=>{x&&c.componentGoal(e,Q,{reward:de}),c.goal(Q,{metadata:{componentId:e,arm:_},weight:de,stepIndex:Ee})}},R)},[c,e,k,d,g,a,x,_]);let A=(0,K.useRef)(null);(0,K.useEffect)(()=>{let w=m.current;if(w){if(A.current===null){A.current=d;return}A.current!==d&&(A.current=d,(0,Ce.reveal)(w))}},[d]);let O=(0,K.useMemo)(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return(0,Nt.jsx)("div",W(S({ref:m,className:i},O),{children:p}))}var _e=require("react/jsx-runtime");function Tn(e){var o;let{client:t,variantId:n,content:r,ref:i}=we(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=(0,se.useState)(!1);if((0,se.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return G()&&s===null&&m===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,_e.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Dn=(0,se.memo)(Tn,(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.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)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 jt(e){return e.variants===void 0?(0,_e.jsx)(Ae,S({},e)):(G()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),(0,_e.jsx)(Dn,S({},e)))}var F=require("react");var Wt=require("react/jsx-runtime");function Kt({id:e,default:t,component:n="span",className:r,goal:i}){var k;let f=E(),c=z(),s=Se(),m=ye(),o=(0,F.useRef)(null),d=(0,F.useRef)(null),u=(0,F.useSyncExternalStore)($,()=>ie(e),()=>null),[g,b]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.content)!=null?O:null}),[h,v]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.variantId)!=null?O:null});(0,F.useEffect)(()=>{if(u||!f)return;let A=f.getAssignment(e,m);if((A==null?void 0:A.content)!==void 0){v(A.variantId),b(A.content);return}let O=!1;return f.assign(e).then(P=>{if(!O){if(!P){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(P.variantId),P.content&&b(P.content)}}),()=>{O=!0}},[f,e,m,u]),(0,F.useEffect)(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=(0,F.useMemo)(()=>i===void 0?null:V(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{y.current=!1},[h,p]),(0,F.useEffect)(()=>{if(u||!f||!h||!c||!a||!l)return;let A=d.current;if(!A)return;let O=X(a);return H(A,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},O!==void 0?{goalValue:O}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(P,w,R)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:P,payload:{reward:w}}),f.goal(P,{metadata:{},weight:w,stepIndex:R})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let A=f==null?void 0:f.getAssignment(e,m);x=A&&A.variantId===u&&(k=A.content)!=null?k:t}return(0,Wt.jsx)(n,{ref:A=>{d.current=A},className:r,children:x})}var Re=require("react");function ke(e){let t=E(),n=(0,Re.useRef)(new Set);return(0,Re.useCallback)((r,i)=>{var f,c;if(!ie(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,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var ue=require("react");function Ut(e,t={}){let m=t,{componentId:n}=m,r=Qe(m,["componentId"]),i=E(),f=ke(n!=null?n:""),c=(0,ue.useRef)(!1),s=(0,ue.useRef)(r);s.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}var Xt=require("@sentientui/core"),Ht=require("@sentientui/policy"),qt=require("react/jsx-runtime");function Jt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ln(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Jt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Jt((0,Ht.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Xt.renderPrePaintScript)(e.apiKey)}function zt(e){return(0,qt.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ln(e)}})}var J=require("react"),en=require("@sentientui/policy");var U=require("react"),te=require("@sentientui/core"),Zt=require("@sentientui/policy");function Ge(e,t){let n=E(),r=he(),[,i]=(0,U.useReducer)(u=>u+1,0),f=(0,U.useSyncExternalStore)($,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;(0,U.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:(0,te.armOfResult)(f),source:"override"};if(c!==void 0)return{result:c,arm:(0,te.armOfResult)(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:(0,te.armOfResult)(s),source:g?"client":"seeded"}}let u=(0,te.baselineResultFor)(t);return{result:u,arm:(0,te.armOfResult)(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return(0,U.useEffect)(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function In(){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 Yt(){let e=E(),t=Rt();(0,U.useSyncExternalStore)($,lt,()=>0);let[n,r]=(0,U.useState)(!1);(0,U.useEffect)(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:(0,Zt.confidenceBand)(s.confidence)});if(!n)return t?i(t):null;let f=In();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Qt=new Set;function Fn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tn(e,t,n){let r=E(),i=z(),f=JSON.stringify(t),c=(0,J.useMemo)(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=Ge(e,c),d=(0,J.useMemo)(()=>typeof s=="string"?{}:s,[m]);if(G()&&!Qt.has(e)){Qt.add(e);let v=(0,en.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} 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 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,J.useEffect)(()=>re({id:e,dims:t}),[e]);let g=(0,J.useRef)(null);(0,J.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,Z(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;(0,J.useEffect)(()=>{var v;!r||!b||o==="override"||ne(r,i,e,b,V((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),(0,J.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Fn(e)}"]`);if(!v){G()&&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 p=q(n.goal),a=X(n.goal),l=!1;return H(v,V(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,_)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:_})}},p)},[r,e,u,m,o]);let h=(0,J.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}var ae=require("react");var nn=new Set;function rn(e,t){var b;if(G()&&!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:f,goalLabel:c,ref:s,nodeRef:m}=we(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];(0,ae.useEffect)(()=>{if(!G()||!n)return;let h=setTimeout(()=>{!m.current&&!nn.has(e)&&(nn.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 u=(0,ae.useCallback)((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l: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,c,f]),g=(0,ae.useMemo)(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}var B=require("react");var sn=require("react/jsx-runtime"),Oe=new Set;function on(e){var a;let t=E(),n=z(),r=(0,B.useRef)(null),i=Object.keys(e.arrangements).join(" "),f=(0,B.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,B.useMemo)(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=Ge(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Oe.has(e.id+":baseline")&&(Oe.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=B.Children.toArray(e.children).filter(B.isValidElement),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));G()&&u!==void 0&&!g&&!Oe.has(e.id+":keys")&&(Oe.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;(0,B.useEffect)(()=>re({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=(0,B.useRef)(null);(0,B.useEffect)(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,Z(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;(0,B.useEffect)(()=>{var l;!t||!v||m==="override"||ne(t,n,e.id,v,V((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,B.useEffect)(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=q(e.goal),x=X(e.goal),_=!1;return H(l,V(e.goal),{fireGoal:()=>{_||(_=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(k,A,O)=>{t.componentGoal(e.id,k,{reward:A}),t.goal(k,{metadata:{componentId:e.id,arm:s},weight:A,stepIndex:O})}},y)},[t,e.id,p,s,m]),(0,sn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var Ue=require("@sentientui/core");var Bn=["page","blocks","layoutOrder"],an=new Map;function ln(e,t){an.set(e,t)}function Je(e){return an.get(e)}function cn(e){var i,f;let t=(f=(i=e.content)!=null?i:Je(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))Bn.includes(c)||(n[c]=s);let r=W(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function un(e){return`<script type="application/ld+json">${Xe(e)}</script>`}function Xe(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function dn(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 gn=Object.create;var le=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,vn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,Sn=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,Ye=Object.prototype.propertyIsEnumerable;var Ze=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Ze(e,n,t[n]);if(fe)for(var n of fe(t))Ye.call(t,n)&&Ze(e,n,t[n]);return e},W=(e,t)=>mn(e,vn(t));var Qe=(e,t)=>{var n={};for(var r in e)Pe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fe)for(var r of fe(e))t.indexOf(r)<0&&Ye.call(e,r)&&(n[r]=e[r]);return n};var hn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},et=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yn(t))!Pe.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=pn(t,i))||r.enumerable});return e};var tt=(e,t,n)=>(n=e!=null?gn(Sn(e)):{},et(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>et(le({},"__esModule",{value:!0}),e);var Mn={};hn(Mn,{Adaptive:()=>jt,AdaptiveGroup:()=>on,AdaptiveProvider:()=>wt,AdaptiveSlot:()=>Ae,AdaptiveText:()=>Kt,SentientPersonaScript:()=>zt,buildAgentFeed:()=>cn,defineAgentContent:()=>ln,detectSegment:()=>Ue.deriveSessionSegment,getAgentContent:()=>Je,grantConsent:()=>fn.grantConsent,renderAgentJsonLd:()=>un,renderAgentJsonLdBody:()=>Xe,renderAgentMarkdown:()=>dn,renderBlocks:()=>oe,useAdaptive:()=>rn,useAdaptiveApiBaseUrl:()=>Ot,useAdaptiveGoal:()=>ke,useAdaptivePersona:()=>Yt,useAdaptiveTokens:()=>tn,useAssignment:()=>xe,useInitialAssignments:()=>ve,useLayoutOrder:()=>_t,usePageGoal:()=>Ut,useSentient:()=>E});module.exports=bn(Mn);var C=require("react"),pe=require("@sentientui/core");var nt=new Map,ge=new Map;function rt(e,t){let n=ge.get(e);return n||(n=new Set,ge.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ge.delete(e)}}function it(e,t){nt.set(e,t);let n=ge.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Te(e){var t;return(t=nt.get(e))!=null?t:null}var xn={on:!1,listeners:new Set};function ot(){if(typeof window=="undefined")return xn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function De(){return ot().on}function st(e){let t=ot().listeners;return t.add(e),()=>{t.delete(e)}}function at(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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 lt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ct(){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 $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Le,e),()=>window.removeEventListener(Le,e))}function ut(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function V(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function X(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ie=new Set,Fe=!1;function dt(e){if(Ie.has(e))return!0;if(Ie.add(e),!Fe){Fe=!0;let t=()=>{Fe=!1,Ie.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 wn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ft(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(wn(r))return!0;r=r.parentElement}return!1}function H(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&dt(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&ft(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&dt(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&ft(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var gt=new Set,mt=new Set;function ne(e,t,n,r,i){let f=`${r}|${n}`;if(mt.has(f))return;mt.add(f);let c=i.type==="weighted_composite"&&!gt.has(r);c&>.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function Z(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Cn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ee(){if(typeof window=="undefined")return Cn;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 ce(){ee().version+=1;for(let e of ee().listeners)e()}var pt=()=>{};function vt(e){return G()?(ee().components.set(e.id,e),ce(),()=>{ee().components.delete(e.id),ce()}):pt}function re(e){return G()?(ee().slots.set(e.id,e),ce(),()=>{ee().slots.delete(e.id),ce()}):pt}function Be(e){G()&&(ee().sections=[...e],ce())}var yt="0.34.4",Me=yt!=="0.0.0-dev"?{name:"react",version:yt}:void 0;function An(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function $e(e,t){An()[e]=t}function _n(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ve(e,t){_n()[e]=t}var St="sentient_editor",ht="sentient_preview_cell",je="sentient-cell-preview-bar",Ne="__preview__";function bt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(je))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(St),n=s.get(ht)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){me(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 m=await s.json();if(m.blocks!=null)$e(i,{kind:"arms",blocks:{[Ne]:m.blocks}}),Ve(i,Ne);else if(m.content!=null)$e(i,{kind:"arms",content:m.content}),Ve(i,Ne);else{me("Nothing to preview in that square yet.");return}ct(),me(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},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(je))return;let t=document.createElement("div");t.id=je,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=()=>{let f=new URL(window.location.href);f.searchParams.delete(St),f.searchParams.delete(ht),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Et=require("react/jsx-runtime");function Rn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,pe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xt="https://api.sentient-ui.com/v1",M=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:xt,debug:!1});function kn(e){let[t,n]=(0,C.useState)(!1),r=(0,C.useRef)(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,C.useEffect)(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function wt(e){var h,v;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var p;return(p=e.sessionSegment)!=null?p:Rn()}),[i,f]=(0,C.useState)(De());(0,C.useEffect)(()=>st(()=>f(De())),[]),(0,C.useEffect)(()=>{bt(e.apiBaseUrl)},[]);let c=kn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=(0,C.useRef)(null);(0,C.useEffect)(()=>{var _;if(s===!1&&!e.preConsentBehavior){(_=m.current)==null||_.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Me?{sdk:Me}:{}),a=!1,l=null,y=null,x=k=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{a||(y=A(k,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:k})=>{a||(l=k(W(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=(0,pe.init)(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),(0,C.useEffect)(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let _={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(k=>{var A;return{variantId:k.variantId,pulls:k.pulls,avgReward:(A=k.avgReward)!=null?A:0}})};it(x.componentId,_)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:xt).replace(/\/$/,""),u=(0,C.useRef)(null);(0,C.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),(0,C.useEffect)(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||ut({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,C.useEffect)(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Be(p);return}e.declaredSections&&e.declaredSections.length>0&&Be(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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 g=(0,C.useMemo)(()=>t&&i?at(t):t,[t,i]),b=(0,C.useMemo)(()=>{var p,a,l,y,x,_,k;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(_=e.initialPersona)!=null?_:null,apiBaseUrl:d,debug:(k=e.debug)!=null?k:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,Et.jsx)(M.Provider,{value:b,children:e.children})}function E(){return(0,C.useContext)(M).client}function z(){return(0,C.useContext)(M).apiKey}function ve(){return(0,C.useContext)(M).initialAssignments}function ye(){return(0,C.useContext)(M).sessionSegment}function Ct(){return(0,C.useContext)(M).ssrFallback}function Se(){return(0,C.useContext)(M).onAssignment}function At(){return(0,C.useContext)(M).debug}function _t(){let e=(0,C.useContext)(M).initialLayoutOrder,t=(0,C.useSyncExternalStore)($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function he(){return(0,C.useContext)(M).initialSlots}function Rt(){return(0,C.useContext)(M).initialPersona}function kt(){return(0,C.useContext)(M).initialSlotConfig}function Gt(){return(0,C.useContext)(M).initialPalette}function Ot(){return(0,C.useContext)(M).apiBaseUrl}var se=require("react");var D=require("react"),Pt=require("@sentientui/core");var N=require("react"),be=require("@sentientui/policy");function ie(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 f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function xe(e,t,n,r){let i=ve(),f=Ct(),c=E(),s=ye(),m=Se(),o=At(),d=(0,N.useRef)(null),u=(0,N.useSyncExternalStore)($,()=>ie(e),()=>null),g=u&&t.includes(u)?u:null,b=(0,N.useRef)(null);(0,N.useEffect)(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=(0,N.useState)(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Te(e);if(l){let _=(0,be.pickFromWeights)(l.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return(0,N.useEffect)(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Te(e);if(l&&h.settled&&h.variantId&&h.variantId===(0,be.pickFromWeights)(l.variants,t)){p(h.variantId);return}v(x=>{var _;return x.variantId?x:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),(0,N.useEffect)(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),(0,N.useEffect)(()=>{if(!g&&c)return rt(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=(0,be.pickFromWeights)(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function we(e,t,n){let r=E(),i=z(),f=Object.keys(t).join("\0"),c=(0,D.useMemo)(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=xe(e,c,n.agentData,n.agentDataByVariant),[u,g]=(0,D.useState)(null),b=(0,D.useRef)(null),h=(0,D.useCallback)(w=>{b.current=w,g(w)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=(0,D.useMemo)(()=>v?V(v):null,[p]),l=v?q(v):"";(0,D.useEffect)(()=>vt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=(0,D.useRef)(null);(0,D.useEffect)(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,Z(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=(0,D.useRef)(!1),_=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{x.current=!1,_.current=new Set},[s,a]);let k=n.funnel;(0,D.useEffect)(()=>{o||!d||!r||!k||!a||ne(r,i,e,k,a)},[r,i,e,k,a,o,d]);let A=n.cursorSignal===!0;(0,D.useEffect)(()=>{if(!A||o||!d||!r||!s||!u)return;let w=null,R=0,L=()=>{R=Date.now(),w=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),w=null},800)},I=()=>{w!==null&&(clearTimeout(w),w=null)};return u.addEventListener("mouseenter",L),u.addEventListener("mouseleave",I),()=>{u.removeEventListener("mouseenter",L),u.removeEventListener("mouseleave",I),w!==null&&clearTimeout(w)}},[A,r,s,i,e,u,o,d]);let O=(0,D.useRef)(n.microSignalGoals);O.current=n.microSignalGoals;let P=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u)return;let w=Date.now();return(0,Pt.attachMicroSignalDetectors)((R,L={})=>{var He,ze,qe;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:R},L)});let I=(He=O.current)==null?void 0:He[R];if(!I||_.current.has(R))return;_.current.add(R);let Q=typeof I=="string"?I:I.name,de=typeof I=="string"?1:(ze=I.weight)!=null?ze:1,Ee=typeof I=="string"?0:(qe=I.stepIndex)!=null?qe:0;r.goal(Q,{metadata:S({signalType:R},L),weight:de,stepIndex:Ee})},u,w)},[r,s,i,e,u,P,o,d]),(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u||!a)return;let w=X(a);return H(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},w!==void 0?{goalValue:w}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},w!==void 0?{value:w}:{})))},fireStep:(R,L,I)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:R,payload:{reward:L}}),r.goal(R,{metadata:{},weight:L,stepIndex:I})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}var K=require("react"),Ce=require("@sentientui/core");var j=require("react"),Dt=require("@sentientui/core");var Tt=new Set;function Lt(e,t){var p;let n=E(),r=(0,j.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=he(),f=kt(),c=Gt(),s=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":(0,Dt.armOfResult)(a),d=(0,j.useCallback)(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);(0,j.useSyncExternalStore)(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),(0,j.useSyncExternalStore)(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return(0,j.useEffect)(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var _;return(_=n.cancelSlots)==null?void 0:_.call(n,[e])}},[n,v,h.source,e]),(0,j.useEffect)(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Tt.has(e)||(Tt.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,h.source,e]),h}var We=require("react");var T=require("react/jsx-runtime"),Y={none:"0",sm:"8px",md:"16px",lg:"24px"},Ke={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Mt={sm:"0.875em",md:"1em",lg:"1.25em"},Gn={sm:"1.25em",md:"1.5em",lg:"2em"},It={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ft={sm:"8px",md:"16px",lg:"32px"},On={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},En={normal:"400",medium:"500",bold:"700"};function Bt(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function $t(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return W(S({display:"inline-block",padding:(i=It[n!=null?n:"md"])!=null?i:It.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Mt[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return(0,T.jsxs)("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return(0,T.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,T.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,T.jsx)("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>(0,T.jsx)("option",{value:g,children:g},g))}):(0,T.jsx)("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,T.jsx)("button",{type:"submit",style:$t(n,t.palette),children:e.submitLabel})]})}function oe(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,_,k,A,O;try{switch(e.type){case"stack":{let P=(r=Y[(n=e.gap)!=null?n:"md"])!=null?r:Y.md,w=e.surface==="raised",R=(i=e.pad)!=null?i:w?"md":void 0;return(0,T.jsx)("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.justify?{justifyContent:Ke[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),R?{padding:(f=Y[R])!=null?f:Y.md}:{}),w?W(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((L,I)=>{let Q=oe(L,t);return Q===null?null:(0,T.jsx)(We.Fragment,{children:Q},I)})})}case"grid":{let P=(v=Y[(h=e.gap)!=null?h:"md"])!=null?v:Y.md;return(0,T.jsx)("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${P}) / ${e.columns})), 1fr))`,gap:P},e.align?{alignItems:Ke[e.align]}:{}),e.pad?{padding:(p=Y[e.pad])!=null?p:Y.md}:{}),children:((a=e.children)!=null?a:[]).map((w,R)=>{let L=oe(w,t);return L===null?null:(0,T.jsx)(We.Fragment,{children:L},R)})})}case"text":return(0,T.jsx)("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Mt[e.size]}:{}),e.weight?{fontWeight:En[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bt(e.tone,t.palette)),children:e.value});case"heading":{let P=`h${e.level}`;return(0,T.jsx)(P,{style:S(S({margin:0,fontSize:Gn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let P=(y=e.emphasis)!=null?y:"primary";return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:$t(P,t.palette,e.size),children:e.label}))}case"link":return(0,T.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,T.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:On[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,T.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(x=t.palette)==null?void 0:x.border)!=null?_:"currentColor"}`},Bt(e.tone,t.palette)),children:e.value});case"spacer":return(0,T.jsx)("div",{style:{height:(k=Ft[e.size])!=null?k:Ft.md}});case"divider":return(0,T.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(O=(A=t.palette)==null?void 0:A.border)!=null?O:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,T.jsx)(Pn,{node:e,opts:t});default:return null}}catch(P){return null}}var Nt=require("react/jsx-runtime"),Vt=new Set;function Ae({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var P;let c=E(),s=z(),m=(0,K.useRef)(null),{config:o,arm:d,palette:u,source:g}=Lt(e,{baselineText:f?()=>{var w,R;return(R=(w=m.current)==null?void 0:w.textContent)!=null?R:null}:void 0}),b=d!==""?(P=o==null?void 0:o.blocks)==null?void 0:P[d]:void 0,h=b!==void 0&&(0,Ce.containsFormBlock)(b)&&!n;(0,K.useEffect)(()=>{!h||!G()||Vt.has(e)||(Vt.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.`))},[h,e]);let v=w=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,w),c.goal(w,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let w=h?null:oe(b,{palette:u,onFormSubmit:n,onFormGoal:v});w===null?a=!0:p=w}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,K.useEffect)(()=>re({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=(0,K.useRef)(null);(0,K.useEffect)(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,Z(c,s,e,d))},[c,s,e,d,g,a]);let x=g!=="none"&&g!=="seeded"&&!a,_=x?d:"",k=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,K.useEffect)(()=>{if(!c||!r||g==="override")return;let w=m.current;if(!w)return;let R=q(r),L=X(r),I=!1;return H(w,V(r),{fireGoal:()=>{I||(I=!0,x&&(L!==void 0?c.componentGoal(e,R,{value:L}):c.componentGoal(e,R)),c.goal(R,S({metadata:{componentId:e,arm:_},weight:1,stepIndex:0},L!==void 0?{value:L}:{})))},fireStep:(Q,de,Ee)=>{x&&c.componentGoal(e,Q,{reward:de}),c.goal(Q,{metadata:{componentId:e,arm:_},weight:de,stepIndex:Ee})}},R)},[c,e,k,d,g,a,x,_]);let A=(0,K.useRef)(null);(0,K.useEffect)(()=>{let w=m.current;if(w){if(A.current===null){A.current=d;return}A.current!==d&&(A.current=d,(0,Ce.reveal)(w))}},[d]);let O=(0,K.useMemo)(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return(0,Nt.jsx)("div",W(S({ref:m,className:i},O),{children:p}))}var _e=require("react/jsx-runtime");function Tn(e){var o;let{client:t,variantId:n,content:r,ref:i}=we(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=(0,se.useState)(!1);if((0,se.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return G()&&s===null&&m===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,_e.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Dn=(0,se.memo)(Tn,(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.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)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 jt(e){return e.variants===void 0?(0,_e.jsx)(Ae,S({},e)):(G()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),(0,_e.jsx)(Dn,S({},e)))}var F=require("react");var Wt=require("react/jsx-runtime");function Kt({id:e,default:t,component:n="span",className:r,goal:i}){var k;let f=E(),c=z(),s=Se(),m=ye(),o=(0,F.useRef)(null),d=(0,F.useRef)(null),u=(0,F.useSyncExternalStore)($,()=>ie(e),()=>null),[g,b]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.content)!=null?O:null}),[h,v]=(0,F.useState)(()=>{var A,O;return(O=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.variantId)!=null?O:null});(0,F.useEffect)(()=>{if(u||!f)return;let A=f.getAssignment(e,m);if((A==null?void 0:A.content)!==void 0){v(A.variantId),b(A.content);return}let O=!1;return f.assign(e).then(P=>{if(!O){if(!P){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(P.variantId),P.content&&b(P.content)}}),()=>{O=!0}},[f,e,m,u]),(0,F.useEffect)(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=(0,F.useMemo)(()=>i===void 0?null:V(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{y.current=!1},[h,p]),(0,F.useEffect)(()=>{if(u||!f||!h||!c||!a||!l)return;let A=d.current;if(!A)return;let O=X(a);return H(A,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},O!==void 0?{goalValue:O}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(P,w,R)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:P,payload:{reward:w}}),f.goal(P,{metadata:{},weight:w,stepIndex:R})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let A=f==null?void 0:f.getAssignment(e,m);x=A&&A.variantId===u&&(k=A.content)!=null?k:t}return(0,Wt.jsx)(n,{ref:A=>{d.current=A},className:r,children:x})}var Re=require("react");function ke(e){let t=E(),n=(0,Re.useRef)(new Set);return(0,Re.useCallback)((r,i)=>{var f,c;if(!ie(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,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var ue=require("react");function Ut(e,t={}){let m=t,{componentId:n}=m,r=Qe(m,["componentId"]),i=E(),f=ke(n!=null?n:""),c=(0,ue.useRef)(!1),s=(0,ue.useRef)(r);s.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}var Xt=require("@sentientui/core"),Ht=require("@sentientui/policy"),qt=require("react/jsx-runtime");function Jt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ln(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Jt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Jt((0,Ht.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Xt.renderPrePaintScript)(e.apiKey)}function zt(e){return(0,qt.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ln(e)}})}var J=require("react"),en=require("@sentientui/policy");var U=require("react"),te=require("@sentientui/core"),Zt=require("@sentientui/policy");function Ge(e,t){let n=E(),r=he(),[,i]=(0,U.useReducer)(u=>u+1,0),f=(0,U.useSyncExternalStore)($,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;(0,U.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:(0,te.armOfResult)(f),source:"override"};if(c!==void 0)return{result:c,arm:(0,te.armOfResult)(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:(0,te.armOfResult)(s),source:g?"client":"seeded"}}let u=(0,te.baselineResultFor)(t);return{result:u,arm:(0,te.armOfResult)(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return(0,U.useEffect)(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function In(){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 Yt(){let e=E(),t=Rt();(0,U.useSyncExternalStore)($,lt,()=>0);let[n,r]=(0,U.useState)(!1);(0,U.useEffect)(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:(0,Zt.confidenceBand)(s.confidence)});if(!n)return t?i(t):null;let f=In();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Qt=new Set;function Fn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tn(e,t,n){let r=E(),i=z(),f=JSON.stringify(t),c=(0,J.useMemo)(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=Ge(e,c),d=(0,J.useMemo)(()=>typeof s=="string"?{}:s,[m]);if(G()&&!Qt.has(e)){Qt.add(e);let v=(0,en.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} 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 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,J.useEffect)(()=>re({id:e,dims:t}),[e]);let g=(0,J.useRef)(null);(0,J.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,Z(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;(0,J.useEffect)(()=>{var v;!r||!b||o==="override"||ne(r,i,e,b,V((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),(0,J.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Fn(e)}"]`);if(!v){G()&&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 p=q(n.goal),a=X(n.goal),l=!1;return H(v,V(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,_)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:_})}},p)},[r,e,u,m,o]);let h=(0,J.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}var ae=require("react");var nn=new Set;function rn(e,t){var b;if(G()&&!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:f,goalLabel:c,ref:s,nodeRef:m}=we(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];(0,ae.useEffect)(()=>{if(!G()||!n)return;let h=setTimeout(()=>{!m.current&&!nn.has(e)&&(nn.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 u=(0,ae.useCallback)((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l: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,c,f]),g=(0,ae.useMemo)(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}var B=require("react");var sn=require("react/jsx-runtime"),Oe=new Set;function on(e){var a;let t=E(),n=z(),r=(0,B.useRef)(null),i=Object.keys(e.arrangements).join(" "),f=(0,B.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,B.useMemo)(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=Ge(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Oe.has(e.id+":baseline")&&(Oe.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=B.Children.toArray(e.children).filter(B.isValidElement),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));G()&&u!==void 0&&!g&&!Oe.has(e.id+":keys")&&(Oe.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;(0,B.useEffect)(()=>re({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=(0,B.useRef)(null);(0,B.useEffect)(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,Z(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;(0,B.useEffect)(()=>{var l;!t||!v||m==="override"||ne(t,n,e.id,v,V((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,B.useEffect)(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=q(e.goal),x=X(e.goal),_=!1;return H(l,V(e.goal),{fireGoal:()=>{_||(_=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(k,A,O)=>{t.componentGoal(e.id,k,{reward:A}),t.goal(k,{metadata:{componentId:e.id,arm:s},weight:A,stepIndex:O})}},y)},[t,e.id,p,s,m]),(0,sn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var Ue=require("@sentientui/core");var Bn=["page","blocks","layoutOrder"],an=new Map;function ln(e,t){an.set(e,t)}function Je(e){return an.get(e)}function cn(e){var i,f;let t=(f=(i=e.content)!=null?i:Je(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))Bn.includes(c)||(n[c]=s);let r=W(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function un(e){return`<script type="application/ld+json">${Xe(e)}</script>`}function Xe(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function dn(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 fn=require("@sentientui/core");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var Jt=Object.defineProperty,Xt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var Je=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Xe.call(t,n)&&Je(e,n,t[n]);if(re)for(var n of re(t))He.call(t,n)&&Je(e,n,t[n]);return e},M=(e,t)=>Xt(e,Ht(t));var ze=(e,t)=>{var n={};for(var r in e)Xe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&re)for(var r of re(e))t.indexOf(r)<0&&He.call(e,r)&&(n[r]=e[r]);return n};import{createContext as en,useContext as I,useEffect as j,useMemo as pt,useRef as Pe,useState as se,useSyncExternalStore as tn}from"react";import{deriveSessionSegment as nn,init as rn}from"@sentientui/core";var qe=new Map,ie=new Map;function Ze(e,t){let n=ie.get(e);return n||(n=new Set,ie.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ie.delete(e)}}function Ye(e,t){qe.set(e,t);let n=ie.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function be(e){var t;return(t=qe.get(e))!=null?t:null}var zt={on:!1,listeners:new Set};function Qe(){if(typeof window=="undefined")return zt;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function xe(){return Qe().on}function et(e){let t=Qe().listeners;return t.add(e),()=>{t.delete(e)}}function tt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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 we="sentient:overrides-changed";function nt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function rt(){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(we))}function F(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(we,e),()=>window.removeEventListener(we,e))}function it(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function k(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function B(e){return typeof e=="string"?{type:"click"}:e}function K(e){return typeof e=="string"?e:e.type}function $(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ce=new Set,Ae=!1;function ot(e){if(Ce.has(e))return!0;if(Ce.add(e),!Ae){Ae=!0;let t=()=>{Ae=!1,Ce.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 qt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function st(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(qt(r))return!0;r=r.parentElement}return!1}function V(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&ot(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&st(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&ot(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&st(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var at=new Set,lt=new Set;function z(e,t,n,r,i){let f=`${r}|${n}`;if(lt.has(f))return;lt.add(f);let c=i.type==="weighted_composite"&&!at.has(r);c&&at.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function W(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function X(){if(typeof window=="undefined")return Zt;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 Y(){X().version+=1;for(let e of X().listeners)e()}var ct=()=>{};function ut(e){return k()?(X().components.set(e.id,e),Y(),()=>{X().components.delete(e.id),Y()}):ct}function q(e){return k()?(X().slots.set(e.id,e),Y(),()=>{X().slots.delete(e.id),Y()}):ct}function _e(e){k()&&(X().sections=[...e],Y())}var dt="0.34.3",Re=dt!=="0.0.0-dev"?{name:"react",version:dt}:void 0;function Yt(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function ke(e,t){Yt()[e]=t}function Qt(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ge(e,t){Qt()[e]=t}var ft="sentient_editor",gt="sentient_preview_cell",Ee="sentient-cell-preview-bar",Oe="__preview__";function mt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ee))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ft),n=s.get(gt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){oe(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 m=await s.json();if(m.blocks!=null)ke(i,{kind:"arms",blocks:{[Oe]:m.blocks}}),Ge(i,Oe);else if(m.content!=null)ke(i,{kind:"arms",content:m.content}),Ge(i,Oe);else{oe("Nothing to preview in that square yet.");return}rt(),oe(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>oe("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function oe(e){var i;if(document.getElementById(Ee))return;let t=document.createElement("div");t.id=Ee,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=()=>{let f=new URL(window.location.href);f.searchParams.delete(ft),f.searchParams.delete(gt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}import{jsx as un}from"react/jsx-runtime";function on(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return nn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var vt="https://api.sentient-ui.com/v1",L=en({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:vt,debug:!1});function sn(e){let[t,n]=se(!1),r=Pe(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return j(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function an(e){var h,v;let[t,n]=se(null),[r]=se(()=>{var p;return(p=e.sessionSegment)!=null?p:on()}),[i,f]=se(xe());j(()=>et(()=>f(xe())),[]),j(()=>{mt(e.apiBaseUrl)},[]);let c=sn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=Pe(null);j(()=>{var A;if(s===!1&&!e.preConsentBehavior){(A=m.current)==null||A.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Re?{sdk:Re}:{}),a=!1,l=null,y=null,x=R=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{a||(y=C(R,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:R})=>{a||(l=R(M(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=rn(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),j(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let A={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(R=>{var C;return{variantId:R.variantId,pulls:R.pulls,avgReward:(C=R.avgReward)!=null?C:0}})};Ye(x.componentId,A)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:vt).replace(/\/$/,""),u=Pe(null);j(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),j(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||it({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),j(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){_e(p);return}e.declaredSections&&e.declaredSections.length>0&&_e(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),j(()=>{if(!k())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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 g=pt(()=>t&&i?tt(t):t,[t,i]),b=pt(()=>{var p,a,l,y,x,A,R;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(A=e.initialPersona)!=null?A:null,apiBaseUrl:d,debug:(R=e.debug)!=null?R:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return un(L.Provider,{value:b,children:e.children})}function E(){return I(L).client}function N(){return I(L).apiKey}function Te(){return I(L).initialAssignments}function ae(){return I(L).sessionSegment}function yt(){return I(L).ssrFallback}function le(){return I(L).onAssignment}function St(){return I(L).debug}function ln(){let e=I(L).initialLayoutOrder,t=tn(F,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function ce(){return I(L).initialSlots}function ht(){return I(L).initialPersona}function bt(){return I(L).initialSlotConfig}function xt(){return I(L).initialPalette}function cn(){return I(L).apiBaseUrl}import{memo as kn,useEffect as Gn,useState as On}from"react";import{useCallback as gn,useEffect as H,useMemo as Ct,useRef as Q,useState as mn}from"react";import{attachMicroSignalDetectors as pn}from"@sentientui/core";import{useEffect as ue,useRef as wt,useState as dn,useSyncExternalStore as fn}from"react";import{pickFromWeights as De}from"@sentientui/policy";function Z(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 f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function Le(e,t,n,r){let i=Te(),f=yt(),c=E(),s=ae(),m=le(),o=St(),d=wt(null),u=fn(F,()=>Z(e),()=>null),g=u&&t.includes(u)?u:null,b=wt(null);ue(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=dn(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let A=i[e];return A&&t.includes(A)?{variantId:A,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=be(e);if(l){let A=De(l.variants,t);if(A)return{variantId:A,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return ue(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=be(e);if(l&&h.settled&&h.variantId&&h.variantId===De(l.variants,t)){p(h.variantId);return}v(x=>{var A;return x.variantId?x:{variantId:(A=t[0])!=null?A:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),ue(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),ue(()=>{if(!g&&c)return Ze(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=De(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function de(e,t,n){let r=E(),i=N(),f=Object.keys(t).join("\0"),c=Ct(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=Le(e,c,n.agentData,n.agentDataByVariant),[u,g]=mn(null),b=Q(null),h=gn(w=>{b.current=w,g(w)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=Ct(()=>v?B(v):null,[p]),l=v?K(v):"";H(()=>ut({id:e,variantIds:c,goal:l}),[e,c,l]);let y=Q(null);H(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,W(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=Q(!1),A=Q(new Set);H(()=>{x.current=!1,A.current=new Set},[s,a]);let R=n.funnel;H(()=>{o||!d||!r||!R||!a||z(r,i,e,R,a)},[r,i,e,R,a,o,d]);let C=n.cursorSignal===!0;H(()=>{if(!C||o||!d||!r||!s||!u)return;let w=null,_=0,P=()=>{_=Date.now(),w=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-_}}),w=null},800)},T=()=>{w!==null&&(clearTimeout(w),w=null)};return u.addEventListener("mouseenter",P),u.addEventListener("mouseleave",T),()=>{u.removeEventListener("mouseenter",P),u.removeEventListener("mouseleave",T),w!==null&&clearTimeout(w)}},[C,r,s,i,e,u,o,d]);let G=Q(n.microSignalGoals);G.current=n.microSignalGoals;let O=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return H(()=>{if(o||!d||!r||!s||!u)return;let w=Date.now();return pn((_,P={})=>{var Ke,We,Ue;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:_},P)});let T=(Ke=G.current)==null?void 0:Ke[_];if(!T||A.current.has(_))return;A.current.add(_);let J=typeof T=="string"?T:T.name,ne=typeof T=="string"?1:(We=T.weight)!=null?We:1,he=typeof T=="string"?0:(Ue=T.stepIndex)!=null?Ue:0;r.goal(J,{metadata:S({signalType:_},P),weight:ne,stepIndex:he})},u,w)},[r,s,i,e,u,O,o,d]),H(()=>{if(o||!d||!r||!s||!u||!a)return;let w=$(a);return V(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},w!==void 0?{goalValue:w}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},w!==void 0?{value:w}:{})))},fireStep:(_,P,T)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:_,payload:{reward:P}}),r.goal(_,{metadata:{},weight:P,stepIndex:T})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}import{useEffect as te,useMemo as Cn,useRef as Fe}from"react";import{containsFormBlock as An,reveal as _n}from"@sentientui/core";import{useCallback as vn,useEffect as At,useRef as yn,useSyncExternalStore as fe}from"react";import{armOfResult as Sn}from"@sentientui/core";var _t=new Set;function Rt(e,t){var p;let n=E(),r=yn(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=ce(),f=bt(),c=xt(),s=fe(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=fe(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":Sn(a),d=vn(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);fe(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),fe(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return At(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var A;return(A=n.cancelSlots)==null?void 0:A.call(n,[e])}},[n,v,h.source,e]),At(()=>{!k()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||_t.has(e)||(_t.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,h.source,e]),h}import{Fragment as kt}from"react";import{jsx as D,jsxs as Pt}from"react/jsx-runtime";var U={none:"0",sm:"8px",md:"16px",lg:"24px"},Ie={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Tt={sm:"0.875em",md:"1em",lg:"1.25em"},hn={sm:"1.25em",md:"1.5em",lg:"2em"},Gt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ot={sm:"8px",md:"16px",lg:"32px"},bn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},xn={normal:"400",medium:"500",bold:"700"};function Et(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Dt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return M(S({display:"inline-block",padding:(i=Gt[n!=null?n:"md"])!=null?i:Gt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Tt[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function wn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return Pt("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return Pt("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?D("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?D("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>D("option",{value:g,children:g},g))}):D("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),D("button",{type:"submit",style:Dt(n,t.palette),children:e.submitLabel})]})}function ee(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,A,R,C,G;try{switch(e.type){case"stack":{let O=(r=U[(n=e.gap)!=null?n:"md"])!=null?r:U.md,w=e.surface==="raised",_=(i=e.pad)!=null?i:w?"md":void 0;return D("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:O},e.align?{alignItems:Ie[e.align]}:{}),e.justify?{justifyContent:Ie[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),_?{padding:(f=U[_])!=null?f:U.md}:{}),w?M(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((P,T)=>{let J=ee(P,t);return J===null?null:D(kt,{children:J},T)})})}case"grid":{let O=(v=U[(h=e.gap)!=null?h:"md"])!=null?v:U.md;return D("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${O}) / ${e.columns})), 1fr))`,gap:O},e.align?{alignItems:Ie[e.align]}:{}),e.pad?{padding:(p=U[e.pad])!=null?p:U.md}:{}),children:((a=e.children)!=null?a:[]).map((w,_)=>{let P=ee(w,t);return P===null?null:D(kt,{children:P},_)})})}case"text":return D("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Tt[e.size]}:{}),e.weight?{fontWeight:xn[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Et(e.tone,t.palette)),children:e.value});case"heading":{let O=`h${e.level}`;return D(O,{style:S(S({margin:0,fontSize:hn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let O=(y=e.emphasis)!=null?y:"primary";return D("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Dt(O,t.palette,e.size),children:e.label}))}case"link":return D("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return D("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:bn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return D("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(A=(x=t.palette)==null?void 0:x.border)!=null?A:"currentColor"}`},Et(e.tone,t.palette)),children:e.value});case"spacer":return D("div",{style:{height:(R=Ot[e.size])!=null?R:Ot.md}});case"divider":return D("hr",{style:{border:"none",borderTop:`1px solid ${(G=(C=t.palette)==null?void 0:C.border)!=null?G:"currentColor"}`,margin:0,width:"100%"}});case"form":return D(wn,{node:e,opts:t});default:return null}}catch(O){return null}}import{jsx as Rn}from"react/jsx-runtime";var Lt=new Set;function Be({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var O;let c=E(),s=N(),m=Fe(null),{config:o,arm:d,palette:u,source:g}=Rt(e,{baselineText:f?()=>{var w,_;return(_=(w=m.current)==null?void 0:w.textContent)!=null?_:null}:void 0}),b=d!==""?(O=o==null?void 0:o.blocks)==null?void 0:O[d]:void 0,h=b!==void 0&&An(b)&&!n;te(()=>{!h||!k()||Lt.has(e)||(Lt.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.`))},[h,e]);let v=w=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,w),c.goal(w,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let w=h?null:ee(b,{palette:u,onFormSubmit:n,onFormGoal:v});w===null?a=!0:p=w}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";te(()=>q({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=Fe(null);te(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,W(c,s,e,d))},[c,s,e,d,g,a]);let x=g!=="none"&&g!=="seeded"&&!a,A=x?d:"",R=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);te(()=>{if(!c||!r||g==="override")return;let w=m.current;if(!w)return;let _=K(r),P=$(r),T=!1;return V(w,B(r),{fireGoal:()=>{T||(T=!0,x&&(P!==void 0?c.componentGoal(e,_,{value:P}):c.componentGoal(e,_)),c.goal(_,S({metadata:{componentId:e,arm:A},weight:1,stepIndex:0},P!==void 0?{value:P}:{})))},fireStep:(J,ne,he)=>{x&&c.componentGoal(e,J,{reward:ne}),c.goal(J,{metadata:{componentId:e,arm:A},weight:ne,stepIndex:he})}},_)},[c,e,R,d,g,a,x,A]);let C=Fe(null);te(()=>{let w=m.current;if(w){if(C.current===null){C.current=d;return}C.current!==d&&(C.current=d,_n(w))}},[d]);let G=Cn(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return Rn("div",M(S({ref:m,className:i},G),{children:p}))}import{jsx as Me}from"react/jsx-runtime";function En(e){var o;let{client:t,variantId:n,content:r,ref:i}=de(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=On(!1);if(Gn(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return k()&&s===null&&m===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.`),Me("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Pn=kn(En,(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.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)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 Tn(e){return e.variants===void 0?Me(Be,S({},e)):(k()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),Me(Pn,S({},e)))}import{useEffect as ge,useMemo as Dn,useRef as $e,useState as It,useSyncExternalStore as Ln}from"react";import{jsx as Fn}from"react/jsx-runtime";function In({id:e,default:t,component:n="span",className:r,goal:i}){var R;let f=E(),c=N(),s=le(),m=ae(),o=$e(null),d=$e(null),u=Ln(F,()=>Z(e),()=>null),[g,b]=It(()=>{var C,G;return(G=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.content)!=null?G:null}),[h,v]=It(()=>{var C,G;return(G=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.variantId)!=null?G:null});ge(()=>{if(u||!f)return;let C=f.getAssignment(e,m);if((C==null?void 0:C.content)!==void 0){v(C.variantId),b(C.content);return}let G=!1;return f.assign(e).then(O=>{if(!G){if(!O){k()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(O.variantId),O.content&&b(O.content)}}),()=>{G=!0}},[f,e,m,u]),ge(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=Dn(()=>i===void 0?null:B(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=$e(!1);ge(()=>{y.current=!1},[h,p]),ge(()=>{if(u||!f||!h||!c||!a||!l)return;let C=d.current;if(!C)return;let G=$(a);return V(C,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},G!==void 0?{goalValue:G}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},G!==void 0?{value:G}:{})))},fireStep:(O,w,_)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:O,payload:{reward:w}}),f.goal(O,{metadata:{},weight:w,stepIndex:_})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let C=f==null?void 0:f.getAssignment(e,m);x=C&&C.variantId===u&&(R=C.content)!=null?R:t}return Fn(n,{ref:C=>{d.current=C},className:r,children:x})}import{useCallback as Bn,useRef as Mn}from"react";function Ve(e){let t=E(),n=Mn(new Set);return Bn((r,i)=>{var f,c;if(!Z(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,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as $n,useRef as Ft}from"react";function Vn(e,t={}){let m=t,{componentId:n}=m,r=ze(m,["componentId"]),i=E(),f=Ve(n!=null?n:""),c=Ft(!1),s=Ft(r);s.current=r,$n(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}import{renderPrePaintScript as Nn}from"@sentientui/core";import{confidenceBand as jn}from"@sentientui/policy";import{jsx as Un}from"react/jsx-runtime";function Bt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Kn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Bt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Bt(jn(e.persona.confidence))+");}catch(e){}})();":Nn(e.apiKey)}function Wn(e){return Un("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Kn(e)}})}import{useEffect as ve,useMemo as je,useRef as Yn}from"react";import{validateSlotDecl as Qn}from"@sentientui/policy";import{useEffect as Ne,useReducer as Jn,useState as Xn,useSyncExternalStore as Mt}from"react";import{armOfResult as me,baselineResultFor as Hn}from"@sentientui/core";import{confidenceBand as zn}from"@sentientui/policy";function pe(e,t){let n=E(),r=ce(),[,i]=Jn(u=>u+1,0),f=Mt(F,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;Ne(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:me(f),source:"override"};if(c!==void 0)return{result:c,arm:me(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:me(s),source:g?"client":"seeded"}}let u=Hn(t);return{result:u,arm:me(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return Ne(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function qn(){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 Zn(){let e=E(),t=ht();Mt(F,nt,()=>0);let[n,r]=Xn(!1);Ne(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:zn(s.confidence)});if(!n)return t?i(t):null;let f=qn();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var $t=new Set;function er(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tr(e,t,n){let r=E(),i=N(),f=JSON.stringify(t),c=je(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=pe(e,c),d=je(()=>typeof s=="string"?{}:s,[m]);if(k()&&!$t.has(e)){$t.add(e);let v=Qn({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} 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 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);ve(()=>q({id:e,dims:t}),[e]);let g=Yn(null);ve(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,W(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;ve(()=>{var v;!r||!b||o==="override"||z(r,i,e,b,B((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),ve(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${er(e)}"]`);if(!v){k()&&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 p=K(n.goal),a=$(n.goal),l=!1;return V(v,B(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,A)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:A})}},p)},[r,e,u,m,o]);let h=je(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}import{useCallback as nr,useEffect as rr,useMemo as ir}from"react";var Vt=new Set;function or(e,t){var b;if(k()&&!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:f,goalLabel:c,ref:s,nodeRef:m}=de(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];rr(()=>{if(!k()||!n)return;let h=setTimeout(()=>{!m.current&&!Vt.has(e)&&(Vt.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 u=nr((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l: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,c,f]),g=ir(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}import{Children as sr,isValidElement as ar,useEffect as ye,useMemo as Nt,useRef as jt}from"react";import{jsx as cr}from"react/jsx-runtime";var Se=new Set;function lr(e){var a;let t=E(),n=N(),r=jt(null),i=Object.keys(e.arrangements).join(" "),f=Nt(()=>Object.keys(e.arrangements),[i]),c=Nt(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=pe(e.id,c);k()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Se.has(e.id+":baseline")&&(Se.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=sr.toArray(e.children).filter(ar),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));k()&&u!==void 0&&!g&&!Se.has(e.id+":keys")&&(Se.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;ye(()=>q({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=jt(null);ye(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,W(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;ye(()=>{var l;!t||!v||m==="override"||z(t,n,e.id,v,B((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ye(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=K(e.goal),x=$(e.goal),A=!1;return V(l,B(e.goal),{fireGoal:()=>{A||(A=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(R,C,G)=>{t.componentGoal(e.id,R,{reward:C}),t.goal(R,{metadata:{componentId:e.id,arm:s},weight:C,stepIndex:G})}},y)},[t,e.id,p,s,m]),cr("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}import{deriveSessionSegment as ur}from"@sentientui/core";var dr=["page","blocks","layoutOrder"],Kt=new Map;function fr(e,t){Kt.set(e,t)}function Wt(e){return Kt.get(e)}function gr(e){var i,f;let t=(f=(i=e.content)!=null?i:Wt(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))dr.includes(c)||(n[c]=s);let r=M(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function mr(e){return`<script type="application/ld+json">${Ut(e)}</script>`}function Ut(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function pr(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 Jt=Object.defineProperty,Xt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,He=Object.prototype.propertyIsEnumerable;var Je=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Xe.call(t,n)&&Je(e,n,t[n]);if(re)for(var n of re(t))He.call(t,n)&&Je(e,n,t[n]);return e},M=(e,t)=>Xt(e,Ht(t));var ze=(e,t)=>{var n={};for(var r in e)Xe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&re)for(var r of re(e))t.indexOf(r)<0&&He.call(e,r)&&(n[r]=e[r]);return n};import{createContext as en,useContext as I,useEffect as j,useMemo as pt,useRef as Pe,useState as se,useSyncExternalStore as tn}from"react";import{deriveSessionSegment as nn,init as rn}from"@sentientui/core";var qe=new Map,ie=new Map;function Ze(e,t){let n=ie.get(e);return n||(n=new Set,ie.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&ie.delete(e)}}function Ye(e,t){qe.set(e,t);let n=ie.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function be(e){var t;return(t=qe.get(e))!=null?t:null}var zt={on:!1,listeners:new Set};function Qe(){if(typeof window=="undefined")return zt;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function xe(){return Qe().on}function et(e){let t=Qe().listeners;return t.add(e),()=>{t.delete(e)}}function tt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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 we="sentient:overrides-changed";function nt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function rt(){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(we))}function F(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(we,e),()=>window.removeEventListener(we,e))}function it(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function k(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function B(e){return typeof e=="string"?{type:"click"}:e}function K(e){return typeof e=="string"?e:e.type}function $(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Ce=new Set,Ae=!1;function ot(e){if(Ce.has(e))return!0;if(Ce.add(e),!Ae){Ae=!0;let t=()=>{Ae=!1,Ce.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 qt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function st(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(qt(r))return!0;r=r.parentElement}return!1}function V(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&ot(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&st(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&ot(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&st(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var at=new Set,lt=new Set;function z(e,t,n,r,i){let f=`${r}|${n}`;if(lt.has(f))return;lt.add(f);let c=i.type==="weighted_composite"&&!at.has(r);c&&at.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function W(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function X(){if(typeof window=="undefined")return Zt;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 Y(){X().version+=1;for(let e of X().listeners)e()}var ct=()=>{};function ut(e){return k()?(X().components.set(e.id,e),Y(),()=>{X().components.delete(e.id),Y()}):ct}function q(e){return k()?(X().slots.set(e.id,e),Y(),()=>{X().slots.delete(e.id),Y()}):ct}function _e(e){k()&&(X().sections=[...e],Y())}var dt="0.34.4",Re=dt!=="0.0.0-dev"?{name:"react",version:dt}:void 0;function Yt(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function ke(e,t){Yt()[e]=t}function Qt(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ge(e,t){Qt()[e]=t}var ft="sentient_editor",gt="sentient_preview_cell",Ee="sentient-cell-preview-bar",Oe="__preview__";function mt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ee))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ft),n=s.get(gt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){oe(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 m=await s.json();if(m.blocks!=null)ke(i,{kind:"arms",blocks:{[Oe]:m.blocks}}),Ge(i,Oe);else if(m.content!=null)ke(i,{kind:"arms",content:m.content}),Ge(i,Oe);else{oe("Nothing to preview in that square yet.");return}rt(),oe(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>oe("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function oe(e){var i;if(document.getElementById(Ee))return;let t=document.createElement("div");t.id=Ee,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=()=>{let f=new URL(window.location.href);f.searchParams.delete(ft),f.searchParams.delete(gt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}import{jsx as un}from"react/jsx-runtime";function on(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return nn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var vt="https://api.sentient-ui.com/v1",L=en({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:vt,debug:!1});function sn(e){let[t,n]=se(!1),r=Pe(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return j(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function an(e){var h,v;let[t,n]=se(null),[r]=se(()=>{var p;return(p=e.sessionSegment)!=null?p:on()}),[i,f]=se(xe());j(()=>et(()=>f(xe())),[]),j(()=>{mt(e.apiBaseUrl)},[]);let c=sn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=Pe(null);j(()=>{var A;if(s===!1&&!e.preConsentBehavior){(A=m.current)==null||A.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Re?{sdk:Re}:{}),a=!1,l=null,y=null,x=R=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{a||(y=C(R,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:R})=>{a||(l=R(M(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=rn(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),j(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let A={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(R=>{var C;return{variantId:R.variantId,pulls:R.pulls,avgReward:(C=R.avgReward)!=null?C:0}})};Ye(x.componentId,A)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:vt).replace(/\/$/,""),u=Pe(null);j(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),j(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||it({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),j(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){_e(p);return}e.declaredSections&&e.declaredSections.length>0&&_e(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),j(()=>{if(!k())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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 g=pt(()=>t&&i?tt(t):t,[t,i]),b=pt(()=>{var p,a,l,y,x,A,R;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(A=e.initialPersona)!=null?A:null,apiBaseUrl:d,debug:(R=e.debug)!=null?R:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return un(L.Provider,{value:b,children:e.children})}function E(){return I(L).client}function N(){return I(L).apiKey}function Te(){return I(L).initialAssignments}function ae(){return I(L).sessionSegment}function yt(){return I(L).ssrFallback}function le(){return I(L).onAssignment}function St(){return I(L).debug}function ln(){let e=I(L).initialLayoutOrder,t=tn(F,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function ce(){return I(L).initialSlots}function ht(){return I(L).initialPersona}function bt(){return I(L).initialSlotConfig}function xt(){return I(L).initialPalette}function cn(){return I(L).apiBaseUrl}import{memo as kn,useEffect as Gn,useState as On}from"react";import{useCallback as gn,useEffect as H,useMemo as Ct,useRef as Q,useState as mn}from"react";import{attachMicroSignalDetectors as pn}from"@sentientui/core";import{useEffect as ue,useRef as wt,useState as dn,useSyncExternalStore as fn}from"react";import{pickFromWeights as De}from"@sentientui/policy";function Z(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 f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function Le(e,t,n,r){let i=Te(),f=yt(),c=E(),s=ae(),m=le(),o=St(),d=wt(null),u=fn(F,()=>Z(e),()=>null),g=u&&t.includes(u)?u:null,b=wt(null);ue(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=dn(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let A=i[e];return A&&t.includes(A)?{variantId:A,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=be(e);if(l){let A=De(l.variants,t);if(A)return{variantId:A,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return ue(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=be(e);if(l&&h.settled&&h.variantId&&h.variantId===De(l.variants,t)){p(h.variantId);return}v(x=>{var A;return x.variantId?x:{variantId:(A=t[0])!=null?A:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),ue(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),ue(()=>{if(!g&&c)return Ze(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=De(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function de(e,t,n){let r=E(),i=N(),f=Object.keys(t).join("\0"),c=Ct(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=Le(e,c,n.agentData,n.agentDataByVariant),[u,g]=mn(null),b=Q(null),h=gn(w=>{b.current=w,g(w)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=Ct(()=>v?B(v):null,[p]),l=v?K(v):"";H(()=>ut({id:e,variantIds:c,goal:l}),[e,c,l]);let y=Q(null);H(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,W(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=Q(!1),A=Q(new Set);H(()=>{x.current=!1,A.current=new Set},[s,a]);let R=n.funnel;H(()=>{o||!d||!r||!R||!a||z(r,i,e,R,a)},[r,i,e,R,a,o,d]);let C=n.cursorSignal===!0;H(()=>{if(!C||o||!d||!r||!s||!u)return;let w=null,_=0,P=()=>{_=Date.now(),w=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-_}}),w=null},800)},T=()=>{w!==null&&(clearTimeout(w),w=null)};return u.addEventListener("mouseenter",P),u.addEventListener("mouseleave",T),()=>{u.removeEventListener("mouseenter",P),u.removeEventListener("mouseleave",T),w!==null&&clearTimeout(w)}},[C,r,s,i,e,u,o,d]);let G=Q(n.microSignalGoals);G.current=n.microSignalGoals;let O=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return H(()=>{if(o||!d||!r||!s||!u)return;let w=Date.now();return pn((_,P={})=>{var Ke,We,Ue;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:_},P)});let T=(Ke=G.current)==null?void 0:Ke[_];if(!T||A.current.has(_))return;A.current.add(_);let J=typeof T=="string"?T:T.name,ne=typeof T=="string"?1:(We=T.weight)!=null?We:1,he=typeof T=="string"?0:(Ue=T.stepIndex)!=null?Ue:0;r.goal(J,{metadata:S({signalType:_},P),weight:ne,stepIndex:he})},u,w)},[r,s,i,e,u,O,o,d]),H(()=>{if(o||!d||!r||!s||!u||!a)return;let w=$(a);return V(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},w!==void 0?{goalValue:w}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},w!==void 0?{value:w}:{})))},fireStep:(_,P,T)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:_,payload:{reward:P}}),r.goal(_,{metadata:{},weight:P,stepIndex:T})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}import{useEffect as te,useMemo as Cn,useRef as Fe}from"react";import{containsFormBlock as An,reveal as _n}from"@sentientui/core";import{useCallback as vn,useEffect as At,useRef as yn,useSyncExternalStore as fe}from"react";import{armOfResult as Sn}from"@sentientui/core";var _t=new Set;function Rt(e,t){var p;let n=E(),r=yn(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=ce(),f=bt(),c=xt(),s=fe(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=fe(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":Sn(a),d=vn(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);fe(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),fe(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return At(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var A;return(A=n.cancelSlots)==null?void 0:A.call(n,[e])}},[n,v,h.source,e]),At(()=>{!k()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||_t.has(e)||(_t.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,h.source,e]),h}import{Fragment as kt}from"react";import{jsx as D,jsxs as Pt}from"react/jsx-runtime";var U={none:"0",sm:"8px",md:"16px",lg:"24px"},Ie={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Tt={sm:"0.875em",md:"1em",lg:"1.25em"},hn={sm:"1.25em",md:"1.5em",lg:"2em"},Gt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ot={sm:"8px",md:"16px",lg:"32px"},bn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},xn={normal:"400",medium:"500",bold:"700"};function Et(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Dt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return M(S({display:"inline-block",padding:(i=Gt[n!=null?n:"md"])!=null?i:Gt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Tt[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function wn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return Pt("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return Pt("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?D("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?D("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>D("option",{value:g,children:g},g))}):D("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),D("button",{type:"submit",style:Dt(n,t.palette),children:e.submitLabel})]})}function ee(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,A,R,C,G;try{switch(e.type){case"stack":{let O=(r=U[(n=e.gap)!=null?n:"md"])!=null?r:U.md,w=e.surface==="raised",_=(i=e.pad)!=null?i:w?"md":void 0;return D("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:O},e.align?{alignItems:Ie[e.align]}:{}),e.justify?{justifyContent:Ie[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),_?{padding:(f=U[_])!=null?f:U.md}:{}),w?M(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((P,T)=>{let J=ee(P,t);return J===null?null:D(kt,{children:J},T)})})}case"grid":{let O=(v=U[(h=e.gap)!=null?h:"md"])!=null?v:U.md;return D("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${O}) / ${e.columns})), 1fr))`,gap:O},e.align?{alignItems:Ie[e.align]}:{}),e.pad?{padding:(p=U[e.pad])!=null?p:U.md}:{}),children:((a=e.children)!=null?a:[]).map((w,_)=>{let P=ee(w,t);return P===null?null:D(kt,{children:P},_)})})}case"text":return D("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Tt[e.size]}:{}),e.weight?{fontWeight:xn[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Et(e.tone,t.palette)),children:e.value});case"heading":{let O=`h${e.level}`;return D(O,{style:S(S({margin:0,fontSize:hn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let O=(y=e.emphasis)!=null?y:"primary";return D("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Dt(O,t.palette,e.size),children:e.label}))}case"link":return D("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return D("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:bn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return D("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(A=(x=t.palette)==null?void 0:x.border)!=null?A:"currentColor"}`},Et(e.tone,t.palette)),children:e.value});case"spacer":return D("div",{style:{height:(R=Ot[e.size])!=null?R:Ot.md}});case"divider":return D("hr",{style:{border:"none",borderTop:`1px solid ${(G=(C=t.palette)==null?void 0:C.border)!=null?G:"currentColor"}`,margin:0,width:"100%"}});case"form":return D(wn,{node:e,opts:t});default:return null}}catch(O){return null}}import{jsx as Rn}from"react/jsx-runtime";var Lt=new Set;function Be({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var O;let c=E(),s=N(),m=Fe(null),{config:o,arm:d,palette:u,source:g}=Rt(e,{baselineText:f?()=>{var w,_;return(_=(w=m.current)==null?void 0:w.textContent)!=null?_:null}:void 0}),b=d!==""?(O=o==null?void 0:o.blocks)==null?void 0:O[d]:void 0,h=b!==void 0&&An(b)&&!n;te(()=>{!h||!k()||Lt.has(e)||(Lt.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.`))},[h,e]);let v=w=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,w),c.goal(w,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let w=h?null:ee(b,{palette:u,onFormSubmit:n,onFormGoal:v});w===null?a=!0:p=w}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";te(()=>q({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=Fe(null);te(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,W(c,s,e,d))},[c,s,e,d,g,a]);let x=g!=="none"&&g!=="seeded"&&!a,A=x?d:"",R=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);te(()=>{if(!c||!r||g==="override")return;let w=m.current;if(!w)return;let _=K(r),P=$(r),T=!1;return V(w,B(r),{fireGoal:()=>{T||(T=!0,x&&(P!==void 0?c.componentGoal(e,_,{value:P}):c.componentGoal(e,_)),c.goal(_,S({metadata:{componentId:e,arm:A},weight:1,stepIndex:0},P!==void 0?{value:P}:{})))},fireStep:(J,ne,he)=>{x&&c.componentGoal(e,J,{reward:ne}),c.goal(J,{metadata:{componentId:e,arm:A},weight:ne,stepIndex:he})}},_)},[c,e,R,d,g,a,x,A]);let C=Fe(null);te(()=>{let w=m.current;if(w){if(C.current===null){C.current=d;return}C.current!==d&&(C.current=d,_n(w))}},[d]);let G=Cn(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return Rn("div",M(S({ref:m,className:i},G),{children:p}))}import{jsx as Me}from"react/jsx-runtime";function En(e){var o;let{client:t,variantId:n,content:r,ref:i}=de(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=On(!1);if(Gn(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return k()&&s===null&&m===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.`),Me("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Pn=kn(En,(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.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)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 Tn(e){return e.variants===void 0?Me(Be,S({},e)):(k()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),Me(Pn,S({},e)))}import{useEffect as ge,useMemo as Dn,useRef as $e,useState as It,useSyncExternalStore as Ln}from"react";import{jsx as Fn}from"react/jsx-runtime";function In({id:e,default:t,component:n="span",className:r,goal:i}){var R;let f=E(),c=N(),s=le(),m=ae(),o=$e(null),d=$e(null),u=Ln(F,()=>Z(e),()=>null),[g,b]=It(()=>{var C,G;return(G=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.content)!=null?G:null}),[h,v]=It(()=>{var C,G;return(G=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.variantId)!=null?G:null});ge(()=>{if(u||!f)return;let C=f.getAssignment(e,m);if((C==null?void 0:C.content)!==void 0){v(C.variantId),b(C.content);return}let G=!1;return f.assign(e).then(O=>{if(!G){if(!O){k()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(O.variantId),O.content&&b(O.content)}}),()=>{G=!0}},[f,e,m,u]),ge(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=Dn(()=>i===void 0?null:B(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=$e(!1);ge(()=>{y.current=!1},[h,p]),ge(()=>{if(u||!f||!h||!c||!a||!l)return;let C=d.current;if(!C)return;let G=$(a);return V(C,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},G!==void 0?{goalValue:G}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},G!==void 0?{value:G}:{})))},fireStep:(O,w,_)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:O,payload:{reward:w}}),f.goal(O,{metadata:{},weight:w,stepIndex:_})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let C=f==null?void 0:f.getAssignment(e,m);x=C&&C.variantId===u&&(R=C.content)!=null?R:t}return Fn(n,{ref:C=>{d.current=C},className:r,children:x})}import{useCallback as Bn,useRef as Mn}from"react";function Ve(e){let t=E(),n=Mn(new Set);return Bn((r,i)=>{var f,c;if(!Z(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,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as $n,useRef as Ft}from"react";function Vn(e,t={}){let m=t,{componentId:n}=m,r=ze(m,["componentId"]),i=E(),f=Ve(n!=null?n:""),c=Ft(!1),s=Ft(r);s.current=r,$n(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}import{renderPrePaintScript as Nn}from"@sentientui/core";import{confidenceBand as jn}from"@sentientui/policy";import{jsx as Un}from"react/jsx-runtime";function Bt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Kn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Bt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Bt(jn(e.persona.confidence))+");}catch(e){}})();":Nn(e.apiKey)}function Wn(e){return Un("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Kn(e)}})}import{useEffect as ve,useMemo as je,useRef as Yn}from"react";import{validateSlotDecl as Qn}from"@sentientui/policy";import{useEffect as Ne,useReducer as Jn,useState as Xn,useSyncExternalStore as Mt}from"react";import{armOfResult as me,baselineResultFor as Hn}from"@sentientui/core";import{confidenceBand as zn}from"@sentientui/policy";function pe(e,t){let n=E(),r=ce(),[,i]=Jn(u=>u+1,0),f=Mt(F,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;Ne(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:me(f),source:"override"};if(c!==void 0)return{result:c,arm:me(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:me(s),source:g?"client":"seeded"}}let u=Hn(t);return{result:u,arm:me(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return Ne(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function qn(){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 Zn(){let e=E(),t=ht();Mt(F,nt,()=>0);let[n,r]=Xn(!1);Ne(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:zn(s.confidence)});if(!n)return t?i(t):null;let f=qn();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var $t=new Set;function er(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tr(e,t,n){let r=E(),i=N(),f=JSON.stringify(t),c=je(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=pe(e,c),d=je(()=>typeof s=="string"?{}:s,[m]);if(k()&&!$t.has(e)){$t.add(e);let v=Qn({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} 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 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);ve(()=>q({id:e,dims:t}),[e]);let g=Yn(null);ve(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,W(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;ve(()=>{var v;!r||!b||o==="override"||z(r,i,e,b,B((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),ve(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${er(e)}"]`);if(!v){k()&&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 p=K(n.goal),a=$(n.goal),l=!1;return V(v,B(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,A)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:A})}},p)},[r,e,u,m,o]);let h=je(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}import{useCallback as nr,useEffect as rr,useMemo as ir}from"react";var Vt=new Set;function or(e,t){var b;if(k()&&!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:f,goalLabel:c,ref:s,nodeRef:m}=de(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];rr(()=>{if(!k()||!n)return;let h=setTimeout(()=>{!m.current&&!Vt.has(e)&&(Vt.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 u=nr((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l: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,c,f]),g=ir(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}import{Children as sr,isValidElement as ar,useEffect as ye,useMemo as Nt,useRef as jt}from"react";import{jsx as cr}from"react/jsx-runtime";var Se=new Set;function lr(e){var a;let t=E(),n=N(),r=jt(null),i=Object.keys(e.arrangements).join(" "),f=Nt(()=>Object.keys(e.arrangements),[i]),c=Nt(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=pe(e.id,c);k()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Se.has(e.id+":baseline")&&(Se.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=sr.toArray(e.children).filter(ar),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));k()&&u!==void 0&&!g&&!Se.has(e.id+":keys")&&(Se.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;ye(()=>q({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=jt(null);ye(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,W(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;ye(()=>{var l;!t||!v||m==="override"||z(t,n,e.id,v,B((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ye(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=K(e.goal),x=$(e.goal),A=!1;return V(l,B(e.goal),{fireGoal:()=>{A||(A=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(R,C,G)=>{t.componentGoal(e.id,R,{reward:C}),t.goal(R,{metadata:{componentId:e.id,arm:s},weight:C,stepIndex:G})}},y)},[t,e.id,p,s,m]),cr("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}import{deriveSessionSegment as ur}from"@sentientui/core";var dr=["page","blocks","layoutOrder"],Kt=new Map;function fr(e,t){Kt.set(e,t)}function Wt(e){return Kt.get(e)}function gr(e){var i,f;let t=(f=(i=e.content)!=null?i:Wt(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))dr.includes(c)||(n[c]=s);let r=M(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function mr(e){return`<script type="application/ld+json">${Ut(e)}</script>`}function Ut(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function pr(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 Zo}from"@sentientui/core";export{Tn as Adaptive,lr as AdaptiveGroup,an as AdaptiveProvider,Be as AdaptiveSlot,In as AdaptiveText,Wn as SentientPersonaScript,gr as buildAgentFeed,fr as defineAgentContent,ur as detectSegment,Wt as getAgentContent,Zo as grantConsent,mr as renderAgentJsonLd,Ut as renderAgentJsonLdBody,pr as renderAgentMarkdown,ee as renderBlocks,or as useAdaptive,cn as useAdaptiveApiBaseUrl,Ve as useAdaptiveGoal,Zn as useAdaptivePersona,tr as useAdaptiveTokens,Le as useAssignment,Te as useInitialAssignments,ln as useLayoutOrder,Vn as usePageGoal,E as useSentient};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/testing/react.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),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 ye="sentient:overrides-changed";function x(){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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){if(typeof window=="undefined")return Se;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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.34.3",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",W="sentient-cell-preview-bar",T="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.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 g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[T]:c.blocks}}),G(i,T);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,T);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,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 s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.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"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var M,K;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(m,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",d=((K=e.apiBaseUrl)!=null?K:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` 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,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).join(", ")} ${a.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 w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;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:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
|
|
2
|
+
"use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),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 ye="sentient:overrides-changed";function x(){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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){if(typeof window=="undefined")return Se;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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.34.4",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",W="sentient-cell-preview-bar",T="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.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 g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[T]:c.blocks}}),G(i,T);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,T);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,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 s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.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"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var M,K;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(m,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",d=((K=e.apiBaseUrl)!=null?K:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` 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,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).join(", ")} ${a.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 w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;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:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{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 te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as W,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),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 ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.34.3",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",T="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(T))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.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 l=await f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(T))return;let t=document.createElement("div");t.id=T,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=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=W(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var M,K;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=W(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",c=((K=e.apiBaseUrl)!=null?K:Y).replace(/\/$/,""),h=W(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` 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,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.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 w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",consent:!1,children:e}),n)}export{at as renderWithSentient};
|
|
2
|
+
var te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as W,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),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 ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.34.4",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",T="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(T))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.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 l=await f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(T))return;let t=document.createElement("div");t.id=T,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=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=W(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var M,K;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=W(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",c=((K=e.apiBaseUrl)!=null?K:Y).replace(/\/$/,""),h=W(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` 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,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.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 w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",consent:!1,children:e}),n)}export{at 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.34.
|
|
3
|
+
"version": "0.34.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
],
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@sentientui/policy": "0.12.0",
|
|
79
|
-
"@sentientui/core": "0.
|
|
79
|
+
"@sentientui/core": "0.33.0"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@testing-library/react": ">=14.0.0",
|