@matterfact/embed 0.4.0 → 0.6.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 +62 -6
- package/dist/{chunk-523BCS2Z.js → chunk-4Q2ROXLR.js} +2 -2
- package/dist/chunk-7I37ZFAJ.js +2 -0
- package/dist/{chunk-Z4WT3TIZ.js → chunk-AXKXNYRT.js} +39 -38
- package/dist/chunk-AXKXNYRT.js.map +1 -0
- package/dist/chunk-D7R6WVHG.js +2 -0
- package/dist/chunk-D7R6WVHG.js.map +7 -0
- package/dist/{chunk-SBNMM3ZV.js → chunk-RS6RMZ77.js} +39 -37
- package/dist/chunk-RS6RMZ77.js.map +1 -0
- package/dist/{context-432WQST4.js → context-WU2F5CBC.js} +6 -4
- package/dist/context-YX2KXFLI.js +3 -0
- package/dist/{context-KZAUOIR6.js.map → context-YX2KXFLI.js.map} +1 -1
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +2 -2
- package/dist/index.cjs +58 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +64 -50
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +35 -1
- package/dist/react.d.ts +35 -1
- package/dist/react.js +28 -15
- package/dist/react.js.map +1 -1
- package/dist/{snapshot-SOMSG2OF.js → snapshot-JOGZWESK.js} +2 -2
- package/dist/{snapshot-Q3CALMHD.js → snapshot-MUXE7KXX.js} +3 -3
- package/dist/{snapshot-Q3CALMHD.js.map → snapshot-MUXE7KXX.js.map} +1 -1
- package/examples/README.md +46 -0
- package/examples/demo-host/index.html +163 -0
- package/examples/demo-host/serve.mjs +62 -0
- package/examples/embed-demo/.env.example +24 -0
- package/examples/embed-demo/README.md +72 -0
- package/examples/embed-demo/index.html +12 -0
- package/examples/embed-demo/package.json +25 -0
- package/examples/embed-demo/src/App.tsx +239 -0
- package/examples/embed-demo/src/config.ts +43 -0
- package/examples/embed-demo/src/main.tsx +10 -0
- package/examples/embed-demo/src/styles.css +354 -0
- package/examples/embed-demo/tsconfig.json +16 -0
- package/examples/embed-demo/vite.config.ts +11 -0
- package/examples/host-panel.html +259 -0
- package/package.json +3 -2
- package/dist/chunk-SBNMM3ZV.js.map +0 -1
- package/dist/chunk-URIBHOOQ.js +0 -2
- package/dist/chunk-XLQ36ZMV.js +0 -2
- package/dist/chunk-XLQ36ZMV.js.map +0 -7
- package/dist/chunk-Z4WT3TIZ.js.map +0 -1
- package/dist/context-KZAUOIR6.js +0 -3
- /package/dist/{chunk-523BCS2Z.js.map → chunk-4Q2ROXLR.js.map} +0 -0
- /package/dist/{chunk-URIBHOOQ.js.map → chunk-7I37ZFAJ.js.map} +0 -0
- /package/dist/{context-432WQST4.js.map → context-WU2F5CBC.js.map} +0 -0
- /package/dist/{snapshot-SOMSG2OF.js.map → snapshot-JOGZWESK.js.map} +0 -0
package/README.md
CHANGED
|
@@ -84,8 +84,12 @@ the token never reaches the model. Nothing extra to configure.
|
|
|
84
84
|
Script-tag / non-React hosts can use the iframe directly (the Share dialog shows this form):
|
|
85
85
|
|
|
86
86
|
```html
|
|
87
|
-
<iframe
|
|
88
|
-
|
|
87
|
+
<iframe
|
|
88
|
+
src="https://app.matterfact.com/embed/artifacts/tsla-liquidity?owner=you@firm.com&t=…"
|
|
89
|
+
width="100%"
|
|
90
|
+
height="600"
|
|
91
|
+
style="border:0"
|
|
92
|
+
></iframe>
|
|
89
93
|
```
|
|
90
94
|
|
|
91
95
|
## Signing users in
|
|
@@ -111,7 +115,7 @@ On a single-tenant Entra deployment there are **two app registrations**, and mix
|
|
|
111
115
|
is the thing that catches everyone:
|
|
112
116
|
|
|
113
117
|
- the **matterfact** app registration — you created it in your tenant and gave us its
|
|
114
|
-
client id + secret. It
|
|
118
|
+
client id + secret. It _exposes_ the scope.
|
|
115
119
|
- the app you're **embedding into** (e.g. your portal) — a **different** registration with
|
|
116
120
|
its **own** client id. It's the one your users sign into.
|
|
117
121
|
|
|
@@ -127,14 +131,14 @@ done, your embedding app requests that scope with MSAL and hands the access toke
|
|
|
127
131
|
```tsx
|
|
128
132
|
import { useMsal } from '@azure/msal-react';
|
|
129
133
|
|
|
130
|
-
const { instance, accounts } = useMsal();
|
|
134
|
+
const { instance, accounts } = useMsal(); // configured with YOUR app's client id
|
|
131
135
|
|
|
132
136
|
const getAuthToken = async () => {
|
|
133
137
|
const { accessToken } = await instance.acquireTokenSilent({
|
|
134
138
|
scopes: ['api://<matterfact-client-id>/embed.access'],
|
|
135
139
|
account: accounts[0],
|
|
136
140
|
});
|
|
137
|
-
return accessToken;
|
|
141
|
+
return accessToken; // access token, not the ID token
|
|
138
142
|
};
|
|
139
143
|
|
|
140
144
|
<MatterfactAgent publishableKey="pk_live_…" getAuthToken={getAuthToken} />;
|
|
@@ -164,6 +168,42 @@ window.matterfact = {
|
|
|
164
168
|
};
|
|
165
169
|
```
|
|
166
170
|
|
|
171
|
+
### Keeping context fresh (virtualized SPAs)
|
|
172
|
+
|
|
173
|
+
The static `context` above is read on load and on URL navigation. In a **virtualized SPA**,
|
|
174
|
+
what the agent should know changes without the path changing — a team switch, a filter edit,
|
|
175
|
+
a row selection — and a static object goes stale until the next navigation. Give a **pull
|
|
176
|
+
callback** instead and the widget reads it **fresh at the start of every turn** — symmetric
|
|
177
|
+
with `getAuthToken`:
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
<MatterfactAgent
|
|
181
|
+
publishableKey="pk_live_…"
|
|
182
|
+
getPageContext={() => ({
|
|
183
|
+
route: '/portfolios/:id',
|
|
184
|
+
description: `Growth Sleeve${selected ? ` — focused on ${selected}` : ''}`,
|
|
185
|
+
entities: holdings.map((h) => ({
|
|
186
|
+
kind: 'x:ticker',
|
|
187
|
+
id: h.ticker,
|
|
188
|
+
label: h.ticker,
|
|
189
|
+
})),
|
|
190
|
+
data: { selected },
|
|
191
|
+
})}
|
|
192
|
+
/>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
// script tag — same idea, a global callback (supersedes window.matterfact.context)
|
|
197
|
+
window.matterfact = {
|
|
198
|
+
getPageContext: () => ({ route: '/portfolios/:id', description: '…' }),
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
May be async (read a store, await a selector). Auto-detected fields (url/path/title, embedded
|
|
203
|
+
artifacts) are still merged on top. Resolution order, first non-null wins: the React
|
|
204
|
+
`getPageContext` prop → `window.matterfact.getPageContext()` → the static `window.matterfact.context`.
|
|
205
|
+
See [`examples/embed-demo`](examples/embed-demo) (React) and [`examples/host-panel.html`](examples/host-panel.html) (script tag).
|
|
206
|
+
|
|
167
207
|
Want none of this? `pageContext={false}` (or `data-page-context="off"` on the script
|
|
168
208
|
tag) turns off page observation entirely — not just the declared context object above,
|
|
169
209
|
but the snapshot, the focus/activity stream, and artifact grants too. The loader never
|
|
@@ -193,7 +233,10 @@ engineer can flip it on a live deployment without redeploying the customer's sit
|
|
|
193
233
|
prop is for a host that wants it wired into their own debug tooling instead.
|
|
194
234
|
|
|
195
235
|
```tsx
|
|
196
|
-
<MatterfactAgent
|
|
236
|
+
<MatterfactAgent
|
|
237
|
+
publishableKey="pk_live_…"
|
|
238
|
+
dev={process.env.NODE_ENV !== 'production'}
|
|
239
|
+
/>
|
|
197
240
|
```
|
|
198
241
|
|
|
199
242
|
## Security model
|
|
@@ -204,6 +247,19 @@ prop is for a host that wants it wired into their own debug tooling instead.
|
|
|
204
247
|
- The page snapshot is untrusted reference data to the agent — grounding, never
|
|
205
248
|
instructions.
|
|
206
249
|
|
|
250
|
+
## Examples
|
|
251
|
+
|
|
252
|
+
Runnable examples ship inside this package (under `examples/`) and are browsable without
|
|
253
|
+
cloning anything:
|
|
254
|
+
|
|
255
|
+
- **`examples/embed-demo/`** — a tiny Vite + React app that mounts `<MatterfactAgent inline>`
|
|
256
|
+
in a side panel next to an embedded `<MatterfactArtifact>`, configured entirely via `.env`.
|
|
257
|
+
Browse it on [unpkg](https://unpkg.com/browse/@matterfact/embed/examples/embed-demo/), or
|
|
258
|
+
after `npm install @matterfact/embed` find it at
|
|
259
|
+
`node_modules/@matterfact/embed/examples/embed-demo/` — copy it out, `npm install`, `npm run dev`.
|
|
260
|
+
- **`examples/host-panel.html`** — the inline-placement pattern as a single HTML file (script-tag loader).
|
|
261
|
+
- **`examples/demo-host/`** — a zero-dependency host site proving the script-tag loader end to end.
|
|
262
|
+
|
|
207
263
|
## Full guide
|
|
208
264
|
|
|
209
265
|
The complete integration reference — endpoints, single-tenant Entra setup, troubleshooting
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as re,b as P}from"./chunk-XLQ36ZMV.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-D7R6WVHG.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-4Q2ROXLR.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-D7R6WVHG.js";export{c as artifactIdFromPath,d as buildPageContext,j as callTool,g as grantsFromIframeSrcs,b as isPrivate,f as provideContext,e as readPageContext,a as redact,i as sendRegion,h as sendSnapshot,l as start,k as stop};
|
|
2
|
+
//# sourceMappingURL=chunk-7I37ZFAJ.js.map
|
|
@@ -6,10 +6,10 @@ var activitySeq = 0;
|
|
|
6
6
|
var activity = [];
|
|
7
7
|
var lastUrl = "";
|
|
8
8
|
var pageContextOn = true;
|
|
9
|
+
var contextProvider;
|
|
9
10
|
var navFire = null;
|
|
10
11
|
var origPushState = null;
|
|
11
12
|
var origReplaceState = null;
|
|
12
|
-
var pendingAuthListener = null;
|
|
13
13
|
var snapshotModule = null;
|
|
14
14
|
var PII = [
|
|
15
15
|
/\b[\w.+-]+@[\w-]+\.[\w.]{2,}\b/g,
|
|
@@ -77,8 +77,7 @@ function opaqueFrameCount() {
|
|
|
77
77
|
}
|
|
78
78
|
}).length;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const declared = window.matterfact?.context ?? {};
|
|
80
|
+
function buildPageContext(declared) {
|
|
82
81
|
const found = embeddedMatterfactEntities();
|
|
83
82
|
const opaque = opaqueFrameCount();
|
|
84
83
|
return {
|
|
@@ -99,8 +98,30 @@ function readPageContext() {
|
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
100
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
101
|
+
function readPageContext() {
|
|
102
|
+
return buildPageContext(
|
|
103
|
+
window.matterfact?.context ?? {}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
async function resolveDeclaredContext() {
|
|
107
|
+
const mf = window.matterfact;
|
|
108
|
+
if (contextProvider) {
|
|
109
|
+
const c = await contextProvider();
|
|
110
|
+
if (c) return c;
|
|
111
|
+
}
|
|
112
|
+
if (mf?.getPageContext) {
|
|
113
|
+
const c = await mf.getPageContext();
|
|
114
|
+
if (c) return c;
|
|
115
|
+
}
|
|
116
|
+
return mf?.context ?? {};
|
|
117
|
+
}
|
|
118
|
+
async function publishContext() {
|
|
119
|
+
if (!pageContextOn) return;
|
|
120
|
+
const declared = await resolveDeclaredContext();
|
|
121
|
+
send?.({ type: "host.context", context: buildPageContext(declared) });
|
|
122
|
+
}
|
|
123
|
+
function provideContext() {
|
|
124
|
+
void publishContext();
|
|
104
125
|
}
|
|
105
126
|
function grantsFromIframeSrcs(srcs, origin) {
|
|
106
127
|
const out = [];
|
|
@@ -194,7 +215,7 @@ function watchNavigation() {
|
|
|
194
215
|
if (url === lastUrl) return;
|
|
195
216
|
lastUrl = url;
|
|
196
217
|
pushActivity({ type: "nav", summary: `navigated to ${url}` });
|
|
197
|
-
publishContext();
|
|
218
|
+
void publishContext();
|
|
198
219
|
publishArtifactGrants();
|
|
199
220
|
};
|
|
200
221
|
navFire = fire;
|
|
@@ -238,7 +259,7 @@ function describeControl(el) {
|
|
|
238
259
|
return describe(el);
|
|
239
260
|
}
|
|
240
261
|
async function loadSnapshotModule() {
|
|
241
|
-
const m = await import('./snapshot-
|
|
262
|
+
const m = await import('./snapshot-MUXE7KXX.js');
|
|
242
263
|
snapshotModule = m;
|
|
243
264
|
return m;
|
|
244
265
|
}
|
|
@@ -286,27 +307,6 @@ async function callTool(call, emit) {
|
|
|
286
307
|
error: "Host tools are read-only in this version; no action was taken."
|
|
287
308
|
});
|
|
288
309
|
}
|
|
289
|
-
function beginAuth(config, emit) {
|
|
290
|
-
const w = window.open(
|
|
291
|
-
`${config.origin}/embed/authorize?k=${encodeURIComponent(
|
|
292
|
-
config.publishableKey
|
|
293
|
-
)}&o=${encodeURIComponent(location.origin)}`,
|
|
294
|
-
"mf_auth",
|
|
295
|
-
"width=460,height=640"
|
|
296
|
-
);
|
|
297
|
-
if (!w) return;
|
|
298
|
-
if (pendingAuthListener) window.removeEventListener("message", pendingAuthListener);
|
|
299
|
-
const onMsg = (event) => {
|
|
300
|
-
if (event.origin !== config.origin) return;
|
|
301
|
-
const d = event.data;
|
|
302
|
-
if (d?.type !== "mf:embed:auth") return;
|
|
303
|
-
window.removeEventListener("message", onMsg);
|
|
304
|
-
pendingAuthListener = null;
|
|
305
|
-
emit({ type: "host.auth", token: d.token, expiresAt: d.expiresAt });
|
|
306
|
-
};
|
|
307
|
-
pendingAuthListener = onMsg;
|
|
308
|
-
window.addEventListener("message", onMsg);
|
|
309
|
-
}
|
|
310
310
|
function stop() {
|
|
311
311
|
document.removeEventListener("click", onClick, { capture: true });
|
|
312
312
|
document.removeEventListener("submit", onSubmit, { capture: true });
|
|
@@ -326,31 +326,32 @@ function stop() {
|
|
|
326
326
|
history.replaceState = origReplaceState;
|
|
327
327
|
origReplaceState = null;
|
|
328
328
|
}
|
|
329
|
-
if (pendingAuthListener) {
|
|
330
|
-
window.removeEventListener("message", pendingAuthListener);
|
|
331
|
-
pendingAuthListener = null;
|
|
332
|
-
}
|
|
333
329
|
if (focusTimer) {
|
|
334
330
|
clearTimeout(focusTimer);
|
|
335
331
|
focusTimer = null;
|
|
336
332
|
}
|
|
337
333
|
send = null;
|
|
334
|
+
contextProvider = void 0;
|
|
338
335
|
activity.length = 0;
|
|
339
336
|
lastFocus = {};
|
|
340
337
|
widgetOrigin = "";
|
|
341
338
|
snapshotModule?.clearRefs();
|
|
342
339
|
}
|
|
343
|
-
function start(emit, origin, pageContext = true) {
|
|
340
|
+
function start(emit, origin, pageContext = true, provider) {
|
|
344
341
|
stop();
|
|
345
342
|
send = emit;
|
|
346
343
|
widgetOrigin = origin || "";
|
|
347
344
|
lastUrl = location.pathname;
|
|
348
345
|
pageContextOn = pageContext;
|
|
346
|
+
contextProvider = provider;
|
|
349
347
|
if (pageContextOn) {
|
|
350
|
-
publishContext();
|
|
348
|
+
void publishContext();
|
|
351
349
|
publishArtifactGrants();
|
|
352
350
|
watchNavigation();
|
|
353
|
-
document.addEventListener("click", onClick, {
|
|
351
|
+
document.addEventListener("click", onClick, {
|
|
352
|
+
capture: true,
|
|
353
|
+
passive: true
|
|
354
|
+
});
|
|
354
355
|
document.addEventListener("submit", onSubmit, {
|
|
355
356
|
capture: true,
|
|
356
357
|
passive: true
|
|
@@ -375,6 +376,6 @@ function start(emit, origin, pageContext = true) {
|
|
|
375
376
|
emit({ type: "host.theme", mode: theme });
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
export { artifactIdFromPath,
|
|
379
|
-
//# sourceMappingURL=chunk-
|
|
380
|
-
//# sourceMappingURL=chunk-
|
|
379
|
+
export { artifactIdFromPath, buildPageContext, callTool, grantsFromIframeSrcs, isPrivate, provideContext, readPageContext, redact, sendRegion, sendSnapshot, start, stop };
|
|
380
|
+
//# sourceMappingURL=chunk-AXKXNYRT.js.map
|
|
381
|
+
//# sourceMappingURL=chunk-AXKXNYRT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts"],"names":[],"mappings":";AAWA,IAAI,YAAA,GAAe,EAAA;AAuBnB,IAAM,YAAA,GAAe,EAAA;AAErB,IAAI,IAAA,GAAoB,IAAA;AACxB,IAAI,WAAA,GAAc,CAAA;AAClB,IAAM,WAA4B,EAAC;AACnC,IAAI,OAAA,GAAU,EAAA;AAGd,IAAI,aAAA,GAAgB,IAAA;AAcpB,IAAI,eAAA;AAcJ,IAAI,OAAA,GAA+B,IAAA;AAInC,IAAI,aAAA,GAA6C,IAAA;AACjD,IAAI,gBAAA,GAAmD,IAAA;AAKvD,IAAI,cAAA,GAAmD,IAAA;AAIvD,IAAM,GAAA,GAAM;AAAA,EACV,iCAAA;AAAA;AAAA,EACA,yBAAA;AAAA;AAAA,EACA,gCAAA;AAAA;AAAA,EACA,aAAA;AAAA;AAAA,EACA,4DAAA;AAAA;AAAA,EACA,oDAAA;AAAA;AAAA,EACA;AAAA;AACF,CAAA;AASO,SAAS,OAAO,IAAA,EAAsB;AAC3C,EAAA,IAAI,GAAA,GAAM,IAAA;AACV,EAAA,KAAA,MAAW,MAAM,GAAA,EAAK,GAAA,GAAM,GAAA,CAAI,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,CAAE,UACrD,MAAA,GACA,OAAA;AACJ,EAAA,IAAA,CAAK,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,OAAO,CAAA;AAC1C","file":"chunk-AXKXNYRT.js","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/** Set once by `start()`. False ⇒ the host opted out of ALL page observation — every\n * exported entry point below that would otherwise read or send the page checks this. */\nlet pageContextOn = true;\n\n/**\n * A host callback that returns the DECLARED page context on demand — 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/* ─────────────────────────── teardown state ───────────────────────────── */\n\n/**\n * Everything below is module-global bookkeeping so `stop()` (see `start()`, bottom of\n * file) can undo exactly what `start()`/`watchNavigation()` installed — 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` — 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`) — 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/* ─────────────────────────── 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 */\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 — 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 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 — 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 NOW, so a turn assembled\n * right after carries the current context rather than the context as of the last route\n * change. No-op when page observation is off.\n */\nexport function provideContext() {\n void publishContext();\n}\n\n/* ─────────────────────── artifact grants (backend-only) ────────────────── */\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\nfunction readArtifactGrants(): ArtifactGrantSrc[] {\n if (!widgetOrigin) return [];\n const srcs = Array.from(document.querySelectorAll('iframe')).map(\n (f) => f.getAttribute('src') || '',\n );\n return grantsFromIframeSrcs(srcs, widgetOrigin);\n}\n\nfunction publishArtifactGrants() {\n send?.({ type: 'host.artifactGrants', grants: readArtifactGrants() });\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 void publishContext();\n publishArtifactGrants();\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 — 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/* ─────────────────────────── 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 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 —\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/* ───────────────────────────── snapshot ───────────────────────────────── */\n\nlet snapshotSeq = 0;\n\nexport async function sendSnapshot(emit: Send) {\n // pageContext: false ⇒ no snapshot, ever — a `widget.requestSnapshot` must not be\n // able to reintroduce the page observation the host explicitly turned off.\n if (!pageContextOn) return;\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 — 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 // Mirrors sendSnapshot's guard: a `widget.readRegion` for a ref minted before\n // opt-out must not pull a live DOM subtree just because the ref is still\n // resolvable (see refs.ts's `clearRefs`, which `stop()` also uses as a backstop).\n if (!pageContextOn) 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/* ───────────────────────────── 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/* ───────────────────────────── stop / start ───────────────────────────── */\n\n/**\n * The opposite number of `start()` — 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 — 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) — 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 — 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 — see\n // loadSnapshotModule's doc comment.\n snapshotModule?.clearRefs();\n}\n\n/**\n * @param pageContext Whether to observe the host page at all. Default `true`. False is\n * the loader's `pageContext: false` opt-out reaching all the way down here: skip every\n * bit of page reading below — no declared/found context, no artifact grants, no nav/\n * click/submit/change/focus observers — so there is nothing to send and nothing that\n * could later be asked for (see `widget.requestSnapshot` in loader.ts). Theme detection\n * is unaffected: it reads an OS media query, never the page, so it isn't page context.\n */\nexport function start(\n emit: Send,\n origin?: string,\n pageContext = 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 pageContextOn = pageContext;\n contextProvider = provider;\n\n if (pageContextOn) {\n void publishContext();\n publishArtifactGrants();\n watchNavigation();\n\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 — 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 const theme = matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n emit({ type: 'host.theme', mode: theme });\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var c="";var p=null,q=0,l=[],w="",g=!0,b,h=null,y=null,v=null,A=null,F=[/\b[\w.+-]+@[\w-]+\.[\w.]{2,}\b/g,/\b(?:\d[ -]?){13,19}\b/g,/\b\d{3}[- ]?\d{2}[- ]?\d{4}\b/g,/\b\d{9,}\b/g,/(?:\+?\d{1,2}[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}\b/g,/\b(?:sk|pk|rk|ak)_(?:live|test)_[A-Za-z0-9]{8,}\b/g,/\beyJ[\w-]+\.[\w-]+\.[\w-]+\b/g];function s(t){let e=t;for(let n of F)e=e.replace(n,"[redacted]");return e}function x(t){if(t.closest("[data-mf-private]"))return!0;if(t.tagName==="INPUT"){let n=t.type;if(n==="password"||n==="hidden")return!0}return!1}function L(t){let e=t.match(/^\/(?:embed\/)?artifacts\/(.+?)\/?$/);return e?decodeURIComponent(e[1]):null}function N(){if(!c)return[];let t=[];for(let e of Array.from(document.querySelectorAll("iframe"))){let n;try{n=new URL(e.getAttribute("src")||"",location.href)}catch{continue}if(n.origin!==c)continue;let r=L(n.pathname);r&&(t.some(o=>o.id===r)||t.push({kind:"artifact",id:r,label:s(e.getAttribute("title")||"")||r}))}return t}function $(){return Array.from(document.querySelectorAll("iframe")).filter(t=>{try{let e=new URL(t.getAttribute("src")||"",location.href);return e.origin!==location.origin&&e.origin!==c}catch{return!1}}).length}function T(t){let e=N(),n=$();return{url:location.origin+location.pathname,path:location.pathname,title:s(document.title),locale:document.documentElement.lang||void 0,...t,entities:[...t.entities??[],...e],data:{...t.data??{},...n?{opaque_frames:n}:{}}}}function J(){return T(window.matterfact?.context??{})}async function U(){let t=window.matterfact;if(b){let e=await b();if(e)return e}if(t?.getPageContext){let e=await t.getPageContext();if(e)return e}return t?.context??{}}async function C(){if(!g)return;let t=await U();p?.({type:"host.context",context:T(t)})}function Z(){C()}function O(t,e){let n=[];for(let r of t){let o;try{o=new URL(r||"",location.href)}catch{continue}if(o.origin!==e)continue;let i=L(o.pathname);if(!i)continue;let a=o.searchParams.get("owner")||"",P=o.searchParams.get("t")||"";!a||!P||n.some(M=>M.id===i)||n.push({id:i,owner:a,token:P})}return n}function G(){if(!c)return[];let t=Array.from(document.querySelectorAll("iframe")).map(e=>e.getAttribute("src")||"");return O(t,c)}function k(){p?.({type:"host.artifactGrants",grants:G()})}function E(t){l.push({...t,seq:++q,ts:Date.now()}),l.length>40&&l.shift(),p?.({type:"host.activity",events:[l[l.length-1]]})}function _(t){let e=t.getAttribute("aria-label");if(e)return e;let n=t.id;if(n){let a=document.querySelector(`label[for="${CSS.escape(n)}"]`)?.textContent?.trim();if(a)return a}let r=t.closest("label")?.textContent?.trim();if(r)return r;let o=t.getAttribute("placeholder");return o||""}var X=new Set(["INPUT","SELECT","TEXTAREA"]);function u(t){let e=t.getAttribute("role")||t.tagName.toLowerCase(),n=t.getAttribute("aria-label")||(X.has(t.tagName)?_(t):t.innerText?.trim().slice(0,60))||t.getAttribute("title")||"";return n?`${e} "${s(n)}"`:e}var B='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]';function I(t){let e=t.target;if(!e||!(e instanceof Element))return;let n=e.closest("label"),o=(n?n.getAttribute("for")&&document.getElementById(n.getAttribute("for"))||n.querySelector("input,select,textarea"):null)??e.closest(B);!o||x(o)||E({type:"click",summary:`clicked ${u(o)}`})}function H(t){let e=t.target;!e||x(e)||E({type:"submit",summary:`submitted ${u(e)}`})}function R(t){let e=t.target;if(!e||!(e instanceof Element)||x(e))return;let n=e.tagName,r=e.type;if(n==="INPUT"&&(r==="password"||r==="hidden"))return;let o=`changed ${u(e)}`;if(n==="SELECT"){let i=e.selectedOptions[0]?.text;i&&(o=`${u(e)} \u2192 "${s(i)}"`)}else(r==="checkbox"||r==="radio")&&(o=`${e.checked?"checked":"unchecked"} ${u(e)}`);E({type:"input",summary:o})}function D(){let t=()=>{let e=location.pathname;e!==w&&(w=e,E({type:"nav",summary:`navigated to ${e}`}),C(),k())};h=t;for(let e of["pushState","replaceState"]){let n=history[e];e==="pushState"?y=n:v=n,history[e]=function(...r){let o=n.apply(this,r);return t(),o}}window.addEventListener("popstate",t)}var d={};async function V(){let t={},e=window.getSelection?.();if(e&&!e.isCollapsed){let i=e.anchorNode?.parentElement??null;if(!i||!i.closest("[data-mf-private]")){let a=e.toString().trim().slice(0,500);a&&(t.selection=s(a))}}let n=document.activeElement;if(n&&n!==document.body&&!x(n)&&!n.closest("[data-mf-private]")){let{snapshot:i}=await S();t.focused={label:s(W(n)),role:n.getAttribute("role")||n.tagName.toLowerCase()}}let r=document.documentElement,o=r.scrollHeight-r.clientHeight;return t.scroll=o>0?Math.round(r.scrollTop/o*100)/100:0,t}function W(t){return u(t)}async function S(){let t=await import("./chunk-4Q2ROXLR.js");return A=t,t}var f=null;function m(){f||(f=setTimeout(async()=>{f=null,d=await V(),p?.({type:"host.focus",focus:d})},250))}var Y=0;async function j(t){if(!g)return;let{snapshot:e}=await S(),{yaml:n,truncated:r,visibleRefs:o}=e();t({type:"host.snapshot",snapshot:{yaml:s(n),seq:++Y,truncated:r}}),d={...d,visibleRefs:o},t({type:"host.focus",focus:d})}async function K(t,e){if(!g)return;let{snapshotRegion:n,resolveRef:r}=await S(),o=r(t);if(!o){e({type:"host.region",ref:t,yaml:"(this element is no longer on the page)"});return}let{yaml:i}=n(o);e({type:"host.region",ref:t,yaml:s(i)})}async function Q(t,e){e({type:"host.toolResult",callId:t.callId,ok:!1,error:"Host tools are read-only in this version; no action was taken."})}function z(){document.removeEventListener("click",I,{capture:!0}),document.removeEventListener("submit",H,{capture:!0}),document.removeEventListener("change",R,{capture:!0}),document.removeEventListener("selectionchange",m),document.removeEventListener("focusin",m,{capture:!0}),window.removeEventListener("scroll",m,{capture:!0}),h&&(window.removeEventListener("popstate",h),h=null),y&&(history.pushState=y,y=null),v&&(history.replaceState=v,v=null),f&&(clearTimeout(f),f=null),p=null,b=void 0,l.length=0,d={},c="",A?.clearRefs()}function tt(t,e,n=!0,r){z(),p=t,c=e||"",w=location.pathname,g=n,b=r,g&&(C(),k(),D(),document.addEventListener("click",I,{capture:!0,passive:!0}),document.addEventListener("submit",H,{capture:!0,passive:!0}),document.addEventListener("change",R,{capture:!0,passive:!0}),document.addEventListener("selectionchange",m,{passive:!0}),document.addEventListener("focusin",m,{capture:!0,passive:!0}),window.addEventListener("scroll",m,{capture:!0,passive:!0}));let o=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";t({type:"host.theme",mode:o})}export{s as a,x as b,L as c,T as d,J as e,Z as f,O as g,j as h,K as i,Q as j,z as k,tt as l};
|
|
2
|
+
//# sourceMappingURL=chunk-D7R6WVHG.js.map
|