@matterfact/embed 0.2.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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions for
125
+ use, reproduction, or distribution of Your modifications, or for any
126
+ such Derivative Works as a whole, provided Your use, reproduction,
127
+ and distribution of the Work otherwise complies with the conditions
128
+ stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed
144
+ to in writing, Licensor provides the Work (and each Contributor
145
+ provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
146
+ OR CONDITIONS OF ANY KIND, either express or implied, including,
147
+ without limitation, any warranties or conditions of TITLE,
148
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
149
+ PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Matterfact, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @matterfact/embed
2
+
3
+ Drop-in loader for the matterfact assistant. See `examples/` for usage; the
4
+ CDN stub is built from `src/embed.ts`.
5
+
6
+ ## Microphone / dictation
7
+
8
+ The widget's composer supports voice dictation. The loader grants the iframe
9
+ `allow="microphone"`, so the browser will prompt inside the widget as usual.
10
+
11
+ One caveat for host pages: if your site sends a `Permissions-Policy` response
12
+ header that denies `microphone`, the browser blocks the widget's mic access
13
+ too and the composer shows "Microphone access denied". Allow the feature (or
14
+ omit it from the header) to enable dictation, e.g.
15
+ `Permissions-Policy: microphone=(self "https://app.matterfact.com")`.
16
+
17
+ Note: changes to the loader (including this grant) reach host pages only when
18
+ the package is rebuilt and the CDN copy republished.
@@ -0,0 +1,300 @@
1
+ "use client";
2
+
3
+ // src/context.ts
4
+ var widgetOrigin = "";
5
+ var MAX_ACTIVITY = 40;
6
+ var send = null;
7
+ var activitySeq = 0;
8
+ var activity = [];
9
+ var lastUrl = "";
10
+ var PII = [
11
+ /\b[\w.+-]+@[\w-]+\.[\w.]{2,}\b/g,
12
+ // email
13
+ /\b(?:\d[ -]?){13,19}\b/g,
14
+ // card-ish
15
+ /\b\d{3}[- ]?\d{2}[- ]?\d{4}\b/g,
16
+ // ssn — dashed, spaced, OR bare 9 digits
17
+ /\b\d{9,}\b/g,
18
+ // long bare digit runs: account / MRN / routing numbers
19
+ /(?:\+?\d{1,2}[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}\b/g,
20
+ // us phone
21
+ /\b(?:sk|pk|rk|ak)_(?:live|test)_[A-Za-z0-9]{8,}\b/g,
22
+ // stripe-style api keys
23
+ /\beyJ[\w-]+\.[\w-]+\.[\w-]+\b/g
24
+ // jwt
25
+ ];
26
+ function redact(text) {
27
+ let out = text;
28
+ for (const re of PII) out = out.replace(re, "[redacted]");
29
+ return out;
30
+ }
31
+ function isPrivate(el) {
32
+ if (el.closest("[data-mf-private]")) return true;
33
+ const tag = el.tagName;
34
+ if (tag === "INPUT") {
35
+ const t = el.type;
36
+ if (t === "password" || t === "hidden") return true;
37
+ }
38
+ return false;
39
+ }
40
+ function embeddedMatterfactEntities() {
41
+ if (!widgetOrigin) return [];
42
+ const out = [];
43
+ for (const frame of Array.from(document.querySelectorAll("iframe"))) {
44
+ let u;
45
+ try {
46
+ u = new URL(frame.getAttribute("src") || "", location.href);
47
+ } catch {
48
+ continue;
49
+ }
50
+ if (u.origin !== widgetOrigin) continue;
51
+ const m = u.pathname.match(/^\/artifacts\/(.+?)\/?$/);
52
+ if (!m) continue;
53
+ const id = decodeURIComponent(m[1]);
54
+ if (!id || out.some((e) => e.id === id)) continue;
55
+ out.push({
56
+ kind: "artifact",
57
+ id,
58
+ label: redact(frame.getAttribute("title") || "") || id
59
+ });
60
+ }
61
+ return out;
62
+ }
63
+ function opaqueFrameCount() {
64
+ return Array.from(document.querySelectorAll("iframe")).filter((f) => {
65
+ try {
66
+ const u = new URL(f.getAttribute("src") || "", location.href);
67
+ return u.origin !== location.origin && u.origin !== widgetOrigin;
68
+ } catch {
69
+ return false;
70
+ }
71
+ }).length;
72
+ }
73
+ function readPageContext() {
74
+ const declared = window.matterfact?.context ?? {};
75
+ const found = embeddedMatterfactEntities();
76
+ const opaque = opaqueFrameCount();
77
+ return {
78
+ // Path only. A query string is where session ids, tokens and email addresses
79
+ // live; it is not ours to take.
80
+ url: location.origin + location.pathname,
81
+ path: location.pathname,
82
+ title: redact(document.title),
83
+ locale: document.documentElement.lang || void 0,
84
+ ...declared,
85
+ // After the spread: what we FOUND is additive to what the host DECLARED, never a
86
+ // replacement. A host that declares its own entities still gets the artifacts we
87
+ // spotted, and vice versa.
88
+ entities: [...declared.entities ?? [], ...found],
89
+ data: {
90
+ ...declared.data ?? {},
91
+ ...opaque ? { opaque_frames: opaque } : {}
92
+ }
93
+ };
94
+ }
95
+ function publishContext() {
96
+ send?.({ type: "host.context", context: readPageContext() });
97
+ }
98
+ function pushActivity(e) {
99
+ activity.push({ ...e, seq: ++activitySeq, ts: Date.now() });
100
+ if (activity.length > MAX_ACTIVITY) activity.shift();
101
+ send?.({ type: "host.activity", events: [activity[activity.length - 1]] });
102
+ }
103
+ function controlLabel(el) {
104
+ const aria = el.getAttribute("aria-label");
105
+ if (aria) return aria;
106
+ const id = el.id;
107
+ if (id) {
108
+ const forLabel = document.querySelector(`label[for="${CSS.escape(id)}"]`);
109
+ const t = forLabel?.textContent?.trim();
110
+ if (t) return t;
111
+ }
112
+ const wrapping = el.closest("label")?.textContent?.trim();
113
+ if (wrapping) return wrapping;
114
+ const placeholder = el.getAttribute("placeholder");
115
+ if (placeholder) return placeholder;
116
+ return "";
117
+ }
118
+ var FORM_CONTROLS = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
119
+ function describe(el) {
120
+ const role = el.getAttribute("role") || el.tagName.toLowerCase();
121
+ const label = el.getAttribute("aria-label") || (FORM_CONTROLS.has(el.tagName) ? controlLabel(el) : el.innerText?.trim().slice(0, 60)) || el.getAttribute("title") || "";
122
+ return label ? `${role} "${redact(label)}"` : role;
123
+ }
124
+ var ACTIONABLE = 'a[href],button,input,select,textarea,summary,[role="button"],[role="link"],[role="menuitem"],[role="tab"],[role="option"],[role="checkbox"],[role="switch"],[role="radio"],[onclick],[tabindex]';
125
+ function onClick(ev) {
126
+ const target = ev.target;
127
+ if (!target || !(target instanceof Element)) return;
128
+ const label = target.closest("label");
129
+ const labelled = label ? label.getAttribute("for") && document.getElementById(label.getAttribute("for")) || label.querySelector("input,select,textarea") : null;
130
+ const actionable = labelled ?? target.closest(ACTIONABLE);
131
+ if (!actionable || isPrivate(actionable)) return;
132
+ pushActivity({ type: "click", summary: `clicked ${describe(actionable)}` });
133
+ }
134
+ function onSubmit(ev) {
135
+ const el = ev.target;
136
+ if (!el || isPrivate(el)) return;
137
+ pushActivity({ type: "submit", summary: `submitted ${describe(el)}` });
138
+ }
139
+ function onChange(ev) {
140
+ const el = ev.target;
141
+ if (!el || !(el instanceof Element) || isPrivate(el)) return;
142
+ const tag = el.tagName;
143
+ const type = el.type;
144
+ if (tag === "INPUT" && (type === "password" || type === "hidden")) return;
145
+ let summary = `changed ${describe(el)}`;
146
+ if (tag === "SELECT") {
147
+ const opt = el.selectedOptions[0]?.text;
148
+ if (opt) summary = `${describe(el)} \u2192 "${redact(opt)}"`;
149
+ } else if (type === "checkbox" || type === "radio") {
150
+ summary = `${el.checked ? "checked" : "unchecked"} ${describe(el)}`;
151
+ }
152
+ pushActivity({ type: "input", summary });
153
+ }
154
+ function watchNavigation() {
155
+ const fire = () => {
156
+ const url = location.pathname;
157
+ if (url === lastUrl) return;
158
+ lastUrl = url;
159
+ pushActivity({ type: "nav", summary: `navigated to ${url}` });
160
+ publishContext();
161
+ };
162
+ for (const name of ["pushState", "replaceState"]) {
163
+ const orig = history[name];
164
+ history[name] = function(...args) {
165
+ const r = orig.apply(this, args);
166
+ fire();
167
+ return r;
168
+ };
169
+ }
170
+ window.addEventListener("popstate", fire);
171
+ }
172
+ var lastFocus = {};
173
+ async function readFocus() {
174
+ const focus = {};
175
+ const sel = window.getSelection?.();
176
+ if (sel && !sel.isCollapsed) {
177
+ const anchor = sel.anchorNode?.parentElement ?? null;
178
+ if (!anchor || !anchor.closest("[data-mf-private]")) {
179
+ const text = sel.toString().trim().slice(0, 500);
180
+ if (text) focus.selection = redact(text);
181
+ }
182
+ }
183
+ const active = document.activeElement;
184
+ if (active && active !== document.body && !isPrivate(active) && !active.closest("[data-mf-private]")) {
185
+ const { snapshot } = await import("./snapshot-Z7YUSB27.js");
186
+ void snapshot;
187
+ focus.focused = {
188
+ label: redact(describeControl(active)),
189
+ role: active.getAttribute("role") || active.tagName.toLowerCase()
190
+ };
191
+ }
192
+ const doc = document.documentElement;
193
+ const scrollable = doc.scrollHeight - doc.clientHeight;
194
+ focus.scroll = scrollable > 0 ? Math.round(doc.scrollTop / scrollable * 100) / 100 : 0;
195
+ return focus;
196
+ }
197
+ function describeControl(el) {
198
+ return describe(el);
199
+ }
200
+ var focusTimer = null;
201
+ function scheduleFocus() {
202
+ if (focusTimer) return;
203
+ focusTimer = setTimeout(async () => {
204
+ focusTimer = null;
205
+ lastFocus = await readFocus();
206
+ send?.({ type: "host.focus", focus: lastFocus });
207
+ }, 250);
208
+ }
209
+ var snapshotSeq = 0;
210
+ async function sendSnapshot(emit) {
211
+ const { snapshot } = await import("./snapshot-Z7YUSB27.js");
212
+ const { yaml, truncated, visibleRefs } = snapshot();
213
+ emit({
214
+ type: "host.snapshot",
215
+ snapshot: { yaml: redact(yaml), seq: ++snapshotSeq, truncated }
216
+ });
217
+ lastFocus = { ...lastFocus, visibleRefs };
218
+ emit({ type: "host.focus", focus: lastFocus });
219
+ }
220
+ async function sendRegion(ref, emit) {
221
+ const { snapshotRegion, resolveRef } = await import("./snapshot-Z7YUSB27.js");
222
+ const el = resolveRef(ref);
223
+ if (!el) {
224
+ emit({
225
+ type: "host.region",
226
+ ref,
227
+ yaml: "(this element is no longer on the page)"
228
+ });
229
+ return;
230
+ }
231
+ const { yaml } = snapshotRegion(el);
232
+ emit({ type: "host.region", ref, yaml: redact(yaml) });
233
+ }
234
+ async function callTool(call, emit) {
235
+ emit({
236
+ type: "host.toolResult",
237
+ callId: call.callId,
238
+ ok: false,
239
+ error: "Host tools are read-only in this version; no action was taken."
240
+ });
241
+ }
242
+ function beginAuth(config, emit) {
243
+ const w = window.open(
244
+ `${config.origin}/embed/authorize?k=${encodeURIComponent(
245
+ config.publishableKey
246
+ )}&o=${encodeURIComponent(location.origin)}`,
247
+ "mf_auth",
248
+ "width=460,height=640"
249
+ );
250
+ if (!w) return;
251
+ const onMsg = (event) => {
252
+ if (event.origin !== config.origin) return;
253
+ const d = event.data;
254
+ if (d?.type !== "mf:embed:auth") return;
255
+ window.removeEventListener("message", onMsg);
256
+ emit({ type: "host.auth", token: d.token, expiresAt: d.expiresAt });
257
+ };
258
+ window.addEventListener("message", onMsg);
259
+ }
260
+ function start(emit, origin) {
261
+ send = emit;
262
+ widgetOrigin = origin || "";
263
+ lastUrl = location.pathname;
264
+ publishContext();
265
+ watchNavigation();
266
+ document.addEventListener("click", onClick, { capture: true, passive: true });
267
+ document.addEventListener("submit", onSubmit, {
268
+ capture: true,
269
+ passive: true
270
+ });
271
+ document.addEventListener("change", onChange, {
272
+ capture: true,
273
+ passive: true
274
+ });
275
+ document.addEventListener("selectionchange", scheduleFocus, {
276
+ passive: true
277
+ });
278
+ document.addEventListener("focusin", scheduleFocus, {
279
+ capture: true,
280
+ passive: true
281
+ });
282
+ window.addEventListener("scroll", scheduleFocus, {
283
+ capture: true,
284
+ passive: true
285
+ });
286
+ const theme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
287
+ emit({ type: "host.theme", mode: theme });
288
+ }
289
+
290
+ export {
291
+ redact,
292
+ isPrivate,
293
+ readPageContext,
294
+ sendSnapshot,
295
+ sendRegion,
296
+ callTool,
297
+ beginAuth,
298
+ start
299
+ };
300
+ //# sourceMappingURL=chunk-6N5OYQLF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/context.ts"],"sourcesContent":["import type {\n ActivityEvent,\n FocusContext,\n HostToWidget,\n PageContext,\n PageEntity,\n ToolCall,\n} from './protocol';\n\n/** The origin serving our chat — 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 — 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 — 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\n/* ─────────────────────────── redaction ────────────────────────────────── */\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 — 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 — 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/** 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/* ───────────────────────── page context ───────────────────────────────── */\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 — 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 — 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 */\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 m = u.pathname.match(/^\\/artifacts\\/(.+?)\\/?$/);\n if (!m) continue;\n const id = decodeURIComponent(m[1]);\n if (!id || 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 — 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\nexport function readPageContext(): PageContext {\n const declared =\n (window as { matterfact?: { context?: PageContext } }).matterfact\n ?.context ?? {};\n\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\nfunction publishContext() {\n send?.({ type: 'host.context', context: readPageContext() });\n}\n\n/* ────────────────────────── activity ──────────────────────────────────── */\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}` — 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 — 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 — 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 — 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 — 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 — 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 — \"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)} → \"${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 — 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 publishContext();\n };\n\n for (const name of ['pushState', 'replaceState'] as const) {\n const orig = history[name];\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/* ─────────────────────────── focal context ────────────────────────────── */\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 — 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 — 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 — 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 — 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 — 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 import('./dom/snapshot');\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\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/* ───────────────────────────── snapshot ───────────────────────────────── */\n\nlet snapshotSeq = 0;\n\nexport async function sendSnapshot(emit: Send) {\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 import('./dom/snapshot');\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 — 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 const { snapshotRegion, resolveRef } = await import('./dom/snapshot');\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/* ───────────────────────────── tools ──────────────────────────────────── */\n\n/**\n * v1 IS READ-ONLY.\n *\n * The page's content is untrusted — text on it can try to instruct the agent — and\n * the moment the agent can act, a bad answer becomes a bad ACTION. So no tool here\n * mutates the page yet. The call path exists, and the enforcement point is HERE (in\n * the page, where we control what actually happens) rather than in the widget, which\n * can be lied to.\n *\n * When write tools land: anything not `readOnly` gets a user confirmation, on every\n * call. Not \"unless the host opts out\" — every call, because the trigger may have\n * been written by the page.\n */\nexport async function callTool(call: ToolCall, emit: Send) {\n emit({\n type: 'host.toolResult',\n callId: call.callId,\n ok: false,\n error: 'Host tools are read-only in this version; no action was taken.',\n });\n}\n\n/* ───────────────────────────── auth ───────────────────────────────────── */\n\n/**\n * Hosted login, in a POPUP — and the popup is not a UX preference.\n *\n * Our iframe on acme.com gets a PARTITIONED cookie jar: it cannot see the user's\n * existing matterfact session, no matter that it is served from our own origin.\n * A popup, however, is a TOP-LEVEL window on app.matterfact.com — first-party, real\n * cookies, silent SSO if they are already signed in. It hands the token back by\n * postMessage and we forward it into the iframe.\n */\nexport function beginAuth(\n config: { origin: string; publishableKey: string },\n emit: Send,\n) {\n const w = window.open(\n `${config.origin}/embed/authorize?k=${encodeURIComponent(\n config.publishableKey,\n )}&o=${encodeURIComponent(location.origin)}`,\n 'mf_auth',\n 'width=460,height=640',\n );\n if (!w) return; // popup blocked; the widget shows its own \"sign in\" affordance\n\n const onMsg = (event: MessageEvent) => {\n if (event.origin !== config.origin) return;\n const d = event.data;\n if (d?.type !== 'mf:embed:auth') return;\n window.removeEventListener('message', onMsg);\n emit({ type: 'host.auth', token: d.token, expiresAt: d.expiresAt });\n };\n window.addEventListener('message', onMsg);\n}\n\n/* ───────────────────────────── start ──────────────────────────────────── */\n\nexport function start(emit: Send, origin?: string) {\n send = emit;\n widgetOrigin = origin || '';\n lastUrl = location.pathname;\n\n publishContext();\n watchNavigation();\n\n // Passive + capture: we observe, we never interfere with the host's own handling.\n document.addEventListener('click', onClick, { capture: true, passive: true });\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 — 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 const theme = matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n emit({ type: 'host.theme', mode: theme });\n}\n"],"mappings":";;;AAWA,IAAI,eAAe;AAuBnB,IAAM,eAAe;AAErB,IAAI,OAAoB;AACxB,IAAI,cAAc;AAClB,IAAM,WAA4B,CAAC;AACnC,IAAI,UAAU;AAId,IAAM,MAAM;AAAA,EACV;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AASO,SAAS,OAAO,MAAsB;AAC3C,MAAI,MAAM;AACV,aAAW,MAAM,IAAK,OAAM,IAAI,QAAQ,IAAI,YAAY;AACxD,SAAO;AACT;AAGO,SAAS,UAAU,IAAsB;AAC9C,MAAI,GAAG,QAAQ,mBAAmB,EAAG,QAAO;AAC5C,QAAM,MAAM,GA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ACrD,SACA;AACJ,OAAK,EAAE,MAAM,cAAc,MAAM,MAAM,CAAC;AAC1C;","names":[]}
@@ -0,0 +1,3 @@
1
+ import{a as re,b as P}from"./chunk-MWRVWYWX.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,O=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 R(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)?R(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=R(i,"alt");if(E!==null)return E}else if(se(i)){var k=R(i,"label");if(k!==null)return k}if(H(i)&&(i.type==="button"||i.type==="submit"||i.type==="reset")){var Z=R(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=R(i,"alt");if(ee!==null)return ee;var te=R(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(!O&&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 Oe(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 Re(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 j(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||j(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)||j(e)}function Nt(e,t){let n=e.tagName;return n==="INPUT"||n==="TEXTAREA"?Tt.has(t)?(e.value??"").length>0:!1:j(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 j(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 Ot=0,G=0,Y=new WeakMap,q=new Map;function _e(){G++,q.clear()}function He(e,t,n){let r=`${t} ${n}`,a=Y.get(e);return!a||a.key!==r?(a={id:`e${++Ot}`,key:r,gen:G},Y.set(e,a)):a.gen=G,q.set(a.id,e),a.id}function Rt(e){let t=q.get(e);if(!t)return null;if(!t.isConnected)return q.delete(e),null;let n=Y.get(t);return!n||n.id!==e||n.gen!==G?null:t}var Ct=4e3,Mt=800,It=120,kt=120,Ge=25,$e=new Set(["generic","presentation","none"]),Pt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","LINK","META","BASE"]);function L(e){return e.nodes>=Ct||e.lines>=Mt?(e.truncated=!0,!1):!0}function Dt(e){return e.id==="matterfact-embed"||e.hasAttribute("data-mf-embed")}function _t(e,t,n){return e.getAttribute("aria-hidden")==="true"||e.hasAttribute("hidden")||e.hasAttribute("inert")?!0:!Oe(e,t,n)}function Ht(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=Ht(e);for(let o=0;o<a.length;o++){let l=a[o];l&&qt(l,t,n,r)}}function $t(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 Vt(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 jt(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 Gt(e,t,n,r){if(!L(r)||Pt.has(e.tagName)||Dt(e)||P(e))return;r.nodes++;let a=r.styleOf(e);if(_t(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&&Re(a)){let I=He(e,m,p);x=` [ref=${I}]`,r.onRef?.(I,e)}let M=ke(e,m),O={role:m,name:p,props:(M?` ${M}`:"")+x,children:[]};if(r.lines++,t.children.push(O),e.tagName==="SELECT"){Vt(e,O,r);return}e.tagName==="INPUT"&&e.list&&jt(e,O,r),!Ie(e)&&Q(e,O,a,r)}function qt(e,t,n,r){e.nodeType===3?$t(e,t,r):e.nodeType===1&&Gt(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,kt))}`);continue}let o=a.name?` ${je(Ve(a.name,It))}`:"",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
+ `),truncated:r.truncated}}function Tn(){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 wn(e){return e.isConnected?We(e):{yaml:"",truncated:!1}}export{Rt as resolveRef,Tn as snapshot,wn as snapshotRegion};
3
+ //# sourceMappingURL=chunk-6VW4CCNF.js.map