@sentientui/core 0.36.4 → 0.37.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-GVKKOUWE.mjs → chunk-5CCBWT6H.mjs} +2 -2
- package/dist/chunk-5CCBWT6H.mjs.map +1 -0
- package/dist/chunk-MKM7TD3L.mjs +2 -0
- package/dist/chunk-MKM7TD3L.mjs.map +1 -0
- package/dist/{index-BYOMZ3t-.d.cts → index-C-meVCmm.d.cts} +1 -1
- package/dist/{index-DEwRTvxc.d.ts → index-DbpGK3Dj.d.ts} +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-graph.d.cts +4 -4
- package/dist/index-graph.d.ts +4 -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-local.d.cts +2 -2
- package/dist/index-local.d.ts +2 -2
- package/dist/index-server.d.cts +8 -2
- package/dist/index-server.d.ts +8 -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.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{session-meta-CJwAWbJr.d.cts → session-meta-CJ-QAskZ.d.cts} +4 -0
- package/dist/{session-meta-CKXcaBjt.d.ts → session-meta-DlCp0tyi.d.ts} +4 -0
- package/package.json +2 -2
- package/dist/chunk-735EJYJX.mjs +0 -2
- package/dist/chunk-735EJYJX.mjs.map +0 -1
- package/dist/chunk-GVKKOUWE.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as Z,B as _,C as $,D as aa,E as ba,F as ca,G as ga,H as ha,I as ia,J as ja,K as ka,L as la,M as ma,N as na,O as oa,a as i,b as j,c as k,d as C,e as D,f as E,g as F,h as G,i as H,j as I,k as J,l as K,m as L,n as M,o as N,p as O,q as P,r as Q,s as R,t as S,u as T,v as U,w as V,x as W,y as X,z as Y}from"./chunk-
|
|
1
|
+
import{A as Z,B as _,C as $,D as aa,E as ba,F as ca,G as ga,H as ha,I as ia,J as ja,K as ka,L as la,M as ma,N as na,O as oa,a as i,b as j,c as k,d as C,e as D,f as E,g as F,h as G,i as H,j as I,k as J,l as K,m as L,n as M,o as N,p as O,q as P,r as Q,s as R,t as S,u as T,v as U,w as V,x as W,y as X,z as Y}from"./chunk-5CCBWT6H.mjs";import{a as d,b as e,c as f,d as g,m as h}from"./chunk-DU3AXQHR.mjs";import{a as da,b as ea,c as fa}from"./chunk-NCLBL5V3.mjs";import{a as l,b as m,c as n,d as o,e as p,f as q,g as r,h as s,i as t,j as u,k as v,l as w,m as x,o as y,p as z,q as A,r as B}from"./chunk-MKM7TD3L.mjs";import{b as a,c as b,e as c}from"./chunk-J5EL7HKC.mjs";import"./chunk-TMCGHANO.mjs";export{o as AGENT_INTENTS,H as BLOCK_ALIGNS,M as BLOCK_EMPHASES,P as BLOCK_FITS,G as BLOCK_GAPS,Q as BLOCK_GRID_COLUMNS,R as BLOCK_HEADING_LEVELS,I as BLOCK_JUSTIFIES,U as BLOCK_MAX_WIDTHS,T as BLOCK_PADS,O as BLOCK_RATIOS,J as BLOCK_SIZES,S as BLOCK_SURFACES,N as BLOCK_TEXT_ALIGNS,L as BLOCK_TONES,K as BLOCK_WEIGHTS,u as CLICK_ID_KEYS,V as FORM_FIELD_KINDS,W as FORM_INPUT_TYPES,a as LEGACY_SESSION_COOKIE_NAME,D as LOCAL_MODE_BANNER,aa as MAX_BLOCK_ARMS,$ as MAX_BLOCK_CHILDREN,_ as MAX_BLOCK_DEPTH,Z as MAX_BLOCK_NODES,ba as MAX_BLOCK_TEXT_LEN,X as MAX_FORM_FIELDS,Y as MAX_FORM_SELECT_OPTIONS,ea as MAX_SKELETON_LEAVES,da as MAX_SKELETON_NODES,fa as MAX_SKELETON_TEXT,E as PAGE_SCOPE_RE,C as PROD_KEYLESS_ERROR,ga as REVEAL_MS,d as SNAPSHOT_STORAGE_KEY_PREFIX,ka as _registerConsentUpgradeInit,p as agentIntent,l as agentUaList,k as applyNonce,B as armOfResult,ja as attachMicroSignalDetectors,z as baselineResultFor,A as baselineSlots,q as classifiedAgents,ca as containsFormBlock,j as cspNonce,x as deriveSessionSegment,r as detectDeviceClass,w as detectTimeOfDay,s as detectTrafficSource,v as extractTrackedParams,c as forgetGeneration,h as forgetVisitor,ma as grantConsent,oa as init,la as isDoNotTrackEnabled,n as matchedAgentToken,F as pageScopeMatches,e as readSnapshot,t as referrerDomainFromReferer,g as renderPrePaintScript,ha as resetRevealStyles,ia as reveal,na as routeKey,b as sessionCookieName,i as setCspNonce,y as toWireSlot,m as uaTokenMatch,f as writeSnapshot};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -192,6 +192,8 @@ type SessionUpsertPayload = {
|
|
|
192
192
|
clickIds: Record<string, string>;
|
|
193
193
|
deviceClass: string;
|
|
194
194
|
trafficSource: string;
|
|
195
|
+
/** Landing page path, no query string (arrival classification). */
|
|
196
|
+
landingPath?: string;
|
|
195
197
|
referrerDomain: string | null;
|
|
196
198
|
timeOfDay: string;
|
|
197
199
|
dayOfWeek: string;
|
|
@@ -221,6 +223,8 @@ declare function buildSessionUpsertPayload(sessionId: string, opts?: {
|
|
|
221
223
|
now?: Date;
|
|
222
224
|
/** `navigator.webdriver` value from the browser, when available. */
|
|
223
225
|
webdriver?: boolean;
|
|
226
|
+
/** The landing page's path (no query string), when the caller knows it. */
|
|
227
|
+
landingPath?: string;
|
|
224
228
|
}): SessionUpsertPayload;
|
|
225
229
|
|
|
226
230
|
export { AGENT_INTENTS as A, CLICK_ID_KEYS as C, type DecisionSnapshot as D, SNAPSHOT_STORAGE_KEY_PREFIX as S, type AgentIntent as a, type CompoundLocator as b, type SessionUpsertPayload as c, type SlotConfigEntry as d, type SlotDeclInput as e, type SlotOps as f, agentIntent as g, agentUaList as h, armOfResult as i, baselineResultFor as j, baselineSlots as k, buildSessionUpsertPayload as l, classifiedAgents as m, deriveSessionSegment as n, detectDeviceClass as o, detectTimeOfDay as p, detectTrafficSource as q, extractTrackedParams as r, matchedAgentToken as s, readSnapshot as t, referrerDomainFromReferer as u, renderPrePaintScript as v, toWireSlot as w, uaTokenMatch as x, writeSnapshot as y };
|
|
@@ -192,6 +192,8 @@ type SessionUpsertPayload = {
|
|
|
192
192
|
clickIds: Record<string, string>;
|
|
193
193
|
deviceClass: string;
|
|
194
194
|
trafficSource: string;
|
|
195
|
+
/** Landing page path, no query string (arrival classification). */
|
|
196
|
+
landingPath?: string;
|
|
195
197
|
referrerDomain: string | null;
|
|
196
198
|
timeOfDay: string;
|
|
197
199
|
dayOfWeek: string;
|
|
@@ -221,6 +223,8 @@ declare function buildSessionUpsertPayload(sessionId: string, opts?: {
|
|
|
221
223
|
now?: Date;
|
|
222
224
|
/** `navigator.webdriver` value from the browser, when available. */
|
|
223
225
|
webdriver?: boolean;
|
|
226
|
+
/** The landing page's path (no query string), when the caller knows it. */
|
|
227
|
+
landingPath?: string;
|
|
224
228
|
}): SessionUpsertPayload;
|
|
225
229
|
|
|
226
230
|
export { AGENT_INTENTS as A, CLICK_ID_KEYS as C, type DecisionSnapshot as D, SNAPSHOT_STORAGE_KEY_PREFIX as S, type AgentIntent as a, type CompoundLocator as b, type SessionUpsertPayload as c, type SlotConfigEntry as d, type SlotDeclInput as e, type SlotOps as f, agentIntent as g, agentUaList as h, armOfResult as i, baselineResultFor as j, baselineSlots as k, buildSessionUpsertPayload as l, classifiedAgents as m, deriveSessionSegment as n, detectDeviceClass as o, detectTimeOfDay as p, detectTrafficSource as q, extractTrackedParams as r, matchedAgentToken as s, readSnapshot as t, referrerDomainFromReferer as u, renderPrePaintScript as v, toWireSlot as w, uaTokenMatch as x, writeSnapshot as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"llms.txt"
|
|
90
90
|
],
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@sentientui/policy": "0.
|
|
92
|
+
"@sentientui/policy": "0.16.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@iabtechlabtcf/core": "1.5.22",
|
package/dist/chunk-735EJYJX.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-TMCGHANO.mjs";var c=["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 y(t){return b(t)!==null}function b(t){var r;if(!t)return null;let e=t.toLowerCase();return(r=c.find(i=>e.includes(i.toLowerCase())))!=null?r:null}var h={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 U(t){if(!t)return"other";let e=c.find(r=>r.toLowerCase()===t.toLowerCase());return e&&h[e]||"other"}function B(){var e;let t={user:[],search:[],training:[],other:[]};for(let r of c)t[(e=h[r])!=null?e:"other"].push(r);return t}function x(t){let e=t.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(e)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(e)?"mobile":"desktop"}function R(t,e){if(!t)return"direct";try{let r=new URL(t);if(e)try{if(new URL(e).host===r.host)return"direct"}catch(n){}let i=r.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(i)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(i)?"social":"referral"}catch(r){return"direct"}}function S(t){if(!t)return null;try{return new URL(t).hostname}catch(e){return null}}var p=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function L(t){let e={},r={};try{let i=typeof t=="string"||t instanceof URLSearchParams?new URLSearchParams(t):Object.entries(t).flatMap(([n,o])=>{let s=Array.isArray(o)?o[0]:o;return s===void 0?[]:[[n,s]]});for(let[n,o]of i)n.startsWith("utm_")?n in e||(e[n]=o):p.includes(n)&&(n in r||(r[n]=o))}catch(i){}return{utmParams:e,clickIds:r}}function C(t){let e=t.getHours();return e<6?"night":e<12?"morning":e<18?"afternoon":"evening"}function O(t){let e=A("__segment__",t);return`${e.deviceClass}:${e.trafficSource}`}function A(t,e){var o,s,l,u,g,d,f,m;let r=(s=(o=e==null?void 0:e.userAgent)==null?void 0:o.trim())!=null?s:"",i=(u=(l=e==null?void 0:e.referer)==null?void 0:l.trim())!=null?u:"",n=(g=e==null?void 0:e.now)!=null?g:new Date;return{sessionId:t,ephemeral:!1,utmParams:(d=e==null?void 0:e.utmParams)!=null?d:{},clickIds:(f=e==null?void 0:e.clickIds)!=null?f:{},deviceClass:r?x(r):"desktop",trafficSource:i?R(i,e==null?void 0:e.appOrigin):"direct",referrerDomain:S(i),timeOfDay:C(n),dayOfWeek:(m=["sun","mon","tue","wed","thu","fri","sat"][n.getDay()])!=null?m:"sun",automation:(e==null?void 0:e.webdriver)===!0||y(r)}}import{canonicalArm as I,slotBaselineArm as k,slotResultFor as P}from"@sentientui/policy";function w(t){return a(a(a({id:t.id},t.arms?{arms:[...t.arms]}:{}),t.dims?{dims:Object.fromEntries(Object.entries(t.dims).map(([e,r])=>[e,[...r]]))}:{}),t.baseline!==void 0?{baseline:t.baseline}:{})}function D(t){let e=w(t);return P(e,k(e))}function _(t){let e={};for(let r of t)e[r.id]=D(r);return e}function v(t){return typeof t=="string"?t:I(t)}export{c as a,y as b,b as c,h as d,U as e,B as f,x as g,R as h,S as i,p as j,L as k,C as l,O as m,A as n,w as o,D as p,_ as q,v as r};
|
|
2
|
-
//# sourceMappingURL=chunk-735EJYJX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/session-meta.ts","../src/slots.ts"],"sourcesContent":["/** Session metadata helpers (browser + Node). No DOM APIs. */\n\n/**\n * Known AI-agent / crawler user-agent tokens. Matched case-insensitively as\n * substrings. This is maintained data — bot lists move monthly. Used both to\n * flag automation on sessions (agentic browsers that leak a token) and by the\n * server middleware / agent-feed route to identify crawler HTTP reads.\n */\nexport const agentUaList: readonly string[] = [\n 'GPTBot',\n 'ChatGPT-User',\n 'OAI-SearchBot',\n 'ClaudeBot',\n 'Claude-User',\n 'Claude-SearchBot',\n 'PerplexityBot',\n 'Perplexity-User',\n 'Google-Extended',\n 'Applebot-Extended',\n 'Meta-ExternalAgent',\n 'Bytespider',\n 'CCBot',\n 'Amazonbot',\n 'cohere-ai',\n 'Diffbot',\n];\n\n/** True when the user-agent contains a known AI-agent / crawler token. */\nexport function uaTokenMatch(userAgent: string): boolean {\n return matchedAgentToken(userAgent) !== null;\n}\n\n/** The first known agent token found in the user-agent, or null. */\nexport function matchedAgentToken(userAgent: string): string | null {\n if (!userAgent) return null;\n const s = userAgent.toLowerCase();\n return agentUaList.find((token) => s.includes(token.toLowerCase())) ?? null;\n}\n\n/**\n * Purpose category for an agent fetch, inferred from its published user-agent:\n * - `user` — a person asked an assistant to read the page, live (…-User UAs)\n * - `search` — indexing for an AI answer engine (…-SearchBot / SearchBot)\n * - `training` — model-training crawl (GPTBot, ClaudeBot, CCBot, …)\n * - `other` — not clearly AI, or an unknown/new token\n */\nexport type AgentIntent = 'user' | 'search' | 'training' | 'other';\n\n/** Intent per agent token. Maintained beside `agentUaList` — when you add or\n * rename a token above, set its intent here (a unit test enforces coverage). */\nexport const AGENT_INTENTS: Record<string, AgentIntent> = {\n 'GPTBot': 'training',\n 'ChatGPT-User': 'user',\n 'OAI-SearchBot': 'search',\n 'ClaudeBot': 'training',\n 'Claude-User': 'user',\n 'Claude-SearchBot': 'search',\n 'PerplexityBot': 'search',\n 'Perplexity-User': 'user',\n 'Google-Extended': 'training',\n 'Applebot-Extended': 'training',\n 'Meta-ExternalAgent': 'training',\n 'Bytespider': 'training',\n 'CCBot': 'training',\n 'Amazonbot': 'other',\n 'cohere-ai': 'training',\n 'Diffbot': 'other',\n};\n\n/** Intent for a matched bot token (case-insensitive); `other` for null/unknown. */\nexport function agentIntent(botName: string | null): AgentIntent {\n if (!botName) return 'other';\n const hit = agentUaList.find((t) => t.toLowerCase() === botName.toLowerCase());\n return (hit && AGENT_INTENTS[hit]) || 'other';\n}\n\n/** `agentUaList` grouped by intent — the \"which crawlers do you classify?\" reference. */\nexport function classifiedAgents(): Record<AgentIntent, string[]> {\n const out: Record<AgentIntent, string[]> = { user: [], search: [], training: [], other: [] };\n for (const t of agentUaList) out[AGENT_INTENTS[t] ?? 'other'].push(t);\n return out;\n}\n\nexport function detectDeviceClass(userAgent: string): string {\n const s = userAgent.toLowerCase();\n if (/ipad|tablet|playbook|kindle|silk/.test(s)) return 'tablet';\n if (/mobi|iphone|ipod|android.*mobile|phone/.test(s)) return 'mobile';\n return 'desktop';\n}\n\nexport function detectTrafficSource(referrer: string, appOrigin?: string): string {\n if (!referrer) return 'direct';\n try {\n const refUrl = new URL(referrer);\n if (appOrigin) {\n try {\n if (new URL(appOrigin).host === refUrl.host) return 'direct';\n } catch {\n /* ignore invalid appOrigin */\n }\n }\n const host = refUrl.hostname.toLowerCase();\n if (/(^|\\.)(google|bing|duckduckgo|yahoo)\\./.test(host)) return 'search';\n // Anchor to the registrable domain (exact host or a subdomain of it) so\n // hosts like `x.company.com`, `t.company.io` or `linkedinsights.com` are not\n // misclassified as social by an unbounded substring match.\n if (/(^|\\.)(twitter\\.com|x\\.com|facebook\\.com|linkedin\\.com|reddit\\.com|t\\.co)$/.test(host)) return 'social';\n return 'referral';\n } catch {\n return 'direct';\n }\n}\n\nexport function referrerDomainFromReferer(referrer: string): string | null {\n if (!referrer) return null;\n try {\n return new URL(referrer).hostname;\n } catch {\n return null;\n }\n}\n\n/**\n * Ad-platform click-ID query params worth keeping. An ALLOWLIST, unlike the\n * `utm_` prefix match: unknown query keys here are unbounded-cardinality junk\n * (session tokens, cache busters) that would bloat the sessions table, so only\n * the IDs the major ad platforms actually append survive.\n *\n * gclid / gbraid / wbraid — Google Ads auto-tagging (search, YouTube, Display;\n * gbraid/wbraid are the iOS-14 privacy variants)\n * fbclid — Meta (Facebook + Instagram). Appended to EVERY outbound Meta\n * click, paid and organic alike — it identifies the platform, never spend.\n * ttclid — TikTok Ads\n * msclkid — Microsoft Ads (Bing)\n * twclid — X/Twitter Ads\n * li_fat_id — LinkedIn Ads\n */\nexport const CLICK_ID_KEYS: readonly string[] = [\n 'gclid',\n 'gbraid',\n 'wbraid',\n 'fbclid',\n 'ttclid',\n 'msclkid',\n 'twclid',\n 'li_fat_id',\n];\n\n/**\n * Splits a URL query into the attribution params the session upsert carries:\n * every `utm_`-prefixed key, plus allowlisted ad click IDs (CLICK_ID_KEYS).\n * Accepts a raw search string (\"?a=b\" or \"a=b\"), a URLSearchParams, or a\n * Next.js `searchParams` object (whose values may be string arrays — the\n * first occurrence wins, matching URLSearchParams iteration order).\n * Node-safe: no DOM APIs.\n */\nexport function extractTrackedParams(\n search: string | URLSearchParams | Record<string, string | string[] | undefined>,\n): { utmParams: Record<string, string>; clickIds: Record<string, string> } {\n const utmParams: Record<string, string> = {};\n const clickIds: Record<string, string> = {};\n try {\n const entries: Iterable<[string, string]> =\n typeof search === 'string' || search instanceof URLSearchParams\n ? new URLSearchParams(search)\n : Object.entries(search).flatMap(([k, v]): Array<[string, string]> => {\n const first = Array.isArray(v) ? v[0] : v;\n return first === undefined ? [] : [[k, first]];\n });\n for (const [k, v] of entries) {\n // First occurrence wins for duplicates — a repeated gclid in a mangled\n // URL must not let the later value silently replace the real one.\n if (k.startsWith('utm_')) {\n if (!(k in utmParams)) utmParams[k] = v;\n } else if (CLICK_ID_KEYS.includes(k)) {\n if (!(k in clickIds)) clickIds[k] = v;\n }\n }\n } catch {\n /* malformed input → empty attribution, never a throw at init() */\n }\n return { utmParams, clickIds };\n}\n\nexport function detectTimeOfDay(d: Date): string {\n const h = d.getHours();\n if (h < 6) return 'night';\n if (h < 12) return 'morning';\n if (h < 18) return 'afternoon';\n return 'evening';\n}\n\nexport type SessionUpsertPayload = {\n sessionId: string;\n ephemeral: boolean;\n utmParams: Record<string, string>;\n /** Allowlisted ad-platform click IDs from the landing URL (CLICK_ID_KEYS). */\n clickIds: Record<string, string>;\n deviceClass: string;\n trafficSource: string;\n referrerDomain: string | null;\n timeOfDay: string;\n dayOfWeek: string;\n /**\n * True when this session is likely driven by automation — either\n * `navigator.webdriver` was set, or the user-agent carried a known agent\n * token. Probabilistic: a flag for metrics + bandit exclusion, never a gate.\n */\n automation: boolean;\n};\n\n/** Bandit segment key: `<device_class>:<traffic_source>`. */\nexport function deriveSessionSegment(opts?: {\n userAgent?: string;\n referer?: string;\n appOrigin?: string;\n}): string {\n const body = buildSessionUpsertPayload('__segment__', opts);\n return `${body.deviceClass}:${body.trafficSource}`;\n}\n\n/**\n * Builds a session upsert body aligned with the browser SDK so SSR assign uses\n * the same segment key (`device:source`) as the client after hydration.\n */\nexport function buildSessionUpsertPayload(\n sessionId: string,\n opts?: {\n userAgent?: string;\n referer?: string;\n appOrigin?: string;\n utmParams?: Record<string, string>;\n clickIds?: Record<string, string>;\n now?: Date;\n /** `navigator.webdriver` value from the browser, when available. */\n webdriver?: boolean;\n },\n): SessionUpsertPayload {\n const ua = opts?.userAgent?.trim() ?? '';\n const referer = opts?.referer?.trim() ?? '';\n const now = opts?.now ?? new Date();\n return {\n sessionId,\n ephemeral: false,\n utmParams: opts?.utmParams ?? {},\n clickIds: opts?.clickIds ?? {},\n deviceClass: ua ? detectDeviceClass(ua) : 'desktop',\n trafficSource: referer\n ? detectTrafficSource(referer, opts?.appOrigin)\n : 'direct',\n referrerDomain: referrerDomainFromReferer(referer),\n timeOfDay: detectTimeOfDay(now),\n dayOfWeek: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'][now.getDay()] ?? 'sun',\n automation: opts?.webdriver === true || uaTokenMatch(ua),\n };\n}\n","/**\n * Slot declaration helpers shared by the browser client (decide) and the\n * server preload path. Pure wrappers over @sentientui/policy.\n */\nimport {\n canonicalArm,\n slotBaselineArm,\n slotResultFor,\n type SlotDecl,\n type SlotResult,\n} from '@sentientui/policy';\n\n/** SDK-facing slot declaration. `dims` accepts readonly arrays (`as const`). */\nexport type SlotDeclInput = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n baseline?: string | Record<string, string>;\n};\n\nexport type { SlotResult };\n\n/**\n * Whitelists the wire fields of a slot declaration. Anything an SDK layer\n * attached (goal configs, refs, …) is stripped so it never reaches the zod\n * schema on the API. Also normalizes readonly arrays to mutable ones.\n */\nexport function toWireSlot(d: SlotDeclInput): SlotDecl {\n return {\n id: d.id,\n ...(d.arms ? { arms: [...d.arms] } : {}),\n ...(d.dims\n ? {\n dims: Object.fromEntries(\n Object.entries(d.dims).map(([dim, values]) => [dim, [...values]]),\n ),\n }\n : {}),\n ...(d.baseline !== undefined ? { baseline: d.baseline } : {}),\n };\n}\n\n/** The declared (or default first-declared) baseline result for a slot. */\nexport function baselineResultFor(d: SlotDeclInput): SlotResult {\n const decl = toWireSlot(d);\n return slotResultFor(decl, slotBaselineArm(decl));\n}\n\n/** Baseline results for a whole declaration list, keyed by slot id. */\nexport function baselineSlots(decls: SlotDeclInput[]): Record<string, SlotResult> {\n const out: Record<string, SlotResult> = {};\n for (const d of decls) out[d.id] = baselineResultFor(d);\n return out;\n}\n\n/**\n * Canonical arm string of a slot result: dims results encode as sorted\n * `dim=value` pairs joined with '|'; arms results are the arm id verbatim.\n */\nexport function armOfResult(result: SlotResult): string {\n return typeof result === 'string' ? result : canonicalArm(result);\n}\n"],"mappings":"oCAQO,IAAMA,EAAiC,CAC5C,SACA,eACA,gBACA,YACA,cACA,mBACA,gBACA,kBACA,kBACA,oBACA,qBACA,aACA,QACA,YACA,YACA,SACF,EAGO,SAASC,EAAaC,EAA4B,CACvD,OAAOC,EAAkBD,CAAS,IAAM,IAC1C,CAGO,SAASC,EAAkBD,EAAkC,CAjCpE,IAAAE,EAkCE,GAAI,CAACF,EAAW,OAAO,KACvB,IAAMG,EAAIH,EAAU,YAAY,EAChC,OAAOE,EAAAJ,EAAY,KAAMM,GAAUD,EAAE,SAASC,EAAM,YAAY,CAAC,CAAC,IAA3D,KAAAF,EAAgE,IACzE,CAaO,IAAMG,EAA6C,CACxD,OAAU,WACV,eAAgB,OAChB,gBAAiB,SACjB,UAAa,WACb,cAAe,OACf,mBAAoB,SACpB,cAAiB,SACjB,kBAAmB,OACnB,kBAAmB,WACnB,oBAAqB,WACrB,qBAAsB,WACtB,WAAc,WACd,MAAS,WACT,UAAa,QACb,YAAa,WACb,QAAW,OACb,EAGO,SAASC,EAAYC,EAAqC,CAC/D,GAAI,CAACA,EAAS,MAAO,QACrB,IAAMC,EAAMV,EAAY,KAAMW,GAAMA,EAAE,YAAY,IAAMF,EAAQ,YAAY,CAAC,EAC7E,OAAQC,GAAOH,EAAcG,CAAG,GAAM,OACxC,CAGO,SAASE,GAAkD,CA7ElE,IAAAR,EA8EE,IAAMS,EAAqC,CAAE,KAAM,CAAC,EAAG,OAAQ,CAAC,EAAG,SAAU,CAAC,EAAG,MAAO,CAAC,CAAE,EAC3F,QAAWF,KAAKX,EAAaa,GAAIT,EAAAG,EAAcI,CAAC,IAAf,KAAAP,EAAoB,OAAO,EAAE,KAAKO,CAAC,EACpE,OAAOE,CACT,CAEO,SAASC,EAAkBZ,EAA2B,CAC3D,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C,CAAE,CACzD,CACF,CC3PA,OACE,gBAAAG,EACA,mBAAAC,EACA,iBAAAC,MAGK,qBAiBA,SAASC,EAAWC,EAA4B,CACrD,OAAOC,MAAA,CACL,GAAID,EAAE,IACFA,EAAE,KAAO,CAAE,KAAM,CAAC,GAAGA,EAAE,IAAI,CAAE,EAAI,CAAC,GAClCA,EAAE,KACF,CACE,KAAM,OAAO,YACX,OAAO,QAAQA,EAAE,IAAI,EAAE,IAAI,CAAC,CAACE,EAAKC,CAAM,IAAM,CAACD,EAAK,CAAC,GAAGC,CAAM,CAAC,CAAC,CAClE,CACF,EACA,CAAC,GACDH,EAAE,WAAa,OAAY,CAAE,SAAUA,EAAE,QAAS,EAAI,CAAC,EAE/D,CAGO,SAASI,EAAkBJ,EAA8B,CAC9D,IAAMK,EAAON,EAAWC,CAAC,EACzB,OAAOM,EAAcD,EAAME,EAAgBF,CAAI,CAAC,CAClD,CAGO,SAASG,EAAcC,EAAoD,CAChF,IAAMC,EAAkC,CAAC,EACzC,QAAWV,KAAKS,EAAOC,EAAIV,EAAE,EAAE,EAAII,EAAkBJ,CAAC,EACtD,OAAOU,CACT,CAMO,SAASC,EAAYC,EAA4B,CACtD,OAAO,OAAOA,GAAW,SAAWA,EAASC,EAAaD,CAAM,CAClE","names":["agentUaList","uaTokenMatch","userAgent","matchedAgentToken","_a","s","token","AGENT_INTENTS","agentIntent","botName","hit","t","classifiedAgents","out","detectDeviceClass","detectTrafficSource","referrer","appOrigin","refUrl","e","host","referrerDomainFromReferer","CLICK_ID_KEYS","extractTrackedParams","search","utmParams","clickIds","entries","k","v","first","detectTimeOfDay","d","h","deriveSessionSegment","opts","body","buildSessionUpsertPayload","sessionId","_b","_c","_d","_e","_f","_g","_h","ua","referer","now","canonicalArm","slotBaselineArm","slotResultFor","toWireSlot","d","__spreadValues","dim","values","baselineResultFor","decl","slotResultFor","slotBaselineArm","baselineSlots","decls","out","armOfResult","result","canonicalArm"]}
|