@matterfact/embed 0.11.3 → 0.13.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.
Files changed (44) hide show
  1. package/README.md +41 -0
  2. package/dist/chunk-C7DXO37G.js +2 -0
  3. package/dist/{chunk-CTZEDOH7.js → chunk-JLJG3MDX.js} +101 -51
  4. package/dist/chunk-JLJG3MDX.js.map +1 -0
  5. package/dist/chunk-QZCUQZJK.js +3 -0
  6. package/dist/chunk-QZCUQZJK.js.map +7 -0
  7. package/dist/{chunk-AANODHBV.js → chunk-S6OT47DL.js} +100 -49
  8. package/dist/chunk-S6OT47DL.js.map +1 -0
  9. package/dist/{chunk-JO3GWFMJ.js → chunk-UA4Y2O64.js} +2 -2
  10. package/dist/{context-FR7VFENN.js → context-DAXACLSP.js} +3 -3
  11. package/dist/{context-FR7VFENN.js.map → context-DAXACLSP.js.map} +1 -1
  12. package/dist/{context-IK5MECUW.js → context-IJK345PN.js} +4 -2
  13. package/dist/embed.js +1 -1
  14. package/dist/embed.js.map +3 -3
  15. package/dist/index.cjs +167 -53
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +83 -10
  18. package/dist/index.d.ts +83 -10
  19. package/dist/index.js +63 -6
  20. package/dist/index.js.map +1 -1
  21. package/dist/react.cjs +159 -52
  22. package/dist/react.cjs.map +1 -1
  23. package/dist/react.d.cts +29 -2
  24. package/dist/react.d.ts +29 -2
  25. package/dist/react.js +54 -5
  26. package/dist/react.js.map +1 -1
  27. package/dist/{snapshot-2V5SDSH2.js → snapshot-EVBNVVCT.js} +2 -2
  28. package/dist/{snapshot-Y5BF2UJR.js → snapshot-P5SVKSPB.js} +3 -3
  29. package/dist/{snapshot-Y5BF2UJR.js.map → snapshot-P5SVKSPB.js.map} +1 -1
  30. package/examples/embed-demo/.env.example +7 -3
  31. package/examples/embed-demo/README.md +25 -4
  32. package/examples/embed-demo/src/App.tsx +67 -7
  33. package/examples/embed-demo/src/styles.css +52 -0
  34. package/examples/embed-demo/vite.config.ts +3 -2
  35. package/package.json +1 -1
  36. package/dist/chunk-AANODHBV.js.map +0 -1
  37. package/dist/chunk-CTZEDOH7.js.map +0 -1
  38. package/dist/chunk-SKJFF7RD.js +0 -2
  39. package/dist/chunk-Y7I25VHL.js +0 -3
  40. package/dist/chunk-Y7I25VHL.js.map +0 -7
  41. /package/dist/{chunk-SKJFF7RD.js.map → chunk-C7DXO37G.js.map} +0 -0
  42. /package/dist/{chunk-JO3GWFMJ.js.map → chunk-UA4Y2O64.js.map} +0 -0
  43. /package/dist/{context-IK5MECUW.js.map → context-IJK345PN.js.map} +0 -0
  44. /package/dist/{snapshot-2V5SDSH2.js.map → snapshot-EVBNVVCT.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- import{a as re,b as P}from"./chunk-Y7I25VHL.js";var Be=Object.prototype.toString;function ie(e){return typeof e=="function"||Be.call(e)==="[object Function]"}function Fe(e){var t=Number(e);return isNaN(t)?0:t===0||!isFinite(t)?t:(t>0?1:-1)*Math.floor(Math.abs(t))}var Ke=Math.pow(2,53)-1;function ze(e){var t=Fe(e);return Math.min(Math.max(t,0),Ke)}function b(e,t){var n=Array,r=Object(e);if(e==null)throw new TypeError("Array.from requires an array-like object - not null or undefined");if(typeof t<"u"&&!ie(t))throw new TypeError("Array.from: when provided, the second argument must be a function");for(var a=ze(r.length),o=ie(n)?Object(new n(a)):new Array(a),l=0,u;l<a;)u=r[l],t?o[l]=t(u,l):o[l]=u,l+=1;return o.length=a,o}function D(e){"@babel/helpers - typeof";return D=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(e)}function Ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ae(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,oe(r.key),r)}}function Qe(e,t,n){return t&&ae(e.prototype,t),n&&ae(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Je(e,t,n){return t=oe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oe(e){var t=Ze(e,"string");return D(t)=="symbol"?t:t+""}function Ze(e,t){if(D(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(D(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var et=(function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];Ye(this,e),Je(this,"items",void 0),this.items=t}return Qe(e,[{key:"add",value:function(n){return this.has(n)===!1&&this.items.push(n),this}},{key:"clear",value:function(){this.items=[]}},{key:"delete",value:function(n){var r=this.items.length;return this.items=this.items.filter(function(a){return a!==n}),r!==this.items.length}},{key:"forEach",value:function(n){var r=this;this.items.forEach(function(a){n(a,a,r)})}},{key:"has",value:function(n){return this.items.indexOf(n)!==-1}},{key:"size",get:function(){return this.items.length}}])})(),le=typeof Set>"u"?Set:et;function d(e){var t;return(t=e.localName)!==null&&t!==void 0?t:e.tagName.toLowerCase()}var tt={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",form:"form",footer:"contentinfo",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",header:"banner",hr:"separator",html:"document",legend:"legend",li:"listitem",math:"math",main:"main",menu:"list",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",progress:"progressbar",section:"region",summary:"button",table:"table",tbody:"rowgroup",textarea:"textbox",tfoot:"rowgroup",td:"cell",th:"columnheader",thead:"rowgroup",tr:"row",ul:"list"},nt={caption:new Set(["aria-label","aria-labelledby"]),code:new Set(["aria-label","aria-labelledby"]),deletion:new Set(["aria-label","aria-labelledby"]),emphasis:new Set(["aria-label","aria-labelledby"]),generic:new Set(["aria-label","aria-labelledby","aria-roledescription"]),insertion:new Set(["aria-label","aria-labelledby"]),none:new Set(["aria-label","aria-labelledby"]),paragraph:new Set(["aria-label","aria-labelledby"]),presentation:new Set(["aria-label","aria-labelledby"]),strong:new Set(["aria-label","aria-labelledby"]),subscript:new Set(["aria-label","aria-labelledby"]),superscript:new Set(["aria-label","aria-labelledby"])};function rt(e,t){return["aria-atomic","aria-busy","aria-controls","aria-current","aria-description","aria-describedby","aria-details","aria-dropeffect","aria-flowto","aria-grabbed","aria-hidden","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"].some(function(n){var r;return e.hasAttribute(n)&&!((r=nt[t])!==null&&r!==void 0&&r.has(n))})}function ue(e,t){return rt(e,t)}function C(e){var t=at(e);if(t===null||_.indexOf(t)!==-1){var n=it(e);if(_.indexOf(t||"")===-1||ue(e,n||""))return n}return t}function it(e){var t=tt[d(e)];if(t!==void 0)return t;switch(d(e)){case"a":case"area":case"link":if(e.hasAttribute("href"))return"link";break;case"img":return e.getAttribute("alt")===""&&!ue(e,"img")?"presentation":"img";case"input":{var n=e,r=n.type;switch(r){case"button":case"image":case"reset":case"submit":return"button";case"checkbox":case"radio":return r;case"range":return"slider";case"email":case"tel":case"text":case"url":return e.hasAttribute("list")?"combobox":"textbox";case"search":return e.hasAttribute("list")?"combobox":"searchbox";case"number":return"spinbutton";default:return null}}case"select":return e.hasAttribute("multiple")||e.size>1?"listbox":"combobox"}return null}function at(e){var t=e.getAttribute("role");if(t!==null){var n=t.trim().split(" ")[0];if(n.length>0)return n}return null}var _=["presentation","none"];function s(e){return e!==null&&e.nodeType===e.ELEMENT_NODE}function B(e){return s(e)&&d(e)==="caption"}function H(e){return s(e)&&d(e)==="input"}function se(e){return s(e)&&d(e)==="optgroup"}function fe(e){return s(e)&&d(e)==="select"}function ce(e){return s(e)&&d(e)==="table"}function de(e){return s(e)&&d(e)==="textarea"}function me(e){var t=e.ownerDocument===null?e:e.ownerDocument,n=t.defaultView;if(n===null)throw new TypeError("no window available");return n}function pe(e){return s(e)&&d(e)==="fieldset"}function be(e){return s(e)&&d(e)==="legend"}function ge(e){return s(e)&&d(e)==="slot"}function ot(e){return s(e)&&e.ownerSVGElement!==void 0}function he(e){return s(e)&&d(e)==="svg"}function ye(e){return ot(e)&&d(e)==="title"}function $(e,t){if(s(e)&&e.hasAttribute(t)){var n=e.getAttribute(t).split(" "),r=e.getRootNode?e.getRootNode():e.ownerDocument;return n.map(function(a){return r.getElementById(a)}).filter(function(a){return a!==null})}return[]}function g(e,t){return s(e)?t.indexOf(C(e))!==-1:!1}function lt(e){return e.trim().replace(/\s\s+/g," ")}function ut(e,t){if(!s(e))return!1;if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!0;var n=t(e);return n.getPropertyValue("display")==="none"||n.getPropertyValue("visibility")==="hidden"}function st(e){return g(e,["button","combobox","listbox","textbox"])||Ee(e,"range")}function Ee(e,t){if(!s(e))return!1;switch(t){case"range":return g(e,["meter","progressbar","scrollbar","slider","spinbutton"]);default:throw new TypeError("No knowledge about abstract role '".concat(t,"'. This is likely a bug :("))}}function ve(e,t){var n=b(e.querySelectorAll(t));return $(e,"aria-owns").forEach(function(r){n.push.apply(n,b(r.querySelectorAll(t)))}),n}function ft(e){return fe(e)?e.selectedOptions||ve(e,"[selected]"):ve(e,'[aria-selected="true"]')}function ct(e){return g(e,_)}function dt(e){return B(e)}function mt(e){return g(e,["button","cell","checkbox","columnheader","gridcell","heading","label","legend","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"])}function pt(e){return!1}function bt(e){return H(e)||de(e)?e.value:e.textContent||""}function Se(e){var t=e.getPropertyValue("content");return/^["'].*["']$/.test(t)?t.slice(1,-1):""}function xe(e){var t=d(e);return t==="button"||t==="input"&&e.getAttribute("type")!=="hidden"||t==="meter"||t==="output"||t==="progress"||t==="select"||t==="textarea"}function Ae(e){if(xe(e))return e;var t=null;return e.childNodes.forEach(function(n){if(t===null&&s(n)){var r=Ae(n);r!==null&&(t=r)}}),t}function gt(e){if(e.control!==void 0)return e.control;var t=e.getAttribute("for");return t!==null?e.ownerDocument.getElementById(t):Ae(e)}function ht(e){var t=e.labels;if(t===null)return t;if(t!==void 0)return b(t);if(!xe(e))return null;var n=e.ownerDocument;return b(n.querySelectorAll("label")).filter(function(r){return gt(r)===e})}function yt(e){var t=e.assignedNodes();return t.length===0?b(e.childNodes):t}function F(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=new le,r=typeof Map>"u"?void 0:new Map,a=me(e),o=t.compute,l=o===void 0?"name":o,u=t.computedStyleSupportsPseudoElements,m=u===void 0?t.getComputedStyle!==void 0:u,p=t.getComputedStyle,x=p===void 0?a.getComputedStyle.bind(a):p,M=t.hidden,R=M===void 0?!1:M,I=function(f,c){if(c!==void 0)throw new Error("use uncachedGetComputedStyle directly for pseudo elements");if(r===void 0)return x(f);var h=r.get(f);if(h)return h;var y=x(f,c);return r.set(f,y),y};function W(i,f){var c="";if(s(i)&&m){var h=x(i,"::before"),y=Se(h);c="".concat(y," ").concat(c)}var S=ge(i)?yt(i):b(i.childNodes).concat($(i,"aria-owns"));if(S.forEach(function(v){var N=A(v,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0}),E=s(v)?I(v).getPropertyValue("display"):"inline",k=E!=="inline"?" ":"";c+="".concat(k).concat(N).concat(k)}),s(i)&&m){var T=x(i,"::after"),w=Se(T);c="".concat(c," ").concat(w)}return c.trim()}function O(i,f){var c=i.getAttributeNode(f);return c!==null&&!n.has(c)&&c.value.trim()!==""?(n.add(c),c.value):null}function Ue(i){return s(i)?O(i,"title"):null}function Xe(i){if(!s(i))return null;if(pe(i)){n.add(i);for(var f=b(i.childNodes),c=0;c<f.length;c+=1){var h=f[c];if(be(h))return A(h,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(ce(i)){n.add(i);for(var y=b(i.childNodes),S=0;S<y.length;S+=1){var T=y[S];if(B(T))return A(T,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(he(i)){n.add(i);for(var w=b(i.childNodes),v=0;v<w.length;v+=1){var N=w[v];if(ye(N))return N.textContent}return null}else if(d(i)==="img"||d(i)==="area"){var E=O(i,"alt");if(E!==null)return E}else if(se(i)){var k=O(i,"label");if(k!==null)return k}if(H(i)&&(i.type==="button"||i.type==="submit"||i.type==="reset")){var Z=O(i,"value");if(Z!==null)return Z;if(i.type==="submit")return"Submit";if(i.type==="reset")return"Reset"}var U=ht(i);if(U!==null&&U.length!==0)return n.add(i),b(U).map(function(X){return A(X,{isEmbeddedInLabel:!0,isReferenced:!1,recursion:!0})}).filter(function(X){return X.length>0}).join(" ");if(H(i)&&i.type==="image"){var ee=O(i,"alt");if(ee!==null)return ee;var te=O(i,"title");return te!==null?te:"Submit Query"}if(g(i,["button"])){var ne=W(i,{isEmbeddedInLabel:!1,isReferenced:!1});if(ne!=="")return ne}return null}function A(i,f){if(n.has(i))return"";if(!R&&ut(i,I)&&!f.isReferenced)return n.add(i),"";var c=s(i)?i.getAttributeNode("aria-labelledby"):null,h=c!==null&&!n.has(c)?$(i,"aria-labelledby"):[];if(l==="name"&&!f.isReferenced&&h.length>0)return n.add(c),h.map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!0,recursion:!1})}).join(" ");var y=f.recursion&&st(i)&&l==="name";if(!y){var S=(s(i)&&i.getAttribute("aria-label")||"").trim();if(S!==""&&l==="name")return n.add(i),S;if(!ct(i)){var T=Xe(i);if(T!==null)return n.add(i),T}}if(g(i,["menu"]))return n.add(i),"";if(y||f.isEmbeddedInLabel||f.isReferenced){if(g(i,["combobox","listbox"])){n.add(i);var w=ft(i);return w.length===0?H(i)?i.value:"":b(w).map(function(E){return A(E,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0})}).join(" ")}if(Ee(i,"range"))return n.add(i),i.hasAttribute("aria-valuetext")?i.getAttribute("aria-valuetext"):i.hasAttribute("aria-valuenow")?i.getAttribute("aria-valuenow"):i.getAttribute("value")||"";if(g(i,["textbox"]))return n.add(i),bt(i)}if(mt(i)||s(i)&&f.isReferenced||dt(i)||pt(i)){var v=W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});if(v!=="")return n.add(i),v}if(i.nodeType===i.TEXT_NODE)return n.add(i),i.textContent||"";if(f.recursion)return n.add(i),W(i,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});var N=Ue(i);return N!==null?(n.add(i),N):(n.add(i),"")}return lt(A(e,{isEmbeddedInLabel:!1,isReferenced:l==="description",recursion:!1}))}function vt(e){return g(e,["caption","code","deletion","emphasis","generic","insertion","none","paragraph","presentation","strong","subscript","superscript"])}function K(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return vt(e)?"":F(e,t)}function Te(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r,o=n.isSubtreeInaccessible,l=o===void 0?St:o;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");if(a(e).visibility==="hidden")return!0;for(var u=e;u;){if(l(u,{getComputedStyle:a}))return!0;u=u.parentElement}return!1}function St(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.getComputedStyle,a=r===void 0?(t=e.ownerDocument.defaultView)===null||t===void 0?void 0:t.getComputedStyle:r;if(typeof a!="function")throw new TypeError("Owner document of the element needs to have an associated window.");return e.hidden===!0||e.getAttribute("aria-hidden")==="true"||a(e).display==="none"}var Et=new Set(["button","fieldset","input","optgroup","option","select","textarea"]);function V(e){var t=d(e);return Et.has(t)&&e.hasAttribute("disabled")?!0:e.getAttribute("aria-disabled")==="true"}function Ne(){let e=new WeakMap;return((t,n)=>{if(n)return window.getComputedStyle(t,n);let r=e.get(t);return r||(r=window.getComputedStyle(t),e.set(t,r)),r})}function Le(){return document.documentElement.getClientRects().length>0}function Re(e,t,n){let r=t.display;if(r==="none")return!1;let a=t.visibility;if(a==="hidden"||a==="collapse"||Number(t.opacity)===0)return!1;if(n&&r!=="contents"){let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0||e.getClientRects().length===0||o.right<-2e3||o.bottom<-2e3)return!1}return!0}function Oe(e){return e.pointerEvents!=="none"}var xt=new Set(["button","checkbox","combobox","link","listbox","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]),At=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","SUMMARY"]);function G(e){let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function Ce(e,t,n,r){let a=e.tagName;if(a==="A"&&e.hasAttribute("href")||At.has(a)||t!==null&&xt.has(t))return!0;let o=e.getAttribute("tabindex");return!!(o!==null&&Number(o)>=0||G(e)||n.cursor==="pointer"&&r?.cursor!=="pointer")}var Me=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"]),Tt=new Set(["textbox","searchbox","spinbutton"]),wt=new Set(["INPUT","TEXTAREA"]);function Ie(e){return wt.has(e.tagName)||G(e)}function Nt(e,t){let n=e.tagName;return n==="INPUT"||n==="TEXTAREA"?Tt.has(t)?(e.value??"").length>0:!1:G(e)?(e.textContent??"").trim().length>0:!1}function we(e,t){let n=e.getAttribute(t);return n==="true"?"true":n==="mixed"?"mixed":null}function ke(e,t){let n=[],r=e.tagName;if(r==="INPUT"&&(t==="checkbox"||t==="radio"))e.checked&&n.push("[checked]");else{let l=we(e,"aria-checked");l==="mixed"?n.push("[checked=mixed]"):l==="true"&&n.push("[checked]")}V(e)&&n.push("[disabled]");let a=e.getAttribute("aria-expanded");if(a==="true"||a==="false")a==="true"&&n.push("[expanded]");else if(r==="SUMMARY"){let l=e.parentElement;l?.tagName==="DETAILS"&&l.open&&n.push("[expanded]")}if(t==="heading"){let l=e.getAttribute("aria-level"),u=Number(l||r[1]);Number.isFinite(u)&&u>0&&n.push(`[level=${u}]`)}let o=we(e,"aria-pressed");return o==="mixed"?n.push("[pressed=mixed]"):o==="true"&&n.push("[pressed]"),e.getAttribute("aria-selected")==="true"&&n.push("[selected]"),Nt(e,t)&&n.push("[filled]"),n.join(" ")}function Pe(e){return G(e)?"textbox":C(e)}var z='input,textarea,select,[contenteditable=""],[contenteditable="true"],[aria-valuetext],[data-mf-private]';function Lt(e){let t=e.getAttribute("aria-labelledby");if(t){for(let n of t.split(/\s+/)){if(!n)continue;let r=e.ownerDocument.getElementById(n);if(r&&(r.matches(z)||r.querySelector(z)))return!0}return!1}return e.hasAttribute("aria-label")?!1:e.querySelector(z)!==null}function De(e,t){let n=K(e,{getComputedStyle:t,computedStyleSupportsPseudoElements:!1});return n?Lt(e)?e.getAttribute("aria-label")||"":n:""}var Rt=0,q=0,Y=new WeakMap,j=new Map;function _e(){q++,j.clear()}function He(e,t,n){let r=`${t} ${n}`,a=Y.get(e);return!a||a.key!==r?(a={id:`e${++Rt}`,key:r,gen:q},Y.set(e,a)):a.gen=q,j.set(a.id,e),a.id}function Ot(e){let t=j.get(e);if(!t)return null;if(!t.isConnected)return j.delete(e),null;let n=Y.get(t);return!n||n.id!==e||n.gen!==q?null:t}function Ct(){j.clear()}var Mt=4e3,It=800,kt=120,Pt=120,Ge=25,$e=new Set(["generic","presentation","none"]),Dt=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","SVG","HEAD","LINK","META","BASE"]);function L(e){return e.nodes>=Mt||e.lines>=It?(e.truncated=!0,!1):!0}function _t(e){return e.id==="matterfact-embed"||e.hasAttribute("data-mf-embed")}function Ht(e,t,n){return e.getAttribute("aria-hidden")==="true"||e.hasAttribute("hidden")||e.hasAttribute("inert")?!0:!Re(e,t,n)}function $t(e){if(e.shadowRoot)return e.shadowRoot.childNodes;if(e.tagName==="SLOT"){let t=e.assignedNodes({flatten:!0});if(t.length)return t}return e.childNodes}function Q(e,t,n,r){let a=$t(e);for(let o=0;o<a.length;o++){let l=a[o];l&&Wt(l,t,n,r)}}function Vt(e,t,n){let r=(e.nodeValue??"").replace(/\s+/g," ").trim();r&&(Me.has(t.role)||L(n)&&(n.lines++,t.children.push(r)))}function J(e){let t=e.matches(":disabled")||V(e);return{role:"option",name:(e.label||e.textContent||"").trim(),props:(t?" [disabled]":"")+(e.selected?" [selected]":""),children:[]}}function jt(e,t,n){let r=e.options,a=Math.min(r.length,Ge);for(let m=0;m<a;m++){if(!L(n))return;let p=r[m];!p||P(p)||(n.lines++,t.children.push(J(p)))}let o=0,l=e.selectedOptions;for(let m=0;m<l.length;m++){let p=l[m];if(p&&p.index>=a&&!P(p)){if(!L(n))return;n.lines++,t.children.push(J(p)),o++}}let u=r.length-a-o;u>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${u} more options)`))}function Gt(e,t,n){let r=e.list;if(!r)return;let a=r.options,o=Math.min(a.length,Ge);for(let u=0;u<o;u++){if(!L(n))return;let m=a[u];!m||P(m)||(n.lines++,t.children.push(J(m)))}let l=a.length-o;l>0&&L(n)&&(n.lines++,t.children.push(`\u2026 (+${l} more options)`))}function qt(e,t,n,r){if(!L(r)||Dt.has(e.tagName)||_t(e)||P(e))return;r.nodes++;let a=r.styleOf(e);if(Ht(e,a,r.layout))return;let o=Pe(e),l=o===null||$e.has(o),u=Ce(e,o,a,n);if(l&&!u){Q(e,t,a,r);return}let m=o===null||$e.has(o)?"generic":o,p=De(e,r.styleOf),x="";if(u&&Oe(a)){let I=He(e,m,p);x=` [ref=${I}]`,r.onRef?.(I,e)}let M=ke(e,m),R={role:m,name:p,props:(M?` ${M}`:"")+x,children:[]};if(r.lines++,t.children.push(R),e.tagName==="SELECT"){jt(e,R,r);return}e.tagName==="INPUT"&&e.list&&Gt(e,R,r),!Ie(e)&&Q(e,R,a,r)}function Wt(e,t,n,r){e.nodeType===3?Vt(e,t,r):e.nodeType===1&&qt(e,t,n,r)}function Ve(e,t){let n=e.replace(/\s+/g," ").trim(),r=re(n);return r.length>t?`${r.slice(0,t-1)}\u2026`:r}function je(e){return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function qe(e,t,n){let r=" ".repeat(t);for(let a of e){if(typeof a=="string"){n.push(`${r}- text: ${je(Ve(a,Pt))}`);continue}let o=a.name?` ${je(Ve(a.name,kt))}`:"",l=`${r}- ${a.role}${o}${a.props}`;a.children.length?(n.push(`${l}:`),qe(a.children,t+1,n)):n.push(l)}}function We(e,t){let n=Ne(),r={styleOf:n,layout:Le(),nodes:0,lines:0,truncated:!1,onRef:t};if(Te(e,{getComputedStyle:n}))return{yaml:"",truncated:!1};let a={role:"",name:"",props:"",children:[]};Q(e,a,n(e),r);let o=[];return qe(a.children,0,o),r.truncated&&o.length&&(o[o.length-1]='- text: "\u2026 (snapshot truncated \u2014 more of the page is below)"'),{yaml:o.join(`
