@matterfact/embed 0.11.2 → 0.12.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/README.md +7 -4
- package/dist/{chunk-AANODHBV.js → chunk-C4XGE6BO.js} +71 -42
- package/dist/chunk-C4XGE6BO.js.map +1 -0
- package/dist/chunk-M5TS546Z.js +2 -0
- package/dist/chunk-SR4ZNUAN.js +3 -0
- package/dist/chunk-SR4ZNUAN.js.map +7 -0
- package/dist/{chunk-JO3GWFMJ.js → chunk-WAUSVV7Y.js} +2 -2
- package/dist/{chunk-CTZEDOH7.js → chunk-ZXMJWCQV.js} +72 -44
- package/dist/chunk-ZXMJWCQV.js.map +1 -0
- package/dist/{context-FR7VFENN.js → context-4LP3EDXL.js} +3 -3
- package/dist/{context-FR7VFENN.js.map → context-4LP3EDXL.js.map} +1 -1
- package/dist/{context-IK5MECUW.js → context-ZSPDZWIB.js} +4 -2
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +3 -3
- package/dist/index.cjs +110 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -10
- package/dist/index.d.ts +12 -10
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +102 -45
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +26 -5
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-2V5SDSH2.js → snapshot-OR5SVEUD.js} +2 -2
- package/dist/{snapshot-Y5BF2UJR.js → snapshot-X6FPP3HF.js} +3 -3
- package/dist/{snapshot-Y5BF2UJR.js.map → snapshot-X6FPP3HF.js.map} +1 -1
- package/examples/embed-demo/.env.example +7 -3
- package/examples/embed-demo/README.md +25 -4
- package/examples/embed-demo/src/App.tsx +67 -7
- package/examples/embed-demo/src/styles.css +52 -0
- package/examples/embed-demo/vite.config.ts +3 -2
- package/package.json +1 -1
- package/dist/chunk-AANODHBV.js.map +0 -1
- package/dist/chunk-CTZEDOH7.js.map +0 -1
- package/dist/chunk-SKJFF7RD.js +0 -2
- package/dist/chunk-Y7I25VHL.js +0 -3
- package/dist/chunk-Y7I25VHL.js.map +0 -7
- /package/dist/{chunk-SKJFF7RD.js.map → chunk-M5TS546Z.js.map} +0 -0
- /package/dist/{chunk-JO3GWFMJ.js.map → chunk-WAUSVV7Y.js.map} +0 -0
- /package/dist/{context-IK5MECUW.js.map → context-ZSPDZWIB.js.map} +0 -0
- /package/dist/{snapshot-2V5SDSH2.js.map → snapshot-OR5SVEUD.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pageContextMode.ts", "../src/redact.ts", "../src/adapters/hoist.ts", "../src/adapters/hoist-runtime.ts", "../src/adapters/registry.ts", "../src/context.ts"],
|
|
4
|
+
"sourcesContent": ["/** Page-context observation modes (embed host + admin max). */\n\nexport type PageContextMode = 'full' | 'declared' | 'off';\n\nconst RANK: Record<PageContextMode, number> = {\n off: 0,\n declared: 1,\n full: 2,\n};\n\n/** Coerce host/config/bootstrap values. Bool aliases: true\u2192full, false\u2192off. */\nexport function parsePageContextMode(value: unknown): PageContextMode {\n if (typeof value === 'boolean') return value ? 'full' : 'off';\n if (value == null) return 'full';\n const s = String(value).trim().toLowerCase();\n if (s === 'full' || s === 'declared' || s === 'off') return s;\n if (s === 'true' || s === 'on' || s === '1' || s === 'yes') return 'full';\n if (s === 'false' || s === '0' || s === 'no') return 'off';\n return 'full';\n}\n\n/** Effective mode = more restrictive of admin max and host request. */\nexport function clampPageContextMode(\n adminMax: PageContextMode,\n hostRequest: PageContextMode,\n): PageContextMode {\n return RANK[adminMax] <= RANK[hostRequest] ? adminMax : hostRequest;\n}\n\nexport function allowsDeclared(mode: PageContextMode): boolean {\n return mode !== 'off';\n}\n\nexport function allowsAuto(mode: PageContextMode): boolean {\n return mode === 'full';\n}\n", "/**\n * Redaction, split out of context.ts so it can be imported by both context.ts\n * (the DOM-walking eye) and the Hoist adapter (adapters/hoist.ts) without the\n * latter creating an import cycle back into context.ts.\n *\n * Re-exported from context.ts (`export { redact } from './redact'`) so every\n * existing importer of `redact` from `./context` keeps working unchanged.\n */\n\nconst PII = [\n /\\b[\\w.+-]+@[\\w-]+\\.[\\w.]{2,}\\b/g, // email\n /\\b(?:\\d[ -]?){13,19}\\b/g, // card-ish\n /\\b\\d{3}[- ]?\\d{2}[- ]?\\d{4}\\b/g, // ssn \u2014 dashed, spaced, OR bare 9 digits\n /\\b\\d{9,}\\b/g, // long bare digit runs: account / MRN / routing numbers\n /(?:\\+?\\d{1,2}[\\s.-]?)?\\(?\\d{3}\\)?[\\s.-]\\d{3}[\\s.-]\\d{4}\\b/g, // us phone\n /\\b(?:sk|pk|rk|ak)_(?:live|test)_[A-Za-z0-9]{8,}\\b/g, // stripe-style api keys\n /\\beyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+\\b/g, // jwt\n];\n\n/**\n * Scrub before anything leaves the page \u2014 not after it arrives.\n *\n * A compromised widget, or a bug in ours, must not be able to retroactively obtain\n * a customer's users' email addresses. The only way to guarantee that is to never\n * put them on the wire.\n */\nexport function redact(text: string): string {\n let out = text;\n for (const re of PII) out = out.replace(re, '[redacted]');\n return out;\n}\n", "/**\n * The Hoist adapter \u2014 a pure transform from a `HoistRuntime` (already read out of\n * `window.XH` by hoist-runtime.ts) into the context/snapshot shapes context.ts sends\n * over the bridge.\n *\n * This file never touches `window` or `XH` itself \u2014 see hoist-runtime.ts for the only\n * code that does \u2014 so every function here is a plain, fully unit-testable transform\n * against a plain object. That split is what keeps this file degrade-safe: it can be\n * exhaustively tested without a real Hoist app, and hoist-runtime.ts's own try/catch\n * (via detectHoist) is the one place a live-model surprise can ever throw.\n */\n\n// From ./redact, not ./context: context.ts (Task 7) imports THIS module, so importing\n// from ./context here would be a cycle. redact.ts holds no other context.ts state, so\n// this is the clean fix rather than a same-cycle-but-runtime-safe workaround. context.ts\n// still re-exports `redact`, so every pre-existing importer is unaffected.\nimport { redact } from '../redact';\nimport type { HostTool, PageContext } from '../protocol';\n\nexport interface HoistRoute {\n name: string;\n path: string;\n params: Record<string, unknown>;\n}\nexport interface HoistColumn {\n field: string;\n header: string;\n}\nexport type HoistRow = Record<string, unknown>;\nexport interface HoistGrid {\n id: string;\n title: string;\n columns: HoistColumn[];\n selected: HoistRow[];\n rows: HoistRow[];\n totalCount: number;\n}\nexport interface HoistChart {\n id: string;\n title: string;\n series: { name: string; data: number[] }[];\n}\n/** A navigable destination in the host app: a human label + a deep-link path. */\nexport interface HoistDestination {\n label: string;\n path: string;\n /**\n * The fully-qualified router route name (e.g. `default.company.ticker.ownership`) \u2014\n * what `hoist.navigate` actually hands `XH.navigate`/`XH.router.navigate`. The LABEL\n * is what the agent sees and picks from (the tool arg is `destination`, a label); the\n * name is resolved from it internally, never exposed as an arg the model fills in.\n */\n name: string;\n /** True for the destination the user is currently on (per nav level). */\n current?: boolean;\n}\n/** One level of site navigation (a Hoist TabContainer): the top app tabs, the\n * per-section sidebar, etc. */\nexport interface HoistNavGroup {\n label: string;\n items: HoistDestination[];\n}\nexport interface HoistRuntime {\n route: HoistRoute;\n grids: HoistGrid[];\n charts: HoistChart[];\n /** The site map \u2014 navigable destinations, grouped by nav level. */\n nav: HoistNavGroup[];\n}\n\n/** Read the runtime through `read`, but never let a Hoist-side error reach context.ts.\n * Returns null when there is nothing worth sending, so the caller falls back to the\n * generic DOM walker. */\nexport function detectHoist(\n read: () => HoistRuntime | null,\n): HoistRuntime | null {\n let rt: HoistRuntime | null;\n try {\n rt = read();\n } catch {\n return null;\n }\n if (!rt) return null;\n const worthwhile =\n !!rt.route.name ||\n rt.grids.length > 0 ||\n rt.charts.length > 0 ||\n rt.nav.length > 0;\n return worthwhile ? rt : null;\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 grid rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** Collapse whitespace, then redact, then truncate, then escape \u2014 in that order.\n * The order matches dom/snapshot.ts's `sanitize()`: truncate first and a value\n * containing PII can be cut through the middle of it, the regex no longer\n * matches, and the fragment before the cut ships unredacted. Collapsing\n * whitespace first also means an embedded newline can never survive into the\n * YAML as a fabricated sibling line. */\nfunction quote(s: string, max = 120): string {\n const clean = redact(s.replace(/\\s+/g, ' ').trim());\n const capped = clean.length > max ? `${clean.slice(0, max - 1)}\u2026` : clean;\n return `\"${capped.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/** One field value \u2192 a short, redacted, quoted cell string. */\nfunction cell(value: unknown): string {\n const s = value == null ? '' : String(value);\n return `- cell ${quote(s)}`;\n}\n\nfunction pushRow(\n row: HoistRow,\n cols: HoistColumn[],\n out: string[],\n pad: string,\n): void {\n out.push(`${pad}- row:`);\n for (const c of cols) out.push(`${pad} ${cell(row[c.field])}`);\n}\n\nexport function renderGrid(\n grid: HoistGrid,\n rowCap: number,\n out: string[],\n depth: number,\n): void {\n const pad = ' '.repeat(depth);\n out.push(`${pad}- table ${quote(grid.title || 'grid')}:`);\n\n out.push(`${pad} - rowgroup \"columns\":`);\n for (const c of grid.columns)\n out.push(`${pad} - columnheader ${quote(c.header || c.field)}`);\n\n if (grid.selected.length) {\n out.push(`${pad} - rowgroup \"selected\":`);\n for (const r of grid.selected) pushRow(r, grid.columns, out, `${pad} `);\n }\n\n const shown = grid.rows.slice(0, Math.max(0, rowCap));\n out.push(`${pad} - rowgroup \"rows\":`);\n for (const r of shown) pushRow(r, grid.columns, out, `${pad} `);\n\n out.push(\n `${pad} - text: ${quote(`showing ${shown.length} of ${grid.totalCount} rows`)}`,\n );\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 chart rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nfunction seriesSummary(name: string, data: number[]): string {\n if (!data.length) return `series ${name}: 0 points`;\n // Looped, not Math.min(...data)/Math.max(...data): spreading a large series into\n // call arguments hits the engine's argument-count ceiling (RangeError) well within\n // the size of a normal intraday/tick series. See adapters/hoist.test.ts's 200k-point\n // case.\n let min = data[0];\n let max = data[0];\n for (const n of data) {\n if (n < min) min = n;\n if (n > max) max = n;\n }\n const last = data[data.length - 1];\n return `series ${name}: ${data.length} points, min ${min}, max ${max}, last ${last}`;\n}\n\nexport function renderChart(\n chart: HoistChart,\n out: string[],\n depth: number,\n): void {\n const pad = ' '.repeat(depth);\n out.push(`${pad}- figure ${quote(chart.title || 'chart')}:`);\n for (const s of chart.series) {\n out.push(`${pad} - text: ${quote(seriesSummary(s.name, s.data))}`);\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 site-map rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nexport function renderNav(\n groups: HoistNavGroup[],\n out: string[],\n depth: number,\n): void {\n const pad = ' '.repeat(depth);\n for (const g of groups) {\n if (!g.items.length) continue;\n out.push(`${pad}- navigation ${quote(g.label)}:`);\n for (const d of g.items) {\n const mark = d.current ? ' [current]' : '';\n // The path is a deep-link the agent can hand the user. Redact it like any value,\n // but leave it after the arrow rather than as a quoted YAML name.\n out.push(`${pad} - link ${quote(d.label)}${mark} \u2192 ${redact(d.path)}`);\n }\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 navigate tool (Layer 3) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** The host's policy for agent-driven actions, keyed by tool family. Read from\n * `window.matterfact.hoist.actions` by hoist-runtime.ts's `readActionsConfig`\n * (the `<MatterfactAgent actions>` React prop is sugar that writes that same\n * global \u2014 see react.tsx's `writeActionsGlobal`); `'off'` is the default \u2014 the\n * tool is opt-in, never advertised unless a host turns it on. */\nexport interface HoistActionsConfig {\n navigate: 'off' | 'confirm' | 'auto';\n}\n\n/** Every destination across every nav level, flattened \u2014 the universe `hoist.navigate`\n * is bounded to (its enum) and what `executeHostTool` looks the agent's chosen label\n * up against. */\nexport function flattenDestinations(rt: HoistRuntime): HoistDestination[] {\n return rt.nav.flatMap((g) => g.items);\n}\n\n/**\n * The `hoist.navigate` tool: lets the agent send the user to a destination in the\n * CURRENT site map. The arg is `destination` \u2014 the human LABEL the agent already sees\n * in the sitemap (e.g. \"Ownership\"), never a raw route name; the loader resolves the\n * label to a route name internally (see executeHostTool). The enum is exactly the\n * labels `readSitemap` found on THIS page, so the model cannot name a destination that\n * doesn't exist here \u2014 the injection bound this tool relies on.\n */\nexport function buildNavigateTool(\n rt: HoistRuntime,\n policy: 'confirm' | 'auto',\n): HostTool {\n const destinations = flattenDestinations(rt);\n const bySection = rt.nav\n .filter((g) => g.items.length)\n .map((g) => `${g.label} (${g.items.map((d) => d.label).join(', ')})`)\n .join('; ');\n return {\n name: 'hoist.navigate',\n description: redact(\n 'Navigate the user to a destination in the app. \"destination\" must be one of ' +\n `the destinations currently available, grouped by section: ${bySection || '(none available)'}.`,\n ),\n inputSchema: {\n type: 'object',\n properties: {\n destination: {\n type: 'string',\n enum: destinations.map((d) => d.label),\n },\n params: { type: 'object' },\n },\n required: ['destination'],\n },\n readOnly: false,\n // 'confirm' policy \u21D2 the widget must show a confirm card every call; 'auto' \u21D2 it\n // may call without asking. See the confirm field's doc comment on HostTool.\n confirm: policy === 'auto' ? 'auto' : 'required',\n };\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 top-level transforms \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nexport function buildHoistContext(rt: HoistRuntime): PageContext {\n const selected = rt.grids.reduce((n, g) => n + g.selected.length, 0);\n const view = rt.route.name || rt.route.path || 'this view';\n const bits = [`Viewing ${view}`];\n if (selected) bits.push(`${selected} selected`);\n if (rt.grids.length) bits.push(`${rt.grids.length} grid(s)`);\n if (rt.charts.length) bits.push(`${rt.charts.length} chart(s)`);\n return {\n route: rt.route.name ? redact(rt.route.name) : undefined,\n description: redact(`${bits.join(', ')}.`),\n };\n}\n\nexport function renderHoistSnapshot(\n rt: HoistRuntime,\n rowCap: number,\n): { yaml: string; truncated: boolean } {\n const out: string[] = [];\n // Nav LEADS. It's the most stable part of the page \u2014 it barely changes as the user\n // works within a view \u2014 so emitting it first keeps the snapshot's prefix stable\n // across turns (better prompt caching) and orients the agent before the volatile\n // grid/chart data.\n renderNav(rt.nav, out, 0);\n let truncated = false;\n for (const g of rt.grids) {\n if (g.rows.length > rowCap) truncated = true;\n renderGrid(g, rowCap, out, 0);\n }\n for (const c of rt.charts) renderChart(c, out, 0);\n return { yaml: out.join('\\n'), truncated };\n}\n", "/**\n * The only module that touches `window.XH`.\n *\n * Everything here is defensive by construction: every field read is optional-chained\n * and falls back to an empty/zero value, so a Hoist version whose shape drifts from\n * what's confirmed below degrades to missing fields rather than a thrown error. The\n * one place a genuine surprise (e.g. `XH` itself being a stub) could still throw is\n * caught one layer up, by `detectHoist()` in ./hoist \u2014 this module does not try/catch.\n *\n * The accessors below are CONFIRMED against a live ActivistHub instance (see\n * adapters/HOIST-CONTRACT.md). Two findings shaped this file:\n * 1. Model discovery uses the global `XH.getModels(className)` lookup, NOT the\n * Inspector \u2014 `XH.inspectorService.activeInstances` is empty unless the dev\n * Inspector UI is toggled on, so it's useless as an ambient source.\n * 2. Grid columns can be GROUPED: `gridModel.columns` holds ColumnGroups (no field,\n * a `.children` array) whose leaves carry the real `colId`. We read the flat leaf\n * set via `getVisibleLeafColumns()` and prefix each leaf's header with its group\n * (\"5Y\" group + \"Value\" leaf -> \"5Y Value\") so the columns aren't ambiguous.\n */\n\nimport type {\n HoistRuntime,\n HoistGrid,\n HoistChart,\n HoistColumn,\n HoistRow,\n HoistNavGroup,\n HoistDestination,\n HoistActionsConfig,\n} from './hoist';\nimport { buildNavigateTool, flattenDestinations } from './hoist';\nimport type { HostTool, ToolCall } from '../protocol';\nimport { redact } from '../redact';\n\nexport function readHoistConfig(win: unknown): {\n rows: number;\n excludeModels: string[];\n} {\n const cfg = (\n win as {\n matterfact?: { hoist?: { rows?: number; excludeModels?: string[] } };\n }\n )?.matterfact?.hoist;\n const ex = cfg?.excludeModels;\n return {\n rows: typeof cfg?.rows === 'number' && cfg.rows >= 0 ? cfg.rows : 50,\n excludeModels: Array.isArray(ex) ? ex : [],\n };\n}\n\n// \u2500\u2500 model discovery \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Confirmed: `XH.getModels(className)` returns every mounted model of that class\n// (a native Hoist ModelSelector form). It also returns empty / off-view grids that\n// happen to be mounted \u2014 those are dropped by `hasContent` in readHoistRuntime.\nfunction getModelsByClass(XH: any, name: string): any[] {\n const models = typeof XH?.getModels === 'function' ? XH.getModels(name) : [];\n return Array.isArray(models) ? models : [];\n}\n\nfunction className(m: any): string {\n return m?.constructor?.name ?? '';\n}\n\nfunction modelId(m: any): string {\n return String(m?.xhId ?? m?.id ?? m?.modelId ?? '');\n}\n\nfunction headerOf(c: any): string {\n return String(c?.headerName ?? c?.displayName ?? c?.field ?? c?.colId ?? '');\n}\n\n// Walk the full column tree (a ColumnGroup has a `.children` array and no field) to\n// map each leaf colId -> its group-qualified header, so a leaf headed \"Value\" under a\n// \"5Y\" group reads as \"5Y Value\" rather than an ambiguous bare \"Value\".\nfunction collectHeaders(\n cols: any[],\n prefix: string[],\n out: Map<string, string>,\n): void {\n for (const c of Array.isArray(cols) ? cols : []) {\n const children = c?.children;\n if (Array.isArray(children) && children.length) {\n collectHeaders(children, [...prefix, headerOf(c)], out);\n } else {\n const id = String(c?.colId ?? c?.field ?? '');\n if (id) out.set(id, [...prefix, headerOf(c)].filter(Boolean).join(' '));\n }\n }\n}\n\n// Prefer getVisibleLeafColumns() \u2014 flat, hidden-aware, real colIds \u2014 over the raw\n// `columns` tree (which contains groups without fields). Falls back to `columns` for\n// a Hoist without that method.\nfunction readColumns(g: any): HoistColumn[] {\n const leaves =\n typeof g?.getVisibleLeafColumns === 'function'\n ? g.getVisibleLeafColumns()\n : Array.isArray(g?.columns)\n ? g.columns\n : [];\n const headers = new Map<string, string>();\n collectHeaders(Array.isArray(g?.columns) ? g.columns : [], [], headers);\n return (Array.isArray(leaves) ? leaves : [])\n .map((c: any) => {\n const field = String(c?.colId ?? c?.field ?? '');\n return { field, header: headers.get(field) || headerOf(c) };\n })\n .filter((c: HoistColumn) => c.field);\n}\n\nfunction readRow(rec: any, cols: HoistColumn[]): HoistRow {\n const row: HoistRow = {};\n for (const c of cols)\n row[c.field] =\n typeof rec?.get === 'function' ? rec.get(c.field) : rec?.data?.[c.field];\n return row;\n}\n\nfunction readGrid(g: any): HoistGrid {\n const columns = readColumns(g);\n const records = Array.isArray(g?.store?.records) ? g.store.records : [];\n return {\n id: modelId(g),\n title: String(g?.title ?? ''),\n columns,\n selected: (Array.isArray(g?.selectedRecords) ? g.selectedRecords : []).map(\n (r: any) => readRow(r, columns),\n ),\n rows: records.map((r: any) => readRow(r, columns)),\n totalCount:\n typeof g?.store?.allCount === 'number'\n ? g.store.allCount\n : records.length,\n };\n}\n\n// An off-view / not-yet-loaded grid (no rows AND nothing selected) is one that\n// XH.getModels still returns but that carries no page-context value \u2014 drop it.\nfunction hasContent(g: HoistGrid): boolean {\n return g.totalCount > 0 || g.selected.length > 0;\n}\n\nfunction readChart(c: any): HoistChart {\n // Confirmed: series data points can be [timestamp, value] tuples (not bare numbers) \u2014\n // extract the value (`d[1]` / `d.y`) so min/max/last summarise values, not timestamps.\n const series = c?.series ?? c?.highchartsConfig?.series ?? [];\n return {\n id: modelId(c),\n title: String(c?.title ?? c?.highchartsConfig?.title?.text ?? ''),\n series: (Array.isArray(series) ? series : []).map((s: any) => ({\n name: String(s?.name ?? ''),\n data: (Array.isArray(s?.data) ? s.data : [])\n .map((d: any) => (typeof d === 'number' ? d : Number(d?.y ?? d?.[1])))\n .filter((n: number) => Number.isFinite(n)),\n })),\n };\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 site map \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nfunction humanize(seg: string): string {\n return seg\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n .trim();\n}\n\nfunction childrenOf(node: any): any[] {\n const k = node?.children;\n return k ? (Array.isArray(k) ? k : Array.from(k)) : [];\n}\n\n// Map each route's LAST segment -> { path, fully-qualified name }, by walking the\n// router5 tree and building a deep-link path for each with the current params.\nfunction routeIndex(\n XH: any,\n params: Record<string, unknown>,\n): Map<string, { path: string; name: string }> {\n const router = XH?.router;\n const root = router?.rootNode ?? router?.config?.rootNode;\n const out = new Map<string, { path: string; name: string }>();\n if (!router || typeof router.buildPath !== 'function' || !root) return out;\n const walk = (node: any, prefix: string) => {\n for (const c of childrenOf(node)) {\n const seg = String(c?.name ?? '');\n if (!seg) continue;\n const name = prefix ? `${prefix}.${seg}` : seg;\n let path = '';\n try {\n path = router.buildPath(name, params);\n } catch {\n path = '';\n }\n if (path && !out.has(seg)) out.set(seg, { path, name });\n walk(c, name);\n }\n };\n walk(root, '');\n return out;\n}\n\n// The site map: each Hoist TabContainerModel is one nav level (top app tabs, the\n// per-section sidebar, \u2026). Its tabs give the exact human labels + the active tab;\n// the router gives each tab id its deep-link path. Route names \u2260 display labels\n// (e.g. `governanceScorecard` shows as \"Governance Risk\"), so the tab TITLE wins.\nfunction readSitemap(\n XH: any,\n excluded: (m: any) => boolean,\n origin: string,\n): HoistNavGroup[] {\n const params = (XH?.routerState?.params ?? {}) as Record<string, unknown>;\n const currentName = String(XH?.routerState?.name ?? '');\n const routes = routeIndex(XH, params);\n if (!routes.size) return [];\n\n const groups: HoistNavGroup[] = [];\n for (const tc of getModelsByClass(XH, 'TabContainerModel')) {\n if (excluded(tc)) continue;\n const tabs = Array.isArray(tc?.tabs) ? tc.tabs : [];\n const activeTabId = String(tc?.activeTabId ?? '');\n const items: HoistDestination[] = [];\n let companyScoped = false;\n for (const t of tabs) {\n const id = String(t?.id ?? '');\n const r = routes.get(id);\n if (!id || !r) continue;\n if (r.name.includes('.company.ticker.')) companyScoped = true;\n items.push({\n // Redact HERE, at the source \u2014 not in a downstream renderer. This is the\n // one place a Hoist tab TITLE (host-page text, so potentially PII-shaped)\n // becomes a `HoistDestination.label`, and that label is what EVERY\n // consumer uses verbatim: renderNav's YAML, buildNavigateTool's\n // description AND its inputSchema.enum, and executeHostTool's\n // `.find(d => d.label === destination)` lookup. Redacting once here keeps\n // all of them consistent by construction \u2014 an enum built from an\n // ALREADY-redacted label can never leak PII a sibling renderer scrubbed\n // (see Important #1), and a destination arg matching the redacted string\n // (the only thing the agent ever saw) still resolves.\n label: redact(String(t?.title ?? '') || humanize(id)),\n // ABSOLUTE, against the HOST page's origin \u2014 not the router's bare path.\n // This path's only job is to be a link the agent can hand the user, and\n // the agent's answer renders inside our widget iframe, which is on OUR\n // origin: a bare \"/research\" there resolves to app.matterfact.com/research\n // (a dead link to the wrong app), which is exactly what shipped before.\n // The adapter runs in the host page, so its own origin is the right one.\n path: origin && r.path.startsWith('/') ? origin + r.path : r.path,\n // The fully-qualified route name \u2014 what hoist.navigate hands XH.navigate.\n // Always present: `r` only exists here because routes.get(id) resolved.\n name: r.name,\n current: id === activeTabId || r.name === currentName,\n });\n }\n if (!items.length) continue;\n const ticker = String(params.ticker ?? '');\n const label = companyScoped\n ? ticker\n ? `Company \u00B7 ${ticker}`\n : 'Company'\n : 'Site';\n groups.push({ label, items });\n }\n return groups;\n}\n\nexport function readHoistRuntime(\n win: unknown = typeof window !== 'undefined' ? window : undefined,\n): HoistRuntime | null {\n const XH = (win as { XH?: any })?.XH;\n if (!XH) return null;\n const { excludeModels } = readHoistConfig(win);\n const excluded = (m: any) =>\n excludeModels.includes(className(m)) || excludeModels.includes(modelId(m));\n\n const rs = XH.routerState ?? {};\n return {\n route: {\n name: String(rs.name ?? ''),\n path: String(rs.path ?? ''),\n params: rs.params ?? {},\n },\n grids: getModelsByClass(XH, 'GridModel')\n .filter((m) => !excluded(m))\n .map(readGrid)\n .filter(hasContent),\n charts: getModelsByClass(XH, 'ChartModel')\n .filter((m) => !excluded(m))\n .map(readChart)\n .filter((c) => c.series.length > 0),\n nav: readSitemap(\n XH,\n excluded,\n String(\n (win as { location?: { origin?: string } })?.location?.origin ?? '',\n ),\n ),\n };\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 actions / tools (Layer 3) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/** Read the host's action policy from `window.matterfact.hoist.actions`. Defaults to\n * `{navigate:'off'}` \u2014 agent-driven navigation is opt-in, and any value other than\n * the two known policies degrades to `'off'` rather than advertising a tool under an\n * unrecognized policy. */\nexport function readActionsConfig(win: unknown): HoistActionsConfig {\n const navigate = (\n win as {\n matterfact?: { hoist?: { actions?: { navigate?: unknown } } };\n }\n )?.matterfact?.hoist?.actions?.navigate;\n return {\n navigate: navigate === 'confirm' || navigate === 'auto' ? navigate : 'off',\n };\n}\n\n/**\n * The tools this page currently offers the agent \u2014 today, just `hoist.navigate` when\n * a Hoist app is detected and the host has turned navigation on via\n * `window.matterfact.hoist.actions` (`readActionsConfig` above) \u2014 the SAME read\n * `executeHostTool` re-checks at call time, so advertise and execute can never\n * disagree about the current policy.\n *\n * Degrade-safe by construction: no `window.XH`, `navigate:'off'` (the default), no\n * detectable runtime, or a `getModels`/router surprise \u21D2 `[]`, never a throw \u2014 so a\n * caller can call this unconditionally without its own try/catch.\n */\nexport function advertiseTools(\n win: unknown = typeof window !== 'undefined' ? window : undefined,\n): HostTool[] {\n try {\n const XH = (win as { XH?: unknown })?.XH;\n if (!XH) return [];\n const { navigate } = readActionsConfig(win);\n if (navigate === 'off') return [];\n const rt = readHoistRuntime(win);\n if (!rt) return [];\n return [buildNavigateTool(rt, navigate)];\n } catch {\n return [];\n }\n}\n\n/**\n * Run a host tool call. Two enforcement points, both re-checked fresh on every call \u2014\n * never against anything the widget claims was advertised earlier, which a\n * compromised or merely-stale widget could lie about:\n *\n * 1. the host's CURRENT action policy (`readActionsConfig`) \u2014 a widget that cached\n * an advertisement from before the host flipped `actions.navigate` to `'off'`\n * (e.g. entering a regulated flow) must be refused, not just un-advertised;\n * 2. the destination, against the LIVE current sitemap.\n *\n * That is the \"loader route-bound\" guarantee the confirm card (Wave 2) sits on top\n * of, not a substitute for it.\n *\n * Degrade-safe and NEVER throws: any surprise (bad args, XH/router missing or\n * throwing) becomes `{ok:false, error}`, never an exception into context.ts. The\n * error text itself is redacted too \u2014 a thrown Error can plausibly embed host-page\n * detail, same as the success path's `result`.\n */\nexport function executeHostTool(\n call: ToolCall,\n win: unknown = typeof window !== 'undefined' ? window : undefined,\n): { ok: boolean; result?: unknown; error?: string } {\n try {\n if (call.name !== 'hoist.navigate') {\n return { ok: false, error: 'unknown tool' };\n }\n // Execute-time policy re-check (defense-in-depth): `advertiseTools` already\n // gates on this at advertise time, but that is not an access-control decision\n // this function may assume still holds \u2014 the widget calling in is exactly the\n // thing this whole module treats as untrustworthy. See the doc comment above.\n if (readActionsConfig(win).navigate === 'off') {\n return { ok: false, error: 'navigation is disabled' };\n }\n\n const destination = String(call.args?.destination ?? '');\n const rt = readHoistRuntime(win);\n const item = rt\n ? flattenDestinations(rt).find((d) => d.label === destination)\n : undefined;\n if (!item) return { ok: false, error: 'unknown destination' };\n\n const XH = (win as { XH?: any })?.XH;\n // Merge: the CURRENT route's params first, then whatever the agent explicitly\n // supplied on top. A company subroute (e.g. Ownership) needs the current\n // `ticker` param to resolve correctly even though the agent never saw or passed\n // it; an agent-supplied key still wins on conflict (spread order).\n const params = {\n ...(XH?.routerState?.params ?? {}),\n ...((call.args?.params as Record<string, unknown> | undefined) ?? {}),\n };\n if (typeof XH?.navigate === 'function') {\n XH.navigate(item.name, params);\n } else if (typeof XH?.router?.navigate === 'function') {\n XH.router.navigate(item.name, params);\n } else {\n return { ok: false, error: 'navigation unavailable' };\n }\n return { ok: true, result: redact(`navigated to ${destination}`) };\n } catch (e) {\n return {\n ok: false,\n error: redact(e instanceof Error ? e.message : 'navigate failed'),\n };\n }\n}\n", "/**\n * The host-tool registry \u2014 the ONE place the three tool classes are merged into the\n * single list the widget advertises, and the ONE execution path for calling any of\n * them.\n *\n * Three classes, distinguished by who owns the contract and who runs the code:\n *\n * - `hoist.*` matterfact-defined, matterfact-implemented. The loader adapter runs\n * them (today: `hoist.navigate`). Gated on `window.XH` + the host's\n * `hoist.actions` policy. See `hoist-runtime.ts`.\n * - `mf.*` matterfact-defined, HOST-implemented. WE fix the name, schema and\n * agent semantics (the description is authored HERE, not per\n * integration); the host supplies the function via `resolve.*`. Today:\n * `mf.resolveDocument`, `mf.resolveArtifact`.\n * - `app.*` host-defined, host-implemented. Anything the host advertises via\n * `tools`. Normalised into the `app.` namespace so it can never shadow\n * ours.\n *\n * Everything downstream (the widget's confirm gate, the backend dispatcher) is already\n * generic over \"a tool with a name/schema/confirm and a call round-trip\" \u2014 this module\n * is purely the loader-side composition + dispatch, so `hoist-runtime.ts` stays one\n * adapter rather than the whole surface.\n *\n * SECURITY: `mf.*`/`app.*` handlers are HOST code. Their results and error strings pass\n * through `redact()` before leaving the page, exactly like the hoist adapter's; a\n * handler that throws or hangs becomes a normal `{ok:false}` result, never an exception\n * into `context.ts`. And the SERVER decides which of these an app may actually expose\n * (the `host_tools` policy) \u2014 advertising here is necessary but not sufficient.\n */\nimport type { HostTool, MatterfactEvent, ToolCall, ToolEvent } from '../protocol';\nimport { redact } from '../redact';\nimport { advertiseTools, executeHostTool } from './hoist-runtime';\n\n/** Advertised metadata rides EVERY turn's model context and is host-supplied. Bound\n * the count; the backend caps it too (defense in depth). */\nexport const MAX_TOOLS = 16;\n\n/** A host `mf.*`/`app.*` handler is host code \u2014 bound it so a hung promise surfaces as\n * a normal declined result INSIDE the backend's own ~60s wait, never eating it. */\nexport const HOST_HANDLER_TIMEOUT_MS = 30_000;\n\nexport type ToolClass = 'hoist' | 'mf' | 'app';\n\n/** A host-supplied resolver: matterfact fixes the contract, the host implements it. */\nexport interface HostResolvers {\n document?: (args: {\n doctype: string;\n key: string;\n }) => Promise<{ id: string; label: string; href?: string }>;\n artifact?: (args: {\n slug: string;\n }) => Promise<{ id: string; owner: string; token: string; label: string }>;\n}\n\n/** A host-defined tool (the `tools` prop): a WebMCP-shaped descriptor plus its handler. */\nexport interface HostToolDef {\n name: string;\n description: string;\n inputSchema?: Record<string, unknown>;\n confirm?: 'auto' | 'required';\n handler: (args: Record<string, unknown>) => unknown | Promise<unknown>;\n}\n\ninterface MatterfactGlobal {\n resolve?: HostResolvers;\n tools?: HostToolDef[];\n onToolEvent?: (e: ToolEvent) => void;\n onEvent?: (e: MatterfactEvent) => void;\n}\n\nfunction mfGlobal(win: unknown): MatterfactGlobal {\n return (\n (win as { matterfact?: MatterfactGlobal } | undefined)?.matterfact ?? {}\n );\n}\n\nexport function toolClass(name: string): ToolClass {\n if (name.startsWith('hoist.')) return 'hoist';\n if (name.startsWith('mf.')) return 'mf';\n return 'app';\n}\n\n/** Fire the host's unified `onEvent` telemetry hook, swallowing any throw. A host\n * telemetry callback is host code: a throw here must not fail a call, advertise, or\n * anything else on the path. */\nexport function emitEvent(win: unknown, e: MatterfactEvent): void {\n const cb = mfGlobal(win).onEvent;\n if (typeof cb !== 'function') return;\n try {\n cb(e);\n } catch {\n /* a host telemetry callback must never break the call path */\n }\n}\n\n/** Fire tool telemetry on BOTH the unified `onEvent` (tagged `type:'tool'`) and the\n * legacy `onToolEvent` shim (untagged). Each is independently throw-guarded, so a\n * throwing hook on one never starves the other or the call path. */\nexport function emitToolEvent(win: unknown, e: ToolEvent): void {\n emitEvent(win, { type: 'tool', ...e });\n const cb = mfGlobal(win).onToolEvent;\n if (typeof cb !== 'function') return;\n try {\n cb(e);\n } catch {\n /* legacy shim: a host telemetry callback must never break the call path */\n }\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 mf.* contracts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The `mf.*` tool descriptors. Authored HERE so the agent's understanding of them is\n * ours and lives in one place \u2014 an integration spends no instruction budget teaching\n * what they mean. Only advertised for the resolvers the host actually supplied.\n */\nfunction mfTools(win: unknown): HostTool[] {\n const { document, artifact } = mfGlobal(win).resolve ?? {};\n const out: HostTool[] = [];\n if (typeof document === 'function') {\n out.push({\n name: 'mf.resolveDocument',\n description:\n 'Resolve a matterfact document (dossier, report, briefing) that is NOT on the ' +\n 'current page to a concrete id. Call it with the document type and a key (e.g. a ' +\n 'ticker) when the site map shows the document lives on another route. Returns ' +\n '{id, label, href}. Cite the result inline as ' +\n '<MFRef kind=\"document\" id=\"<id>\" label=\"<label>\" /> \u2014 it renders as a chip that ' +\n 'opens the document in the side panel; href is its \"open on page\" deeplink.',\n inputSchema: {\n type: 'object',\n properties: {\n doctype: { type: 'string' },\n key: { type: 'string' },\n },\n required: ['doctype', 'key'],\n },\n readOnly: true,\n confirm: 'auto',\n });\n }\n if (typeof artifact === 'function') {\n out.push({\n name: 'mf.resolveArtifact',\n description:\n 'Resolve a matterfact artifact (an interactive board) that is NOT co-embedded on ' +\n 'the current page to a read grant. Call it with the artifact slug. Returns ' +\n '{id, owner, token, label}; the grant is applied for you. Cite the result inline ' +\n 'as <MFRef kind=\"artifact\" id=\"<id>\" label=\"<label>\" /> \u2014 it renders as a chip ' +\n 'that opens the artifact in the side panel.',\n inputSchema: {\n type: 'object',\n properties: { slug: { type: 'string' } },\n required: ['slug'],\n },\n readOnly: true,\n confirm: 'auto',\n });\n }\n return out;\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 app.* host tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nconst APP_NAME_RE = /^[A-Za-z0-9._-]+$/;\n\n/** Normalise a host tool name into the `app.` namespace so it can never collide with\n * `hoist.*`/`mf.*`. A name already prefixed `app.` is kept; anything else is prefixed.\n * Names outside the safe charset are dropped by the caller. */\nfunction appName(name: string): string {\n return name.startsWith('app.') ? name : `app.${name}`;\n}\n\nfunction appTools(win: unknown): HostTool[] {\n const defs = mfGlobal(win).tools;\n if (!Array.isArray(defs)) return [];\n const out: HostTool[] = [];\n for (const d of defs) {\n const raw = (d?.name ?? '').trim();\n if (!raw || typeof d.handler !== 'function') continue;\n const name = appName(raw);\n if (!APP_NAME_RE.test(name)) continue;\n out.push({\n name,\n description: String(d.description ?? `Run the host tool ${name}.`),\n inputSchema: d.inputSchema ?? { type: 'object', properties: {} },\n readOnly: false,\n confirm: d.confirm === 'auto' ? 'auto' : 'required',\n });\n }\n return out;\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 advertise \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The merged tool list this page offers the agent: hoist adapter tools, then the\n * `mf.*` contracts for supplied resolvers, then host `app.*` tools. matterfact-defined\n * names win on collision (an `app.*` normalisation can't produce one, but a host that\n * literally named a tool `mf.foo` in `app.` space still can't shadow a real `mf.*`).\n * Deduped by name, first-wins, capped at MAX_TOOLS.\n *\n * Degrade-safe: any surprise \u21D2 the entries built so far, never a throw \u2014 a caller can\n * call this unconditionally.\n */\nexport function advertise(\n win: unknown = typeof window !== 'undefined' ? window : undefined,\n): HostTool[] {\n const merged: HostTool[] = [];\n const seen = new Set<string>();\n const push = (tools: HostTool[]) => {\n for (const t of tools) {\n if (seen.has(t.name)) continue;\n seen.add(t.name);\n merged.push(t);\n }\n };\n try {\n push(advertiseTools(win));\n } catch {\n /* hoist adapter already degrade-safe; belt and suspenders */\n }\n try {\n push(mfTools(win));\n push(appTools(win));\n } catch {\n /* fall through with whatever merged so far */\n }\n return merged.slice(0, MAX_TOOLS);\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 execute \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nfunction timeout(ms: number): Promise<never> {\n return new Promise((_, reject) =>\n setTimeout(() => reject(new Error('host tool timed out')), ms),\n );\n}\n\n/** Redact anything a host handler returns before it can leave the page. Strings are\n * scrubbed directly; structured results are JSON round-tripped through the scrubber so\n * an email tucked in a field can't ride out. */\nfunction redactResult(value: unknown): unknown {\n if (value === undefined || value === null) return value;\n if (typeof value === 'string') return redact(value);\n try {\n return JSON.parse(redact(JSON.stringify(value)));\n } catch {\n return redact(String(value));\n }\n}\n\n/**\n * Run one host tool call. Dispatches by class:\n * - `hoist.*` \u2192 the existing adapter (keeps its OWN execute-time policy + route\n * re-checks \u2014 this module does not second-guess it);\n * - `mf.*` \u2192 the matching `resolve.*` function;\n * - `app.*` \u2192 the matching host `tools[].handler`.\n *\n * Handlers are read FRESH off the global on every call (so a host swapping a handler\n * body never needs a remount) and bounded at HOST_HANDLER_TIMEOUT_MS. NEVER throws:\n * any surprise becomes `{ok:false, error}`, redacted.\n */\nexport async function execute(\n call: ToolCall,\n win: unknown = typeof window !== 'undefined' ? window : undefined,\n): Promise<{ ok: boolean; result?: unknown; error?: string }> {\n const cls = toolClass(call.name);\n try {\n if (cls === 'hoist') {\n // Synchronous adapter; keep its result/redaction exactly as-is.\n return executeHostTool(call, win);\n }\n\n const handler = resolveHandler(win, call.name);\n if (!handler) return { ok: false, error: 'unknown tool' };\n\n const result = await Promise.race([\n Promise.resolve(handler(call.args ?? {})),\n timeout(HOST_HANDLER_TIMEOUT_MS),\n ]);\n return { ok: true, result: redactResult(result) };\n } catch (e) {\n return {\n ok: false,\n error: redact(e instanceof Error ? e.message : 'host tool failed'),\n };\n }\n}\n\n/** The host function backing an `mf.*`/`app.*` name, or undefined. */\nfunction resolveHandler(\n win: unknown,\n name: string,\n): ((args: Record<string, unknown>) => unknown) | undefined {\n const mf = mfGlobal(win);\n if (name === 'mf.resolveDocument') return mf.resolve?.document as never;\n if (name === 'mf.resolveArtifact') return mf.resolve?.artifact as never;\n if (name.startsWith('app.')) {\n const def = (mf.tools ?? []).find((d) => appName((d?.name ?? '').trim()) === name);\n return def?.handler;\n }\n return undefined;\n}\n", "import type {\n ActivityEvent,\n FocusContext,\n HostToWidget,\n PageContext,\n PageEntity,\n SiteMapEntry,\n ToolCall,\n} from './protocol';\nimport {\n allowsAuto,\n allowsDeclared,\n clampPageContextMode,\n parsePageContextMode,\n type PageContextMode,\n} from './pageContextMode';\nimport { redact } from './redact';\nimport {\n detectHoist,\n buildHoistContext,\n renderHoistSnapshot,\n} from './adapters/hoist';\nimport {\n readHoistRuntime,\n readHoistConfig,\n} from './adapters/hoist-runtime';\n// The registry composes the hoist adapter with the mf.*/app.* tool sources and is the\n// single advertise/execute surface \u2014 context.ts talks to it, not to the hoist adapter\n// directly. See adapters/registry.ts.\nimport { advertise, execute, emitToolEvent, toolClass } from './adapters/registry';\n\n// Re-exported so every existing importer of `redact` from `./context` (e.g.\n// dom/snapshot.ts) keeps working unchanged \u2014 see redact.ts for why the\n// definition itself lives in its own module.\nexport { redact } from './redact';\n\n/** The origin serving our chat \u2014 how we tell OUR embedded content from the host's own\n * iframes. Set by start(); empty until then, which just means we spot nothing. */\nlet widgetOrigin = '';\n\n/**\n * The eye.\n *\n * Everything in this module can see the customer's page. It is a SEPARATE CHUNK,\n * loaded only when someone actually opens the chat \u2014 so a page whose visitors never\n * click the widget pays nothing for any of it, and a security reviewer can read\n * exactly one file to know what we look at.\n *\n * The rules, which are not negotiable:\n *\n * NEVER captured \u2014 no config enables it: the value of any <input>, <textarea> or\n * contenteditable; anything inside a password field; cookies; localStorage;\n * sessionStorage; the raw DOM; screenshots; network traffic; anything inside an\n * element marked `data-mf-private`.\n *\n * The agent never gets a selector and never touches the DOM. It gets refs. A ref\n * is resolved to an element HERE, in the page, by us.\n */\n\ntype Send = (msg: HostToWidget) => void;\n\nconst MAX_ACTIVITY = 40;\n\nlet send: Send | null = null;\nlet activitySeq = 0;\nconst activity: ActivityEvent[] = [];\nlet lastUrl = '';\n/** Host-requested mode (before admin clamp). Set by `start()`. */\nlet hostPageContextMode: PageContextMode = 'full';\n/** Admin max from bootstrap (`widget.pageContextMax`); defaults to full. */\nlet adminPageContextMax: PageContextMode = 'full';\n\nfunction effectivePageContextMode(): PageContextMode {\n return clampPageContextMode(adminPageContextMax, hostPageContextMode);\n}\n\n/** @deprecated Prefer allowsDeclared/allowsAuto \u2014 true when any observation is on. */\nfunction pageContextOn(): boolean {\n return allowsDeclared(effectivePageContextMode());\n}\n\n/**\n * A host callback that returns the DECLARED page context on demand \u2014 the pull-based\n * counterpart to the static `window.matterfact.context` global. Symmetric with\n * `AuthTokenProvider`: the React `<MatterfactAgent getPageContext>` prop supplies it; the\n * `<script>` loader uses `window.matterfact.getPageContext` instead (see resolveDeclaredContext).\n */\nexport type PageContextProvider = () =>\n | PageContext\n | null\n | undefined\n | Promise<PageContext | null | undefined>;\n/** The programmatic pull callback, set by `start()`. Read fresh on every publish. */\nlet contextProvider: PageContextProvider | undefined;\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 teardown state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Everything below is module-global bookkeeping so `stop()` (see `start()`, bottom of\n * file) can undo exactly what `start()`/`watchNavigation()` installed \u2014 remove every\n * listener, restore `history` to what it was before we wrapped it, and forget any\n * DOM-walk module we pulled in. All of this outlives a single `EmbedHost`; see\n * `stop()`'s doc comment for why that's the bug this exists to close.\n */\n\n/** The `fire` closure `watchNavigation()` handed to `popstate` \u2014 the only handle we\n * have to remove that listener again. */\nlet navFire: (() => void) | null = null;\n/** The `history.pushState`/`replaceState` this module wrapped, captured so `stop()`\n * can restore them EXACTLY rather than re-wrapping (which is how the old code\n * double-fired navigation on a second `start()`). */\nlet origPushState: History['pushState'] | null = null;\nlet origReplaceState: History['replaceState'] | null = null;\n/** Set once `sendSnapshot`/`sendRegion`/`readFocus` actually pull in the DOM-walk\n * chunk (`./dom/snapshot`) \u2014 never imported eagerly, so `stop()` doesn't pay for a\n * chunk that a host who only ever opted out (and never opened a snapshot) never\n * loaded in the first place. */\nlet snapshotModule: { clearRefs: () => void } | null = null;\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 redaction \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n// redact() now lives in ./redact \u2014 see that file's doc comment. Re-exported\n// above; imported here for local use throughout this module.\n\n/** Anything the host has marked private, or that is inherently sensitive, is out. */\nexport function isPrivate(el: Element): boolean {\n if (el.closest('[data-mf-private]')) return true;\n const tag = el.tagName;\n if (tag === 'INPUT') {\n const t = (el as HTMLInputElement).type;\n if (t === 'password' || t === 'hidden') return true;\n }\n return false;\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 page context \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * What the page says about itself.\n *\n * A host that declares nothing still gets URL + title, which is what every other\n * embeddable assistant on the market offers in total. The interesting fields\n * (`route`, `description`, `entities`) are host-declared, because only the host\n * knows that `/o/8813` is \"the Acme Corp order, 3 items, unpaid\".\n *\n * Declared via a global the host sets before we load:\n * window.matterfact = { context: { route: '/orders/:id', description: '...', entities: [...] } }\n */\n/**\n * matterfact content embedded IN the host page \u2014 today, artifact iframes.\n *\n * A cross-origin iframe is opaque: `contentDocument` throws, so the DOM snapshot walks\n * straight past an embedded artifact and the agent is blind to the very thing the page\n * is built around. It reads the page as empty and asks which URL you mean.\n *\n * We don't need to see inside, and shouldn't want to. The artifact's ID is right there\n * in the src, and the agent can already resolve `artifacts/<id>/` in its session \u2014 the\n * same path an `@`-mention uses. So we report the ID and let the backend fetch the real\n * thing, which beats scraping a rendering of it: it gets the data, not the picture.\n *\n * Matched by ORIGIN, not by path shape: a customer is perfectly entitled to their own\n * /artifacts/ route, and it isn't ours.\n */\n/** The artifact slug from a matterfact artifact path, or null. Matches both the\n * chrome-free embed route (/embed/artifacts/<slug>) and the bare /artifacts/<slug>. */\nexport function artifactIdFromPath(pathname: string): string | null {\n const m = pathname.match(/^\\/(?:embed\\/)?artifacts\\/(.+?)\\/?$/);\n return m ? decodeURIComponent(m[1]) : null;\n}\n\nfunction embeddedMatterfactEntities(): PageEntity[] {\n if (!widgetOrigin) return [];\n const out: PageEntity[] = [];\n for (const frame of Array.from(document.querySelectorAll('iframe'))) {\n let u: URL;\n try {\n u = new URL(frame.getAttribute('src') || '', location.href);\n } catch {\n continue;\n }\n if (u.origin !== widgetOrigin) continue;\n const id = artifactIdFromPath(u.pathname);\n if (!id) continue;\n if (out.some((e) => e.id === id)) continue; // same artifact twice = once\n // No url field: the agent reaches an artifact by ID (`artifacts/<id>/`), never by\n // fetching the page, and an artifact URL can carry a share token we've no business\n // forwarding. The id is the whole useful payload.\n out.push({\n kind: 'artifact',\n id,\n label: redact(frame.getAttribute('title') || '') || id,\n });\n }\n return out;\n}\n\n/**\n * Frames we can see the existence of but nothing inside \u2014 someone else's cross-origin\n * embed. Worth one line: \"there is a thing here I cannot read\" is a true and useful\n * statement, and much better than the agent confidently describing a page while missing\n * the widget the user is actually asking about.\n */\nfunction opaqueFrameCount(): number {\n return Array.from(document.querySelectorAll('iframe')).filter((f) => {\n try {\n const u = new URL(f.getAttribute('src') || '', location.href);\n return u.origin !== location.origin && u.origin !== widgetOrigin;\n } catch {\n return false;\n }\n }).length;\n}\n\n/**\n * Merge the host's DECLARED context with what we auto-detect. Auto-detected fields\n * (url/path/title/locale, co-embedded artifact entities, opaque-frame count) are additive:\n * a declared value wins where they overlap (the `...declared` spread), and found entities\n * append to declared ones.\n */\nexport function buildPageContext(declared: PageContext): PageContext {\n const found = embeddedMatterfactEntities();\n const opaque = opaqueFrameCount();\n\n return {\n // Path only. A query string is where session ids, tokens and email addresses\n // live; it is not ours to take.\n url: location.origin + location.pathname,\n path: location.pathname,\n title: redact(document.title),\n locale: document.documentElement.lang || undefined,\n ...declared,\n // After the spread: what we FOUND is additive to what the host DECLARED, never a\n // replacement. A host that declares its own entities still gets the artifacts we\n // spotted, and vice versa.\n entities: [...(declared.entities ?? []), ...found],\n data: {\n ...(declared.data ?? {}),\n ...(opaque ? { opaque_frames: opaque } : {}),\n },\n };\n}\n\n/** Back-compat: build context from the static `window.matterfact.context` global only (sync). */\nexport function readPageContext(): PageContext {\n return buildPageContext(\n (window as { matterfact?: { context?: PageContext } }).matterfact\n ?.context ?? {},\n );\n}\n\n/**\n * Resolve the host's DECLARED context, preferring a pull callback over the static global so\n * a virtualized SPA can hand us fresh context per turn. First non-null wins:\n * 1. the programmatic `getPageContext` provider (React `<MatterfactAgent getPageContext>`),\n * 2. the `<script>`-loader global `window.matterfact.getPageContext()`,\n * 3. the static `window.matterfact.context`.\n */\nasync function resolveDeclaredContext(): Promise<PageContext> {\n const mf = (\n window as {\n matterfact?: {\n context?: PageContext;\n getPageContext?: PageContextProvider;\n };\n }\n ).matterfact;\n if (contextProvider) {\n const c = await contextProvider();\n if (c) return c;\n }\n if (mf?.getPageContext) {\n const c = await mf.getPageContext();\n if (c) return c;\n }\n // Hoist auto-detection: a framework-shaped context source, below explicit host\n // declarations but above the static global. Degrade-safe (detectHoist swallows).\n const hoist = detectHoist(() => readHoistRuntime());\n if (hoist) return buildHoistContext(hoist);\n return mf?.context ?? {};\n}\n\n/**\n * Publish the current declared+detected context as `host.context`. Async because the pull\n * callback may be (a host might read a store). Rapid calls just re-publish \u2014 for idempotent\n * context, last-writer-wins is fine. No-op when the host opted out of page observation.\n */\nasync function publishContext() {\n if (!pageContextOn()) return;\n const declared = await resolveDeclaredContext();\n send?.({ type: 'host.context', context: buildPageContext(declared) });\n}\n\n/**\n * Answer a `widget.requestContext` (the pull path): publish context AND the site map NOW,\n * so a turn assembled right after carries both as they are \u2014 not as of the last route\n * change. The site map matters here as much as the context: the loader's nav hook fires\n * synchronously during `pushState`, BEFORE a React host has re-rendered with the new\n * route's map, so a nav-time push can be a render stale. Re-publishing at turn-assembly\n * (after the host has settled) is what makes it fresh. No-op when page observation is off.\n */\nexport function provideContext() {\n void publishContext();\n publishSitemap();\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 artifact grants (backend-only) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nexport interface ArtifactGrantSrc {\n id: string;\n owner: string;\n token: string;\n}\n\n/** Read-only capability grants from co-embedded artifact iframes, for the backend to\n * materialize their data. Separate from entities on purpose: the token must never ride\n * ambient (rendered) context, only this backend-only channel. */\nexport function grantsFromIframeSrcs(\n srcs: string[],\n origin: string,\n): ArtifactGrantSrc[] {\n const out: ArtifactGrantSrc[] = [];\n for (const raw of srcs) {\n let u: URL;\n try {\n u = new URL(raw || '', location.href);\n } catch {\n continue;\n }\n if (u.origin !== origin) continue;\n const id = artifactIdFromPath(u.pathname);\n if (!id) continue;\n const owner = u.searchParams.get('owner') || '';\n const token = u.searchParams.get('t') || '';\n if (!owner || !token) continue;\n if (out.some((g) => g.id === id)) continue;\n out.push({ id, owner, token });\n }\n return out;\n}\n\n/**\n * Grants DECLARED by the host \u2014 `window.matterfact.artifacts` (the\n * `<MatterfactAgent artifacts>` prop mirrors onto it). Same wire shape as a scanned\n * iframe grant, so a board is reachable from a route where its iframe isn't mounted\n * WITHOUT hidden zero-size iframes smuggling the token into the DOM. Degrade-safe:\n * anything malformed is skipped, never thrown.\n */\nexport function readDeclaredGrants(): ArtifactGrantSrc[] {\n const declared = (\n window as {\n matterfact?: {\n artifacts?: Array<{ slug?: string; owner?: string; token?: string }>;\n };\n }\n ).matterfact?.artifacts;\n if (!Array.isArray(declared)) return [];\n const out: ArtifactGrantSrc[] = [];\n for (const a of declared) {\n const id = (a?.slug || '').trim();\n const owner = (a?.owner || '').trim();\n const token = (a?.token || '').trim();\n if (!id || !owner || !token) continue;\n if (out.some((g) => g.id === id)) continue;\n out.push({ id, owner, token });\n }\n return out;\n}\n\nfunction readArtifactGrants(): ArtifactGrantSrc[] {\n if (!widgetOrigin) return [];\n const srcs = Array.from(document.querySelectorAll('iframe')).map(\n (f) => f.getAttribute('src') || '',\n );\n const scanned = grantsFromIframeSrcs(srcs, widgetOrigin);\n // A live co-embedded iframe on THIS page wins over a declared grant for the same\n // slug (its token is the one the visible board is actually spending); declared\n // grants fill in the boards that aren't mounted here.\n const out = [...scanned];\n for (const g of readDeclaredGrants()) {\n if (!out.some((s) => s.id === g.id)) out.push(g);\n }\n return out;\n}\n\nfunction publishArtifactGrants() {\n send?.({ type: 'host.artifactGrants', grants: readArtifactGrants() });\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 site map \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The host's DECLARED site map \u2014 its routes, annotated with a content class so the\n * agent knows which carry matterfact content and of what kind. Read from the\n * `window.matterfact.sitemap` global; the React `<MatterfactAgent sitemap>` prop writes\n * it there, symmetric with `context`/`actions`. Classification only \u2014 no per-instance\n * ids, never a capability token (those ride `host.context`/`host.artifactGrants`).\n */\nfunction readSitemap(): SiteMapEntry[] {\n const s = (window as { matterfact?: { sitemap?: SiteMapEntry[] } }).matterfact\n ?.sitemap;\n return Array.isArray(s) ? s : [];\n}\n\nfunction publishSitemap() {\n if (!pageContextOn()) return;\n const sitemap = readSitemap();\n // Omit an empty map rather than send `[]` on every load \u2014 most hosts declare none.\n if (sitemap.length) send?.({ type: 'host.sitemap', sitemap });\n}\n\n/**\n * Navigate the HOST page to one of its OWN routes \u2014 the \"open on page\" deeplink from\n * a co-embedded document's side-panel viewer. The widget is a cross-origin iframe and\n * can't navigate the top window itself, so it asks us (via `widget.navigate`).\n *\n * Guarded to the host's OWN origin: resolve the href against the host location and\n * refuse anything on a different origin or a non-http(s) scheme. The href originates\n * in page context the host itself declared, so this is defense-in-depth \u2014 the widget\n * must never be able to send the host off-site. Lives in this lazy chunk (not the\n * eager loader stub) to stay off the every-page budget.\n */\nexport function navigateHost(href: unknown): void {\n if (typeof href !== 'string' || !href) return;\n let target: URL;\n try {\n target = new URL(href, location.href);\n } catch {\n return;\n }\n if (target.protocol !== 'http:' && target.protocol !== 'https:') return;\n if (target.origin !== location.origin) return;\n location.assign(target.href);\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 activity \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nfunction pushActivity(e: Omit<ActivityEvent, 'seq' | 'ts'>) {\n activity.push({ ...e, seq: ++activitySeq, ts: Date.now() });\n if (activity.length > MAX_ACTIVITY) activity.shift();\n send?.({ type: 'host.activity', events: [activity[activity.length - 1]] });\n}\n\n/**\n * A short, human-readable label for what got clicked.\n *\n * Shaped after PostHog's autocapture, not after a session-replay frame: rrweb would\n * give us `{source:2, type:2, id:417, x:210, y:88}` \u2014 no text, no role, no href,\n * meaningless to a model without the full DOM snapshot it deltas against. One line\n * of \"clicked button 'Export CSV'\" is worth more and costs less.\n */\n/**\n * The accessible NAME of a form control \u2014 never its value.\n *\n * A control has no `innerText`, so the generic path below misses it. We look where a\n * control's name actually lives: `aria-label`, then a `<label for>` or a wrapping\n * `<label>`, then `placeholder`. `placeholder` is a LABEL, not a value \u2014 it is the\n * hint shown when the field is empty (\"Order number or customer\"), so it is safe.\n */\nfunction controlLabel(el: Element): string {\n const aria = el.getAttribute('aria-label');\n if (aria) return aria;\n\n const id = el.id;\n if (id) {\n const forLabel = document.querySelector(`label[for=\"${CSS.escape(id)}\"]`);\n const t = forLabel?.textContent?.trim();\n if (t) return t;\n }\n const wrapping = el.closest('label')?.textContent?.trim();\n if (wrapping) return wrapping;\n\n const placeholder = el.getAttribute('placeholder');\n if (placeholder) return placeholder;\n\n return '';\n}\n\nconst FORM_CONTROLS = new Set(['INPUT', 'SELECT', 'TEXTAREA']);\n\nfunction describe(el: Element): string {\n const role = el.getAttribute('role') || el.tagName.toLowerCase();\n const label =\n el.getAttribute('aria-label') ||\n (FORM_CONTROLS.has(el.tagName)\n ? controlLabel(el)\n : (el as HTMLElement).innerText?.trim().slice(0, 60)) ||\n el.getAttribute('title') ||\n '';\n return label ? `${role} \"${redact(label)}\"` : role;\n}\n\n/**\n * Elements a click is worth recording. Deliberately tight: the point of the activity\n * stream is INTENT (\"the user chose to export\"), and a click on a heading, a label,\n * a card gutter, or blank page is not intent, it is noise. We only log a click that\n * lands on something actionable.\n */\nconst ACTIONABLE =\n 'a[href],button,input,select,textarea,summary,' +\n '[role=\"button\"],[role=\"link\"],[role=\"menuitem\"],[role=\"tab\"],[role=\"option\"],' +\n '[role=\"checkbox\"],[role=\"switch\"],[role=\"radio\"],[onclick],[tabindex]';\n\nfunction onClick(ev: Event) {\n const target = ev.target as Element | null;\n if (!target || !(target instanceof Element)) return;\n\n // Clicking a <label> operates the control it labels \u2014 record THAT, not \"clicked\n // label\", so the event reads as the user's actual intent.\n const label = target.closest('label');\n const labelled = label\n ? (label.getAttribute('for') &&\n document.getElementById(label.getAttribute('for')!)) ||\n label.querySelector('input,select,textarea')\n : null;\n\n const actionable = labelled ?? target.closest(ACTIONABLE);\n // No actionable target \u2014 a click on text, a gutter, or blank space. That is not an\n // action; dropping it is the whole fix for the click-log noise.\n if (!actionable || isPrivate(actionable)) return;\n\n pushActivity({ type: 'click', summary: `clicked ${describe(actionable)}` });\n}\n\nfunction onSubmit(ev: Event) {\n const el = ev.target as Element | null;\n if (!el || isPrivate(el)) return;\n // The FORM was submitted \u2014 never its values.\n pushActivity({ type: 'submit', summary: `submitted ${describe(el)}` });\n}\n\n/**\n * A form field changed.\n *\n * The rule is the same as everywhere else and the temptation here is sharpest:\n * record THAT a field changed and WHICH field (its label), never WHAT it was\n * changed to. `change` fires on exactly the elements whose values are off-limits.\n *\n * One safe exception: a <select>, a checkbox, or a radio chose from a fixed, visible\n * set of options the agent can already see in the snapshot \u2014 \"Unpaid\", \"Shipped\".\n * That is a user *choice*, not typed data, so the chosen option's LABEL is fair to\n * include and is the useful part (\"filtered status to Shipped\"). Free-text and\n * numeric inputs get their label only.\n */\nfunction onChange(ev: Event) {\n const el = ev.target as (HTMLElement & { type?: string }) | null;\n if (!el || !(el instanceof Element) || isPrivate(el)) return;\n\n const tag = el.tagName;\n const type = (el as HTMLInputElement).type;\n\n // Never a password/hidden field, and isPrivate already covered data-mf-private.\n if (tag === 'INPUT' && (type === 'password' || type === 'hidden')) return;\n\n let summary = `changed ${describe(el)}`;\n\n if (tag === 'SELECT') {\n const opt = (el as HTMLSelectElement).selectedOptions[0]?.text;\n if (opt) summary = `${describe(el)} \u2192 \"${redact(opt)}\"`;\n } else if (type === 'checkbox' || type === 'radio') {\n summary = `${(el as HTMLInputElement).checked ? 'checked' : 'unchecked'} ${describe(el)}`;\n }\n\n pushActivity({ type: 'input', summary });\n}\n\n/**\n * SPA navigation. There is no event for `pushState`, so we wrap it \u2014 a 20-line job\n * that no library does better.\n */\nfunction watchNavigation() {\n const fire = () => {\n const url = location.pathname;\n if (url === lastUrl) return;\n lastUrl = url;\n pushActivity({ type: 'nav', summary: `navigated to ${url}` });\n void publishContext();\n publishArtifactGrants();\n // The site map can change without a reload (a virtualized SPA) and `current`\n // moves with the route, so re-publish it on navigation like context/grants.\n publishSitemap();\n // Re-advertise host.tools too (Minor #2): the enum `hoist.navigate` carries is\n // bound to the CURRENT sitemap, and start() only ever advertised it ONCE. A\n // route that gained or lost destinations must not leave the widget holding a\n // stale enum forever. Unlike start()'s one-shot emit (gated on tools.length),\n // this fires even when the result is `[]` \u2014 the whole point is to CLEAR a\n // tool the widget cached from before this navigation, not just to add one.\n publishTools();\n };\n // Captured so stop() can remove exactly this listener, and so history.pushState/\n // replaceState get restored to what they were before we wrapped them \u2014 never\n // re-wrapped on top of an existing wrap (that was the pre-existing bug: a second\n // start() used to wrap the ALREADY-wrapped methods, double-firing every nav).\n navFire = fire;\n\n for (const name of ['pushState', 'replaceState'] as const) {\n const orig = history[name];\n if (name === 'pushState') origPushState = orig as History['pushState'];\n else origReplaceState = orig as History['replaceState'];\n history[name] = function (\n this: History,\n ...args: Parameters<History['pushState']>\n ) {\n const r = orig.apply(this, args);\n fire();\n return r;\n } as History[typeof name];\n }\n window.addEventListener('popstate', fire);\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 focal context \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Where the user's attention is, right now.\n *\n * This is the \"knows what you're doing\" layer, and it is deliberately small so it can\n * ride on every turn \u2014 where the full snapshot cannot. It is also the most sensitive:\n * `selection` is whatever the user highlighted, which could be their own email, so it\n * is redacted and respects data-mf-private like everything else. Focus and the\n * viewport are labels and refs \u2014 never a value.\n *\n * Held so the last-known focus can travel with a turn even between the (throttled)\n * push updates.\n */\nlet lastFocus: FocusContext = {};\n\nasync function readFocus(): Promise<FocusContext> {\n const focus: FocusContext = {};\n\n // Selection \u2014 the single strongest \"this is what I'm asking about\" signal.\n const sel = window.getSelection?.();\n if (sel && !sel.isCollapsed) {\n const anchor = sel.anchorNode?.parentElement ?? null;\n // Don't lift a selection out of a private region, and cap it \u2014 a user can select\n // the whole page.\n if (!anchor || !anchor.closest('[data-mf-private]')) {\n const text = sel.toString().trim().slice(0, 500);\n if (text) focus.selection = redact(text);\n }\n }\n\n // The control they're working in \u2014 its label, never its contents.\n const active = document.activeElement;\n if (\n active &&\n active !== document.body &&\n !isPrivate(active) &&\n !active.closest('[data-mf-private]')\n ) {\n const { snapshot } = await loadSnapshotModule();\n void snapshot; // ensure the chunk that owns refFor is loaded before we describe\n focus.focused = {\n label: redact(describeControl(active)),\n role: active.getAttribute('role') || active.tagName.toLowerCase(),\n };\n }\n\n const doc = document.documentElement;\n const scrollable = doc.scrollHeight - doc.clientHeight;\n focus.scroll =\n scrollable > 0 ? Math.round((doc.scrollTop / scrollable) * 100) / 100 : 0;\n\n return focus;\n}\n\n/** A label for whatever is focused, reusing the same value-blind rules as activity. */\nfunction describeControl(el: Element): string {\n return describe(el);\n}\n\n/** The one place any of the three call sites below reach into the DOM-walk chunk \u2014\n * so `stop()` has a single `snapshotModule` to check without importing anything\n * itself (see the teardown-state block above). */\nasync function loadSnapshotModule() {\n const m = await import('./dom/snapshot');\n snapshotModule = m;\n return m;\n}\n\nlet focusTimer: ReturnType<typeof setTimeout> | null = null;\n\n/** Coalesce a burst of selection/focus/scroll events into one push. */\nfunction scheduleFocus() {\n if (focusTimer) return;\n focusTimer = setTimeout(async () => {\n focusTimer = null;\n lastFocus = await readFocus();\n send?.({ type: 'host.focus', focus: lastFocus });\n }, 250);\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 snapshot \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\nlet snapshotSeq = 0;\n\nexport async function sendSnapshot(emit: Send) {\n // Auto observation only \u2014 `declared` keeps getPageContext but skips DOM crawl.\n if (!allowsAuto(effectivePageContextMode())) return;\n\n // Hoist-first: on an XH Hoist SPA, the live models are a richer and cheaper source\n // of truth than scraping role-less div soup. detectHoist() is degrade-safe (never\n // throws here), so an absent/broken window.XH falls straight through to the\n // generic a11y walk below, unchanged.\n const hoist = detectHoist(() => readHoistRuntime());\n if (hoist) {\n const { rows } = readHoistConfig(\n typeof window !== 'undefined' ? window : undefined,\n );\n const { yaml, truncated } = renderHoistSnapshot(hoist, rows);\n emit({\n type: 'host.snapshot',\n snapshot: { yaml: redact(yaml), seq: ++snapshotSeq, truncated },\n });\n // Refs are out of scope for Layer 1 (they arrive with the interactive channel in\n // Layer 3) \u2014 a Hoist snapshot never mints [ref=eN] handles, so nothing is visible\n // by ref.\n lastFocus = { ...lastFocus, visibleRefs: [] };\n emit({ type: 'host.focus', focus: lastFocus });\n return;\n }\n\n // The a11y walk is itself lazily imported: a host that only ever declares\n // PageContext and never lets the agent look at the page never downloads it.\n const { snapshot } = await loadSnapshotModule();\n const { yaml, truncated, visibleRefs } = snapshot();\n emit({\n type: 'host.snapshot',\n snapshot: { yaml: redact(yaml), seq: ++snapshotSeq, truncated },\n });\n // The viewport slice rides with the focus context so the agent can tell the few\n // things on screen from the whole tree it just received.\n lastFocus = { ...lastFocus, visibleRefs };\n emit({ type: 'host.focus', focus: lastFocus });\n}\n\n/**\n * Zoom in on one ref \u2014 the pull half of the model. The agent asks; we resolve the ref\n * to a live element and return just its sub-tree.\n */\nexport async function sendRegion(ref: string, emit: Send) {\n // Auto observation only (same gate as sendSnapshot).\n if (!allowsAuto(effectivePageContextMode())) return;\n const { snapshotRegion, resolveRef } = await loadSnapshotModule();\n const el = resolveRef(ref);\n if (!el) {\n emit({\n type: 'host.region',\n ref,\n yaml: '(this element is no longer on the page)',\n });\n return;\n }\n const { yaml } = snapshotRegion(el);\n emit({ type: 'host.region', ref, yaml: redact(yaml) });\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * Tools the page's ADAPTER (today: Hoist) exposes to the agent, and the sole\n * execution path for calling one.\n *\n * The page's content is untrusted \u2014 text on it can try to instruct the agent \u2014 and\n * the moment the agent can act, a bad answer becomes a bad ACTION. Several things\n * hold that line, and all of them live HERE (in the page, where we control what\n * actually happens), not in the widget, which can be lied to:\n *\n * - a tool is only ever ADVERTISED (`advertiseTools`) when the HOST opted in via\n * `window.matterfact.hoist.actions` \u2014 default 'off';\n * - host tools are independent of page-context mode (admin host-tool allowlist);\n * - `executeHostTool` (adapters/hoist-runtime.ts) RE-CHECKS the host's current\n * action policy AND re-validates the destination against the LIVE page state,\n * on every call \u2014 never trusting what the widget claims was advertised, or\n * that the policy it was advertised UNDER still holds. A tool not marked\n * `readOnly` also carries a `confirm` policy the widget must gate on \u2014 see\n * HostTool's doc comment in protocol.ts.\n */\nexport async function callTool(call: ToolCall, emit: Send) {\n const win = typeof window !== 'undefined' ? window : undefined;\n const cls = toolClass(call.name);\n const startedAt = Date.now();\n emitToolEvent(win, {\n phase: 'call',\n name: call.name,\n toolClass: cls,\n args: call.args,\n });\n const r = await execute(call, win);\n emitToolEvent(win, {\n phase: 'result',\n name: call.name,\n toolClass: cls,\n ok: r.ok,\n error: r.error,\n ms: Date.now() - startedAt,\n });\n emit({\n type: 'host.toolResult',\n callId: call.callId,\n ok: r.ok,\n result: r.result,\n error: r.error,\n });\n}\n\n/* \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 stop / start \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/**\n * The opposite number of `start()` \u2014 remove every listener it (or `watchNavigation`)\n * installed, restore `history.pushState`/`replaceState` to what they were before we\n * wrapped them, and forget the module-level `send`/`activity`/focus state. Nothing\n * here is a filter over what gets sent afterward \u2014 there is simply nothing left\n * installed to send anything.\n *\n * Why this has to exist at all: everything `start()` installs is MODULE-GLOBAL, and\n * this module outlives any single `EmbedHost`. React remounts `EmbedHost` whenever\n * ANY of its identity-defining props change (react.tsx's effect deps: publishableKey,\n * widgetOrigin, surface, theme, inline, pageContext, dev) \u2014 including just a theme\n * swap, not only a deliberate opt-out. Before this fix, a remount's `start()` call\n * only ever ADDED listeners; the previous mount's were still attached and kept firing\n * into the module `send`, which the new `start()` had just repointed at the NEW\n * widget. Net effect: open once with pageContext on, then remount for any reason\n * (including `pageContext: false`) and the new widget silently keeps receiving\n * clicks/nav/focus collected by the old mount's still-live listeners.\n *\n * Called from two places: the top of `start()` (idempotency \u2014 a second `start()`\n * never doubles up, which also fixes the pre-existing double history-wrap /\n * double-`fire()`-per-navigation bug), and `EmbedHost.destroy()` in loader.ts (a\n * plain unmount with no remount still has to stop, not just wait for a `start()`\n * that may never come).\n */\nexport function stop(): void {\n document.removeEventListener('click', onClick, { capture: true });\n document.removeEventListener('submit', onSubmit, { capture: true });\n document.removeEventListener('change', onChange, { capture: true });\n document.removeEventListener('selectionchange', scheduleFocus);\n document.removeEventListener('focusin', scheduleFocus, { capture: true });\n window.removeEventListener('scroll', scheduleFocus, { capture: true });\n\n if (navFire) {\n window.removeEventListener('popstate', navFire);\n navFire = null;\n }\n // Restore, don't re-wrap: this is what stops a repeated start() from wrapping an\n // already-wrapped pushState/replaceState (the old double-fire-per-nav bug).\n if (origPushState) {\n history.pushState = origPushState;\n origPushState = null;\n }\n if (origReplaceState) {\n history.replaceState = origReplaceState;\n origReplaceState = null;\n }\n\n if (focusTimer) {\n clearTimeout(focusTimer);\n focusTimer = null;\n }\n\n send = null;\n contextProvider = undefined;\n activity.length = 0;\n lastFocus = {};\n widgetOrigin = '';\n\n // Belt-and-suspenders alongside sendRegion's own pageContextOn check (see above):\n // an old ref minted while observation was on must not stay resolvable afterward.\n // Only touches the DOM-walk chunk if it was ever actually loaded \u2014 see\n // loadSnapshotModule's doc comment.\n snapshotModule?.clearRefs();\n}\n\n/**\n * Admin max from bootstrap \u2014 clamps effective mode without requiring a remount.\n * Host request (from `start`) is unchanged; effective = min(admin, host).\n */\nexport function setPageContextMax(max: unknown): void {\n adminPageContextMax = parsePageContextMode(max);\n}\n\n/**\n * @param pageContext Observation mode. Default `full` (`true`). `declared` keeps\n * getPageContext / host sitemap; `off`/`false` disables all page context.\n * Auto DOM/focus/activity requires `full`.\n */\nexport function start(\n emit: Send,\n origin?: string,\n pageContext: boolean | PageContextMode = true,\n provider?: PageContextProvider,\n) {\n // Idempotent: undo whatever a PREVIOUS start() installed before this one installs\n // anything. Without this, a remount (see stop()'s doc comment) leaves the old\n // mount's listeners live, writing into the `send` this call is about to reassign.\n stop();\n\n send = emit;\n widgetOrigin = origin || '';\n lastUrl = location.pathname;\n hostPageContextMode = parsePageContextMode(pageContext);\n contextProvider = provider;\n\n if (allowsDeclared(effectivePageContextMode())) {\n void publishContext();\n publishArtifactGrants();\n publishSitemap();\n watchNavigation();\n\n if (allowsAuto(effectivePageContextMode())) {\n // Passive + capture: we observe, we never interfere with the host's own handling.\n document.addEventListener('click', onClick, {\n capture: true,\n passive: true,\n });\n document.addEventListener('submit', onSubmit, {\n capture: true,\n passive: true,\n });\n // `change` fires on blur/commit for text inputs and immediately for select/\n // checkbox/radio \u2014 not on every keystroke, which is what we want: a settled\n // choice, not a stream of partial values.\n document.addEventListener('change', onChange, {\n capture: true,\n passive: true,\n });\n\n // Focal context: what the user is attending to. Coalesced (scheduleFocus), because\n // selectionchange and scroll fire in torrents.\n document.addEventListener('selectionchange', scheduleFocus, {\n passive: true,\n });\n document.addEventListener('focusin', scheduleFocus, {\n capture: true,\n passive: true,\n });\n window.addEventListener('scroll', scheduleFocus, {\n capture: true,\n passive: true,\n });\n }\n }\n\n const theme = matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n emit({ type: 'host.theme', mode: theme });\n\n // Host tools are independent of page-context mode (admin allowlist + host actions).\n {\n const w = typeof window !== 'undefined' ? window : undefined;\n const tools = advertise(w);\n if (tools.length) {\n emit({ type: 'host.tools', tools });\n for (const t of tools) {\n emitToolEvent(w, {\n phase: 'advertise',\n name: t.name,\n toolClass: toolClass(t.name),\n });\n }\n }\n }\n}\n\n/** Advertise the merged tool list on the wire and fire the host's onToolEvent so its\n * telemetry (and the dev panel) sees the current set. Shared by start()'s first emit's\n * navigation re-advertisement; fires even on `[]` to CLEAR a tool cached before a nav. */\nfunction publishTools() {\n const win = typeof window !== 'undefined' ? window : undefined;\n const tools = advertise(win);\n send?.({ type: 'host.tools', tools });\n for (const t of tools) {\n emitToolEvent(win, {\n phase: 'advertise',\n name: t.name,\n toolClass: toolClass(t.name),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAIA,IAAMA,EAAwC,CAC5C,IAAK,EACL,SAAU,EACV,KAAM,CACR,EAGO,SAASC,EAAqBC,EAAiC,CACpE,GAAI,OAAOA,GAAU,UAAW,OAAOA,EAAQ,OAAS,MACxD,GAAIA,GAAS,KAAM,MAAO,OAC1B,IAAMC,EAAI,OAAOD,CAAK,EAAE,KAAK,EAAE,YAAY,EAC3C,OAAIC,IAAM,QAAUA,IAAM,YAAcA,IAAM,MAAcA,EACxDA,IAAM,QAAUA,IAAM,MAAQA,IAAM,KAAOA,IAAM,MAAc,OAC/DA,IAAM,SAAWA,IAAM,KAAOA,IAAM,KAAa,MAC9C,MACT,CAGO,SAASC,EACdC,EACAC,EACiB,CACjB,OAAON,EAAKK,CAAQ,GAAKL,EAAKM,CAAW,EAAID,EAAWC,CAC1D,CAEO,SAASC,EAAeC,EAAgC,CAC7D,OAAOA,IAAS,KAClB,CAEO,SAASC,EAAWD,EAAgC,CACzD,OAAOA,IAAS,MAClB,CC1BA,IAAME,GAAM,CACV,kCACA,0BACA,iCACA,cACA,6DACA,qDACA,gCACF,EASO,SAASC,EAAOC,EAAsB,CAC3C,IAAIC,EAAMD,EACV,QAAWE,KAAMJ,GAAKG,EAAMA,EAAI,QAAQC,EAAI,YAAY,EACxD,OAAOD,CACT,CC2CO,SAASE,EACdC,EACqB,CACrB,IAAIC,EACJ,GAAI,CACFA,EAAKD,EAAK,CACZ,MAAQ,CACN,OAAO,IACT,CACA,OAAKC,IAEH,CAAC,CAACA,EAAG,MAAM,MACXA,EAAG,MAAM,OAAS,GAClBA,EAAG,OAAO,OAAS,GACnBA,EAAG,IAAI,OAAS,GACEA,EANJ,IAOlB,CAUA,SAASC,EAAMC,EAAWC,EAAM,IAAa,CAC3C,IAAMC,EAAQC,EAAOH,EAAE,QAAQ,OAAQ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G,EAAUvG,EAAE,IAAI,CAC7B,CAAC,CAEL",
|
|
6
|
+
"names": ["RANK", "parsePageContextMode", "value", "s", "clampPageContextMode", "adminMax", "hostRequest", "allowsDeclared", "mode", "allowsAuto", "PII", "redact", "text", "out", "re", "detectHoist", "read", "rt", "quote", "s", "max", "clean", "redact", "cell", "value", "pushRow", "row", "cols", "out", "pad", "c", "renderGrid", "grid", "rowCap", "depth", "r", "shown", "seriesSummary", "name", "data", "min", "n", "last", "renderChart", "chart", "renderNav", "groups", "g", "d", "mark", "flattenDestinations", "buildNavigateTool", "policy", "destinations", "bySection", "buildHoistContext", "selected", "bits", "renderHoistSnapshot", "truncated", "readHoistConfig", "win", "cfg", "ex", "getModelsByClass", "XH", "name", "models", "className", "m", "modelId", "headerOf", "c", "collectHeaders", "cols", "prefix", "out", "children", "id", "readColumns", "g", "leaves", "headers", "field", "readRow", "rec", "row", "readGrid", "columns", "records", "r", "hasContent", "readChart", "series", "s", "d", "n", "humanize", "seg", "childrenOf", "node", "k", "routeIndex", "params", "router", "root", "walk", "path", "readSitemap", "excluded", "origin", "currentName", "routes", "groups", "tc", "tabs", "activeTabId", "items", "companyScoped", "t", "redact", "ticker", "label", "readHoistRuntime", "excludeModels", "rs", "readActionsConfig", "navigate", "advertiseTools", "rt", "buildNavigateTool", "executeHostTool", "call", "destination", "item", "flattenDestinations", "e", "MAX_TOOLS", "HOST_HANDLER_TIMEOUT_MS", "mfGlobal", "win", "toolClass", "name", "emitEvent", "cb", "emitToolEvent", "mfTools", "document", "artifact", "out", "APP_NAME_RE", "appName", "appTools", "defs", "d", "raw", "advertise", "merged", "seen", "push", "tools", "t", "advertiseTools", "timeout", "ms", "_", "reject", "redactResult", "value", "redact", "execute", "call", "cls", "executeHostTool", "handler", "resolveHandler", "result", "e", "mf", "widgetOrigin", "MAX_ACTIVITY", "send", "activitySeq", "activity", "lastUrl", "hostPageContextMode", "adminPageContextMax", "effectivePageContextMode", "clampPageContextMode", "pageContextOn", "allowsDeclared", "contextProvider", "navFire", "origPushState", "origReplaceState", "snapshotModule", "isPrivate", "el", "t", "artifactIdFromPath", "pathname", "m", "embeddedMatterfactEntities", "out", "frame", "u", "id", "e", "redact", "opaqueFrameCount", "f", "buildPageContext", "declared", "found", "opaque", "readPageContext", "resolveDeclaredContext", "mf", "c", "hoist", "detectHoist", "readHoistRuntime", "buildHoistContext", "publishContext", "provideContext", "publishSitemap", "grantsFromIframeSrcs", "srcs", "origin", "raw", "owner", "token", "g", "readDeclaredGrants", "a", "readArtifactGrants", "s", "publishArtifactGrants", "readSitemap", "sitemap", "navigateHost", "href", "target", "pushActivity", "controlLabel", "aria", "wrapping", "placeholder", "FORM_CONTROLS", "describe", "role", "label", "ACTIONABLE", "onClick", "ev", "actionable", "onSubmit", "onChange", "tag", "type", "summary", "opt", "watchNavigation", "fire", "url", "publishTools", "name", "orig", "args", "lastFocus", "readFocus", "focus", "sel", "anchor", "text", "active", "snapshot", "loadSnapshotModule", "describeControl", "doc", "scrollable", "focusTimer", "scheduleFocus", "snapshotSeq", "sendSnapshot", "emit", "allowsAuto", "rows", "readHoistConfig", "yaml", "truncated", "renderHoistSnapshot", "visibleRefs", "sendRegion", "ref", "snapshotRegion", "resolveRef", "callTool", "call", "win", "cls", "toolClass", "startedAt", "emitToolEvent", "r", "execute", "stop", "setPageContextMax", "max", "parsePageContextMode", "start", "pageContext", "provider", "theme", "w", "tools", "advertise"]
|
|
7
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as re,b as P}from"./chunk-Y7I25VHL.js";var Be=Object.prototype.toString;function ie(e){return typeof e=="function"||Be.call(e)==="[object Function]"}function Fe(e){var t=Number(e);return isNaN(t)?0:t===0||!isFinite(t)?t:(t>0?1:-1)*Math.floor(Math.abs(t))}var Ke=Math.pow(2,53)-1;function ze(e){var t=Fe(e);return Math.min(Math.max(t,0),Ke)}function b(e,t){var n=Array,r=Object(e);if(e==null)throw new TypeError("Array.from requires an array-like object - not null or undefined");if(typeof t<"u"&&!ie(t))throw new TypeError("Array.from: when provided, the second argument must be a function");for(var a=ze(r.length),o=ie(n)?Object(new n(a)):new Array(a),l=0,u;l<a;)u=r[l],t?o[l]=t(u,l):o[l]=u,l+=1;return o.length=a,o}function D(e){"@babel/helpers - typeof";return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(e)}function Ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,oe(r.key),r)}}function Qe(e,t,n){return t&&ae(e.prototype,t),n&&ae(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Je(e,t,n){return t=oe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oe(e){var t=Ze(e,"string");return D(t)=="symbol"?t:t+""}function Ze(e,t){if(D(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(D(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var et=(function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];Ye(this,e),Je(this,"items",void 0),this.items=t}return Qe(e,[{key:"add",value:function(n){return this.has(n)===!1&&this.items.push(n),this}},{key:"clear",value:function(){this.items=[]}},{key:"delete",value:function(n){var r=this.items.length;return this.items=this.items.filter(function(a){return a!==n}),r!==this.items.length}},{key:"forEach",value:function(n){var r=this;this.items.forEach(function(a){n(a,a,r)})}},{key:"has",value:function(n){return this.items.indexOf(n)!==-1}},{key:"size",get:function(){return this.items.length}}])})(),le=typeof Set>"u"?Set:et;function d(e){var t;return(t=e.localName)!==null&&t!==void 0?t:e.tagName.toLowerCase()}var tt={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",form:"form",footer:"contentinfo",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",header:"banner",hr:"separator",html:"document",legend:"legend",li:"listitem",math:"math",main:"main",menu:"list",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",progress:"progressbar",section:"region",summary:"button",table:"table",tbody:"rowgroup",textarea:"textbox",tfoot:"rowgroup",td:"cell",th:"columnheader",thead:"rowgroup",tr:"row",ul:"list"},nt={caption:new Set(["aria-label","aria-labelledby"]),code:new Set(["aria-label","aria-labelledby"]),deletion:new Set(["aria-label","aria-labelledby"]),emphasis:new Set(["aria-label","aria-labelledby"]),generic:new Set(["aria-label","aria-labelledby","aria-roledescription"]),insertion:new Set(["aria-label","aria-labelledby"]),none:new Set(["aria-label","aria-labelledby"]),paragraph:new Set(["aria-label","aria-labelledby"]),presentation:new Set(["aria-label","aria-labelledby"]),strong:new Set(["aria-label","aria-labelledby"]),subscript:new Set(["aria-label","aria-labelledby"]),superscript:new Set(["aria-label","aria-labelledby"])};function rt(e,t){return["aria-atomic","aria-busy","aria-controls","aria-current","aria-description","aria-describedby","aria-details","aria-dropeffect","aria-flowto","aria-grabbed","aria-hidden","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"].some(function(n){var r;return e.hasAttribute(n)&&!((r=nt[t])!==null&&r!==void 0&&r.has(n))})}function ue(e,t){return rt(e,t)}function C(e){var t=at(e);if(t===null||_.indexOf(t)!==-1){var n=it(e);if(_.indexOf(t||"")===-1||ue(e,n||""))return n}return t}function it(e){var t=tt[d(e)];if(t!==void 0)return t;switch(d(e)){case"a":case"area":case"link":if(e.hasAttribute("href"))return"link";break;case"img":return e.getAttribute("alt")===""&&!ue(e,"img")?"presentation":"img";case"input":{var n=e,r=n.type;switch(r){case"button":case"image":case"reset":case"submit":return"button";case"checkbox":case"radio":return r;case"range":return"slider";case"email":case"tel":case"text":case"url":return e.hasAttribute("list")?"combobox":"textbox";case"search":return e.hasAttribute("list")?"combobox":"searchbox";case"number":return"spinbutton";default:return null}}case"select":return e.hasAttribute("multiple")||e.size>1?"listbox":"combobox"}return null}function at(e){var t=e.getAttribute("role");if(t!==null){var n=t.trim().split(" ")[0];if(n.length>0)return n}return null}var _=["presentation","none"];function s(e){return e!==null&&e.nodeType===e.ELEMENT_NODE}function B(e){return s(e)&&d(e)==="caption"}function H(e){return s(e)&&d(e)==="input"}function se(e){return s(e)&&d(e)==="optgroup"}function fe(e){return s(e)&&d(e)==="select"}function ce(e){return s(e)&&d(e)==="table"}function de(e){return s(e)&&d(e)==="textarea"}function me(e){var t=e.ownerDocument===null?e:e.ownerDocument,n=t.defaultView;if(n===null)throw new TypeError("no window available");return n}function pe(e){return s(e)&&d(e)==="fieldset"}function be(e){return s(e)&&d(e)==="legend"}function ge(e){return s(e)&&d(e)==="slot"}function ot(e){return s(e)&&e.ownerSVGElement!==void 0}function he(e){return s(e)&&d(e)==="svg"}function ye(e){return ot(e)&&d(e)==="title"}function $(e,t){if(s(e)&&e.hasAttribute(t)){var n=e.getAttribute(t).split(" "),r=e.getRootNode?e.getRootNode():e.ownerDocument;return n.map(function(a){return r.getElementById(a)}).filter(function(a){return a!==null})}return[]}function g(e,t){return s(e)?t.indexOf(C(e))!==-1:!1}function lt(e){return e.trim().replace(/\s\s+/g," ")}function ut(e,t){if(!s(e))return!1;if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!0;var n=t(e);return n.getPropertyValue("display")==="none"||n.getPropertyValue("visibility")==="hidden"}function st(e){return g(e,["button","combobox","listbox","textbox"])||Ee(e,"range")}function Ee(e,t){if(!s(e))return!1;switch(t){case"range":return g(e,["meter","progressbar","scrollbar","slider","spinbutton"]);default:throw new TypeError("No knowledge about abstract role '".concat(t,"'. This is likely a bug :("))}}function ve(e,t){var n=b(e.querySelectorAll(t));return $(e,"aria-owns").forEach(function(r){n.push.apply(n,b(r.querySelectorAll(t)))}),n}function ft(e){return fe(e)?e.selectedOptions||ve(e,"[selected]"):ve(e,'[aria-selected="true"]')}function ct(e){return g(e,_)}function dt(e){return B(e)}function mt(e){return g(e,["button","cell","checkbox","columnheader","gridcell","heading","label","legend","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"])}function pt(e){return!1}function bt(e){return H(e)||de(e)?e.value:e.textContent||""}function Se(e){var t=e.getPropertyValue("content");return/^["'].*["']$/.test(t)?t.slice(1,-1):""}function xe(e){var t=d(e);return t==="button"||t==="input"&&e.getAttribute("type")!=="hidden"||t==="meter"||t==="output"||t==="progress"||t==="select"||t==="textarea"}function Ae(e){if(xe(e))return e;var t=null;return e.childNodes.forEach(function(n){if(t===null&&s(n)){var r=Ae(n);r!==null&&(t=r)}}),t}function gt(e){if(e.control!==void 0)return e.control;var t=e.getAttribute("for");return t!==null?e.ownerDocument.getElementById(t):Ae(e)}function ht(e){var t=e.labels;if(t===null)return t;if(t!==void 0)return b(t);if(!xe(e))return null;var n=e.ownerDocument;return b(n.querySelectorAll("label")).filter(function(r){return gt(r)===e})}function yt(e){var t=e.assignedNodes();return t.length===0?b(e.childNodes):t}function F(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=new le,r=typeof Map>"u"?void 0:new Map,a=me(e),o=t.compute,l=o===void 0?"name":o,u=t.computedStyleSupportsPseudoElements,m=u===void 0?t.getComputedStyle!==void 0:u,p=t.getComputedStyle,x=p===void 0?a.getComputedStyle.bind(a):p,M=t.hidden,R=M===void 0?!1:M,I=function(f,c){if(c!==void 0)throw new Error("use uncachedGetComputedStyle directly for pseudo elements");if(r===void 0)return x(f);var h=r.get(f);if(h)return h;var y=x(f,c);return r.set(f,y),y};function W(i,f){var c="";if(s(i)&&m){var h=x(i,"::before"),y=Se(h);c="".concat(y," ").concat(c)}var S=ge(i)?yt(i):b(i.childNodes).concat($(i,"aria-owns"));if(S.forEach(function(v){var N=A(v,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0}),E=s(v)?I(v).getPropertyValue("display"):"inline",k=E!=="inline"?" ":"";c+="".concat(k).concat(N).concat(k)}),s(i)&&m){var T=x(i,"::after"),w=Se(T);c="".concat(c," ").concat(w)}return c.trim()}function O(i,f){var c=i.getAttributeNode(f);return c!==null&&!n.has(c)&&c.value.trim()!==""?(n.add(c),c.value):null}function Ue(i){return s(i)?O(i,"title"):null}function Xe(i){if(!s(i))return null;if(pe(i)){n.add(i);for(var f=b(i.childNodes),c=0;c<f.length;c+=1){var h=f[c];if(be(h))return A(h,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(ce(i)){n.add(i);for(var y=b(i.childNodes),S=0;S<y.length;S+=1){var T=y[S];if(B(T))return A(T,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(he(i)){n.add(i);for(var w=b(i.childNodes),v=0;v<w.length;v+=1){var N=w[v];if(ye(N))return N.textContent}return null}else if(d(i)==="img"||d(i)==="area"){var E=O(i,"alt");if(E!==null)return E}else if(se(i)){var k=O(i,"label");if(k!==null)return k}if(H(i)&&(i.type==="button"||i.type==="submit"||i.type==="reset")){var Z=O(i,"value");if(Z!==null)return Z;if(i.type==="submit")return"Submit";if(i.type==="reset")return"Reset"}var U=ht(i);if(U!==null&&U.length!==0)return n.add(i),b(U).map(function(X){return A(X,{isEmbeddedInLabel:!0,isReferenced:!1,recursion:!0})}).filter(function(X){return X.length>0}).join(" ");if(H(i)&&i.type==="image"){var ee=O(i,"alt");if(ee!==null)return ee;var te=O(i,"title");return te!==null?te:"Submit Query"}if(g(i,["button"])){var ne=W(i,{isEmbeddedInLabel:!1,isReferenced:!1});if(ne!=="")return ne}return null}function A(i,f){if(n.has(i))return"";if(!R&&ut(i,I)&&!f.isReferenced)return n.add(i),"";var c=s(i)?i.getAttributeNode("aria-labelledby"):null,h=c!==null&&!n.has(c)?$(i,"aria-labelledby"):[];if(l==="name"&&!f.isReferenced&&h.length>0)return n.add(c),h.map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!0,recursion:!1})}).join(" ");var y=f.recursion&&st(i)&&l==="name";if(!y){var S=(s(i)&&i.getAttribute("aria-label")||"").trim();if(S!==""&&l==="name")return n.add(i),S;if(!ct(i)){var T=Xe(i);if(T!==null)return n.add(i),T}}if(g(i,["menu"]))return n.add(i),"";if(y||f.isEmbeddedInLabel||f.isReferenced){if(g(i,["combobox","listbox"])){n.add(i);var w=ft(i);return w.length===0?H(i)?i.value:"":b(w).map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0})}).join(" ")}if(Ee(i,"range"))return n.add(i),i.hasAttribute("aria-valuetext")?i.getAttribute("aria-valuetext"):i.hasAttribute("aria-valuenow")?i.getAttribute("aria-valuenow"):i.getAttribute("value")||"";if(g(i,["textbox"]))return n.add(i),bt(i)}if(mt(i)||s(i)&&f.isReferenced||dt(i)||pt(i)){var v=W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});if(v!=="")return n.add(i),v}if(i.nodeType===i.TEXT_NODE)return n.add(i),i.textContent||"";if(f.recursion)return n.add(i),W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});var N=Ue(i);return N!==null?(n.add(i),N):(n.add(i),"")}return lt(A(e,{isEmbeddedInLabel:!1,isReferenced:l==="description",recursion:!1}))}function vt(e){return g(e,["caption","code","deletion","emphasis","generic","insertion","none","paragraph","presentation","strong","subscript","superscript"])}function K(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vt(e)?"":F(e,t)}function Te(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r,o=n.isSubtreeInaccessible,l=o===void 0?St:o;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");if(a(e).visibility==="hidden")return!0;for(var u=e;u;){if(l(u,{getComputedStyle:a}))return!0;u=u.parentElement}return!1}function St(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");return e.hidden===!0||e.getAttribute("aria-hidden")==="true"||a(e).display==="none"}var Et=new Set(["button","fieldset","input","optgroup","option","select","textarea"]);function V(e){var t=d(e);return Et.has(t)&&e.hasAttribute("disabled")?!0:e.getAttribute("aria-disabled")==="true"}function Ne(){let e=new WeakMap;return((t,n)=>{if(n)return window.getComputedStyle(t,n);let r=e.get(t);return r||(r=window.getComputedStyle(t),e.set(t,r)),r})}function Le(){return document.documentElement.getClientRects().length>0}function Re(e,t,n){let r=t.display;if(r==="none")return!1;let a=t.visibility;if(a==="hidden"||a==="collapse"||Number(t.opacity)===0)return!1;if(n&&r!=="contents"){let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0||e.getClientRects().length===0||o.right<-2e3||o.bottom<-2e3)return!1}return!0}function Oe(e){return e.pointerEvents!=="none"}var xt=new Set(["button","checkbox","combobox","link","listbox","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]),At=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY"]);function G(e){let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function Ce(e,t,n,r){let a=e.tagName;if(a==="A"&&e.hasAttribute("href")||At.has(a)||t!==null&&xt.has(t))return!0;let o=e.getAttribute("tabindex");return!!(o!==null&&Number(o)>=0||G(e)||n.cursor==="pointer"&&r?.cursor!=="pointer")}var Me=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"]),Tt=new Set(["textbox","searchbox","spinbutton"]),wt=new Set(["INPUT","TEXTAREA"]);function Ie(e){return wt.has(e.tagName)||G(e)}function Nt(e,t){let n=e.tagName;return n==="INPUT"||n==="TEXTAREA"?Tt.has(t)?(e.value??"").length>0:!1:G(e)?(e.textContent??"").trim().length>0:!1}function we(e,t){let n=e.getAttribute(t);return n==="true"?"true":n==="mixed"?"mixed":null}function ke(e,t){let n=[],r=e.tagName;if(r==="INPUT"&&(t==="checkbox"||t==="radio"))e.checked&&n.push("[checked]");else{let l=we(e,"aria-checked");l==="mixed"?n.push("[checked=mixed]"):l==="true"&&n.push("[checked]")}V(e)&&n.push("[disabled]");let a=e.getAttribute("aria-expanded");if(a==="true"||a==="false")a==="true"&&n.push("[expanded]");else if(r==="SUMMARY"){let l=e.parentElement;l?.tagName==="DETAILS"&&l.open&&n.push("[expanded]")}if(t==="heading"){let l=e.getAttribute("aria-level"),u=Number(l||r[1]);Number.isFinite(u)&&u>0&&n.push(`[level=${u}]`)}let o=we(e,"aria-pressed");return o==="mixed"?n.push("[pressed=mixed]"):o==="true"&&n.push("[pressed]"),e.getAttribute("aria-selected")==="true"&&n.push("[selected]"),Nt(e,t)&&n.push("[filled]"),n.join(" ")}function Pe(e){return G(e)?"textbox":C(e)}var z='input,textarea,select,[contenteditable=""],[contenteditable="true"],[aria-valuetext],[data-mf-private]';function Lt(e){let t=e.getAttribute("aria-labelledby");if(t){for(let n of t.split(/\s+/)){if(!n)continue;let r=e.ownerDocument.getElementById(n);if(r&&(r.matches(z)||r.querySelector(z)))return!0}return!1}return e.hasAttribute("aria-label")?!1:e.querySelector(z)!==null}function De(e,t){let n=K(e,{getComputedStyle:t,computedStyleSupportsPseudoElements:!1});return n?Lt(e)?e.getAttribute("aria-label")||"":n:""}var Rt=0,q=0,Y=new WeakMap,j=new Map;function _e(){q++,j.clear()}function He(e,t,n){let r=`${t} ${n}`,a=Y.get(e);return!a||a.key!==r?(a={id:`e${++Rt}`,key:r,gen:q},Y.set(e,a)):a.gen=q,j.set(a.id,e),a.id}function Ot(e){let t=j.get(e);if(!t)return null;if(!t.isConnected)return j.delete(e),null;let n=Y.get(t);return!n||n.id!==e||n.gen!==q?null:t}function Ct(){j.clear()}var Mt=4e3,It=800,kt=120,Pt=120,Ge=25,$e=new Set(["generic","presentation","none"]),Dt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","LINK","META","BASE"]);function L(e){return e.nodes>=Mt||e.lines>=It?(e.truncated=!0,!1):!0}function _t(e){return e.id==="matterfact-embed"||e.hasAttribute("data-mf-embed")}function Ht(e,t,n){return e.getAttribute("aria-hidden")==="true"||e.hasAttribute("hidden")||e.hasAttribute("inert")?!0:!Re(e,t,n)}function $t(e){if(e.shadowRoot)return e.shadowRoot.childNodes;if(e.tagName==="SLOT"){let t=e.assignedNodes({flatten:!0});if(t.length)return t}return e.childNodes}function Q(e,t,n,r){let a=$t(e);for(let o=0;o<a.length;o++){let l=a[o];l&&Wt(l,t,n,r)}}function Vt(e,t,n){let r=(e.nodeValue??"").replace(/\s+/g," ").trim();r&&(Me.has(t.role)||L(n)&&(n.lines++,t.children.push(r)))}function J(e){let t=e.matches(":disabled")||V(e);return{role:"option",name:(e.label||e.textContent||"").trim(),props:(t?" [disabled]":"")+(e.selected?" [selected]":""),children:[]}}function jt(e,t,n){let r=e.options,a=Math.min(r.length,Ge);for(let m=0;m<a;m++){if(!L(n))return;let p=r[m];!p||P(p)||(n.lines++,t.children.push(J(p)))}let o=0,l=e.selectedOptions;for(let m=0;m<l.length;m++){let p=l[m];if(p&&p.index>=a&&!P(p)){if(!L(n))return;n.lines++,t.children.push(J(p)),o++}}let u=r.length-a-o;u>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${u} more options)`))}function Gt(e,t,n){let r=e.list;if(!r)return;let a=r.options,o=Math.min(a.length,Ge);for(let u=0;u<o;u++){if(!L(n))return;let m=a[u];!m||P(m)||(n.lines++,t.children.push(J(m)))}let l=a.length-o;l>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${l} more options)`))}function qt(e,t,n,r){if(!L(r)||Dt.has(e.tagName)||_t(e)||P(e))return;r.nodes++;let a=r.styleOf(e);if(Ht(e,a,r.layout))return;let o=Pe(e),l=o===null||$e.has(o),u=Ce(e,o,a,n);if(l&&!u){Q(e,t,a,r);return}let m=o===null||$e.has(o)?"generic":o,p=De(e,r.styleOf),x="";if(u&&Oe(a)){let I=He(e,m,p);x=` [ref=${I}]`,r.onRef?.(I,e)}let M=ke(e,m),R={role:m,name:p,props:(M?` ${M}`:"")+x,children:[]};if(r.lines++,t.children.push(R),e.tagName==="SELECT"){jt(e,R,r);return}e.tagName==="INPUT"&&e.list&&Gt(e,R,r),!Ie(e)&&Q(e,R,a,r)}function Wt(e,t,n,r){e.nodeType===3?Vt(e,t,r):e.nodeType===1&&qt(e,t,n,r)}function Ve(e,t){let n=e.replace(/\s+/g," ").trim(),r=re(n);return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function je(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function qe(e,t,n){let r=" ".repeat(t);for(let a of e){if(typeof a=="string"){n.push(`${r}- text: ${je(Ve(a,Pt))}`);continue}let o=a.name?` ${je(Ve(a.name,kt))}`:"",l=`${r}- ${a.role}${o}${a.props}`;a.children.length?(n.push(`${l}:`),qe(a.children,t+1,n)):n.push(l)}}function We(e,t){let n=Ne(),r={styleOf:n,layout:Le(),nodes:0,lines:0,truncated:!1,onRef:t};if(Te(e,{getComputedStyle:n}))return{yaml:"",truncated:!1};let a={role:"",name:"",props:"",children:[]};Q(e,a,n(e),r);let o=[];return qe(a.children,0,o),r.truncated&&o.length&&(o[o.length-1]='- text: "\u2026 (snapshot truncated \u2014 more of the page is below)"'),{yaml:o.join(`
|
|
1
|
+
import{a as re,b as P}from"./chunk-SR4ZNUAN.js";var Be=Object.prototype.toString;function ie(e){return typeof e=="function"||Be.call(e)==="[object Function]"}function Fe(e){var t=Number(e);return isNaN(t)?0:t===0||!isFinite(t)?t:(t>0?1:-1)*Math.floor(Math.abs(t))}var Ke=Math.pow(2,53)-1;function ze(e){var t=Fe(e);return Math.min(Math.max(t,0),Ke)}function b(e,t){var n=Array,r=Object(e);if(e==null)throw new TypeError("Array.from requires an array-like object - not null or undefined");if(typeof t<"u"&&!ie(t))throw new TypeError("Array.from: when provided, the second argument must be a function");for(var a=ze(r.length),o=ie(n)?Object(new n(a)):new Array(a),l=0,u;l<a;)u=r[l],t?o[l]=t(u,l):o[l]=u,l+=1;return o.length=a,o}function D(e){"@babel/helpers - typeof";return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(e)}function Ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,oe(r.key),r)}}function Qe(e,t,n){return t&&ae(e.prototype,t),n&&ae(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Je(e,t,n){return t=oe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oe(e){var t=Ze(e,"string");return D(t)=="symbol"?t:t+""}function Ze(e,t){if(D(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(D(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var et=(function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];Ye(this,e),Je(this,"items",void 0),this.items=t}return Qe(e,[{key:"add",value:function(n){return this.has(n)===!1&&this.items.push(n),this}},{key:"clear",value:function(){this.items=[]}},{key:"delete",value:function(n){var r=this.items.length;return this.items=this.items.filter(function(a){return a!==n}),r!==this.items.length}},{key:"forEach",value:function(n){var r=this;this.items.forEach(function(a){n(a,a,r)})}},{key:"has",value:function(n){return this.items.indexOf(n)!==-1}},{key:"size",get:function(){return this.items.length}}])})(),le=typeof Set>"u"?Set:et;function d(e){var t;return(t=e.localName)!==null&&t!==void 0?t:e.tagName.toLowerCase()}var tt={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",form:"form",footer:"contentinfo",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",header:"banner",hr:"separator",html:"document",legend:"legend",li:"listitem",math:"math",main:"main",menu:"list",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",progress:"progressbar",section:"region",summary:"button",table:"table",tbody:"rowgroup",textarea:"textbox",tfoot:"rowgroup",td:"cell",th:"columnheader",thead:"rowgroup",tr:"row",ul:"list"},nt={caption:new Set(["aria-label","aria-labelledby"]),code:new Set(["aria-label","aria-labelledby"]),deletion:new Set(["aria-label","aria-labelledby"]),emphasis:new Set(["aria-label","aria-labelledby"]),generic:new Set(["aria-label","aria-labelledby","aria-roledescription"]),insertion:new Set(["aria-label","aria-labelledby"]),none:new Set(["aria-label","aria-labelledby"]),paragraph:new Set(["aria-label","aria-labelledby"]),presentation:new Set(["aria-label","aria-labelledby"]),strong:new Set(["aria-label","aria-labelledby"]),subscript:new Set(["aria-label","aria-labelledby"]),superscript:new Set(["aria-label","aria-labelledby"])};function rt(e,t){return["aria-atomic","aria-busy","aria-controls","aria-current","aria-description","aria-describedby","aria-details","aria-dropeffect","aria-flowto","aria-grabbed","aria-hidden","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"].some(function(n){var r;return e.hasAttribute(n)&&!((r=nt[t])!==null&&r!==void 0&&r.has(n))})}function ue(e,t){return rt(e,t)}function C(e){var t=at(e);if(t===null||_.indexOf(t)!==-1){var n=it(e);if(_.indexOf(t||"")===-1||ue(e,n||""))return n}return t}function it(e){var t=tt[d(e)];if(t!==void 0)return t;switch(d(e)){case"a":case"area":case"link":if(e.hasAttribute("href"))return"link";break;case"img":return e.getAttribute("alt")===""&&!ue(e,"img")?"presentation":"img";case"input":{var n=e,r=n.type;switch(r){case"button":case"image":case"reset":case"submit":return"button";case"checkbox":case"radio":return r;case"range":return"slider";case"email":case"tel":case"text":case"url":return e.hasAttribute("list")?"combobox":"textbox";case"search":return e.hasAttribute("list")?"combobox":"searchbox";case"number":return"spinbutton";default:return null}}case"select":return e.hasAttribute("multiple")||e.size>1?"listbox":"combobox"}return null}function at(e){var t=e.getAttribute("role");if(t!==null){var n=t.trim().split(" ")[0];if(n.length>0)return n}return null}var _=["presentation","none"];function s(e){return e!==null&&e.nodeType===e.ELEMENT_NODE}function B(e){return s(e)&&d(e)==="caption"}function H(e){return s(e)&&d(e)==="input"}function se(e){return s(e)&&d(e)==="optgroup"}function fe(e){return s(e)&&d(e)==="select"}function ce(e){return s(e)&&d(e)==="table"}function de(e){return s(e)&&d(e)==="textarea"}function me(e){var t=e.ownerDocument===null?e:e.ownerDocument,n=t.defaultView;if(n===null)throw new TypeError("no window available");return n}function pe(e){return s(e)&&d(e)==="fieldset"}function be(e){return s(e)&&d(e)==="legend"}function ge(e){return s(e)&&d(e)==="slot"}function ot(e){return s(e)&&e.ownerSVGElement!==void 0}function he(e){return s(e)&&d(e)==="svg"}function ye(e){return ot(e)&&d(e)==="title"}function $(e,t){if(s(e)&&e.hasAttribute(t)){var n=e.getAttribute(t).split(" "),r=e.getRootNode?e.getRootNode():e.ownerDocument;return n.map(function(a){return r.getElementById(a)}).filter(function(a){return a!==null})}return[]}function g(e,t){return s(e)?t.indexOf(C(e))!==-1:!1}function lt(e){return e.trim().replace(/\s\s+/g," ")}function ut(e,t){if(!s(e))return!1;if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!0;var n=t(e);return n.getPropertyValue("display")==="none"||n.getPropertyValue("visibility")==="hidden"}function st(e){return g(e,["button","combobox","listbox","textbox"])||Ee(e,"range")}function Ee(e,t){if(!s(e))return!1;switch(t){case"range":return g(e,["meter","progressbar","scrollbar","slider","spinbutton"]);default:throw new TypeError("No knowledge about abstract role '".concat(t,"'. This is likely a bug :("))}}function ve(e,t){var n=b(e.querySelectorAll(t));return $(e,"aria-owns").forEach(function(r){n.push.apply(n,b(r.querySelectorAll(t)))}),n}function ft(e){return fe(e)?e.selectedOptions||ve(e,"[selected]"):ve(e,'[aria-selected="true"]')}function ct(e){return g(e,_)}function dt(e){return B(e)}function mt(e){return g(e,["button","cell","checkbox","columnheader","gridcell","heading","label","legend","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"])}function pt(e){return!1}function bt(e){return H(e)||de(e)?e.value:e.textContent||""}function Se(e){var t=e.getPropertyValue("content");return/^["'].*["']$/.test(t)?t.slice(1,-1):""}function xe(e){var t=d(e);return t==="button"||t==="input"&&e.getAttribute("type")!=="hidden"||t==="meter"||t==="output"||t==="progress"||t==="select"||t==="textarea"}function Ae(e){if(xe(e))return e;var t=null;return e.childNodes.forEach(function(n){if(t===null&&s(n)){var r=Ae(n);r!==null&&(t=r)}}),t}function gt(e){if(e.control!==void 0)return e.control;var t=e.getAttribute("for");return t!==null?e.ownerDocument.getElementById(t):Ae(e)}function ht(e){var t=e.labels;if(t===null)return t;if(t!==void 0)return b(t);if(!xe(e))return null;var n=e.ownerDocument;return b(n.querySelectorAll("label")).filter(function(r){return gt(r)===e})}function yt(e){var t=e.assignedNodes();return t.length===0?b(e.childNodes):t}function F(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=new le,r=typeof Map>"u"?void 0:new Map,a=me(e),o=t.compute,l=o===void 0?"name":o,u=t.computedStyleSupportsPseudoElements,m=u===void 0?t.getComputedStyle!==void 0:u,p=t.getComputedStyle,x=p===void 0?a.getComputedStyle.bind(a):p,M=t.hidden,R=M===void 0?!1:M,I=function(f,c){if(c!==void 0)throw new Error("use uncachedGetComputedStyle directly for pseudo elements");if(r===void 0)return x(f);var h=r.get(f);if(h)return h;var y=x(f,c);return r.set(f,y),y};function W(i,f){var c="";if(s(i)&&m){var h=x(i,"::before"),y=Se(h);c="".concat(y," ").concat(c)}var S=ge(i)?yt(i):b(i.childNodes).concat($(i,"aria-owns"));if(S.forEach(function(v){var N=A(v,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0}),E=s(v)?I(v).getPropertyValue("display"):"inline",k=E!=="inline"?" ":"";c+="".concat(k).concat(N).concat(k)}),s(i)&&m){var T=x(i,"::after"),w=Se(T);c="".concat(c," ").concat(w)}return c.trim()}function O(i,f){var c=i.getAttributeNode(f);return c!==null&&!n.has(c)&&c.value.trim()!==""?(n.add(c),c.value):null}function Ue(i){return s(i)?O(i,"title"):null}function Xe(i){if(!s(i))return null;if(pe(i)){n.add(i);for(var f=b(i.childNodes),c=0;c<f.length;c+=1){var h=f[c];if(be(h))return A(h,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(ce(i)){n.add(i);for(var y=b(i.childNodes),S=0;S<y.length;S+=1){var T=y[S];if(B(T))return A(T,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(he(i)){n.add(i);for(var w=b(i.childNodes),v=0;v<w.length;v+=1){var N=w[v];if(ye(N))return N.textContent}return null}else if(d(i)==="img"||d(i)==="area"){var E=O(i,"alt");if(E!==null)return E}else if(se(i)){var k=O(i,"label");if(k!==null)return k}if(H(i)&&(i.type==="button"||i.type==="submit"||i.type==="reset")){var Z=O(i,"value");if(Z!==null)return Z;if(i.type==="submit")return"Submit";if(i.type==="reset")return"Reset"}var U=ht(i);if(U!==null&&U.length!==0)return n.add(i),b(U).map(function(X){return A(X,{isEmbeddedInLabel:!0,isReferenced:!1,recursion:!0})}).filter(function(X){return X.length>0}).join(" ");if(H(i)&&i.type==="image"){var ee=O(i,"alt");if(ee!==null)return ee;var te=O(i,"title");return te!==null?te:"Submit Query"}if(g(i,["button"])){var ne=W(i,{isEmbeddedInLabel:!1,isReferenced:!1});if(ne!=="")return ne}return null}function A(i,f){if(n.has(i))return"";if(!R&&ut(i,I)&&!f.isReferenced)return n.add(i),"";var c=s(i)?i.getAttributeNode("aria-labelledby"):null,h=c!==null&&!n.has(c)?$(i,"aria-labelledby"):[];if(l==="name"&&!f.isReferenced&&h.length>0)return n.add(c),h.map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!0,recursion:!1})}).join(" ");var y=f.recursion&&st(i)&&l==="name";if(!y){var S=(s(i)&&i.getAttribute("aria-label")||"").trim();if(S!==""&&l==="name")return n.add(i),S;if(!ct(i)){var T=Xe(i);if(T!==null)return n.add(i),T}}if(g(i,["menu"]))return n.add(i),"";if(y||f.isEmbeddedInLabel||f.isReferenced){if(g(i,["combobox","listbox"])){n.add(i);var w=ft(i);return w.length===0?H(i)?i.value:"":b(w).map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0})}).join(" ")}if(Ee(i,"range"))return n.add(i),i.hasAttribute("aria-valuetext")?i.getAttribute("aria-valuetext"):i.hasAttribute("aria-valuenow")?i.getAttribute("aria-valuenow"):i.getAttribute("value")||"";if(g(i,["textbox"]))return n.add(i),bt(i)}if(mt(i)||s(i)&&f.isReferenced||dt(i)||pt(i)){var v=W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});if(v!=="")return n.add(i),v}if(i.nodeType===i.TEXT_NODE)return n.add(i),i.textContent||"";if(f.recursion)return n.add(i),W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});var N=Ue(i);return N!==null?(n.add(i),N):(n.add(i),"")}return lt(A(e,{isEmbeddedInLabel:!1,isReferenced:l==="description",recursion:!1}))}function vt(e){return g(e,["caption","code","deletion","emphasis","generic","insertion","none","paragraph","presentation","strong","subscript","superscript"])}function K(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vt(e)?"":F(e,t)}function Te(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r,o=n.isSubtreeInaccessible,l=o===void 0?St:o;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");if(a(e).visibility==="hidden")return!0;for(var u=e;u;){if(l(u,{getComputedStyle:a}))return!0;u=u.parentElement}return!1}function St(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");return e.hidden===!0||e.getAttribute("aria-hidden")==="true"||a(e).display==="none"}var Et=new Set(["button","fieldset","input","optgroup","option","select","textarea"]);function V(e){var t=d(e);return Et.has(t)&&e.hasAttribute("disabled")?!0:e.getAttribute("aria-disabled")==="true"}function Ne(){let e=new WeakMap;return((t,n)=>{if(n)return window.getComputedStyle(t,n);let r=e.get(t);return r||(r=window.getComputedStyle(t),e.set(t,r)),r})}function Le(){return document.documentElement.getClientRects().length>0}function Re(e,t,n){let r=t.display;if(r==="none")return!1;let a=t.visibility;if(a==="hidden"||a==="collapse"||Number(t.opacity)===0)return!1;if(n&&r!=="contents"){let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0||e.getClientRects().length===0||o.right<-2e3||o.bottom<-2e3)return!1}return!0}function Oe(e){return e.pointerEvents!=="none"}var xt=new Set(["button","checkbox","combobox","link","listbox","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]),At=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY"]);function G(e){let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function Ce(e,t,n,r){let a=e.tagName;if(a==="A"&&e.hasAttribute("href")||At.has(a)||t!==null&&xt.has(t))return!0;let o=e.getAttribute("tabindex");return!!(o!==null&&Number(o)>=0||G(e)||n.cursor==="pointer"&&r?.cursor!=="pointer")}var Me=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"]),Tt=new Set(["textbox","searchbox","spinbutton"]),wt=new Set(["INPUT","TEXTAREA"]);function Ie(e){return wt.has(e.tagName)||G(e)}function Nt(e,t){let n=e.tagName;return n==="INPUT"||n==="TEXTAREA"?Tt.has(t)?(e.value??"").length>0:!1:G(e)?(e.textContent??"").trim().length>0:!1}function we(e,t){let n=e.getAttribute(t);return n==="true"?"true":n==="mixed"?"mixed":null}function ke(e,t){let n=[],r=e.tagName;if(r==="INPUT"&&(t==="checkbox"||t==="radio"))e.checked&&n.push("[checked]");else{let l=we(e,"aria-checked");l==="mixed"?n.push("[checked=mixed]"):l==="true"&&n.push("[checked]")}V(e)&&n.push("[disabled]");let a=e.getAttribute("aria-expanded");if(a==="true"||a==="false")a==="true"&&n.push("[expanded]");else if(r==="SUMMARY"){let l=e.parentElement;l?.tagName==="DETAILS"&&l.open&&n.push("[expanded]")}if(t==="heading"){let l=e.getAttribute("aria-level"),u=Number(l||r[1]);Number.isFinite(u)&&u>0&&n.push(`[level=${u}]`)}let o=we(e,"aria-pressed");return o==="mixed"?n.push("[pressed=mixed]"):o==="true"&&n.push("[pressed]"),e.getAttribute("aria-selected")==="true"&&n.push("[selected]"),Nt(e,t)&&n.push("[filled]"),n.join(" ")}function Pe(e){return G(e)?"textbox":C(e)}var z='input,textarea,select,[contenteditable=""],[contenteditable="true"],[aria-valuetext],[data-mf-private]';function Lt(e){let t=e.getAttribute("aria-labelledby");if(t){for(let n of t.split(/\s+/)){if(!n)continue;let r=e.ownerDocument.getElementById(n);if(r&&(r.matches(z)||r.querySelector(z)))return!0}return!1}return e.hasAttribute("aria-label")?!1:e.querySelector(z)!==null}function De(e,t){let n=K(e,{getComputedStyle:t,computedStyleSupportsPseudoElements:!1});return n?Lt(e)?e.getAttribute("aria-label")||"":n:""}var Rt=0,q=0,Y=new WeakMap,j=new Map;function _e(){q++,j.clear()}function He(e,t,n){let r=`${t} ${n}`,a=Y.get(e);return!a||a.key!==r?(a={id:`e${++Rt}`,key:r,gen:q},Y.set(e,a)):a.gen=q,j.set(a.id,e),a.id}function Ot(e){let t=j.get(e);if(!t)return null;if(!t.isConnected)return j.delete(e),null;let n=Y.get(t);return!n||n.id!==e||n.gen!==q?null:t}function Ct(){j.clear()}var Mt=4e3,It=800,kt=120,Pt=120,Ge=25,$e=new Set(["generic","presentation","none"]),Dt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","LINK","META","BASE"]);function L(e){return e.nodes>=Mt||e.lines>=It?(e.truncated=!0,!1):!0}function _t(e){return e.id==="matterfact-embed"||e.hasAttribute("data-mf-embed")}function Ht(e,t,n){return e.getAttribute("aria-hidden")==="true"||e.hasAttribute("hidden")||e.hasAttribute("inert")?!0:!Re(e,t,n)}function $t(e){if(e.shadowRoot)return e.shadowRoot.childNodes;if(e.tagName==="SLOT"){let t=e.assignedNodes({flatten:!0});if(t.length)return t}return e.childNodes}function Q(e,t,n,r){let a=$t(e);for(let o=0;o<a.length;o++){let l=a[o];l&&Wt(l,t,n,r)}}function Vt(e,t,n){let r=(e.nodeValue??"").replace(/\s+/g," ").trim();r&&(Me.has(t.role)||L(n)&&(n.lines++,t.children.push(r)))}function J(e){let t=e.matches(":disabled")||V(e);return{role:"option",name:(e.label||e.textContent||"").trim(),props:(t?" [disabled]":"")+(e.selected?" [selected]":""),children:[]}}function jt(e,t,n){let r=e.options,a=Math.min(r.length,Ge);for(let m=0;m<a;m++){if(!L(n))return;let p=r[m];!p||P(p)||(n.lines++,t.children.push(J(p)))}let o=0,l=e.selectedOptions;for(let m=0;m<l.length;m++){let p=l[m];if(p&&p.index>=a&&!P(p)){if(!L(n))return;n.lines++,t.children.push(J(p)),o++}}let u=r.length-a-o;u>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${u} more options)`))}function Gt(e,t,n){let r=e.list;if(!r)return;let a=r.options,o=Math.min(a.length,Ge);for(let u=0;u<o;u++){if(!L(n))return;let m=a[u];!m||P(m)||(n.lines++,t.children.push(J(m)))}let l=a.length-o;l>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${l} more options)`))}function qt(e,t,n,r){if(!L(r)||Dt.has(e.tagName)||_t(e)||P(e))return;r.nodes++;let a=r.styleOf(e);if(Ht(e,a,r.layout))return;let o=Pe(e),l=o===null||$e.has(o),u=Ce(e,o,a,n);if(l&&!u){Q(e,t,a,r);return}let m=o===null||$e.has(o)?"generic":o,p=De(e,r.styleOf),x="";if(u&&Oe(a)){let I=He(e,m,p);x=` [ref=${I}]`,r.onRef?.(I,e)}let M=ke(e,m),R={role:m,name:p,props:(M?` ${M}`:"")+x,children:[]};if(r.lines++,t.children.push(R),e.tagName==="SELECT"){jt(e,R,r);return}e.tagName==="INPUT"&&e.list&&Gt(e,R,r),!Ie(e)&&Q(e,R,a,r)}function Wt(e,t,n,r){e.nodeType===3?Vt(e,t,r):e.nodeType===1&&qt(e,t,n,r)}function Ve(e,t){let n=e.replace(/\s+/g," ").trim(),r=re(n);return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function je(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function qe(e,t,n){let r=" ".repeat(t);for(let a of e){if(typeof a=="string"){n.push(`${r}- text: ${je(Ve(a,Pt))}`);continue}let o=a.name?` ${je(Ve(a.name,kt))}`:"",l=`${r}- ${a.role}${o}${a.props}`;a.children.length?(n.push(`${l}:`),qe(a.children,t+1,n)):n.push(l)}}function We(e,t){let n=Ne(),r={styleOf:n,layout:Le(),nodes:0,lines:0,truncated:!1,onRef:t};if(Te(e,{getComputedStyle:n}))return{yaml:"",truncated:!1};let a={role:"",name:"",props:"",children:[]};Q(e,a,n(e),r);let o=[];return qe(a.children,0,o),r.truncated&&o.length&&(o[o.length-1]='- text: "\u2026 (snapshot truncated \u2014 more of the page is below)"'),{yaml:o.join(`
|
|
2
2
|
`),truncated:r.truncated}}function wn(){let e=document.body;if(!e)return{yaml:"",truncated:!1,visibleRefs:[]};_e();let t=[],n=window.innerHeight||0,r=window.innerWidth||0;return{...We(e,(o,l)=>{let u=l.getBoundingClientRect();u.bottom>0&&u.top<n&&u.right>0&&u.left<r&&t.push(o)}),visibleRefs:t}}function Nn(e){return e.isConnected?We(e):{yaml:"",truncated:!1}}export{Ct as clearRefs,Ot as resolveRef,wn as snapshot,Nn as snapshotRegion};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-WAUSVV7Y.js.map
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
// src/pageContextMode.ts
|
|
2
|
+
var RANK = {
|
|
3
|
+
off: 0,
|
|
4
|
+
declared: 1,
|
|
5
|
+
full: 2
|
|
6
|
+
};
|
|
7
|
+
function parsePageContextMode(value) {
|
|
8
|
+
if (typeof value === "boolean") return value ? "full" : "off";
|
|
9
|
+
if (value == null) return "full";
|
|
10
|
+
const s = String(value).trim().toLowerCase();
|
|
11
|
+
if (s === "full" || s === "declared" || s === "off") return s;
|
|
12
|
+
if (s === "true" || s === "on" || s === "1" || s === "yes") return "full";
|
|
13
|
+
if (s === "false" || s === "0" || s === "no") return "off";
|
|
14
|
+
return "full";
|
|
15
|
+
}
|
|
16
|
+
function clampPageContextMode(adminMax, hostRequest) {
|
|
17
|
+
return RANK[adminMax] <= RANK[hostRequest] ? adminMax : hostRequest;
|
|
18
|
+
}
|
|
19
|
+
function allowsDeclared(mode) {
|
|
20
|
+
return mode !== "off";
|
|
21
|
+
}
|
|
22
|
+
function allowsAuto(mode) {
|
|
23
|
+
return mode === "full";
|
|
24
|
+
}
|
|
25
|
+
|
|
1
26
|
// src/redact.ts
|
|
2
27
|
var PII = [
|
|
3
28
|
/\b[\w.+-]+@[\w-]+\.[\w.]{2,}\b/g,
|
|
@@ -532,7 +557,14 @@ var send = null;
|
|
|
532
557
|
var activitySeq = 0;
|
|
533
558
|
var activity = [];
|
|
534
559
|
var lastUrl = "";
|
|
535
|
-
var
|
|
560
|
+
var hostPageContextMode = "full";
|
|
561
|
+
var adminPageContextMax = "full";
|
|
562
|
+
function effectivePageContextMode() {
|
|
563
|
+
return clampPageContextMode(adminPageContextMax, hostPageContextMode);
|
|
564
|
+
}
|
|
565
|
+
function pageContextOn() {
|
|
566
|
+
return allowsDeclared(effectivePageContextMode());
|
|
567
|
+
}
|
|
536
568
|
var contextProvider;
|
|
537
569
|
var navFire = null;
|
|
538
570
|
var origPushState = null;
|
|
@@ -624,7 +656,7 @@ async function resolveDeclaredContext() {
|
|
|
624
656
|
return mf?.context ?? {};
|
|
625
657
|
}
|
|
626
658
|
async function publishContext() {
|
|
627
|
-
if (!pageContextOn) return;
|
|
659
|
+
if (!pageContextOn()) return;
|
|
628
660
|
const declared = await resolveDeclaredContext();
|
|
629
661
|
send?.({ type: "host.context", context: buildPageContext(declared) });
|
|
630
662
|
}
|
|
@@ -686,7 +718,7 @@ function readSitemap2() {
|
|
|
686
718
|
return Array.isArray(s) ? s : [];
|
|
687
719
|
}
|
|
688
720
|
function publishSitemap() {
|
|
689
|
-
if (!pageContextOn) return;
|
|
721
|
+
if (!pageContextOn()) return;
|
|
690
722
|
const sitemap = readSitemap2();
|
|
691
723
|
if (sitemap.length) send?.({ type: "host.sitemap", sitemap });
|
|
692
724
|
}
|
|
@@ -810,7 +842,7 @@ function describeControl(el) {
|
|
|
810
842
|
return describe(el);
|
|
811
843
|
}
|
|
812
844
|
async function loadSnapshotModule() {
|
|
813
|
-
const m = await import('./snapshot-
|
|
845
|
+
const m = await import('./snapshot-X6FPP3HF.js');
|
|
814
846
|
snapshotModule = m;
|
|
815
847
|
return m;
|
|
816
848
|
}
|
|
@@ -825,7 +857,7 @@ function scheduleFocus() {
|
|
|
825
857
|
}
|
|
826
858
|
var snapshotSeq = 0;
|
|
827
859
|
async function sendSnapshot(emit) {
|
|
828
|
-
if (!
|
|
860
|
+
if (!allowsAuto(effectivePageContextMode())) return;
|
|
829
861
|
const hoist = detectHoist(() => readHoistRuntime());
|
|
830
862
|
if (hoist) {
|
|
831
863
|
const { rows } = readHoistConfig(
|
|
@@ -850,7 +882,7 @@ async function sendSnapshot(emit) {
|
|
|
850
882
|
emit({ type: "host.focus", focus: lastFocus });
|
|
851
883
|
}
|
|
852
884
|
async function sendRegion(ref, emit) {
|
|
853
|
-
if (!
|
|
885
|
+
if (!allowsAuto(effectivePageContextMode())) return;
|
|
854
886
|
const { snapshotRegion, resolveRef } = await loadSnapshotModule();
|
|
855
887
|
const el = resolveRef(ref);
|
|
856
888
|
if (!el) {
|
|
@@ -865,15 +897,6 @@ async function sendRegion(ref, emit) {
|
|
|
865
897
|
emit({ type: "host.region", ref, yaml: redact(yaml) });
|
|
866
898
|
}
|
|
867
899
|
async function callTool(call, emit) {
|
|
868
|
-
if (!pageContextOn) {
|
|
869
|
-
emit({
|
|
870
|
-
type: "host.toolResult",
|
|
871
|
-
callId: call.callId,
|
|
872
|
-
ok: false,
|
|
873
|
-
error: "host tools are disabled"
|
|
874
|
-
});
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
900
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
878
901
|
const cls = toolClass(call.name);
|
|
879
902
|
const startedAt = Date.now();
|
|
@@ -930,45 +953,50 @@ function stop() {
|
|
|
930
953
|
widgetOrigin = "";
|
|
931
954
|
snapshotModule?.clearRefs();
|
|
932
955
|
}
|
|
956
|
+
function setPageContextMax(max) {
|
|
957
|
+
adminPageContextMax = parsePageContextMode(max);
|
|
958
|
+
}
|
|
933
959
|
function start(emit, origin, pageContext = true, provider) {
|
|
934
960
|
stop();
|
|
935
961
|
send = emit;
|
|
936
962
|
widgetOrigin = origin || "";
|
|
937
963
|
lastUrl = location.pathname;
|
|
938
|
-
|
|
964
|
+
hostPageContextMode = parsePageContextMode(pageContext);
|
|
939
965
|
contextProvider = provider;
|
|
940
|
-
if (
|
|
966
|
+
if (allowsDeclared(effectivePageContextMode())) {
|
|
941
967
|
void publishContext();
|
|
942
968
|
publishArtifactGrants();
|
|
943
969
|
publishSitemap();
|
|
944
970
|
watchNavigation();
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
971
|
+
if (allowsAuto(effectivePageContextMode())) {
|
|
972
|
+
document.addEventListener("click", onClick, {
|
|
973
|
+
capture: true,
|
|
974
|
+
passive: true
|
|
975
|
+
});
|
|
976
|
+
document.addEventListener("submit", onSubmit, {
|
|
977
|
+
capture: true,
|
|
978
|
+
passive: true
|
|
979
|
+
});
|
|
980
|
+
document.addEventListener("change", onChange, {
|
|
981
|
+
capture: true,
|
|
982
|
+
passive: true
|
|
983
|
+
});
|
|
984
|
+
document.addEventListener("selectionchange", scheduleFocus, {
|
|
985
|
+
passive: true
|
|
986
|
+
});
|
|
987
|
+
document.addEventListener("focusin", scheduleFocus, {
|
|
988
|
+
capture: true,
|
|
989
|
+
passive: true
|
|
990
|
+
});
|
|
991
|
+
window.addEventListener("scroll", scheduleFocus, {
|
|
992
|
+
capture: true,
|
|
993
|
+
passive: true
|
|
994
|
+
});
|
|
995
|
+
}
|
|
968
996
|
}
|
|
969
997
|
const theme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
970
998
|
emit({ type: "host.theme", mode: theme });
|
|
971
|
-
|
|
999
|
+
{
|
|
972
1000
|
const w = typeof window !== "undefined" ? window : void 0;
|
|
973
1001
|
const tools = advertise(w);
|
|
974
1002
|
if (tools.length) {
|
|
@@ -996,6 +1024,6 @@ function publishTools() {
|
|
|
996
1024
|
}
|
|
997
1025
|
}
|
|
998
1026
|
|
|
999
|
-
export { artifactIdFromPath, buildPageContext, callTool, grantsFromIframeSrcs, isPrivate, navigateHost, provideContext, readDeclaredGrants, readPageContext, redact, sendRegion, sendSnapshot, start, stop };
|
|
1000
|
-
//# sourceMappingURL=chunk-
|
|
1001
|
-
//# sourceMappingURL=chunk-
|
|
1027
|
+
export { artifactIdFromPath, buildPageContext, callTool, grantsFromIframeSrcs, isPrivate, navigateHost, provideContext, readDeclaredGrants, readPageContext, redact, sendRegion, sendSnapshot, setPageContextMax, start, stop };
|
|
1028
|
+
//# sourceMappingURL=chunk-ZXMJWCQV.js.map
|
|
1029
|
+
//# sourceMappingURL=chunk-ZXMJWCQV.js.map
|