@sentientui/react 0.29.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +19 -4
- package/dist/index.d.ts +19 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.js.map +1 -1
- package/dist/testing/react.mjs +1 -1
- package/dist/testing/react.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, JSX } from 'react';
|
|
3
|
-
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions } from '@sentientui/core';
|
|
4
|
-
export { deriveSessionSegment as detectSegment, grantConsent } from '@sentientui/core';
|
|
3
|
+
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions, BlockNode } from '@sentientui/core';
|
|
4
|
+
export { SitePalette, deriveSessionSegment as detectSegment, grantConsent } from '@sentientui/core';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
/** How to render adaptive slots during SSR when assignments are not preloaded. */
|
|
@@ -505,6 +505,11 @@ type AdaptiveSlotProps = {
|
|
|
505
505
|
* shape as AdaptiveGroup's. Form arms fire their own submitGoal regardless. */
|
|
506
506
|
goal?: string | GoalConfig;
|
|
507
507
|
className?: string;
|
|
508
|
+
/** On first registration the SDK sends the region's rendered text (capped at
|
|
509
|
+
* 400 chars) so dashboard-generated versions are grounded in what they
|
|
510
|
+
* replace. Set false for a slot wrapping personalized or account content —
|
|
511
|
+
* the text of THIS region is all that is ever read, never the page. */
|
|
512
|
+
reportBaselineText?: boolean;
|
|
508
513
|
};
|
|
509
514
|
/**
|
|
510
515
|
* A region whose content the server may replace with a named arm — a copy
|
|
@@ -513,7 +518,7 @@ type AdaptiveSlotProps = {
|
|
|
513
518
|
* traffic, unserved slots, and every error path, so the worst case is always
|
|
514
519
|
* "nothing changed" (spec 2026-09-08 empty-cell-generation §3).
|
|
515
520
|
*/
|
|
516
|
-
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className }: AdaptiveSlotProps): JSX.Element;
|
|
521
|
+
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
517
522
|
|
|
518
523
|
type UseAdaptiveBind = {
|
|
519
524
|
ref: (el: HTMLElement | null) => void;
|
|
@@ -674,4 +679,14 @@ declare function renderAgentJsonLdBody(feed: AgentFeed): string;
|
|
|
674
679
|
/** Render the feed as Markdown for agents that negotiate `text/markdown`. */
|
|
675
680
|
declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
676
681
|
|
|
677
|
-
|
|
682
|
+
type RenderBlocksOptions = {
|
|
683
|
+
palette: SitePalette | null;
|
|
684
|
+
/** Absent handler = form trees must not reach this function (AdaptiveSlot gates). */
|
|
685
|
+
onFormSubmit?: (values: Record<string, string>) => void;
|
|
686
|
+
/** Fired with the form's submitGoal when a rendered form submits. */
|
|
687
|
+
onFormGoal?: (goal: string) => void;
|
|
688
|
+
};
|
|
689
|
+
/** Render one validated block tree as JSX. Null for anything unrenderable — fail-safe. */
|
|
690
|
+
declare function renderBlocks(node: BlockNode, opts: RenderBlocksOptions): JSX.Element | null;
|
|
691
|
+
|
|
692
|
+
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode, JSX } from 'react';
|
|
3
|
-
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions } from '@sentientui/core';
|
|
4
|
-
export { deriveSessionSegment as detectSegment, grantConsent } from '@sentientui/core';
|
|
3
|
+
import { SentientConfig, SlotResult, SlotConfigEntry, SitePalette, SentientClient, MicroSignalType, ComponentGoalOptions, BlockNode } from '@sentientui/core';
|
|
4
|
+
export { SitePalette, deriveSessionSegment as detectSegment, grantConsent } from '@sentientui/core';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
/** How to render adaptive slots during SSR when assignments are not preloaded. */
|
|
@@ -505,6 +505,11 @@ type AdaptiveSlotProps = {
|
|
|
505
505
|
* shape as AdaptiveGroup's. Form arms fire their own submitGoal regardless. */
|
|
506
506
|
goal?: string | GoalConfig;
|
|
507
507
|
className?: string;
|
|
508
|
+
/** On first registration the SDK sends the region's rendered text (capped at
|
|
509
|
+
* 400 chars) so dashboard-generated versions are grounded in what they
|
|
510
|
+
* replace. Set false for a slot wrapping personalized or account content —
|
|
511
|
+
* the text of THIS region is all that is ever read, never the page. */
|
|
512
|
+
reportBaselineText?: boolean;
|
|
508
513
|
};
|
|
509
514
|
/**
|
|
510
515
|
* A region whose content the server may replace with a named arm — a copy
|
|
@@ -513,7 +518,7 @@ type AdaptiveSlotProps = {
|
|
|
513
518
|
* traffic, unserved slots, and every error path, so the worst case is always
|
|
514
519
|
* "nothing changed" (spec 2026-09-08 empty-cell-generation §3).
|
|
515
520
|
*/
|
|
516
|
-
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className }: AdaptiveSlotProps): JSX.Element;
|
|
521
|
+
declare function AdaptiveSlot({ id, children, onFormSubmit, goal, className, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
|
|
517
522
|
|
|
518
523
|
type UseAdaptiveBind = {
|
|
519
524
|
ref: (el: HTMLElement | null) => void;
|
|
@@ -674,4 +679,14 @@ declare function renderAgentJsonLdBody(feed: AgentFeed): string;
|
|
|
674
679
|
/** Render the feed as Markdown for agents that negotiate `text/markdown`. */
|
|
675
680
|
declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
676
681
|
|
|
677
|
-
|
|
682
|
+
type RenderBlocksOptions = {
|
|
683
|
+
palette: SitePalette | null;
|
|
684
|
+
/** Absent handler = form trees must not reach this function (AdaptiveSlot gates). */
|
|
685
|
+
onFormSubmit?: (values: Record<string, string>) => void;
|
|
686
|
+
/** Fired with the form's submitGoal when a rendered form submits. */
|
|
687
|
+
onFormGoal?: (goal: string) => void;
|
|
688
|
+
};
|
|
689
|
+
/** Render one validated block tree as JSX. Null for anything unrenderable — fail-safe. */
|
|
690
|
+
declare function renderBlocks(node: BlockNode, opts: RenderBlocksOptions): JSX.Element | null;
|
|
691
|
+
|
|
692
|
+
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptivePersona, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveSlot, type AdaptiveSlotProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type PageGoalOptions, type RenderBlocksOptions, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, renderBlocks, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptivePersona, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, usePageGoal, useSentient };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Yt=Object.create;var ie=Object.defineProperty,en=Object.defineProperties,tn=Object.getOwnPropertyDescriptor,nn=Object.getOwnPropertyDescriptors,rn=Object.getOwnPropertyNames,ae=Object.getOwnPropertySymbols,on=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var Be=(e,t,n)=>t in e?ie(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)&&Be(e,n,t[n]);if(ae)for(var n of ae(t))Me.call(t,n)&&Be(e,n,t[n]);return e},J=(e,t)=>en(e,nn(t));var Ke=(e,t)=>{var n={};for(var r in e)xe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ae)for(var r of ae(e))t.indexOf(r)<0&&Me.call(e,r)&&(n[r]=e[r]);return n};var sn=(e,t)=>{for(var n in t)ie(e,n,{get:t[n],enumerable:!0})},je=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rn(t))!xe.call(e,o)&&o!==n&&ie(e,o,{get:()=>t[o],enumerable:!(r=tn(t,o))||r.enumerable});return e};var Ne=(e,t,n)=>(n=e!=null?Yt(on(e)):{},je(t||!e||!e.__esModule?ie(n,"default",{value:e,enumerable:!0}):n,e)),an=e=>je(ie({},"__esModule",{value:!0}),e);var xn={};sn(xn,{Adaptive:()=>mt,AdaptiveGroup:()=>Ut,AdaptiveProvider:()=>it,AdaptiveSlot:()=>jt,AdaptiveText:()=>vt,SentientPersonaScript:()=>xt,buildAgentFeed:()=>zt,defineAgentContent:()=>Xt,detectSegment:()=>Pe.deriveSessionSegment,getAgentContent:()=>Ie,grantConsent:()=>Qt.grantConsent,renderAgentJsonLd:()=>qt,renderAgentJsonLdBody:()=>Le,renderAgentMarkdown:()=>Zt,useAdaptive:()=>Wt,useAdaptiveApiBaseUrl:()=>dt,useAdaptiveGoal:()=>ye,useAdaptivePersona:()=>Rt,useAdaptiveTokens:()=>Ot,useAssignment:()=>re,useInitialAssignments:()=>de,useLayoutOrder:()=>at,usePageGoal:()=>St,useSentient:()=>O});module.exports=an(xn);var _=require("react"),ce=require("@sentientui/core");var $e=new Map,le=new Map;function Ve(e,t){let n=le.get(e);return n||(n=new Set,le.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&le.delete(e)}}function We(e,t){$e.set(e,t);let n=le.get(e);if(n)for(let r of n)try{r(t)}catch(o){}}function Ae(e){var t;return(t=$e.get(e))!=null?t:null}var ln={on:!1,listeners:new Set};function Ue(){if(typeof window=="undefined")return ln;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Ce(){return Ue().on}function Je(e){let t=Ue().listeners;return t.add(e),()=>{t.delete(e)}}function He(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,o)=>e.assign(t,n,r,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Xe="sentient:overrides-changed";function ze(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function M(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Xe,e),()=>window.removeEventListener(Xe,e))}function qe(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 F(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function K(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ke=new Set,Re=!1;function Ze(e){if(ke.has(e))return!0;if(ke.add(e),!Re){Re=!0;let t=()=>{Re=!1,ke.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 un(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Qe(e,t,n){if(n){try{let o=e;for(;o&&o!==t;){if(o.matches(n))return!0;o=o.parentElement}}catch(o){}return!1}let r=e;for(;r&&r!==t;){if(un(r))return!0;r=r.parentElement}return!1}function j(e,t,n,r){if(t.type==="weighted_composite"){let l=new Set,d=[];return t.steps.forEach(({goal:f,name:p,weight:h},b)=>{let y=(c=!1)=>{l.has(b)||c&&r!==void 0&&Ze(`step\0${p}\0${h}\0${b}`)||(l.add(b),n.fireStep(p,h,b))};if(f.type==="click"){let c=u=>{let g=u.target;g instanceof Element&&Qe(g,e,f.selector)&&y()};e.addEventListener("click",c),d.push(()=>e.removeEventListener("click",c));return}if(f.type==="form_submit"){let c=u=>{u.target instanceof HTMLFormElement&&e.contains(u.target)&&y()};e.addEventListener("submit",c),d.push(()=>e.removeEventListener("submit",c));return}if(f.type==="scroll_depth"){let c=Math.max(0,Math.min(1,f.threshold)),u=new IntersectionObserver(g=>{for(let v of g)if(v.intersectionRatio>=c){y(!0),u.disconnect();break}},{threshold:[c]});u.observe(e),d.push(()=>u.disconnect())}}),()=>{for(let f of d)f()}}let o=t.type==="composite"?t.all:[t],i=new Set(o.map((l,d)=>d)),m=()=>{r!==void 0&&Ze(r)||n.fireGoal()},s=(l,d=!1)=>{i.delete(l),i.size===0&&(d?m():n.fireGoal())},a=[];return o.forEach((l,d)=>{if(l.type==="click"){let f=p=>{let h=p.target;h instanceof Element&&Qe(h,e,l.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",f),a.push(()=>e.removeEventListener("click",f));return}if(l.type==="form_submit"){let f=p=>{p.target instanceof HTMLFormElement&&e.contains(p.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",f),a.push(()=>e.removeEventListener("submit",f));return}if(l.type==="scroll_depth"){let f=Math.max(0,Math.min(1,l.threshold)),p=new IntersectionObserver(h=>{for(let b of h)if(b.intersectionRatio>=f){t.type==="composite"?s(d,!0):m(),p.disconnect();break}},{threshold:[f]});p.observe(e),a.push(()=>p.disconnect());return}}),()=>{for(let l of a)l()}}var Ye=new Set,et=new Set;function Z(e,t,n,r,o){let i=`${r}|${n}`;if(et.has(i))return;et.add(i);let m=o.type==="weighted_composite"&&!Ye.has(r);m&&Ye.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:m?{funnelId:r,steps:o.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function H(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 Q(){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 oe(){Q().version+=1;for(let e of Q().listeners)e()}var tt=()=>{};function ue(e){return G()?(Q().components.set(e.id,e),oe(),()=>{Q().components.delete(e.id),oe()}):tt}function te(e){return G()?(Q().slots.set(e.id,e),oe(),()=>{Q().slots.delete(e.id),oe()}):tt}function _e(e){G()&&(Q().sections=[...e],oe())}var nt="0.29.0",Ge=nt!=="0.0.0-dev"?{name:"react",version:nt}:void 0;var ft=require("react/jsx-runtime");function dn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,ce.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var rt="https://api.sentient-ui.com/v1",B=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:rt,debug:!1});function fn(e){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(e);r.current=e;let{cookie:o,value:i,event:m}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,_.useEffect)(()=>{let a=()=>{var p;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let f=`${d.cookie}=${(p=d.value)!=null?p:"accepted"}`;return document.cookie.split("; ").some(h=>h.trim()===f)};if(n(a()),!m)return;let l=()=>{n(a())};return window.addEventListener(m,l),()=>window.removeEventListener(m,l)},[o,i,m,s]),t}function it(e){var b,y;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var c;return(c=e.sessionSegment)!=null?c:dn()}),[o,i]=(0,_.useState)(Ce());(0,_.useEffect)(()=>Je(()=>i(Ce())),[]);let m=fn(e.consentFrom),s=e.consentFrom?e.consent===!0||m:e.consent,a=(0,_.useRef)(null);(0,_.useEffect)(()=>{var k;if(s===!1&&!e.preConsentBehavior){(k=a.current)==null||k.destroy(),a.current=null,n(null);return}let c=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},Ge?{sdk:Ge}:{}),u=!1,g=null,v=null,C=R=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:x})=>{u||(v=x(R,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:R})=>{u||(g=R(J(S({},c),{graph:!0,captureDomText:e.captureDomText===!0})),a.current=g,n(g),C(g))}):(g=(0,ce.init)(c),a.current=g,n(g),C(g)),()=>{u=!0,v==null||v(),g==null||g.dispose()}},[s]),(0,_.useEffect)(()=>{if(!t)return;let c=!1,u=async()=>{if(c)return;let v;try{v=await t.fetchWeights()}catch(C){return}if(!c)for(let C of v){let k={componentId:C.componentId,updatedAt:C.updatedAt,variants:C.variants.map(R=>{var x;return{variantId:R.variantId,pulls:R.pulls,avgReward:(x=R.avgReward)!=null?x:0}})};We(C.componentId,k)}};u();let g=setInterval(()=>{u()},6e4);return()=>{c=!0,clearInterval(g)}},[t]);let l=(b=e.ssrFallback)!=null?b:"first",d=((y=e.apiBaseUrl)!=null?y:rt).replace(/\/$/,""),f=(0,_.useRef)(null);(0,_.useEffect)(()=>{var g;if(typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production")return;let c={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=f.current;if(f.current=c,u!==null)for(let v of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[v],c[v])||console.warn(`[sentient] AdaptiveProvider: \`${v}\` 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,_.useEffect)(()=>{var c;typeof process!="undefined"&&((c=process.env)==null?void 0:c.NODE_ENV)==="production"||qe({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,_.useEffect)(()=>{let c=e.initialLayoutOrder;if(c&&c.length>0){_e(c);return}e.declaredSections&&e.declaredSections.length>0&&_e(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{if(!G())return;let c=e.declaredSections;if(!c||c.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),v=>v.getAttribute("data-sentient-id"))),g=c.filter(v=>!u.has(v));g.length>0&&console.warn(`[SentientUI] Declared section${g.length>1?"s":""} ${g.map(v=>`"${v}"`).join(", ")} ${g.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>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let p=(0,_.useMemo)(()=>t&&o?He(t):t,[t,o]),h=(0,_.useMemo)(()=>{var c,u,g,v,C,k,R;return{client:p,apiKey:e.apiKey,initialAssignments:(c=e.initialAssignments)!=null?c:{},sessionSegment:r,ssrFallback:l,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(g=e.initialSlots)!=null?g:{},initialSlotConfig:(v=e.initialSlotConfig)!=null?v:{},initialPalette:(C=e.initialPalette)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:d,debug:(R=e.debug)!=null?R:!1}},[p,e.apiKey,e.initialAssignments,r,l,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ft.jsx)(B.Provider,{value:h,children:e.children})}function O(){return(0,_.useContext)(B).client}function N(){return(0,_.useContext)(B).apiKey}function de(){return(0,_.useContext)(B).initialAssignments}function fe(){return(0,_.useContext)(B).sessionSegment}function ot(){return(0,_.useContext)(B).ssrFallback}function ge(){return(0,_.useContext)(B).onAssignment}function st(){return(0,_.useContext)(B).debug}function at(){let e=(0,_.useContext)(B).initialLayoutOrder,t=(0,_.useSyncExternalStore)(M,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function me(){return(0,_.useContext)(B).initialSlots}function lt(){return(0,_.useContext)(B).initialPersona}function ut(){return(0,_.useContext)(B).initialSlotConfig}function ct(){return(0,_.useContext)(B).initialPalette}function dt(){return(0,_.useContext)(B).apiBaseUrl}var E=require("react"),gt=require("@sentientui/core");var $=require("react"),pe=require("@sentientui/policy");function ne(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 o of r.getAll("sentient_variant")){let i=o.indexOf(":");if(i!==-1&&o.slice(0,i)===e)return o.slice(i+1)}}catch(r){}return null}function re(e,t,n,r){let o=de(),i=ot(),m=O(),s=fe(),a=ge(),l=st(),d=(0,$.useRef)(null),f=(0,$.useSyncExternalStore)(M,()=>ne(e),()=>null),p=f&&t.includes(f)?f:null,h=(0,$.useRef)(null);(0,$.useEffect)(()=>{l&&p&&h.current!==p&&(h.current=p,console.info(`[sentient] override active: ${e} -> ${p}`))},[l,p,e]);let[b,y]=(0,$.useState)(()=>{var v,C;if(p)return{variantId:p,content:null,isLoading:!1,settled:!0};if(!m){let k=o[e];return k&&t.includes(k)?{variantId:k,content:null,isLoading:!1,settled:!0}:i==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let u=m.getAssignment(e,s);if(u&&(t.includes(u.variantId)||u.content))return{variantId:u.variantId,content:(v=u.content)!=null?v:null,isLoading:!1,settled:!0};let g=Ae(e);if(g){let k=(0,pe.pickFromWeights)(g.variants,t);if(k)return{variantId:k,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),c=u=>{a&&d.current!==u&&(d.current=u,a(e,u))};return(0,$.useEffect)(()=>{var v;if(p||!m)return;let u=m.getAssignment(e,s);if(u&&(t.includes(u.variantId)||u.content)){y({variantId:u.variantId,content:(v=u.content)!=null?v:null,isLoading:!1,settled:!0}),c(u.variantId);return}let g=Ae(e);if(g&&b.settled&&b.variantId&&b.variantId===(0,pe.pickFromWeights)(g.variants,t)){c(b.variantId);return}y(C=>{var k;return C.variantId?C:{variantId:(k=t[0])!=null?k:null,content:null,isLoading:!1,settled:!1}})},[p,m,e,s]),(0,$.useEffect)(()=>{if(p||!m)return;let u=m.getAssignment(e,s);if(u&&t.includes(u.variantId))return;let g=!1;return m.assign(e,t,n,r).then(v=>{var C;g||v&&(!t.includes(v.variantId)&&!v.content||(y({variantId:v.variantId,content:(C=v.content)!=null?C:null,isLoading:!1,settled:!0}),c(v.variantId)))}),()=>{g=!0}},[p,m,e,s]),(0,$.useEffect)(()=>{if(!p&&m)return Ve(e,u=>{var C;let g=m.getAssignment(e,s);if(g&&(t.includes(g.variantId)||g.content)){y({variantId:g.variantId,content:(C=g.content)!=null?C:null,isLoading:!1,settled:!0}),c(g.variantId);return}let v=(0,pe.pickFromWeights)(u.variants,t);v&&(y({variantId:v,content:null,isLoading:!1,settled:!0}),c(v))})},[p,m,e,s]),p?{variantId:p,content:null,isLoading:!1,settled:!0,isOverride:!0}:b}var pt=require("react/jsx-runtime");function gn(e){var C;let t=O(),n=N(),r=Object.keys(e.variants).join("\0"),o=(0,E.useMemo)(()=>Object.keys(e.variants),[r]),{variantId:i,content:m,isOverride:s,settled:a}=re(e.id,o,e.agentData,e.agentDataByVariant),l=(0,E.useRef)(null),[d,f]=(0,E.useState)(!1);(0,E.useEffect)(()=>{f(!0)},[]);let p=(0,E.useRef)(!1),h=(0,E.useRef)(new Set),b=(0,E.useRef)(null),y=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),c=(0,E.useMemo)(()=>F(e.goal),[y]),u=typeof e.goal=="string"?e.goal:c.type;if((0,E.useEffect)(()=>ue({id:e.id,variantIds:o,goal:u}),[e.id,o,u]),(0,E.useEffect)(()=>{s||a&&(!t||!i||!n||b.current!==i&&(b.current=i,H(t,n,e.id,i)))},[t,i,n,e.id,s,a]),(0,E.useEffect)(()=>{p.current=!1,h.current=new Set},[i,c]),(0,E.useEffect)(()=>{s||!a||!t||!e.funnel||Z(t,n,e.id,e.funnel,c)},[t,n,e.id,e.funnel,c,s,a]),(0,E.useEffect)(()=>{if(s||!a||!t||!i)return;let k=l.current;if(!k)return;let R=null,x=0,A=()=>{x=Date.now(),R=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-x}}),R=null},800)},w=()=>{R!==null&&(clearTimeout(R),R=null)};return k.addEventListener("mouseenter",A),k.addEventListener("mouseleave",w),()=>{k.removeEventListener("mouseenter",A),k.removeEventListener("mouseleave",w),R!==null&&clearTimeout(R)}},[t,i,n,e.id,s,a]),(0,E.useEffect)(()=>{if(s||!a||!t||!i)return;let k=l.current;if(!k)return;let R=Date.now();return(0,gt.attachMicroSignalDetectors)((x,A={})=>{var De,Te,Fe;t.track({projectId:n,componentId:e.id,variantId:i,eventType:"micro_signal",payload:S({signalType:x},A)});let w=(De=e.microSignalGoals)==null?void 0:De[x];if(!w||h.current.has(x))return;h.current.add(x);let L=typeof w=="string"?w:w.name,V=typeof w=="string"?1:(Te=w.weight)!=null?Te:1,ee=typeof w=="string"?0:(Fe=w.stepIndex)!=null?Fe:0;t.goal(L,{metadata:S({signalType:x},A),weight:V,stepIndex:ee})},k,R)},[t,i,n,e.id,e.microSignalGoals,s,a]),(0,E.useEffect)(()=>{if(s||!a||!t||!i)return;let k=l.current;if(!k)return;let R=K(c);return j(k,c,{fireGoal:()=>{p.current||(p.current=!0,t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:u,payload:S({reward:1},R!==void 0?{goalValue:R}:{})}),t.goal(u,S({metadata:{componentId:e.id,variantId:i},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(x,A,w)=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:x,payload:{reward:A}}),t.goal(x,{metadata:{},weight:A,stepIndex:w})}},u)},[t,i,n,e.id,c,u,s,a]),e.clientOnly&&(!d||!t)||!i)return null;let g=(C=e.variants[i])!=null?C:null,v=g===null?m:null;return G()&&g===null&&v===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${i}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,pt.jsx)("div",{ref:l,"data-sentient-id":e.id,"data-sentient-variant":i,children:g!=null?g:v})}var mt=(0,E.memo)(gn,(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(o=>o in t.variants&&Object.is(e.variants[o],t.variants[o]))});var D=require("react");var yt=require("react/jsx-runtime");function vt({id:e,default:t,component:n="span",className:r,goal:o}){var R;let i=O(),m=N(),s=ge(),a=fe(),l=(0,D.useRef)(null),d=(0,D.useRef)(null),f=(0,D.useSyncExternalStore)(M,()=>ne(e),()=>null),[p,h]=(0,D.useState)(()=>{var x,A;return(A=(x=i==null?void 0:i.getAssignment(e,a))==null?void 0:x.content)!=null?A:null}),[b,y]=(0,D.useState)(()=>{var x,A;return(A=(x=i==null?void 0:i.getAssignment(e,a))==null?void 0:x.variantId)!=null?A:null});(0,D.useEffect)(()=>{if(f||!i)return;let x=i.getAssignment(e,a);if((x==null?void 0:x.content)!==void 0){y(x.variantId),h(x.content);return}let A=!1;return i.assign(e).then(w=>{if(!A){if(!w){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(w.variantId),w.content&&h(w.content)}}),()=>{A=!0}},[i,e,a,f]),(0,D.useEffect)(()=>{f||!i||!b||!m||l.current!==b&&(l.current=b,i.track({projectId:m,componentId:e,variantId:b,eventType:"variant_assigned",payload:{}}),s==null||s(e,b))},[i,b,m,e,s,f]);let c=o===void 0?"":typeof o=="string"?o:JSON.stringify(o),u=(0,D.useMemo)(()=>o===void 0?null:F(o),[c]),g=o===void 0?null:typeof o=="string"?o:u.type,v=(0,D.useRef)(!1);(0,D.useEffect)(()=>{v.current=!1},[b,c]),(0,D.useEffect)(()=>{if(f||!i||!b||!m||!u||!g)return;let x=d.current;if(!x)return;let A=K(u);return j(x,u,{fireGoal:()=>{v.current||(v.current=!0,i.track({projectId:m,componentId:e,variantId:b,eventType:"goal_achieved",goalType:g,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),i.goal(g,S({metadata:{componentId:e,variantId:b},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(w,L,V)=>{i.track({projectId:m,componentId:e,variantId:b,eventType:"goal_achieved",goalType:w,payload:{reward:L}}),i.goal(w,{metadata:{},weight:L,stepIndex:V})}})},[i,b,m,e,u,g,f]);let C=p!=null?p:t;if(f){let x=i==null?void 0:i.getAssignment(e,a);C=x&&x.variantId===f&&(R=x.content)!=null?R:t}return(0,yt.jsx)(n,{ref:x=>{d.current=x},className:r,children:C})}var ve=require("react");function ye(e){let t=O(),n=(0,ve.useRef)(new Set);return(0,ve.useCallback)((r,o)=>{var i,m;if(!ne(e)){if(o!=null&&o.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,o),t==null||t.goal(r,S(S(S({metadata:(i=o==null?void 0:o.metadata)!=null?i:{},weight:(m=o==null?void 0:o.reward)!=null?m:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{}))}},[t,e])}var se=require("react");function St(e,t={}){let a=t,{componentId:n}=a,r=Ke(a,["componentId"]),o=O(),i=ye(n!=null?n:""),m=(0,se.useRef)(!1),s=(0,se.useRef)(r);s.current=r,(0,se.useEffect)(()=>{if(!o||m.current)return;m.current=!0;let{metadata:l,reward:d,value:f,currency:p,externalId:h}=s.current;if(n){i(e,s.current);return}o.goal(e,S(S(S({metadata:l!=null?l:{},weight:d!=null?d:1,stepIndex:0},f!==void 0?{value:f}:{}),p!==void 0?{currency:p}:{}),h!==void 0?{externalId:h}:{}))},[o,n,e,i])}var bt=require("@sentientui/core"),wt=require("@sentientui/policy"),At=require("react/jsx-runtime");function ht(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function mn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+ht(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+ht((0,wt.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,bt.renderPrePaintScript)(e.apiKey)}function xt(e){return(0,At.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:mn(e)}})}var U=require("react"),Gt=require("@sentientui/policy");var W=require("react"),Y=require("@sentientui/core"),kt=require("@sentientui/policy");var Ct=new Set;function Se(e,t){let n=O(),r=me(),[,o]=(0,W.useReducer)(d=>d+1,0),i=(0,W.useSyncExternalStore)(M,()=>{var d;return typeof window!="undefined"?(d=window.__sentient_slot_overrides)==null?void 0:d[e]:void 0},()=>{}),m=i===void 0?r[e]:void 0,s=i===void 0&&m===void 0&&n?n.getSlotResult(e):null,a=(n==null?void 0:n.isLocal)===!0&&i===void 0&&m===void 0&&s===null;(0,W.useEffect)(()=>{if(!a||!n)return;let d=!1;return n.decide({slots:[t]}).then(f=>{!d&&f&&o()}),()=>{d=!0}},[n,e,a]);let l=(()=>{if(i!==void 0)return{result:i,arm:(0,Y.armOfResult)(i),source:"override"};if(m!==void 0)return{result:m,arm:(0,Y.armOfResult)(m),source:"preloaded"};if(s!==null)return{result:s,arm:(0,Y.armOfResult)(s),source:"client"};let d=(0,Y.baselineResultFor)(t);return{result:d,arm:(0,Y.armOfResult)(d),source:"baseline"}})();return(0,W.useEffect)(()=>{G()&&(!n||n.isLocal===!0||l.source==="baseline"&&(Ct.has(e)||(Ct.add(e),console.warn(`[sentient] slot "${e}" resolved to its baseline \u2014 no SSR-preloaded or decided result. Keyed clients decide slots server-side, so this slot serves baseline for the whole session and records no exposure. Preload it via loadAdaptiveDecision()/initialSlots so it can serve a decided arm and learn.`))))},[n,l.source,e]),l}function pn(){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 Rt(){let e=O(),t=lt();(0,W.useSyncExternalStore)(M,ze,()=>0);let[n,r]=(0,W.useState)(!1);(0,W.useEffect)(()=>r(!0),[]);let o=s=>({persona:s.persona,confidence:s.confidence,band:(0,kt.confidenceBand)(s.confidence)});if(!n)return t?o(t):null;let i=pn();if(i)return o(i);if(t)return o(t);let m=e?e.getPersona():null;return m?o(m):null}var _t=new Set;function vn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Ot(e,t,n){let r=O(),o=N(),i=JSON.stringify(t),m=(0,U.useMemo)(()=>({id:e,dims:t}),[e,i]),{result:s,arm:a,source:l}=Se(e,m),d=(0,U.useMemo)(()=>typeof s=="string"?{}:s,[a]);if(G()&&!_t.has(e)){_t.add(e);let y=(0,Gt.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([u,g])=>[u,[...g]]))}),c=Object.values(t).reduce((u,g)=>u*g.length,1);y.ok?c>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${c} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let f=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,U.useEffect)(()=>te({id:e,dims:t}),[e]);let p=(0,U.useRef)(null);(0,U.useEffect)(()=>{!r||l==="baseline"||l==="override"||p.current===a||(p.current=a,H(r,o,e,a))},[r,o,e,a,l]);let h=n==null?void 0:n.funnel;(0,U.useEffect)(()=>{var y;!r||!h||l==="override"||Z(r,o,e,h,F((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,o,e,h,f,l]),(0,U.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||l==="override"||l==="baseline")return;let y=document.querySelector(`[data-sentient-slot="${vn(e)}"]`);if(!y){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 c=q(n.goal),u=K(n.goal),g=!1;return j(y,F(n.goal),{fireGoal:()=>{g||(g=!0,u!==void 0?r.componentGoal(e,c,{value:u}):r.componentGoal(e,c),r.goal(c,S({metadata:{componentId:e,arm:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(v,C,k)=>{r.componentGoal(e,v,{reward:C}),r.goal(v,{metadata:{componentId:e,arm:a},weight:C,stepIndex:k})}},c)},[r,e,f,a,l]);let b=(0,U.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[c,u]of Object.entries(d))y[`data-${c}`]=u;return y},[e,d]);return{tokens:d,props:b}}var X=require("react"),Kt=require("@sentientui/core");var z=require("react"),Pt=require("@sentientui/core");var Et=new Set;function It(e){var b;let t=O(),n=me(),r=ut(),o=ct(),[,i]=(0,z.useReducer)(y=>y+1,0),m=(0,z.useSyncExternalStore)(M,()=>{var y;return typeof window!="undefined"?(y=window.__sentient_slot_config_overrides)==null?void 0:y[e]:void 0},()=>{}),s=(0,z.useSyncExternalStore)(M,()=>{var y;return typeof window!="undefined"?(y=window.__sentient_slot_overrides)==null?void 0:y[e]:void 0},()=>{}),a=m===void 0?r[e]:void 0,l=m===void 0&&a===void 0&&t?t.getSlotConfig(e):null,d=y=>y==null?"":(0,Pt.armOfResult)(y),f=(b=o!=null?o:t==null?void 0:t.getSitePalette())!=null?b:null,p=(t==null?void 0:t.isLocal)===!0&&m===void 0&&a===void 0&&l===null;(0,z.useEffect)(()=>{if(!p||!t)return;let y=!1;return t.decide({slotsFrom:"registry"}).then(c=>{!y&&c&&i()}),()=>{y=!0}},[t,e,p]);let h=(()=>{var y,c;return m!==void 0?{config:m,arm:d(s),palette:f,source:"override"}:a!==void 0?{config:a,arm:d((y=n[e])!=null?y:t==null?void 0:t.getSlotResult(e)),palette:f,source:"preloaded"}:l!==null?{config:l,arm:d((c=t==null?void 0:t.getSlotResult(e))!=null?c:n[e]),palette:f,source:"client"}:{config:null,arm:"",palette:f,source:"none"}})();return(0,z.useEffect)(()=>{!t||t.isLocal===!0||h.source!=="none"||t.reportSlots([e])},[t,h.source,e]),(0,z.useEffect)(()=>{G()&&(!t||t.isLocal===!0||h.source==="none"&&(Et.has(e)||(Et.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" has no server config \u2014 rendering its baseline children. Preload it via loadAdaptiveDecision({ slotsFrom: 'registry' }) and pass initialSlotConfig/initialSlots to <AdaptiveProvider> so it can serve a decided arm and learn.`))))},[t,h.source,e]),h}var Ee=require("react");var P=require("react/jsx-runtime"),he={none:"0",sm:"8px",md:"16px",lg:"24px"},Oe={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Ft={sm:"0.875em",md:"1em",lg:"1.25em"},yn={sm:"1.25em",md:"1.5em",lg:"2em"},Lt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Dt={sm:"8px",md:"16px",lg:"32px"},Sn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},hn={normal:"400",medium:"500",bold:"700"};function Tt(e){return S(S({},e==="muted"?{opacity:.7}:{}),e==="accent"?{fontWeight:600}:{})}function Bt(e,t,n){var r,o,i,m;return J(S({display:"inline-block",padding:(r=Lt[n!=null?n:"md"])!=null?r:Lt.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Ft[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(i=t==null?void 0:t.primaryBg)!=null?i:"#111827":"transparent",color:e==="primary"?(m=t==null?void 0:t.primaryText)!=null?m:"#ffffff":"inherit",border:e==="secondary"?"1px solid currentColor":"none"})}function bn({node:e,opts:t}){var o,i,m;let n=(o=e.emphasis)!=null?o:"primary",r={padding:"8px 10px",font:"inherit",border:"1px solid currentColor",borderRadius:(m=(i=t.palette)==null?void 0:i.radius)!=null?m:"8px"};return(0,P.jsxs)("form",{onSubmit:s=>{var d,f,p;s.preventDefault();let a=new FormData(s.currentTarget),l={};for(let h of e.fields)l[h.name]=String((d=a.get(h.name))!=null?d:"");(f=t.onFormGoal)==null||f.call(t,e.submitGoal);try{(p=t.onFormSubmit)==null||p.call(t,l)}catch(h){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var a,l;return(0,P.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,P.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,P.jsx)("select",{name:s.name,required:s.required,style:r,children:((a=s.options)!=null?a:[]).map(d=>(0,P.jsx)("option",{value:d,children:d},d))}):(0,P.jsx)("input",{name:s.name,type:(l=s.inputType)!=null?l:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,P.jsx)("button",{type:"submit",style:Bt(n,t.palette),children:e.submitLabel})]})}function be(e,t){var n,r,o,i,m,s,a,l,d;try{switch(e.type){case"stack":{let f=(r=he[(n=e.gap)!=null?n:"md"])!=null?r:he.md;return(0,P.jsx)("div",{style:S(S(S({display:"flex",flexDirection:e.direction,gap:f},e.align?{alignItems:Oe[e.align]}:{}),e.justify?{justifyContent:Oe[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),children:((o=e.children)!=null?o:[]).map((p,h)=>{let b=be(p,t);return b===null?null:(0,P.jsx)(Ee.Fragment,{children:b},h)})})}case"grid":{let f=(m=he[(i=e.gap)!=null?i:"md"])!=null?m:he.md;return(0,P.jsx)("div",{style:S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${f}) / ${e.columns})), 1fr))`,gap:f},e.align?{alignItems:Oe[e.align]}:{}),children:((s=e.children)!=null?s:[]).map((p,h)=>{let b=be(p,t);return b===null?null:(0,P.jsx)(Ee.Fragment,{children:b},h)})})}case"text":return(0,P.jsx)("p",{style:S(S(S(S({margin:0},e.size?{fontSize:Ft[e.size]}:{}),e.weight?{fontWeight:hn[e.weight]}:{}),e.align?{textAlign:e.align}:{}),Tt(e.tone)),children:e.value});case"heading":{let f=`h${e.level}`;return(0,P.jsx)(f,{style:S({margin:0,fontSize:yn[(a=e.size)!=null?a:"md"]},e.align?{textAlign:e.align}:{}),children:e.value})}case"button":{let f=(l=e.emphasis)!=null?l:"primary";return(0,P.jsx)("a",J(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Bt(f,t.palette,e.size),children:e.label}))}case"link":return(0,P.jsx)("a",J(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,P.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Sn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,P.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:"1px solid currentColor"},Tt(e.tone)),children:e.value});case"spacer":return(0,P.jsx)("div",{style:{height:(d=Dt[e.size])!=null?d:Dt.md}});case"form":return(0,P.jsx)(bn,{node:e,opts:t});default:return null}}catch(f){return null}}var Nt=require("react/jsx-runtime"),Mt=new Set;function jt({id:e,children:t,onFormSubmit:n,goal:r,className:o}){var C,k;let i=O(),m=N(),{config:s,arm:a,palette:l,source:d}=It(e),f=(0,X.useRef)(null),p=a!==""?(C=s==null?void 0:s.blocks)==null?void 0:C[a]:void 0,h=p!==void 0&&(0,Kt.containsFormBlock)(p)&&!n;(0,X.useEffect)(()=>{!h||!G()||Mt.has(e)||(Mt.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 b=R=>{!i||d==="override"||(i.componentGoal(e,R),i.goal(R,{metadata:{componentId:e,arm:a},weight:1,stepIndex:0}))},y=t;p!==void 0&&!h?y=(k=be(p,{palette:l,onFormSubmit:n,onFormGoal:b}))!=null?k:t:(s==null?void 0:s.content)!==void 0&&d!=="none"&&(y=s.content);let c=s!=null&&s.blocks?Object.keys(s.blocks).sort().join("|"):"";(0,X.useEffect)(()=>te({id:e,arms:c===""?void 0:c.split("|")}),[e,c]);let u=(0,X.useRef)(null);(0,X.useEffect)(()=>{!i||d==="none"||d==="override"||a===""||u.current===a||(u.current=a,H(i,m,e,a))},[i,m,e,a,d]);let g=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,X.useEffect)(()=>{if(!i||!r||d==="override"||d==="none")return;let R=f.current;if(!R)return;let x=q(r),A=K(r),w=!1;return j(R,F(r),{fireGoal:()=>{w||(w=!0,A!==void 0?i.componentGoal(e,x,{value:A}):i.componentGoal(e,x),i.goal(x,S({metadata:{componentId:e,arm:a},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(L,V,ee)=>{i.componentGoal(e,L,{reward:V}),i.goal(L,{metadata:{componentId:e,arm:a},weight:V,stepIndex:ee})}},x)},[i,e,g,a,d]);let v=(0,X.useMemo)(()=>S({"data-sentient-slot":e},a!==""?{"data-sentient-arm":a}:{}),[e,a]);return(0,Nt.jsx)("div",J(S({ref:f,className:o},v),{children:y}))}var I=require("react"),Vt=require("@sentientui/core");var $t=new Set;function Wt(e,t){var x;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 n=O(),r=N(),o=Object.keys(t.variants).join(" "),i=(0,I.useMemo)(()=>Object.keys(t.variants),[o]),{variantId:m,isOverride:s,settled:a}=re(e,i),l=(x=m!=null?m:i[0])!=null?x:"",d=t.variants[l],[f,p]=(0,I.useState)(null),h=(0,I.useRef)(null),b=(0,I.useCallback)(A=>{h.current=A,p(A)},[]),y=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),c=(0,I.useMemo)(()=>t.goal?F(t.goal):null,[y]),u=t.goal?q(t.goal):"";(0,I.useEffect)(()=>ue({id:e,variantIds:i,goal:u}),[e,i,u]);let g=(0,I.useRef)(null);(0,I.useEffect)(()=>{s||a&&(!n||!l||!f||g.current!==l&&(g.current=l,H(n,r,e,l)))},[n,r,e,l,f,s,a]);let v=t.funnel;(0,I.useEffect)(()=>{s||!a||!n||!v||!c||Z(n,r,e,v,c)},[n,r,e,v,c,s,a]);let C=(0,I.useRef)(!1);(0,I.useEffect)(()=>{C.current=!1},[l,y]),(0,I.useEffect)(()=>{if(s||!a||!n||!l||!f||!c)return;let A=K(c);return j(f,c,{fireGoal:()=>{C.current||(C.current=!0,n.track({projectId:r,componentId:e,variantId:l,eventType:"goal_achieved",goalType:u,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),n.goal(u,S({metadata:{componentId:e,variantId:l},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(w,L,V)=>{n.track({projectId:r,componentId:e,variantId:l,eventType:"goal_achieved",goalType:w,payload:{reward:L}}),n.goal(w,{metadata:{},weight:L,stepIndex:V})}},u)},[n,f,l,r,e,c,u,s,a]),(0,I.useEffect)(()=>{if(s||!n||!l||!f)return;let A=Date.now();return(0,Vt.attachMicroSignalDetectors)((w,L={})=>{n.track({projectId:r,componentId:e,variantId:l,eventType:"micro_signal",payload:S({signalType:w},L)})},f,A)},[n,f,l,r,e,s]),(0,I.useEffect)(()=>{if(!G()||!n)return;let A=setTimeout(()=>{!h.current&&!$t.has(e)&&($t.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(A)},[n,e]);let k=(0,I.useCallback)((A,w)=>{var V,ee;if(s)return;let L=A!=null?A:u;L&&(n==null||n.componentGoal(e,L,w),n==null||n.goal(L,S(S(S({metadata:(V=w==null?void 0:w.metadata)!=null?V:{},weight:(ee=w==null?void 0:w.reward)!=null?ee:1,stepIndex:0},(w==null?void 0:w.value)!==void 0?{value:w.value}:{}),(w==null?void 0:w.currency)!==void 0?{currency:w.currency}:{}),(w==null?void 0:w.externalId)!==void 0?{externalId:w.externalId}:{})))},[n,e,u,s]),R=(0,I.useMemo)(()=>({ref:b,"data-sentient-id":e,"data-sentient-variant":l}),[b,e,l]);return{variant:l,value:d,bind:R,fireGoal:k}}var T=require("react");var Jt=require("react/jsx-runtime"),we=new Set;function Ut(e){var u;let t=O(),n=N(),r=(0,T.useRef)(null),o=Object.keys(e.arrangements).join(" "),i=(0,T.useMemo)(()=>Object.keys(e.arrangements),[o]),m=(0,T.useMemo)(()=>S({id:e.id,arms:i},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,i,e.baseline]),{arm:s,source:a}=Se(e.id,m);G()&&e.baseline!==void 0&&e.baseline!==i[0]&&!we.has(e.id+":baseline")&&(we.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${i[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let l=T.Children.toArray(e.children).filter(T.isValidElement),d=new Map;for(let g of l)d.set(String((u=g.key)!=null?u:"").replace(/^\.\$/,""),g);let f=e.arrangements[s],p=f!==void 0&&f.length===l.length&&f.every(g=>d.has(g));G()&&f!==void 0&&!p&&!we.has(e.id+":keys")&&(we.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${f.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let h=p?f.map(g=>d.get(g)):l;(0,T.useEffect)(()=>te({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let b=(0,T.useRef)(null);(0,T.useEffect)(()=>{!t||a==="baseline"||a==="override"||b.current===s||(b.current=s,H(t,n,e.id,s))},[t,n,e.id,s,a]);let y=e.funnel;(0,T.useEffect)(()=>{var g;!t||!y||a==="override"||Z(t,n,e.id,y,F((g=e.goal)!=null?g:"click"))},[t,n,e.id,y,a]);let c=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,T.useEffect)(()=>{if(!t||e.goal===void 0||a==="override"||a==="baseline")return;let g=r.current;if(!g)return;let v=q(e.goal),C=K(e.goal),k=!1;return j(g,F(e.goal),{fireGoal:()=>{k||(k=!0,C!==void 0?t.componentGoal(e.id,v,{value:C}):t.componentGoal(e.id,v),t.goal(v,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(R,x,A)=>{t.componentGoal(e.id,R,{reward:x}),t.goal(R,{metadata:{componentId:e.id,arm:s},weight:x,stepIndex:A})}},v)},[t,e.id,c,s,a]),(0,Jt.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:h})}var Pe=require("@sentientui/core");var wn=["page","blocks","layoutOrder"],Ht=new Map;function Xt(e,t){Ht.set(e,t)}function Ie(e){return Ht.get(e)}function zt(e){var o,i;let t=(i=(o=e.content)!=null?o:Ie(e.page))!=null?i:{},n={};for(let[m,s]of Object.entries(t))wn.includes(m)||(n[m]=s);let r=J(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function qt(e){return`<script type="application/ld+json">${Le(e)}</script>`}function Le(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Zt(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 cn=Object.create;var le=Object.defineProperty,un=Object.defineProperties,dn=Object.getOwnPropertyDescriptor,fn=Object.getOwnPropertyDescriptors,gn=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols,mn=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var We=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))ke.call(t,n)&&We(e,n,t[n]);if(de)for(var n of de(t))Ue.call(t,n)&&We(e,n,t[n]);return e},J=(e,t)=>un(e,fn(t));var Je=(e,t)=>{var n={};for(var r in e)ke.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&de)for(var r of de(e))t.indexOf(r)<0&&Ue.call(e,r)&&(n[r]=e[r]);return n};var pn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},ze=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of gn(t))!ke.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=dn(t,i))||r.enumerable});return e};var Xe=(e,t,n)=>(n=e!=null?cn(mn(e)):{},ze(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),vn=e=>ze(le({},"__esModule",{value:!0}),e);var Tn={};pn(Tn,{Adaptive:()=>At,AdaptiveGroup:()=>en,AdaptiveProvider:()=>mt,AdaptiveSlot:()=>Ht,AdaptiveText:()=>kt,SentientPersonaScript:()=>It,buildAgentFeed:()=>on,defineAgentContent:()=>rn,detectSegment:()=>Ne.deriveSessionSegment,getAgentContent:()=>Ke,grantConsent:()=>ln.grantConsent,renderAgentJsonLd:()=>sn,renderAgentJsonLdBody:()=>je,renderAgentMarkdown:()=>an,renderBlocks:()=>ae,useAdaptive:()=>Qt,useAdaptiveApiBaseUrl:()=>wt,useAdaptiveGoal:()=>xe,useAdaptivePersona:()=>Ft,useAdaptiveTokens:()=>Mt,useAssignment:()=>se,useInitialAssignments:()=>ve,useLayoutOrder:()=>yt,usePageGoal:()=>Et,useSentient:()=>G});module.exports=vn(Tn);var k=require("react"),pe=require("@sentientui/core");var He=new Map,fe=new Map;function qe(e,t){let n=fe.get(e);return n||(n=new Set,fe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&fe.delete(e)}}function Ze(e,t){He.set(e,t);let n=fe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Re(e){var t;return(t=He.get(e))!=null?t:null}var yn={on:!1,listeners:new Set};function Ye(){if(typeof window=="undefined")return yn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Ee(){return Ye().on}function Qe(e){let t=Ye().listeners;return t.add(e),()=>{t.delete(e)}}function et(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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Ge="sentient:overrides-changed";function tt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function nt(){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(Ge))}function N(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Ge,e),()=>window.removeEventListener(Ge,e))}function rt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function E(){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 q(e){return typeof e=="string"?e:e.type}function K(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var Oe=new Set,Pe=!1;function it(e){if(Oe.has(e))return!0;if(Oe.add(e),!Pe){Pe=!0;let t=()=>{Pe=!1,Oe.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 Sn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ot(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(Sn(r))return!0;r=r.parentElement}return!1}function j(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,u=[];return t.steps.forEach(({goal:p,name:m,weight:x},w)=>{let h=(d=!1)=>{s.has(w)||d&&r!==void 0&&it(`step\0${m}\0${x}\0${w}`)||(s.add(w),n.fireStep(m,x,w))};if(p.type==="click"){let d=l=>{let f=l.target;f instanceof Element&&ot(f,e,p.selector)&&h()};e.addEventListener("click",d),u.push(()=>e.removeEventListener("click",d));return}if(p.type==="form_submit"){let d=l=>{l.target instanceof HTMLFormElement&&e.contains(l.target)&&h()};e.addEventListener("submit",d),u.push(()=>e.removeEventListener("submit",d));return}if(p.type==="scroll_depth"){let d=Math.max(0,Math.min(1,p.threshold)),l=new IntersectionObserver(f=>{for(let y of f)if(y.intersectionRatio>=d){h(!0),l.disconnect();break}},{threshold:[d]});l.observe(e),u.push(()=>l.disconnect())}}),()=>{for(let p of u)p()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,u)=>u)),c=()=>{r!==void 0&&it(r)||n.fireGoal()},a=(s,u=!1)=>{o.delete(s),o.size===0&&(u?c():n.fireGoal())},g=[];return i.forEach((s,u)=>{if(s.type==="click"){let p=m=>{let x=m.target;x instanceof Element&&ot(x,e,s.selector)&&(t.type==="composite"?a(u):n.fireGoal())};e.addEventListener("click",p),g.push(()=>e.removeEventListener("click",p));return}if(s.type==="form_submit"){let p=m=>{m.target instanceof HTMLFormElement&&e.contains(m.target)&&(t.type==="composite"?a(u):n.fireGoal())};e.addEventListener("submit",p),g.push(()=>e.removeEventListener("submit",p));return}if(s.type==="scroll_depth"){let p=Math.max(0,Math.min(1,s.threshold)),m=new IntersectionObserver(x=>{for(let w of x)if(w.intersectionRatio>=p){t.type==="composite"?a(u,!0):c(),m.disconnect();break}},{threshold:[p]});m.observe(e),g.push(()=>m.disconnect());return}}),()=>{for(let s of g)s()}}var st=new Set,at=new Set;function Z(e,t,n,r,i){let o=`${r}|${n}`;if(at.has(o))return;at.add(o);let c=i.type==="weighted_composite"&&!st.has(r);c&&st.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(a=>({goalId:a.name,weight:a.weight}))}:{funnelId:r}})}function H(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var hn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function ne(){if(typeof window=="undefined")return hn;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(){ne().version+=1;for(let e of ne().listeners)e()}var lt=()=>{};function ge(e){return E()?(ne().components.set(e.id,e),ce(),()=>{ne().components.delete(e.id),ce()}):lt}function ie(e){return E()?(ne().slots.set(e.id,e),ce(),()=>{ne().slots.delete(e.id),ce()}):lt}function Ie(e){E()&&(ne().sections=[...e],ce())}var ct="0.31.0",Te=ct!=="0.0.0-dev"?{name:"react",version:ct}:void 0;function bn(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Le(e,t){bn()[e]=t}function wn(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function De(e,t){wn()[e]=t}var ut="sentient_editor",dt="sentient_preview_cell",Be="sentient-cell-preview-bar",Fe="__preview__";function ft(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Be))return;let t,n;try{let a=new URLSearchParams(window.location.search);t=a.get(ut),n=a.get(dt)}catch(a){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),o=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(o)}`,{headers:{authorization:`Bearer ${t}`}}).then(async a=>{if(!a.ok){me(a.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 g=await a.json();if(g.blocks!=null)Le(i,{kind:"arms",blocks:{[Fe]:g.blocks}}),De(i,Fe);else if(g.content!=null)Le(i,{kind:"arms",content:g.content}),De(i,Fe);else{me("Nothing to preview in that square yet.");return}nt(),me(`Previewing \u201C${g.slotName}\u201D for ${g.personaDisplay}${g.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var s;try{(s=document.querySelector(`[data-sentient-slot="${i}"]`))==null||s.scrollIntoView({block:"center"})}catch(u){}},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(Be))return;let t=document.createElement("div");t.id=Be,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 o=new URL(window.location.href);o.searchParams.delete(ut),o.searchParams.delete(dt),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var xt=require("react/jsx-runtime");function xn(){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 gt="https://api.sentient-ui.com/v1",$=(0,k.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:gt,debug:!1});function Cn(e){let[t,n]=(0,k.useState)(!1),r=(0,k.useRef)(e);r.current=e;let{cookie:i,value:o,event:c}=e!=null?e:{},a=typeof(e==null?void 0:e.check)=="function";return(0,k.useEffect)(()=>{let g=()=>{var m;let u=r.current;if(!u)return!1;if(u.check)return u.check()===!0;if(!u.cookie||typeof document=="undefined")return!1;let p=`${u.cookie}=${(m=u.value)!=null?m:"accepted"}`;return document.cookie.split("; ").some(x=>x.trim()===p)};if(n(g()),!c)return;let s=()=>{n(g())};return window.addEventListener(c,s),()=>window.removeEventListener(c,s)},[i,o,c,a]),t}function mt(e){var w,h;let[t,n]=(0,k.useState)(null),[r]=(0,k.useState)(()=>{var d;return(d=e.sessionSegment)!=null?d:xn()}),[i,o]=(0,k.useState)(Ee());(0,k.useEffect)(()=>Qe(()=>o(Ee())),[]),(0,k.useEffect)(()=>{ft(e.apiBaseUrl)},[]);let c=Cn(e.consentFrom),a=e.consentFrom?e.consent===!0||c:e.consent,g=(0,k.useRef)(null);(0,k.useEffect)(()=>{var _;if(a===!1&&!e.preConsentBehavior){(_=g.current)==null||_.destroy(),g.current=null,n(null);return}let d=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:a,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},Te?{sdk:Te}:{}),l=!1,f=null,y=null,A=R=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{l||(y=C(R,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:R})=>{l||(f=R(J(v({},d),{graph:!0,captureDomText:e.captureDomText===!0})),g.current=f,n(f),A(f))}):(f=(0,pe.init)(d),g.current=f,n(f),A(f)),()=>{l=!0,y==null||y(),f==null||f.dispose()}},[a]),(0,k.useEffect)(()=>{if(!t)return;let d=!1,l=async()=>{if(d)return;let y;try{y=await t.fetchWeights()}catch(A){return}if(!d)for(let A of y){let _={componentId:A.componentId,updatedAt:A.updatedAt,variants:A.variants.map(R=>{var C;return{variantId:R.variantId,pulls:R.pulls,avgReward:(C=R.avgReward)!=null?C:0}})};Ze(A.componentId,_)}};l();let f=setInterval(()=>{l()},6e4);return()=>{d=!0,clearInterval(f)}},[t]);let s=(w=e.ssrFallback)!=null?w:"first",u=((h=e.apiBaseUrl)!=null?h:gt).replace(/\/$/,""),p=(0,k.useRef)(null);(0,k.useEffect)(()=>{var f;if(typeof process!="undefined"&&((f=process.env)==null?void 0:f.NODE_ENV)==="production")return;let d={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:u},l=p.current;if(p.current=d,l!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(l[y],d[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,u]),(0,k.useEffect)(()=>{var d;typeof process!="undefined"&&((d=process.env)==null?void 0:d.NODE_ENV)==="production"||rt({apiKey:e.apiKey,apiBaseUrl:u,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,u]),(0,k.useEffect)(()=>{let d=e.initialLayoutOrder;if(d&&d.length>0){Ie(d);return}e.declaredSections&&e.declaredSections.length>0&&Ie(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,k.useEffect)(()=>{if(!E())return;let d=e.declaredSections;if(!d||d.length===0||typeof document=="undefined")return;let l=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),f=d.filter(y=>!l.has(y));f.length>0&&console.warn(`[SentientUI] Declared section${f.length>1?"s":""} ${f.map(y=>`"${y}"`).join(", ")} ${f.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>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let m=(0,k.useMemo)(()=>t&&i?et(t):t,[t,i]),x=(0,k.useMemo)(()=>{var d,l,f,y,A,_,R;return{client:m,apiKey:e.apiKey,initialAssignments:(d=e.initialAssignments)!=null?d:{},sessionSegment:r,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(l=e.initialLayoutOrder)!=null?l:null,initialSlots:(f=e.initialSlots)!=null?f:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(A=e.initialPalette)!=null?A:null,initialPersona:(_=e.initialPersona)!=null?_:null,apiBaseUrl:u,debug:(R=e.debug)!=null?R:!1}},[m,e.apiKey,e.initialAssignments,r,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,u,e.debug]);return(0,xt.jsx)($.Provider,{value:x,children:e.children})}function G(){return(0,k.useContext)($).client}function V(){return(0,k.useContext)($).apiKey}function ve(){return(0,k.useContext)($).initialAssignments}function ye(){return(0,k.useContext)($).sessionSegment}function pt(){return(0,k.useContext)($).ssrFallback}function Se(){return(0,k.useContext)($).onAssignment}function vt(){return(0,k.useContext)($).debug}function yt(){let e=(0,k.useContext)($).initialLayoutOrder,t=(0,k.useSyncExternalStore)(N,()=>{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,k.useContext)($).initialSlots}function St(){return(0,k.useContext)($).initialPersona}function ht(){return(0,k.useContext)($).initialSlotConfig}function bt(){return(0,k.useContext)($).initialPalette}function wt(){return(0,k.useContext)($).apiBaseUrl}var I=require("react"),Ct=require("@sentientui/core");var W=require("react"),be=require("@sentientui/policy");function oe(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function se(e,t,n,r){let i=ve(),o=pt(),c=G(),a=ye(),g=Se(),s=vt(),u=(0,W.useRef)(null),p=(0,W.useSyncExternalStore)(N,()=>oe(e),()=>null),m=p&&t.includes(p)?p:null,x=(0,W.useRef)(null);(0,W.useEffect)(()=>{s&&m&&x.current!==m&&(x.current=m,console.info(`[sentient] override active: ${e} -> ${m}`))},[s,m,e]);let[w,h]=(0,W.useState)(()=>{var y,A;if(m)return{variantId:m,content:null,isLoading:!1,settled:!0};if(!c){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:o==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let l=c.getAssignment(e,a);if(l&&(t.includes(l.variantId)||l.content))return{variantId:l.variantId,content:(y=l.content)!=null?y:null,isLoading:!1,settled:!0};let f=Re(e);if(f){let _=(0,be.pickFromWeights)(f.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(A=t[0])!=null?A:null,content:null,isLoading:!1,settled:!1}}),d=l=>{g&&u.current!==l&&(u.current=l,g(e,l))};return(0,W.useEffect)(()=>{var y;if(m||!c)return;let l=c.getAssignment(e,a);if(l&&(t.includes(l.variantId)||l.content)){h({variantId:l.variantId,content:(y=l.content)!=null?y:null,isLoading:!1,settled:!0}),d(l.variantId);return}let f=Re(e);if(f&&w.settled&&w.variantId&&w.variantId===(0,be.pickFromWeights)(f.variants,t)){d(w.variantId);return}h(A=>{var _;return A.variantId?A:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[m,c,e,a]),(0,W.useEffect)(()=>{if(m||!c)return;let l=c.getAssignment(e,a);if(l&&t.includes(l.variantId))return;let f=!1;return c.assign(e,t,n,r).then(y=>{var A;f||y&&(!t.includes(y.variantId)&&!y.content||(h({variantId:y.variantId,content:(A=y.content)!=null?A:null,isLoading:!1,settled:!0}),d(y.variantId)))}),()=>{f=!0}},[m,c,e,a]),(0,W.useEffect)(()=>{if(!m&&c)return qe(e,l=>{var A;let f=c.getAssignment(e,a);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(A=f.content)!=null?A:null,isLoading:!1,settled:!0}),d(f.variantId);return}let y=(0,be.pickFromWeights)(l.variants,t);y&&(h({variantId:y,content:null,isLoading:!1,settled:!0}),d(y))})},[m,c,e,a]),m?{variantId:m,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}var _t=require("react/jsx-runtime");function An(e){var A;let t=G(),n=V(),r=Object.keys(e.variants).join("\0"),i=(0,I.useMemo)(()=>Object.keys(e.variants),[r]),{variantId:o,content:c,isOverride:a,settled:g}=se(e.id,i,e.agentData,e.agentDataByVariant),s=(0,I.useRef)(null),[u,p]=(0,I.useState)(!1);(0,I.useEffect)(()=>{p(!0)},[]);let m=(0,I.useRef)(!1),x=(0,I.useRef)(new Set),w=(0,I.useRef)(null),h=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),d=(0,I.useMemo)(()=>B(e.goal),[h]),l=typeof e.goal=="string"?e.goal:d.type;if((0,I.useEffect)(()=>ge({id:e.id,variantIds:i,goal:l}),[e.id,i,l]),(0,I.useEffect)(()=>{a||g&&(!t||!o||!n||w.current!==o&&(w.current=o,H(t,n,e.id,o)))},[t,o,n,e.id,a,g]),(0,I.useEffect)(()=>{m.current=!1,x.current=new Set},[o,d]),(0,I.useEffect)(()=>{a||!g||!t||!e.funnel||Z(t,n,e.id,e.funnel,d)},[t,n,e.id,e.funnel,d,a,g]),(0,I.useEffect)(()=>{if(a||!g||!t||!o)return;let _=s.current;if(!_)return;let R=null,C=0,b=()=>{C=Date.now(),R=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-C}}),R=null},800)},S=()=>{R!==null&&(clearTimeout(R),R=null)};return _.addEventListener("mouseenter",b),_.addEventListener("mouseleave",S),()=>{_.removeEventListener("mouseenter",b),_.removeEventListener("mouseleave",S),R!==null&&clearTimeout(R)}},[t,o,n,e.id,a,g]),(0,I.useEffect)(()=>{if(a||!g||!t||!o)return;let _=s.current;if(!_)return;let R=Date.now();return(0,Ct.attachMicroSignalDetectors)((C,b={})=>{var ee,te,Ve;t.track({projectId:n,componentId:e.id,variantId:o,eventType:"micro_signal",payload:v({signalType:C},b)});let S=(ee=e.microSignalGoals)==null?void 0:ee[C];if(!S||x.current.has(C))return;x.current.add(C);let O=typeof S=="string"?S:S.name,L=typeof S=="string"?1:(te=S.weight)!=null?te:1,M=typeof S=="string"?0:(Ve=S.stepIndex)!=null?Ve:0;t.goal(O,{metadata:v({signalType:C},b),weight:L,stepIndex:M})},_,R)},[t,o,n,e.id,e.microSignalGoals,a,g]),(0,I.useEffect)(()=>{if(a||!g||!t||!o)return;let _=s.current;if(!_)return;let R=K(d);return j(_,d,{fireGoal:()=>{m.current||(m.current=!0,t.track({projectId:n,componentId:e.id,variantId:o,eventType:"goal_achieved",goalType:l,payload:v({reward:1},R!==void 0?{goalValue:R}:{})}),t.goal(l,v({metadata:{componentId:e.id,variantId:o},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(C,b,S)=>{t.track({projectId:n,componentId:e.id,variantId:o,eventType:"goal_achieved",goalType:C,payload:{reward:b}}),t.goal(C,{metadata:{},weight:b,stepIndex:S})}},l)},[t,o,n,e.id,d,l,a,g]),e.clientOnly&&(!u||!t)||!o)return null;let f=(A=e.variants[o])!=null?A:null,y=f===null?c:null;return E()&&f===null&&y===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${o}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,_t.jsx)("div",{ref:s,"data-sentient-id":e.id,"data-sentient-variant":o,children:f!=null?f:y})}var At=(0,I.memo)(An,(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]))});var D=require("react");var Rt=require("react/jsx-runtime");function kt({id:e,default:t,component:n="span",className:r,goal:i}){var R;let o=G(),c=V(),a=Se(),g=ye(),s=(0,D.useRef)(null),u=(0,D.useRef)(null),p=(0,D.useSyncExternalStore)(N,()=>oe(e),()=>null),[m,x]=(0,D.useState)(()=>{var C,b;return(b=(C=o==null?void 0:o.getAssignment(e,g))==null?void 0:C.content)!=null?b:null}),[w,h]=(0,D.useState)(()=>{var C,b;return(b=(C=o==null?void 0:o.getAssignment(e,g))==null?void 0:C.variantId)!=null?b:null});(0,D.useEffect)(()=>{if(p||!o)return;let C=o.getAssignment(e,g);if((C==null?void 0:C.content)!==void 0){h(C.variantId),x(C.content);return}let b=!1;return o.assign(e).then(S=>{if(!b){if(!S){E()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}h(S.variantId),S.content&&x(S.content)}}),()=>{b=!0}},[o,e,g,p]),(0,D.useEffect)(()=>{p||!o||!w||!c||s.current!==w&&(s.current=w,o.track({projectId:c,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),a==null||a(e,w))},[o,w,c,e,a,p]);let d=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),l=(0,D.useMemo)(()=>i===void 0?null:B(i),[d]),f=i===void 0?null:typeof i=="string"?i:l.type,y=(0,D.useRef)(!1);(0,D.useEffect)(()=>{y.current=!1},[w,d]),(0,D.useEffect)(()=>{if(p||!o||!w||!c||!l||!f)return;let C=u.current;if(!C)return;let b=K(l);return j(C,l,{fireGoal:()=>{y.current||(y.current=!0,o.track({projectId:c,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:v({reward:1},b!==void 0?{goalValue:b}:{})}),o.goal(f,v({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},b!==void 0?{value:b}:{})))},fireStep:(S,O,L)=>{o.track({projectId:c,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:O}}),o.goal(S,{metadata:{},weight:O,stepIndex:L})}})},[o,w,c,e,l,f,p]);let A=m!=null?m:t;if(p){let C=o==null?void 0:o.getAssignment(e,g);A=C&&C.variantId===p&&(R=C.content)!=null?R:t}return(0,Rt.jsx)(n,{ref:C=>{u.current=C},className:r,children:A})}var we=require("react");function xe(e){let t=G(),n=(0,we.useRef)(new Set);return(0,we.useCallback)((r,i)=>{var o,c;if(!oe(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,v(v(v({metadata:(o=i==null?void 0:i.metadata)!=null?o:{},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 Et(e,t={}){let g=t,{componentId:n}=g,r=Je(g,["componentId"]),i=G(),o=xe(n!=null?n:""),c=(0,ue.useRef)(!1),a=(0,ue.useRef)(r);a.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:s,reward:u,value:p,currency:m,externalId:x}=a.current;if(n){o(e,a.current);return}i.goal(e,v(v(v({metadata:s!=null?s:{},weight:u!=null?u:1,stepIndex:0},p!==void 0?{value:p}:{}),m!==void 0?{currency:m}:{}),x!==void 0?{externalId:x}:{}))},[i,n,e,o])}var Ot=require("@sentientui/core"),Pt=require("@sentientui/policy"),Tt=require("react/jsx-runtime");function Gt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function _n(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Gt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Gt((0,Pt.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Ot.renderPrePaintScript)(e.apiKey)}function It(e){return(0,Tt.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:_n(e)}})}var X=require("react"),$t=require("@sentientui/policy");var z=require("react"),re=require("@sentientui/core"),Dt=require("@sentientui/policy");var Lt=new Set;function Ce(e,t){let n=G(),r=he(),[,i]=(0,z.useReducer)(u=>u+1,0),o=(0,z.useSyncExternalStore)(N,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=o===void 0?r[e]:void 0,a=o===void 0&&c===void 0&&n?n.getSlotResult(e):null,g=(n==null?void 0:n.isLocal)===!0&&o===void 0&&c===void 0&&a===null;(0,z.useEffect)(()=>{if(!g||!n)return;let u=!1;return n.decide({slots:[t]}).then(p=>{!u&&p&&i()}),()=>{u=!0}},[n,e,g]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,re.armOfResult)(o),source:"override"};if(c!==void 0)return{result:c,arm:(0,re.armOfResult)(c),source:"preloaded"};if(a!==null)return{result:a,arm:(0,re.armOfResult)(a),source:"client"};let u=(0,re.baselineResultFor)(t);return{result:u,arm:(0,re.armOfResult)(u),source:"baseline"}})();return(0,z.useEffect)(()=>{E()&&(!n||n.isLocal===!0||s.source==="baseline"&&(Lt.has(e)||(Lt.add(e),console.warn(`[sentient] slot "${e}" resolved to its baseline \u2014 no SSR-preloaded or decided result. Keyed clients decide slots server-side, so this slot serves baseline for the whole session and records no exposure. Preload it via loadAdaptiveDecision()/initialSlots so it can serve a decided arm and learn.`))))},[n,s.source,e]),s}function kn(){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 Ft(){let e=G(),t=St();(0,z.useSyncExternalStore)(N,tt,()=>0);let[n,r]=(0,z.useState)(!1);(0,z.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,Dt.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=kn();if(o)return i(o);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Bt=new Set;function Rn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Mt(e,t,n){let r=G(),i=V(),o=JSON.stringify(t),c=(0,X.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:g,source:s}=Ce(e,c),u=(0,X.useMemo)(()=>typeof a=="string"?{}:a,[g]);if(E()&&!Bt.has(e)){Bt.add(e);let h=(0,$t.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([l,f])=>[l,[...f]]))}),d=Object.values(t).reduce((l,f)=>l*f.length,1);h.ok?d>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${d} 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 ${h.reason}. Serving baseline.`)}let p=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,X.useEffect)(()=>ie({id:e,dims:t}),[e]);let m=(0,X.useRef)(null);(0,X.useEffect)(()=>{!r||s==="baseline"||s==="override"||m.current===g||(m.current=g,H(r,i,e,g))},[r,i,e,g,s]);let x=n==null?void 0:n.funnel;(0,X.useEffect)(()=>{var h;!r||!x||s==="override"||Z(r,i,e,x,B((h=n==null?void 0:n.goal)!=null?h:"click"))},[r,i,e,x,p,s]),(0,X.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline")return;let h=document.querySelector(`[data-sentient-slot="${Rn(e)}"]`);if(!h){E()&&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 d=q(n.goal),l=K(n.goal),f=!1;return j(h,B(n.goal),{fireGoal:()=>{f||(f=!0,l!==void 0?r.componentGoal(e,d,{value:l}):r.componentGoal(e,d),r.goal(d,v({metadata:{componentId:e,arm:g},weight:1,stepIndex:0},l!==void 0?{value:l}:{})))},fireStep:(y,A,_)=>{r.componentGoal(e,y,{reward:A}),r.goal(y,{metadata:{componentId:e,arm:g},weight:A,stepIndex:_})}},d)},[r,e,p,g,s]);let w=(0,X.useMemo)(()=>{let h={"data-sentient-slot":e};for(let[d,l]of Object.entries(u))h[`data-${d}`]=l;return h},[e,u]);return{tokens:u,props:w}}var U=require("react"),Ae=require("@sentientui/core");var Y=require("react"),Kt=require("@sentientui/core");var Nt=new Set;function jt(e,t){var w;let n=G(),r=(0,Y.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=he(),o=ht(),c=bt(),a=(0,Y.useSyncExternalStore)(N,()=>{var h;return typeof window!="undefined"?(h=window.__sentient_slot_config_overrides)==null?void 0:h[e]:void 0},()=>{}),g=(0,Y.useSyncExternalStore)(N,()=>{var h;return typeof window!="undefined"?(h=window.__sentient_slot_overrides)==null?void 0:h[e]:void 0},()=>{}),s=a===void 0?o[e]:void 0,u=a===void 0&&s===void 0&&n?n.getSlotConfig(e):null,p=h=>h==null?"":(0,Kt.armOfResult)(h),m=(w=c!=null?c:n==null?void 0:n.getSitePalette())!=null?w:null,x=(()=>{var h,d;return a!==void 0?{config:a,arm:p(g),palette:m,source:"override"}:s!==void 0?{config:s,arm:p((h=i[e])!=null?h:n==null?void 0:n.getSlotResult(e)),palette:m,source:"preloaded"}:u!==null?{config:u,arm:p((d=n==null?void 0:n.getSlotResult(e))!=null?d:i[e]),palette:m,source:"client"}:{config:null,arm:"",palette:m,source:"none"}})();return(0,Y.useEffect)(()=>{var d,l;if(!n||n.isLocal===!0||x.source!=="none")return;let h=(l=(d=r.current)==null?void 0:d.call(r))!=null?l:null;h!=null&&h!==""?n.reportSlots([e],{[e]:h}):n.reportSlots([e])},[n,x.source,e]),(0,Y.useEffect)(()=>{if(E()&&n&&x.source==="none"&&!Nt.has(e)){if(Nt.add(e),n.isLocal===!0){console.warn(`[sentient] AdaptiveSlot "${e}" is rendering its baseline children: in local/keyless mode AdaptiveSlot serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`);return}console.warn(`[sentient] AdaptiveSlot "${e}" has no server config \u2014 rendering its baseline children. Keyed clients issue no client-side registry decide, so a production CSR-only app will NEVER serve this slot: preload the decision server-side via loadAdaptiveDecision({ slotsFrom: 'registry' }) and pass initialSlotConfig/initialSlots to <AdaptiveProvider> so it can serve a decided arm and learn.`)}},[n,x.source,e]),x}var Me=require("react");var P=require("react/jsx-runtime"),Q={none:"0",sm:"8px",md:"16px",lg:"24px"},$e={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Jt={sm:"0.875em",md:"1em",lg:"1.25em"},En={sm:"1.25em",md:"1.5em",lg:"2em"},Vt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Wt={sm:"8px",md:"16px",lg:"32px"},Gn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},On={normal:"400",medium:"500",bold:"700"};function Ut(e,t){return v(v({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?v({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function zt(e,t,n){var i,o,c,a;let r=t==null?void 0:t.accent;return J(v({display:"inline-block",padding:(i=Vt[n!=null?n:"md"])!=null?i:Vt.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Jt[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"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,o,c,a,g;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(o=t.palette)==null?void 0:o.border)!=null?c:"currentColor"}`,borderRadius:(g=(a=t.palette)==null?void 0:a.radius)!=null?g:"8px"};return(0,P.jsxs)("form",{onSubmit:s=>{var m,x,w;s.preventDefault();let u=new FormData(s.currentTarget),p={};for(let h of e.fields)p[h.name]=String((m=u.get(h.name))!=null?m:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,p)}catch(h){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var u,p;return(0,P.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,P.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,P.jsx)("select",{name:s.name,required:s.required,style:r,children:((u=s.options)!=null?u:[]).map(m=>(0,P.jsx)("option",{value:m,children:m},m))}):(0,P.jsx)("input",{name:s.name,type:(p=s.inputType)!=null?p:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,P.jsx)("button",{type:"submit",style:zt(n,t.palette),children:e.submitLabel})]})}function ae(e,t){var n,r,i,o,c,a,g,s,u,p,m,x,w,h,d,l,f,y,A,_,R,C,b;try{switch(e.type){case"stack":{let S=(r=Q[(n=e.gap)!=null?n:"md"])!=null?r:Q.md,O=e.surface==="raised",L=(i=e.pad)!=null?i:O?"md":void 0;return(0,P.jsx)("div",{style:v(v(v(v(v({display:"flex",flexDirection:e.direction,gap:S},e.align?{alignItems:$e[e.align]}:{}),e.justify?{justifyContent:$e[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),L?{padding:(o=Q[L])!=null?o:Q.md}:{}),O?J(v(v({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((g=t.palette)!=null&&g.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(u=(s=t.palette)==null?void 0:s.border)!=null?u:"currentColor"}`,borderRadius:(m=(p=t.palette)==null?void 0:p.radius)!=null?m:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((M,ee)=>{let te=ae(M,t);return te===null?null:(0,P.jsx)(Me.Fragment,{children:te},ee)})})}case"grid":{let S=(h=Q[(w=e.gap)!=null?w:"md"])!=null?h:Q.md;return(0,P.jsx)("div",{style:v(v({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${S}) / ${e.columns})), 1fr))`,gap:S},e.align?{alignItems:$e[e.align]}:{}),e.pad?{padding:(d=Q[e.pad])!=null?d:Q.md}:{}),children:((l=e.children)!=null?l:[]).map((O,L)=>{let M=ae(O,t);return M===null?null:(0,P.jsx)(Me.Fragment,{children:M},L)})})}case"text":return(0,P.jsx)("p",{style:v(v(v(v(v({margin:0},e.size?{fontSize:Jt[e.size]}:{}),e.weight?{fontWeight:On[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Ut(e.tone,t.palette)),children:e.value});case"heading":{let S=`h${e.level}`;return(0,P.jsx)(S,{style:v(v({margin:0,fontSize:En[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let S=(y=e.emphasis)!=null?y:"primary";return(0,P.jsx)("a",J(v({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:zt(S,t.palette,e.size),children:e.label}))}case"link":return(0,P.jsx)("a",J(v({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,P.jsx)("img",{src:e.src,alt:e.alt,style:v(v({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Gn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,P.jsx)("span",{style:v({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(A=t.palette)==null?void 0:A.border)!=null?_:"currentColor"}`},Ut(e.tone,t.palette)),children:e.value});case"spacer":return(0,P.jsx)("div",{style:{height:(R=Wt[e.size])!=null?R:Wt.md}});case"divider":return(0,P.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(b=(C=t.palette)==null?void 0:C.border)!=null?b:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,P.jsx)(Pn,{node:e,opts:t});default:return null}}catch(S){return null}}var qt=require("react/jsx-runtime"),Xt=new Set;function Ht({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:o=!0}){var C;let c=G(),a=V(),g=(0,U.useRef)(null),{config:s,arm:u,palette:p,source:m}=jt(e,{baselineText:o?()=>{var b,S;return(S=(b=g.current)==null?void 0:b.textContent)!=null?S:null}:void 0}),x=u!==""?(C=s==null?void 0:s.blocks)==null?void 0:C[u]:void 0,w=x!==void 0&&(0,Ae.containsFormBlock)(x)&&!n;(0,U.useEffect)(()=>{!w||!E()||Xt.has(e)||(Xt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[w,e]);let h=b=>{!c||m==="override"||(c.componentGoal(e,b),c.goal(b,{metadata:{componentId:e,arm:u},weight:1,stepIndex:0}))},d=t,l=!1;if(x!==void 0){let b=w?null:ae(x,{palette:p,onFormSubmit:n,onFormGoal:h});b===null?l=!0:d=b}else(s==null?void 0:s.content)!==void 0&&m!=="none"&&(d=s.content);let f=s!=null&&s.blocks?Object.keys(s.blocks).sort().join("|"):"";(0,U.useEffect)(()=>ie({id:e,arms:f===""?void 0:f.split("|")}),[e,f]);let y=(0,U.useRef)(null);(0,U.useEffect)(()=>{!c||m==="none"||m==="override"||u===""||l||y.current!==u&&(y.current=u,H(c,a,e,u))},[c,a,e,u,m,l]);let A=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,U.useEffect)(()=>{if(!c||!r||m==="override"||m==="none"||l)return;let b=g.current;if(!b)return;let S=q(r),O=K(r),L=!1;return j(b,B(r),{fireGoal:()=>{L||(L=!0,O!==void 0?c.componentGoal(e,S,{value:O}):c.componentGoal(e,S),c.goal(S,v({metadata:{componentId:e,arm:u},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(M,ee,te)=>{c.componentGoal(e,M,{reward:ee}),c.goal(M,{metadata:{componentId:e,arm:u},weight:ee,stepIndex:te})}},S)},[c,e,A,u,m,l]);let _=(0,U.useRef)(null);(0,U.useEffect)(()=>{let b=g.current;if(b){if(_.current===null){_.current=u;return}_.current!==u&&(_.current=u,(0,Ae.reveal)(b))}},[u]);let R=(0,U.useMemo)(()=>v({"data-sentient-slot":e},u!==""?{"data-sentient-arm":u}:{}),[e,u]);return(0,qt.jsx)("div",J(v({ref:g,className:i},R),{children:d}))}var T=require("react"),Yt=require("@sentientui/core");var Zt=new Set;function Qt(e,t){var C;if(E()&&!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 n=G(),r=V(),i=Object.keys(t.variants).join(" "),o=(0,T.useMemo)(()=>Object.keys(t.variants),[i]),{variantId:c,isOverride:a,settled:g}=se(e,o),s=(C=c!=null?c:o[0])!=null?C:"",u=t.variants[s],[p,m]=(0,T.useState)(null),x=(0,T.useRef)(null),w=(0,T.useCallback)(b=>{x.current=b,m(b)},[]),h=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),d=(0,T.useMemo)(()=>t.goal?B(t.goal):null,[h]),l=t.goal?q(t.goal):"";(0,T.useEffect)(()=>ge({id:e,variantIds:o,goal:l}),[e,o,l]);let f=(0,T.useRef)(null);(0,T.useEffect)(()=>{a||g&&(!n||!s||!p||f.current!==s&&(f.current=s,H(n,r,e,s)))},[n,r,e,s,p,a,g]);let y=t.funnel;(0,T.useEffect)(()=>{a||!g||!n||!y||!d||Z(n,r,e,y,d)},[n,r,e,y,d,a,g]);let A=(0,T.useRef)(!1);(0,T.useEffect)(()=>{A.current=!1},[s,h]),(0,T.useEffect)(()=>{if(a||!g||!n||!s||!p||!d)return;let b=K(d);return j(p,d,{fireGoal:()=>{A.current||(A.current=!0,n.track({projectId:r,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:v({reward:1},b!==void 0?{goalValue:b}:{})}),n.goal(l,v({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},b!==void 0?{value:b}:{})))},fireStep:(S,O,L)=>{n.track({projectId:r,componentId:e,variantId:s,eventType:"goal_achieved",goalType:S,payload:{reward:O}}),n.goal(S,{metadata:{},weight:O,stepIndex:L})}},l)},[n,p,s,r,e,d,l,a,g]),(0,T.useEffect)(()=>{if(a||!n||!s||!p)return;let b=Date.now();return(0,Yt.attachMicroSignalDetectors)((S,O={})=>{n.track({projectId:r,componentId:e,variantId:s,eventType:"micro_signal",payload:v({signalType:S},O)})},p,b)},[n,p,s,r,e,a]),(0,T.useEffect)(()=>{if(!E()||!n)return;let b=setTimeout(()=>{!x.current&&!Zt.has(e)&&(Zt.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(b)},[n,e]);let _=(0,T.useCallback)((b,S)=>{var L,M;if(a)return;let O=b!=null?b:l;O&&(n==null||n.componentGoal(e,O,S),n==null||n.goal(O,v(v(v({metadata:(L=S==null?void 0:S.metadata)!=null?L:{},weight:(M=S==null?void 0:S.reward)!=null?M:1,stepIndex:0},(S==null?void 0:S.value)!==void 0?{value:S.value}:{}),(S==null?void 0:S.currency)!==void 0?{currency:S.currency}:{}),(S==null?void 0:S.externalId)!==void 0?{externalId:S.externalId}:{})))},[n,e,l,a]),R=(0,T.useMemo)(()=>({ref:w,"data-sentient-id":e,"data-sentient-variant":s}),[w,e,s]);return{variant:s,value:u,bind:R,fireGoal:_}}var F=require("react");var tn=require("react/jsx-runtime"),_e=new Set;function en(e){var l;let t=G(),n=V(),r=(0,F.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,F.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,F.useMemo)(()=>v({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:g}=Ce(e.id,c);E()&&e.baseline!==void 0&&e.baseline!==o[0]&&!_e.has(e.id+":baseline")&&(_e.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=F.Children.toArray(e.children).filter(F.isValidElement),u=new Map;for(let f of s)u.set(String((l=f.key)!=null?l:"").replace(/^\.\$/,""),f);let p=e.arrangements[a],m=p!==void 0&&p.length===s.length&&p.every(f=>u.has(f));E()&&p!==void 0&&!m&&!_e.has(e.id+":keys")&&(_e.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${p.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=m?p.map(f=>u.get(f)):s;(0,F.useEffect)(()=>ie({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=(0,F.useRef)(null);(0,F.useEffect)(()=>{!t||g==="baseline"||g==="override"||w.current===a||(w.current=a,H(t,n,e.id,a))},[t,n,e.id,a,g]);let h=e.funnel;(0,F.useEffect)(()=>{var f;!t||!h||g==="override"||Z(t,n,e.id,h,B((f=e.goal)!=null?f:"click"))},[t,n,e.id,h,g]);let d=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,F.useEffect)(()=>{if(!t||e.goal===void 0||g==="override"||g==="baseline")return;let f=r.current;if(!f)return;let y=q(e.goal),A=K(e.goal),_=!1;return j(f,B(e.goal),{fireGoal:()=>{_||(_=!0,A!==void 0?t.componentGoal(e.id,y,{value:A}):t.componentGoal(e.id,y),t.goal(y,v({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(R,C,b)=>{t.componentGoal(e.id,R,{reward:C}),t.goal(R,{metadata:{componentId:e.id,arm:a},weight:C,stepIndex:b})}},y)},[t,e.id,d,a,g]),(0,tn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Ne=require("@sentientui/core");var In=["page","blocks","layoutOrder"],nn=new Map;function rn(e,t){nn.set(e,t)}function Ke(e){return nn.get(e)}function on(e){var i,o;let t=(o=(i=e.content)!=null?i:Ke(e.page))!=null?o:{},n={};for(let[c,a]of Object.entries(t))In.includes(c)||(n[c]=a);let r=J(v({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function sn(e){return`<script type="application/ld+json">${je(e)}</script>`}function je(e){return JSON.stringify(v({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function an(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
|
-
`}var
|
|
4
|
+
`}var ln=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
|