@sentientui/core 0.33.0 → 0.34.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/chunk-3FKD44SF.mjs +2 -0
- package/dist/chunk-3FKD44SF.mjs.map +1 -0
- package/dist/chunk-DGRAS5VP.mjs +2 -0
- package/dist/chunk-DGRAS5VP.mjs.map +1 -0
- package/dist/{index-CgkImSaM.d.ts → index-C2EOL-_c.d.cts} +43 -4
- package/dist/{index-COl_pfNm.d.cts → index-DrMXbLKP.d.ts} +43 -4
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +6 -4
- package/dist/index-graph.d.ts +6 -4
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-graph.mjs.map +1 -1
- package/dist/index-local.d.cts +4 -2
- package/dist/index-local.d.ts +4 -2
- package/dist/index-region.d.cts +40 -0
- package/dist/index-region.d.ts +40 -0
- package/dist/index-region.js +2 -0
- package/dist/index-region.js.map +1 -0
- package/dist/index-region.mjs +2 -0
- package/dist/index-region.mjs.map +1 -0
- package/dist/index-server.d.cts +15 -2
- package/dist/index-server.d.ts +15 -2
- package/dist/index-server.js +1 -1
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +1 -1
- package/dist/index-server.mjs.map +1 -1
- package/dist/index-style-sample.d.cts +12 -0
- package/dist/index-style-sample.d.ts +12 -0
- package/dist/index-style-sample.js +2 -0
- package/dist/index-style-sample.js.map +1 -0
- package/dist/index-style-sample.mjs +2 -0
- package/dist/index-style-sample.mjs.map +1 -0
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/region-skeleton-CQ4yhVw1.d.cts +56 -0
- package/dist/region-skeleton-CQ4yhVw1.d.ts +56 -0
- package/dist/session-meta-CWGtzFOQ.d.ts +226 -0
- package/dist/session-meta-KwDqU9a8.d.cts +226 -0
- package/dist/style-vocabulary-BqviEw9O.d.cts +285 -0
- package/dist/style-vocabulary-BqviEw9O.d.ts +285 -0
- package/package.json +11 -1
- package/dist/chunk-EVYMV2C6.mjs +0 -2
- package/dist/chunk-EVYMV2C6.mjs.map +0 -1
- package/dist/session-meta-DydKfQiR.d.cts +0 -416
- package/dist/session-meta-DydKfQiR.d.ts +0 -416
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index-style-sample.ts","../src/style-sample.ts","../src/style-vocabulary.ts"],"sourcesContent":["/** `@sentientui/core/style-sample`: the site-style sampler for trusted\n * sessions only (editor overlay, dashboard-opened React pages). Never\n * imported by the lean entry. */\nexport { sampleStyleVocabulary } from './style-sample.js';\nexport { STYLE_ROLES, LIKE_ID_RE, MAX_STYLE_ENTRIES, MAX_SITE_IMAGES } from './style-vocabulary.js';\n","// Browser sampler for the site style vocabulary (spec 2026-09-23 §4.2).\n// Runs only in TRUSTED sessions — the on-site editor overlay and React pages\n// opened from the dashboard with an editor token — and ships on its own\n// subpath (`@sentientui/core/style-sample`), so no visitor bundle carries it.\n//\n// It reads the live page the way a designer would: which class lists the site\n// actually uses for its buttons, headings, lead copy, cards and sections, with\n// the computed colors that make a generated section's contrast judgeable.\n// Classification is deterministic and computed-style based (the same approach\n// as the palette sampler): no class-name guessing, so it works on Tailwind,\n// BEM and hashed CSS-module names alike.\nimport type { SiteImage, StyleEntry, StyleRole } from './style-vocabulary.js';\n\ntype Sampled = Omit<StyleEntry, 'source'>;\n\nconst PER_ROLE = 4;\nconst BUTTON_DISPLAYS = new Set(['inline-block', 'block', 'flex', 'inline-flex']);\nconst HEADING_TAGS: Record<string, StyleRole> = { H1: 'heading-1', H2: 'heading-2', H3: 'heading-3' };\n\ntype RGBA = { r: number; g: number; b: number; a: number };\n\nfunction parseColor(c: string): RGBA | null {\n const m = /rgba?\\(\\s*([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)(?:[,\\s/]+([\\d.]+%?))?\\s*\\)/i.exec(c);\n if (!m) return null;\n const a = m[4] === undefined ? 1 : m[4].endsWith('%') ? Number.parseFloat(m[4]) / 100 : Number(m[4]);\n return { r: Number(m[1]), g: Number(m[2]), b: Number(m[3]), a };\n}\n\n// WCAG relative luminance — duplicated from the API's contrastRatio on\n// purpose: core can't import server code, and it's ten lines.\nfunction luminance(c: RGBA): number {\n const ch = (v: number) => {\n const s = v / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * ch(c.r) + 0.7152 * ch(c.g) + 0.0722 * ch(c.b);\n}\n\nfunction contrast(a: RGBA, b: RGBA): number {\n const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n return (hi + 0.05) / (lo + 0.05);\n}\n\nconst painted = (c: string): boolean => {\n const p = parseColor(c);\n return p !== null && p.a > 0;\n};\n\nfunction gradientStops(img: string): string[] {\n if (!img || img === 'none' || !/gradient/i.test(img)) return [];\n return img.match(/rgba?\\([^)]+\\)/gi) ?? [];\n}\n\nconst px = (v: string): number => {\n const n = Number.parseFloat(v);\n return Number.isFinite(n) ? n : 0;\n};\n\n/** The painted background an element sits on (itself or nearest ancestor). */\nfunction ambientBg(el: Element, view: Window): RGBA {\n for (let e: Element | null = el; e; e = e.parentElement) {\n const cs = view.getComputedStyle(e);\n if (painted(cs.backgroundColor)) return parseColor(cs.backgroundColor)!;\n const stops = gradientStops(cs.backgroundImage);\n if (stops.length > 0) return parseColor(stops[0]!)!;\n }\n return { r: 255, g: 255, b: 255, a: 1 };\n}\n\nfunction hasOwnText(el: Element): boolean {\n for (const n of Array.from(el.childNodes)) if (n.nodeType === 3 && (n.nodeValue ?? '').trim() !== '') return true;\n return false;\n}\n\nfunction classify(el: Element, cs: CSSStyleDeclaration, ctx: { bodySize: number; pageBg: RGBA; bodyContrast: number; view: Window; vw: number }): StyleRole | null {\n const tag = el.tagName;\n const fontSize = px(cs.fontSize) || ctx.bodySize;\n const weight = Number(cs.fontWeight) || 400;\n const bgPainted = painted(cs.backgroundColor);\n const gradient = gradientStops(cs.backgroundImage).length > 0;\n const radius = px(cs.borderTopLeftRadius || cs.borderRadius);\n const width = el.getBoundingClientRect().width; // 0 = unknown (no layout, e.g. jsdom)\n\n const isButtonLike =\n tag === 'BUTTON' ||\n el.getAttribute('role') === 'button' ||\n (tag === 'INPUT' && /^(submit|button)$/i.test((el as HTMLInputElement).type)) ||\n (tag === 'A' && BUTTON_DISPLAYS.has(cs.display) && px(cs.paddingLeft) >= 8);\n if (isButtonLike) {\n const bg = parseColor(cs.backgroundColor);\n if (bgPainted && bg && !(bg.r === ctx.pageBg.r && bg.g === ctx.pageBg.g && bg.b === ctx.pageBg.b)) return 'button-primary';\n if (px(cs.borderTopWidth) > 0) return 'button-secondary';\n return 'button-ghost';\n }\n if (tag === 'A') return 'link';\n if (HEADING_TAGS[tag]) return HEADING_TAGS[tag]!;\n if (hasOwnText(el) && fontSize >= 1.8 * ctx.bodySize && weight >= 600) {\n return fontSize >= 2.5 * ctx.bodySize ? 'heading-1' : fontSize >= 2 * ctx.bodySize ? 'heading-2' : 'heading-3';\n }\n // Eyebrow: small, tracked or uppercase, sitting right above a heading.\n const next = el.nextElementSibling;\n if (\n hasOwnText(el) &&\n fontSize <= 0.9 * ctx.bodySize &&\n (cs.textTransform === 'uppercase' || px(cs.letterSpacing) > 0.05 * fontSize) &&\n next !== null &&\n /^H[1-4]$/.test(next.tagName)\n ) {\n return 'eyebrow';\n }\n if (tag === 'UL' || tag === 'OL') return el.querySelectorAll(':scope > li').length >= 2 ? 'list' : null;\n if (tag === 'P' && hasOwnText(el)) {\n if (fontSize >= 1.1 * ctx.bodySize) return 'text-lead';\n if (fontSize <= 0.85 * ctx.bodySize) return 'text-small';\n const color = parseColor(cs.color);\n if (color && contrast(color, ambientBg(el, ctx.view)) < ctx.bodyContrast * 0.8) return 'text-muted';\n return 'text-body';\n }\n if ((tag === 'SPAN' || tag === 'DIV') && bgPainted && hasOwnText(el) && el.children.length === 0 && radius >= 999) return 'badge';\n if (/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(tag) && (bgPainted || gradient) && radius > 0 && px(cs.paddingTop) >= 16 && !(width > 0 && width >= 0.9 * ctx.vw)) {\n return 'card';\n }\n if (/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(tag) && (bgPainted || gradient) && el.querySelector('h1,h2,h3') !== null && (width === 0 || width >= 0.9 * ctx.vw)) {\n return 'section';\n }\n return null;\n}\n\nexport function sampleStyleVocabulary(doc: Document, opts?: { maxElements?: number }): { entries: Sampled[]; images: SiteImage[] } {\n const view = doc.defaultView;\n if (!view || !doc.body) return { entries: [], images: [] };\n const bodyCs = view.getComputedStyle(doc.body);\n const bodySize = px(bodyCs.fontSize) || 16;\n const pageBg = painted(bodyCs.backgroundColor) ? parseColor(bodyCs.backgroundColor)! : { r: 255, g: 255, b: 255, a: 1 };\n const bodyColor = parseColor(bodyCs.color) ?? { r: 17, g: 24, b: 39, a: 1 };\n const ctx = { bodySize, pageBg, bodyContrast: contrast(bodyColor, pageBg), view, vw: view.innerWidth || 0 };\n const url = view.location?.pathname ?? '/';\n const at = new Date().toISOString();\n\n const clusters = new Map<string, Sampled>(); // `${role}|${classes}`\n const images = new Map<string, SiteImage>();\n const all = Array.from(doc.body.querySelectorAll('*')).slice(0, opts?.maxElements ?? 4000);\n for (const el of all) {\n try {\n if (el.tagName === 'IMG') {\n const img = el as HTMLImageElement;\n const alt = (img.getAttribute('alt') ?? '').trim();\n const w = img.naturalWidth || Number(img.getAttribute('width')) || 0;\n const h = img.naturalHeight || Number(img.getAttribute('height')) || 0;\n const raw = img.getAttribute('src');\n if (alt && w >= 200 && raw) {\n const src = new URL(raw, doc.baseURI).href;\n if (src.startsWith('https://') && !images.has(src)) {\n images.set(src, { id: `img-${images.size + 1}`, src, alt: alt.slice(0, 200), w, h, seenOn: url });\n }\n }\n }\n const classes = (el.getAttribute('class') ?? '').replace(/\\s+/g, ' ').trim();\n if (classes === '') continue; // nothing to borrow\n const cs = view.getComputedStyle(el);\n const role = el.tagName === 'IMG' ? ((el.getAttribute('alt') ?? '').trim() ? 'image' : null) : classify(el, cs, ctx);\n if (!role) continue;\n const key = `${role}|${classes}`;\n const prev = clusters.get(key);\n if (prev) {\n prev.seen.count++;\n continue;\n }\n // Gradients: the contrast gate must judge text against the WORST stop,\n // so both stops are kept. `bg` = the lower-luminance stop, `bgDark` =\n // the other (the field name is historical, from the spec; the gate\n // checks both, so the order never affects correctness).\n const stops = gradientStops(cs.backgroundImage).map(parseColor).filter((c): c is RGBA => c !== null);\n let bg: string | undefined;\n let bgDark: string | undefined;\n if (painted(cs.backgroundColor)) bg = cs.backgroundColor;\n else if (stops.length > 0) {\n const sorted = [...stops].sort((a, b) => luminance(a) - luminance(b));\n const fmt = (c: RGBA) => (c.a < 1 ? `rgba(${c.r}, ${c.g}, ${c.b}, ${c.a})` : `rgb(${c.r}, ${c.g}, ${c.b})`);\n bg = fmt(sorted[0]!);\n if (sorted.length > 1) bgDark = fmt(sorted[sorted.length - 1]!);\n }\n const radius = cs.borderTopLeftRadius || cs.borderRadius;\n clusters.set(key, {\n id: role,\n role,\n classes,\n computed: {\n ...(cs.color ? { color: cs.color } : {}),\n ...(bg ? { bg } : {}),\n ...(bgDark ? { bgDark } : {}),\n ...(cs.fontSize ? { fontSize: cs.fontSize } : {}),\n ...(cs.fontWeight ? { fontWeight: cs.fontWeight } : {}),\n ...(radius && px(radius) > 0 ? { radius } : {}),\n },\n seen: { url, count: 1, at },\n });\n } catch {\n // A hostile or exotic element never breaks sampling of the rest.\n }\n }\n\n // Keep each role's most frequent class lists; ids role, role-2, …\n const byRole = new Map<StyleRole, Sampled[]>();\n for (const e of clusters.values()) byRole.set(e.role, [...(byRole.get(e.role) ?? []), e]);\n const entries: Sampled[] = [];\n for (const [role, list] of byRole) {\n list\n .sort((a, b) => b.seen.count - a.seen.count)\n .slice(0, PER_ROLE)\n .forEach((e, i) => entries.push({ ...e, id: i === 0 ? role : `${role}-${i + 1}` }));\n }\n return { entries, images: [...images.values()] };\n}\n","//\n// The site's own design system, as observed (spec 2026-09-23 §4.2). Every\n// entry is a class list seen on ONE real element of the live site — which on a\n// utility-CSS site is the only styling guaranteed to exist in the shipped CSS\n// (Tailwind purges the rest). Composed arms borrow these by id instead of\n// painting palette inline styles, which is what makes generated sections look\n// native instead of \"brand-colored generic\".\nimport type { BlockNode } from './blocks.js';\n\nexport const STYLE_ROLES = [\n 'button-primary', 'button-secondary', 'button-ghost', 'link',\n 'heading-1', 'heading-2', 'heading-3', 'eyebrow',\n 'text-lead', 'text-body', 'text-muted', 'text-small',\n 'badge', 'card', 'section', 'image', 'list',\n] as const;\nexport type StyleRole = (typeof STYLE_ROLES)[number];\n\n/** A resolved vocabulary id. `node:k` and `role:x` are authoring forms the\n * server resolves BEFORE persist — a stored or served tree only ever carries\n * ids that match this. */\nexport const LIKE_ID_RE = /^[a-z][a-z0-9-]{0,63}$/;\n\nexport const MAX_STYLE_ENTRIES = 60;\nexport const MAX_SITE_IMAGES = 40;\n\nexport type StyleEntry = {\n id: string;\n role: StyleRole;\n /** Exactly as observed on one element; validated server-side (validateClassList). */\n classes: string;\n /** Computed styles at observation time. Colors are what make the contrast\n * gate judgeable; an entry without them can't carry text in a Redesign. */\n computed: { color?: string; bg?: string; bgDark?: string; fontSize?: string; fontWeight?: string; radius?: string };\n seen: { url: string; count: number; at: string };\n source: 'editor' | 'crawl' | 'skeleton';\n};\n\nexport type SiteImage = { id: string; src: string; alt: string; w: number; h: number; seenOn: string };\n\nexport type StyleVocabulary = { rev: string; entries: StyleEntry[]; images: SiteImage[] };\n\n/** A Redesign arm: a composition tree whose visual nodes borrow site styles,\n * optionally painted on a site section/card surface. */\nexport type ComposeArm = { surface?: { like: string }; tree: BlockN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C,EAAS,OAAO,EAAGgB,EAAO,IAAIhD,EAAE,KAAM,CAAC,IAAIyB,EAAAuB,EAAO,IAAIhD,EAAE,IAAI,IAAjB,KAAAyB,EAAsB,CAAC,EAAIzB,CAAC,CAAC,EACxF,IAAMiD,EAAqB,CAAC,EAC5B,OAAW,CAACR,EAAMS,CAAI,IAAKF,EACzBE,EACG,KAAK,CAACvE,EAAGM,IAAMA,EAAE,KAAK,MAAQN,EAAE,KAAK,KAAK,EAC1C,MAAM,EAAG,CAAQ,EACjB,QAAQ,CAACqB,EAAGmD,IAAMF,EAAQ,KAAKG,EAAAL,EAAA,GAAK/C,GAAL,CAAQ,GAAImD,IAAM,EAAIV,EAAO,GAAGA,CAAI,IAAIU,EAAI,CAAC,EAAG,EAAC,CAAC,EAEtF,MAAO,CAAE,QAAAF,EAAS,OAAQ,CAAC,GAAGhB,EAAO,OAAO,CAAC,CAAE,CACjD,CC5MO,IAAMoB,GAAc,CACzB,iBAAkB,mBAAoB,eAAgB,OACtD,YAAa,YAAa,YAAa,UACvC,YAAa,YAAa,aAAc,aACxC,QAAS,OAAQ,UAAW,QAAS,MACvC,EAMaC,GAAa,yBAEbC,GAAoB,GACpBC,GAAkB","names":["index_style_sample_exports","__export","LIKE_ID_RE","MAX_SITE_IMAGES","MAX_STYLE_ENTRIES","STYLE_ROLES","sampleStyleVocabulary","__toCommonJS","BUTTON_DISPLAYS","HEADING_TAGS","parseColor","c","m","a","luminance","ch","v","s","contrast","b","hi","lo","x","y","painted","p","gradientStops","img","_a","px","n","ambientBg","el","view","e","cs","stops","hasOwnText","classify","ctx","tag","fontSize","weight","bgPainted","gradient","radius","width","bg","next","color","sampleStyleVocabulary","doc","opts","_b","_c","_d","_e","_f","_g","_h","bodyCs","bodySize","pageBg","bodyColor","url","at","clusters","images","all","alt","w","h","raw","src","classes","role","key","prev","bgDark","sorted","fmt","__spreadValues","byRole","entries","list","i","__spreadProps","STYLE_ROLES","LIKE_ID_RE","MAX_STYLE_ENTRIES","MAX_SITE_IMAGES"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as b,b as X}from"./chunk-TMCGHANO.mjs";var j=new Set(["inline-block","block","flex","inline-flex"]),q={H1:"heading-1",H2:"heading-2",H3:"heading-3"};function d(e){let t=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(e);if(!t)return null;let n=t[4]===void 0?1:t[4].endsWith("%")?Number.parseFloat(t[4])/100:Number(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:n}}function T(e){let t=n=>{let r=n/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function F(e,t){let[n,r]=[T(e),T(t)].sort((i,f)=>f-i);return(n+.05)/(r+.05)}var k=e=>{let t=d(e);return t!==null&&t.a>0};function _(e){var t;return!e||e==="none"||!/gradient/i.test(e)?[]:(t=e.match(/rgba?\([^)]+\)/gi))!=null?t:[]}var c=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function K(e,t){for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(k(r.backgroundColor))return d(r.backgroundColor);let i=_(r.backgroundImage);if(i.length>0)return d(i[0])}return{r:255,g:255,b:255,a:1}}function N(e){var t;for(let n of Array.from(e.childNodes))if(n.nodeType===3&&((t=n.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function J(e,t,n){let r=e.tagName,i=c(t.fontSize)||n.bodySize,f=Number(t.fontWeight)||400,S=k(t.backgroundColor),A=_(t.backgroundImage).length>0,h=c(t.borderTopLeftRadius||t.borderRadius),p=e.getBoundingClientRect().width;if(r==="BUTTON"||e.getAttribute("role")==="button"||r==="INPUT"&&/^(submit|button)$/i.test(e.type)||r==="A"&&j.has(t.display)&&c(t.paddingLeft)>=8){let u=d(t.backgroundColor);return S&&u&&!(u.r===n.pageBg.r&&u.g===n.pageBg.g&&u.b===n.pageBg.b)?"button-primary":c(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(r==="A")return"link";if(q[r])return q[r];if(N(e)&&i>=1.8*n.bodySize&&f>=600)return i>=2.5*n.bodySize?"heading-1":i>=2*n.bodySize?"heading-2":"heading-3";let m=e.nextElementSibling;if(N(e)&&i<=.9*n.bodySize&&(t.textTransform==="uppercase"||c(t.letterSpacing)>.05*i)&&m!==null&&/^H[1-4]$/.test(m.tagName))return"eyebrow";if(r==="UL"||r==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(r==="P"&&N(e)){if(i>=1.1*n.bodySize)return"text-lead";if(i<=.85*n.bodySize)return"text-small";let u=d(t.color);return u&&F(u,K(e,n.view))<n.bodyContrast*.8?"text-muted":"text-body"}return(r==="SPAN"||r==="DIV")&&S&&N(e)&&e.children.length===0&&h>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(r)&&(S||A)&&h>0&&c(t.paddingTop)>=16&&!(p>0&&p>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(r)&&(S||A)&&e.querySelector("h1,h2,h3")!==null&&(p===0||p>=.9*n.vw)?"section":null}function Q(e,t){var $,D,G,O,M,v,W,H;let n=e.defaultView;if(!n||!e.body)return{entries:[],images:[]};let r=n.getComputedStyle(e.body),i=c(r.fontSize)||16,f=k(r.backgroundColor)?d(r.backgroundColor):{r:255,g:255,b:255,a:1},S=($=d(r.color))!=null?$:{r:17,g:24,b:39,a:1},A={bodySize:i,pageBg:f,bodyContrast:F(S,f),view:n,vw:n.innerWidth||0},h=(G=(D=n.location)==null?void 0:D.pathname)!=null?G:"/",p=new Date().toISOString(),I=new Map,m=new Map,u=Array.from(e.body.querySelectorAll("*")).slice(0,(O=t==null?void 0:t.maxElements)!=null?O:4e3);for(let s of u)try{if(s.tagName==="IMG"){let a=s,E=((M=a.getAttribute("alt"))!=null?M:"").trim(),l=a.naturalWidth||Number(a.getAttribute("width"))||0,z=a.naturalHeight||Number(a.getAttribute("height"))||0,Y=a.getAttribute("src");if(E&&l>=200&&Y){let w=new URL(Y,e.baseURI).href;w.startsWith("https://")&&!m.has(w)&&m.set(w,{id:`img-${m.size+1}`,src:w,alt:E.slice(0,200),w:l,h:z,seenOn:h})}}let y=((v=s.getAttribute("class"))!=null?v:"").replace(/\s+/g," ").trim();if(y==="")continue;let o=n.getComputedStyle(s),g=s.tagName==="IMG"?((W=s.getAttribute("alt"))!=null?W:"").trim()?"image":null:J(s,o,A);if(!g)continue;let V=`${g}|${y}`,P=I.get(V);if(P){P.seen.count++;continue}let U=_(o.backgroundImage).map(d).filter(a=>a!==null),R,C;if(k(o.backgroundColor))R=o.backgroundColor;else if(U.length>0){let a=[...U].sort((l,z)=>T(l)-T(z)),E=l=>l.a<1?`rgba(${l.r}, ${l.g}, ${l.b}, ${l.a})`:`rgb(${l.r}, ${l.g}, ${l.b})`;R=E(a[0]),a.length>1&&(C=E(a[a.length-1]))}let B=o.borderTopLeftRadius||o.borderRadius;I.set(V,{id:g,role:g,classes:y,computed:b(b(b(b(b(b({},o.color?{color:o.color}:{}),R?{bg:R}:{}),C?{bgDark:C}:{}),o.fontSize?{fontSize:o.fontSize}:{}),o.fontWeight?{fontWeight:o.fontWeight}:{}),B&&c(B)>0?{radius:B}:{}),seen:{url:h,count:1,at:p}})}catch(y){}let L=new Map;for(let s of I.values())L.set(s.role,[...(H=L.get(s.role))!=null?H:[],s]);let x=[];for(let[s,y]of L)y.sort((o,g)=>g.seen.count-o.seen.count).slice(0,4).forEach((o,g)=>x.push(X(b({},o),{id:g===0?s:`${s}-${g+1}`})));return{entries:x,images:[...m.values()]}}var Z=["button-primary","button-secondary","button-ghost","link","heading-1","heading-2","heading-3","eyebrow","text-lead","text-body","text-muted","text-small","badge","card","section","image","list"],tt=/^[a-z][a-z0-9-]{0,63}$/,et=60,nt=40;export{tt as LIKE_ID_RE,nt as MAX_SITE_IMAGES,et as MAX_STYLE_ENTRIES,Z as STYLE_ROLES,Q as sampleStyleVocabulary};
|
|
2
|
+
//# sourceMappingURL=index-style-sample.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/style-sample.ts","../src/style-vocabulary.ts"],"sourcesContent":["// Browser sampler for the site style vocabulary (spec 2026-09-23 §4.2).\n// Runs only in TRUSTED sessions — the on-site editor overlay and React pages\n// opened from the dashboard with an editor token — and ships on its own\n// subpath (`@sentientui/core/style-sample`), so no visitor bundle carries it.\n//\n// It reads the live page the way a designer would: which class lists the site\n// actually uses for its buttons, headings, lead copy, cards and sections, with\n// the computed colors that make a generated section's contrast judgeable.\n// Classification is deterministic and computed-style based (the same approach\n// as the palette sampler): no class-name guessing, so it works on Tailwind,\n// BEM and hashed CSS-module names alike.\nimport type { SiteImage, StyleEntry, StyleRole } from './style-vocabulary.js';\n\ntype Sampled = Omit<StyleEntry, 'source'>;\n\nconst PER_ROLE = 4;\nconst BUTTON_DISPLAYS = new Set(['inline-block', 'block', 'flex', 'inline-flex']);\nconst HEADING_TAGS: Record<string, StyleRole> = { H1: 'heading-1', H2: 'heading-2', H3: 'heading-3' };\n\ntype RGBA = { r: number; g: number; b: number; a: number };\n\nfunction parseColor(c: string): RGBA | null {\n const m = /rgba?\\(\\s*([\\d.]+)[,\\s]+([\\d.]+)[,\\s]+([\\d.]+)(?:[,\\s/]+([\\d.]+%?))?\\s*\\)/i.exec(c);\n if (!m) return null;\n const a = m[4] === undefined ? 1 : m[4].endsWith('%') ? Number.parseFloat(m[4]) / 100 : Number(m[4]);\n return { r: Number(m[1]), g: Number(m[2]), b: Number(m[3]), a };\n}\n\n// WCAG relative luminance — duplicated from the API's contrastRatio on\n// purpose: core can't import server code, and it's ten lines.\nfunction luminance(c: RGBA): number {\n const ch = (v: number) => {\n const s = v / 255;\n return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * ch(c.r) + 0.7152 * ch(c.g) + 0.0722 * ch(c.b);\n}\n\nfunction contrast(a: RGBA, b: RGBA): number {\n const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n return (hi + 0.05) / (lo + 0.05);\n}\n\nconst painted = (c: string): boolean => {\n const p = parseColor(c);\n return p !== null && p.a > 0;\n};\n\nfunction gradientStops(img: string): string[] {\n if (!img || img === 'none' || !/gradient/i.test(img)) return [];\n return img.match(/rgba?\\([^)]+\\)/gi) ?? [];\n}\n\nconst px = (v: string): number => {\n const n = Number.parseFloat(v);\n return Number.isFinite(n) ? n : 0;\n};\n\n/** The painted background an element sits on (itself or nearest ancestor). */\nfunction ambientBg(el: Element, view: Window): RGBA {\n for (let e: Element | null = el; e; e = e.parentElement) {\n const cs = view.getComputedStyle(e);\n if (painted(cs.backgroundColor)) return parseColor(cs.backgroundColor)!;\n const stops = gradientStops(cs.backgroundImage);\n if (stops.length > 0) return parseColor(stops[0]!)!;\n }\n return { r: 255, g: 255, b: 255, a: 1 };\n}\n\nfunction hasOwnText(el: Element): boolean {\n for (const n of Array.from(el.childNodes)) if (n.nodeType === 3 && (n.nodeValue ?? '').trim() !== '') return true;\n return false;\n}\n\nfunction classify(el: Element, cs: CSSStyleDeclaration, ctx: { bodySize: number; pageBg: RGBA; bodyContrast: number; view: Window; vw: number }): StyleRole | null {\n const tag = el.tagName;\n const fontSize = px(cs.fontSize) || ctx.bodySize;\n const weight = Number(cs.fontWeight) || 400;\n const bgPainted = painted(cs.backgroundColor);\n const gradient = gradientStops(cs.backgroundImage).length > 0;\n const radius = px(cs.borderTopLeftRadius || cs.borderRadius);\n const width = el.getBoundingClientRect().width; // 0 = unknown (no layout, e.g. jsdom)\n\n const isButtonLike =\n tag === 'BUTTON' ||\n el.getAttribute('role') === 'button' ||\n (tag === 'INPUT' && /^(submit|button)$/i.test((el as HTMLInputElement).type)) ||\n (tag === 'A' && BUTTON_DISPLAYS.has(cs.display) && px(cs.paddingLeft) >= 8);\n if (isButtonLike) {\n const bg = parseColor(cs.backgroundColor);\n if (bgPainted && bg && !(bg.r === ctx.pageBg.r && bg.g === ctx.pageBg.g && bg.b === ctx.pageBg.b)) return 'button-primary';\n if (px(cs.borderTopWidth) > 0) return 'button-secondary';\n return 'button-ghost';\n }\n if (tag === 'A') return 'link';\n if (HEADING_TAGS[tag]) return HEADING_TAGS[tag]!;\n if (hasOwnText(el) && fontSize >= 1.8 * ctx.bodySize && weight >= 600) {\n return fontSize >= 2.5 * ctx.bodySize ? 'heading-1' : fontSize >= 2 * ctx.bodySize ? 'heading-2' : 'heading-3';\n }\n // Eyebrow: small, tracked or uppercase, sitting right above a heading.\n const next = el.nextElementSibling;\n if (\n hasOwnText(el) &&\n fontSize <= 0.9 * ctx.bodySize &&\n (cs.textTransform === 'uppercase' || px(cs.letterSpacing) > 0.05 * fontSize) &&\n next !== null &&\n /^H[1-4]$/.test(next.tagName)\n ) {\n return 'eyebrow';\n }\n if (tag === 'UL' || tag === 'OL') return el.querySelectorAll(':scope > li').length >= 2 ? 'list' : null;\n if (tag === 'P' && hasOwnText(el)) {\n if (fontSize >= 1.1 * ctx.bodySize) return 'text-lead';\n if (fontSize <= 0.85 * ctx.bodySize) return 'text-small';\n const color = parseColor(cs.color);\n if (color && contrast(color, ambientBg(el, ctx.view)) < ctx.bodyContrast * 0.8) return 'text-muted';\n return 'text-body';\n }\n if ((tag === 'SPAN' || tag === 'DIV') && bgPainted && hasOwnText(el) && el.children.length === 0 && radius >= 999) return 'badge';\n if (/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(tag) && (bgPainted || gradient) && radius > 0 && px(cs.paddingTop) >= 16 && !(width > 0 && width >= 0.9 * ctx.vw)) {\n return 'card';\n }\n if (/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(tag) && (bgPainted || gradient) && el.querySelector('h1,h2,h3') !== null && (width === 0 || width >= 0.9 * ctx.vw)) {\n return 'section';\n }\n return null;\n}\n\nexport function sampleStyleVocabulary(doc: Document, opts?: { maxElements?: number }): { entries: Sampled[]; images: SiteImage[] } {\n const view = doc.defaultView;\n if (!view || !doc.body) return { entries: [], images: [] };\n const bodyCs = view.getComputedStyle(doc.body);\n const bodySize = px(bodyCs.fontSize) || 16;\n const pageBg = painted(bodyCs.backgroundColor) ? parseColor(bodyCs.backgroundColor)! : { r: 255, g: 255, b: 255, a: 1 };\n const bodyColor = parseColor(bodyCs.color) ?? { r: 17, g: 24, b: 39, a: 1 };\n const ctx = { bodySize, pageBg, bodyContrast: contrast(bodyColor, pageBg), view, vw: view.innerWidth || 0 };\n const url = view.location?.pathname ?? '/';\n const at = new Date().toISOString();\n\n const clusters = new Map<string, Sampled>(); // `${role}|${classes}`\n const images = new Map<string, SiteImage>();\n const all = Array.from(doc.body.querySelectorAll('*')).slice(0, opts?.maxElements ?? 4000);\n for (const el of all) {\n try {\n if (el.tagName === 'IMG') {\n const img = el as HTMLImageElement;\n const alt = (img.getAttribute('alt') ?? '').trim();\n const w = img.naturalWidth || Number(img.getAttribute('width')) || 0;\n const h = img.naturalHeight || Number(img.getAttribute('height')) || 0;\n const raw = img.getAttribute('src');\n if (alt && w >= 200 && raw) {\n const src = new URL(raw, doc.baseURI).href;\n if (src.startsWith('https://') && !images.has(src)) {\n images.set(src, { id: `img-${images.size + 1}`, src, alt: alt.slice(0, 200), w, h, seenOn: url });\n }\n }\n }\n const classes = (el.getAttribute('class') ?? '').replace(/\\s+/g, ' ').trim();\n if (classes === '') continue; // nothing to borrow\n const cs = view.getComputedStyle(el);\n const role = el.tagName === 'IMG' ? ((el.getAttribute('alt') ?? '').trim() ? 'image' : null) : classify(el, cs, ctx);\n if (!role) continue;\n const key = `${role}|${classes}`;\n const prev = clusters.get(key);\n if (prev) {\n prev.seen.count++;\n continue;\n }\n // Gradients: the contrast gate must judge text against the WORST stop,\n // so both stops are kept. `bg` = the lower-luminance stop, `bgDark` =\n // the other (the field name is historical, from the spec; the gate\n // checks both, so the order never affects correctness).\n const stops = gradientStops(cs.backgroundImage).map(parseColor).filter((c): c is RGBA => c !== null);\n let bg: string | undefined;\n let bgDark: string | undefined;\n if (painted(cs.backgroundColor)) bg = cs.backgroundColor;\n else if (stops.length > 0) {\n const sorted = [...stops].sort((a, b) => luminance(a) - luminance(b));\n const fmt = (c: RGBA) => (c.a < 1 ? `rgba(${c.r}, ${c.g}, ${c.b}, ${c.a})` : `rgb(${c.r}, ${c.g}, ${c.b})`);\n bg = fmt(sorted[0]!);\n if (sorted.length > 1) bgDark = fmt(sorted[sorted.length - 1]!);\n }\n const radius = cs.borderTopLeftRadius || cs.borderRadius;\n clusters.set(key, {\n id: role,\n role,\n classes,\n computed: {\n ...(cs.color ? { color: cs.color } : {}),\n ...(bg ? { bg } : {}),\n ...(bgDark ? { bgDark } : {}),\n ...(cs.fontSize ? { fontSize: cs.fontSize } : {}),\n ...(cs.fontWeight ? { fontWeight: cs.fontWeight } : {}),\n ...(radius && px(radius) > 0 ? { radius } : {}),\n },\n seen: { url, count: 1, at },\n });\n } catch {\n // A hostile or exotic element never breaks sampling of the rest.\n }\n }\n\n // Keep each role's most frequent class lists; ids role, role-2, …\n const byRole = new Map<StyleRole, Sampled[]>();\n for (const e of clusters.values()) byRole.set(e.role, [...(byRole.get(e.role) ?? []), e]);\n const entries: Sampled[] = [];\n for (const [role, list] of byRole) {\n list\n .sort((a, b) => b.seen.count - a.seen.count)\n .slice(0, PER_ROLE)\n .forEach((e, i) => entries.push({ ...e, id: i === 0 ? role : `${role}-${i + 1}` }));\n }\n return { entries, images: [...images.values()] };\n}\n","//\n// The site's own design system, as observed (spec 2026-09-23 §4.2). Every\n// entry is a class list seen on ONE real element of the live site — which on a\n// utility-CSS site is the only styling guaranteed to exist in the shipped CSS\n// (Tailwind purges the rest). Composed arms borrow these by id instead of\n// painting palette inline styles, which is what makes generated sections look\n// native instead of \"brand-colored generic\".\nimport type { BlockNode } from './blocks.js';\n\nexport const STYLE_ROLES = [\n 'button-primary', 'button-secondary', 'button-ghost', 'link',\n 'heading-1', 'heading-2', 'heading-3', 'eyebrow',\n 'text-lead', 'text-body', 'text-muted', 'text-small',\n 'badge', 'card', 'section', 'image', 'list',\n] as const;\nexport type StyleRole = (typeof STYLE_ROLES)[number];\n\n/** A resolved vocabulary id. `node:k` and `role:x` are authoring forms the\n * server resolves BEFORE persist — a stored or served tree only ever carries\n * ids that match this. */\nexport const LIKE_ID_RE = /^[a-z][a-z0-9-]{0,63}$/;\n\nexport const MAX_STYLE_ENTRIES = 60;\nexport const MAX_SITE_IMAGES = 40;\n\nexport type StyleEntry = {\n id: string;\n role: StyleRole;\n /** Exactly as observed on one element; validated server-side (validateClassList). */\n classes: string;\n /** Computed styles at observation time. Colors are what make the contrast\n * gate judgeable; an entry without them can't carry text in a Redesign. */\n computed: { color?: string; bg?: string; bgDark?: string; fontSize?: string; fontWeight?: string; radius?: string };\n seen: { url: string; count: number; at: string };\n source: 'editor' | 'crawl' | 'skeleton';\n};\n\nexport type SiteImage = { id: string; src: string; alt: string; w: number; h: number; seenOn: string };\n\nexport type StyleVocabulary = { rev: string; entries: StyleEntry[]; images: SiteImage[] };\n\n/** A Redesign arm: a composition tree whose visual nodes borrow site styles,\n * optionally painted on a site section/card surface. */\nexport type ComposeArm = { surface?: { like: string }; tree: BlockNode };\n"],"mappings":"gDAgBA,IAAMA,EAAkB,IAAI,IAAI,CAAC,eAAgB,QAAS,OAAQ,aAAa,CAAC,EAC1EC,EAA0C,CAAE,GAAI,YAAa,GAAI,YAAa,GAAI,WAAY,EAIpG,SAASC,EAAWC,EAAwB,CAC1C,IAAMC,EAAI,6EAA6E,KAAKD,CAAC,EAC7F,GAAI,CAACC,EAAG,OAAO,KACf,IAAMC,EAAID,EAAE,CAAC,IAAM,OAAY,EAAIA,EAAE,CAAC,EAAE,SAAS,GAAG,EAAI,OAAO,WAAWA,EAAE,CAAC,CAAC,EAAI,IAAM,OAAOA,EAAE,CAAC,CAAC,EACnG,MAAO,CAAE,EAAG,OAAOA,EAAE,CAAC,CAAC,EAAG,EAAG,OAAOA,EAAE,CAAC,C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AAgB,OACtD,YAAa,YAAa,YAAa,UACvC,YAAa,YAAa,aAAc,aACxC,QAAS,OAAQ,UAAW,QAAS,MACvC,EAMaC,GAAa,yBAEbC,GAAoB,GACpBC,GAAkB","names":["BUTTON_DISPLAYS","HEADING_TAGS","parseColor","c","m","a","luminance","ch","v","s","contrast","b","hi","lo","x","y","painted","p","gradientStops","img","_a","px","n","ambientBg","el","view","e","cs","stops","hasOwnText","classify","ctx","tag","fontSize","weight","bgPainted","gradient","radius","width","bg","next","color","sampleStyleVocabulary","doc","opts","_b","_c","_d","_e","_f","_g","_h","bodyCs","bodySize","pageBg","bodyColor","url","at","clusters","images","all","alt","w","h","raw","src","classes","role","key","prev","bgDark","sorted","fmt","__spreadValues","byRole","entries","list","i","__spreadProps","STYLE_ROLES","LIKE_ID_RE","MAX_STYLE_ENTRIES","MAX_SITE_IMAGES"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { A as AssignResult, a as Assignment, C as ComponentGoalOptions,
|
|
1
|
+
export { B as BLOCK_ALIGNS, a as BLOCK_EMPHASES, b as BLOCK_FITS, c as BLOCK_GAPS, d as BLOCK_GRID_COLUMNS, e as BLOCK_HEADING_LEVELS, f as BLOCK_JUSTIFIES, g as BLOCK_MAX_WIDTHS, h as BLOCK_PADS, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_SURFACES, l as BLOCK_TEXT_ALIGNS, m as BLOCK_TONES, n as BLOCK_WEIGHTS, o as BadgeBlock, p as BlockAlign, q as BlockEmphasis, r as BlockFit, s as BlockGap, t as BlockJustify, u as BlockMaxWidth, v as BlockNode, w as BlockPad, x as BlockRatio, y as BlockSize, z as BlockSurface, A as BlockTextAlign, C as BlockTone, D as BlockWeight, E as ButtonBlock, F as ComposeArm, G as DividerBlock, H as FORM_FIELD_KINDS, I as FORM_INPUT_TYPES, J as FormBlock, K as FormField, L as GridBlock, M as HeadingBlock, N as ImageBlock, P as LinkBlock, Q as MAX_BLOCK_ARMS, R as MAX_BLOCK_CHILDREN, S as MAX_BLOCK_DEPTH, T as MAX_BLOCK_NODES, U as MAX_BLOCK_TEXT_LEN, V as MAX_FORM_FIELDS, W as MAX_FORM_SELECT_OPTIONS, _ as SiteImage, $ as SitePalette, a0 as SpacerBlock, a1 as StackBlock, a2 as StyleEntry, a3 as StyleRole, a4 as StyleVocabulary, a5 as TextBlock, a6 as containsFormBlock } from './style-vocabulary-BqviEw9O.cjs';
|
|
2
|
+
export { A as AssignResult, a as Assignment, c as AuthoredArmReport, C as ComponentGoalOptions, d as ComponentWeightEntry, D as DecideInput, e as DecideOutcome, f as EventType, G as GoalDefinition, g as GoalOptions, i as GraphConfig, j as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, k as LOCAL_MODE_BANNER, M as MicroSignalEmitter, l as MicroSignalType, P as PAGE_SCOPE_RE, m as PROD_KEYLESS_ERROR, Q as QueueConfig, R as REVEAL_MS, o as RevealOptions, S as SectionMapEntry, p as SentientClient, q as SentientConfig, r as SentientEvent, s as SessionConfig, t as SessionManager, u as SkeletonReport, W as WeightEntry, _ as _registerConsentUpgradeInit, v as attachMicroSignalDetectors, w as grantConsent, x as init, y as isDoNotTrackEnabled, z as pageScopeMatches, B as resetRevealStyles, F as reveal, I as sessionCookieName } from './index-C2EOL-_c.cjs';
|
|
3
|
+
export { A as AGENT_INTENTS, a as AgentIntent, C as CLICK_ID_KEYS, b as CompoundLocator, D as DecisionSnapshot, S as SNAPSHOT_STORAGE_KEY_PREFIX, d as SlotConfigEntry, e as SlotDeclInput, f as SlotOps, g as agentIntent, h as agentUaList, i as armOfResult, j as baselineResultFor, k as baselineSlots, m as classifiedAgents, n as deriveSessionSegment, o as detectDeviceClass, p as detectTimeOfDay, q as detectTrafficSource, r as extractTrackedParams, s as matchedAgentToken, t as readSnapshot, u as referrerDomainFromReferer, v as renderPrePaintScript, w as toWireSlot, x as uaTokenMatch, y as writeSnapshot } from './session-meta-KwDqU9a8.cjs';
|
|
4
|
+
export { A as ArmEdits, M as MAX_SKELETON_LEAVES, a as MAX_SKELETON_NODES, b as MAX_SKELETON_TEXT, R as RegionSkeleton, c as RenderCaps, S as ServedEdits, d as SkeletonNode, e as SkeletonRole } from './region-skeleton-CQ4yhVw1.cjs';
|
|
3
5
|
export { SlotResult } from '@sentientui/policy';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { A as AssignResult, a as Assignment, C as ComponentGoalOptions,
|
|
1
|
+
export { B as BLOCK_ALIGNS, a as BLOCK_EMPHASES, b as BLOCK_FITS, c as BLOCK_GAPS, d as BLOCK_GRID_COLUMNS, e as BLOCK_HEADING_LEVELS, f as BLOCK_JUSTIFIES, g as BLOCK_MAX_WIDTHS, h as BLOCK_PADS, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_SURFACES, l as BLOCK_TEXT_ALIGNS, m as BLOCK_TONES, n as BLOCK_WEIGHTS, o as BadgeBlock, p as BlockAlign, q as BlockEmphasis, r as BlockFit, s as BlockGap, t as BlockJustify, u as BlockMaxWidth, v as BlockNode, w as BlockPad, x as BlockRatio, y as BlockSize, z as BlockSurface, A as BlockTextAlign, C as BlockTone, D as BlockWeight, E as ButtonBlock, F as ComposeArm, G as DividerBlock, H as FORM_FIELD_KINDS, I as FORM_INPUT_TYPES, J as FormBlock, K as FormField, L as GridBlock, M as HeadingBlock, N as ImageBlock, P as LinkBlock, Q as MAX_BLOCK_ARMS, R as MAX_BLOCK_CHILDREN, S as MAX_BLOCK_DEPTH, T as MAX_BLOCK_NODES, U as MAX_BLOCK_TEXT_LEN, V as MAX_FORM_FIELDS, W as MAX_FORM_SELECT_OPTIONS, _ as SiteImage, $ as SitePalette, a0 as SpacerBlock, a1 as StackBlock, a2 as StyleEntry, a3 as StyleRole, a4 as StyleVocabulary, a5 as TextBlock, a6 as containsFormBlock } from './style-vocabulary-BqviEw9O.js';
|
|
2
|
+
export { A as AssignResult, a as Assignment, c as AuthoredArmReport, C as ComponentGoalOptions, d as ComponentWeightEntry, D as DecideInput, e as DecideOutcome, f as EventType, G as GoalDefinition, g as GoalOptions, i as GraphConfig, j as GraphSnapshot, L as LEGACY_SESSION_COOKIE_NAME, k as LOCAL_MODE_BANNER, M as MicroSignalEmitter, l as MicroSignalType, P as PAGE_SCOPE_RE, m as PROD_KEYLESS_ERROR, Q as QueueConfig, R as REVEAL_MS, o as RevealOptions, S as SectionMapEntry, p as SentientClient, q as SentientConfig, r as SentientEvent, s as SessionConfig, t as SessionManager, u as SkeletonReport, W as WeightEntry, _ as _registerConsentUpgradeInit, v as attachMicroSignalDetectors, w as grantConsent, x as init, y as isDoNotTrackEnabled, z as pageScopeMatches, B as resetRevealStyles, F as reveal, I as sessionCookieName } from './index-DrMXbLKP.js';
|
|
3
|
+
export { A as AGENT_INTENTS, a as AgentIntent, C as CLICK_ID_KEYS, b as CompoundLocator, D as DecisionSnapshot, S as SNAPSHOT_STORAGE_KEY_PREFIX, d as SlotConfigEntry, e as SlotDeclInput, f as SlotOps, g as agentIntent, h as agentUaList, i as armOfResult, j as baselineResultFor, k as baselineSlots, m as classifiedAgents, n as deriveSessionSegment, o as detectDeviceClass, p as detectTimeOfDay, q as detectTrafficSource, r as extractTrackedParams, s as matchedAgentToken, t as readSnapshot, u as referrerDomainFromReferer, v as renderPrePaintScript, w as toWireSlot, x as uaTokenMatch, y as writeSnapshot } from './session-meta-CWGtzFOQ.js';
|
|
4
|
+
export { A as ArmEdits, M as MAX_SKELETON_LEAVES, a as MAX_SKELETON_NODES, b as MAX_SKELETON_TEXT, R as RegionSkeleton, c as RenderCaps, S as ServedEdits, d as SkeletonNode, e as SkeletonRole } from './region-skeleton-CQ4yhVw1.js';
|
|
3
5
|
export { SlotResult } from '@sentientui/policy';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var tn=Object.create;var we=Object.defineProperty,nn=Object.defineProperties,on=Object.getOwnPropertyDescriptor,rn=Object.getOwnPropertyDescriptors,sn=Object.getOwnPropertyNames,It=Object.getOwnPropertySymbols,an=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable;var _t=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&_t(e,n,t[n]);if(It)for(var n of It(t))ln.call(t,n)&&_t(e,n,t[n]);return e},de=(e,t)=>nn(e,rn(t));var cn=(e,t)=>{for(var n in t)we(e,n,{get:t[n],enumerable:!0})},Rt=(e,t,n,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of sn(t))!Ct.call(e,g)&&g!==n&&we(e,g,{get:()=>t[g],enumerable:!(u=on(t,g))||u.enumerable});return e};var dn=(e,t,n)=>(n=e!=null?tn(an(e)):{},Rt(t||!e||!e.__esModule?we(n,"default",{value:e,enumerable:!0}):n,e)),un=e=>Rt(we({},"__esModule",{value:!0}),e);var po={};cn(po,{AGENT_INTENTS:()=>Ke,BLOCK_ALIGNS:()=>Pn,BLOCK_EMPHASES:()=>Nn,BLOCK_FITS:()=>Un,BLOCK_GAPS:()=>On,BLOCK_GRID_COLUMNS:()=>Fn,BLOCK_HEADING_LEVELS:()=>$n,BLOCK_JUSTIFIES:()=>Dn,BLOCK_MAX_WIDTHS:()=>zn,BLOCK_PADS:()=>jn,BLOCK_RATIOS:()=>Gn,BLOCK_SIZES:()=>Bn,BLOCK_SURFACES:()=>Wn,BLOCK_TEXT_ALIGNS:()=>Kn,BLOCK_TONES:()=>Mn,BLOCK_WEIGHTS:()=>Ln,CLICK_ID_KEYS:()=>Ze,FORM_FIELD_KINDS:()=>Hn,FORM_INPUT_TYPES:()=>Qn,LEGACY_SESSION_COOKIE_NAME:()=>Je,LOCAL_MODE_BANNER:()=>et,MAX_BLOCK_ARMS:()=>Zn,MAX_BLOCK_CHILDREN:()=>Yn,MAX_BLOCK_DEPTH:()=>qn,MAX_BLOCK_NODES:()=>Xn,MAX_BLOCK_TEXT_LEN:()=>eo,MAX_FORM_FIELDS:()=>Jn,MAX_FORM_SELECT_OPTIONS:()=>Vn,PAGE_SCOPE_RE:()=>nt,PROD_KEYLESS_ERROR:()=>We,REVEAL_MS:()=>jt,SNAPSHOT_STORAGE_KEY_PREFIX:()=>le,_registerConsentUpgradeInit:()=>oo,agentIntent:()=>Lt,agentUaList:()=>ke,armOfResult:()=>Ue,attachMicroSignalDetectors:()=>Qt,baselineResultFor:()=>ge,baselineSlots:()=>Kt,classifiedAgents:()=>Mt,containsFormBlock:()=>Wt,deriveSessionSegment:()=>Nt,detectDeviceClass:()=>Ie,detectTimeOfDay:()=>Re,detectTrafficSource:()=>_e,extractTrackedParams:()=>Ge,grantConsent:()=>co,init:()=>Yt,isDoNotTrackEnabled:()=>at,matchedAgentToken:()=>Ye,pageScopeMatches:()=>$t,readSnapshot:()=>fe,referrerDomainFromReferer:()=>Ce,renderPrePaintScript:()=>Gt,resetRevealStyles:()=>zt,reveal:()=>Ht,sessionCookieName:()=>Pe,toWireSlot:()=>Ae,uaTokenMatch:()=>Ee,writeSnapshot:()=>me});module.exports=un(po);function Oe(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function be(e){return e?`_${e.slice(0,12)}`:""}var Je="_snt_uid";function Pe(e){return`${Je}${be(e)}`}var pn="_snt_uid",gn=365,De="_snt_uid";function fn(){return Oe()}function At(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function mn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(u){}}function Ve(e){try{return localStorage.getItem(e)}catch(t){return null}}function Tt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Ot(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function yn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Sn(e){try{sessionStorage.removeItem(e)}catch(t){}}function hn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function vn(e){try{localStorage.removeItem(e)}catch(t){}}function xn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var wn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Be(e){var p,y,k,b,N,G,P;if(typeof window=="undefined")return wn;let t=be(e==null?void 0:e.apiKey),n=(p=e==null?void 0:e.cookieName)!=null?p:Pe(e==null?void 0:e.apiKey),u=`${De}${t}`,g=`${De}_tomb${t}`,i=((y=e==null?void 0:e.cookieTTLDays)!=null?y:gn)*24*60*60,c=L=>L&&L.length>0?L:null,f=()=>{var L,D;return t&&!(e!=null&&e.cookieName)&&Ve(g)===null?(D=(L=c(At(pn)))!=null?L:c(Ve(De)))!=null?D:c(Ot(De)):null},s=(P=(G=(N=(b=(k=c(At(n)))!=null?k:c(Ve(u)))!=null?b:c(Ot(u)))!=null?N:f())!=null?G:c(e==null?void 0:e.ssrSessionId))!=null?P:fn();mn(n,s,i);let r=Tt(u,s),a=hn(n),w=r?!1:yn(u,s),R=!r&&!a&&!w;return{getSessionId:()=>s,isEphemeral:()=>R,destroy:()=>{s=null,xn(n),vn(u),Sn(u),t&&!(e!=null&&e.cookieName)&&Tt(g,"1")}}}function Y(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ue(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Le(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let u=JSON.parse(n);return Array.isArray(u)?(localStorage.removeItem(e),u.slice(-t)):[]}catch(n){return[]}}function oe(e,t,n){try{let u=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let i=JSON.parse(l);return Array.isArray(i)?i:[]}catch(l){return[]}})(),g=new Map;for(let l of u)g.set(l.id,l);for(let l of e)g.set(l.id,l);localStorage.setItem(n,JSON.stringify([...g.values()].slice(-t)))}catch(u){}}function Me(e,t){try{let n=localStorage.getItem(t);if(!n)return;let u=JSON.parse(n);if(!Array.isArray(u))return;let g=new Set(e),l=u.filter(i=>!g.has(i.id));if(l.length===u.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var bn=500,kn=56*1024;function Xe(e){return`_snt_retry_${e.slice(0,12)}`}var En={push:()=>{},flush:()=>{},destroy:()=>{}};function Pt(e){var V,X,Se;if(typeof window=="undefined")return En;let t=(V=e.flushIntervalMs)!=null?V:5e3,n=(X=e.maxBatchSize)!=null?X:20,u=(Se=e.maxRetrySize)!=null?Se:100,g=e.ingestUrl,l=e.apiKey,i=Xe(l),c=[],f=new Set,s=[],r=v=>{for(let A of v)a.delete(A),!f.has(A)&&(f.add(A),s.push(A));for(;s.length>bn;){let A=s.shift();A&&f.delete(A)}Me(v,i)},a=new Set,w=()=>{for(;c.length>u;){let v=c.shift();v&&a.delete(v.id)}},R=v=>{f.has(v.id)||a.has(v.id)||(a.add(v.id),c.push(v),w())},p=v=>{for(let A of v)f.has(A.id)||(a.add(A.id),c.push(A));w()},y=Le(i,u);for(let v of y)R(v);let k=0,b=0,N=(v,A=!0)=>{if(v.length===0)return;let j=JSON.stringify(v),Q=v.map(H=>H.id),z;try{z=fetch(g,{method:"POST",keepalive:!0,body:j,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(H){oe(v,u,i),p(v),b++,k=Date.now()+Y(b);return}let re=H=>{if(ue(H)!=="retry"){if(!H.ok&&A){let se=v.filter(ie=>ie.eventType!=="pageview");if(se.length>0&&se.length<v.length){r(v.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),N(se,!1);return}}r(Q),b=0,k=0;return}oe(v,u,i),p(v),b++,k=Date.now()+Y(b)};z instanceof Promise?z.then(re).catch(()=>{oe(v,u,i),p(v),b++,k=Date.now()+Y(b)}):re(z)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,P=v=>G?G.encode(v).length:v.length,L=v=>{let A=[],j=2;for(let Q of v){let z=P(JSON.stringify(Q))+1;if(A.length>0&&j+z>kn||A.length>=n)break;A.push(Q),j+=z}return A},D=()=>{try{if(Date.now()<k)return;for(;c.length>0&&!(Date.now()<k);){let v=c.filter(j=>!f.has(j.id));if(c.length=0,v.length===0)break;let A=L(v);if(A.length===0)break;A.length<v.length&&c.push(...v.slice(A.length)),N(A)}}catch(v){}},h=!0,I=null;I=setInterval(()=>{h&&D()},t);let Z=()=>{document.visibilityState==="hidden"&&D()},W=()=>{D()};return document.addEventListener("visibilitychange",Z),window.addEventListener("pagehide",W),{push(v){R(v),c.length>=n&&D()},flush:D,destroy(){h=!1,I!==null&&(clearInterval(I),I=null),document.removeEventListener("visibilitychange",Z),window.removeEventListener("pagehide",W),D()}}}var In=200;function qe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var _n={send:()=>{},flush:()=>{},destroy:()=>{}};function Dt(e){var P,L,D;if(typeof window=="undefined")return _n;let t=(P=e.flushIntervalMs)!=null?P:5e3,n=(L=e.maxRetrySize)!=null?L:100,u=(D=e.maxPerFlush)!=null?D:5,g=qe(e.apiKey),l=[],i=new Set,c=new Set,f=[],s=0,r=0,a=!1,w=h=>{for(i.delete(h.id),c.has(h.id)||(c.add(h.id),f.push(h.id));f.length>In;){let I=f.shift();I&&c.delete(I)}Me([h.id],g)},R=h=>{oe([h],n,g),!c.has(h.id)&&!i.has(h.id)&&(i.add(h.id),l.push(h)),Date.now()>=s&&(r++,s=Date.now()+Y(r))},p=h=>{let I;try{I=fetch(e.url,{method:"POST",keepalive:!0,body:h.body,headers:e.headers})}catch(W){R(h);return}let Z=W=>{var X;let V=ue(W);if(V==="retry"){R(h);return}V==="dropped"&&((X=e.onDrop)==null||X.call(e,h,W.status)),w(h),r=0,s=0};I instanceof Promise?I.then(Z).catch(()=>R(h)):Z(I)},y=()=>{try{if(a||Date.now()<s)return;let h=0;for(;l.length>0&&h<u&&!(Date.now()<s);){let I=l.shift();i.delete(I.id),!c.has(I.id)&&(h++,p(I))}}catch(h){}},k=Le(g,n);for(let h of k)i.has(h.id)||(i.add(h.id),l.push(h));k.length>0&&oe(k,n,g);let b=setInterval(y,t),N=()=>{document.visibilityState==="hidden"&&y()},G=()=>y();return document.addEventListener("visibilitychange",N),window.addEventListener("pagehide",G),{send(h){if(!a&&!(c.has(h.id)||i.has(h.id))){if(Date.now()<s){oe([h],n,g),i.add(h.id),l.push(h);return}p(h)}},flush:y,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",N),window.removeEventListener("pagehide",G),y(),a=!0}}}var Cn=1800*1e3;function Ne(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Bt(e=Cn,t){let n=new Map,u=`_snt_asgn${be(t)}_`,g=(s,r)=>`${u}${encodeURIComponent(s)}:${encodeURIComponent(r)}`,l=s=>{let r=s.slice(u.length),a=r.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(r.slice(0,a)),segment:decodeURIComponent(r.slice(a+1))}}catch(w){return null}},i=()=>{try{let s=[];for(let r=0;r<localStorage.length;r++){let a=localStorage.key(r);a!=null&&a.startsWith(u)&&s.push(a)}return s}catch(s){return[]}},c=s=>s.assignedAt+(s.ttlMs&&s.ttlMs>0?s.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let s of i())try{let r=localStorage.getItem(s);if(!r)continue;let a=JSON.parse(r);if(c(a)){localStorage.removeItem(s);continue}let w=l(s);if(!w)continue;n.set(Ne(w.componentId,w.segment),a)}catch(r){}})(),{get(s,r){let a=n.get(Ne(s,r));return a?c(a)?(n.delete(Ne(s,r)),null):a:null},set(s,r,a){let w=Ne(s,r);n.set(w,a);try{localStorage.setItem(g(s,r),JSON.stringify(a))}catch(R){}},clear(){n.clear();for(let s of i())try{localStorage.removeItem(s)}catch(r){}}}}var ke=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function Ee(e){return Ye(e)!==null}function Ye(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ke.find(u=>t.includes(u.toLowerCase())))!=null?n:null}var Ke={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Lt(e){if(!e)return"other";let t=ke.find(n=>n.toLowerCase()===e.toLowerCase());return t&&Ke[t]||"other"}function Mt(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of ke)e[(t=Ke[n])!=null?t:"other"].push(n);return e}function Ie(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function _e(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(g){}let u=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(u)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(u)?"social":"referral"}catch(n){return"direct"}}function Ce(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Ze=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Ge(e){let t={},n={};try{let u=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([g,l])=>{let i=Array.isArray(l)?l[0]:l;return i===void 0?[]:[[g,i]]});for(let[g,l]of u)g.startsWith("utm_")?g in t||(t[g]=l):Ze.includes(g)&&(g in n||(n[g]=l))}catch(u){}return{utmParams:t,clickIds:n}}function Re(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Nt(e){let t=Rn("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Rn(e,t){var l,i,c,f,s,r,a,w;let n=(i=(l=t==null?void 0:t.userAgent)==null?void 0:l.trim())!=null?i:"",u=(f=(c=t==null?void 0:t.referer)==null?void 0:c.trim())!=null?f:"",g=(s=t==null?void 0:t.now)!=null?s:new Date;return{sessionId:e,ephemeral:!1,utmParams:(r=t==null?void 0:t.utmParams)!=null?r:{},clickIds:(a=t==null?void 0:t.clickIds)!=null?a:{},deviceClass:n?Ie(n):"desktop",trafficSource:u?_e(u,t==null?void 0:t.appOrigin):"direct",referrerDomain:Ce(u),timeOfDay:Re(g),dayOfWeek:(w=["sun","mon","tue","wed","thu","fri","sat"][g.getDay()])!=null?w:"sun",automation:(t==null?void 0:t.webdriver)===!0||Ee(n)}}var pe=require("@sentientui/policy");function Ae(e){return O(O(O({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function ge(e){let t=Ae(e);return(0,pe.slotResultFor)(t,(0,pe.slotBaselineArm)(t))}function Kt(e){let t={};for(let n of e)t[n.id]=ge(n);return t}function Ue(e){return typeof e=="string"?e:(0,pe.canonicalArm)(e)}var le="_snt_snap:",An=["low","medium","high"];function fe(e){try{let t=localStorage.getItem(le+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!An.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function me(e,t){try{localStorage.setItem(le+e,JSON.stringify(t))}catch(n){}}function Gt(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(le+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var st=require("@sentientui/policy");var $e=require("@sentientui/policy");var We="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",et="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Ut=!1,Fe=!1;function Tn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Ft(e){var s;let t=Be({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(s=t.getSessionId())!=null?s:"local",u=Tn(),g=import("@sentientui/core/local").then(r=>{let a=r;return a.LOCAL_ENGINE_AVAILABLE?(Ut||(Ut=!0,console.info(et)),a):(Fe||(Fe=!0,console.error(We)),null)}).catch(()=>(Fe||(Fe=!0,console.error(We)),null)),l=null,i={low:.15,medium:.5,high:.85},c=(()=>{var a;if(e.initialPersona)return O({},e.initialPersona);let r=fe(e.apiKey||"local");return r?{persona:r.persona,confidence:(a=i[r.band])!=null?a:.15}:null})();function f(r){let a=document.documentElement;a.dataset.sentientPersona===void 0&&(a.dataset.sentientPersona=r.persona,a.dataset.sentientConfidence=(0,$e.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var R,p,y;let a=await g;if(!a)return null;let w=a.createLocalEngine({sessionId:n,forcedPersona:u}).decide(r);return l=de(O({},w),{layoutOrder:(p=(R=w.layoutOrder)!=null?R:l==null?void 0:l.layoutOrder)!=null?p:null,slots:O(O({},(y=l==null?void 0:l.slots)!=null?y:{}),w.slots)}),me(e.apiKey||"local",{v:1,persona:l.persona,band:(0,$e.confidenceBand)(l.confidence),slots:l.slots,layoutOrder:l.layoutOrder,savedAt:Date.now()}),f(w),w},getSlotResult(r){var a,w,R;return(R=(w=l==null?void 0:l.slots[r])!=null?w:(a=e.initialSlots)==null?void 0:a[r])!=null?R:null},getSlotConfig(r){var a,w;return(w=(a=e.initialSlotConfig)==null?void 0:a[r])!=null?w:null},getSitePalette(){var r;return(r=e.initialPalette)!=null?r:null},reportSlots(){},getPersona(){let r=l!=null?l:c;return r?{persona:r.persona,confidence:r.confidence,band:(0,$e.confidenceBand)(r.confidence)}:null},async assign(r,a){var p;let w=await g;return!w||!a||a.length===0?a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null:{variantId:(p=w.createLocalEngine({sessionId:n,forcedPersona:u}).decide({components:[{id:r,variantIds:a}]}).assignments[r])!=null?p:a[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>t.destroy()}}var nt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function tt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function $t(e,t){if(e===void 0||!nt.test(e))return!1;if(e==="*")return!0;let n=tt(t);if(e.endsWith("/*")){let u=tt(e.slice(0,-2));return n.startsWith(u==="/"?"/":`${u}/`)&&n!==u}return n===tt(e)}var On=["none","sm","md","lg"],Pn=["start","center","end","stretch"],Dn=["start","center","end","between"],Bn=["sm","md","lg"],Ln=["normal","medium","bold"],Mn=["default","muted","accent"],Nn=["primary","secondary","ghost"],Kn=["left","center","right"],Gn=["auto","square","landscape","wide"],Un=["cover","contain"],Fn=[2,3,4],$n=[2,3,4],Wn=["default","raised"],jn=["none","sm","md","lg"],zn=["measure"],Hn=["input","textarea","select"],Qn=["text","email","number","tel"],Jn=5,Vn=8,Xn=64,qn=5,Yn=12,Zn=4,eo=500;function Wt(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(Wt):!1}var ot="sentient-reveal",ye="sentient-revealed",jt=240,je=!1;function zt(){var e;je=!1,typeof document!="undefined"&&((e=document.getElementById(ot))==null||e.remove())}function to(e){if(je||e.getElementById(ot)){je=!0;return}let t=e.createElement("style");t.id=ot,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${ye}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${ye}{animation:${ye} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),je=!0}function Ht(e,t={}){var g;let n=(g=t.doc)!=null?g:typeof document!="undefined"?document:void 0;if(!n||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;to(n),e.classList.remove(ye),e.offsetWidth,e.classList.add(ye);let u=()=>{e.classList.remove(ye),e.removeEventListener("animationend",u)};return e.addEventListener("animationend",u),!0}function Qt(e,t,n,u){let g=[];{let c=!1,f=[],s=()=>{if(c)return;let r=Date.now();for(f.push(r);f.length>0&&r-f[0]>500;)f.shift();f.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",s),g.push(()=>t.removeEventListener("click",s))}{let l=!1,i=c=>{if(l||!(c.target instanceof Node)||!t.contains(c.target)&&t!==c.target)return;l=!0;let f=typeof window!="undefined"?window.getSelection():null,s=f?f.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",i),g.push(()=>document.removeEventListener("copy",i))}{let l=!1,i=!1,c=null,f=()=>{c!==null&&(clearTimeout(c),c=null)},s=()=>{l||!i||(f(),c=setTimeout(()=>{!l&&i&&(l=!0,e("scroll_hesitation"))},3e3))},r=()=>{f(),s()},a=R=>{for(let p of R)i=p.intersectionRatio>.3,i?s():f()},w=new IntersectionObserver(a,{threshold:[.3]});w.observe(t),window.addEventListener("scroll",r,{passive:!0}),g.push(()=>{w.disconnect(),window.removeEventListener("scroll",r),f()})}if((u==null?void 0:u.tabLoss)!==!1){let l=!1,i=n!=null?n:Date.now(),c=()=>{if(l||document.visibilityState!=="hidden")return;let f=Date.now()-i;f<15e3&&(l=!0,e("tab_loss",{timeOnPage:f}))};document.addEventListener("visibilitychange",c),g.push(()=>document.removeEventListener("visibilitychange",c))}return()=>{for(let l of g)l()}}function no(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Jt="https://api.sentient-ui.com/v1/events",$=new Map,Vt=null;function oo(e,t){let n=$.get(e);n&&n.upgrade&&(n.reinit=t)}function ro(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var so=3;function rt(){return Oe()}function ze(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function io(){let e=new WeakMap,t=new Map,n=!1,u=(c,f,s)=>{let r=c.get(f);return s===null?r?!0:(c.set(f,new Set),!1):r?r.has(s)?!0:(r.add(s),!1):(c.set(f,new Set([s])),!1)},g=typeof window!="undefined"&&"event"in window,l=()=>{if(!g)return;let c=window.event;return typeof Event=="function"&&c instanceof Event?c:void 0},i=()=>{if(g){Promise.resolve().then(()=>{n=!1,t.clear()});return}let c=!1,f=()=>{c||(c=!0,n=!1,t.clear())};if(setTimeout(f,0),typeof MessageChannel=="function"){let s=new MessageChannel;s.port1.onmessage=()=>{s.port1.close(),s.port2.close(),f()},s.port2.postMessage(0)}};return{firedBefore(c,f){let s=l();if(s){let a=e.get(s);return a||(a=new Map,e.set(s,a)),u(a,c,f)}let r=u(t,c,f);return!r&&!n&&(n=!0,i()),r}}}var Xt=new Set;function ao(e,t,n){let u=typeof window=="undefined"?null:window.history;if(!u)return()=>{};let g=!1,l,i=()=>{if(g)return;let s=ze();!s||s===l||(l=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},c=[];for(let s of["pushState","replaceState"]){let r=u[s],a=function(...w){let R=r.apply(this,w);return i(),R};u[s]=a,c.push([s,r,a])}window.addEventListener("popstate",i);let f=ze();return f&&Xt.has(`${t}:${f}`)?l=f:i(),()=>{if(!g){g=!0,window.removeEventListener("popstate",i);for(let[s,r,a]of c)u[s]===a&&(u[s]=r)}}}var Te={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function lo(){try{return Ge(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function qt(e){return e.replace(/\/events\/?$/,"")}function at(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}function co(e){var f;if(typeof window=="undefined")return;let t=e!=null?e:Vt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=$.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:u,upgrade:g,reinit:l}=n;if(!g){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(u.respectDoNotTrack!==!1&&at())return;let i=(l!=null?l:Yt)(de(O({},u),{consent:!0}));g(i);let c=(f=$.get(t))==null?void 0:f.dispose;$.set(t,{config:de(O({},u),{consent:!0}),upgrade:null,dispose:c})}function uo(e){var R;let t=e.preConsentBehavior==="statistical_winner",n=qt((R=e.ingestUrl)!=null?R:Jt),u={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Map,l=new Map,i={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(p,y,k){if(!t)return Promise.resolve(null);let b=g.get(p);return b?Promise.resolve(b):it(l,p,async()=>{try{let N=new URLSearchParams({componentId:p});for(let D of y!=null?y:[])N.append("variantIds[]",D);let G=await fetch(`${n}/winner?${N.toString()}`,{headers:u});if(!G.ok)return y!=null&&y[0]?{variantId:y[0],assignmentTtlMs:0}:null;let L={variantId:(await G.json()).variantId,assignmentTtlMs:0};return g.set(p,L),L}catch(N){return y!=null&&y[0]?{variantId:y[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},c=!1,f=new Set,s=[],r=[],a={track:p=>i.track(p),goal:((p,y,k,b)=>i.goal(p,y,k,b)),componentGoal:(p,y,k)=>i.componentGoal(p,y,k),identify:p=>i.identify(p),getAssignment:(p,y)=>i.getAssignment(p,y),assign:(p,y,k,b)=>i.assign(p,y,k,b),decide:p=>i.decide(p),getSlotResult:p=>i.getSlotResult(p),isSlotDecided:p=>{var y,k;return(k=(y=i.isSlotDecided)==null?void 0:y.call(i,p))!=null?k:!0},getSlotConfig:p=>i.getSlotConfig(p),getSitePalette:()=>i.getSitePalette(),reportSlots:(p,y)=>i.reportSlots(p,y),requestSlots:(p,y)=>{var k;return c?(k=i.requestSlots)==null?void 0:k.call(i,p,y):s.push([p,y])},decideSlots:p=>{var y;return c?(y=i.decideSlots)==null?void 0:y.call(i,p):r.push(...p)},cancelSlots:p=>{var k;if(c)return(k=i.cancelSlots)==null?void 0:k.call(i,p);let y=new Set(p);for(let b of s)b[0]=b[0].filter(N=>!y.has(N));r=r.filter(b=>!y.has(b.id))},onSlotsChanged:p=>(f.add(p),()=>{f.delete(p)}),getPersona:()=>i.getPersona(),fetchWeights:()=>i.fetchWeights(),getGraph:()=>i.getGraph(),flush:()=>i.flush(),dispose:()=>i.dispose(),destroy:()=>i.destroy()};function w(p){var y,k,b;i=p,c=!0,(y=p.onSlotsChanged)==null||y.call(p,()=>f.forEach(N=>N()));for(let[N,G]of s.splice(0))N.length>0&&((k=p.requestSlots)==null||k.call(p,N,G));r.length>0&&((b=p.decideSlots)==null||b.call(p,r.splice(0)))}return{proxy:a,setInner:w}}function it(e,t,n){let u=e.get(t);if(u)return u;let g=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,g),g}function Yt(e){var gt,ft,mt,yt,St,ht,vt,xt,wt,bt;if(typeof window=="undefined")return Te;Vt=e.apiKey||"local";let t=$.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(o){}let n=e.respectDoNotTrack!==!1&&at(),u=e.consent===!1||n,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return $.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),u?Te:Ft(e);if(u){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),$.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Te;let{proxy:o,setInner:d}=uo(e);return $.set(e.apiKey,{config:e,upgrade:n?null:d}),o}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Te;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Te;let l=(gt=e.ingestUrl)!=null?gt:Jt,i=Date.now(),c=Be({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),f=Bt(void 0,e.apiKey),s=Pt({ingestUrl:l,apiKey:e.apiKey}),r=qt(l),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},w=new Set,R=Dt({url:`${r}/goals`,apiKey:e.apiKey,headers:a,onDrop:(o,d)=>{if(!e.debug){if(w.has(d))return;w.add(d)}console.warn(`[sentient] goal dropped (HTTP ${d}) \u2014 this will not be retried. `+(d===400?"The session was not found: call init() and let the session upsert complete before firing goals.":d===401||d===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),o)}}),p=Ie((ft=navigator.userAgent)!=null?ft:""),y=window.location.origin,k=_e((mt=document.referrer)!=null?mt:"",y),b=(yt=e.sessionSegment)!=null?yt:`${p}:${k}`,N=new Map,G=new Map,P=new Map,L=new Set,D=new Map,h=null,I=null,Z=new Set,W=new Set,V=new Map,X=null,Se=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,v=new Set,A=new Set,j=new Set,Q=new Map,z=null,re=new Set,H=new Map,se=null,ie=2,lt=new Map,He=!1,ct=(o,d,m)=>{var S;let x=new Set,_=1;for(let E of o){d.delete(E);let C=((S=lt.get(E))!=null?S:0)+1;lt.set(E,C),C<=ie&&(x.add(E),C>_&&(_=C))}x.size>0&&setTimeout(()=>{He||m(x)},Y(_))},dt=o=>{for(let d of o)P.has(d.id)||P.set(d.id,ge(d))};if(e.initialSlots)for(let[o,d]of Object.entries(e.initialSlots))P.set(o,d),L.add(o);if(e.initialSlotConfig)for(let[o,d]of Object.entries(e.initialSlotConfig))D.set(o,d);e.initialPalette&&(h=e.initialPalette);let ee=fe(e.apiKey);if(ee){for(let[o,d]of Object.entries(ee.slots))P.has(o)||P.set(o,d);for(let[o,d]of Object.entries((St=ee.slotConfig)!=null?St:{}))D.has(o)||D.set(o,d);!h&&ee.palette&&(h=ee.palette)}let ut={low:.15,medium:.5,high:.85};if(e.initialPersona)I=O({},e.initialPersona);else{let o=document.documentElement.dataset;o.sentientPersona?I={persona:o.sentientPersona,confidence:(vt=ut[(ht=o.sentientConfidence)!=null?ht:"low"])!=null?vt:.15}:ee&&(I={persona:ee.persona,confidence:(xt=ut[ee.band])!=null?xt:.15})}if(e.initialAssignments)for(let[o,d]of Object.entries(e.initialAssignments))f.set(o,b,{variantId:d,assignedAt:Date.now(),segment:b,confidence:1});let te=Promise.resolve(),pt=c.getSessionId();if(pt){let o=Ce((wt=document.referrer)!=null?wt:""),{utmParams:d,clickIds:m}=lo(),x=O(O(O(O({sessionId:pt,deviceClass:p,trafficSource:k,referrerDomain:o,utmParams:d,clickIds:m,timeOfDay:Re(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:c.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ee((bt=navigator.userAgent)!=null?bt:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),_=async()=>{for(let S=0;;S++){try{let E=await fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(x),headers:a});if(E.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(E.ok||ue(E)==="dropped")return}catch(E){}if(S>=so){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(E=>setTimeout(E,Y(S+1)))}};try{te=_()}catch(S){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:s});let Zt=io(),ae=null,Qe=!1,K={goal(o,d={},m=1,x=0){var ne,he,ve,xe,ce,T,q;let _=c.getSessionId();if(!_)return;let S=ro(d)?d:{metadata:d},E=[o,(ne=S.externalId)!=null?ne:"",(he=S.stepIndex)!=null?he:x,(ve=S.weight)!=null?ve:m].join("\0"),C=S.value!==void 0?`${S.value}\0${(xe=S.currency)!=null?xe:""}`:null;if(Zt.firedBefore(E,C)){e.debug&&console.log(`[sentient] goal("${o}") already recorded for this action \u2014 not sent twice`);return}let M=rt(),U={sessionId:_,name:o,metadata:(ce=S.metadata)!=null?ce:{},weight:(T=S.weight)!=null?T:m,stepIndex:(q=S.stepIndex)!=null?q:x,goalId:M,value:S.value,currency:S.currency,externalId:S.externalId};e.debug&&console.log("[sentient] goal",U);let F={id:M,body:JSON.stringify(U)};te.then(()=>R.send(F))},componentGoal(o,d,m){var M,U,F;let x=c.getSessionId();if(!x)return;let _=f.get(o,b),S=_?null:(M=P.get(o))!=null?M:null;if(!_&&S===null){e.debug&&console.warn(`[sentient] componentGoal("${o}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!_&&!L.has(o)){e.debug&&console.warn(`[sentient] componentGoal("${o}"): slot not decided this session \u2014 not attributed`);return}let E=_?_.variantId:Ue(S),C={id:rt(),sessionId:x,projectId:e.apiKey,componentId:o,variantId:E,eventType:"goal_achieved",goalType:d,payload:O({reward:(U=m==null?void 0:m.reward)!=null?U:1,goalValue:m==null?void 0:m.value,currency:m==null?void 0:m.currency},(F=m==null?void 0:m.metadata)!=null?F:{}),timestamp:Date.now(),timeInSession:Date.now()-i,path:ze()};e.debug&&console.log("[sentient] componentGoal",C),te.then(()=>s.push(C))},identify(o){let d=c.getSessionId();d&&te.then(()=>{fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:d,userId:o,ephemeral:c.isEphemeral()}),headers:a}).catch(()=>{})})},track(o){let d=c.getSessionId();if(!d||o.eventType==="variant_assigned"&&P.get(o.componentId)!==void 0&&!L.has(o.componentId)&&!f.get(o.componentId,b))return;let m=de(O({path:ze()},o),{id:rt(),sessionId:d,timestamp:Date.now(),timeInSession:Date.now()-i});e.debug&&console.log("[sentient] track",m),te.then(()=>s.push(m))},getAssignment(o,d){return f.get(o,d)},async assign(o,d,m,x){let _=c.getSessionId();if(!_)return null;let S=f.get(o,b);if(S&&(d!=null&&d.length||S.content!==void 0)){let E=S.ttlMs&&S.ttlMs>0?Math.max(0,S.assignedAt+S.ttlMs-Date.now()):0;return{variantId:S.variantId,assignmentTtlMs:E,content:S.content}}return it(N,o,async()=>{await te;try{let E={sessionId:_,componentId:o,variantIds:d};x!==void 0?E.agentDataByVariant=x:m!==void 0&&(E.agentData=m);let C=await fetch(`${r}/assign`,{method:"POST",body:JSON.stringify(E),headers:a});if(!C.ok)return null;let M=await C.json();return f.set(o,b,O({variantId:M.variantId,assignedAt:Date.now(),segment:b,confidence:1,content:M.content},M.assignmentTtlMs&&M.assignmentTtlMs>0?{ttlMs:M.assignmentTtlMs}:{})),M}catch(E){return null}})},async decide(o){var S,E;let d=c.getSessionId();if(!d)return null;let m=(S=o.slots)!=null?S:[],x={sessionId:d};o.sections&&o.sections.length>0&&(x.sections=o.sections.map(C=>({id:C}))),x.components=(E=o.components)!=null?E:[],m.length>0&&(x.slots=m.map(Ae)),o.slotsFrom==="registry"&&(x.slotsFrom="registry",o.registrySlotIds&&(x.registrySlotIds=o.registrySlotIds),o.bootstrap===!1&&(x.bootstrap=!1)),o.v&&(x.v=o.v),typeof o.pp=="number"&&(x.pp=o.pp),e.persona&&(x.persona=e.persona);let _=JSON.stringify(x);return it(G,_,async()=>{var C,M,U,F,ne,he,ve,xe;await te;try{let ce=await fetch(`${r}/decide`,{method:"POST",body:_,headers:a});if(!ce.ok)return dt(m),null;let T=await ce.json(),q={};for(let B of m){let J=(C=T.slots)==null?void 0:C[B.id];if(J!==void 0){q[B.id]=J,P.set(B.id,J),L.add(B.id);continue}let kt=P.get(B.id);if(kt!==void 0)q[B.id]=kt;else{let Et=ge(B);q[B.id]=Et,P.set(B.id,Et)}}if(T.slots)for(let[B,J]of Object.entries(T.slots))B in q||(q[B]=J,P.set(B,J),L.add(B));let en=I!=null&&I.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&en)?I={persona:T.persona,confidence:(M=T.confidence)!=null?M:0}:I||(I={persona:"unknown",confidence:0});for(let[B,J]of Object.entries((U=T.assignments)!=null?U:{}))f.set(B,b,{variantId:J,assignedAt:Date.now(),segment:b,confidence:1});if(T.slotConfig)for(let[B,J]of Object.entries(T.slotConfig))D.set(B,J);T.palette&&(h=T.palette);for(let B of(F=o.registrySlotIds)!=null?F:[])(ne=T.slotConfig)!=null&&ne[B]||(D.delete(B),P.delete(B),L.delete(B));return me(e.apiKey,O(O({v:1,persona:I.persona,band:(0,st.confidenceBand)(I.confidence),slots:Object.fromEntries(P),layoutOrder:(he=T.layoutOrder)!=null?he:null,savedAt:Date.now()},D.size>0?{slotConfig:Object.fromEntries(D)}:{}),h?{palette:h}:{})),O(O(O(O({layoutOrder:(ve=T.layoutOrder)!=null?ve:null,assignments:(xe=T.assignments)!=null?xe:{},slots:q,persona:I.persona,confidence:I.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(ce){return dt(m),null}})},getSlotResult(o){var d;return(d=P.get(o))!=null?d:null},isSlotDecided(o){return L.has(o)},getSlotConfig(o){var d;return(d=D.get(o))!=null?d:null},reportSlots(o,d){for(let m of o)if(!(typeof m!="string"||m.length===0)){if(!Se.test(m)){no()&&!v.has(m)&&(v.add(m),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(m)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!Z.has(m)){Z.add(m),W.add(m);let x=d==null?void 0:d[m];if(typeof x=="string"){let _=x.replace(/\s+/g," ").trim().slice(0,400);_!==""&&V.set(m,_)}}}W.size===0||X!=null||(X=setTimeout(()=>{X=null;let m=[...W];W.clear();for(let x=0;x<m.length;x+=20){let _=m.slice(x,x+20),S={};for(let E of _){let C=V.get(E);C!==void 0&&(S[E]=C,V.delete(E))}fetch(`${r}/slots/observed`,{method:"POST",headers:a,body:JSON.stringify(O({slotIds:_},Object.keys(S).length>0?{baselineTexts:S}:{}))}).catch(()=>{})}},1e3))},requestSlots(o,d){for(let m of o)j.has(m)||(j.add(m),Se.test(m)?Q.set(m,d==null?void 0:d[m]):K.reportSlots([m]));Q.size===0||z!=null||(z=setTimeout(()=>{z=null;let m=[...Q];Q.clear();for(let x=0;x<m.length;x+=50){let _=m.slice(x,x+50);K.decide({slotsFrom:"registry",registrySlotIds:_.map(([S])=>S),bootstrap:!1}).then(S=>{var E;if(S){let C={},M=[];for(let[U,F]of _)(E=S.slotConfig)!=null&&E[U]||(M.push(U),F&&(C[U]=F));M.length>0&&K.reportSlots(M,C)}else ct(_.map(([C])=>C),j,C=>{var U;let M={};for(let[F,ne]of _)C.has(F)&&ne&&(M[F]=ne);(U=K.requestSlots)==null||U.call(K,[...C],M)});A.forEach(C=>C())})}},0))},decideSlots(o){for(let d of o)re.has(d.id)||(re.add(d.id),H.set(d.id,d));H.size===0||se!=null||(se=setTimeout(()=>{se=null;let d=[...H.values()];H.clear();for(let m=0;m<d.length;m+=30){let x=d.slice(m,m+30);K.decide({slots:x}).then(_=>{_||ct(x.map(S=>S.id),re,S=>{var E;return(E=K.decideSlots)==null?void 0:E.call(K,x.filter(C=>S.has(C.id)))}),A.forEach(S=>S())})}},0))},cancelSlots(o){for(let d of o)Q.delete(d)&&j.delete(d),H.delete(d)&&re.delete(d)},onSlotsChanged(o){return A.add(o),()=>{A.delete(o)}},getSitePalette(){return h},getPersona(){return I?{persona:I.persona,confidence:I.confidence,band:(0,st.confidenceBand)(I.confidence)}:null},async fetchWeights(){var o;try{let d=await fetch(`${r}/weights`,{headers:a});return d.ok?(o=(await d.json()).components)!=null?o:[]:[]}catch(d){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){s.flush(),R.flush()},dispose(){var o;ae==null||ae(),Qe=!0,He=!0,s.destroy(),R.destroy(),((o=$.get(e.apiKey))==null?void 0:o.dispose)===K.dispose&&$.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var o;ae==null||ae(),Qe=!0,He=!0,s.destroy(),R.destroy(),c.destroy(),f.clear(),((o=$.get(e.apiKey))==null?void 0:o.dispose)===K.dispose&&$.delete(e.apiKey);try{localStorage.removeItem(le+e.apiKey),localStorage.removeItem(Xe(e.apiKey)),localStorage.removeItem(qe(e.apiKey))}catch(d){}e.debug&&console.log("[sentient] destroyed")}};if($.set(e.apiKey,{config:e,upgrade:null,dispose:K.dispose}),ae=ao(K,e.apiKey,o=>{te.then(()=>{Qe||Xt.add(o)})}),e.debug){let o=window;o.__sentient&&(o.__sentient.client=K)}return K}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_MAX_WIDTHS,BLOCK_PADS,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_SURFACES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,CLICK_ID_KEYS,FORM_FIELD_KINDS,FORM_INPUT_TYPES,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,MAX_FORM_FIELDS,MAX_FORM_SELECT_OPTIONS,PAGE_SCOPE_RE,PROD_KEYLESS_ERROR,REVEAL_MS,SNAPSHOT_STORAGE_KEY_PREFIX,_registerConsentUpgradeInit,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,containsFormBlock,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,extractTrackedParams,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,pageScopeMatches,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,resetRevealStyles,reveal,sessionCookieName,toWireSlot,uaTokenMatch,writeSnapshot});
|
|
1
|
+
"use strict";var an=Object.create;var we=Object.defineProperty,ln=Object.defineProperties,cn=Object.getOwnPropertyDescriptor,dn=Object.getOwnPropertyDescriptors,un=Object.getOwnPropertyNames,Ot=Object.getOwnPropertySymbols,pn=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var Tt=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))Pt.call(t,n)&&Tt(e,n,t[n]);if(Ot)for(var n of Ot(t))gn.call(t,n)&&Tt(e,n,t[n]);return e},pe=(e,t)=>ln(e,dn(t));var fn=(e,t)=>{for(var n in t)we(e,n,{get:t[n],enumerable:!0})},Dt=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let g of un(t))!Pt.call(e,g)&&g!==n&&we(e,g,{get:()=>t[g],enumerable:!(l=cn(t,g))||l.enumerable});return e};var mn=(e,t,n)=>(n=e!=null?an(pn(e)):{},Dt(t||!e||!e.__esModule?we(n,"default",{value:e,enumerable:!0}):n,e)),yn=e=>Dt(we({},"__esModule",{value:!0}),e);var So={};fn(So,{AGENT_INTENTS:()=>Fe,BLOCK_ALIGNS:()=>Nn,BLOCK_EMPHASES:()=>$n,BLOCK_FITS:()=>Vn,BLOCK_GAPS:()=>Mn,BLOCK_GRID_COLUMNS:()=>zn,BLOCK_HEADING_LEVELS:()=>Hn,BLOCK_JUSTIFIES:()=>Kn,BLOCK_MAX_WIDTHS:()=>Qn,BLOCK_PADS:()=>Xn,BLOCK_RATIOS:()=>Wn,BLOCK_SIZES:()=>Gn,BLOCK_SURFACES:()=>Jn,BLOCK_TEXT_ALIGNS:()=>jn,BLOCK_TONES:()=>Fn,BLOCK_WEIGHTS:()=>Un,CLICK_ID_KEYS:()=>rt,FORM_FIELD_KINDS:()=>qn,FORM_INPUT_TYPES:()=>Yn,LEGACY_SESSION_COOKIE_NAME:()=>Ze,LOCAL_MODE_BANNER:()=>st,MAX_BLOCK_ARMS:()=>ro,MAX_BLOCK_CHILDREN:()=>oo,MAX_BLOCK_DEPTH:()=>no,MAX_BLOCK_NODES:()=>to,MAX_BLOCK_TEXT_LEN:()=>so,MAX_FORM_FIELDS:()=>Zn,MAX_FORM_SELECT_OPTIONS:()=>eo,MAX_SKELETON_LEAVES:()=>$o,MAX_SKELETON_NODES:()=>Fo,MAX_SKELETON_TEXT:()=>jo,PAGE_SCOPE_RE:()=>at,PROD_KEYLESS_ERROR:()=>ze,REVEAL_MS:()=>Xt,SNAPSHOT_STORAGE_KEY_PREFIX:()=>ge,_registerConsentUpgradeInit:()=>lo,agentIntent:()=>Ut,agentUaList:()=>Ie,armOfResult:()=>je,attachMicroSignalDetectors:()=>Yt,baselineResultFor:()=>Se,baselineSlots:()=>jt,classifiedAgents:()=>Ft,containsFormBlock:()=>Jt,deriveSessionSegment:()=>$t,detectDeviceClass:()=>_e,detectTimeOfDay:()=>Oe,detectTrafficSource:()=>Ce,extractTrackedParams:()=>$e,grantConsent:()=>mo,init:()=>on,isDoNotTrackEnabled:()=>pt,matchedAgentToken:()=>ot,pageScopeMatches:()=>Ht,readSnapshot:()=>he,referrerDomainFromReferer:()=>Ae,renderPrePaintScript:()=>Wt,resetRevealStyles:()=>Qt,reveal:()=>qt,sessionCookieName:()=>Le,toWireSlot:()=>Te,uaTokenMatch:()=>Re,writeSnapshot:()=>ve});module.exports=yn(So);function Be(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Ee(e){return e?`_${e.slice(0,12)}`:""}var Ze="_snt_uid";function Le(e){return`${Ze}${Ee(e)}`}var Sn="_snt_uid",hn=365,Me="_snt_uid";function vn(){return Be()}function Bt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function bn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(l){}}function et(e){try{return localStorage.getItem(e)}catch(t){return null}}function Lt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Mt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function kn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function xn(e){try{sessionStorage.removeItem(e)}catch(t){}}function wn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function En(e){try{localStorage.removeItem(e)}catch(t){}}function In(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Rn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ne(e){var p,m,x,v,B,V,P;if(typeof window=="undefined")return Rn;let t=Ee(e==null?void 0:e.apiKey),n=(p=e==null?void 0:e.cookieName)!=null?p:Le(e==null?void 0:e.apiKey),l=`${Me}${t}`,g=`${Me}_tomb${t}`,s=((m=e==null?void 0:e.cookieTTLDays)!=null?m:hn)*24*60*60,d=K=>K&&K.length>0?K:null,f=()=>{var K,M;return t&&!(e!=null&&e.cookieName)&&et(g)===null?(M=(K=d(Bt(Sn)))!=null?K:d(et(Me)))!=null?M:d(Mt(Me)):null},i=(P=(V=(B=(v=(x=d(Bt(n)))!=null?x:d(et(l)))!=null?v:d(Mt(l)))!=null?B:f())!=null?V:d(e==null?void 0:e.ssrSessionId))!=null?P:vn();bn(n,i,s);let r=Lt(l,i),a=wn(n),w=r?!1:kn(l,i),A=!r&&!a&&!w;return{getSessionId:()=>i,isEphemeral:()=>A,destroy:()=>{i=null,In(n),En(l),xn(l),t&&!(e!=null&&e.cookieName)&&Lt(g,"1")}}}function se(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function me(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Ke(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let l=JSON.parse(n);return Array.isArray(l)?(localStorage.removeItem(e),l.slice(-t)):[]}catch(n){return[]}}function de(e,t,n){try{let l=(()=>{try{let u=localStorage.getItem(n);if(!u)return[];let s=JSON.parse(u);return Array.isArray(s)?s:[]}catch(u){return[]}})(),g=new Map;for(let u of l)g.set(u.id,u);for(let u of e)g.set(u.id,u);localStorage.setItem(n,JSON.stringify([...g.values()].slice(-t)))}catch(l){}}function Ge(e,t){try{let n=localStorage.getItem(t);if(!n)return;let l=JSON.parse(n);if(!Array.isArray(l))return;let g=new Set(e),u=l.filter(s=>!g.has(s.id));if(u.length===l.length)return;u.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(u))}catch(n){}}var _n=500,Cn=56*1024;function tt(e){return`_snt_retry_${e.slice(0,12)}`}var An={push:()=>{},flush:()=>{},destroy:()=>{}};function Nt(e){var Y,oe,fe;if(typeof window=="undefined")return An;let t=(Y=e.flushIntervalMs)!=null?Y:5e3,n=(oe=e.maxBatchSize)!=null?oe:20,l=(fe=e.maxRetrySize)!=null?fe:100,g=e.ingestUrl,u=e.apiKey,s=tt(u),d=[],f=new Set,i=[],r=k=>{for(let T of k)a.delete(T),!f.has(T)&&(f.add(T),i.push(T));for(;i.length>_n;){let T=i.shift();T&&f.delete(T)}Ge(k,s)},a=new Set,w=()=>{for(;d.length>l;){let k=d.shift();k&&a.delete(k.id)}},A=k=>{f.has(k.id)||a.has(k.id)||(a.add(k.id),d.push(k),w())},p=k=>{for(let T of k)f.has(T.id)||(a.add(T.id),d.push(T));w()},m=Ke(s,l);for(let k of m)A(k);let x=0,v=0,B=(k,T=!0)=>{if(k.length===0)return;let re=JSON.stringify(k),ie=k.map(Z=>Z.id),X;try{X=fetch(g,{method:"POST",keepalive:!0,body:re,headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`}})}catch(Z){de(k,l,s),p(k),v++,x=Date.now()+se(v);return}let ke=Z=>{if(me(Z)!=="retry"){if(!Z.ok&&T){let ae=k.filter(q=>q.eventType!=="pageview");if(ae.length>0&&ae.length<k.length){r(k.filter(q=>q.eventType==="pageview").map(q=>q.id)),B(ae,!1);return}}r(ie),v=0,x=0;return}de(k,l,s),p(k),v++,x=Date.now()+se(v)};X instanceof Promise?X.then(ke).catch(()=>{de(k,l,s),p(k),v++,x=Date.now()+se(v)}):ke(X)},V=typeof TextEncoder!="undefined"?new TextEncoder:null,P=k=>V?V.encode(k).length:k.length,K=k=>{let T=[],re=2;for(let ie of k){let X=P(JSON.stringify(ie))+1;if(T.length>0&&re+X>Cn||T.length>=n)break;T.push(ie),re+=X}return T},M=()=>{try{if(Date.now()<x)return;for(;d.length>0&&!(Date.now()<x);){let k=d.filter(re=>!f.has(re.id));if(d.length=0,k.length===0)break;let T=K(k);if(T.length===0)break;T.length<k.length&&d.push(...k.slice(T.length)),B(T)}}catch(k){}},b=!0,L=null;L=setInterval(()=>{b&&M()},t);let G=()=>{document.visibilityState==="hidden"&&M()},ne=()=>{M()};return document.addEventListener("visibilitychange",G),window.addEventListener("pagehide",ne),{push(k){A(k),d.length>=n&&M()},flush:M,destroy(){b=!1,L!==null&&(clearInterval(L),L=null),document.removeEventListener("visibilitychange",G),window.removeEventListener("pagehide",ne),M()}}}var On=200;function nt(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Tn={send:()=>{},flush:()=>{},destroy:()=>{}};function Kt(e){var P,K,M;if(typeof window=="undefined")return Tn;let t=(P=e.flushIntervalMs)!=null?P:5e3,n=(K=e.maxRetrySize)!=null?K:100,l=(M=e.maxPerFlush)!=null?M:5,g=nt(e.apiKey),u=[],s=new Set,d=new Set,f=[],i=0,r=0,a=!1,w=b=>{for(s.delete(b.id),d.has(b.id)||(d.add(b.id),f.push(b.id));f.length>On;){let L=f.shift();L&&d.delete(L)}Ge([b.id],g)},A=b=>{de([b],n,g),!d.has(b.id)&&!s.has(b.id)&&(s.add(b.id),u.push(b)),Date.now()>=i&&(r++,i=Date.now()+se(r))},p=b=>{let L;try{L=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(ne){A(b);return}let G=ne=>{var oe;let Y=me(ne);if(Y==="retry"){A(b);return}Y==="dropped"&&((oe=e.onDrop)==null||oe.call(e,b,ne.status)),w(b),r=0,i=0};L instanceof Promise?L.then(G).catch(()=>A(b)):G(L)},m=()=>{try{if(a||Date.now()<i)return;let b=0;for(;u.length>0&&b<l&&!(Date.now()<i);){let L=u.shift();s.delete(L.id),!d.has(L.id)&&(b++,p(L))}}catch(b){}},x=Ke(g,n);for(let b of x)s.has(b.id)||(s.add(b.id),u.push(b));x.length>0&&de(x,n,g);let v=setInterval(m,t),B=()=>{document.visibilityState==="hidden"&&m()},V=()=>m();return document.addEventListener("visibilitychange",B),window.addEventListener("pagehide",V),{send(b){if(!a&&!(d.has(b.id)||s.has(b.id))){if(Date.now()<i){de([b],n,g),s.add(b.id),u.push(b);return}p(b)}},flush:m,destroy(){clearInterval(v),document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",V),m(),a=!0}}}var Pn=1800*1e3;function Ue(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Gt(e=Pn,t){let n=new Map,l=`_snt_asgn${Ee(t)}_`,g=(i,r)=>`${l}${encodeURIComponent(i)}:${encodeURIComponent(r)}`,u=i=>{let r=i.slice(l.length),a=r.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(r.slice(0,a)),segment:decodeURIComponent(r.slice(a+1))}}catch(w){return null}},s=()=>{try{let i=[];for(let r=0;r<localStorage.length;r++){let a=localStorage.key(r);a!=null&&a.startsWith(l)&&i.push(a)}return i}catch(i){return[]}},d=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of s())try{let r=localStorage.getItem(i);if(!r)continue;let a=JSON.parse(r);if(d(a)){localStorage.removeItem(i);continue}let w=u(i);if(!w)continue;n.set(Ue(w.componentId,w.segment),a)}catch(r){}})(),{get(i,r){let a=n.get(Ue(i,r));return a?d(a)?(n.delete(Ue(i,r)),null):a:null},set(i,r,a){let w=Ue(i,r);n.set(w,a);try{localStorage.setItem(g(i,r),JSON.stringify(a))}catch(A){}},clear(){n.clear();for(let i of s())try{localStorage.removeItem(i)}catch(r){}}}}var Ie=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function Re(e){return ot(e)!==null}function ot(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ie.find(l=>t.includes(l.toLowerCase())))!=null?n:null}var Fe={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Ut(e){if(!e)return"other";let t=Ie.find(n=>n.toLowerCase()===e.toLowerCase());return t&&Fe[t]||"other"}function Ft(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of Ie)e[(t=Fe[n])!=null?t:"other"].push(n);return e}function _e(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Ce(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(g){}let l=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(l)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(l)?"social":"referral"}catch(n){return"direct"}}function Ae(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var rt=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function $e(e){let t={},n={};try{let l=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([g,u])=>{let s=Array.isArray(u)?u[0]:u;return s===void 0?[]:[[g,s]]});for(let[g,u]of l)g.startsWith("utm_")?g in t||(t[g]=u):rt.includes(g)&&(g in n||(n[g]=u))}catch(l){}return{utmParams:t,clickIds:n}}function Oe(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function $t(e){let t=Dn("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Dn(e,t){var u,s,d,f,i,r,a,w;let n=(s=(u=t==null?void 0:t.userAgent)==null?void 0:u.trim())!=null?s:"",l=(f=(d=t==null?void 0:t.referer)==null?void 0:d.trim())!=null?f:"",g=(i=t==null?void 0:t.now)!=null?i:new Date;return{sessionId:e,ephemeral:!1,utmParams:(r=t==null?void 0:t.utmParams)!=null?r:{},clickIds:(a=t==null?void 0:t.clickIds)!=null?a:{},deviceClass:n?_e(n):"desktop",trafficSource:l?Ce(l,t==null?void 0:t.appOrigin):"direct",referrerDomain:Ae(l),timeOfDay:Oe(g),dayOfWeek:(w=["sun","mon","tue","wed","thu","fri","sat"][g.getDay()])!=null?w:"sun",automation:(t==null?void 0:t.webdriver)===!0||Re(n)}}var ye=require("@sentientui/policy");function Te(e){return C(C(C({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function Se(e){let t=Te(e);return(0,ye.slotResultFor)(t,(0,ye.slotBaselineArm)(t))}function jt(e){let t={};for(let n of e)t[n.id]=Se(n);return t}function je(e){return typeof e=="string"?e:(0,ye.canonicalArm)(e)}var ge="_snt_snap:",Bn=["low","medium","high"];function he(e){try{let t=localStorage.getItem(ge+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Bn.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig)))return null;let l=n.vocabulary;return l!==void 0&&(typeof l!="object"||l===null||!Array.isArray(l.entries)||!Array.isArray(l.images))&&delete n.vocabulary,n}catch(t){return null}}function ve(e,t){try{localStorage.setItem(ge+e,JSON.stringify(t))}catch(n){}}function Wt(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(ge+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var dt=require("@sentientui/policy");var Ve=require("@sentientui/policy");var ze="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",st="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Vt=!1,We=!1;function Ln(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function zt(e){var i;let t=Ne({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(i=t.getSessionId())!=null?i:"local",l=Ln(),g=import("@sentientui/core/local").then(r=>{let a=r;return a.LOCAL_ENGINE_AVAILABLE?(Vt||(Vt=!0,console.info(st)),a):(We||(We=!0,console.error(ze)),null)}).catch(()=>(We||(We=!0,console.error(ze)),null)),u=null,s={low:.15,medium:.5,high:.85},d=(()=>{var a;if(e.initialPersona)return C({},e.initialPersona);let r=he(e.apiKey||"local");return r?{persona:r.persona,confidence:(a=s[r.band])!=null?a:.15}:null})();function f(r){let a=document.documentElement;a.dataset.sentientPersona===void 0&&(a.dataset.sentientPersona=r.persona,a.dataset.sentientConfidence=(0,Ve.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var A,p,m;let a=await g;if(!a)return null;let w=a.createLocalEngine({sessionId:n,forcedPersona:l}).decide(r);return u=pe(C({},w),{layoutOrder:(p=(A=w.layoutOrder)!=null?A:u==null?void 0:u.layoutOrder)!=null?p:null,slots:C(C({},(m=u==null?void 0:u.slots)!=null?m:{}),w.slots)}),ve(e.apiKey||"local",{v:1,persona:u.persona,band:(0,Ve.confidenceBand)(u.confidence),slots:u.slots,layoutOrder:u.layoutOrder,savedAt:Date.now()}),f(w),w},getSlotResult(r){var a,w,A;return(A=(w=u==null?void 0:u.slots[r])!=null?w:(a=e.initialSlots)==null?void 0:a[r])!=null?A:null},getSlotConfig(r){var a,w;return(w=(a=e.initialSlotConfig)==null?void 0:a[r])!=null?w:null},getSitePalette(){var r;return(r=e.initialPalette)!=null?r:null},reportSlots(){},getPersona(){let r=u!=null?u:d;return r?{persona:r.persona,confidence:r.confidence,band:(0,Ve.confidenceBand)(r.confidence)}:null},async assign(r,a){var p;let w=await g;return!w||!a||a.length===0?a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null:{variantId:(p=w.createLocalEngine({sessionId:n,forcedPersona:l}).decide({components:[{id:r,variantIds:a}]}).assignments[r])!=null?p:a[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>t.destroy()}}var at=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function it(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Ht(e,t){if(e===void 0||!at.test(e))return!1;if(e==="*")return!0;let n=it(t);if(e.endsWith("/*")){let l=it(e.slice(0,-2));return n.startsWith(l==="/"?"/":`${l}/`)&&n!==l}return n===it(e)}var Mn=["none","sm","md","lg"],Nn=["start","center","end","stretch"],Kn=["start","center","end","between"],Gn=["sm","md","lg"],Un=["normal","medium","bold"],Fn=["default","muted","accent"],$n=["primary","secondary","ghost"],jn=["left","center","right"],Wn=["auto","square","landscape","wide"],Vn=["cover","contain"],zn=[2,3,4],Hn=[1,2,3,4],Jn=["default","raised"],Xn=["none","sm","md","lg"],Qn=["measure"],qn=["input","textarea","select"],Yn=["text","email","number","tel"],Zn=5,eo=8,to=64,no=5,oo=12,ro=4,so=500;function Jt(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(Jt):!1}var Fo=40,$o=120,jo=300;var lt="sentient-reveal",be="sentient-revealed",Xt=240,He=!1;function Qt(){var e;He=!1,typeof document!="undefined"&&((e=document.getElementById(lt))==null||e.remove())}function io(e){if(He||e.getElementById(lt)){He=!0;return}let t=e.createElement("style");t.id=lt,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${be}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${be}{animation:${be} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),He=!0}function qt(e,t={}){var g;let n=(g=t.doc)!=null?g:typeof document!="undefined"?document:void 0;if(!n||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;io(n),e.classList.remove(be),e.offsetWidth,e.classList.add(be);let l=()=>{e.classList.remove(be),e.removeEventListener("animationend",l)};return e.addEventListener("animationend",l),!0}function Yt(e,t,n,l){let g=[];{let d=!1,f=[],i=()=>{if(d)return;let r=Date.now();for(f.push(r);f.length>0&&r-f[0]>500;)f.shift();f.length>=3&&(d=!0,e("rage_click"))};t.addEventListener("click",i),g.push(()=>t.removeEventListener("click",i))}{let u=!1,s=d=>{if(u||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;u=!0;let f=typeof window!="undefined"?window.getSelection():null,i=f?f.toString().length:0;e("text_copy",{selectionLength:i})};document.addEventListener("copy",s),g.push(()=>document.removeEventListener("copy",s))}{let u=!1,s=!1,d=null,f=()=>{d!==null&&(clearTimeout(d),d=null)},i=()=>{u||!s||(f(),d=setTimeout(()=>{!u&&s&&(u=!0,e("scroll_hesitation"))},3e3))},r=()=>{f(),i()},a=A=>{for(let p of A)s=p.intersectionRatio>.3,s?i():f()},w=new IntersectionObserver(a,{threshold:[.3]});w.observe(t),window.addEventListener("scroll",r,{passive:!0}),g.push(()=>{w.disconnect(),window.removeEventListener("scroll",r),f()})}if((l==null?void 0:l.tabLoss)!==!1){let u=!1,s=n!=null?n:Date.now(),d=()=>{if(u||document.visibilityState!=="hidden")return;let f=Date.now()-s;f<15e3&&(u=!0,e("tab_loss",{timeOnPage:f}))};document.addEventListener("visibilitychange",d),g.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let u of g)u()}}function ao(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Zt="https://api.sentient-ui.com/v1/events",J=new Map,en=null;function lo(e,t){let n=J.get(e);n&&n.upgrade&&(n.reinit=t)}function co(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var uo=3;function ct(){return Be()}function Je(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function po(){let e=new WeakMap,t=new Map,n=!1,l=(d,f,i)=>{let r=d.get(f);return i===null?r?!0:(d.set(f,new Set),!1):r?r.has(i)?!0:(r.add(i),!1):(d.set(f,new Set([i])),!1)},g=typeof window!="undefined"&&"event"in window,u=()=>{if(!g)return;let d=window.event;return typeof Event=="function"&&d instanceof Event?d:void 0},s=()=>{if(g){Promise.resolve().then(()=>{n=!1,t.clear()});return}let d=!1,f=()=>{d||(d=!0,n=!1,t.clear())};if(setTimeout(f,0),typeof MessageChannel=="function"){let i=new MessageChannel;i.port1.onmessage=()=>{i.port1.close(),i.port2.close(),f()},i.port2.postMessage(0)}};return{firedBefore(d,f){let i=u();if(i){let a=e.get(i);return a||(a=new Map,e.set(i,a)),l(a,d,f)}let r=l(t,d,f);return!r&&!n&&(n=!0,s()),r}}}var tn=new Set;function go(e,t,n){let l=typeof window=="undefined"?null:window.history;if(!l)return()=>{};let g=!1,u,s=()=>{if(g)return;let i=Je();!i||i===u||(u=i,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${i}`))},d=[];for(let i of["pushState","replaceState"]){let r=l[i],a=function(...w){let A=r.apply(this,w);return s(),A};l[i]=a,d.push([i,r,a])}window.addEventListener("popstate",s);let f=Je();return f&&tn.has(`${t}:${f}`)?u=f:s(),()=>{if(!g){g=!0,window.removeEventListener("popstate",s);for(let[i,r,a]of d)l[i]===a&&(l[i]=r)}}}var Pe={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function fo(){try{return $e(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function nn(e){return e.replace(/\/events\/?$/,"")}function pt(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}function mo(e){var f;if(typeof window=="undefined")return;let t=e!=null?e:en;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=J.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:l,upgrade:g,reinit:u}=n;if(!g){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(l.respectDoNotTrack!==!1&&pt())return;let s=(u!=null?u:on)(pe(C({},l),{consent:!0}));g(s);let d=(f=J.get(t))==null?void 0:f.dispose;J.set(t,{config:pe(C({},l),{consent:!0}),upgrade:null,dispose:d})}function yo(e){var A;let t=e.preConsentBehavior==="statistical_winner",n=nn((A=e.ingestUrl)!=null?A:Zt),l={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Map,u=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(p,m,x){if(!t)return Promise.resolve(null);let v=g.get(p);return v?Promise.resolve(v):ut(u,p,async()=>{try{let B=new URLSearchParams({componentId:p});for(let M of m!=null?m:[])B.append("variantIds[]",M);let V=await fetch(`${n}/winner?${B.toString()}`,{headers:l});if(!V.ok)return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null;let K={variantId:(await V.json()).variantId,assignmentTtlMs:0};return g.set(p,K),K}catch(B){return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},d=!1,f=new Set,i=[],r=[],a={track:p=>s.track(p),goal:((p,m,x,v)=>s.goal(p,m,x,v)),componentGoal:(p,m,x)=>s.componentGoal(p,m,x),identify:p=>s.identify(p),getAssignment:(p,m)=>s.getAssignment(p,m),assign:(p,m,x,v)=>s.assign(p,m,x,v),decide:p=>s.decide(p),getSlotResult:p=>s.getSlotResult(p),isSlotDecided:p=>{var m,x;return(x=(m=s.isSlotDecided)==null?void 0:m.call(s,p))!=null?x:!0},getSlotConfig:p=>s.getSlotConfig(p),getSitePalette:()=>s.getSitePalette(),getStyleVocabulary:()=>{var p,m;return(m=(p=s.getStyleVocabulary)==null?void 0:p.call(s))!=null?m:null},reportSlots:(p,m,x,v)=>s.reportSlots(p,m,x,v),reportSkeleton:(p,m)=>{var x;return(x=s.reportSkeleton)==null?void 0:x.call(s,p,m)},reportDrift:(p,m,x,v)=>{var B;return(B=s.reportDrift)==null?void 0:B.call(s,p,m,x,v)},requestSlots:(p,m,x)=>{var v;return d?(v=s.requestSlots)==null?void 0:v.call(s,p,m,x):i.push([p,m,x])},decideSlots:p=>{var m;return d?(m=s.decideSlots)==null?void 0:m.call(s,p):r.push(...p)},cancelSlots:p=>{var x;if(d)return(x=s.cancelSlots)==null?void 0:x.call(s,p);let m=new Set(p);for(let v of i)v[0]=v[0].filter(B=>!m.has(B));r=r.filter(v=>!m.has(v.id))},onSlotsChanged:p=>(f.add(p),()=>{f.delete(p)}),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),flush:()=>s.flush(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function w(p){var m,x,v;s=p,d=!0,(m=p.onSlotsChanged)==null||m.call(p,()=>f.forEach(B=>B()));for(let[B,V,P]of i.splice(0))B.length>0&&((x=p.requestSlots)==null||x.call(p,B,V,P));r.length>0&&((v=p.decideSlots)==null||v.call(p,r.splice(0)))}return{proxy:a,setInner:w}}function ut(e,t,n){let l=e.get(t);if(l)return l;let g=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,g),g}function on(e){var ht,vt,bt,kt,xt,wt,Et,It,Rt,_t;if(typeof window=="undefined")return Pe;en=e.apiKey||"local";let t=J.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(o){}let n=e.respectDoNotTrack!==!1&&pt(),l=e.consent===!1||n,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return J.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),l?Pe:zt(e);if(l){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),J.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Pe;let{proxy:o,setInner:c}=yo(e);return J.set(e.apiKey,{config:e,upgrade:n?null:c}),o}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Pe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Pe;let u=(ht=e.ingestUrl)!=null?ht:Zt,s=Date.now(),d=Ne({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),f=Gt(void 0,e.apiKey),i=Nt({ingestUrl:u,apiKey:e.apiKey}),r=nn(u),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},w=new Set,A=Kt({url:`${r}/goals`,apiKey:e.apiKey,headers:a,onDrop:(o,c)=>{if(!e.debug){if(w.has(c))return;w.add(c)}console.warn(`[sentient] goal dropped (HTTP ${c}) \u2014 this will not be retried. `+(c===400?"The session was not found: call init() and let the session upsert complete before firing goals.":c===401||c===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),o)}}),p=_e((vt=navigator.userAgent)!=null?vt:""),m=window.location.origin,x=Ce((bt=document.referrer)!=null?bt:"",m),v=(kt=e.sessionSegment)!=null?kt:`${p}:${x}`,B=new Map,V=new Map,P=new Map,K=new Set,M=new Map,b=null,L=null,G=null,ne=new Set,Y=new Set,oe=new Map,fe=new Map,k=new Set,T=new Set,re=new Set,ie=null,X=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,ke=new Set,Z=new Set,ae=new Set,q=new Map,Xe=null,De=new Set,xe=new Map,Qe=null,rn=2,gt=new Map,qe=!1,ft=(o,c,h)=>{var y;let I=new Set,R=1;for(let S of o){c.delete(S);let _=((y=gt.get(S))!=null?y:0)+1;gt.set(S,_),_<=rn&&(I.add(S),_>R&&(R=_))}I.size>0&&setTimeout(()=>{qe||h(I)},se(R))},mt=o=>{for(let c of o)P.has(c.id)||P.set(c.id,Se(c))};if(e.initialSlots)for(let[o,c]of Object.entries(e.initialSlots))P.set(o,c),K.add(o);if(e.initialSlotConfig)for(let[o,c]of Object.entries(e.initialSlotConfig))M.set(o,c);e.initialPalette&&(b=e.initialPalette),e.initialVocabulary&&(L=e.initialVocabulary);let ee=he(e.apiKey);if(ee){for(let[o,c]of Object.entries(ee.slots))P.has(o)||P.set(o,c);for(let[o,c]of Object.entries((xt=ee.slotConfig)!=null?xt:{}))M.has(o)||M.set(o,c);!b&&ee.palette&&(b=ee.palette),!L&&ee.vocabulary&&(L=ee.vocabulary)}let yt={low:.15,medium:.5,high:.85};if(e.initialPersona)G=C({},e.initialPersona);else{let o=document.documentElement.dataset;o.sentientPersona?G={persona:o.sentientPersona,confidence:(Et=yt[(wt=o.sentientConfidence)!=null?wt:"low"])!=null?Et:.15}:ee&&(G={persona:ee.persona,confidence:(It=yt[ee.band])!=null?It:.15})}if(e.initialAssignments)for(let[o,c]of Object.entries(e.initialAssignments))f.set(o,v,{variantId:c,assignedAt:Date.now(),segment:v,confidence:1});let le=Promise.resolve(),St=d.getSessionId();if(St){let o=Ae((Rt=document.referrer)!=null?Rt:""),{utmParams:c,clickIds:h}=fo(),I=C(C(C(C({sessionId:St,deviceClass:p,trafficSource:x,referrerDomain:o,utmParams:c,clickIds:h,timeOfDay:Oe(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:d.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Re((_t=navigator.userAgent)!=null?_t:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),R=async()=>{for(let y=0;;y++){try{let S=await fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(I),headers:a});if(S.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(S.ok||me(S)==="dropped")return}catch(S){}if(y>=uo){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(S=>setTimeout(S,se(y+1)))}};try{le=R()}catch(y){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:i});let sn=po(),ue=null,Ye=!1,U={goal(o,c={},h=1,I=0){var j,F,H,Q,z,E,W;let R=d.getSessionId();if(!R)return;let y=co(c)?c:{metadata:c},S=[o,(j=y.externalId)!=null?j:"",(F=y.stepIndex)!=null?F:I,(H=y.weight)!=null?H:h].join("\0"),_=y.value!==void 0?`${y.value}\0${(Q=y.currency)!=null?Q:""}`:null;if(sn.firedBefore(S,_)){e.debug&&console.log(`[sentient] goal("${o}") already recorded for this action \u2014 not sent twice`);return}let O=ct(),D={sessionId:R,name:o,metadata:(z=y.metadata)!=null?z:{},weight:(E=y.weight)!=null?E:h,stepIndex:(W=y.stepIndex)!=null?W:I,goalId:O,value:y.value,currency:y.currency,externalId:y.externalId};e.debug&&console.log("[sentient] goal",D);let $={id:O,body:JSON.stringify(D)};le.then(()=>A.send($))},componentGoal(o,c,h){var O,D,$;let I=d.getSessionId();if(!I)return;let R=f.get(o,v),y=R?null:(O=P.get(o))!=null?O:null;if(!R&&y===null){e.debug&&console.warn(`[sentient] componentGoal("${o}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!R&&!K.has(o)){e.debug&&console.warn(`[sentient] componentGoal("${o}"): slot not decided this session \u2014 not attributed`);return}let S=R?R.variantId:je(y),_={id:ct(),sessionId:I,projectId:e.apiKey,componentId:o,variantId:S,eventType:"goal_achieved",goalType:c,payload:C({reward:(D=h==null?void 0:h.reward)!=null?D:1,goalValue:h==null?void 0:h.value,currency:h==null?void 0:h.currency},($=h==null?void 0:h.metadata)!=null?$:{}),timestamp:Date.now(),timeInSession:Date.now()-s,path:Je()};e.debug&&console.log("[sentient] componentGoal",_),le.then(()=>i.push(_))},identify(o){let c=d.getSessionId();c&&le.then(()=>{fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:c,userId:o,ephemeral:d.isEphemeral()}),headers:a}).catch(()=>{})})},track(o){let c=d.getSessionId();if(!c||o.eventType==="variant_assigned"&&P.get(o.componentId)!==void 0&&!K.has(o.componentId)&&!f.get(o.componentId,v))return;let h=pe(C({path:Je()},o),{id:ct(),sessionId:c,timestamp:Date.now(),timeInSession:Date.now()-s});e.debug&&console.log("[sentient] track",h),le.then(()=>i.push(h))},getAssignment(o,c){return f.get(o,c)},async assign(o,c,h,I){let R=d.getSessionId();if(!R)return null;let y=f.get(o,v);if(y&&(c!=null&&c.length||y.content!==void 0)){let S=y.ttlMs&&y.ttlMs>0?Math.max(0,y.assignedAt+y.ttlMs-Date.now()):0;return{variantId:y.variantId,assignmentTtlMs:S,content:y.content}}return ut(B,o,async()=>{await le;try{let S={sessionId:R,componentId:o,variantIds:c};I!==void 0?S.agentDataByVariant=I:h!==void 0&&(S.agentData=h);let _=await fetch(`${r}/assign`,{method:"POST",body:JSON.stringify(S),headers:a});if(!_.ok)return null;let O=await _.json();return f.set(o,v,C({variantId:O.variantId,assignedAt:Date.now(),segment:v,confidence:1,content:O.content},O.assignmentTtlMs&&O.assignmentTtlMs>0?{ttlMs:O.assignmentTtlMs}:{})),O}catch(S){return null}})},async decide(o){var y,S;let c=d.getSessionId();if(!c)return null;let h=(y=o.slots)!=null?y:[],I={sessionId:c};o.sections&&o.sections.length>0&&(I.sections=o.sections.map(_=>({id:_}))),I.components=(S=o.components)!=null?S:[],h.length>0&&(I.slots=h.map(Te)),o.slotsFrom==="registry"&&(I.slotsFrom="registry",o.registrySlotIds&&(I.registrySlotIds=o.registrySlotIds),o.bootstrap===!1&&(I.bootstrap=!1),o.render&&Object.keys(o.render).length>0&&(I.render=o.render)),o.v&&(I.v=o.v),typeof o.pp=="number"&&(I.pp=o.pp),e.persona&&(I.persona=e.persona);let R=JSON.stringify(I);return ut(V,R,async()=>{var _,O,D,$,j,F,H,Q;await le;try{let z=await fetch(`${r}/decide`,{method:"POST",body:R,headers:a});if(!z.ok)return mt(h),null;let E=await z.json(),W={};for(let N of h){let te=(_=E.slots)==null?void 0:_[N.id];if(te!==void 0){W[N.id]=te,P.set(N.id,te),K.add(N.id);continue}let Ct=P.get(N.id);if(Ct!==void 0)W[N.id]=Ct;else{let At=Se(N);W[N.id]=At,P.set(N.id,At)}}if(E.slots)for(let[N,te]of Object.entries(E.slots))N in W||(W[N]=te,P.set(N,te),K.add(N));let ce=G!=null&&G.persona!=="unknown";E.persona&&!(E.persona==="unknown"&&ce)?G={persona:E.persona,confidence:(O=E.confidence)!=null?O:0}:G||(G={persona:"unknown",confidence:0});for(let[N,te]of Object.entries((D=E.assignments)!=null?D:{}))f.set(N,v,{variantId:te,assignedAt:Date.now(),segment:v,confidence:1});if(E.slotConfig)for(let[N,te]of Object.entries(E.slotConfig))M.set(N,te);E.palette&&(b=E.palette),E.vocabulary&&(L=E.vocabulary);for(let N of($=o.registrySlotIds)!=null?$:[])(j=E.slotConfig)!=null&&j[N]||(M.delete(N),P.delete(N),K.delete(N));return ve(e.apiKey,C(C(C({v:1,persona:G.persona,band:(0,dt.confidenceBand)(G.confidence),slots:Object.fromEntries(P),layoutOrder:(F=E.layoutOrder)!=null?F:null,savedAt:Date.now()},M.size>0?{slotConfig:Object.fromEntries(M)}:{}),b?{palette:b}:{}),L?{vocabulary:L}:{})),C(C(C(C(C({layoutOrder:(H=E.layoutOrder)!=null?H:null,assignments:(Q=E.assignments)!=null?Q:{},slots:W,persona:G.persona,confidence:G.confidence},E.slotConfig?{slotConfig:E.slotConfig}:{}),E.goals?{goals:E.goals}:{}),E.sectionMap?{sectionMap:E.sectionMap}:{}),E.palette?{palette:E.palette}:{}),E.vocabulary?{vocabulary:E.vocabulary}:{})}catch(z){return mt(h),null}})},getSlotResult(o){var c;return(c=P.get(o))!=null?c:null},isSlotDecided(o){return K.has(o)},getSlotConfig(o){var c;return(c=M.get(o))!=null?c:null},reportSlots(o,c,h,I){var y;let R={};for(let[S,_]of Object.entries(I!=null?I:{}))for(let O of _){let D=`${S}|${O.key}`;!X.test(S)||re.has(D)||(re.add(D),((y=R[S])!=null?y:R[S]=[]).push(O))}Object.keys(R).length>0&&fetch(`${r}/slots/observed`,{method:"POST",headers:a,body:JSON.stringify({slotIds:Object.keys(R),authoredArms:R})}).catch(()=>{});for(let S of o)if(!(typeof S!="string"||S.length===0)){if(!X.test(S)){ao()&&!ke.has(S)&&(ke.add(S),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(S)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!ne.has(S)){ne.add(S),Y.add(S);let _=c==null?void 0:c[S];if(typeof _=="string"){let D=_.replace(/\s+/g," ").trim().slice(0,400);D!==""&&oe.set(S,D)}let O=h==null?void 0:h[S];O!==void 0&&fe.set(S,O)}}Y.size===0||ie!=null||(ie=setTimeout(()=>{ie=null;let S=[...Y];Y.clear();for(let _=0;_<S.length;_+=20){let O=S.slice(_,_+20),D={},$={};for(let j of O){let F=oe.get(j);F!==void 0&&(D[j]=F,oe.delete(j));let H=fe.get(j);H!==void 0&&($[j]=H,fe.delete(j))}fetch(`${r}/slots/observed`,{method:"POST",headers:a,body:JSON.stringify(pe(C(C({slotIds:O},Object.keys(D).length>0?{baselineTexts:D}:{}),Object.keys($).length>0?{baselineSkeletons:$}:{}),{pagePaths:Object.fromEntries(O.map(j=>[j,location.pathname]))}))}).catch(()=>{})}},1e3))},reportSkeleton(o,c){!X.test(o)||k.has(o)||(k.add(o),fetch(`${r}/slots/observed`,{method:"POST",headers:a,body:JSON.stringify({slotIds:[o],baselineSkeletons:{[o]:c}})}).catch(()=>{}))},reportDrift(o,c,h,I){let R=`${o}|${c}`,y=d.getSessionId();!y||T.has(R)||(T.add(R),fetch(`${r}/slots/drift`,{method:"POST",headers:a,body:JSON.stringify({sessionId:y,reports:[{slotId:o,expectedFp:c,observedFp:h,reason:I}]})}).catch(()=>{}))},requestSlots(o,c,h){var I,R;for(let y of o)ae.has(y)||(ae.add(y),X.test(y)?q.set(y,{text:c==null?void 0:c[y],render:(I=h==null?void 0:h.render)==null?void 0:I[y],skeleton:(R=h==null?void 0:h.skeletons)==null?void 0:R[y]}):U.reportSlots([y]));q.size===0||Xe!=null||(Xe=setTimeout(()=>{Xe=null;let y=[...q];q.clear();for(let S=0;S<y.length;S+=50){let _=y.slice(S,S+50),O={};for(let[D,$]of _)$.render&&(O[D]=$.render);U.decide({slotsFrom:"registry",registrySlotIds:_.map(([D])=>D),bootstrap:!1,render:O}).then(D=>{var $,j;if(D){let F={},H={},Q=[];for(let[z,E]of _){let W=($=D.slotConfig)==null?void 0:$[z];if(W){W.needsSkeleton&&E.skeleton&&((j=U.reportSkeleton)==null||j.call(U,z,E.skeleton));continue}Q.push(z),E.text&&(F[z]=E.text),E.skeleton&&(H[z]=E.skeleton)}Q.length>0&&U.reportSlots(Q,F,H)}else ft(_.map(([F])=>F),ae,F=>{var E;let H={},Q={},z={};for(let[W,ce]of _)F.has(W)&&(ce.text&&(H[W]=ce.text),ce.render&&(Q[W]=ce.render),ce.skeleton&&(z[W]=ce.skeleton));(E=U.requestSlots)==null||E.call(U,[...F],H,{render:Q,skeletons:z})});Z.forEach(F=>F())})}},0))},decideSlots(o){for(let c of o)De.has(c.id)||(De.add(c.id),xe.set(c.id,c));xe.size===0||Qe!=null||(Qe=setTimeout(()=>{Qe=null;let c=[...xe.values()];xe.clear();for(let h=0;h<c.length;h+=30){let I=c.slice(h,h+30);U.decide({slots:I}).then(R=>{R||ft(I.map(y=>y.id),De,y=>{var S;return(S=U.decideSlots)==null?void 0:S.call(U,I.filter(_=>y.has(_.id)))}),Z.forEach(y=>y())})}},0))},cancelSlots(o){for(let c of o)q.delete(c)&&ae.delete(c),xe.delete(c)&&De.delete(c)},onSlotsChanged(o){return Z.add(o),()=>{Z.delete(o)}},getStyleVocabulary(){return L},getSitePalette(){return b},getPersona(){return G?{persona:G.persona,confidence:G.confidence,band:(0,dt.confidenceBand)(G.confidence)}:null},async fetchWeights(){var o;try{let c=await fetch(`${r}/weights`,{headers:a});return c.ok?(o=(await c.json()).components)!=null?o:[]:[]}catch(c){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){i.flush(),A.flush()},dispose(){var o;ue==null||ue(),Ye=!0,qe=!0,i.destroy(),A.destroy(),((o=J.get(e.apiKey))==null?void 0:o.dispose)===U.dispose&&J.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var o;ue==null||ue(),Ye=!0,qe=!0,i.destroy(),A.destroy(),d.destroy(),f.clear(),((o=J.get(e.apiKey))==null?void 0:o.dispose)===U.dispose&&J.delete(e.apiKey);try{localStorage.removeItem(ge+e.apiKey),localStorage.removeItem(tt(e.apiKey)),localStorage.removeItem(nt(e.apiKey))}catch(c){}e.debug&&console.log("[sentient] destroyed")}};if(J.set(e.apiKey,{config:e,upgrade:null,dispose:U.dispose}),ue=go(U,e.apiKey,o=>{le.then(()=>{Ye||tn.add(o)})}),e.debug){let o=window;o.__sentient&&(o.__sentient.client=U)}return U}0&&(module.exports={AGENT_INTENTS,BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_MAX_WIDTHS,BLOCK_PADS,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_SURFACES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,CLICK_ID_KEYS,FORM_FIELD_KINDS,FORM_INPUT_TYPES,LEGACY_SESSION_COOKIE_NAME,LOCAL_MODE_BANNER,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,MAX_FORM_FIELDS,MAX_FORM_SELECT_OPTIONS,MAX_SKELETON_LEAVES,MAX_SKELETON_NODES,MAX_SKELETON_TEXT,PAGE_SCOPE_RE,PROD_KEYLESS_ERROR,REVEAL_MS,SNAPSHOT_STORAGE_KEY_PREFIX,_registerConsentUpgradeInit,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,containsFormBlock,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,extractTrackedParams,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,pageScopeMatches,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,resetRevealStyles,reveal,sessionCookieName,toWireSlot,uaTokenMatch,writeSnapshot});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|