1
+ import{a as re,b as P}from"./chunk-QZCUQZJK.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-JO3GWFMJ.js.map
3
+ //# sourceMappingURL=chunk-UA4Y2O64.js.map
@@ -1,3 +1,3 @@
1
- export { artifactIdFromPath, buildPageContext, callTool, grantsFromIframeSrcs, isPrivate, navigateHost, provideContext, readDeclaredGrants, readPageContext, redact, sendRegion, sendSnapshot, start, stop } from './chunk-CTZEDOH7.js';
2
- //# sourceMappingURL=context-FR7VFENN.js.map
3
- //# sourceMappingURL=context-FR7VFENN.js.map
1
+ export { artifactIdFromPath, buildPageContext, callTool, grantsFromIframeSrcs, isPrivate, navigateHost, provideContext, readDeclaredGrants, readPageContext, redact, sendRegion, sendSnapshot, setPageContextMax, start, stop } from './chunk-JLJG3MDX.js';
2
+ //# sourceMappingURL=context-DAXACLSP.js.map
3
+ //# sourceMappingURL=context-DAXACLSP.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"context-FR7VFENN.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"context-DAXACLSP.js"}
@@ -12,9 +12,10 @@ import {
12
12
  redact,
13
13
  sendRegion,
14
14
  sendSnapshot,
15
+ setPageContextMax,
15
16
  start,
16
17
  stop
17
- } from "./chunk-AANODHBV.js";
18
+ } from "./chunk-S6OT47DL.js";
18
19
  export {
19
20
  artifactIdFromPath,
20
21
  buildPageContext,
@@ -28,7 +29,8 @@ export {
28
29
  redact,
29
30
  sendRegion,
30
31
  sendSnapshot,
32
+ setPageContextMax,
31
33
  start,
32
34
  stop
33
35
  };
34
- //# sourceMappingURL=context-IK5MECUW.js.map
36
+ //# sourceMappingURL=context-IJK345PN.js.map
package/dist/embed.js CHANGED
@@ -1,2 +1,2 @@
1
- var b="mf-embed";function A(o,e){return{channel:b,protocol:3,...e?{id:e}:{},payload:o}}function C(o){return typeof o=="object"&&o!==null&&o.channel===b}var M=["tl","tr","bl","br"];function l(){return{mode:"dock",corner:"br",x:0,y:0,floatW:420,floatH:640,dockSide:"right",tabY:0,dockW:600}}function h(o,e,t){return Math.min(Math.max(o,e),t)}function R(o,e,t,r,n){return{x:o[1]==="l"?20:r-20-e,y:o[0]==="t"?20:n-20-t}}function m(o,e,t){return o.corner?R(o.corner,56,56,e,t):{x:h(o.x,20,Math.max(20,e-20-56)),y:h(o.y,20,Math.max(20,t-20-56))}}function c(o,e,t){if(o.corner)return o.corner;let r=m(o,e,t);return K(r.x+56/2,r.y+56/2,e,t)}function K(o,e,t,r){return`${e<r/2?"t":"b"}${o<t/2?"l":"r"}`}function Y(o,e,t,r){let n=h(o,20,Math.max(20,t-20-56)),i=h(e,20,Math.max(20,r-20-56));for(let s of M){let d=R(s,56,56,t,r);if(Math.hypot(n-d.x,i-d.y)<=96)return{corner:s,x:n,y:i}}return{corner:null,x:n,y:i}}function y(o,e,t){return o<=64?"left":o+e>=t-64?"right":null}function v(o,e,t){return o.mode==="dock"?{x:o.dockSide==="left"?0:e-44,y:x(o,t)}:m(o,e,t)}function S(o,e,t,r){if(o.mode==="dock"){let s=e?Math.min(Math.max(o.dockW,320),Math.max(0,t-40)):44;return{x:o.dockSide==="left"?0:t-s,w:s}}let n=m(o,t,r);if(!e)return{x:n.x,w:56};let{w:i}=p(o.floatW,o.floatH,t,r,320,420);return{x:c(o,t,r)[1]==="r"?n.x+56-i:n.x,w:i}}function G(o,e,t,r,n,i){let s=Y(o,e,n,i);if(s.corner)return{mode:"float",...s};let d=y(t,r,n);return d?{mode:"dock",dockSide:d,tabY:h(e,0,Math.max(0,i-132))}:{mode:"float",...s}}function p(o,e,t,r,n,i){return{w:Math.min(Math.max(o,n),Math.max(0,t-40)),h:Math.min(Math.max(e,i),Math.max(0,r-40))}}function N(o,e,t,r,n){let i=o[1]==="r"?-1:1,s=o[0]==="b"?-1:1;return{w:e+i*r,h:t+s*n}}function T(o,e,t){return o==="right"?e-t:e+t}function H(o){if(!o)return null;try{let e=JSON.parse(o);if(!e||e.mode!=="float"&&e.mode!=="dock")return null;let t=l(),r=(n,i)=>typeof n=="number"?n:i;return{mode:e.mode,corner:M.includes(e.corner)?e.corner:null,x:r(e.x,t.x),y:r(e.y,t.y),floatW:r(e.floatW,t.floatW),floatH:r(e.floatH,t.floatH),dockSide:e.dockSide==="left"?"left":"right",tabY:r(e.tabY,t.tabY),dockW:r(e.dockW,t.dockW)}}catch{return null}}function L(o){return JSON.stringify(o)}var a=o=>`${o}px`;function $(o,e,t,r,n,i,s){let d=n[1]==="r",f=n[0]==="b",P=d?i-(o+56):o,q=f?s-(e+56):e,k=h(P,20,Math.max(20,i-20-t)),E=h(q,20,Math.max(20,s-20-r));return{top:f?"auto":a(E),bottom:f?a(E):"auto",left:d?"auto":a(k),right:d?a(k):"auto",width:a(t),height:a(r)}}function x(o,e){let t=Math.max(0,e-132);return h(o.tabY||Math.round((e-132)/2),0,t)}function _(o,e,t){let r=o.dockSide==="left";return{top:a(x(o,t)),bottom:"auto",left:r?"0px":"auto",right:r?"auto":"0px",width:a(44),height:a(132)}}function g(o,e,t,r,n,i){let s=m(o,r,n);return $(s.x,s.y,e,t,i??c(o,r,n),r,n)}function I(o,e,t,r,n){let i=o.dockSide==="left";return{top:a(x(o,n)),bottom:"auto",left:i?"0px":"auto",right:i?"auto":"0px",width:a(e),height:a(t)}}function W(o,e,t,r){let n=p(o.floatW,o.floatH,e,t,320,420);return g(o,n.w,n.h,e,t,r)}function B(o,e,t){let r=Math.min(Math.max(o.dockW,320),Math.max(0,e-40)),n=o.dockSide==="left";return{top:"0px",bottom:"0px",height:"auto",left:n?"0px":"auto",right:n?"auto":"0px",width:a(r)}}var Z="https://app.matterfact.com";function ee(){try{return new URLSearchParams(location.search).get("mfdev")==="1"}catch{return!1}}function F(){let o=document.currentScript??document.querySelector('script[data-key][src*="embed"]'),e=o?.dataset.key;if(!e)return console.error("[matterfact] missing data-key on the embed script tag"),null;let t=o?.dataset.container,r=t?document.querySelector(t):null;t&&!r&&console.error(`[matterfact] data-container="${t}" matched nothing; falling back to the corner`);let n=o?.dataset.pageContext?.toLowerCase();return{publishableKey:e,origin:o?.dataset.origin||Z,theme:o?.dataset.theme||"auto",surface:o?.dataset.surface||"",container:r,pageContext:n!=="off"&&n!=="false"&&n!=="0"}}var O="mf.embed.pos",w=class{constructor(e){this.config=e;this.iframe=null;this.shadow=null;this.queue=[];this.ready=!1;this.open=!1;this.geo=l();this.resizeBase=null;this.dockBase=600;this.dragFrom=null;this.dragAt={x:0,y:0};this.dragBox={x:0,w:0};this.dragGrowth=null;this.dragLeftBand=!1;this.context=null;this.hostEl=null;this.ac=0;this.onMessage=e=>{e.origin===this.config.origin&&e.source===this.iframe?.contentWindow&&C(e.data)&&this.handle(e.data.payload)};this.onViewportResize=()=>{this.place()};this.send=e=>{if(!this.ready){this.queue.push(e);return}this.iframe?.contentWindow?.postMessage(A(e),this.config.origin)};this.inline=!!e.container}mount(){let e=document.createElement("div");this.hostEl=e,e.id="matterfact-embed",this.inline?(e.style.cssText=["all: initial","position: relative","display: block","width: 100%","height: 100%","contain: layout style"].join(";"),this.config.container.appendChild(e)):(this.geo=this.readGeometry(),e.style.cssText=["all: initial","position: fixed","z-index: 2147483000","contain: layout style","transition: width .18s ease, height .18s ease, top .18s ease, right .18s ease, bottom .18s ease, left .18s ease"].join(";"),document.body.appendChild(e)),this.shadow=e.attachShadow({mode:"closed"});let t=document.createElement("style");t.textContent=":host{all:initial}iframe{border:0;display:block;width:100%;height:100%;background:transparent}"+(this.inline?"":':host([data-mode="float"]) iframe,:host([data-mode="dock"]) iframe{color-scheme:light dark}:host([data-mode="float"]) iframe{border-radius:12px;box-shadow:0 0 0 1px #00000014,0 8px 40px #00000029}:host([data-mode="dock"]) iframe{box-shadow:0 0 0 1px #00000014,0 8px 40px #00000029}:host([data-mode="dock"][data-flush="right"]) iframe{border-radius:12px 0 0 12px}:host([data-mode="dock"][data-flush="left"]) iframe{border-radius:0 12px 12px 0}'),this.shadow.appendChild(t);let r=document.createElement("iframe");r.title="matterfact assistant",r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads"),r.setAttribute("allow","microphone; clipboard-write"),r.src=`${this.config.origin}/embed/chat?k=${encodeURIComponent(this.config.publishableKey)}&o=${encodeURIComponent(location.origin)}`+(this.config.surface?`&s=${encodeURIComponent(this.config.surface)}`:"")+(ee()||this.config.dev?"&dev=1":"")+(this.inline?"&inline=1":""),this.iframe=r,this.shadow.appendChild(r),window.addEventListener("message",this.onMessage),this.inline||(window.addEventListener("resize",this.onViewportResize),this.place())}__testHandle(e){this.handle(e)}emit(e){let t=globalThis.matterfact?.onEvent;if(typeof t=="function")try{t(e)}catch{}}handle(e){switch(e.type){case"widget.ready":this.ready=!0,this.send({type:"host.ready",protocol:3,origin:location.origin}),this.send({type:"host.theme",mode:this.themeMode()}),this.flush(),this.inline&&this.loadContext(),this.emit({type:"ready"});break;case"widget.setOpen":if(this.emit({type:e.open?"open":"close"}),this.inline)break;this.open=e.open,this.place(),e.open&&this.loadContext();break;case"widget.setMode":if(this.inline)break;this.geo.mode=e.mode,this.writeGeometry(this.geo),this.place();break;case"widget.setDockSide":if(this.inline)break;this.geo.dockSide=e.side,this.writeGeometry(this.geo),this.place();break;case"widget.snapCorner":if(this.inline)break;this.geo.corner=e.corner,this.writeGeometry(this.geo),this.place();break;case"widget.setLauncherRegion":{if(this.inline||this.open)break;let t=window.innerWidth,r=window.innerHeight;if(e.w<=56&&e.h<=56)this.place();else{let n=this.geo.mode==="dock"?I(this.geo,e.w,e.h,t,r):g(this.geo,e.w,e.h,t,r);this.applyBox(n,e.h>56?"menu":"pill")}break}case"widget.resize":if(this.inline)break;this.hostEl&&this.open&&this.geo.mode==="float"&&(this.hostEl.style.height=`${Math.min(e.height,Math.max(0,window.innerHeight-40))}px`);break;case"widget.resizeStart":if(this.inline)break;this.resizeBase={w:this.geo.floatW,h:this.geo.floatH},this.dockBase=this.geo.dockW,this.hostEl&&(this.hostEl.style.transition="none");break;case"widget.resizeMove":{if(this.inline||!this.resizeBase)break;if(this.geo.mode==="dock"){let t=T(this.geo.dockSide,this.dockBase,e.dx);this.geo.dockW=Math.min(Math.max(t,320),Math.max(0,window.innerWidth-40))}else{let t=N(c(this.geo,window.innerWidth,window.innerHeight),this.resizeBase.w,this.resizeBase.h,e.dx,e.dy),r=p(t.w,t.h,window.innerWidth,window.innerHeight,320,420);this.geo.floatW=r.w,this.geo.floatH=r.h}this.place();break}case"widget.resizeEnd":if(this.inline)break;this.resizeBase=null,this.hostEl&&(this.hostEl.style.transition=""),this.writeGeometry(this.geo);break;case"widget.requestContext":this.loadContext().then(t=>t.provideContext());break;case"widget.requestSnapshot":this.loadContext().then(t=>t.sendSnapshot(this.send));break;case"widget.readRegion":this.loadContext().then(t=>t.sendRegion(e.ref,this.send));break;case"widget.callTool":this.loadContext().then(t=>t.callTool(e.call,this.send));break;case"widget.dragStart":if(this.inline)break;this.dragFrom=v(this.geo,window.innerWidth,window.innerHeight),this.dragAt={...this.dragFrom},this.dragLeftBand=!1,this.dragGrowth=c(this.geo,window.innerWidth,window.innerHeight),this.dragBox=S(this.geo,this.open,window.innerWidth,window.innerHeight),this.hostEl&&(this.hostEl.style.transition="none");break;case"widget.dragMove":{if(this.inline||!this.dragFrom)break;let t=window.innerWidth,r=window.innerHeight;this.dragAt={x:this.dragFrom.x+e.dx,y:this.dragFrom.y+e.dy};let n=y(this.dragBox.x+e.dx,this.dragBox.w,t);n||(this.dragLeftBand=!0),n&&(this.dragLeftBand||this.geo.mode==="dock")?(this.geo.mode="dock",this.geo.dockSide=n,this.geo.tabY=Math.max(0,this.dragAt.y)):(this.geo.mode="float",this.geo.corner=null,this.geo.x=this.dragAt.x,this.geo.y=this.dragAt.y),this.place();break}case"widget.dragEnd":{if(this.inline||!this.dragFrom)break;let t=G(this.dragAt.x,this.dragAt.y,this.dragBox.x+(this.dragAt.x-this.dragFrom.x),this.dragBox.w,window.innerWidth,window.innerHeight);this.geo.mode=t.mode,t.mode==="dock"?(this.geo.dockSide=t.dockSide,this.geo.tabY=t.tabY):(this.geo.corner=t.corner,this.geo.x=t.x,this.geo.y=t.y),this.dragFrom=null,this.dragGrowth=null,this.hostEl&&(this.hostEl.style.transition=""),this.place(),this.writeGeometry(this.geo);break}case"widget.resetPos":if(this.inline)break;this.geo=l(),this.writeGeometry(this.geo),this.place();break;case"widget.hide":if(this.inline)break;this.hostEl&&(this.hostEl.style.display="none");break;case"widget.needsAuth":this.emit({type:"auth",phase:"required"}),this.provideAuth();break;case"widget.navigate":this.emit({type:"navigate",href:e.href}),this.loadContext().then(t=>t.navigateHost(e.href));break;case"widget.chat":this.emit({type:"chat",phase:e.phase,chatId:e.chatId});break}}applyBox(e,t){if(!this.hostEl||this.inline)return;let r=this.hostEl.style;r.top=e.top,r.right=e.right,r.bottom=e.bottom,r.left=e.left,r.width=e.width,r.height=e.height,this.hostEl.dataset.mode=t,t==="tab"||t==="dock"?this.hostEl.dataset.flush=this.geo.dockSide:delete this.hostEl.dataset.flush}growthNow(){return this.dragGrowth??c(this.geo,window.innerWidth,window.innerHeight)}place(){let e=window.innerWidth,t=window.innerHeight;if(this.open)this.geo.mode==="dock"?this.applyBox(B(this.geo,e,t),"dock"):this.applyBox(W(this.geo,e,t,this.growthNow()),"float");else{let r=this.geo.mode==="dock";this.applyBox(r?_(this.geo,e,t):g(this.geo,56,56,e,t,this.growthNow()),r?"tab":"launcher")}this.publishGeometry()}publishGeometry(){this.send({type:"host.geometry",mode:this.geo.mode,dockSide:this.geo.dockSide,growth:this.growthNow()})}themeMode(){return this.config.theme==="auto"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":this.config.theme}readGeometry(){try{return H(localStorage.getItem(O))??l()}catch{return l()}}writeGeometry(e){try{localStorage.setItem(O,L(e))}catch{}}async provideAuth(){let e=this.config.authTokenProvider??globalThis.matterfact?.getEmbedAuthToken;if(e&&!(++this.ac>5))try{let t=await e();t&&this.send({type:"host.auth",token:t,expiresAt:0}),this.emit({type:"auth",phase:t?"granted":"failed"})}catch{this.emit({type:"auth",phase:"failed"})}}loadContext(){return this.context??(this.context=import("./chunk-SKJFF7RD.js").then(e=>(e.start(this.send,this.config.origin,this.config.pageContext,this.config.pageContextProvider),this.config.theme!=="auto"&&this.send({type:"host.theme",mode:this.config.theme}),e))),this.context}flush(){let e=this.queue;this.queue=[];for(let t of e)this.send(t)}destroy(){window.removeEventListener("message",this.onMessage),window.removeEventListener("resize",this.onViewportResize),this.hostEl?.remove(),this.hostEl=null,this.iframe=null,this.shadow=null,this.ready=!1,this.context?.then(e=>e.stop())}};function U(o){let e=new w(o);return e.mount(),e}var z=F();if(z){let o=()=>U(z);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o,{once:!0}):o()}
1
+ var y="mf-embed";function C(o,e){return{channel:y,protocol:3,...e?{id:e}:{},payload:o}}function M(o){return typeof o=="object"&&o!==null&&o.channel===y}var v=["tl","tr","bl","br"];function l(){return{mode:"dock",corner:"br",x:0,y:0,floatW:420,floatH:640,dockSide:"right",tabY:0,dockW:600}}function h(o,e,t){return Math.min(Math.max(o,e),t)}function R(o,e,t,r,n){return{x:o[1]==="l"?20:r-20-e,y:o[0]==="t"?20:n-20-t}}function u(o,e,t){return o.corner?R(o.corner,56,56,e,t):{x:h(o.x,20,Math.max(20,e-20-56)),y:h(o.y,20,Math.max(20,t-20-56))}}function c(o,e,t){if(o.corner)return o.corner;let r=u(o,e,t);return $(r.x+56/2,r.y+56/2,e,t)}function $(o,e,t,r){return`${e<r/2?"t":"b"}${o<t/2?"l":"r"}`}function V(o,e,t,r){let n=h(o,20,Math.max(20,t-20-56)),i=h(e,20,Math.max(20,r-20-56));for(let a of v){let d=R(a,56,56,t,r);if(Math.hypot(n-d.x,i-d.y)<=96)return{corner:a,x:n,y:i}}return{corner:null,x:n,y:i}}function x(o,e,t){return o<=64?"left":o+e>=t-64?"right":null}function S(o,e,t){return o.mode==="dock"?{x:o.dockSide==="left"?0:e-44,y:w(o,t)}:u(o,e,t)}function G(o,e,t,r){if(o.mode==="dock"){let a=e?Math.min(Math.max(o.dockW,320),Math.max(0,t-40)):44;return{x:o.dockSide==="left"?0:t-a,w:a}}let n=u(o,t,r);if(!e)return{x:n.x,w:56};let{w:i}=p(o.floatW,o.floatH,t,r,320,420);return{x:c(o,t,r)[1]==="r"?n.x+56-i:n.x,w:i}}function N(o,e,t,r,n,i){let a=V(o,e,n,i);if(a.corner)return{mode:"float",...a};let d=x(t,r,n);return d?{mode:"dock",dockSide:d,tabY:h(e,0,Math.max(0,i-132))}:{mode:"float",...a}}function p(o,e,t,r,n,i){return{w:Math.min(Math.max(o,n),Math.max(0,t-40)),h:Math.min(Math.max(e,i),Math.max(0,r-40))}}function T(o,e,t,r,n){let i=o[1]==="r"?-1:1,a=o[0]==="b"?-1:1;return{w:e+i*r,h:t+a*n}}function L(o,e,t){return o==="right"?e-t:e+t}function H(o){if(!o)return null;try{let e=JSON.parse(o);if(!e||e.mode!=="float"&&e.mode!=="dock")return null;let t=l(),r=(n,i)=>typeof n=="number"?n:i;return{mode:e.mode,corner:v.includes(e.corner)?e.corner:null,x:r(e.x,t.x),y:r(e.y,t.y),floatW:r(e.floatW,t.floatW),floatH:r(e.floatH,t.floatH),dockSide:e.dockSide==="left"?"left":"right",tabY:r(e.tabY,t.tabY),dockW:r(e.dockW,t.dockW)}}catch{return null}}function I(o){return JSON.stringify(o)}var s=o=>`${o}px`;function j(o,e,t,r,n,i,a){let d=n[1]==="r",b=n[0]==="b",K=d?i-(o+56):o,Y=b?a-(e+56):e,A=h(K,20,Math.max(20,i-20-t)),E=h(Y,20,Math.max(20,a-20-r));return{top:b?"auto":s(E),bottom:b?s(E):"auto",left:d?"auto":s(A),right:d?s(A):"auto",width:s(t),height:s(r)}}function w(o,e){let t=Math.max(0,e-132);return h(o.tabY||Math.round((e-132)/2),0,t)}function _(o,e,t){let r=o.dockSide==="left";return{top:s(w(o,t)),bottom:"auto",left:r?"0px":"auto",right:r?"auto":"0px",width:s(44),height:s(132)}}function f(o,e,t,r,n,i){let a=u(o,r,n);return j(a.x,a.y,e,t,i??c(o,r,n),r,n)}function W(o,e,t,r,n){let i=o.dockSide==="left";return{top:s(w(o,n)),bottom:"auto",left:i?"0px":"auto",right:i?"auto":"0px",width:s(e),height:s(t)}}function B(o,e,t,r){let n=p(o.floatW,o.floatH,e,t,320,420);return f(o,n.w,n.h,e,t,r)}function P(o,e,t){let r=Math.min(Math.max(o.dockW,320),Math.max(0,e-40)),n=o.dockSide==="left";return{top:"0px",bottom:"0px",height:"auto",left:n?"0px":"auto",right:n?"auto":"0px",width:s(r)}}var te="https://app.matterfact.com";function F(){try{if(new URLSearchParams(location.search).get("mfdev")==="1")return!0;try{return localStorage.getItem("mfdev")==="1"}catch{return!1}}catch{return!1}}function g(o,e){F()&&console.info("[embed auth] host: "+o,e??"")}function U(){let o=document.currentScript??document.querySelector('script[data-key][src*="embed"]'),e=o?.dataset.key;if(!e)return console.error("[matterfact] missing data-key on the embed script tag"),null;let t=o?.dataset.container,r=t?document.querySelector(t):null;t&&!r&&console.error(`[matterfact] data-container="${t}" matched nothing; falling back to the corner`);let n=o?.dataset.pageContext?.toLowerCase(),i=!0;return n==="off"||n==="false"||n==="0"?i=!1:n==="declared"?i="declared":(n==="full"||n==="on"||n==="true"||n==="1")&&(i=!0),{publishableKey:e,origin:o?.dataset.origin||te,theme:o?.dataset.theme||"auto",surface:o?.dataset.surface||"",container:r,pageContext:i}}var O="mf.embed.pos",k=class{constructor(e){this.config=e;this.iframe=null;this.shadow=null;this.queue=[];this.ready=!1;this.open=!1;this.geo=l();this.resizeBase=null;this.dockBase=600;this.dragFrom=null;this.dragAt={x:0,y:0};this.dragBox={x:0,w:0};this.dragGrowth=null;this.dragLeftBand=!1;this.context=null;this.hostEl=null;this.ac=0;this.onMessage=e=>{e.origin===this.config.origin&&e.source===this.iframe?.contentWindow&&M(e.data)&&this.handle(e.data.payload)};this.onViewportResize=()=>{this.place()};this.send=e=>{if(!this.ready){this.queue.push(e);return}this.iframe?.contentWindow?.postMessage(C(e),this.config.origin)};this.inline=!!e.container}mount(){let e=document.createElement("div");this.hostEl=e,e.id="matterfact-embed",this.inline?(e.style.cssText=["all: initial","position: relative","display: block","width: 100%","height: 100%","contain: layout style"].join(";"),this.config.container.appendChild(e)):(this.geo=this.readGeometry(),e.style.cssText=["all: initial","position: fixed","z-index: 2147483000","contain: layout style","transition: width .18s ease, height .18s ease, top .18s ease, right .18s ease, bottom .18s ease, left .18s ease"].join(";"),document.body.appendChild(e)),this.shadow=e.attachShadow({mode:"closed"});let t=document.createElement("style");t.textContent=":host{all:initial}iframe{border:0;display:block;width:100%;height:100%;background:transparent}"+(this.inline?"":':host([data-mode="float"]) iframe,:host([data-mode="dock"]) iframe{color-scheme:light dark}:host([data-mode="float"]) iframe{border-radius:12px;box-shadow:0 0 0 1px #00000014,0 8px 40px #00000029}:host([data-mode="dock"]) iframe{box-shadow:0 0 0 1px #00000014,0 8px 40px #00000029}:host([data-mode="dock"][data-flush="right"]) iframe{border-radius:12px 0 0 12px}:host([data-mode="dock"][data-flush="left"]) iframe{border-radius:0 12px 12px 0}'),this.shadow.appendChild(t);let r=document.createElement("iframe");r.title="matterfact assistant",r.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-downloads"),r.setAttribute("allow","microphone; clipboard-write"),r.src=`${this.config.origin}/embed/chat?k=${encodeURIComponent(this.config.publishableKey)}&o=${encodeURIComponent(location.origin)}`+(this.config.surface?`&s=${encodeURIComponent(this.config.surface)}`:"")+(F()||this.config.dev?"&dev=1":"")+(this.inline?"&inline=1":""),this.iframe=r,this.shadow.appendChild(r),window.addEventListener("message",this.onMessage),this.inline||(window.addEventListener("resize",this.onViewportResize),this.place())}__testHandle(e){this.handle(e)}emit(e){let t=globalThis.matterfact?.onEvent;if(typeof t=="function")try{t(e)}catch{}}handle(e){switch(e.type){case"widget.ready":this.ready=!0,this.send({type:"host.ready",protocol:3,origin:location.origin}),this.send({type:"host.theme",mode:this.themeMode()}),this.flush(),this.inline&&this.loadContext(),this.emit({type:"ready"});break;case"widget.setOpen":if(this.emit({type:e.open?"open":"close"}),this.inline)break;this.open=e.open,this.place(),e.open&&this.loadContext();break;case"widget.setMode":if(this.inline)break;this.geo.mode=e.mode,this.writeGeometry(this.geo),this.place();break;case"widget.setDockSide":if(this.inline)break;this.geo.dockSide=e.side,this.writeGeometry(this.geo),this.place();break;case"widget.snapCorner":if(this.inline)break;this.geo.corner=e.corner,this.writeGeometry(this.geo),this.place();break;case"widget.setLauncherRegion":{if(this.inline||this.open)break;let t=window.innerWidth,r=window.innerHeight;if(e.w<=56&&e.h<=56)this.place();else{let n=this.geo.mode==="dock"?W(this.geo,e.w,e.h,t,r):f(this.geo,e.w,e.h,t,r);this.applyBox(n,e.h>56?"menu":"pill")}break}case"widget.resize":if(this.inline)break;this.hostEl&&this.open&&this.geo.mode==="float"&&(this.hostEl.style.height=`${Math.min(e.height,Math.max(0,window.innerHeight-40))}px`);break;case"widget.resizeStart":if(this.inline)break;this.resizeBase={w:this.geo.floatW,h:this.geo.floatH},this.dockBase=this.geo.dockW,this.hostEl&&(this.hostEl.style.transition="none");break;case"widget.resizeMove":{if(this.inline||!this.resizeBase)break;if(this.geo.mode==="dock"){let t=L(this.geo.dockSide,this.dockBase,e.dx);this.geo.dockW=Math.min(Math.max(t,320),Math.max(0,window.innerWidth-40))}else{let t=T(c(this.geo,window.innerWidth,window.innerHeight),this.resizeBase.w,this.resizeBase.h,e.dx,e.dy),r=p(t.w,t.h,window.innerWidth,window.innerHeight,320,420);this.geo.floatW=r.w,this.geo.floatH=r.h}this.place();break}case"widget.resizeEnd":if(this.inline)break;this.resizeBase=null,this.hostEl&&(this.hostEl.style.transition=""),this.writeGeometry(this.geo);break;case"widget.requestContext":this.loadContext().then(t=>t.provideContext());break;case"widget.pageContextMax":this.loadContext().then(t=>{t.setPageContextMax(e.mode)});break;case"widget.requestSnapshot":this.loadContext().then(t=>t.sendSnapshot(this.send));break;case"widget.readRegion":this.loadContext().then(t=>t.sendRegion(e.ref,this.send));break;case"widget.callTool":this.loadContext().then(t=>t.callTool(e.call,this.send));break;case"widget.dragStart":if(this.inline)break;this.dragFrom=S(this.geo,window.innerWidth,window.innerHeight),this.dragAt={...this.dragFrom},this.dragLeftBand=!1,this.dragGrowth=c(this.geo,window.innerWidth,window.innerHeight),this.dragBox=G(this.geo,this.open,window.innerWidth,window.innerHeight),this.hostEl&&(this.hostEl.style.transition="none");break;case"widget.dragMove":{if(this.inline||!this.dragFrom)break;let t=window.innerWidth,r=window.innerHeight;this.dragAt={x:this.dragFrom.x+e.dx,y:this.dragFrom.y+e.dy};let n=x(this.dragBox.x+e.dx,this.dragBox.w,t);n||(this.dragLeftBand=!0),n&&(this.dragLeftBand||this.geo.mode==="dock")?(this.geo.mode="dock",this.geo.dockSide=n,this.geo.tabY=Math.max(0,this.dragAt.y)):(this.geo.mode="float",this.geo.corner=null,this.geo.x=this.dragAt.x,this.geo.y=this.dragAt.y),this.place();break}case"widget.dragEnd":{if(this.inline||!this.dragFrom)break;let t=N(this.dragAt.x,this.dragAt.y,this.dragBox.x+(this.dragAt.x-this.dragFrom.x),this.dragBox.w,window.innerWidth,window.innerHeight);this.geo.mode=t.mode,t.mode==="dock"?(this.geo.dockSide=t.dockSide,this.geo.tabY=t.tabY):(this.geo.corner=t.corner,this.geo.x=t.x,this.geo.y=t.y),this.dragFrom=null,this.dragGrowth=null,this.hostEl&&(this.hostEl.style.transition=""),this.place(),this.writeGeometry(this.geo);break}case"widget.resetPos":if(this.inline)break;this.geo=l(),this.writeGeometry(this.geo),this.place();break;case"widget.hide":if(this.inline)break;this.hostEl&&(this.hostEl.style.display="none");break;case"widget.needsAuth":this.emit({type:"auth",phase:"required"}),this.provideAuth();break;case"widget.navigate":this.emit({type:"navigate",href:e.href}),this.loadContext().then(t=>t.navigateHost(e.href));break;case"widget.chat":this.emit({type:"chat",phase:e.phase,chatId:e.chatId});break;case"widget.artifactParams":this.emit({type:"artifactParams",params:e.params,source:e.source});break}}applyBox(e,t){if(!this.hostEl||this.inline)return;let r=this.hostEl.style;r.top=e.top,r.right=e.right,r.bottom=e.bottom,r.left=e.left,r.width=e.width,r.height=e.height,this.hostEl.dataset.mode=t,t==="tab"||t==="dock"?this.hostEl.dataset.flush=this.geo.dockSide:delete this.hostEl.dataset.flush}growthNow(){return this.dragGrowth??c(this.geo,window.innerWidth,window.innerHeight)}place(){let e=window.innerWidth,t=window.innerHeight;if(this.open)this.geo.mode==="dock"?this.applyBox(P(this.geo,e,t),"dock"):this.applyBox(B(this.geo,e,t,this.growthNow()),"float");else{let r=this.geo.mode==="dock";this.applyBox(r?_(this.geo,e,t):f(this.geo,56,56,e,t,this.growthNow()),r?"tab":"launcher")}this.publishGeometry()}publishGeometry(){this.send({type:"host.geometry",mode:this.geo.mode,dockSide:this.geo.dockSide,growth:this.growthNow()})}themeMode(){return this.config.theme==="auto"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":this.config.theme}readGeometry(){try{return H(localStorage.getItem(O))??l()}catch{return l()}}writeGeometry(e){try{localStorage.setItem(O,I(e))}catch{}}async provideAuth(){let e=this.config.authTokenProvider??globalThis.matterfact?.getEmbedAuthToken;if(!e){g("no provider");return}if(++this.ac>5){g("storm cap");return}try{let t=await e();t&&this.send({type:"host.auth",token:t,expiresAt:0}),this.emit({type:"auth",phase:t?"granted":"failed"}),g(t?"token":"empty")}catch(t){this.emit({type:"auth",phase:"failed"}),g("threw",t)}}loadContext(){return this.context??(this.context=import("./chunk-C7DXO37G.js").then(e=>(e.start(this.send,this.config.origin,this.config.pageContext,this.config.pageContextProvider),this.config.theme!=="auto"&&this.send({type:"host.theme",mode:this.config.theme}),e))),this.context}flush(){let e=this.queue;this.queue=[];for(let t of e)this.send(t)}setArtifactParams(e){if(e==null||typeof e!="object"||Array.isArray(e)){console.error("[matterfact] setArtifactParams expects an object of param values");return}this.send({type:"host.artifactParams",params:e})}destroy(){window.removeEventListener("message",this.onMessage),window.removeEventListener("resize",this.onViewportResize),this.hostEl?.remove(),this.hostEl=null,this.iframe=null,this.shadow=null,this.ready=!1,this.context?.then(e=>e.stop())}};function z(o){let e=new k(o);return e.mount(),window.matterfact={...window.matterfact??{},setArtifactParams:t=>e.setArtifactParams(t)},e}var q=U();if(q){let o=()=>z(q);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o,{once:!0}):o()}
2
2
  //# sourceMappingURL=embed.js.map