pmx-canvas 0.5.1 → 0.6.1
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/CHANGELOG.md +28 -0
- package/Readme.md +9 -6
- package/dist/canvas/global.css +79 -4
- package/dist/canvas/index.js +171 -128
- package/dist/canvas/mermaid-entry.js +1303 -1303
- package/dist/json-render/index.js +101 -102
- package/docs/adr-001-bun-only-runtime.md +1 -1
- package/docs/bun-webview-integration.md +2 -2
- package/docs/product-context-vision-2026-09.md +207 -0
- package/docs/product-review-2026-09.md +174 -0
- package/docs/product-vision-2026-09.md +200 -0
- package/docs/screenshot.png +0 -0
- package/package.json +2 -2
- package/skills/pmx-canvas/SKILL.md +52 -29
- package/skills/pmx-canvas/references/installing-pmx-canvas.md +126 -18
- package/skills/web-artifacts-builder/scripts/bundle-artifact.sh +12 -1
- package/src/client/canvas/CanvasViewport.tsx +11 -0
- package/src/client/canvas/TopBar.tsx +85 -45
- package/src/client/canvas/use-pan-zoom.ts +7 -0
- package/src/client/nodes/ExtAppFrame.tsx +90 -27
- package/src/client/state/canvas-store.ts +17 -5
- package/src/client/theme/global.css +79 -4
- package/src/server/operations/mcp.ts +45 -31
- package/src/server/operations/ops/ax-presence.ts +3 -0
- package/src/server/scope-fence.ts +1 -1
package/dist/canvas/index.js
CHANGED
|
@@ -1,160 +1,159 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Ow=Object.create;var{getPrototypeOf:Lw,defineProperty:Ud,getOwnPropertyNames:Dw}=Object;var Wd=Object.prototype.hasOwnProperty;function Fw(e){return this[e]}var jw,Zw,Hw=(e,t,n)=>{var o=e!=null&&typeof e==="object";if(o){var r=t?jw??=new WeakMap:Zw??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Ow(Lw(e)):{};let a=t||!e||!e.__esModule||!Wd.call(e,"default")?Ud(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let c of Dw(e))if(!Wd.call(a,c))Ud(a,c,{get:Fw.bind(e,c),enumerable:!0})}if(o)r.set(e,a);return a};var Bw=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var rm=Bw(function(om){Object.defineProperty(om,"__esModule",{value:!0});var Bf=/highlight-(?:text|source)-([a-z0-9]+)/;function Wf(e){e.addRule("highlightedCodeBlock",{filter:function(t){var n=t.firstChild;return t.nodeName==="DIV"&&Bf.test(t.className)&&n&&n.nodeName==="PRE"},replacement:function(t,n,o){var r=n.className||"",s=(r.match(Bf)||[null,""])[1];return`
|
|
2
2
|
|
|
3
|
-
`+
|
|
4
|
-
`+
|
|
5
|
-
`+
|
|
3
|
+
`+o.fence+s+`
|
|
4
|
+
`+n.firstChild.textContent+`
|
|
5
|
+
`+o.fence+`
|
|
6
6
|
|
|
7
|
-
`}})}function
|
|
8
|
-
|
|
9
|
-
`+
|
|
7
|
+
`}})}function qf(e){e.addRule("strikethrough",{filter:["del","s","strike"],replacement:function(t){return"~~"+t+"~~"}})}var xS=Array.prototype.indexOf,bS=Array.prototype.every,Mn={},wS={left:":---",right:"---:",center:":---:"},al=null,Vf=null,Uf=new WeakMap;function _S(e){return e?(e.getAttribute("align")||e.style.textAlign||"").toLowerCase():""}function Gf(e){return e?wS[e]:"---"}function Xf(e,t){var n={left:0,right:0,center:0,"":0},o="";for(var r=0;r<e.rows.length;++r){var s=e.rows[r];if(t<s.childNodes.length){var a=_S(s.childNodes[t]);if(++n[a],n[a]>n[o])o=a}}return o}Mn.tableCell={filter:["th","td"],replacement:function(e,t){if(ll(Qf(t)))return e;return Kf(e,t)}};Mn.tableRow={filter:"tr",replacement:function(e,t){let n=Qf(t);if(ll(n))return e;var o="";if(SS(t)){let a=em(n);for(var r=0;r<a;r++){let c=r<t.childNodes.length?t.childNodes[r]:null;var s=Gf(Xf(n,r));o+=Kf(s,c,r)}}return`
|
|
8
|
+
`+e+(o?`
|
|
9
|
+
`+o:"")}};Mn.table={filter:function(e,t){return e.nodeName==="TABLE"},replacement:function(e,t){if(Yf(t,Vf)){let c=t.outerHTML,l=TS(t);if(l===null||!l.classList.contains("joplin-table-wrapper"))return`
|
|
10
10
|
|
|
11
|
-
<div class="joplin-table-wrapper">${
|
|
11
|
+
<div class="joplin-table-wrapper">${c}</div>
|
|
12
12
|
|
|
13
|
-
`;else return
|
|
14
|
-
`);var
|
|
15
|
-
`);if(
|
|
16
|
-
|`;for(var
|
|
13
|
+
`;else return c}else{if(ll(t))return e;e=e.replace(/\n+/g,`
|
|
14
|
+
`);var n=e.trim().split(`
|
|
15
|
+
`);if(n.length>=2)n=n[1];var o=/\| :?---/.test(n),r=em(t),s="";if(r&&!o){s="|"+" |".repeat(r)+`
|
|
16
|
+
|`;for(var a=0;a<r;++a)s+=" "+Gf(Xf(t,a))+" |"}let c=t.caption?t.caption.textContent||"":"",l=c?`${c}
|
|
17
17
|
|
|
18
|
-
`:"",
|
|
18
|
+
`:"",u=`${s}${e}`.trimStart();return`
|
|
19
19
|
|
|
20
|
-
${
|
|
20
|
+
${l}${u}
|
|
21
21
|
|
|
22
|
-
`}}};_1.tableCaption={filter:["caption"],replacement:()=>""};_1.tableColgroup={filter:["colgroup","col"],replacement:()=>""};_1.tableSection={filter:["thead","tbody","tfoot"],replacement:function($){return $}};function OP($){var U=$.parentNode;return U.nodeName==="THEAD"||U.firstChild===$&&(U.nodeName==="TABLE"||YP(U))&&KP.call($.childNodes,function(v){return v.nodeName==="TH"})}function YP($){var U=$.previousSibling;return $.nodeName==="TBODY"&&(!U||U.nodeName==="THEAD"&&/^\s*$/i.test(U.textContent))}function TZ($,U=null,v=null){if(v===null)v=zP.call(U.parentNode.childNodes,U);var J=" ";if(v===0)J="| ";let _=$.trim().replace(/\n\r/g,"<br>").replace(/\n/g,"<br>");_=_.replace(/\|+/g,"\\|");while(_.length<3)_+=" ";if(U)_=BP(_,U," ");return J+_+" |"}function yZ($){if(!$.childNodes)return!1;for(let U=0;U<$.childNodes.length;U++){let v=$.childNodes[U];if(v.nodeName==="TABLE")return!0;if(yZ(v))return!0}return!1}var t8=($,U)=>{if(!$.childNodes)return!1;for(let v=0;v<$.childNodes.length;v++){let J=$.childNodes[v];if(U==="code"&&n8&&n8(J))return!0;if(U.includes(J.nodeName))return!0;if(t8(J,U))return!0}return!1},CZ=($,U)=>{let v=["UL","OL","H1","H2","H3","H4","H5","H6","HR","BLOCKQUOTE"];if(U.preserveNestedTables)v.push("TABLE");return t8($,"code")||t8($,v)};function a8($){let U=IZ.get($);if(U!==void 0)return U;let v=ZP($);return IZ.set($,v),v}function ZP($){if(!$)return!0;if(!$.rows)return!0;if($.rows.length===1&&$.rows[0].childNodes.length<=1)return!0;if(yZ($))return!0;return!1}function qP($){let U=$.parentNode;while(U.nodeName!=="DIV")if(U=U.parentNode,!U)return null;return U}function DZ($){let U=$.parentNode;while(U.nodeName!=="TABLE")if(U=U.parentNode,!U)return null;return U}function BP($,U,v){let J=U.getAttribute("colspan")||1;for(let _=1;_<J;_++)$+=" | "+v.repeat(3);return $}function jZ($){let U=0;for(let v=0;v<$.rows.length;v++){let _=$.rows[v].childNodes.length;if(_>U)U=_}return U}function VZ($){n8=$.isCodeBlock,NZ=$.options,$.keep(function(v){if(v.nodeName==="TABLE"&&CZ(v,$.options))return!0;return!1});for(var U in _1)$.addRule(U,_1[U])}function fZ($){$.addRule("taskListItems",{filter:function(U){let v=U.parentNode,J=v.parentNode;return U.type==="checkbox"&&(v.nodeName==="LI"||v.nodeName==="LABEL"&&J&&J.nodeName==="LI")},replacement:function(U,v){return(v.checked?"[x]":"[ ]")+" "}})}function XP($){$.use([wZ,gZ,VZ,fZ])}EZ.gfm=XP;EZ.highlightedCodeBlock=wZ;EZ.strikethrough=gZ;EZ.tables=VZ;EZ.taskListItems=fZ});if(typeof crypto<"u"&&typeof crypto.randomUUID!=="function")crypto.randomUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let U=Math.random()*16|0;return($==="x"?U:U&3|8).toString(16)});var M2,b$,TO,Z8,d4,gO,yO,CO,DO,q8,W8,O8,TL,P2={},k2=[],yL=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,A2=Array.isArray;function g4($,U){for(var v in U)$[v]=U[v];return $}function B8($){$&&$.parentNode&&$.parentNode.removeChild($)}function CL($,U,v){var J,_,z,K={};for(z in U)z=="key"?J=U[z]:z=="ref"?_=U[z]:K[z]=U[z];if(arguments.length>2&&(K.children=arguments.length>3?M2.call(arguments,2):v),typeof $=="function"&&$.defaultProps!=null)for(z in $.defaultProps)K[z]===void 0&&(K[z]=$.defaultProps[z]);return F2($,K,J,_,null)}function F2($,U,v,J,_){var z={type:$,props:U,key:v,ref:J,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:_==null?++TO:_,__i:-1,__u:0};return _==null&&b$.vnode!=null&&b$.vnode(z),z}function A$($){return $.children}function KU($,U){this.props=$,this.context=U}function GU($,U){if(U==null)return $.__?GU($.__,$.__i+1):null;for(var v;U<$.__k.length;U++)if((v=$.__k[U])!=null&&v.__e!=null)return v.__e;return typeof $.type=="function"?GU($):null}function DL($){if($.__P&&$.__d){var U=$.__v,v=U.__e,J=[],_=[],z=g4({},U);z.__v=U.__v+1,b$.vnode&&b$.vnode(z),X8($.__P,z,U,$.__n,$.__P.namespaceURI,32&U.__u?[v]:null,J,v==null?GU(U):v,!!(32&U.__u),_),z.__v=U.__v,z.__.__k[z.__i]=z,EO(J,z,_),U.__e=U.__=null,z.__e!=v&&jO(z)}}function jO($){if(($=$.__)!=null&&$.__c!=null)return $.__e=$.__c.base=null,$.__k.some(function(U){if(U!=null&&U.__e!=null)return $.__e=$.__c.base=U.__e}),jO($)}function NO($){(!$.__d&&($.__d=!0)&&d4.push($)&&!b2.__r++||gO!=b$.debounceRendering)&&((gO=b$.debounceRendering)||yO)(b2)}function b2(){try{for(var $,U=1;d4.length;)d4.length>U&&d4.sort(CO),$=d4.shift(),U=d4.length,DL($)}finally{d4.length=b2.__r=0}}function VO($,U,v,J,_,z,K,W,O,Y,Z){var q,X,B,L,F,k,H,P=J&&J.__k||k2,b=U.length;for(O=jL(v,U,P,O,b),q=0;q<b;q++)(B=v.__k[q])!=null&&(X=B.__i!=-1&&P[B.__i]||P2,B.__i=q,k=X8($,B,X,_,z,K,W,O,Y,Z),L=B.__e,B.ref&&X.ref!=B.ref&&(X.ref&&H8(X.ref,null,B),Z.push(B.ref,B.__c||L,B)),F==null&&L!=null&&(F=L),(H=!!(4&B.__u))||X.__k===B.__k?O=fO(B,O,$,H):typeof B.type=="function"&&k!==void 0?O=k:L&&(O=L.nextSibling),B.__u&=-7);return v.__e=F,O}function jL($,U,v,J,_){var z,K,W,O,Y,Z=v.length,q=Z,X=0;for($.__k=Array(_),z=0;z<_;z++)(K=U[z])!=null&&typeof K!="boolean"&&typeof K!="function"?(typeof K=="string"||typeof K=="number"||typeof K=="bigint"||K.constructor==String?K=$.__k[z]=F2(null,K,null,null,null):A2(K)?K=$.__k[z]=F2(A$,{children:K},null,null,null):K.constructor===void 0&&K.__b>0?K=$.__k[z]=F2(K.type,K.props,K.key,K.ref?K.ref:null,K.__v):$.__k[z]=K,O=z+X,K.__=$,K.__b=$.__b+1,W=null,(Y=K.__i=VL(K,v,O,q))!=-1&&(q--,(W=v[Y])&&(W.__u|=2)),W==null||W.__v==null?(Y==-1&&(_>Z?X--:_<Z&&X++),typeof K.type!="function"&&(K.__u|=4)):Y!=O&&(Y==O-1?X--:Y==O+1?X++:(Y>O?X--:X++,K.__u|=4))):$.__k[z]=null;if(q)for(z=0;z<Z;z++)(W=v[z])!=null&&(2&W.__u)==0&&(W.__e==J&&(J=GU(W)),mO(W,W));return J}function fO($,U,v,J){var _,z;if(typeof $.type=="function"){for(_=$.__k,z=0;_&&z<_.length;z++)_[z]&&(_[z].__=$,U=fO(_[z],U,v,J));return U}$.__e!=U&&(J&&(U&&$.type&&!U.parentNode&&(U=GU($)),v.insertBefore($.__e,U||null)),U=$.__e);do U=U&&U.nextSibling;while(U!=null&&U.nodeType==8);return U}function VL($,U,v,J){var _,z,K,W=$.key,O=$.type,Y=U[v],Z=Y!=null&&(2&Y.__u)==0;if(Y===null&&W==null||Z&&W==Y.key&&O==Y.type)return v;if(J>(Z?1:0)){for(_=v-1,z=v+1;_>=0||z<U.length;)if((Y=U[K=_>=0?_--:z++])!=null&&(2&Y.__u)==0&&W==Y.key&&O==Y.type)return K}return-1}function SO($,U,v){U[0]=="-"?$.setProperty(U,v==null?"":v):$[U]=v==null?"":typeof v!="number"||yL.test(U)?v:v+"px"}function L2($,U,v,J,_){var z,K;$:if(U=="style")if(typeof v=="string")$.style.cssText=v;else{if(typeof J=="string"&&($.style.cssText=J=""),J)for(U in J)v&&U in v||SO($.style,U,"");if(v)for(U in v)J&&v[U]==J[U]||SO($.style,U,v[U])}else if(U[0]=="o"&&U[1]=="n")z=U!=(U=U.replace(DO,"$1")),K=U.toLowerCase(),U=K in $||U=="onFocusOut"||U=="onFocusIn"?K.slice(2):U.slice(2),$.l||($.l={}),$.l[U+z]=v,v?J?v.u=J.u:(v.u=q8,$.addEventListener(U,z?O8:W8,z)):$.removeEventListener(U,z?O8:W8,z);else{if(_=="http://www.w3.org/2000/svg")U=U.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(U!="width"&&U!="height"&&U!="href"&&U!="list"&&U!="form"&&U!="tabIndex"&&U!="download"&&U!="rowSpan"&&U!="colSpan"&&U!="role"&&U!="popover"&&U in $)try{$[U]=v==null?"":v;break $}catch(W){}typeof v=="function"||(v==null||v===!1&&U[4]!="-"?$.removeAttribute(U):$.setAttribute(U,U=="popover"&&v==1?"":v))}}function RO($){return function(U){if(this.l){var v=this.l[U.type+$];if(U.t==null)U.t=q8++;else if(U.t<v.u)return;return v(b$.event?b$.event(U):U)}}}function X8($,U,v,J,_,z,K,W,O,Y){var Z,q,X,B,L,F,k,H,P,b,V,E,A,I,N,R=U.type;if(U.constructor!==void 0)return null;128&v.__u&&(O=!!(32&v.__u),z=[W=U.__e=v.__e]),(Z=b$.__b)&&Z(U);$:if(typeof R=="function")try{if(H=U.props,P=R.prototype&&R.prototype.render,b=(Z=R.contextType)&&J[Z.__c],V=Z?b?b.props.value:Z.__:J,v.__c?k=(q=U.__c=v.__c).__=q.__E:(P?U.__c=q=new R(H,V):(U.__c=q=new KU(H,V),q.constructor=R,q.render=EL),b&&b.sub(q),q.state||(q.state={}),q.__n=J,X=q.__d=!0,q.__h=[],q._sb=[]),P&&q.__s==null&&(q.__s=q.state),P&&R.getDerivedStateFromProps!=null&&(q.__s==q.state&&(q.__s=g4({},q.__s)),g4(q.__s,R.getDerivedStateFromProps(H,q.__s))),B=q.props,L=q.state,q.__v=U,X)P&&R.getDerivedStateFromProps==null&&q.componentWillMount!=null&&q.componentWillMount(),P&&q.componentDidMount!=null&&q.__h.push(q.componentDidMount);else{if(P&&R.getDerivedStateFromProps==null&&H!==B&&q.componentWillReceiveProps!=null&&q.componentWillReceiveProps(H,V),U.__v==v.__v||!q.__e&&q.shouldComponentUpdate!=null&&q.shouldComponentUpdate(H,q.__s,V)===!1){U.__v!=v.__v&&(q.props=H,q.state=q.__s,q.__d=!1),U.__e=v.__e,U.__k=v.__k,U.__k.some(function(p){p&&(p.__=U)}),k2.push.apply(q.__h,q._sb),q._sb=[],q.__h.length&&K.push(q);break $}q.componentWillUpdate!=null&&q.componentWillUpdate(H,q.__s,V),P&&q.componentDidUpdate!=null&&q.__h.push(function(){q.componentDidUpdate(B,L,F)})}if(q.context=V,q.props=H,q.__P=$,q.__e=!1,E=b$.__r,A=0,P)q.state=q.__s,q.__d=!1,E&&E(U),Z=q.render(q.props,q.state,q.context),k2.push.apply(q.__h,q._sb),q._sb=[];else do q.__d=!1,E&&E(U),Z=q.render(q.props,q.state,q.context),q.state=q.__s;while(q.__d&&++A<25);q.state=q.__s,q.getChildContext!=null&&(J=g4(g4({},J),q.getChildContext())),P&&!X&&q.getSnapshotBeforeUpdate!=null&&(F=q.getSnapshotBeforeUpdate(B,L)),I=Z!=null&&Z.type===A$&&Z.key==null?uO(Z.props.children):Z,W=VO($,A2(I)?I:[I],U,v,J,_,z,K,W,O,Y),q.base=U.__e,U.__u&=-161,q.__h.length&&K.push(q),k&&(q.__E=q.__=null)}catch(p){if(U.__v=null,O||z!=null)if(p.then){for(U.__u|=O?160:128;W&&W.nodeType==8&&W.nextSibling;)W=W.nextSibling;z[z.indexOf(W)]=null,U.__e=W}else{for(N=z.length;N--;)B8(z[N]);Y8(U)}else U.__e=v.__e,U.__k=v.__k,p.then||Y8(U);b$.__e(p,U,v)}else z==null&&U.__v==v.__v?(U.__k=v.__k,U.__e=v.__e):W=U.__e=fL(v.__e,U,v,J,_,z,K,O,Y);return(Z=b$.diffed)&&Z(U),128&U.__u?void 0:W}function Y8($){$&&($.__c&&($.__c.__e=!0),$.__k&&$.__k.some(Y8))}function EO($,U,v){for(var J=0;J<v.length;J++)H8(v[J],v[++J],v[++J]);b$.__c&&b$.__c(U,$),$.some(function(_){try{$=_.__h,_.__h=[],$.some(function(z){z.call(_)})}catch(z){b$.__e(z,_.__v)}})}function uO($){return typeof $!="object"||$==null||$.__b>0?$:A2($)?$.map(uO):g4({},$)}function fL($,U,v,J,_,z,K,W,O){var Y,Z,q,X,B,L,F,k=v.props||P2,H=U.props,P=U.type;if(P=="svg"?_="http://www.w3.org/2000/svg":P=="math"?_="http://www.w3.org/1998/Math/MathML":_||(_="http://www.w3.org/1999/xhtml"),z!=null){for(Y=0;Y<z.length;Y++)if((B=z[Y])&&"setAttribute"in B==!!P&&(P?B.localName==P:B.nodeType==3)){$=B,z[Y]=null;break}}if($==null){if(P==null)return document.createTextNode(H);$=document.createElementNS(_,P,H.is&&H),W&&(b$.__m&&b$.__m(U,z),W=!1),z=null}if(P==null)k===H||W&&$.data==H||($.data=H);else{if(z=z&&M2.call($.childNodes),!W&&z!=null)for(k={},Y=0;Y<$.attributes.length;Y++)k[(B=$.attributes[Y]).name]=B.value;for(Y in k)B=k[Y],Y=="dangerouslySetInnerHTML"?q=B:Y=="children"||(Y in H)||Y=="value"&&("defaultValue"in H)||Y=="checked"&&("defaultChecked"in H)||L2($,Y,null,B,_);for(Y in H)B=H[Y],Y=="children"?X=B:Y=="dangerouslySetInnerHTML"?Z=B:Y=="value"?L=B:Y=="checked"?F=B:W&&typeof B!="function"||k[Y]===B||L2($,Y,B,k[Y],_);if(Z)W||q&&(Z.__html==q.__html||Z.__html==$.innerHTML)||($.innerHTML=Z.__html),U.__k=[];else if(q&&($.innerHTML=""),VO(U.type=="template"?$.content:$,A2(X)?X:[X],U,v,J,P=="foreignObject"?"http://www.w3.org/1999/xhtml":_,z,K,z?z[0]:v.__k&&GU(v,0),W,O),z!=null)for(Y=z.length;Y--;)B8(z[Y]);W||(Y="value",P=="progress"&&L==null?$.removeAttribute("value"):L!=null&&(L!==$[Y]||P=="progress"&&!L||P=="option"&&L!=k[Y])&&L2($,Y,L,k[Y],_),Y="checked",F!=null&&F!=$[Y]&&L2($,Y,F,k[Y],_))}return $}function H8($,U,v){try{if(typeof $=="function"){var J=typeof $.__u=="function";J&&$.__u(),J&&U==null||($.__u=$(U))}else $.current=U}catch(_){b$.__e(_,v)}}function mO($,U,v){var J,_;if(b$.unmount&&b$.unmount($),(J=$.ref)&&(J.current&&J.current!=$.__e||H8(J,null,U)),(J=$.__c)!=null){if(J.componentWillUnmount)try{J.componentWillUnmount()}catch(z){b$.__e(z,U)}J.base=J.__P=null}if(J=$.__k)for(_=0;_<J.length;_++)J[_]&&mO(J[_],U,v||typeof $.type!="function");v||B8($.__e),$.__c=$.__=$.__e=void 0}function EL($,U,v){return this.constructor($,v)}function xO($,U,v){var J,_,z,K;U==document&&(U=document.documentElement),b$.__&&b$.__($,U),_=(J=typeof v=="function")?null:v&&v.__k||U.__k,z=[],K=[],X8(U,$=(!J&&v||U).__k=CL(A$,null,[$]),_||P2,P2,U.namespaceURI,!J&&v?[v]:_?null:U.firstChild?M2.call(U.childNodes):null,z,!J&&v?v:_?_.__e:U.firstChild,J,K),EO(z,$,K)}M2=k2.slice,b$={__e:function($,U,v,J){for(var _,z,K;U=U.__;)if((_=U.__c)&&!_.__)try{if((z=_.constructor)&&z.getDerivedStateFromError!=null&&(_.setState(z.getDerivedStateFromError($)),K=_.__d),_.componentDidCatch!=null&&(_.componentDidCatch($,J||{}),K=_.__d),K)return _.__E=_}catch(W){$=W}throw $}},TO=0,Z8=function($){return $!=null&&$.constructor===void 0},KU.prototype.setState=function($,U){var v;v=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=g4({},this.state),typeof $=="function"&&($=$(g4({},v),this.props)),$&&g4(v,$),$!=null&&this.__v&&(U&&this._sb.push(U),NO(this))},KU.prototype.forceUpdate=function($){this.__v&&(this.__e=!0,$&&this.__h.push($),NO(this))},KU.prototype.render=A$,d4=[],yO=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,CO=function($,U){return $.__v.__b-U.__v.__b},b2.__r=0,DO=/(PointerCapture)$|Capture$/i,q8=0,W8=RO(!1),O8=RO(!0),TL=0;var WU,a$,Q8,hO,f0=0,nO=[],e$=b$,cO=e$.__b,lO=e$.__r,rO=e$.diffed,iO=e$.__c,pO=e$.unmount,oO=e$.__;function w2($,U){e$.__h&&e$.__h(a$,$,f0||U),f0=0;var v=a$.__H||(a$.__H={__:[],__h:[]});return $>=v.__.length&&v.__.push({}),v.__[$]}function f($){return f0=1,uL(tO,$)}function uL($,U,v){var J=w2(WU++,2);if(J.t=$,!J.__c&&(J.__=[v?v(U):tO(void 0,U),function(W){var O=J.__N?J.__N[0]:J.__[0],Y=J.t(O,W);O!==Y&&(J.__N=[Y,J.__[1]],J.__c.setState({}))}],J.__c=a$,!a$.__f)){var _=function(W,O,Y){if(!J.__c.__H)return!0;var Z=J.__c.__H.__.filter(function(X){return X.__c});if(Z.every(function(X){return!X.__N}))return!z||z.call(this,W,O,Y);var q=J.__c.props!==W;return Z.some(function(X){if(X.__N){var B=X.__[0];X.__=X.__N,X.__N=void 0,B!==X.__[0]&&(q=!0)}}),z&&z.call(this,W,O,Y)||q};a$.__f=!0;var{shouldComponentUpdate:z,componentWillUpdate:K}=a$;a$.componentWillUpdate=function(W,O,Y){if(this.__e){var Z=z;z=void 0,_(W,O,Y),z=Z}K&&K.call(this,W,O,Y)},a$.shouldComponentUpdate=_}return J.__N||J.__}function u($,U){var v=w2(WU++,3);!e$.__s&&F8(v.__H,U)&&(v.__=$,v.u=U,a$.__H.__h.push(v))}function g2($,U){var v=w2(WU++,4);!e$.__s&&F8(v.__H,U)&&(v.__=$,v.u=U,a$.__h.push(v))}function C($){return f0=5,u$(function(){return{current:$}},[])}function u$($,U){var v=w2(WU++,7);return F8(v.__H,U)&&(v.__=$(),v.__H=U,v.__h=$),v.__}function j($,U){return f0=8,u$(function(){return $},U)}function mL(){for(var $;$=nO.shift();){var U=$.__H;if($.__P&&U)try{U.__h.some(I2),U.__h.some(L8),U.__h=[]}catch(v){U.__h=[],e$.__e(v,$.__v)}}}e$.__b=function($){a$=null,cO&&cO($)},e$.__=function($,U){$&&U.__k&&U.__k.__m&&($.__m=U.__k.__m),oO&&oO($,U)},e$.__r=function($){lO&&lO($),WU=0;var U=(a$=$.__c).__H;U&&(Q8===a$?(U.__h=[],a$.__h=[],U.__.some(function(v){v.__N&&(v.__=v.__N),v.u=v.__N=void 0})):(U.__h.some(I2),U.__h.some(L8),U.__h=[],WU=0)),Q8=a$},e$.diffed=function($){rO&&rO($);var U=$.__c;U&&U.__H&&(U.__H.__h.length&&(nO.push(U)!==1&&hO===e$.requestAnimationFrame||((hO=e$.requestAnimationFrame)||xL)(mL)),U.__H.__.some(function(v){v.u&&(v.__H=v.u),v.u=void 0})),Q8=a$=null},e$.__c=function($,U){U.some(function(v){try{v.__h.some(I2),v.__h=v.__h.filter(function(J){return!J.__||L8(J)})}catch(J){U.some(function(_){_.__h&&(_.__h=[])}),U=[],e$.__e(J,v.__v)}}),iO&&iO($,U)},e$.unmount=function($){pO&&pO($);var U,v=$.__c;v&&v.__H&&(v.__H.__.some(function(J){try{I2(J)}catch(_){U=_}}),v.__H=void 0,U&&e$.__e(U,v.__v))};var dO=typeof requestAnimationFrame=="function";function xL($){var U,v=function(){clearTimeout(J),dO&&cancelAnimationFrame(U),setTimeout($)},J=setTimeout(v,35);dO&&(U=requestAnimationFrame(v))}function I2($){var U=a$,v=$.__c;typeof v=="function"&&($.__c=void 0,v()),a$=U}function L8($){var U=a$;$.__c=$.__(),a$=U}function F8($,U){return!$||$.length!==U.length||U.some(function(v,J){return v!==$[J]})}function tO($,U){return typeof U=="function"?U($):U}var hL=Symbol.for("preact-signals");function T2(){if(!(N4>1)){var $,U=!1;(function(){var _=S2;S2=void 0;while(_!==void 0){if(_.S.v===_.v)_.S.i=_.i;_=_.o}})();while(E0!==void 0){var v=E0;E0=void 0,N2++;while(v!==void 0){var J=v.u;if(v.u=void 0,v.f&=-3,!(8&v.f)&&eO(v))try{v.c()}catch(_){if(!U)$=_,U=!0}v=J}}if(N2=0,N4--,U)throw $}else N4--}function o6($){if(N4>0)return $();P8=++cL,N4++;try{return $()}finally{T2()}}var S$=void 0;function k8($){var U=S$;S$=void 0;try{return $()}finally{S$=U}}var aO,E0=void 0,N4=0,N2=0,cL=0,P8=0,S2=void 0,R2=0;function sO($){if(S$!==void 0){var U=$.n;if(U===void 0||U.t!==S$){if(U={i:0,S:$,p:S$.s,n:void 0,t:S$,e:void 0,x:void 0,r:U},S$.s!==void 0)S$.s.n=U;if(S$.s=U,$.n=U,32&S$.f)$.S(U);return U}else if(U.i===-1){if(U.i=0,U.n!==void 0){if(U.n.p=U.p,U.p!==void 0)U.p.n=U.n;U.p=S$.s,U.n=void 0,S$.s.n=U,S$.s=U}return U}}}function K6($,U){this.v=$,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=U==null?void 0:U.watched,this.Z=U==null?void 0:U.unwatched,this.name=U==null?void 0:U.name}K6.prototype.brand=hL;K6.prototype.h=function(){return!0};K6.prototype.S=function($){var U=this,v=this.t;if(v!==$&&$.e===void 0)if($.x=v,this.t=$,v!==void 0)v.e=$;else k8(function(){var J;(J=U.W)==null||J.call(U)})};K6.prototype.U=function($){var U=this;if(this.t!==void 0){var{e:v,x:J}=$;if(v!==void 0)v.x=J,$.e=void 0;if(J!==void 0)J.e=v,$.x=void 0;if($===this.t){if(this.t=J,J===void 0)k8(function(){var _;(_=U.Z)==null||_.call(U)})}}};K6.prototype.subscribe=function($){var U=this;return B4(function(){var v=U.value,J=S$;S$=void 0;try{$(v)}finally{S$=J}},{name:"sub"})};K6.prototype.valueOf=function(){return this.value};K6.prototype.toString=function(){return this.value+""};K6.prototype.toJSON=function(){return this.value};K6.prototype.peek=function(){var $=S$;S$=void 0;try{return this.value}finally{S$=$}};Object.defineProperty(K6.prototype,"value",{get:function(){var $=sO(this);if($!==void 0)$.i=this.i;return this.v},set:function($){if($!==this.v){if(N2>100)throw Error("Cycle detected");(function(v){if(N4!==0&&N2===0){if(v.l!==P8)v.l=P8,S2={S:v,v:v.v,i:v.i,o:S2}}})(this),this.v=$,this.i++,R2++,N4++;try{for(var U=this.t;U!==void 0;U=U.x)U.t.N()}finally{T2()}}}});function s($,U){return new K6($,U)}function eO($){for(var U=$.s;U!==void 0;U=U.n)if(U.S.i!==U.i||!U.S.h()||U.S.i!==U.i)return!0;return!1}function $Y($){for(var U=$.s;U!==void 0;U=U.n){var v=U.S.n;if(v!==void 0)U.r=v;if(U.S.n=U,U.i=-1,U.n===void 0){$.s=U;break}}}function UY($){var U=$.s,v=void 0;while(U!==void 0){var J=U.p;if(U.i===-1){if(U.S.U(U),J!==void 0)J.n=U.n;if(U.n!==void 0)U.n.p=J}else v=U;if(U.S.n=U.r,U.r!==void 0)U.r=void 0;U=J}$.s=v}function y1($,U){K6.call(this,void 0),this.x=$,this.s=void 0,this.g=R2-1,this.f=4,this.W=U==null?void 0:U.watched,this.Z=U==null?void 0:U.unwatched,this.name=U==null?void 0:U.name}y1.prototype=new K6;y1.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32)return!0;if(this.f&=-5,this.g===R2)return!0;if(this.g=R2,this.f|=1,this.i>0&&!eO(this))return this.f&=-2,!0;var $=S$;try{$Y(this),S$=this;var U=this.x();if(16&this.f||this.v!==U||this.i===0)this.v=U,this.f&=-17,this.i++}catch(v){this.v=v,this.f|=16,this.i++}return S$=$,UY(this),this.f&=-2,!0};y1.prototype.S=function($){if(this.t===void 0){this.f|=36;for(var U=this.s;U!==void 0;U=U.n)U.S.S(U)}K6.prototype.S.call(this,$)};y1.prototype.U=function($){if(this.t!==void 0){if(K6.prototype.U.call(this,$),this.t===void 0){this.f&=-33;for(var U=this.s;U!==void 0;U=U.n)U.S.U(U)}}};y1.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var $=this.t;$!==void 0;$=$.x)$.t.N()}};Object.defineProperty(y1.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var $=sO(this);if(this.h(),$!==void 0)$.i=this.i;if(16&this.f)throw this.v;return this.v}});function r$($,U){return new y1($,U)}function _Y($){var U=$.m;if($.m=void 0,typeof U=="function"){N4++;var v=S$;S$=void 0;try{U()}catch(J){throw $.f&=-2,$.f|=8,b8($),J}finally{S$=v,T2()}}}function b8($){for(var U=$.s;U!==void 0;U=U.n)U.S.U(U);$.x=void 0,$.s=void 0,_Y($)}function lL($){if(S$!==this)throw Error("Out-of-order effect");if(UY(this),S$=$,this.f&=-2,8&this.f)b8(this);T2()}function OU($,U){if(this.x=$,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=U==null?void 0:U.name,aO)aO.push(this)}OU.prototype.c=function(){var $=this.S();try{if(8&this.f)return;if(this.x===void 0)return;var U=this.x();if(typeof U=="function")this.m=U}finally{$()}};OU.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,_Y(this),$Y(this),N4++;var $=S$;return S$=this,lL.bind(this,$)};OU.prototype.N=function(){if(!(2&this.f))this.f|=2,this.u=E0,E0=this};OU.prototype.d=function(){if(this.f|=8,!(1&this.f))b8(this)};OU.prototype.dispose=function(){this.d()};function B4($,U){var v=new OU($,U);try{v.c()}catch(_){throw v.d(),_}var J=v.d.bind(v);return J[Symbol.dispose]=J,J}var vY,M8,y2,rL=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var JY=[];B4(function(){vY=this.N})();function YU($,U){b$[$]=U.bind(null,b$[$]||function(){})}function C2($){if(y2){var U=y2;y2=void 0,U()}y2=$&&$.S()}function zY($){var U=this,v=$.data,J=pL(v);J.value=v;var _=u$(function(){var W=U,O=U.__v;while(O=O.__)if(O.__c){O.__c.__$f|=4;break}var Y=r$(function(){var B=J.value.value;return B===0?0:B===!0?"":B||""}),Z=r$(function(){return!Array.isArray(Y.value)&&!Z8(Y.value)}),q=B4(function(){if(this.N=KY,Z.value){var B=Y.value;if(W.__v&&W.__v.__e&&W.__v.__e.nodeType===3)W.__v.__e.data=B}}),X=U.__$u.d;return U.__$u.d=function(){q(),X.call(this)},[Z,Y]},[]),z=_[0],K=_[1];return z.value?K.peek():K.value}zY.displayName="ReactiveTextNode";Object.defineProperties(K6.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:zY},props:{configurable:!0,get:function(){var $=this;return{data:{get value(){return $.value}}}}},__b:{configurable:!0,value:1}});YU("__b",function($,U){if(typeof U.type=="string"){var v,J=U.props;for(var _ in J)if(_!=="children"){var z=J[_];if(z instanceof K6){if(!v)U.__np=v={};v[_]=z,J[_]=z.peek()}}}$(U)});YU("__r",function($,U){if($(U),U.type!==A$){C2();var v,J=U.__c;if(J){if(J.__$f&=-2,(v=J.__$u)===void 0)J.__$u=v=function(_,z){var K;return B4(function(){K=this},{name:z}),K.c=_,K}(function(){var _;if(rL)(_=v.y)==null||_.call(v);J.__$f|=1,J.setState({})},typeof U.type=="function"?U.type.displayName||U.type.name:"")}M8=J,C2(v)}});YU("__e",function($,U,v,J){C2(),M8=void 0,$(U,v,J)});YU("diffed",function($,U){C2(),M8=void 0;var v;if(typeof U.type=="string"&&(v=U.__e)){var{__np:J,props:_}=U;if(J){var z=v.U;if(z)for(var K in z){var W=z[K];if(W!==void 0&&!(K in J))W.d(),z[K]=void 0}else z={},v.U=z;for(var O in J){var Y=z[O],Z=J[O];if(Y===void 0)Y=iL(v,O,Z),z[O]=Y;else Y.o(Z,_)}for(var q in J)_[q]=J[q]}}$(U)});function iL($,U,v,J){var _=U in $&&$.ownerSVGElement===void 0,z=s(v),K=v.peek();return{o:function(W,O){z.value=W,K=W.peek()},d:B4(function(){this.N=KY;var W=z.value.value;if(K!==W)if(K=void 0,_)$[U]=W;else if(W!=null&&(W!==!1||U[4]==="-"))$.setAttribute(U,W);else $.removeAttribute(U);else K=void 0})}}YU("unmount",function($,U){if(typeof U.type=="string"){var v=U.__e;if(v){var J=v.U;if(J){v.U=void 0;for(var _ in J){var z=J[_];if(z)z.d()}}}U.__np=void 0}else{var K=U.__c;if(K){var W=K.__$u;if(W)K.__$u=void 0,W.d()}}$(U)});YU("__h",function($,U,v,J){if(J<3||J===9)U.__$f|=2;$(U,v,J)});KU.prototype.shouldComponentUpdate=function($,U){if(this.__R)return!0;var v=this.__$u,J=v&&v.s!==void 0;for(var _ in U)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var z=2&this.__$f;if(!(J||z||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(J||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var K in $)if(K!=="__source"&&$[K]!==this.props[K])return!0;for(var W in this.props)if(!(W in $))return!0;return!1};function pL($,U){return u$(function(){return s($,U)},[])}var oL=function($){queueMicrotask(function(){queueMicrotask($)})};function dL(){o6(function(){var $;while($=JY.shift())vY.call($)})}function KY(){if(JY.push(this)===1)(b$.requestAnimationFrame||oL)(dL)}var D2=s(null),u0=s([]),qU=s(new Set),BU=s(new Set),j2=s([]),V2=s(new Set),X4=s(!1),ZU=s(0);function GY(){D2.value=null,u0.value=[],qU.value=new Set,BU.value=new Set,j2.value=[],V2.value=new Set,X4.value=!1,ZU.value=0}function f2(){X4.value=!0,ZU.value=0}function WY(){X4.value=!1}function OY($,U,v){qU.value=new Set($),BU.value=new Set(U),j2.value=v}function E2($){D2.value=$}function YY($,U=6){if(u0.value=[$,...u0.value].slice(0,U),!X4.value)ZU.value=Math.min(99,ZU.value+1)}function u2($){V2.value=new Set($)}var nL=0;function G($,U,v,J,_,z){U||(U={});var K,W,O=U;if("ref"in O)for(W in O={},U)W=="ref"?K=U[W]:O[W]=U[W];var Y={type:$,props:O,key:v,ref:K,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--nL,__i:-1,__u:0,__source:_,__self:z};if(typeof $=="function"&&(K=$.defaultProps))for(W in K)O[W]===void 0&&(O[W]=K[W]);return b$.vnode&&b$.vnode(Y),Y}function tL($){return new Date($).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function aL(){f2()}function ZY(){let $=u0.value;if($.length===0)return null;let U=X4.value,v=ZU.value;if(!U)return G("button",{type:"button",class:"attention-history-tab",onClick:aL,"aria-label":v>0?`Recent updates — ${v} new`:"Recent updates",title:v>0?`${v} new updates since last viewed`:"Recent updates",children:[G("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("circle",{cx:"4.5",cy:"8",r:"1.1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"6.5",x2:"12.5",y2:"6.5"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"8",x2:"11",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"9.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"attention-history-tab-label",children:"Updates"},void 0,!1,void 0,this),v>0&&G("span",{class:"attention-history-tab-badge","aria-hidden":"true",children:v>9?"9+":v},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("aside",{class:"attention-history","aria-label":"Recent semantic changes",children:[G("div",{class:"attention-history-header",children:[G("div",{class:"attention-history-header-text",children:[G("span",{class:"attention-history-title",children:"Recent Updates"},void 0,!1,void 0,this),G("span",{class:"attention-history-subtitle",children:"Focus and meaning shifts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"attention-history-close",onClick:WY,"aria-label":"Collapse changes panel",title:"Collapse",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"attention-history-list",children:$.map((J)=>G("article",{class:`attention-history-entry attention-tone-${J.tone}`,children:[G("div",{class:"attention-history-meta",children:[G("span",{class:"attention-history-kind",children:J.title},void 0,!1,void 0,this),G("time",{class:"attention-history-time",dateTime:new Date(J.createdAt).toISOString(),children:tL(J.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("p",{class:"attention-history-detail",children:J.detail},void 0,!1,void 0,this)]},J.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function qY(){let $=D2.value;if(!$)return null;return G("button",{type:"button",class:`attention-toast attention-tone-${$.tone}`,onClick:f2,"aria-label":`${$.title} — open change history`,title:$.detail||$.title,children:[G("span",{class:"attention-toast-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("span",{class:"attention-toast-title",children:$.title},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var A8=null;function BY($){A8=$}function d6(){if(A8?.isConnected){let $=A8.getBoundingClientRect();if($.width>0&&$.height>0)return{left:$.left,top:$.top,width:$.width,height:$.height}}return{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}function C1(){let $=d6();return{x:$.left+$.width/2,y:$.top+$.height/2}}function XY(){let $=16;try{let U=d6(),v=U.top+U.height;for(let J of[".command-bar",".minimap"]){let _=document.querySelector(J);if(!(_ instanceof HTMLElement)||!_.isConnected)continue;let z=_.getBoundingClientRect();if(z.height<=0)continue;let K=v-z.top;if(K>0)$=Math.max($,K+12)}}catch{}return{top:16,right:16,bottom:$,left:16}}var x0=s(null),HY=0;function S4($,U,v={}){return new Promise((J)=>{x0.value?.resolve(null),HY+=1,x0.value={seq:HY,title:$,placeholder:U,initial:v.initial??"",allowEmpty:v.allowEmpty??!1,confirm:v.confirm??"Add",resolve:J}})}function m0($){let U=x0.value;x0.value=null,U?.resolve($)}function QY(){let $=x0.value,U=C(null);if(u(()=>{if(!$)return;let J=(_)=>{if(_.key!=="Escape")return;_.preventDefault(),_.stopPropagation(),m0(null)};return window.addEventListener("keydown",J,{capture:!0}),()=>window.removeEventListener("keydown",J,{capture:!0})},[$]),!$)return null;let v=()=>{let J=U.current?.value.trim()??"";m0(J?J:$.allowEmpty?"":null)};return G("div",{class:"text-prompt-backdrop",onPointerDown:()=>m0(null),children:G("div",{class:"text-prompt",role:"dialog","aria-label":$.title,"data-testid":"text-prompt",onPointerDown:(J)=>J.stopPropagation(),children:[G("div",{class:"text-prompt-title",children:$.title},void 0,!1,void 0,this),G("input",{ref:(J)=>{if(U.current=J,!J)return;if(J.focus(),$.initial)J.select()},class:"text-prompt-input",type:"text",defaultValue:$.initial,placeholder:$.placeholder,onKeyDown:(J)=>{if(J.key==="Enter")J.preventDefault(),J.stopPropagation(),v();else if(J.key==="Escape")J.preventDefault(),J.stopPropagation(),m0(null)}},$.seq,!1,void 0,this),G("div",{class:"text-prompt-actions",children:[G("button",{type:"button",class:"text-prompt-cancel",onClick:()=>m0(null),children:"Cancel"},void 0,!1,void 0,this),G("button",{type:"button",class:"text-prompt-confirm",onClick:v,children:$.confirm},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function I8($,U){console.error(`[intent-bridge] ${$} failed`,U)}var m2=(()=>{try{let $=new URLSearchParams(window.location.search).get("agent")?.trim();return $?$.slice(0,64):null}catch{return null}})();function w8($){let U={...$?.headers};if(m2)U["x-pmx-source"]=m2;else U["X-PMX-Workbench"]="1";return{...$,headers:U}}async function M$($,U,v,J){try{return await(await fetch(U,w8(J))).json()}catch(_){return I8($,_),v}}async function u6($,U,v){try{return{ok:(await fetch(U,w8(v))).ok}}catch(J){return I8($,J),{ok:!1}}}async function _4($,U,v){try{await fetch(U,w8(v))}catch(J){I8($,J)}}async function LY($,U={}){return M$("sendIntent","/api/workbench/intent",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:$,payload:U})})}async function D1($){let v=`Veto: do not ${$.label?.trim()||`${$.kind} intent`}${$.reason?` — ${$.reason}`:""}.`;if((await M$("vetoGhostIntent",`/api/canvas/ax/intent/${encodeURIComponent($.id)}`,{ok:!1,cleared:!1},{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({vetoed:!0})})).cleared!==!0)return!1;return await _4("vetoGhostSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,source:"browser"})}),!0}async function R4($){return(await M$("renderMarkdown","/api/render",{},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdown:$})})).html??""}async function h0($){return M$("fetchFile",`/api/file?path=${encodeURIComponent($)}`,{content:""})}async function FY($,U){return M$("saveFile","/api/file/save",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:$,content:U})})}async function x2($){return u6("openWorkbenchFile","/api/workbench/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:$})})}async function h2($){return M$("saveCanvasTheme","/api/canvas/theme",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:$})})}async function PY(){return[]}async function c0($,U,v,J,_){if(!$.trim())return{ok:!1,error:"Prompt text is required"};return M$("submitCanvasPrompt","/api/canvas/prompt",{ok:!1,error:"Network error"},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:$,...U?{position:U}:{},...v?{parentNodeId:v}:{},...J&&J.length>0?{contextNodeIds:J}:{},..._?{threadNodeId:_}:{}})})}async function kY($,U){return c0(U,void 0,void 0,void 0,$)}async function bY($,U={}){await _4("pushCanvasUpdate","/api/canvas/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:$,...U.recordHistory===!1?{recordHistory:!1}:{}})})}async function j1($,U,v,J){return M$("createEdgeFromClient","/api/canvas/edge",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:$,to:U,type:v,label:J})})}async function n6($){return M$("createNodeFromClient","/api/canvas/node",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)})}async function A6($,U){return M$("updateNodeFromClient",`/api/canvas/node/${encodeURIComponent($)}`,{ok:!1},{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)})}async function c2($,U){return M$("refreshWebpageNodeFromClient",`/api/canvas/node/${encodeURIComponent($)}/refresh`,{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U?{url:U}:{})})}async function n4($){return M$("removeNodeFromClient",`/api/canvas/node/${encodeURIComponent($)}`,{ok:!1},{method:"DELETE"})}async function g8(){return M$("fetchAxSurfaceState","/api/canvas/ax/surface-snapshot",null)}async function MY(){return M$("fetchAgentPresence","/api/canvas/ax/presence",null)}async function AY($,U){return M$("openNodeInSystemBrowserRequest","/api/canvas/open-external",{ok:!1,opened:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nodeId:$,url:U})})}async function l2($){return M$("submitAxInteractionFromClient","/api/canvas/ax/interaction",{ok:!1,code:"request-failed",error:"Request failed"},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceSurface:"native-node",...$,source:"browser"})})}async function IY($,U={}){return M$("updateViewportFromClient","/api/canvas/viewport",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,...wY(),...U.recordHistory===!1?{recordHistory:!1}:{}})})}function wY(){if(typeof window>"u")return{};let $=d6(),U=Math.round($.width),v=Math.round($.height);if(!U||!v)return{};return{clientWidth:U,clientHeight:v}}async function l0(){let $=wY();if(!("clientWidth"in $))return;await _4("reportClientViewportSize","/api/canvas/viewport",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...$,recordHistory:!1})})}async function XU($){return M$("createGroupFromClient","/api/canvas/group",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)})}async function N8($,U,v){return M$("addToGroupFromClient","/api/canvas/group/add",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:$,childIds:U,...v?{childLayout:v}:{}})})}async function r2($,U){return A6($,{children:U})}async function HU($){return M$("ungroupFromClient","/api/canvas/group/ungroup",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:$})})}async function gY(){return M$("listSnapshots","/api/canvas/snapshots?all=true",[])}async function NY($){return M$("saveSnapshot","/api/canvas/snapshots",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})})}async function SY($){return M$("restoreSnapshot",`/api/canvas/snapshots/${$}`,{ok:!1},{method:"POST"})}async function RY($){return M$("deleteSnapshot",`/api/canvas/snapshots/${$}`,{ok:!1},{method:"DELETE"})}async function i2($,U){return M$("updateEdgeFromClient",`/api/canvas/edge/${encodeURIComponent($)}`,{ok:!1},{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)})}async function p2($){return M$("removeEdgeFromClient","/api/canvas/edge",{ok:!1},{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({edge_id:$})})}var Z6={markdown:"MD","mcp-app":"APP",webpage:"WEB","json-render":"UI",graph:"GRAPH",prompt:"ASK",response:"ANS",status:"STATUS",context:"CONTEXT",ledger:"LOG",trace:"TRACE",file:"FILE",diff:"DIFF",mermaid:"MERMAID",image:"IMG",html:"HTML",group:"GROUP"},r0=new Set(["markdown","mcp-app","webpage","json-render","graph","context","ledger","file","diff","mermaid","image","html"]);function TY($){return $.type==="mcp-app"&&$.data.mode==="ext-app"&&$.data.serverName==="Excalidraw"&&$.data.toolName==="create_view"}var sL=700,eL=1600;function $F($){return $.replace(/\r\n?/g,`
|
|
22
|
+
`}}};Mn.tableCaption={filter:["caption"],replacement:()=>""};Mn.tableColgroup={filter:["colgroup","col"],replacement:()=>""};Mn.tableSection={filter:["thead","tbody","tfoot"],replacement:function(e){return e}};function SS(e){var t=e.parentNode;return t.nodeName==="THEAD"||t.firstChild===e&&(t.nodeName==="TABLE"||kS(t))&&bS.call(e.childNodes,function(n){return n.nodeName==="TH"})}function kS(e){var t=e.previousSibling;return e.nodeName==="TBODY"&&(!t||t.nodeName==="THEAD"&&/^\s*$/i.test(t.textContent))}function Kf(e,t=null,n=null){if(n===null)n=xS.call(t.parentNode.childNodes,t);var o=" ";if(n===0)o="| ";let r=e.trim().replace(/\n\r/g,"<br>").replace(/\n/g,"<br>");r=r.replace(/\|+/g,"\\|");while(r.length<3)r+=" ";if(t)r=ES(r,t," ");return o+r+" |"}function Jf(e){if(!e.childNodes)return!1;for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes[t];if(n.nodeName==="TABLE")return!0;if(Jf(n))return!0}return!1}var cl=(e,t)=>{if(!e.childNodes)return!1;for(let n=0;n<e.childNodes.length;n++){let o=e.childNodes[n];if(t==="code"&&al&&al(o))return!0;if(t.includes(o.nodeName))return!0;if(cl(o,t))return!0}return!1},Yf=(e,t)=>{let n=["UL","OL","H1","H2","H3","H4","H5","H6","HR","BLOCKQUOTE"];if(t.preserveNestedTables)n.push("TABLE");return cl(e,"code")||cl(e,n)};function ll(e){let t=Uf.get(e);if(t!==void 0)return t;let n=CS(e);return Uf.set(e,n),n}function CS(e){if(!e)return!0;if(!e.rows)return!0;if(e.rows.length===1&&e.rows[0].childNodes.length<=1)return!0;if(Jf(e))return!0;return!1}function TS(e){let t=e.parentNode;while(t.nodeName!=="DIV")if(t=t.parentNode,!t)return null;return t}function Qf(e){let t=e.parentNode;while(t.nodeName!=="TABLE")if(t=t.parentNode,!t)return null;return t}function ES(e,t,n){let o=t.getAttribute("colspan")||1;for(let r=1;r<o;r++)e+=" | "+n.repeat(3);return e}function em(e){let t=0;for(let n=0;n<e.rows.length;n++){let r=e.rows[n].childNodes.length;if(r>t)t=r}return t}function tm(e){al=e.isCodeBlock,Vf=e.options,e.keep(function(n){if(n.nodeName==="TABLE"&&Yf(n,e.options))return!0;return!1});for(var t in Mn)e.addRule(t,Mn[t])}function nm(e){e.addRule("taskListItems",{filter:function(t){let n=t.parentNode,o=n.parentNode;return t.type==="checkbox"&&(n.nodeName==="LI"||n.nodeName==="LABEL"&&o&&o.nodeName==="LI")},replacement:function(t,n){return(n.checked?"[x]":"[ ]")+" "}})}function AS(e){e.use([Wf,qf,tm,nm])}om.gfm=AS;om.highlightedCodeBlock=Wf;om.strikethrough=qf;om.tables=tm;om.taskListItems=nm});if(typeof crypto<"u"&&typeof crypto.randomUUID!=="function")crypto.randomUUID=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e)=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});var ji,ge,Kd,_c,En,qd,Jd,Yd,Qd,Sc,xc,bc,Uw,Li={},Di=[],Ww=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Zi=Array.isArray;function on(e,t){for(var n in t)e[n]=t[n];return e}function kc(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qw(e,t,n){var o,r,s,a={};for(s in t)s=="key"?o=t[s]:s=="ref"?r=t[s]:a[s]=t[s];if(arguments.length>2&&(a.children=arguments.length>3?ji.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)a[s]===void 0&&(a[s]=e.defaultProps[s]);return Oi(e,a,o,r,null)}function Oi(e,t,n,o,r){var s={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r==null?++Kd:r,__i:-1,__u:0};return r==null&&ge.vnode!=null&&ge.vnode(s),s}function ye(e){return e.children}function No(e,t){this.props=e,this.context=t}function Ro(e,t){if(t==null)return e.__?Ro(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Ro(e):null}function Vw(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],r=[],s=on({},t);s.__v=t.__v+1,ge.vnode&&ge.vnode(s),Cc(e.__P,s,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n==null?Ro(t):n,!!(32&t.__u),r),s.__v=t.__v,s.__.__k[s.__i]=s,op(o,s,r),t.__e=t.__=null,s.__e!=n&&ep(s)}}function ep(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ep(e)}function Vd(e){(!e.__d&&(e.__d=!0)&&En.push(e)&&!Fi.__r++||qd!=ge.debounceRendering)&&((qd=ge.debounceRendering)||Jd)(Fi)}function Fi(){try{for(var e,t=1;En.length;)En.length>t&&En.sort(Yd),e=En.shift(),t=En.length,Vw(e)}finally{En.length=Fi.__r=0}}function tp(e,t,n,o,r,s,a,c,l,u,d){var p,m,f,y,v,x,h,g=o&&o.__k||Di,b=t.length;for(l=Gw(n,t,g,l,b),p=0;p<b;p++)(f=n.__k[p])!=null&&(m=f.__i!=-1&&g[f.__i]||Li,f.__i=p,x=Cc(e,f,m,r,s,a,c,l,u,d),y=f.__e,f.ref&&m.ref!=f.ref&&(m.ref&&Tc(m.ref,null,f),d.push(f.ref,f.__c||y,f)),v==null&&y!=null&&(v=y),(h=!!(4&f.__u))||m.__k===f.__k?l=np(f,l,e,h):typeof f.type=="function"&&x!==void 0?l=x:y&&(l=y.nextSibling),f.__u&=-7);return n.__e=v,l}function Gw(e,t,n,o,r){var s,a,c,l,u,d=n.length,p=d,m=0;for(e.__k=Array(r),s=0;s<r;s++)(a=t[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[s]=Oi(null,a,null,null,null):Zi(a)?a=e.__k[s]=Oi(ye,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[s]=Oi(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[s]=a,l=s+m,a.__=e,a.__b=e.__b+1,c=null,(u=a.__i=Xw(a,n,l,p))!=-1&&(p--,(c=n[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(r>d?m--:r<d&&m++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?m--:u==l+1?m++:(u>l?m--:m++,a.__u|=4))):e.__k[s]=null;if(p)for(s=0;s<d;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=Ro(c)),ip(c,c));return o}function np(e,t,n,o){var r,s;if(typeof e.type=="function"){for(r=e.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=e,t=np(r[s],t,n,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=Ro(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Xw(e,t,n,o){var r,s,a,{key:c,type:l}=e,u=t[n],d=u!=null&&(2&u.__u)==0;if(u===null&&c==null||d&&c==u.key&&l==u.type)return n;if(o>(d?1:0)){for(r=n-1,s=n+1;r>=0||s<t.length;)if((u=t[a=r>=0?r--:s++])!=null&&(2&u.__u)==0&&c==u.key&&l==u.type)return a}return-1}function Gd(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":typeof n!="number"||Ww.test(t)?n:n+"px"}function Mi(e,t,n,o,r){var s,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||Gd(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||Gd(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(Qd,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?o?n.u=o.u:(n.u=Sc,e.addEventListener(t,s?bc:xc,s)):e.removeEventListener(t,s?bc:xc,s);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n==null?"":n;break e}catch(c){}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Xd(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Sc++;else if(t.t<n.u)return;return n(ge.event?ge.event(t):t)}}}function Cc(e,t,n,o,r,s,a,c,l,u){var d,p,m,f,y,v,x,h,g,b,O,F,_,k,T,P=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),s=[c=t.__e=n.__e]),(d=ge.__b)&&d(t);e:if(typeof P=="function")try{if(h=t.props,g=P.prototype&&P.prototype.render,b=(d=P.contextType)&&o[d.__c],O=d?b?b.props.value:d.__:o,n.__c?x=(p=t.__c=n.__c).__=p.__E:(g?t.__c=p=new P(h,O):(t.__c=p=new No(h,O),p.constructor=P,p.render=Jw),b&&b.sub(p),p.state||(p.state={}),p.__n=o,m=p.__d=!0,p.__h=[],p._sb=[]),g&&p.__s==null&&(p.__s=p.state),g&&P.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=on({},p.__s)),on(p.__s,P.getDerivedStateFromProps(h,p.__s))),f=p.props,y=p.state,p.__v=t,m)g&&P.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),g&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(g&&P.getDerivedStateFromProps==null&&h!==f&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(h,O),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(h,p.__s,O)===!1){t.__v!=n.__v&&(p.props=h,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(Z){Z&&(Z.__=t)}),Di.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&a.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(h,p.__s,O),g&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(f,y,v)})}if(p.context=O,p.props=h,p.__P=e,p.__e=!1,F=ge.__r,_=0,g)p.state=p.__s,p.__d=!1,F&&F(t),d=p.render(p.props,p.state,p.context),Di.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,F&&F(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++_<25);p.state=p.__s,p.getChildContext!=null&&(o=on(on({},o),p.getChildContext())),g&&!m&&p.getSnapshotBeforeUpdate!=null&&(v=p.getSnapshotBeforeUpdate(f,y)),k=d!=null&&d.type===ye&&d.key==null?rp(d.props.children):d,c=tp(e,Zi(k)?k:[k],t,n,o,r,s,a,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&a.push(p),x&&(p.__E=p.__=null)}catch(Z){if(t.__v=null,l||s!=null)if(Z.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,t.__e=c}else{for(T=s.length;T--;)kc(s[T]);wc(t)}else t.__e=n.__e,t.__k=n.__k,Z.then||wc(t);ge.__e(Z,t,n)}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=Kw(n.__e,t,n,o,r,s,a,l,u);return(d=ge.diffed)&&d(t),128&t.__u?void 0:c}function wc(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(wc))}function op(e,t,n){for(var o=0;o<n.length;o++)Tc(n[o],n[++o],n[++o]);ge.__c&&ge.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(s){s.call(r)})}catch(s){ge.__e(s,r.__v)}})}function rp(e){return typeof e!="object"||e==null||e.__b>0?e:Zi(e)?e.map(rp):on({},e)}function Kw(e,t,n,o,r,s,a,c,l){var u,d,p,m,f,y,v,x=n.props||Li,{props:h,type:g}=t;if(g=="svg"?r="http://www.w3.org/2000/svg":g=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(u=0;u<s.length;u++)if((f=s[u])&&"setAttribute"in f==!!g&&(g?f.localName==g:f.nodeType==3)){e=f,s[u]=null;break}}if(e==null){if(g==null)return document.createTextNode(h);e=document.createElementNS(r,g,h.is&&h),c&&(ge.__m&&ge.__m(t,s),c=!1),s=null}if(g==null)x===h||c&&e.data==h||(e.data=h);else{if(s=s&&ji.call(e.childNodes),!c&&s!=null)for(x={},u=0;u<e.attributes.length;u++)x[(f=e.attributes[u]).name]=f.value;for(u in x)f=x[u],u=="dangerouslySetInnerHTML"?p=f:u=="children"||(u in h)||u=="value"&&("defaultValue"in h)||u=="checked"&&("defaultChecked"in h)||Mi(e,u,null,f,r);for(u in h)f=h[u],u=="children"?m=f:u=="dangerouslySetInnerHTML"?d=f:u=="value"?y=f:u=="checked"?v=f:c&&typeof f!="function"||x[u]===f||Mi(e,u,f,x[u],r);if(d)c||p&&(d.__html==p.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(p&&(e.innerHTML=""),tp(t.type=="template"?e.content:e,Zi(m)?m:[m],t,n,o,g=="foreignObject"?"http://www.w3.org/1999/xhtml":r,s,a,s?s[0]:n.__k&&Ro(n,0),c,l),s!=null)for(u=s.length;u--;)kc(s[u]);c||(u="value",g=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[u]||g=="progress"&&!y||g=="option"&&y!=x[u])&&Mi(e,u,y,x[u],r),u="checked",v!=null&&v!=e[u]&&Mi(e,u,v,x[u],r))}return e}function Tc(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(r){ge.__e(r,n)}}function ip(e,t,n){var o,r;if(ge.unmount&&ge.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Tc(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){ge.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(r=0;r<o.length;r++)o[r]&&ip(o[r],t,n||typeof e.type!="function");n||kc(e.__e),e.__c=e.__=e.__e=void 0}function Jw(e,t,n){return this.constructor(e,n)}function sp(e,t,n){var o,r,s,a;t==document&&(t=document.documentElement),ge.__&&ge.__(e,t),r=(o=typeof n=="function")?null:n&&n.__k||t.__k,s=[],a=[],Cc(t,e=(!o&&n||t).__k=qw(ye,null,[e]),r||Li,Li,t.namespaceURI,!o&&n?[n]:r?null:t.firstChild?ji.call(t.childNodes):null,s,!o&&n?n:r?r.__e:t.firstChild,o,a),op(s,e,a)}ji=Di.slice,ge={__e:function(e,t,n,o){for(var r,s,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(e)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,o||{}),a=r.__d),a)return r.__E=r}catch(c){e=c}throw e}},Kd=0,_c=function(e){return e!=null&&e.constructor===void 0},No.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=on({},this.state),typeof e=="function"&&(e=e(on({},n),this.props)),e&&on(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Vd(this))},No.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Vd(this))},No.prototype.render=ye,En=[],Jd=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yd=function(e,t){return e.__v.__b-t.__v.__b},Fi.__r=0,Qd=/(PointerCapture)$|Capture$/i,Sc=0,xc=Xd(!1),bc=Xd(!0),Uw=0;var $o,We,Ec,ap,Rr=0,hp=[],Ve=ge,{__b:cp,__r:lp,diffed:up,__c:dp,unmount:pp,__:fp}=Ve;function Bi(e,t){Ve.__h&&Ve.__h(We,e,Rr||t),Rr=0;var n=We.__H||(We.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function L(e){return Rr=1,Yw(gp,e)}function Yw(e,t,n){var o=Bi($o++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):gp(void 0,t),function(c){var l=o.__N?o.__N[0]:o.__[0],u=o.t(l,c);l!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=We,!We.__f)){var r=function(c,l,u){if(!o.__c.__H)return!0;var d=o.__c.__H.__.filter(function(m){return m.__c});if(d.every(function(m){return!m.__N}))return!s||s.call(this,c,l,u);var p=o.__c.props!==c;return d.some(function(m){if(m.__N){var f=m.__[0];m.__=m.__N,m.__N=void 0,f!==m.__[0]&&(p=!0)}}),s&&s.call(this,c,l,u)||p};We.__f=!0;var s=We.shouldComponentUpdate,a=We.componentWillUpdate;We.componentWillUpdate=function(c,l,u){if(this.__e){var d=s;s=void 0,r(c,l,u),s=d}a&&a.call(this,c,l,u)},We.shouldComponentUpdate=r}return o.__N||o.__}function D(e,t){var n=Bi($o++,3);!Ve.__s&&Ic(n.__H,t)&&(n.__=e,n.u=t,We.__H.__h.push(n))}function Ui(e,t){var n=Bi($o++,4);!Ve.__s&&Ic(n.__H,t)&&(n.__=e,n.u=t,We.__h.push(n))}function N(e){return Rr=5,Ie(function(){return{current:e}},[])}function Ie(e,t){var n=Bi($o++,7);return Ic(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function M(e,t){return Rr=8,Ie(function(){return e},t)}function Qw(){for(var e;e=hp.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Hi),t.__h.some(Ac),t.__h=[]}catch(n){t.__h=[],Ve.__e(n,e.__v)}}}Ve.__b=function(e){We=null,cp&&cp(e)},Ve.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),fp&&fp(e,t)},Ve.__r=function(e){lp&&lp(e),$o=0;var t=(We=e.__c).__H;t&&(Ec===We?(t.__h=[],We.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Hi),t.__h.some(Ac),t.__h=[],$o=0)),Ec=We},Ve.diffed=function(e){up&&up(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(hp.push(t)!==1&&ap===Ve.requestAnimationFrame||((ap=Ve.requestAnimationFrame)||e_)(Qw)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Ec=We=null},Ve.__c=function(e,t){t.some(function(n){try{n.__h.some(Hi),n.__h=n.__h.filter(function(o){return!o.__||Ac(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],Ve.__e(o,n.__v)}}),dp&&dp(e,t)},Ve.unmount=function(e){pp&&pp(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{Hi(o)}catch(r){t=r}}),n.__H=void 0,t&&Ve.__e(t,n.__v))};var mp=typeof requestAnimationFrame=="function";function e_(e){var t,n=function(){clearTimeout(o),mp&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);mp&&(t=requestAnimationFrame(n))}function Hi(e){var t=We,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),We=t}function Ac(e){var t=We;e.__c=e.__(),We=t}function Ic(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function gp(e,t){return typeof t=="function"?t(e):t}var t_=Symbol.for("preact-signals");function Gi(){if(!(rn>1)){var e,t=!1;(function(){var r=qi;qi=void 0;while(r!==void 0){if(r.S.v===r.v)r.S.i=r.i;r=r.o}})();while($r!==void 0){var n=$r;$r=void 0,Wi++;while(n!==void 0){var o=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&xp(n))try{n.c()}catch(r){if(!t)e=r,t=!0}n=o}}if(Wi=0,rn--,t)throw e}else rn--}function $t(e){if(rn>0)return e();zc=++n_,rn++;try{return e()}finally{Gi()}}var Se=void 0;function Pc(e){var t=Se;Se=void 0;try{return e()}finally{Se=t}}var vp,$r=void 0,rn=0,Wi=0,n_=0,zc=0,qi=void 0,Vi=0;function yp(e){if(Se!==void 0){var t=e.n;if(t===void 0||t.t!==Se){if(t={i:0,S:e,p:Se.s,n:void 0,t:Se,e:void 0,x:void 0,r:t},Se.s!==void 0)Se.s.n=t;if(Se.s=t,e.n=t,32&Se.f)e.S(t);return t}else if(t.i===-1){if(t.i=0,t.n!==void 0){if(t.n.p=t.p,t.p!==void 0)t.p.n=t.n;t.p=Se.s,t.n=void 0,Se.s.n=t,Se.s=t}return t}}}function Qe(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}Qe.prototype.brand=t_;Qe.prototype.h=function(){return!0};Qe.prototype.S=function(e){var t=this,n=this.t;if(n!==e&&e.e===void 0)if(e.x=n,this.t=e,n!==void 0)n.e=e;else Pc(function(){var o;(o=t.W)==null||o.call(t)})};Qe.prototype.U=function(e){var t=this;if(this.t!==void 0){var{e:n,x:o}=e;if(n!==void 0)n.x=o,e.e=void 0;if(o!==void 0)o.e=n,e.x=void 0;if(e===this.t){if(this.t=o,o===void 0)Pc(function(){var r;(r=t.Z)==null||r.call(t)})}}};Qe.prototype.subscribe=function(e){var t=this;return Kt(function(){var n=t.value,o=Se;Se=void 0;try{e(n)}finally{Se=o}},{name:"sub"})};Qe.prototype.valueOf=function(){return this.value};Qe.prototype.toString=function(){return this.value+""};Qe.prototype.toJSON=function(){return this.value};Qe.prototype.peek=function(){var e=Se;Se=void 0;try{return this.value}finally{Se=e}};Object.defineProperty(Qe.prototype,"value",{get:function(){var e=yp(this);if(e!==void 0)e.i=this.i;return this.v},set:function(e){if(e!==this.v){if(Wi>100)throw Error("Cycle detected");(function(n){if(rn!==0&&Wi===0){if(n.l!==zc)n.l=zc,qi={S:n,v:n.v,i:n.i,o:qi}}})(this),this.v=e,this.i++,Vi++,rn++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Gi()}}}});function V(e,t){return new Qe(e,t)}function xp(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function bp(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0)t.r=n;if(t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function wp(e){var t=e.s,n=void 0;while(t!==void 0){var o=t.p;if(t.i===-1){if(t.S.U(t),o!==void 0)o.n=t.n;if(t.n!==void 0)t.n.p=o}else n=t;if(t.S.n=t.r,t.r!==void 0)t.r=void 0;t=o}e.s=n}function io(e,t){Qe.call(this,void 0),this.x=e,this.s=void 0,this.g=Vi-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}io.prototype=new Qe;io.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32)return!0;if(this.f&=-5,this.g===Vi)return!0;if(this.g=Vi,this.f|=1,this.i>0&&!xp(this))return this.f&=-2,!0;var e=Se;try{bp(this),Se=this;var t=this.x();if(16&this.f||this.v!==t||this.i===0)this.v=t,this.f&=-17,this.i++}catch(n){this.v=n,this.f|=16,this.i++}return Se=e,wp(this),this.f&=-2,!0};io.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Qe.prototype.S.call(this,e)};io.prototype.U=function(e){if(this.t!==void 0){if(Qe.prototype.U.call(this,e),this.t===void 0){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}}};io.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(io.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=yp(this);if(this.h(),e!==void 0)e.i=this.i;if(16&this.f)throw this.v;return this.v}});function Le(e,t){return new io(e,t)}function _p(e){var t=e.m;if(e.m=void 0,typeof t=="function"){rn++;var n=Se;Se=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Nc(e),o}finally{Se=n,Gi()}}}function Nc(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,_p(e)}function o_(e){if(Se!==this)throw Error("Out-of-order effect");if(wp(this),Se=e,this.f&=-2,8&this.f)Nc(this);Gi()}function Mo(e,t){if(this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name,vp)vp.push(this)}Mo.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(this.x===void 0)return;var t=this.x();if(typeof t=="function")this.m=t}finally{e()}};Mo.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,_p(this),bp(this),rn++;var e=Se;return Se=this,o_.bind(this,e)};Mo.prototype.N=function(){if(!(2&this.f))this.f|=2,this.u=$r,$r=this};Mo.prototype.d=function(){if(this.f|=8,!(1&this.f))Nc(this)};Mo.prototype.dispose=function(){this.d()};function Kt(e,t){var n=new Mo(e,t);try{n.c()}catch(r){throw n.d(),r}var o=n.d.bind(n);return o[Symbol.dispose]=o,o}var Sp,Rc,Xi,r_=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var kp=[];Kt(function(){Sp=this.N})();function Oo(e,t){ge[e]=t.bind(null,ge[e]||function(){})}function Ki(e){if(Xi){var t=Xi;Xi=void 0,t()}Xi=e&&e.S()}function Cp(e){var t=this,n=e.data,o=s_(n);o.value=n;var r=Ie(function(){var c=t,l=t.__v;while(l=l.__)if(l.__c){l.__c.__$f|=4;break}var u=Le(function(){var f=o.value.value;return f===0?0:f===!0?"":f||""}),d=Le(function(){return!Array.isArray(u.value)&&!_c(u.value)}),p=Kt(function(){if(this.N=Tp,d.value){var f=u.value;if(c.__v&&c.__v.__e&&c.__v.__e.nodeType===3)c.__v.__e.data=f}}),m=t.__$u.d;return t.__$u.d=function(){p(),m.call(this)},[d,u]},[]),s=r[0],a=r[1];return s.value?a.peek():a.value}Cp.displayName="ReactiveTextNode";Object.defineProperties(Qe.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Cp},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Oo("__b",function(e,t){if(typeof t.type=="string"){var n,o=t.props;for(var r in o)if(r!=="children"){var s=o[r];if(s instanceof Qe){if(!n)t.__np=n={};n[r]=s,o[r]=s.peek()}}}e(t)});Oo("__r",function(e,t){if(e(t),t.type!==ye){Ki();var n,o=t.__c;if(o){if(o.__$f&=-2,(n=o.__$u)===void 0)o.__$u=n=function(r,s){var a;return Kt(function(){a=this},{name:s}),a.c=r,a}(function(){var r;if(r_)(r=n.y)==null||r.call(n);o.__$f|=1,o.setState({})},typeof t.type=="function"?t.type.displayName||t.type.name:"")}Rc=o,Ki(n)}});Oo("__e",function(e,t,n,o){Ki(),Rc=void 0,e(t,n,o)});Oo("diffed",function(e,t){Ki(),Rc=void 0;var n;if(typeof t.type=="string"&&(n=t.__e)){var{__np:o,props:r}=t;if(o){var s=n.U;if(s)for(var a in s){var c=s[a];if(c!==void 0&&!(a in o))c.d(),s[a]=void 0}else s={},n.U=s;for(var l in o){var u=s[l],d=o[l];if(u===void 0)u=i_(n,l,d),s[l]=u;else u.o(d,r)}for(var p in o)r[p]=o[p]}}e(t)});function i_(e,t,n,o){var r=t in e&&e.ownerSVGElement===void 0,s=V(n),a=n.peek();return{o:function(c,l){s.value=c,a=c.peek()},d:Kt(function(){this.N=Tp;var c=s.value.value;if(a!==c)if(a=void 0,r)e[t]=c;else if(c!=null&&(c!==!1||t[4]==="-"))e.setAttribute(t,c);else e.removeAttribute(t);else a=void 0})}}Oo("unmount",function(e,t){if(typeof t.type=="string"){var n=t.__e;if(n){var o=n.U;if(o){n.U=void 0;for(var r in o){var s=o[r];if(s)s.d()}}}t.__np=void 0}else{var a=t.__c;if(a){var c=a.__$u;if(c)a.__$u=void 0,c.d()}}e(t)});Oo("__h",function(e,t,n,o){if(o<3||o===9)t.__$f|=2;e(t,n,o)});No.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,o=n&&n.s!==void 0;for(var r in t)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(o||s||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(o||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var a in e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var c in this.props)if(!(c in e))return!0;return!1};function s_(e,t){return Ie(function(){return V(e,t)},[])}var a_=function(e){queueMicrotask(function(){queueMicrotask(e)})};function c_(){$t(function(){var e;while(e=kp.shift())Sp.call(e)})}function Tp(){if(kp.push(this)===1)(ge.requestAnimationFrame||a_)(c_)}var Ji=V(null),Mr=V([]),Do=V(new Set),Fo=V(new Set),Yi=V([]),Qi=V(new Set),Jt=V(!1),Lo=V(0);function Ep(){Ji.value=null,Mr.value=[],Do.value=new Set,Fo.value=new Set,Yi.value=[],Qi.value=new Set,Jt.value=!1,Lo.value=0}function es(){Jt.value=!0,Lo.value=0}function Ap(){Jt.value=!1}function Ip(e,t,n){Do.value=new Set(e),Fo.value=new Set(t),Yi.value=n}function ts(e){Ji.value=e}function zp(e,t=6){if(Mr.value=[e,...Mr.value].slice(0,t),!Jt.value)Lo.value=Math.min(99,Lo.value+1)}function ns(e){Qi.value=new Set(e)}var l_=0;function i(e,t,n,o,r,s){t||(t={});var a,c,l=t;if("ref"in l)for(c in l={},t)c=="ref"?a=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--l_,__i:-1,__u:0,__source:r,__self:s};if(typeof e=="function"&&(a=e.defaultProps))for(c in a)l[c]===void 0&&(l[c]=a[c]);return ge.vnode&&ge.vnode(u),u}function u_(e){return new Date(e).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function d_(){es()}function Pp(){let e=Mr.value;if(e.length===0)return null;let t=Jt.value,n=Lo.value;if(!t)return i("button",{type:"button",class:"attention-history-tab",onClick:d_,"aria-label":n>0?`Recent updates — ${n} new`:"Recent updates",title:n>0?`${n} new updates since last viewed`:"Recent updates",children:[i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("circle",{cx:"4.5",cy:"8",r:"1.1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"6.5",x2:"12.5",y2:"6.5"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"8",x2:"11",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"9.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"attention-history-tab-label",children:"Updates"},void 0,!1,void 0,this),n>0&&i("span",{class:"attention-history-tab-badge","aria-hidden":"true",children:n>9?"9+":n},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("aside",{class:"attention-history","aria-label":"Recent semantic changes",children:[i("div",{class:"attention-history-header",children:[i("div",{class:"attention-history-header-text",children:[i("span",{class:"attention-history-title",children:"Recent Updates"},void 0,!1,void 0,this),i("span",{class:"attention-history-subtitle",children:"Focus and meaning shifts"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"attention-history-close",onClick:Ap,"aria-label":"Collapse changes panel",title:"Collapse",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"attention-history-list",children:e.map((o)=>i("article",{class:`attention-history-entry attention-tone-${o.tone}`,children:[i("div",{class:"attention-history-meta",children:[i("span",{class:"attention-history-kind",children:o.title},void 0,!1,void 0,this),i("time",{class:"attention-history-time",dateTime:new Date(o.createdAt).toISOString(),children:u_(o.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("p",{class:"attention-history-detail",children:o.detail},void 0,!1,void 0,this)]},o.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Np(){let e=Ji.value;if(!e)return null;return i("button",{type:"button",class:`attention-toast attention-tone-${e.tone}`,onClick:es,"aria-label":`${e.title} — open change history`,title:e.detail||e.title,children:[i("span",{class:"attention-toast-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("span",{class:"attention-toast-title",children:e.title},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $c=null;function Rp(e){$c=e}function bt(){if($c?.isConnected){let e=$c.getBoundingClientRect();if(e.width>0&&e.height>0)return{left:e.left,top:e.top,width:e.width,height:e.height}}return{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}function jo(){let e=bt();return{x:e.left+e.width/2,y:e.top+e.height/2}}function Mc(){let e=16;try{let t=bt(),n=t.top+t.height;for(let o of[".command-bar",".minimap"]){let r=document.querySelector(o);if(!(r instanceof HTMLElement)||!r.isConnected)continue;let s=r.getBoundingClientRect();if(s.height<=0)continue;let a=n-s.top;if(a>0)e=Math.max(e,a+12)}}catch{}return{top:16,right:16,bottom:e,left:16}}var Lr=V(null),$p=0;function sn(e,t,n={}){return new Promise((o)=>{Lr.value?.resolve(null),$p+=1,Lr.value={seq:$p,title:e,placeholder:t,initial:n.initial??"",allowEmpty:n.allowEmpty??!1,confirm:n.confirm??"Add",resolve:o}})}function Or(e){let t=Lr.value;Lr.value=null,t?.resolve(e)}function Mp(){let e=Lr.value,t=N(null);if(D(()=>{if(!e)return;let o=(r)=>{if(r.key!=="Escape")return;r.preventDefault(),r.stopPropagation(),Or(null)};return window.addEventListener("keydown",o,{capture:!0}),()=>window.removeEventListener("keydown",o,{capture:!0})},[e]),!e)return null;let n=()=>{let o=t.current?.value.trim()??"";Or(o?o:e.allowEmpty?"":null)};return i("div",{class:"text-prompt-backdrop",onPointerDown:()=>Or(null),children:i("div",{class:"text-prompt",role:"dialog","aria-label":e.title,"data-testid":"text-prompt",onPointerDown:(o)=>o.stopPropagation(),children:[i("div",{class:"text-prompt-title",children:e.title},void 0,!1,void 0,this),i("input",{ref:(o)=>{if(t.current=o,!o)return;if(o.focus(),e.initial)o.select()},class:"text-prompt-input",type:"text",defaultValue:e.initial,placeholder:e.placeholder,onKeyDown:(o)=>{if(o.key==="Enter")o.preventDefault(),o.stopPropagation(),n();else if(o.key==="Escape")o.preventDefault(),o.stopPropagation(),Or(null)}},e.seq,!1,void 0,this),i("div",{class:"text-prompt-actions",children:[i("button",{type:"button",class:"text-prompt-cancel",onClick:()=>Or(null),children:"Cancel"},void 0,!1,void 0,this),i("button",{type:"button",class:"text-prompt-confirm",onClick:n,children:e.confirm},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Oc(e,t){console.error(`[intent-bridge] ${e} failed`,t)}var os=(()=>{try{let e=new URLSearchParams(window.location.search).get("agent")?.trim();return e?e.slice(0,64):null}catch{return null}})();function Lc(e){let t={...e?.headers};if(os)t["x-pmx-source"]=os;else t["X-PMX-Workbench"]="1";return{...e,headers:t}}async function ve(e,t,n,o){try{return await(await fetch(t,Lc(o))).json()}catch(r){return Oc(e,r),n}}async function kt(e,t,n){try{return{ok:(await fetch(t,Lc(n))).ok}}catch(o){return Oc(e,o),{ok:!1}}}async function jt(e,t,n){try{await fetch(t,Lc(n))}catch(o){Oc(e,o)}}async function Op(e,t={}){return ve("sendIntent","/api/workbench/intent",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:e,payload:t})})}async function so(e){let n=`Veto: do not ${e.label?.trim()||`${e.kind} intent`}${e.reason?` — ${e.reason}`:""}.`;if((await ve("vetoGhostIntent",`/api/canvas/ax/intent/${encodeURIComponent(e.id)}`,{ok:!1,cleared:!1},{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({vetoed:!0})})).cleared!==!0)return!1;return await jt("vetoGhostSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,source:"browser"})}),!0}async function an(e){return(await ve("renderMarkdown","/api/render",{},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({markdown:e})})).html??""}async function Dr(e){return ve("fetchFile",`/api/file?path=${encodeURIComponent(e)}`,{content:""})}async function Lp(e,t){return ve("saveFile","/api/file/save",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,content:t})})}async function rs(e){return kt("openWorkbenchFile","/api/workbench/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})})}async function is(e){return ve("saveCanvasTheme","/api/canvas/theme",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:e})})}async function Dp(){return[]}async function Fr(e,t,n,o,r){if(!e.trim())return{ok:!1,error:"Prompt text is required"};return ve("submitCanvasPrompt","/api/canvas/prompt",{ok:!1,error:"Network error"},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e,...t?{position:t}:{},...n?{parentNodeId:n}:{},...o&&o.length>0?{contextNodeIds:o}:{},...r?{threadNodeId:r}:{}})})}async function Fp(e,t){return Fr(t,void 0,void 0,void 0,e)}async function jp(e,t={}){await jt("pushCanvasUpdate","/api/canvas/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:e,...t.recordHistory===!1?{recordHistory:!1}:{}})})}async function ao(e,t,n,o){return ve("createEdgeFromClient","/api/canvas/edge",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:e,to:t,type:n,label:o})})}async function Mt(e){return ve("createNodeFromClient","/api/canvas/node",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function ft(e,t){return ve("updateNodeFromClient",`/api/canvas/node/${encodeURIComponent(e)}`,{ok:!1},{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function ss(e,t){return ve("refreshWebpageNodeFromClient",`/api/canvas/node/${encodeURIComponent(e)}/refresh`,{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{url:t}:{})})}async function An(e){return ve("removeNodeFromClient",`/api/canvas/node/${encodeURIComponent(e)}`,{ok:!1},{method:"DELETE"})}async function Dc(){return ve("fetchAxSurfaceState","/api/canvas/ax/surface-snapshot",null)}async function Zp(){return ve("fetchAgentPresence","/api/canvas/ax/presence",null)}async function Hp(e,t){return ve("openNodeInSystemBrowserRequest","/api/canvas/open-external",{ok:!1,opened:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nodeId:e,url:t})})}async function as(e){return ve("submitAxInteractionFromClient","/api/canvas/ax/interaction",{ok:!1,code:"request-failed",error:"Request failed"},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceSurface:"native-node",...e,source:"browser"})})}async function Bp(e,t={}){return ve("updateViewportFromClient","/api/canvas/viewport",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,...Up(),...t.recordHistory===!1?{recordHistory:!1}:{}})})}function Up(){if(typeof window>"u")return{};let e=bt(),t=Math.round(e.width),n=Math.round(e.height);if(!t||!n)return{};return{clientWidth:t,clientHeight:n}}async function jr(){let e=Up();if(!("clientWidth"in e))return;await jt("reportClientViewportSize","/api/canvas/viewport",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,recordHistory:!1})})}async function Zo(e){return ve("createGroupFromClient","/api/canvas/group",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Fc(e,t,n){return ve("addToGroupFromClient","/api/canvas/group/add",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:e,childIds:t,...n?{childLayout:n}:{}})})}async function cs(e,t){return ft(e,{children:t})}async function Ho(e){return ve("ungroupFromClient","/api/canvas/group/ungroup",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({groupId:e})})}async function Wp(){return ve("listSnapshots","/api/canvas/snapshots?all=true",[])}async function qp(e){return ve("saveSnapshot","/api/canvas/snapshots",{ok:!1},{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})})}async function Vp(e){return ve("restoreSnapshot",`/api/canvas/snapshots/${e}`,{ok:!1},{method:"POST"})}async function Gp(e){return ve("deleteSnapshot",`/api/canvas/snapshots/${e}`,{ok:!1},{method:"DELETE"})}async function ls(e,t){return ve("updateEdgeFromClient",`/api/canvas/edge/${encodeURIComponent(e)}`,{ok:!1},{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function us(e){return ve("removeEdgeFromClient","/api/canvas/edge",{ok:!1},{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({edge_id:e})})}var ot={markdown:"MD","mcp-app":"APP",webpage:"WEB","json-render":"UI",graph:"GRAPH",prompt:"ASK",response:"ANS",status:"STATUS",context:"CONTEXT",ledger:"LOG",trace:"TRACE",file:"FILE",diff:"DIFF",mermaid:"MERMAID",image:"IMG",html:"HTML",group:"GROUP"},Zr=new Set(["markdown","mcp-app","webpage","json-render","graph","context","ledger","file","diff","mermaid","image","html"]);function Xp(e){return e.type==="mcp-app"&&e.data.mode==="ext-app"&&e.data.serverName==="Excalidraw"&&e.data.toolName==="create_view"}var p_=700,f_=1600;function m_(e){return e.replace(/\r\n?/g,`
|
|
23
23
|
`).replace(/[ \t\f\v]+/g," ").replace(/\n\s+/g,`
|
|
24
24
|
`).replace(/\s+\n/g,`
|
|
25
25
|
`).replace(/\n{3,}/g,`
|
|
26
26
|
|
|
27
|
-
`).trim()}function
|
|
28
|
-
`),
|
|
29
|
-
|
|
30
|
-
${
|
|
31
|
-
`),
|
|
32
|
-
`),
|
|
33
|
-
`),
|
|
34
|
-
|
|
35
|
-
`:"",W=Math.max(0,v-K.length);return`${K}${D6(z,W)}`.trim()}default:return o2($.data,v)}}function KF($,U){let v=$.position.x+$.size.width/2,J=$.position.y+$.size.height/2,_=U.position.x+U.size.width/2,z=U.position.y+U.size.height/2;return Math.sqrt((v-_)**2+(J-z)**2)}function GF($,U){let v=$.position.x+$.size.width,J=$.position.y+$.size.height,_=U.position.x+U.size.width,z=U.position.y+U.size.height,K=Math.max(0,Math.max($.position.x,U.position.x)-Math.min(v,_)),W=Math.max(0,Math.max($.position.y,U.position.y)-Math.min(J,z));return Math.sqrt(K**2+W**2)}function WF($){let U=[...$],v=100;return U.sort((J,_)=>{let z=Math.floor(J.position.y/100),K=Math.floor(_.position.y/100);if(z!==K)return z-K;return J.position.x-_.position.x}),U}function OF($){let U=$.find((_)=>_.data.title&&typeof _.data.title==="string");if(U&&$.length<=3)return $.filter((z)=>z.data.title).map((z)=>z.data.title).slice(0,3).join(", ");let v={};for(let _ of $)v[_.type]=(v[_.type]??0)+1;let J=Object.entries(v).map(([_,z])=>z===1?_:`${z} ${_}`);if(U)return`${U.data.title} + ${J.join(", ")}`;return J.join(", ")}function YF($,U){return $.x<=U.x+U.width&&$.x+$.width>=U.x&&$.y<=U.y+U.height&&$.y+$.height>=U.y}function ZF($,U){let v=U.filter((_)=>YF($.bounds,{x:_.position.x,y:_.position.y,width:_.size.width,height:_.size.height})),J=v.map((_)=>typeof _.data.title==="string"&&_.data.title.length>0?_.data.title:_.id);return{id:$.id,label:$.label??$.text??null,bounds:$.bounds,targetNodeIds:v.map((_)=>_.id),targetNodeTitles:J,target:J.length>0?J.join(", "):"empty canvas region"}}function qF($,U=200){if($.length===0)return[];let v=new Map,J=(O)=>{while(v.get(O)!==O){let Y=v.get(O);v.set(O,v.get(Y)),O=Y}return O},_=(O,Y)=>{let Z=J(O),q=J(Y);if(Z!==q)v.set(Z,q)};for(let O of $)v.set(O.id,O.id);for(let O=0;O<$.length;O++)for(let Y=O+1;Y<$.length;Y++)if(GF($[O],$[Y])<=U)_($[O].id,$[Y].id);let z=new Map;for(let O of $){let Y=J(O.id);if(!z.has(Y))z.set(Y,[]);z.get(Y).push(O)}let K=[],W=0;for(let[,O]of z){if(O.length<2)continue;let Y=O.map((H)=>H.position.x),Z=O.map((H)=>H.position.y),q=O.map((H)=>H.position.x+H.size.width),X=O.map((H)=>H.position.y+H.size.height),B=Math.min(...Y),L=Math.min(...Z),F=Math.max(...q),k=Math.max(...X);K.push({id:`cluster-${W++}`,nodeIds:O.map((H)=>H.id),label:OF(O),centroid:{x:Math.round((B+F)/2),y:Math.round((L+k)/2)},bounds:{x:B,y:L,width:F-B,height:k-L}})}return K.sort((O,Y)=>{let Z=Math.floor(O.centroid.y/200),q=Math.floor(Y.centroid.y/200);if(Z!==q)return Z-q;return O.centroid.x-Y.centroid.x}),K}function BF($,U,v=5,J=600){let _=$.filter((K)=>U.has(K.id)),z=$.filter((K)=>!U.has(K.id));return _.map((K)=>{let W=z.map((O)=>({node:O,distance:KF(K,O)})).filter((O)=>O.distance<=J).sort((O,Y)=>O.distance-Y.distance).slice(0,v);return{pinnedNodeId:K.id,pinnedNodeTitle:K.data.title??null,neighbors:W.map((O)=>({id:O.node.id,type:O.node.type,title:O.node.data.title??null,distance:Math.round(O.distance)}))}})}function i0($,U,v,J=[]){let _=qF($),z=new Map;for(let Y of _)for(let Z of Y.nodeIds)z.set(Z,Y.id);let W=WF($).map((Y,Z)=>({id:Y.id,type:Y.type,title:Y.data.title??null,content:yY(Y,{defaultTextLength:320,webpageTextLength:640})||null,clusterId:z.get(Y.id)??null,readingOrder:Z})),O=BF($,v);return{totalNodes:$.length,clusters:_,nodesInReadingOrder:W,pinnedNeighborhoods:O,annotations:J.map((Y)=>ZF(Y,$))}}function QU($){if(!$)return null;let U=$.data.title;return typeof U==="string"&&U.trim().length>0?U.trim():null}function d2($,U){return{id:$?.id??U,title:QU($),nodeType:$?.type??"markdown"}}function CY($,U){return{id:$.id,edgeType:$.type,fromId:$.from,toId:$.to,fromTitle:QU(U.get($.from)),toTitle:QU(U.get($.to))}}function n2($){return new Map($.map((U)=>[U.id,U]))}function DY($){return new Map($.map((U)=>[U.id,U]))}function v4($){return Array.from($).sort((U,v)=>U.localeCompare(v))}function S8($,U){if($.length!==U.length)return!1;for(let v=0;v<$.length;v++)if($[v]!==U[v])return!1;return!0}function R8($){if(!$||$.type!=="group")return[];let U=$.data.children;if(!Array.isArray(U))return[];return U.filter((v)=>typeof v==="string").sort((v,J)=>v.localeCompare(J))}function jY($){let U=new Map;for(let v of $.clusters){let J=[...v.nodeIds].sort((_,z)=>_.localeCompare(z));for(let _ of J)U.set(_,J.filter((z)=>z!==_))}return U}function VY($){let U=new Map;for(let v of $.pinnedNeighborhoods)U.set(v.pinnedNodeId,v.neighbors.map((J)=>J.id).sort((J,_)=>J.localeCompare(_)));return U}function XF($,U){let v=v4(Array.from(U).filter((_)=>!$.has(_))),J=v4(Array.from($).filter((_)=>!U.has(_)));return{added:v,removed:J}}function fY($){let U=$&&typeof $==="object"?$:{};return{timestamp:typeof U.timestamp==="string"?U.timestamp:void 0,sessionId:typeof U.sessionId==="string"?U.sessionId:void 0}}function HF($,U,v){if(!$||!v)return{layout:$,pinnedNodeIds:[],primaryFocusNodeIds:[],secondaryFocusNodeIds:[],regions:[],spatial:v};let J=n2($.nodes),_=v4(U).filter((O)=>J.has(O)),z=new Set(_),K=new Set,W=[];for(let O of v.pinnedNeighborhoods){if(!z.has(O.pinnedNodeId))continue;let Y=v4([O.pinnedNodeId,...O.neighbors.map((Z)=>Z.id)]).filter((Z,q,X)=>X.indexOf(Z)===q&&J.has(Z));for(let Z of Y)if(!z.has(Z))K.add(Z);W.push({id:`region-${O.pinnedNodeId}`,primaryNodeId:O.pinnedNodeId,nodeIds:Y})}if(W.length===0&&_.length>0)for(let O of _)W.push({id:`region-${O}`,primaryNodeId:O,nodeIds:[O]});return{layout:$,pinnedNodeIds:_,primaryFocusNodeIds:_,secondaryFocusNodeIds:v4(K),regions:W,spatial:v}}class t2{currentLayout=null;currentPins=new Set;previousSpatial=null;setInitialPins($){this.currentPins=new Set($)}getAttentionSnapshot(){return HF(this.currentLayout,this.currentPins,this.previousSpatial)}handleMessage($){if($.event==="context-pins-changed")return this.handleContextPinsChanged($.data);if($.event==="canvas-layout-update")return this.handleLayoutUpdate($.data);return[]}handleContextPinsChanged($){let U=$&&typeof $==="object"?$:{},v=Array.isArray(U.nodeIds)?U.nodeIds.filter((Y)=>typeof Y==="string"):[],J=fY($),_=new Set(v),{added:z,removed:K}=XF(this.currentPins,_);if(this.currentPins=_,!this.currentLayout)return[];let W=n2(this.currentLayout.nodes),O={added:z.map((Y)=>d2(W.get(Y),Y)),removed:K.map((Y)=>d2(W.get(Y),Y))};if(this.previousSpatial=i0(this.currentLayout.nodes,this.currentLayout.edges,this.currentPins,this.currentLayout.annotations??[]),O.added.length===0&&O.removed.length===0)return[];return[{type:"context-pin",...J,...O}]}handleLayoutUpdate($){let U=$&&typeof $==="object"?$:{},v=U.layout&&typeof U.layout==="object"?U.layout:null;if(!v)return[];let J=fY($);if(!this.currentLayout)return this.currentLayout=v,this.previousSpatial=i0(v.nodes,v.edges,this.currentPins,v.annotations??[]),[];let _=this.currentLayout,z=this.previousSpatial??i0(_.nodes,_.edges,this.currentPins,_.annotations??[]),K=i0(v.nodes,v.edges,this.currentPins,v.annotations??[]),W=[],O=n2(_.nodes),Y=n2(v.nodes),Z=DY(_.edges),q=DY(v.edges),X=v4(Array.from(q.keys()).filter((H)=>!Z.has(H))).map((H)=>q.get(H)).filter((H)=>H!==void 0);if(X.length>0)W.push({type:"connect",...J,edges:X.map((H)=>CY(H,Y))});let B=v4(Array.from(O.keys()).filter((H)=>!Y.has(H))),L=v4(Array.from(Z.keys()).filter((H)=>!q.has(H)));if(B.length>0||L.length>0)W.push({type:"remove",...J,nodes:B.map((H)=>d2(O.get(H),H)),edges:L.map((H)=>Z.get(H)).filter((H)=>H!==void 0).map((H)=>CY(H,O))});let F=this.buildGroupEvent(O,Y,J);if(F)W.push(F);let k=this.buildMoveEndEvent(_,v,O,Y,z,K,J);if(k)W.push(k);return this.currentLayout=v,this.previousSpatial=K,W}buildGroupEvent($,U,v){let J=v4(Array.from($.values()).filter((W)=>W.type==="group").map((W)=>W.id)),_=v4(Array.from(U.values()).filter((W)=>W.type==="group").map((W)=>W.id)),z=_.filter((W)=>!J.includes(W)).map((W)=>{let O=U.get(W),Y=R8(O);return{id:W,title:QU(O),childCount:Y.length}}),K=[];for(let W of _.filter((O)=>J.includes(O))){let O=R8($.get(W)),Y=R8(U.get(W));if(S8(O,Y))continue;K.push({id:W,title:QU(U.get(W)),addedChildIds:Y.filter((Z)=>!O.includes(Z)),removedChildIds:O.filter((Z)=>!Y.includes(Z)),childCount:Y.length})}if(z.length===0&&K.length===0)return null;return{type:"group",...v,created:z,updated:K}}buildMoveEndEvent($,U,v,J,_,z,K){let W=v4(Array.from(J.keys()).filter((k)=>{let H=v.get(k),P=J.get(k);if(!H||!P)return!1;return H.position.x!==P.position.x||H.position.y!==P.position.y}));if(W.length===0)return null;let O=jY(_),Y=jY(z),Z=VY(_),q=VY(z),X=new Map,B=(k,H)=>{let P=X.get(k)??new Set;P.add(H),X.set(k,P)};for(let k of W){let H=O.get(k)??[],P=Y.get(k)??[];if(!S8(H,P))if(H.length===0&&P.length>0)B(k,"joined cluster");else if(H.length>0&&P.length===0)B(k,"left cluster");else B(k,"cluster changed")}let L=new Set([...Z.keys(),...q.keys()]);for(let k of L){let H=Z.get(k)??[],P=q.get(k)??[];if(S8(H,P))continue;let b=QU(J.get(k)??v.get(k))??k,V=P.filter((A)=>!H.includes(A)),E=H.filter((A)=>!P.includes(A));for(let A of V)if(W.includes(A))B(A,`entered pinned neighborhood of "${b}"`);for(let A of E)if(W.includes(A))B(A,`left pinned neighborhood of "${b}"`);if(W.includes(k))B(k,"pinned neighborhood changed")}let F=W.filter((k)=>(X.get(k)?.size??0)>0).map((k)=>{let H=J.get(k);return{...d2(H,k),reasons:Array.from(X.get(k)??[]).sort((P,b)=>P.localeCompare(b))}});if(F.length===0)return null;return{type:"move-end",...K,nodes:F}}}var D8=new t2,LU=[],p0=null,FU=null,T8="",y8=0;function uY($,U){return globalThis.setTimeout($,U)}function C8($){if($===null)return;globalThis.clearTimeout($)}function QF($){if(typeof globalThis.requestAnimationFrame==="function"){globalThis.requestAnimationFrame(()=>$());return}$()}function t4($,U){return $&&$.trim().length>0?$.trim():U}function T4($,U=3){if($.length===0)return"";if($.length<=U)return $.join(", ");return`${$.slice(0,U).join(", ")} +${$.length-U}`}function LF($){return Array.from(new Set(Array.from($).filter((U)=>U.length>0)))}function J4($,U,v,J,_=Date.now()){return{id:`${$}-${_}-${Math.random().toString(36).slice(2,8)}`,tone:$,title:U,detail:v,nodeIds:LF(J),createdAt:_}}function EY($){if($==="joined cluster")return"joined a nearby cluster";if($==="left cluster")return"moved away from its cluster";if($==="cluster changed")return"shifted into a different cluster";if($==="pinned neighborhood changed")return"changed the local focus field";let U=/^entered pinned neighborhood of "(.+)"$/.exec($);if(U)return`moved into focus around ${U[1]}`;let v=/^left pinned neighborhood of "(.+)"$/.exec($);if(v)return`moved out of focus around ${v[1]}`;return $}function FF($){let U=$.added.map((_)=>t4(_.title,_.id)),v=$.removed.map((_)=>t4(_.title,_.id));if(U.length===0&&v.length===0)return null;let J="";if(U.length>0&&v.length===0)J=`Now in focus: ${T4(U)}`;else if(v.length>0&&U.length===0)J=`Removed from focus: ${T4(v)}`;else{let _=[];if(U.length>0)_.push(`${T4(U)} added`);if(v.length>0)_.push(`${T4(v)} removed`);J=_.join(" · ")}return J4("context","Context updated",J,[...$.added.map((_)=>_.id),...$.removed.map((_)=>_.id)],$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}function PF($){if($.edges.length===0)return null;if($.edges.length===1){let U=$.edges[0];return J4("relationship","Relationship added",`${t4(U.fromTitle,U.fromId)} linked to ${t4(U.toTitle,U.toId)}`,[U.fromId,U.toId],$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}return J4("relationship","Relationships added",`${$.edges.length} connections changed the board structure`,$.edges.flatMap((U)=>[U.fromId,U.toId]),$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}function kF($){if($.nodes.length===0&&$.edges.length===0)return null;let U=$.nodes.map((J)=>t4(J.title,J.id)),v=[];if(U.length>0)v.push(T4(U));if($.edges.length>0)v.push(`${$.edges.length} relationship${$.edges.length===1?"":"s"}`);return J4("remove","Items removed",v.join(" · "),[...$.nodes.map((J)=>J.id),...$.edges.flatMap((J)=>[J.fromId,J.toId])],$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}function bF($){if($.created.length>0){let U=$.created.map((v)=>t4(v.title,v.id));return J4("group",$.created.length===1?"Group created":"Groups created",$.created.length===1?`${U[0]} now frames ${$.created[0].childCount} items`:T4(U),$.created.map((v)=>v.id),$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}if($.updated.length>0){let U=$.updated.map((v)=>t4(v.title,v.id));return J4("group",$.updated.length===1?"Group updated":"Groups updated",$.updated.length===1?`${U[0]} now holds ${$.updated[0].childCount} items`:T4(U),$.updated.map((v)=>v.id),$.timestamp?Date.parse($.timestamp)||Date.now():Date.now())}return null}function MF($){if($.nodes.length===0)return null;let U=$.nodes.flatMap((z)=>z.reasons),v=$.nodes.map((z)=>t4(z.title,z.id)),J=$.timestamp?Date.parse($.timestamp)||Date.now():Date.now();if(U.some((z)=>z.includes("pinned neighborhood"))){if($.nodes.length===1)return J4("neighborhood","Neighborhood changed",`${v[0]} ${EY($.nodes[0].reasons[0])}`,$.nodes.map((z)=>z.id),J);return J4("neighborhood","Neighborhood changed",T4(v),$.nodes.map((z)=>z.id),J)}let _=U.filter((z)=>z.includes("cluster"));if(_.length>0){let z=_.every((K)=>K==="joined cluster");if($.nodes.length===1)return J4("cluster",z?"Cluster formed":"Cluster changed",`${v[0]} ${EY($.nodes[0].reasons[0])}`,$.nodes.map((K)=>K.id),J);return J4("cluster",z?"Cluster formed":"Cluster changed",T4(v),$.nodes.map((K)=>K.id),J)}return null}function AF($){switch($.type){case"context-pin":return FF($);case"connect":return PF($);case"remove":return kF($);case"group":return bF($);case"move-end":return MF($)}}function IF(){let $=D8.getAttentionSnapshot();OY($.primaryFocusNodeIds,$.secondaryFocusNodeIds,$.regions)}function mY(){if(p0!==null)return;let $=LU.shift()??null;if(!$){E2(null);return}E2($);let U=Math.max(1800,Math.min(2800,1600+$.detail.length*18));p0=uY(()=>{p0=null,E2(null),mY()},U)}function xY($){if(LU.push($),LU.length>3)LU.splice(0,LU.length-3);mY()}function PU($,U,v="",J=[]){xY(J4($,U,v,J))}function wF($){if(C8(FU),FU=null,u2([]),$.length===0)return;QF(()=>{u2($),FU=uY(()=>{FU=null,u2([])},900)})}function gF($){let U=`${$.tone}:${$.title}:${$.detail}`,v=$.createdAt;if(U===T8&&v-y8<1200)return!0;return T8=U,y8=v,!1}function j8(){C8(p0),C8(FU),p0=null,FU=null,LU=[],T8="",y8=0,D8=new t2,GY()}function V8($){let U=D8.handleMessage($).map((v)=>AF(v)).filter((v)=>v!==null);IF();for(let v of U){if(gF(v))continue;YY(v),xY(v),wF(v.nodeIds)}}async function a4($,U,v,J){let _=await l2({type:U,sourceNodeId:$.id,sourceSurface:"native-node",...v?{payload:v}:{}});if(_.ok)PU("context",J,"",[$.id]);else PU("remove","AX action failed",_.error??_.code??"Unknown error",[$.id])}var V1={padding:"3px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer",flexShrink:0};function NF($){let U=$.title||$.label||$.key||"Context",v=$.summary?.trim()||"Available in startup context.",J=$.pathDisplay||$.path||"",_=$.category==="profile"?"Operator":$.category==="planning"||$.category==="memory"?"Product":$.category?$.category.charAt(0).toUpperCase()+$.category.slice(1):void 0,z=$.sourceKind==="global"?"Global":"Workspace",K=$.state==="missing"?"Missing":$.state==="stale"?"Stale":$.state==="invalid"?"Invalid":"Loaded";return{title:U,summary:v,pathDisplay:J,category:_,sourceKind:z,status:K,required:$.required===!0}}function z4($){return typeof $==="string"?$.trim():""}function SF($){return $.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}function RF($){let U=z4($.title),v=z4($.content),J=SF(z4($.rendered)),_=v||J,z=z4($.path);if(!U&&!_&&!z)return null;return{title:U||"Context",summary:_,path:z}}function TF($){let U=z4($.data.title)||$.id,v=z4($.data.content)||z4($.data.excerpt)||z4($.data.description)||z4($.data.pageTitle)||"",J=z4($.data.path)||z4($.data.url);return{id:$.id,title:U,summary:v,kind:Z6[$.type]??$.type,path:J}}function hY($){if($===null||!Number.isFinite($)||$<0)return"0";if($>=1e6)return`${($/1e6).toFixed(1)}m`;if($>=1000)return`${($/1000).toFixed(1)}k`;return`${Math.round($)}`}function yF($){if($>=0.95)return"var(--c-danger)";if($>=0.85)return"var(--c-warn)";if($>=0.7)return"var(--c-warn)";return"var(--c-accent)"}function a2({node:$,expanded:U=!1,pinnedNodes:v=[]}){let J=$.data.cards??[],_=$.data.auxTabs??[],z=v.map(TF),K=z.length>0,W=typeof $.data.currentTokens==="number"?$.data.currentTokens:null,O=typeof $.data.tokenLimit==="number"?$.data.tokenLimit:null,Y=typeof $.data.utilization==="number"?$.data.utilization:null,Z=typeof $.data.messagesLength==="number"?$.data.messagesLength:null,q=Y!==null?Math.max(0,Math.min(100,Math.round(Y*100))):null,X=yF(Y??0),B=!K&&J.length===0&&_.length===0?RF($.data):null,L=async(F)=>{let k=typeof F.path==="string"?F.path.trim():"";if(!k)return;await x2(k)};return G("div",{style:{display:"flex",flexDirection:"column",gap:U?"10px":"6px",fontSize:U?"14px":"12px",maxWidth:U?"760px":void 0,margin:U?"0 auto":void 0,width:U?"100%":void 0,padding:U?"8px 0":void 0},children:[G("div",{style:{display:"flex",justifyContent:"flex-end"},children:G("button",{type:"button",class:"ax-node-action",title:"Point the agent at this node — sets it as the agent's current AX focus so the agent pulls it into context to work on next (a one-click alternative to manually pinning).",style:V1,onClick:(F)=>{F.stopPropagation(),a4($,"ax.focus.set",void 0,"Focus set")},children:"Set focus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),O!==null&&O>0&&G("div",{style:{marginBottom:"8px"},children:[G("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:"Token Usage"},void 0,!1,void 0,this),G("div",{style:{height:"6px",background:"var(--c-surface-hover)",borderRadius:"3px",overflow:"hidden",marginBottom:"4px"},children:G("div",{style:{height:"100%",width:`${Math.min(100,(Y??0)*100)}%`,background:X,borderRadius:"3px",transition:"width 0.3s ease"}},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("div",{style:{fontSize:"11px",color:"var(--c-muted)"},children:[q,"% — ",hY(W)," / ",hY(O)," tokens",Z!==null&&G(A$,{children:[" · ",Z," messages"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K&&G("div",{children:[G("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:["Pinned Context (",z.length,")"]},void 0,!0,void 0,this),z.map((F)=>G("div",{style:{padding:"6px 8px",background:"var(--c-surface-subtle)",borderRadius:"6px",marginBottom:"4px",borderLeft:"2px solid var(--c-accent)"},children:[G("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"2px"},children:F.title},void 0,!1,void 0,this),F.summary&&G("div",{style:{color:"var(--c-muted)",fontSize:"10px",lineHeight:1.45,marginBottom:"4px",whiteSpace:"pre-wrap"},children:F.summary},void 0,!1,void 0,this),G("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginTop:"4px"},children:G("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:F.kind},void 0,!1,void 0,this)},void 0,!1,void 0,this),F.path&&G("div",{style:{marginTop:"6px"},children:[G("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all",marginBottom:"6px"},children:F.path},void 0,!1,void 0,this),F.path.startsWith("/")&&G("button",{type:"button",onClick:()=>void x2(F.path),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},F.id,!0,void 0,this))]},void 0,!0,void 0,this),!K&&J.length>0&&G("div",{children:[G("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:["Context (",J.length,")"]},void 0,!0,void 0,this),J.map((F)=>{let k=NF(F);return G("div",{style:{padding:"6px 8px",background:"var(--c-surface-subtle)",borderRadius:"6px",marginBottom:"4px",borderLeft:"2px solid var(--c-accent)"},children:[G("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"2px"},children:k.title},void 0,!1,void 0,this),G("div",{style:{color:"var(--c-muted)",fontSize:"10px",lineHeight:1.45,marginBottom:"4px"},children:k.summary},void 0,!1,void 0,this),k.pathDisplay&&G("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all"},children:k.pathDisplay},void 0,!1,void 0,this),G("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginTop:"4px"},children:[G("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-accent-10)",color:"var(--c-accent)",borderRadius:"3px",display:"inline-block"},children:k.status},void 0,!1,void 0,this),k.category&&G("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:k.category},void 0,!1,void 0,this),G("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:k.sourceKind},void 0,!1,void 0,this),k.required&&G("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-warn-12)",color:"var(--c-warn-alt)",borderRadius:"3px",display:"inline-block"},children:"Required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.path&&G("div",{style:{marginTop:"6px"},children:G("button",{type:"button",onClick:()=>void L(F),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},F.key??k.pathDisplay??k.title,!0,void 0,this)})]},void 0,!0,void 0,this),!K&&_.length>0&&G("div",{children:[G("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px",marginTop:J.length>0?"8px":0},children:["References (",_.length,")"]},void 0,!0,void 0,this),_.map((F)=>G("a",{href:F.url,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"4px 8px",color:"var(--c-accent)",fontSize:"11px",textDecoration:"none",borderRadius:"4px",marginBottom:"2px",wordBreak:"break-all"},children:[F.url,F.reason&&G("span",{style:{color:"var(--c-dim)",fontSize:"10px",marginLeft:"6px"},children:["(",F.reason,")"]},void 0,!0,void 0,this)]},F.id,!0,void 0,this))]},void 0,!0,void 0,this),B&&G("div",{style:{padding:"8px 10px",background:"var(--c-surface-subtle)",borderRadius:"6px",borderLeft:"2px solid var(--c-accent)"},children:[G("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"4px"},children:B.title},void 0,!1,void 0,this),B.summary&&G("div",{style:{color:"var(--c-text-soft)",fontSize:"11px",lineHeight:1.5,whiteSpace:"pre-wrap"},children:B.summary},void 0,!1,void 0,this),B.path&&G("div",{style:{marginTop:"6px"},children:[G("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all",marginBottom:"6px"},children:B.path},void 0,!1,void 0,this),G("button",{type:"button",onClick:()=>void x2(B.path),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!K&&!B&&J.length===0&&_.length===0&&G("div",{style:{color:"var(--c-dim)",fontStyle:"italic"},children:"No context loaded"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function cY($){return $.replace(/^[ab]\//,"")}function CF($,U){if(U&&U!=="/dev/null")return cY(U);if($&&$!=="/dev/null")return cY($);return null}function DF($){if(!$.trim())return[];let U=$.split(`
|
|
36
|
-
`);if(U.length>0&&U[U.length-1]==="")U.pop();let v=[],J=null,_=!1,z=(K)=>{let W={path:K,lines:[]};return _=!1,v.push(W),W};for(let K=0;K<U.length;K++){let W=U[K]??"",O=W.match(/^diff --git a\/(.+?) b\/(.+)$/);if(O){J=z(O[2]??null);continue}let Y=U[K+1]??"";if(W.startsWith("--- ")&&Y.startsWith("+++ ")){let q=CF(W.slice(4).trim(),Y.slice(4).trim());if(J&&!_){if(!J.path)J.path=q}else J=z(q);K++;continue}if(!J)J=z(null);let Z=J;if(W.startsWith("@@"))_=!0,Z.lines.push({kind:"hunk",text:W});else if(W.startsWith("+"))Z.lines.push({kind:"add",text:W});else if(W.startsWith("-"))Z.lines.push({kind:"remove",text:W});else Z.lines.push({kind:"context",text:W})}return v}function s2({node:$}){let U=typeof $.data.content==="string"?$.data.content:"",v=u$(()=>DF(U),[U]);if(v.length===0)return G("div",{class:"diff-node diff-node-empty",children:"Empty diff"},void 0,!1,void 0,this);return G("div",{class:"diff-node",children:v.map((J,_)=>G("div",{class:"diff-file",children:[J.path&&G("div",{class:"diff-file-header",children:J.path},void 0,!1,void 0,this),G("pre",{class:"diff-lines",children:J.lines.map((z,K)=>G("div",{class:z.kind==="hunk"?"diff-hunk":`diff-line-${z.kind}`,children:z.text||" "},K,!1,void 0,this))},void 0,!1,void 0,this)]},`${J.path??"anonymous"}-${_}`,!0,void 0,this))},void 0,!1,void 0,this)}function lY($){if($.length===0)return null;let{POSITIVE_INFINITY:U,POSITIVE_INFINITY:v,NEGATIVE_INFINITY:J,NEGATIVE_INFINITY:_}=Number;for(let z of $)U=Math.min(U,z.position.x),v=Math.min(v,z.position.y),J=Math.max(J,z.position.x+z.size.width),_=Math.max(_,z.position.y+z.size.height);if(!Number.isFinite(U)||!Number.isFinite(v))return null;return{x:U-40,y:v-40-32,width:J-U+80,height:_-v+80+32}}function jF($){let U=$.filter((O)=>!O.pinned),v=new Map(U.map((O)=>[O.id,O])),J=new Map,_=[],z=new Map;for(let O of U){if(O.type==="group")continue;let Y=typeof O.data.parentGroup==="string"?O.data.parentGroup:"",Z=Y?v.get(Y):void 0;if(!Z||Z.type!=="group")continue;if(!z.has(Y))z.set(Y,[]);z.get(Y).push(O)}let K=U.filter((O)=>O.type==="group").sort((O,Y)=>O.position.y-Y.position.y||O.position.x-Y.position.x);for(let O of K){let Y=z.get(O.id)??[];if(Y.length===0){let B=`unit:${O.id}`;_.push({id:B,memberIds:[O.id],origin:{...O.position},size:{...O.size},sortKey:{x:O.position.x,y:O.position.y}}),J.set(O.id,B);continue}let Z=Y.map((B)=>({position:B.position,size:B.size})),q=lY(Z);if(!q)continue;let X=`group:${O.id}`;_.push({id:X,memberIds:Y.map((B)=>B.id),origin:{x:q.x,y:q.y},size:{width:q.width,height:q.height},sortKey:{x:q.x,y:q.y},groupId:O.id}),J.set(O.id,X);for(let B of Y)J.set(B.id,X)}let W=U.filter((O)=>!J.has(O.id)).sort((O,Y)=>O.position.y-Y.position.y||O.position.x-Y.position.x);for(let O of W){let Y=`unit:${O.id}`;_.push({id:Y,memberIds:[O.id],origin:{...O.position},size:{...O.size},sortKey:{x:O.position.x,y:O.position.y}}),J.set(O.id,Y)}return{units:_,nodesById:v,nodeToUnit:J}}function VF($,U,v){let J=new Map,_=new Map,z=new Map,K=new Map;for(let W of $)J.set(W.id,new Set),_.set(W.id,new Set),z.set(W.id,0),K.set(W.id,0);for(let W of v){let O=U.get(W.from),Y=U.get(W.to);if(!O||!Y||O===Y)continue;if(!J.get(O).has(Y))J.get(O).add(Y),K.set(O,(K.get(O)??0)+1),z.set(Y,(z.get(Y)??0)+1);_.get(O).add(Y),_.get(Y).add(O)}return{outgoing:J,undirected:_,indegree:z,outdegree:K}}function fF($,U){let v=new Map($.map((z)=>[z.id,z])),J=new Set,_=[];for(let z of $){if(J.has(z.id))continue;let K=[z.id],W=[];J.add(z.id);while(K.length>0){let Y=K.pop();W.push(Y);for(let Z of U.get(Y)??[]){if(J.has(Z))continue;J.add(Z),K.push(Z)}}let O=W.map((Y)=>v.get(Y)).filter((Y)=>Y!==void 0).sort((Y,Z)=>Y.sortKey.y-Z.sortKey.y||Y.sortKey.x-Z.sortKey.x);_.push(O)}return _.sort((z,K)=>z[0].sortKey.y-K[0].sortKey.y||z[0].sortKey.x-K[0].sortKey.x)}function EF($){let U=new Map,v=0,J=0,_=0,z=0,K=Math.max(900,Math.ceil(Math.sqrt($.reduce((W,O)=>W+O.size.width*O.size.height,0))));for(let W of $){if(v>0&&v+W.size.width>K)v=0,J+=_+72,_=0;U.set(W.id,{x:v,y:J}),v+=W.size.width+96,_=Math.max(_,W.size.height),z=Math.max(z,v-96)}return{positions:U,size:{width:Math.max(0,z),height:J+_},sortKey:$[0].sortKey}}function uF($,U,v,J,_){if($.length===1)return{positions:new Map([[$[0].id,{x:0,y:0}]]),size:{...$[0].size},sortKey:$[0].sortKey};let z=new Set($.map((P)=>P.id)),K=$.filter((P)=>(J.get(P.id)??0)===0&&(_.get(P.id)??0)>0).sort((P,b)=>P.sortKey.x-b.sortKey.x||P.sortKey.y-b.sortKey.y),W=K.length>0?K:[$.slice().sort((P,b)=>P.sortKey.x-b.sortKey.x||P.sortKey.y-b.sortKey.y)[0]],O=new Map,Y=W.map((P)=>P.id);for(let P of W)O.set(P.id,0);while(Y.length>0){let P=Y.shift(),b=O.get(P)??0;for(let V of v.get(P)??[]){if(!z.has(V)||O.has(V))continue;O.set(V,b+1),Y.push(V)}}let Z=0;for(let P of $){if(O.has(P.id))continue;O.set(P.id,Z),Z+=1}let q=new Map;for(let P of $){let b=O.get(P.id)??0;if(!q.has(b))q.set(b,[]);q.get(b).push(P)}let X=Array.from(q.keys()).sort((P,b)=>P-b);for(let P of X)q.get(P).sort((b,V)=>b.sortKey.y-V.sortKey.y||b.sortKey.x-V.sortKey.x);let B=new Map,L=new Map,F=0;for(let P of X){let b=q.get(P),V=b.reduce((A,I,N)=>A+I.size.height+(N>0?72:0),0),E=Math.max(...b.map((A)=>A.size.width));B.set(P,V),L.set(P,E),F=Math.max(F,V)}let k=new Map,H=0;for(let P of X){let b=q.get(P),V=B.get(P)??0,E=L.get(P)??0,A=Math.max(0,(F-V)/2);for(let I of b)k.set(I.id,{x:H,y:A}),A+=I.size.height+72;H+=E+96}return{positions:k,size:{width:Math.max(0,H-96),height:F},sortKey:$[0].sortKey}}function mF($,U){let v=new Map($.map((O)=>[O.id,O.id])),J=(O)=>{let Y=O;while(v.get(Y)!==Y)Y=v.get(Y);let Z=O;while(v.get(Z)!==Z){let q=v.get(Z);v.set(Z,Y),Z=q}return Y},_=(O,Y)=>{let Z=J(O),q=J(Y);if(Z!==q)v.set(Z,q)},z=160;for(let O=0;O<$.length;O++)for(let Y=O+1;Y<$.length;Y++){let Z=$[O],q=$[Y];if(Z.origin.x-160<q.origin.x+q.size.width+160&&Z.origin.x+Z.size.width+160>q.origin.x-160&&Z.origin.y-160<q.origin.y+q.size.height+160&&Z.origin.y+Z.size.height+160>q.origin.y-160)_(Z.id,q.id)}for(let[O,Y]of U)for(let Z of Y)if(v.has(O)&&v.has(Z))_(O,Z);let K=new Map;for(let O of $){let Y=J(O.id);if(!K.has(Y))K.set(Y,[]);K.get(Y).push(O)}let W=Array.from(K.values());for(let O of W)O.sort((Y,Z)=>Y.sortKey.y-Z.sortKey.y||Y.sortKey.x-Z.sortKey.x);return W.sort((O,Y)=>O[0].sortKey.y-Y[0].sortKey.y||O[0].sortKey.x-Y[0].sortKey.x)}function xF($,U){let v=new Map,J=U.x,_=U.y,z=0;for(let K of $){if(J>U.x&&J-U.x+K.size.width>3200)J=U.x,_+=z+180,z=0;for(let[W,O]of K.positions.entries())v.set(W,{x:J+O.x,y:_+O.y});J+=K.size.width+220,z=Math.max(z,K.size.height)}return v}function f8($,U,v){let{units:J,nodesById:_,nodeToUnit:z}=jF($),K=new Map,W=new Map;if(J.length===0)return{nodePositions:K,groupBounds:W};let{outgoing:O,undirected:Y,indegree:Z,outdegree:q}=VF(J,z,U),X=mF(J,Y),B=new Map,L=[];for(let F of X){let k=fF(F,Y).map((A)=>v==="graph"?uF(A,O,Y,Z,q):EF(A)),H={x:Math.min(...F.map((A)=>A.origin.x)),y:Math.min(...F.map((A)=>A.origin.y))},P=xF(k,H),b=new Map(F.map((A)=>[A.id,A.size])),V=(A)=>{let{POSITIVE_INFINITY:I,POSITIVE_INFINITY:N,NEGATIVE_INFINITY:R,NEGATIVE_INFINITY:p}=Number;for(let[l,T]of A){let r=b.get(l);if(!r)continue;I=Math.min(I,T.x),N=Math.min(N,T.y),R=Math.max(R,T.x+r.width),p=Math.max(p,T.y+r.height)}return{x:I,y:N,width:R-I,height:p-N}},E=P;for(let A=0;A<=L.length;A++){let I=V(E),N=L.filter((l)=>I.x<l.x+l.width+220&&I.x+I.width+220>l.x&&I.y<l.y+l.height+180&&I.y+I.height+180>l.y);if(N.length===0)break;let R=Math.max(...N.map((l)=>l.y+l.height))+180-I.y;if(R<=0)break;let p=new Map;for(let[l,T]of E)p.set(l,{x:T.x,y:T.y+R});E=p}for(let[A,I]of E)B.set(A,I);L.push(V(E))}for(let F of J){let k=B.get(F.id);if(!k)continue;let H=k.x-F.origin.x,P=k.y-F.origin.y;if(F.groupId){let E=[];for(let I of F.memberIds){let N=_.get(I);if(!N)continue;let R={x:N.position.x+H,y:N.position.y+P};K.set(I,R),E.push({position:R,size:N.size})}let A=lY(E);if(A)W.set(F.groupId,A);continue}let b=F.memberIds[0],V=_.get(b);if(!V)continue;K.set(b,{x:V.position.x+H,y:V.position.y+P})}return{nodePositions:K,groupBounds:W}}function dY($,U){console.error(`[canvas-store] ${$} failed`,U)}var G$=s({x:0,y:0,scale:1}),D=s(new Map),c$=s(new Map),bU=s(new Map),C$=s(null),C4=s(null),x6=s("connecting"),f1=s(0),E1=s(0),u1=s(0),D4=s(""),MU=s(!1),$6=s("dark"),K4=s(!1),G4=s(null),n$=s(null),H4=s(null),m6=null,kU,rY=100,hF=2500,e2=s(null),o$=s(null),e4=s(null),I$=s(new Set),j$=s(new Set),R6=s("select"),d0=s(!1);function AU(){return R6.value==="pan"||d0.value}function nY($,U){if(!$)return new Set;let v=new Set;for(let J of U.values()){if(J.from===$)v.add(J.to);if(J.to===$)v.add(J.from)}return v}var tY=r$(()=>nY(C$.value,c$.value));function iY($,U){let v=new Set;for(let J of $)if(U.has(J))v.add(J);return v}function pY($,U){if($.size!==U.size)return!1;for(let v of $)if(!U.has(v))return!1;return!0}function m8($){let U=new Set(I$.value);if(U.has($))U.delete($);else U.add($);I$.value=U}function aY($){I$.value=new Set($)}function I6(){if(C4.value=null,I$.value.size===0)return;I$.value=new Set}var y4=s(null),x8=!1;function sY(){x8=!0,y4.value=null}function eY(){x8=!1,y4.value=null}function E8($){return{x:$.position.x,y:$.position.y,w:$.size.width,h:$.size.height}}function cF($,U,v){let J=E8($);return U>=J.x&&U<=J.x+J.w&&v>=J.y&&v<=J.y+J.h}function oY($,U){let v=E8($),J=E8(U);return v.x+v.w<J.x||v.x>J.x+J.w||v.y+v.h<J.y||v.y>J.y+J.h}function $Z($){let U=D.value.get($);if(!U||U.type==="group")return;let v=typeof U.data.parentGroup==="string"?U.data.parentGroup:null,J=v?D.value.get(v):void 0,_=U.position.x+U.size.width/2,z=U.position.y+U.size.height/2,K=null;for(let W of D.value.values()){if(W.type!=="group"||W.id===v||W.collapsed)continue;if(cF(W,_,z))K=W}if(!x8){let W=K?{nodeId:$,groupId:K.id,mode:"add"}:J&&oY(U,J)?{nodeId:$,groupId:J.id,mode:"remove"}:null,O=y4.value;if((O?.groupId??null)!==(W?.groupId??null)||O?.mode!==W?.mode)y4.value=W}if(J&&J.data.frameMode!=="manual"&&!oY(U,J)){let O=Math.min(J.position.x,U.position.x-22),Y=Math.min(J.position.y,U.position.y-22-32),Z=Math.max(J.position.x+J.size.width,U.position.x+U.size.width+22),q=Math.max(J.position.y+J.size.height,U.position.y+U.size.height+22);if(O!==J.position.x||Y!==J.position.y||Z!==J.position.x+J.size.width||q!==J.position.y+J.size.height)vv(J.id,{position:{x:O,y:Y},size:{width:Z-O,height:q-Y}},{skipGroupChildTranslation:!0})}}var h8=r$(()=>{let $=new Map;for(let U of D.value.values()){if(U.type!=="group"||!U.collapsed)continue;let v=Array.isArray(U.data.children)?U.data.children:[];for(let J of v)if(typeof J==="string")$.set(J,U.id)}return $});function $v($){let U=h8.value.get($);return D.value.get(U??$)}function UZ(){let $=new Set;for(let U of I$.value){let v=D.value.get(U);if(!v)continue;if(v.type==="group")$.add(v.id);else if(typeof v.data.parentGroup==="string")$.add(v.data.parentGroup)}return[...$]}function c8($){let U=l8();if(U.length<2)return;let v=Math.min(...U.map((O)=>$==="left"?O.position.x:O.position.y)),J=24,_=new Map;for(let O of U)_.set(O.id,$==="left"?{x:v,y:O.position.y}:{x:O.position.x,y:v});let z=(O,Y)=>O.x<Y.x+Y.w&&Y.x<O.x+O.w&&O.y<Y.y+Y.h&&Y.y<O.y+O.h,K=U.map((O)=>{let Y=_.get(O.id);return{node:O,x:Y.x,y:Y.y,w:O.size.width,h:O.size.height}});if(K.some((O,Y)=>K.some((Z,q)=>q>Y&&z(O,Z)))){let O=[...U].sort((Z,q)=>$==="left"?Z.position.y-q.position.y:Z.position.x-q.position.x),Y=$==="left"?Math.min(...U.map((Z)=>Z.position.y)):Math.min(...U.map((Z)=>Z.position.x));for(let Z of O)_.set(Z.id,$==="left"?{x:v,y:Y}:{x:Y,y:v}),Y+=($==="left"?Z.size.height:Z.size.width)+J}o6(()=>{for(let O of U)q6(O.id,{position:_.get(O.id)})}),v6()}function _Z(){let $=l8().sort((W,O)=>W.position.x-O.position.x);if($.length<3)return;let U=$[0],J=$[$.length-1].position.x-(U.position.x+U.size.width),_=$.slice(1,-1),z=_.reduce((W,O)=>W+O.size.width,0),K=(J-z)/(_.length+1);o6(()=>{if(K<8){let O=U.position.x+U.size.width+24;for(let Y of $.slice(1))q6(Y.id,{position:{x:O,y:Y.position.y}}),O+=Y.size.width+24;return}let W=U.position.x+U.size.width+K;for(let O of _)q6(O.id,{position:{x:W,y:O.position.y}}),W+=O.size.width+K}),v6()}function vZ($=24){let U=l8().sort((W,O)=>W.position.y-O.position.y||W.position.x-O.position.x);if(U.length<2)return;let v=Math.min(...U.map((W)=>W.position.x)),J=Math.min(...U.map((W)=>W.position.y)),_=Math.ceil(Math.sqrt(U.length)),z=Math.max(...U.map((W)=>W.size.width)),K=Math.max(...U.map((W)=>W.size.height));o6(()=>{U.forEach((W,O)=>{q6(W.id,{position:{x:v+O%_*(z+$),y:J+Math.floor(O/_)*(K+$)}})})}),v6()}function l8(){let $=I$.value;if($.size===0)return[];return Array.from($).map((U)=>D.value.get(U)).filter((U)=>U!==void 0)}function $1($){let U=new Set(j$.value);if(U.has($))U.delete($);else U.add($);j$.value=U,v6(),_v(U)}function Uv($){let U=new Set(j$.value);for(let v of $)U.add(v);j$.value=U,v6(),_v(U)}function JZ(){if(j$.value.size===0)return;j$.value=new Set,v6(),_v(new Set)}function zZ($){j$.value=new Set($)}function _v($){_4("syncContextPinsToServer","/api/canvas/context-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nodeIds:Array.from($)})})}var o0=1;function j4($){o6(()=>{let U=new Map(D.value);if($.zIndex>=o0)o0=$.zIndex+1;U.set($.id,$),D.value=U,C$.value=$.id})}function q6($,U){vv($,U)}function vv($,U,v={}){let J=D.value.get($);if(!J)return;let _=new Map(D.value);if(J.type==="group"&&U.position&&v.skipGroupChildTranslation!==!0){let K=U.position.x-J.position.x,W=U.position.y-J.position.y;if(K!==0||W!==0){let O=Array.isArray(J.data.children)?J.data.children.filter((Y)=>typeof Y==="string"):[];for(let Y of O){let Z=_.get(Y);if(!Z||Z.type==="group")continue;_.set(Y,{...Z,position:{x:Z.position.x+K,y:Z.position.y+W}})}}}_.set($,{...J,...U}),D.value=_;let z=_.get($)?.data.appCheckpoint?.updatedAt;if(H4.value===$&&z!==void 0&&z!==kU)u8($)}function W$($,U){let v=D.value.get($);if(!v)return;q6($,{data:{...v.data,...U}})}function h6($){lF($);let U=new Map(D.value);if(U.delete($),D.value=U,C$.value===$)C$.value=null;if(n$.value===$)n$.value=null;if(I$.value.has($)){let v=new Set(I$.value);v.delete($),I$.value=v}if(j$.value.has($)){let v=new Set(j$.value);v.delete($),j$.value=v,_v(v)}}function Jv($){let U=new Map(c$.value);U.set($.id,$),c$.value=U}function KZ($){let U=new Map(c$.value);U.delete($),c$.value=U}function lF($){let U=!1,v=new Map(c$.value);for(let[J,_]of v)if(_.from===$||_.to===$)v.delete(J),U=!0;if(U)c$.value=v}function rF($){let U=new Map(bU.value);if(!U.delete($))return;bU.value=U}async function r8($){return u6("createAnnotationFromClient","/api/canvas/annotation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)})}async function GZ($){let U=await u6("removeAnnotationFromClient",`/api/canvas/annotation/${encodeURIComponent($)}`,{method:"DELETE"});if(U.ok)rF($);return U}function IU($,U){if(!D.value.get($))return;q6($,{size:U})}function V4($){let U=D.value.get($);if(!U)return;o6(()=>{if(q6($,{zIndex:o0++}),U.type==="group"&&Array.isArray(U.data.children)){for(let v of U.data.children)if(typeof v==="string"&&D.value.has(v))q6(v,{zIndex:o0++})}}),C$.value=$}function wU($){let U=D.value.get($);if(!U)return;q6($,{collapsed:!U.collapsed}),v6()}function WZ($){G$.value={...G$.value,...$}}function OZ($){G$.value=$}function YZ($){ZZ($)}function ZZ($,U={}){G$.value=$,v6(U),IY($,U)}function qZ($,U={}){let v=new Map,J=1;for(let q of $.nodes)if(v.set(q.id,q),q.zIndex>=J)J=q.zIndex+1;let _=$.edges.filter((q)=>v.has(q.from)&&v.has(q.to)),z=new Map;for(let q of _)z.set(q.id,q);let K=new Map;for(let q of $.annotations??[])K.set(q.id,q);let W=C$.value!==null&&v.has(C$.value)?C$.value:null,O=n$.value!==null&&v.has(n$.value)?n$.value:null,Y=iY(I$.value,v),Z=iY(j$.value,v);o6(()=>{if(U.applyViewport===!0&&$.viewport)G$.value=$.viewport;if(o0=J,D.value=v,c$.value=z,bU.value=K,C$.value=W,n$.value=O,!pY(I$.value,Y))I$.value=Y;if(!pY(j$.value,Z))j$.value=Z})}var s4=null;function iF($){return 1-(1-$)**3}function gU($,U=150){let v=G$.value,J=Math.min(4,Math.max(0.1,v.scale*$));if(J===v.scale)return;let _=J/v.scale,{x:z,y:K}=C1();U1({x:z-_*(z-v.x),y:K-_*(K-v.y),scale:J},U)}function U1($,U=300,v={}){if(s4!==null)cancelAnimationFrame(s4);let J={...G$.value},_=performance.now();function z(K){let W=K-_,O=Math.min(1,W/U),Y=iF(O);if(G$.value={x:J.x+($.x-J.x)*Y,y:J.y+($.y-J.y)*Y,scale:J.scale+($.scale-J.scale)*Y},O<1)s4=requestAnimationFrame(z);else s4=null,ZZ($,v)}s4=requestAnimationFrame(z)}function NU(){if(s4!==null)cancelAnimationFrame(s4),s4=null}var BZ="pmx-canvas-layout";function v6($={}){try{let U=Array.from(D.value.values()),v=U.map((_)=>({id:_.id,position:_.position,size:_.size,collapsed:_.collapsed})),J={viewport:G$.value,nodes:U.map((_)=>({id:_.id,type:_.type,position:_.position,size:_.size,collapsed:_.collapsed,pinned:_.pinned})),edges:Array.from(c$.value.values()).map((_)=>({id:_.id,from:_.from,to:_.to,type:_.type,label:_.label,style:_.style,animated:_.animated})),contextPinnedNodeIds:Array.from(j$.value)};localStorage.setItem(BZ,JSON.stringify(J)),bY(v,$)}catch(U){dY("persistLayout",U)}}function i8(){try{let $=localStorage.getItem(BZ);if(!$)return null;let U=JSON.parse($),v=Array.isArray(U.nodes)?U.nodes:[];if(v.length===0)return null;let J=new Map;for(let _ of v){if(typeof _.id!=="string"||_.id.length===0)continue;J.set(_.id,{..._.position?{position:_.position}:{},..._.size?{size:_.size}:{},..._.collapsed!==void 0?{collapsed:_.collapsed}:{},..._.pinned!==void 0?{pinned:_.pinned}:{}})}return J.size>0?J:null}catch($){return dY("restoreLayout",$),null}}function SU($,U){let v=Array.from(D.value.values());if(v.length===0)return;let{POSITIVE_INFINITY:J,POSITIVE_INFINITY:_,NEGATIVE_INFINITY:z,NEGATIVE_INFINITY:K}=Number;for(let F of v)J=Math.min(J,F.position.x),_=Math.min(_,F.position.y),z=Math.max(z,F.position.x+F.size.width),K=Math.max(K,F.position.y+F.size.height);let W=XY(),O=Math.max(80,$-W.left-W.right),Y=Math.max(80,U-W.top-W.bottom),Z=Math.max(1,z-J),q=Math.max(1,K-_),X=Math.min(1,Math.min(O/Z,Y/q)),B=(J+z)/2,L=(_+K)/2;U1({x:W.left+O/2-B*X,y:W.top+Y/2-L*X,scale:X})}function G6($,U={}){let v=D.value.get($);if(!v)return;let J=G$.value,_=v.position.x+v.size.width/2,z=v.position.y+v.size.height/2,K=C1();U1({x:K.x-_*J.scale,y:K.y-z*J.scale,scale:J.scale},300,U),V4($)}function XZ($=1){let U=Array.from(D.value.keys());if(U.length===0)return;let J=((C$.value?U.indexOf(C$.value):-1)+$+U.length)%U.length,_=U[J];V4(_),G6(_)}function HZ($){let U=C$.value;if(!U)return;let v=D.value.get(U);if(!v)return;let J=nY(U,c$.value);if(J.size===0)return;let _=v.position.x+v.size.width/2,z=v.position.y+v.size.height/2,K=null,W=-1/0;for(let O of J){let Y=D.value.get(O);if(!Y)continue;let Z=Y.position.x+Y.size.width/2,q=Y.position.y+Y.size.height/2,X=Z-_,B=q-z,L=Math.sqrt(X*X+B*B);if(L<1)continue;let F;switch($){case"up":F=-B;break;case"down":F=B;break;case"left":F=-X;break;case"right":F=X;break}if(F<=0)continue;let k=F/L-L*0.001;if(k>W)W=k,K=O}if(K)G6(K)}function Q4($){if(!D.value.get($))return;if(m6!==null)clearTimeout(m6),m6=null;H4.value=null,kU=void 0,V4($),n$.value=$}function u8($){if(m6!==null)clearTimeout(m6),m6=null;if(n$.value===$)n$.value=null;if(H4.value===$)H4.value=null;kU=void 0}function m1(){let $=n$.value,U=$?D.value.get($):void 0;if($&&U&&TY(U)){let v=$,J=Date.now();if(H4.value=v,kU=U.data.appCheckpoint?.updatedAt,m6!==null)clearTimeout(m6);let _=()=>{let K=D.value.get(v)?.data.appCheckpoint?.updatedAt;if(K!==void 0&&K!==kU){u8(v);return}if(Date.now()-J>=hF){u8(v);return}m6=setTimeout(_,rY)};m6=setTimeout(_,rY);return}if(m6!==null)clearTimeout(m6),m6=null;H4.value=null,kU=void 0,n$.value=null}function zv(){let $=f8(Array.from(D.value.values()),Array.from(c$.value.values()),"grid");if($.nodePositions.size===0&&$.groupBounds.size===0)return;o6(()=>{for(let[U,v]of $.nodePositions.entries())q6(U,{position:v});for(let[U,v]of $.groupBounds.entries())vv(U,{position:{x:v.x,y:v.y},size:{width:v.width,height:v.height}},{skipGroupChildTranslation:!0})}),v6()}function Kv(){let $=f8(Array.from(D.value.values()),Array.from(c$.value.values()),"graph");if($.nodePositions.size===0&&$.groupBounds.size===0)return;o6(()=>{for(let[U,v]of $.nodePositions.entries())q6(U,{position:v});for(let[U,v]of $.groupBounds.entries())vv(U,{position:{x:v.x,y:v.y},size:{width:v.width,height:v.height}},{skipGroupChildTranslation:!0})}),v6()}var QZ="pmx-canvas-iframe-probe";var pF="/api/canvas/iframe-probe",oF=3000,w6=s(null);function dF(){let $=new URLSearchParams(window.location.search).get("iframe-mode");return $==="srcdoc"||$==="src"?$:null}function LZ($=oF){return new Promise((U)=>{let v=document.createElement("iframe");v.setAttribute("data-pmx-iframe-probe",""),v.style.cssText="position:fixed;width:1px;height:1px;left:-9999px;border:none",v.setAttribute("sandbox","allow-scripts");let J=(K)=>{window.clearTimeout(z),window.removeEventListener("message",_),v.remove(),U(K)},_=(K)=>{if(K.source!==v.contentWindow)return;if(K.data?.source!==QZ)return;J(!0)},z=window.setTimeout(()=>J(!1),$);window.addEventListener("message",_),v.addEventListener("error",()=>J(!1)),v.src=pF,(document.body??document.documentElement).appendChild(v)})}var Gv=null;function nF(){try{return window.self!==window.top}catch{return!0}}function tF(){return window.__PMX_AMP_ORB===!0}function FZ($={}){if(w6.value)return Promise.resolve(w6.value);if(Gv)return Gv;let U=dF();if(U)return w6.value=U,Promise.resolve(U);if(!($.embedded??nF()))return w6.value="src",LZ($.probeTimeoutMs).then((v)=>{if(!v&&w6.value==="src")w6.value="srcdoc"}),Promise.resolve("src");if($.ampOrb??tF())return w6.value="srcdoc",Promise.resolve("srcdoc");return Gv=LZ($.probeTimeoutMs).then((v)=>{let J=v?"src":"srcdoc";return w6.value=J,J}),Gv}function aF($){let U=$.split(".").pop()?.toLowerCase()??"";return{ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",py:"Python",rs:"Rust",go:"Go",rb:"Ruby",java:"Java",kt:"Kotlin",swift:"Swift",c:"C",cpp:"C++",h:"C/C++",css:"CSS",html:"HTML",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",toml:"TOML",sql:"SQL",sh:"Shell",bash:"Shell",xml:"XML",graphql:"GraphQL",proto:"Protobuf"}[U]??(U.toUpperCase()||"Text")}var p8=500;function sF($){let U=$.toLowerCase();if(U.endsWith(".csv"))return",";if(U.endsWith(".tsv"))return"\t";return null}function eF($,U){let v=[],J=[],_="",z=!1,K=!1;for(let O=0;O<$.length;O++){let Y=$[O];if(K=!0,z){if(Y==='"')if($[O+1]==='"')_+='"',O++;else z=!1;else if(Y==="\r"&&$[O+1]===`
|
|
37
|
-
`)
|
|
38
|
-
`,
|
|
39
|
-
`||
|
|
40
|
-
`)
|
|
41
|
-
`).length;
|
|
42
|
-
`).length,
|
|
43
|
-
`),
|
|
44
|
-
`},void 0,!1,void 0,this)]},
|
|
45
|
-
`,
|
|
46
|
-
`,
|
|
47
|
-
${
|
|
48
|
-
\`\`\``+
|
|
49
|
-
`,
|
|
50
|
-
`,
|
|
51
|
-
`),
|
|
52
|
-
`)+
|
|
53
|
-
`)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`}};
|
|
58
|
-
`}};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`+
|
|
27
|
+
`).trim()}function wt(e,t){if(t<=0)return"";let n=m_(e);if(n.length<=t)return n;if(t<=1)return n.slice(0,t);return`${n.slice(0,Math.max(0,t-1)).trimEnd()}…`}function ds(e,t){if(typeof e==="string")return wt(e,t);if(e===null||e===void 0)return"";try{return wt(JSON.stringify(e),t)}catch{return""}}function h_(e,t){let n=[],o=typeof e.url==="string"?e.url:"",r=typeof e.pageTitle==="string"?e.pageTitle:"",s=typeof e.description==="string"?e.description:"",a=typeof e.status==="string"?e.status:"",c=typeof e.statusCode==="number"?e.statusCode:null,l=typeof e.error==="string"?e.error:"",u=typeof e.content==="string"?e.content:typeof e.excerpt==="string"?e.excerpt:"";if(o)n.push(`URL: ${o}`);if(r)n.push(`Title: ${r}`);if(s)n.push(`Description: ${s}`);if(a||c!==null)n.push(`Fetch: ${a||"unknown"}${c!==null?` (${c})`:""}`);if(l)n.push(`Error: ${l}`);let d=n.join(`
|
|
28
|
+
`),p=Math.max(0,t-d.length-(d?2:0)),m=p>0?wt(u,p):"";if(d&&m)return`${d}
|
|
29
|
+
|
|
30
|
+
${m}`;if(d)return wt(d,t);return wt(u,t)}function g_(e){if(e===null||e===void 0)return"";if(typeof e!=="object"||Array.isArray(e))return"";let t=e.elements;if(Array.isArray(t))return`Diagram elements: ${t.length}`;let n=Object.keys(e).sort();return n.length>0?`Input keys: ${n.join(", ")}`:""}function v_(e,t){let n=[],o=typeof e.title==="string"?e.title:"",r=typeof e.mode==="string"?e.mode:"",s=typeof e.hostMode==="string"?e.hostMode:"",a=typeof e.serverName==="string"?e.serverName:"",c=typeof e.toolName==="string"?e.toolName:"",l=typeof e.resourceUri==="string"?e.resourceUri:"",u=typeof e.path==="string"?e.path:"",d=typeof e.url==="string"?e.url:"",p=typeof e.sessionStatus==="string"?e.sessionStatus:"",m=g_(e.toolInput);if(o)n.push(`App: ${o}`);if(r||s)n.push(`Mode: ${[r,s].filter(Boolean).join(" / ")}`);if(a||c)n.push(`Source: ${[a,c].filter(Boolean).join(" / ")}`);if(l)n.push(`Resource: ${l}`);if(u)n.push(`Path: ${u}`);if(d)n.push(`URL: ${d}`);if(p)n.push(`Session: ${p}`);if(m)n.push(m);if(n.length===0)return"MCP App node";return wt(n.join(`
|
|
31
|
+
`),t)}function y_(e,t){let n=[],o=typeof e.content==="string"?e.content:"",r=typeof e.title==="string"?e.title:"",s=typeof e.path==="string"?e.path:"",a=typeof e.url==="string"?e.url:"",c=typeof e.projectPath==="string"?e.projectPath:"",l=typeof e.artifactBytes==="number"?e.artifactBytes:null,u=typeof e.sourceFileCount==="number"?e.sourceFileCount:null,d=Array.isArray(e.sourceFiles)?e.sourceFiles.filter((m)=>typeof m==="string"):[],p=Array.isArray(e.deps)?e.deps.filter((m)=>typeof m==="string"):[];if(o)n.push(o);if(!o&&r)n.push(`Web artifact: ${r}`);if(d.length>0&&!o.includes("Source files:")){let m=u!==null?Math.max(0,u-d.length):0;n.push(`Source files: ${d.join(", ")}${m>0?`, +${m} more`:""}`)}if(l!==null&&!o.includes("Artifact bytes:"))n.push(`Artifact bytes: ${l}`);if(p.length>0&&!o.includes("Dependencies:"))n.push(`Dependencies: ${p.join(", ")}`);if(s)n.push(`Path: ${s}`);if(c)n.push(`Project: ${c}`);if(a)n.push(`URL: ${a}`);return n.length>0?wt(n.join(`
|
|
32
|
+
`),t):"Web artifact node"}function x_(e,t){let n=[],o=typeof e.htmlPrimitive==="string"?e.htmlPrimitive:"",r=typeof e.description==="string"?e.description:"",s=e.primitiveData;if(o)n.push(`HTML primitive: ${o}`);if(r)n.push(r);if(s!==void 0)n.push(`Data: ${ds(s,t)}`);return wt(n.join(`
|
|
33
|
+
`),t)}function Kp(e,t={}){let n=t.defaultTextLength??p_,o=t.webpageTextLength??f_;switch(e.type){case"markdown":{let r=e.data.rendered||e.data.content||"";return wt(r,n)}case"mcp-app":{if(e.data.viewerType==="web-artifact")return y_(e.data,n);let r=e.data.chartConfig;if(r){let s=r.title||"Untitled chart",a=r.type||"unknown",c=Array.isArray(r.labels)?r.labels.join(", "):"";return wt(`Chart: ${s} (${a}). Labels: ${c}`,n)}return v_(e.data,n)}case"webpage":return h_(e.data,o);case"json-render":case"graph":{let r=e.data.graphConfig;if(r)return wt(`Graph: ${JSON.stringify(r)}`,n);return ds(e.data.spec??{},n)}case"html":{if(typeof e.data.agentSummary==="string")return wt(e.data.agentSummary,n);if(typeof e.data.htmlPrimitive==="string")return x_(e.data,n);return ds({title:e.data.title,description:e.data.description,summary:e.data.summary,contentSummary:e.data.contentSummary,embeddedNodeIds:e.data.embeddedNodeIds,embeddedUrls:e.data.embeddedUrls},n)}case"prompt":case"response":{let r=e.data.text||e.data.content||"";return wt(r,n)}case"file":{let r=typeof e.data.path==="string"?e.data.path:"",s=typeof e.data.fileContent==="string"?e.data.fileContent:typeof e.data.content==="string"?e.data.content:"",a=r?`Path: ${r}
|
|
34
|
+
|
|
35
|
+
`:"",c=Math.max(0,n-a.length);return`${a}${wt(s,c)}`.trim()}default:return ds(e.data,n)}}function b_(e,t){let n=e.position.x+e.size.width/2,o=e.position.y+e.size.height/2,r=t.position.x+t.size.width/2,s=t.position.y+t.size.height/2;return Math.sqrt((n-r)**2+(o-s)**2)}function w_(e,t){let n=e.position.x+e.size.width,o=e.position.y+e.size.height,r=t.position.x+t.size.width,s=t.position.y+t.size.height,a=Math.max(0,Math.max(e.position.x,t.position.x)-Math.min(n,r)),c=Math.max(0,Math.max(e.position.y,t.position.y)-Math.min(o,s));return Math.sqrt(a**2+c**2)}function __(e){let t=[...e],n=100;return t.sort((o,r)=>{let s=Math.floor(o.position.y/100),a=Math.floor(r.position.y/100);if(s!==a)return s-a;return o.position.x-r.position.x}),t}function S_(e){let t=e.find((r)=>r.data.title&&typeof r.data.title==="string");if(t&&e.length<=3)return e.filter((s)=>s.data.title).map((s)=>s.data.title).slice(0,3).join(", ");let n={};for(let r of e)n[r.type]=(n[r.type]??0)+1;let o=Object.entries(n).map(([r,s])=>s===1?r:`${s} ${r}`);if(t)return`${t.data.title} + ${o.join(", ")}`;return o.join(", ")}function k_(e,t){return e.x<=t.x+t.width&&e.x+e.width>=t.x&&e.y<=t.y+t.height&&e.y+e.height>=t.y}function C_(e,t){let n=t.filter((r)=>k_(e.bounds,{x:r.position.x,y:r.position.y,width:r.size.width,height:r.size.height})),o=n.map((r)=>typeof r.data.title==="string"&&r.data.title.length>0?r.data.title:r.id);return{id:e.id,label:e.label??e.text??null,bounds:e.bounds,targetNodeIds:n.map((r)=>r.id),targetNodeTitles:o,target:o.length>0?o.join(", "):"empty canvas region"}}function T_(e,t=200){if(e.length===0)return[];let n=new Map,o=(l)=>{while(n.get(l)!==l){let u=n.get(l);n.set(l,n.get(u)),l=u}return l},r=(l,u)=>{let d=o(l),p=o(u);if(d!==p)n.set(d,p)};for(let l of e)n.set(l.id,l.id);for(let l=0;l<e.length;l++)for(let u=l+1;u<e.length;u++)if(w_(e[l],e[u])<=t)r(e[l].id,e[u].id);let s=new Map;for(let l of e){let u=o(l.id);if(!s.has(u))s.set(u,[]);s.get(u).push(l)}let a=[],c=0;for(let[,l]of s){if(l.length<2)continue;let u=l.map((h)=>h.position.x),d=l.map((h)=>h.position.y),p=l.map((h)=>h.position.x+h.size.width),m=l.map((h)=>h.position.y+h.size.height),f=Math.min(...u),y=Math.min(...d),v=Math.max(...p),x=Math.max(...m);a.push({id:`cluster-${c++}`,nodeIds:l.map((h)=>h.id),label:S_(l),centroid:{x:Math.round((f+v)/2),y:Math.round((y+x)/2)},bounds:{x:f,y,width:v-f,height:x-y}})}return a.sort((l,u)=>{let d=Math.floor(l.centroid.y/200),p=Math.floor(u.centroid.y/200);if(d!==p)return d-p;return l.centroid.x-u.centroid.x}),a}function E_(e,t,n=5,o=600){let r=e.filter((a)=>t.has(a.id)),s=e.filter((a)=>!t.has(a.id));return r.map((a)=>{let c=s.map((l)=>({node:l,distance:b_(a,l)})).filter((l)=>l.distance<=o).sort((l,u)=>l.distance-u.distance).slice(0,n);return{pinnedNodeId:a.id,pinnedNodeTitle:a.data.title??null,neighbors:c.map((l)=>({id:l.node.id,type:l.node.type,title:l.node.data.title??null,distance:Math.round(l.distance)}))}})}function Hr(e,t,n,o=[]){let r=T_(e),s=new Map;for(let u of r)for(let d of u.nodeIds)s.set(d,u.id);let c=__(e).map((u,d)=>({id:u.id,type:u.type,title:u.data.title??null,content:Kp(u,{defaultTextLength:320,webpageTextLength:640})||null,clusterId:s.get(u.id)??null,readingOrder:d})),l=E_(e,n);return{totalNodes:e.length,clusters:r,nodesInReadingOrder:c,pinnedNeighborhoods:l,annotations:o.map((u)=>C_(u,e))}}function Bo(e){if(!e)return null;let t=e.data.title;return typeof t==="string"&&t.trim().length>0?t.trim():null}function ps(e,t){return{id:e?.id??t,title:Bo(e),nodeType:e?.type??"markdown"}}function Jp(e,t){return{id:e.id,edgeType:e.type,fromId:e.from,toId:e.to,fromTitle:Bo(t.get(e.from)),toTitle:Bo(t.get(e.to))}}function fs(e){return new Map(e.map((t)=>[t.id,t]))}function Yp(e){return new Map(e.map((t)=>[t.id,t]))}function Zt(e){return Array.from(e).sort((t,n)=>t.localeCompare(n))}function jc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Zc(e){if(!e||e.type!=="group")return[];let t=e.data.children;if(!Array.isArray(t))return[];return t.filter((n)=>typeof n==="string").sort((n,o)=>n.localeCompare(o))}function Qp(e){let t=new Map;for(let n of e.clusters){let o=[...n.nodeIds].sort((r,s)=>r.localeCompare(s));for(let r of o)t.set(r,o.filter((s)=>s!==r))}return t}function ef(e){let t=new Map;for(let n of e.pinnedNeighborhoods)t.set(n.pinnedNodeId,n.neighbors.map((o)=>o.id).sort((o,r)=>o.localeCompare(r)));return t}function A_(e,t){let n=Zt(Array.from(t).filter((r)=>!e.has(r))),o=Zt(Array.from(e).filter((r)=>!t.has(r)));return{added:n,removed:o}}function tf(e){let t=e&&typeof e==="object"?e:{};return{timestamp:typeof t.timestamp==="string"?t.timestamp:void 0,sessionId:typeof t.sessionId==="string"?t.sessionId:void 0}}function I_(e,t,n){if(!e||!n)return{layout:e,pinnedNodeIds:[],primaryFocusNodeIds:[],secondaryFocusNodeIds:[],regions:[],spatial:n};let o=fs(e.nodes),r=Zt(t).filter((l)=>o.has(l)),s=new Set(r),a=new Set,c=[];for(let l of n.pinnedNeighborhoods){if(!s.has(l.pinnedNodeId))continue;let u=Zt([l.pinnedNodeId,...l.neighbors.map((d)=>d.id)]).filter((d,p,m)=>m.indexOf(d)===p&&o.has(d));for(let d of u)if(!s.has(d))a.add(d);c.push({id:`region-${l.pinnedNodeId}`,primaryNodeId:l.pinnedNodeId,nodeIds:u})}if(c.length===0&&r.length>0)for(let l of r)c.push({id:`region-${l}`,primaryNodeId:l,nodeIds:[l]});return{layout:e,pinnedNodeIds:r,primaryFocusNodeIds:r,secondaryFocusNodeIds:Zt(a),regions:c,spatial:n}}class ms{currentLayout=null;currentPins=new Set;previousSpatial=null;setInitialPins(e){this.currentPins=new Set(e)}getAttentionSnapshot(){return I_(this.currentLayout,this.currentPins,this.previousSpatial)}handleMessage(e){if(e.event==="context-pins-changed")return this.handleContextPinsChanged(e.data);if(e.event==="canvas-layout-update")return this.handleLayoutUpdate(e.data);return[]}handleContextPinsChanged(e){let t=e&&typeof e==="object"?e:{},n=Array.isArray(t.nodeIds)?t.nodeIds.filter((u)=>typeof u==="string"):[],o=tf(e),r=new Set(n),{added:s,removed:a}=A_(this.currentPins,r);if(this.currentPins=r,!this.currentLayout)return[];let c=fs(this.currentLayout.nodes),l={added:s.map((u)=>ps(c.get(u),u)),removed:a.map((u)=>ps(c.get(u),u))};if(this.previousSpatial=Hr(this.currentLayout.nodes,this.currentLayout.edges,this.currentPins,this.currentLayout.annotations??[]),l.added.length===0&&l.removed.length===0)return[];return[{type:"context-pin",...o,...l}]}handleLayoutUpdate(e){let t=e&&typeof e==="object"?e:{},n=t.layout&&typeof t.layout==="object"?t.layout:null;if(!n)return[];let o=tf(e);if(!this.currentLayout)return this.currentLayout=n,this.previousSpatial=Hr(n.nodes,n.edges,this.currentPins,n.annotations??[]),[];let r=this.currentLayout,s=this.previousSpatial??Hr(r.nodes,r.edges,this.currentPins,r.annotations??[]),a=Hr(n.nodes,n.edges,this.currentPins,n.annotations??[]),c=[],l=fs(r.nodes),u=fs(n.nodes),d=Yp(r.edges),p=Yp(n.edges),m=Zt(Array.from(p.keys()).filter((h)=>!d.has(h))).map((h)=>p.get(h)).filter((h)=>h!==void 0);if(m.length>0)c.push({type:"connect",...o,edges:m.map((h)=>Jp(h,u))});let f=Zt(Array.from(l.keys()).filter((h)=>!u.has(h))),y=Zt(Array.from(d.keys()).filter((h)=>!p.has(h)));if(f.length>0||y.length>0)c.push({type:"remove",...o,nodes:f.map((h)=>ps(l.get(h),h)),edges:y.map((h)=>d.get(h)).filter((h)=>h!==void 0).map((h)=>Jp(h,l))});let v=this.buildGroupEvent(l,u,o);if(v)c.push(v);let x=this.buildMoveEndEvent(r,n,l,u,s,a,o);if(x)c.push(x);return this.currentLayout=n,this.previousSpatial=a,c}buildGroupEvent(e,t,n){let o=Zt(Array.from(e.values()).filter((c)=>c.type==="group").map((c)=>c.id)),r=Zt(Array.from(t.values()).filter((c)=>c.type==="group").map((c)=>c.id)),s=r.filter((c)=>!o.includes(c)).map((c)=>{let l=t.get(c),u=Zc(l);return{id:c,title:Bo(l),childCount:u.length}}),a=[];for(let c of r.filter((l)=>o.includes(l))){let l=Zc(e.get(c)),u=Zc(t.get(c));if(jc(l,u))continue;a.push({id:c,title:Bo(t.get(c)),addedChildIds:u.filter((d)=>!l.includes(d)),removedChildIds:l.filter((d)=>!u.includes(d)),childCount:u.length})}if(s.length===0&&a.length===0)return null;return{type:"group",...n,created:s,updated:a}}buildMoveEndEvent(e,t,n,o,r,s,a){let c=Zt(Array.from(o.keys()).filter((x)=>{let h=n.get(x),g=o.get(x);if(!h||!g)return!1;return h.position.x!==g.position.x||h.position.y!==g.position.y}));if(c.length===0)return null;let l=Qp(r),u=Qp(s),d=ef(r),p=ef(s),m=new Map,f=(x,h)=>{let g=m.get(x)??new Set;g.add(h),m.set(x,g)};for(let x of c){let h=l.get(x)??[],g=u.get(x)??[];if(!jc(h,g))if(h.length===0&&g.length>0)f(x,"joined cluster");else if(h.length>0&&g.length===0)f(x,"left cluster");else f(x,"cluster changed")}let y=new Set([...d.keys(),...p.keys()]);for(let x of y){let h=d.get(x)??[],g=p.get(x)??[];if(jc(h,g))continue;let b=Bo(o.get(x)??n.get(x))??x,O=g.filter((_)=>!h.includes(_)),F=h.filter((_)=>!g.includes(_));for(let _ of O)if(c.includes(_))f(_,`entered pinned neighborhood of "${b}"`);for(let _ of F)if(c.includes(_))f(_,`left pinned neighborhood of "${b}"`);if(c.includes(x))f(x,"pinned neighborhood changed")}let v=c.filter((x)=>(m.get(x)?.size??0)>0).map((x)=>{let h=o.get(x);return{...ps(h,x),reasons:Array.from(m.get(x)??[]).sort((g,b)=>g.localeCompare(b))}});if(v.length===0)return null;return{type:"move-end",...a,nodes:v}}}var Wc=new ms,Uo=[],Br=null,Wo=null,Hc="",Bc=0;function of(e,t){return globalThis.setTimeout(e,t)}function Uc(e){if(e===null)return;globalThis.clearTimeout(e)}function z_(e){if(typeof globalThis.requestAnimationFrame==="function"){globalThis.requestAnimationFrame(()=>e());return}e()}function In(e,t){return e&&e.trim().length>0?e.trim():t}function cn(e,t=3){if(e.length===0)return"";if(e.length<=t)return e.join(", ");return`${e.slice(0,t).join(", ")} +${e.length-t}`}function P_(e){return Array.from(new Set(Array.from(e).filter((t)=>t.length>0)))}function Ht(e,t,n,o,r=Date.now()){return{id:`${e}-${r}-${Math.random().toString(36).slice(2,8)}`,tone:e,title:t,detail:n,nodeIds:P_(o),createdAt:r}}function nf(e){if(e==="joined cluster")return"joined a nearby cluster";if(e==="left cluster")return"moved away from its cluster";if(e==="cluster changed")return"shifted into a different cluster";if(e==="pinned neighborhood changed")return"changed the local focus field";let t=/^entered pinned neighborhood of "(.+)"$/.exec(e);if(t)return`moved into focus around ${t[1]}`;let n=/^left pinned neighborhood of "(.+)"$/.exec(e);if(n)return`moved out of focus around ${n[1]}`;return e}function N_(e){let t=e.added.map((r)=>In(r.title,r.id)),n=e.removed.map((r)=>In(r.title,r.id));if(t.length===0&&n.length===0)return null;let o="";if(t.length>0&&n.length===0)o=`Now in focus: ${cn(t)}`;else if(n.length>0&&t.length===0)o=`Removed from focus: ${cn(n)}`;else{let r=[];if(t.length>0)r.push(`${cn(t)} added`);if(n.length>0)r.push(`${cn(n)} removed`);o=r.join(" · ")}return Ht("context","Context updated",o,[...e.added.map((r)=>r.id),...e.removed.map((r)=>r.id)],e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}function R_(e){if(e.edges.length===0)return null;if(e.edges.length===1){let t=e.edges[0];return Ht("relationship","Relationship added",`${In(t.fromTitle,t.fromId)} linked to ${In(t.toTitle,t.toId)}`,[t.fromId,t.toId],e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}return Ht("relationship","Relationships added",`${e.edges.length} connections changed the board structure`,e.edges.flatMap((t)=>[t.fromId,t.toId]),e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}function $_(e){if(e.nodes.length===0&&e.edges.length===0)return null;let t=e.nodes.map((o)=>In(o.title,o.id)),n=[];if(t.length>0)n.push(cn(t));if(e.edges.length>0)n.push(`${e.edges.length} relationship${e.edges.length===1?"":"s"}`);return Ht("remove","Items removed",n.join(" · "),[...e.nodes.map((o)=>o.id),...e.edges.flatMap((o)=>[o.fromId,o.toId])],e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}function M_(e){if(e.created.length>0){let t=e.created.map((n)=>In(n.title,n.id));return Ht("group",e.created.length===1?"Group created":"Groups created",e.created.length===1?`${t[0]} now frames ${e.created[0].childCount} items`:cn(t),e.created.map((n)=>n.id),e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}if(e.updated.length>0){let t=e.updated.map((n)=>In(n.title,n.id));return Ht("group",e.updated.length===1?"Group updated":"Groups updated",e.updated.length===1?`${t[0]} now holds ${e.updated[0].childCount} items`:cn(t),e.updated.map((n)=>n.id),e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now())}return null}function O_(e){if(e.nodes.length===0)return null;let t=e.nodes.flatMap((s)=>s.reasons),n=e.nodes.map((s)=>In(s.title,s.id)),o=e.timestamp?Date.parse(e.timestamp)||Date.now():Date.now();if(t.some((s)=>s.includes("pinned neighborhood"))){if(e.nodes.length===1)return Ht("neighborhood","Neighborhood changed",`${n[0]} ${nf(e.nodes[0].reasons[0])}`,e.nodes.map((s)=>s.id),o);return Ht("neighborhood","Neighborhood changed",cn(n),e.nodes.map((s)=>s.id),o)}let r=t.filter((s)=>s.includes("cluster"));if(r.length>0){let s=r.every((a)=>a==="joined cluster");if(e.nodes.length===1)return Ht("cluster",s?"Cluster formed":"Cluster changed",`${n[0]} ${nf(e.nodes[0].reasons[0])}`,e.nodes.map((a)=>a.id),o);return Ht("cluster",s?"Cluster formed":"Cluster changed",cn(n),e.nodes.map((a)=>a.id),o)}return null}function L_(e){switch(e.type){case"context-pin":return N_(e);case"connect":return R_(e);case"remove":return $_(e);case"group":return M_(e);case"move-end":return O_(e)}}function D_(){let e=Wc.getAttentionSnapshot();Ip(e.primaryFocusNodeIds,e.secondaryFocusNodeIds,e.regions)}function rf(){if(Br!==null)return;let e=Uo.shift()??null;if(!e){ts(null);return}ts(e);let t=Math.max(1800,Math.min(2800,1600+e.detail.length*18));Br=of(()=>{Br=null,ts(null),rf()},t)}function sf(e){if(Uo.push(e),Uo.length>3)Uo.splice(0,Uo.length-3);rf()}function qo(e,t,n="",o=[]){sf(Ht(e,t,n,o))}function F_(e){if(Uc(Wo),Wo=null,ns([]),e.length===0)return;z_(()=>{ns(e),Wo=of(()=>{Wo=null,ns([])},900)})}function j_(e){let t=`${e.tone}:${e.title}:${e.detail}`,n=e.createdAt;if(t===Hc&&n-Bc<1200)return!0;return Hc=t,Bc=n,!1}function qc(){Uc(Br),Uc(Wo),Br=null,Wo=null,Uo=[],Hc="",Bc=0,Wc=new ms,Ep()}function Vc(e){let t=Wc.handleMessage(e).map((n)=>L_(n)).filter((n)=>n!==null);D_();for(let n of t){if(j_(n))continue;zp(n),sf(n),F_(n.nodeIds)}}async function zn(e,t,n,o){let r=await as({type:t,sourceNodeId:e.id,sourceSurface:"native-node",...n?{payload:n}:{}});if(r.ok)qo("context",o,"",[e.id]);else qo("remove","AX action failed",r.error??r.code??"Unknown error",[e.id])}var co={padding:"3px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer",flexShrink:0};function Z_(e){let t=e.title||e.label||e.key||"Context",n=e.summary?.trim()||"Available in startup context.",o=e.pathDisplay||e.path||"",r=e.category==="profile"?"Operator":e.category==="planning"||e.category==="memory"?"Product":e.category?e.category.charAt(0).toUpperCase()+e.category.slice(1):void 0,s=e.sourceKind==="global"?"Global":"Workspace",a=e.state==="missing"?"Missing":e.state==="stale"?"Stale":e.state==="invalid"?"Invalid":"Loaded";return{title:t,summary:n,pathDisplay:o,category:r,sourceKind:s,status:a,required:e.required===!0}}function Bt(e){return typeof e==="string"?e.trim():""}function H_(e){return e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}function B_(e){let t=Bt(e.title),n=Bt(e.content),o=H_(Bt(e.rendered)),r=n||o,s=Bt(e.path);if(!t&&!r&&!s)return null;return{title:t||"Context",summary:r,path:s}}function U_(e){let t=Bt(e.data.title)||e.id,n=Bt(e.data.content)||Bt(e.data.excerpt)||Bt(e.data.description)||Bt(e.data.pageTitle)||"",o=Bt(e.data.path)||Bt(e.data.url);return{id:e.id,title:t,summary:n,kind:ot[e.type]??e.type,path:o}}function af(e){if(e===null||!Number.isFinite(e)||e<0)return"0";if(e>=1e6)return`${(e/1e6).toFixed(1)}m`;if(e>=1000)return`${(e/1000).toFixed(1)}k`;return`${Math.round(e)}`}function W_(e){if(e>=0.95)return"var(--c-danger)";if(e>=0.85)return"var(--c-warn)";if(e>=0.7)return"var(--c-warn)";return"var(--c-accent)"}function hs({node:e,expanded:t=!1,pinnedNodes:n=[]}){let o=e.data.cards??[],r=e.data.auxTabs??[],s=n.map(U_),a=s.length>0,c=typeof e.data.currentTokens==="number"?e.data.currentTokens:null,l=typeof e.data.tokenLimit==="number"?e.data.tokenLimit:null,u=typeof e.data.utilization==="number"?e.data.utilization:null,d=typeof e.data.messagesLength==="number"?e.data.messagesLength:null,p=u!==null?Math.max(0,Math.min(100,Math.round(u*100))):null,m=W_(u??0),f=!a&&o.length===0&&r.length===0?B_(e.data):null,y=async(v)=>{let x=typeof v.path==="string"?v.path.trim():"";if(!x)return;await rs(x)};return i("div",{style:{display:"flex",flexDirection:"column",gap:t?"10px":"6px",fontSize:t?"14px":"12px",maxWidth:t?"760px":void 0,margin:t?"0 auto":void 0,width:t?"100%":void 0,padding:t?"8px 0":void 0},children:[i("div",{style:{display:"flex",justifyContent:"flex-end"},children:i("button",{type:"button",class:"ax-node-action",title:"Point the agent at this node — sets it as the agent's current AX focus so the agent pulls it into context to work on next (a one-click alternative to manually pinning).",style:co,onClick:(v)=>{v.stopPropagation(),zn(e,"ax.focus.set",void 0,"Focus set")},children:"Set focus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),l!==null&&l>0&&i("div",{style:{marginBottom:"8px"},children:[i("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:"Token Usage"},void 0,!1,void 0,this),i("div",{style:{height:"6px",background:"var(--c-surface-hover)",borderRadius:"3px",overflow:"hidden",marginBottom:"4px"},children:i("div",{style:{height:"100%",width:`${Math.min(100,(u??0)*100)}%`,background:m,borderRadius:"3px",transition:"width 0.3s ease"}},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("div",{style:{fontSize:"11px",color:"var(--c-muted)"},children:[p,"% — ",af(c)," / ",af(l)," tokens",d!==null&&i(ye,{children:[" · ",d," messages"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a&&i("div",{children:[i("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:["Pinned Context (",s.length,")"]},void 0,!0,void 0,this),s.map((v)=>i("div",{style:{padding:"6px 8px",background:"var(--c-surface-subtle)",borderRadius:"6px",marginBottom:"4px",borderLeft:"2px solid var(--c-accent)"},children:[i("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"2px"},children:v.title},void 0,!1,void 0,this),v.summary&&i("div",{style:{color:"var(--c-muted)",fontSize:"10px",lineHeight:1.45,marginBottom:"4px",whiteSpace:"pre-wrap"},children:v.summary},void 0,!1,void 0,this),i("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginTop:"4px"},children:i("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:v.kind},void 0,!1,void 0,this)},void 0,!1,void 0,this),v.path&&i("div",{style:{marginTop:"6px"},children:[i("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all",marginBottom:"6px"},children:v.path},void 0,!1,void 0,this),v.path.startsWith("/")&&i("button",{type:"button",onClick:()=>void rs(v.path),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},v.id,!0,void 0,this))]},void 0,!0,void 0,this),!a&&o.length>0&&i("div",{children:[i("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px"},children:["Context (",o.length,")"]},void 0,!0,void 0,this),o.map((v)=>{let x=Z_(v);return i("div",{style:{padding:"6px 8px",background:"var(--c-surface-subtle)",borderRadius:"6px",marginBottom:"4px",borderLeft:"2px solid var(--c-accent)"},children:[i("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"2px"},children:x.title},void 0,!1,void 0,this),i("div",{style:{color:"var(--c-muted)",fontSize:"10px",lineHeight:1.45,marginBottom:"4px"},children:x.summary},void 0,!1,void 0,this),x.pathDisplay&&i("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all"},children:x.pathDisplay},void 0,!1,void 0,this),i("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginTop:"4px"},children:[i("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-accent-10)",color:"var(--c-accent)",borderRadius:"3px",display:"inline-block"},children:x.status},void 0,!1,void 0,this),x.category&&i("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:x.category},void 0,!1,void 0,this),i("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-surface-hover)",color:"var(--c-text-soft)",borderRadius:"3px",display:"inline-block"},children:x.sourceKind},void 0,!1,void 0,this),x.required&&i("span",{style:{fontSize:"9px",padding:"1px 4px",background:"var(--c-warn-12)",color:"var(--c-warn-alt)",borderRadius:"3px",display:"inline-block"},children:"Required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v.path&&i("div",{style:{marginTop:"6px"},children:i("button",{type:"button",onClick:()=>void y(v),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},v.key??x.pathDisplay??x.title,!0,void 0,this)})]},void 0,!0,void 0,this),!a&&r.length>0&&i("div",{children:[i("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"6px",marginTop:o.length>0?"8px":0},children:["References (",r.length,")"]},void 0,!0,void 0,this),r.map((v)=>i("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"4px 8px",color:"var(--c-accent)",fontSize:"11px",textDecoration:"none",borderRadius:"4px",marginBottom:"2px",wordBreak:"break-all"},children:[v.url,v.reason&&i("span",{style:{color:"var(--c-dim)",fontSize:"10px",marginLeft:"6px"},children:["(",v.reason,")"]},void 0,!0,void 0,this)]},v.id,!0,void 0,this))]},void 0,!0,void 0,this),f&&i("div",{style:{padding:"8px 10px",background:"var(--c-surface-subtle)",borderRadius:"6px",borderLeft:"2px solid var(--c-accent)"},children:[i("div",{style:{fontWeight:600,color:"var(--c-text)",marginBottom:"4px"},children:f.title},void 0,!1,void 0,this),f.summary&&i("div",{style:{color:"var(--c-text-soft)",fontSize:"11px",lineHeight:1.5,whiteSpace:"pre-wrap"},children:f.summary},void 0,!1,void 0,this),f.path&&i("div",{style:{marginTop:"6px"},children:[i("div",{style:{color:"var(--c-dim)",fontSize:"10px",wordBreak:"break-all",marginBottom:"6px"},children:f.path},void 0,!1,void 0,this),i("button",{type:"button",onClick:()=>void rs(f.path),style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-accent-12)",border:"1px solid var(--c-accent-25)",borderRadius:"4px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Open in canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!a&&!f&&o.length===0&&r.length===0&&i("div",{style:{color:"var(--c-dim)",fontStyle:"italic"},children:"No context loaded"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function cf(e){return e.replace(/^[ab]\//,"")}function q_(e,t){if(t&&t!=="/dev/null")return cf(t);if(e&&e!=="/dev/null")return cf(e);return null}function V_(e){if(!e.trim())return[];let t=e.split(`
|
|
36
|
+
`);if(t.length>0&&t[t.length-1]==="")t.pop();let n=[],o=null,r=!1,s=(a)=>{let c={path:a,lines:[]};return r=!1,n.push(c),c};for(let a=0;a<t.length;a++){let c=t[a]??"",l=c.match(/^diff --git a\/(.+?) b\/(.+)$/);if(l){o=s(l[2]??null);continue}let u=t[a+1]??"";if(c.startsWith("--- ")&&u.startsWith("+++ ")){let p=q_(c.slice(4).trim(),u.slice(4).trim());if(o&&!r){if(!o.path)o.path=p}else o=s(p);a++;continue}if(!o)o=s(null);let d=o;if(c.startsWith("@@"))r=!0,d.lines.push({kind:"hunk",text:c});else if(c.startsWith("+"))d.lines.push({kind:"add",text:c});else if(c.startsWith("-"))d.lines.push({kind:"remove",text:c});else d.lines.push({kind:"context",text:c})}return n}function gs({node:e}){let t=typeof e.data.content==="string"?e.data.content:"",n=Ie(()=>V_(t),[t]);if(n.length===0)return i("div",{class:"diff-node diff-node-empty",children:"Empty diff"},void 0,!1,void 0,this);return i("div",{class:"diff-node",children:n.map((o,r)=>i("div",{class:"diff-file",children:[o.path&&i("div",{class:"diff-file-header",children:o.path},void 0,!1,void 0,this),i("pre",{class:"diff-lines",children:o.lines.map((s,a)=>i("div",{class:s.kind==="hunk"?"diff-hunk":`diff-line-${s.kind}`,children:s.text||" "},a,!1,void 0,this))},void 0,!1,void 0,this)]},`${o.path??"anonymous"}-${r}`,!0,void 0,this))},void 0,!1,void 0,this)}function lf(e){if(e.length===0)return null;let{POSITIVE_INFINITY:t,POSITIVE_INFINITY:n,NEGATIVE_INFINITY:o,NEGATIVE_INFINITY:r}=Number;for(let s of e)t=Math.min(t,s.position.x),n=Math.min(n,s.position.y),o=Math.max(o,s.position.x+s.size.width),r=Math.max(r,s.position.y+s.size.height);if(!Number.isFinite(t)||!Number.isFinite(n))return null;return{x:t-40,y:n-40-32,width:o-t+80,height:r-n+80+32}}function G_(e){let t=e.filter((l)=>!l.pinned),n=new Map(t.map((l)=>[l.id,l])),o=new Map,r=[],s=new Map;for(let l of t){if(l.type==="group")continue;let u=typeof l.data.parentGroup==="string"?l.data.parentGroup:"",d=u?n.get(u):void 0;if(!d||d.type!=="group")continue;if(!s.has(u))s.set(u,[]);s.get(u).push(l)}let a=t.filter((l)=>l.type==="group").sort((l,u)=>l.position.y-u.position.y||l.position.x-u.position.x);for(let l of a){let u=s.get(l.id)??[];if(u.length===0){let f=`unit:${l.id}`;r.push({id:f,memberIds:[l.id],origin:{...l.position},size:{...l.size},sortKey:{x:l.position.x,y:l.position.y}}),o.set(l.id,f);continue}let d=u.map((f)=>({position:f.position,size:f.size})),p=lf(d);if(!p)continue;let m=`group:${l.id}`;r.push({id:m,memberIds:u.map((f)=>f.id),origin:{x:p.x,y:p.y},size:{width:p.width,height:p.height},sortKey:{x:p.x,y:p.y},groupId:l.id}),o.set(l.id,m);for(let f of u)o.set(f.id,m)}let c=t.filter((l)=>!o.has(l.id)).sort((l,u)=>l.position.y-u.position.y||l.position.x-u.position.x);for(let l of c){let u=`unit:${l.id}`;r.push({id:u,memberIds:[l.id],origin:{...l.position},size:{...l.size},sortKey:{x:l.position.x,y:l.position.y}}),o.set(l.id,u)}return{units:r,nodesById:n,nodeToUnit:o}}function X_(e,t,n){let o=new Map,r=new Map,s=new Map,a=new Map;for(let c of e)o.set(c.id,new Set),r.set(c.id,new Set),s.set(c.id,0),a.set(c.id,0);for(let c of n){let l=t.get(c.from),u=t.get(c.to);if(!l||!u||l===u)continue;if(!o.get(l).has(u))o.get(l).add(u),a.set(l,(a.get(l)??0)+1),s.set(u,(s.get(u)??0)+1);r.get(l).add(u),r.get(u).add(l)}return{outgoing:o,undirected:r,indegree:s,outdegree:a}}function K_(e,t){let n=new Map(e.map((s)=>[s.id,s])),o=new Set,r=[];for(let s of e){if(o.has(s.id))continue;let a=[s.id],c=[];o.add(s.id);while(a.length>0){let u=a.pop();c.push(u);for(let d of t.get(u)??[]){if(o.has(d))continue;o.add(d),a.push(d)}}let l=c.map((u)=>n.get(u)).filter((u)=>u!==void 0).sort((u,d)=>u.sortKey.y-d.sortKey.y||u.sortKey.x-d.sortKey.x);r.push(l)}return r.sort((s,a)=>s[0].sortKey.y-a[0].sortKey.y||s[0].sortKey.x-a[0].sortKey.x)}function J_(e){let t=new Map,n=0,o=0,r=0,s=0,a=Math.max(900,Math.ceil(Math.sqrt(e.reduce((c,l)=>c+l.size.width*l.size.height,0))));for(let c of e){if(n>0&&n+c.size.width>a)n=0,o+=r+72,r=0;t.set(c.id,{x:n,y:o}),n+=c.size.width+96,r=Math.max(r,c.size.height),s=Math.max(s,n-96)}return{positions:t,size:{width:Math.max(0,s),height:o+r},sortKey:e[0].sortKey}}function Y_(e,t,n,o,r){if(e.length===1)return{positions:new Map([[e[0].id,{x:0,y:0}]]),size:{...e[0].size},sortKey:e[0].sortKey};let s=new Set(e.map((g)=>g.id)),a=e.filter((g)=>(o.get(g.id)??0)===0&&(r.get(g.id)??0)>0).sort((g,b)=>g.sortKey.x-b.sortKey.x||g.sortKey.y-b.sortKey.y),c=a.length>0?a:[e.slice().sort((g,b)=>g.sortKey.x-b.sortKey.x||g.sortKey.y-b.sortKey.y)[0]],l=new Map,u=c.map((g)=>g.id);for(let g of c)l.set(g.id,0);while(u.length>0){let g=u.shift(),b=l.get(g)??0;for(let O of n.get(g)??[]){if(!s.has(O)||l.has(O))continue;l.set(O,b+1),u.push(O)}}let d=0;for(let g of e){if(l.has(g.id))continue;l.set(g.id,d),d+=1}let p=new Map;for(let g of e){let b=l.get(g.id)??0;if(!p.has(b))p.set(b,[]);p.get(b).push(g)}let m=Array.from(p.keys()).sort((g,b)=>g-b);for(let g of m)p.get(g).sort((b,O)=>b.sortKey.y-O.sortKey.y||b.sortKey.x-O.sortKey.x);let f=new Map,y=new Map,v=0;for(let g of m){let b=p.get(g),O=b.reduce((_,k,T)=>_+k.size.height+(T>0?72:0),0),F=Math.max(...b.map((_)=>_.size.width));f.set(g,O),y.set(g,F),v=Math.max(v,O)}let x=new Map,h=0;for(let g of m){let b=p.get(g),O=f.get(g)??0,F=y.get(g)??0,_=Math.max(0,(v-O)/2);for(let k of b)x.set(k.id,{x:h,y:_}),_+=k.size.height+72;h+=F+96}return{positions:x,size:{width:Math.max(0,h-96),height:v},sortKey:e[0].sortKey}}function Q_(e,t){let n=new Map(e.map((l)=>[l.id,l.id])),o=(l)=>{let u=l;while(n.get(u)!==u)u=n.get(u);let d=l;while(n.get(d)!==d){let p=n.get(d);n.set(d,u),d=p}return u},r=(l,u)=>{let d=o(l),p=o(u);if(d!==p)n.set(d,p)},s=160;for(let l=0;l<e.length;l++)for(let u=l+1;u<e.length;u++){let d=e[l],p=e[u];if(d.origin.x-160<p.origin.x+p.size.width+160&&d.origin.x+d.size.width+160>p.origin.x-160&&d.origin.y-160<p.origin.y+p.size.height+160&&d.origin.y+d.size.height+160>p.origin.y-160)r(d.id,p.id)}for(let[l,u]of t)for(let d of u)if(n.has(l)&&n.has(d))r(l,d);let a=new Map;for(let l of e){let u=o(l.id);if(!a.has(u))a.set(u,[]);a.get(u).push(l)}let c=Array.from(a.values());for(let l of c)l.sort((u,d)=>u.sortKey.y-d.sortKey.y||u.sortKey.x-d.sortKey.x);return c.sort((l,u)=>l[0].sortKey.y-u[0].sortKey.y||l[0].sortKey.x-u[0].sortKey.x)}function eS(e,t){let n=new Map,{x:o,y:r}=t,s=0;for(let a of e){if(o>t.x&&o-t.x+a.size.width>3200)o=t.x,r+=s+180,s=0;for(let[c,l]of a.positions.entries())n.set(c,{x:o+l.x,y:r+l.y});o+=a.size.width+220,s=Math.max(s,a.size.height)}return n}function Gc(e,t,n){let{units:o,nodesById:r,nodeToUnit:s}=G_(e),a=new Map,c=new Map;if(o.length===0)return{nodePositions:a,groupBounds:c};let{outgoing:l,undirected:u,indegree:d,outdegree:p}=X_(o,s,t),m=Q_(o,u),f=new Map,y=[];for(let v of m){let x=K_(v,u).map((_)=>n==="graph"?Y_(_,l,u,d,p):J_(_)),h={x:Math.min(...v.map((_)=>_.origin.x)),y:Math.min(...v.map((_)=>_.origin.y))},g=eS(x,h),b=new Map(v.map((_)=>[_.id,_.size])),O=(_)=>{let{POSITIVE_INFINITY:k,POSITIVE_INFINITY:T,NEGATIVE_INFINITY:P,NEGATIVE_INFINITY:Z}=Number;for(let[j,I]of _){let H=b.get(j);if(!H)continue;k=Math.min(k,I.x),T=Math.min(T,I.y),P=Math.max(P,I.x+H.width),Z=Math.max(Z,I.y+H.height)}return{x:k,y:T,width:P-k,height:Z-T}},F=g;for(let _=0;_<=y.length;_++){let k=O(F),T=y.filter((j)=>k.x<j.x+j.width+220&&k.x+k.width+220>j.x&&k.y<j.y+j.height+180&&k.y+k.height+180>j.y);if(T.length===0)break;let P=Math.max(...T.map((j)=>j.y+j.height))+180-k.y;if(P<=0)break;let Z=new Map;for(let[j,I]of F)Z.set(j,{x:I.x,y:I.y+P});F=Z}for(let[_,k]of F)f.set(_,k);y.push(O(F))}for(let v of o){let x=f.get(v.id);if(!x)continue;let h=x.x-v.origin.x,g=x.y-v.origin.y;if(v.groupId){let F=[];for(let k of v.memberIds){let T=r.get(k);if(!T)continue;let P={x:T.position.x+h,y:T.position.y+g};a.set(k,P),F.push({position:P,size:T.size})}let _=lf(F);if(_)c.set(v.groupId,_);continue}let b=v.memberIds[0],O=r.get(b);if(!O)continue;a.set(b,{x:O.position.x+h,y:O.position.y+g})}return{nodePositions:a,groupBounds:c}}function mf(e,t){console.error(`[canvas-store] ${e} failed`,t)}var oe=V({x:0,y:0,scale:1}),R=V(new Map),Re=V(new Map),Go=V(new Map),Ce=V(null),un=V(null),Tt=V("connecting"),lo=V(0),uo=V(0),po=V(0),dn=V(""),Xo=V(!1),Ge=V("dark"),Ut=V(!1),Wt=V(null),Be=V(null),Yt=V(null),Ct=null,Vo,uf=100,tS=2500,vs=V(null),je=V(null),Nn=V(null),xe=V(new Set),Ee=V(new Set),vt=V("select"),Wr=V(!1);function Ko(){return vt.value==="pan"||Wr.value}function hf(e,t){if(!e)return new Set;let n=new Set;for(let o of t.values()){if(o.from===e)n.add(o.to);if(o.to===e)n.add(o.from)}return n}var gf=Le(()=>hf(Ce.value,Re.value));function df(e,t){let n=new Set;for(let o of e)if(t.has(o))n.add(o);return n}function pf(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Jc(e){let t=new Set(xe.value);if(t.has(e))t.delete(e);else t.add(e);xe.value=t}function vf(e){xe.value=new Set(e)}function mt(){if(un.value=null,xe.value.size===0)return;xe.value=new Set}var ln=V(null),Yc=!1;function yf(){Yc=!0,ln.value=null}function xf(){Yc=!1,ln.value=null}function Xc(e){return{x:e.position.x,y:e.position.y,w:e.size.width,h:e.size.height}}function nS(e,t,n){let o=Xc(e);return t>=o.x&&t<=o.x+o.w&&n>=o.y&&n<=o.y+o.h}function ff(e,t){let n=Xc(e),o=Xc(t);return n.x+n.w<o.x||n.x>o.x+o.w||n.y+n.h<o.y||n.y>o.y+o.h}function bf(e){let t=R.value.get(e);if(!t||t.type==="group")return;let n=typeof t.data.parentGroup==="string"?t.data.parentGroup:null,o=n?R.value.get(n):void 0,r=t.position.x+t.size.width/2,s=t.position.y+t.size.height/2,a=null;for(let c of R.value.values()){if(c.type!=="group"||c.id===n||c.collapsed)continue;if(nS(c,r,s))a=c}if(!Yc){let c=a?{nodeId:e,groupId:a.id,mode:"add"}:o&&ff(t,o)?{nodeId:e,groupId:o.id,mode:"remove"}:null,l=ln.value;if((l?.groupId??null)!==(c?.groupId??null)||l?.mode!==c?.mode)ln.value=c}if(o&&o.data.frameMode!=="manual"&&!ff(t,o)){let l=Math.min(o.position.x,t.position.x-22),u=Math.min(o.position.y,t.position.y-22-32),d=Math.max(o.position.x+o.size.width,t.position.x+t.size.width+22),p=Math.max(o.position.y+o.size.height,t.position.y+t.size.height+22);if(l!==o.position.x||u!==o.position.y||d!==o.position.x+o.size.width||p!==o.position.y+o.size.height)ws(o.id,{position:{x:l,y:u},size:{width:d-l,height:p-u}},{skipGroupChildTranslation:!0})}}var Qc=Le(()=>{let e=new Map;for(let t of R.value.values()){if(t.type!=="group"||!t.collapsed)continue;let n=Array.isArray(t.data.children)?t.data.children:[];for(let o of n)if(typeof o==="string")e.set(o,t.id)}return e});function ys(e){let t=Qc.value.get(e);return R.value.get(t??e)}function wf(){let e=new Set;for(let t of xe.value){let n=R.value.get(t);if(!n)continue;if(n.type==="group")e.add(n.id);else if(typeof n.data.parentGroup==="string")e.add(n.data.parentGroup)}return[...e]}function el(e){let t=tl();if(t.length<2)return;let n=Math.min(...t.map((l)=>e==="left"?l.position.x:l.position.y)),o=24,r=new Map;for(let l of t)r.set(l.id,e==="left"?{x:n,y:l.position.y}:{x:l.position.x,y:n});let s=(l,u)=>l.x<u.x+u.w&&u.x<l.x+l.w&&l.y<u.y+u.h&&u.y<l.y+l.h,a=t.map((l)=>{let u=r.get(l.id);return{node:l,x:u.x,y:u.y,w:l.size.width,h:l.size.height}});if(a.some((l,u)=>a.some((d,p)=>p>u&&s(l,d)))){let l=[...t].sort((d,p)=>e==="left"?d.position.y-p.position.y:d.position.x-p.position.x),u=e==="left"?Math.min(...t.map((d)=>d.position.y)):Math.min(...t.map((d)=>d.position.x));for(let d of l)r.set(d.id,e==="left"?{x:n,y:u}:{x:u,y:n}),u+=(e==="left"?d.size.height:d.size.width)+o}$t(()=>{for(let l of t)rt(l.id,{position:r.get(l.id)})}),Je()}function _f(){let e=tl().sort((c,l)=>c.position.x-l.position.x);if(e.length<3)return;let t=e[0],o=e[e.length-1].position.x-(t.position.x+t.size.width),r=e.slice(1,-1),s=r.reduce((c,l)=>c+l.size.width,0),a=(o-s)/(r.length+1);$t(()=>{if(a<8){let l=t.position.x+t.size.width+24;for(let u of e.slice(1))rt(u.id,{position:{x:l,y:u.position.y}}),l+=u.size.width+24;return}let c=t.position.x+t.size.width+a;for(let l of r)rt(l.id,{position:{x:c,y:l.position.y}}),c+=l.size.width+a}),Je()}function Sf(e=24){let t=tl().sort((c,l)=>c.position.y-l.position.y||c.position.x-l.position.x);if(t.length<2)return;let n=Math.min(...t.map((c)=>c.position.x)),o=Math.min(...t.map((c)=>c.position.y)),r=Math.ceil(Math.sqrt(t.length)),s=Math.max(...t.map((c)=>c.size.width)),a=Math.max(...t.map((c)=>c.size.height));$t(()=>{t.forEach((c,l)=>{rt(c.id,{position:{x:n+l%r*(s+e),y:o+Math.floor(l/r)*(a+e)}})})}),Je()}function tl(){let e=xe.value;if(e.size===0)return[];return Array.from(e).map((t)=>R.value.get(t)).filter((t)=>t!==void 0)}function Rn(e){let t=new Set(Ee.value);if(t.has(e))t.delete(e);else t.add(e);Ee.value=t,Je(),bs(t)}function xs(e){let t=new Set(Ee.value);for(let n of e)t.add(n);Ee.value=t,Je(),bs(t)}function kf(){if(Ee.value.size===0)return;Ee.value=new Set,Je(),bs(new Set)}function Cf(e){Ee.value=new Set(e)}function bs(e){jt("syncContextPinsToServer","/api/canvas/context-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nodeIds:Array.from(e)})})}var Ur=1;function pn(e){$t(()=>{let t=new Map(R.value);if(e.zIndex>=Ur)Ur=e.zIndex+1;t.set(e.id,e),R.value=t,Ce.value=e.id})}function rt(e,t){ws(e,t)}function ws(e,t,n={}){let o=R.value.get(e);if(!o)return;let r=new Map(R.value);if(o.type==="group"&&t.position&&n.skipGroupChildTranslation!==!0){let a=t.position.x-o.position.x,c=t.position.y-o.position.y;if(a!==0||c!==0){let l=Array.isArray(o.data.children)?o.data.children.filter((u)=>typeof u==="string"):[];for(let u of l){let d=r.get(u);if(!d||d.type==="group")continue;r.set(u,{...d,position:{x:d.position.x+a,y:d.position.y+c}})}}}r.set(e,{...o,...t}),R.value=r;let s=r.get(e)?.data.appCheckpoint?.updatedAt;if(Yt.value===e&&s!==void 0&&s!==Vo)Kc(e)}function re(e,t){let n=R.value.get(e);if(!n)return;rt(e,{data:{...n.data,...t}})}function Et(e){oS(e);let t=new Map(R.value);if(t.delete(e),R.value=t,Ce.value===e)Ce.value=null;if(Be.value===e)Be.value=null;if(xe.value.has(e)){let n=new Set(xe.value);n.delete(e),xe.value=n}if(Ee.value.has(e)){let n=new Set(Ee.value);n.delete(e),Ee.value=n,bs(n)}}function _s(e){let t=new Map(Re.value);t.set(e.id,e),Re.value=t}function Tf(e){let t=new Map(Re.value);t.delete(e),Re.value=t}function oS(e){let t=!1,n=new Map(Re.value);for(let[o,r]of n)if(r.from===e||r.to===e)n.delete(o),t=!0;if(t)Re.value=n}function rS(e){let t=new Map(Go.value);if(!t.delete(e))return;Go.value=t}async function nl(e){return kt("createAnnotationFromClient","/api/canvas/annotation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async function Ef(e){let t=await kt("removeAnnotationFromClient",`/api/canvas/annotation/${encodeURIComponent(e)}`,{method:"DELETE"});if(t.ok)rS(e);return t}function Jo(e,t){if(!R.value.get(e))return;rt(e,{size:t})}function fn(e){let t=R.value.get(e);if(!t)return;$t(()=>{if(rt(e,{zIndex:Ur++}),t.type==="group"&&Array.isArray(t.data.children)){for(let n of t.data.children)if(typeof n==="string"&&R.value.has(n))rt(n,{zIndex:Ur++})}}),Ce.value=e}function Yo(e){let t=R.value.get(e);if(!t)return;rt(e,{collapsed:!t.collapsed}),Je()}function Af(e){oe.value={...oe.value,...e}}function If(e){oe.value=e}function zf(e){Pf(e)}function Pf(e,t={}){oe.value=e,Je(t),Bp(e,t)}function Nf(e,t={}){let n=new Map,o=1;for(let p of e.nodes)if(n.set(p.id,p),p.zIndex>=o)o=p.zIndex+1;let r=e.edges.filter((p)=>n.has(p.from)&&n.has(p.to)),s=new Map;for(let p of r)s.set(p.id,p);let a=new Map;for(let p of e.annotations??[])a.set(p.id,p);let c=Ce.value!==null&&n.has(Ce.value)?Ce.value:null,l=Be.value!==null&&n.has(Be.value)?Be.value:null,u=df(xe.value,n),d=df(Ee.value,n);$t(()=>{if(t.applyViewport===!0&&e.viewport)oe.value=e.viewport;if(Ur=o,R.value=n,Re.value=s,Go.value=a,Ce.value=c,Be.value=l,!pf(xe.value,u))xe.value=u;if(!pf(Ee.value,d))Ee.value=d})}var Pn=null;function iS(e){return 1-(1-e)**3}function Qo(e,t=150){let n=oe.value,o=Math.min(4,Math.max(0.1,n.scale*e));if(o===n.scale)return;let r=o/n.scale,{x:s,y:a}=jo();$n({x:s-r*(s-n.x),y:a-r*(a-n.y),scale:o},t)}function $n(e,t=300,n={}){if(Pn!==null)cancelAnimationFrame(Pn);let o={...oe.value},r=performance.now();function s(a){let c=a-r,l=Math.min(1,c/t),u=iS(l);if(oe.value={x:o.x+(e.x-o.x)*u,y:o.y+(e.y-o.y)*u,scale:o.scale+(e.scale-o.scale)*u},l<1)Pn=requestAnimationFrame(s);else Pn=null,Pf(e,n)}Pn=requestAnimationFrame(s)}function er(){if(Pn!==null)cancelAnimationFrame(Pn),Pn=null}var Rf="pmx-canvas-layout";function Je(e={}){try{let t=Array.from(R.value.values()),n=t.map((r)=>({id:r.id,position:r.position,size:r.size,collapsed:r.collapsed})),o={viewport:oe.value,nodes:t.map((r)=>({id:r.id,type:r.type,position:r.position,size:r.size,collapsed:r.collapsed,pinned:r.pinned})),edges:Array.from(Re.value.values()).map((r)=>({id:r.id,from:r.from,to:r.to,type:r.type,label:r.label,style:r.style,animated:r.animated})),contextPinnedNodeIds:Array.from(Ee.value)};localStorage.setItem(Rf,JSON.stringify(o)),jp(n,e)}catch(t){mf("persistLayout",t)}}function ol(){try{let e=localStorage.getItem(Rf);if(!e)return null;let t=JSON.parse(e),n=Array.isArray(t.nodes)?t.nodes:[];if(n.length===0)return null;let o=new Map;for(let r of n){if(typeof r.id!=="string"||r.id.length===0)continue;o.set(r.id,{...r.position?{position:r.position}:{},...r.size?{size:r.size}:{},...r.collapsed!==void 0?{collapsed:r.collapsed}:{},...r.pinned!==void 0?{pinned:r.pinned}:{}})}return o.size>0?o:null}catch(e){return mf("restoreLayout",e),null}}function tr(e,t){let n=Array.from(R.value.values());if(n.length===0)return;let{POSITIVE_INFINITY:o,POSITIVE_INFINITY:r,NEGATIVE_INFINITY:s,NEGATIVE_INFINITY:a}=Number;for(let v of n)o=Math.min(o,v.position.x),r=Math.min(r,v.position.y),s=Math.max(s,v.position.x+v.size.width),a=Math.max(a,v.position.y+v.size.height);let c=Mc(),l=Math.max(80,e-c.left-c.right),u=Math.max(80,t-c.top-c.bottom),d=Math.max(1,s-o),p=Math.max(1,a-r),m=Math.min(1,Math.min(l/d,u/p)),f=(o+s)/2,y=(r+a)/2;$n({x:c.left+l/2-f*m,y:c.top+u/2-y*m,scale:m})}function et(e,t={}){let n=R.value.get(e);if(!n)return;let o=oe.value,r=bt(),s=Mc(),a=Math.max(80,r.width-s.left-s.right),c=Math.max(80,r.height-s.top-s.bottom),l=Math.min(o.scale,a/n.size.width,c/n.size.height),u=n.position.x+n.size.width/2,d=n.position.y+n.size.height/2;$n({x:s.left+a/2-u*l,y:s.top+c/2-d*l,scale:l},300,t),fn(e)}function $f(e=1){let t=Array.from(R.value.keys());if(t.length===0)return;let o=((Ce.value?t.indexOf(Ce.value):-1)+e+t.length)%t.length,r=t[o];fn(r),et(r)}function Mf(e){let t=Ce.value;if(!t)return;let n=R.value.get(t);if(!n)return;let o=hf(t,Re.value);if(o.size===0)return;let r=n.position.x+n.size.width/2,s=n.position.y+n.size.height/2,a=null,c=-1/0;for(let l of o){let u=R.value.get(l);if(!u)continue;let d=u.position.x+u.size.width/2,p=u.position.y+u.size.height/2,m=d-r,f=p-s,y=Math.sqrt(m*m+f*f);if(y<1)continue;let v;switch(e){case"up":v=-f;break;case"down":v=f;break;case"left":v=-m;break;case"right":v=m;break}if(v<=0)continue;let x=v/y-y*0.001;if(x>c)c=x,a=l}if(a)et(a)}function Qt(e){if(!R.value.get(e))return;if(Ct!==null)clearTimeout(Ct),Ct=null;Yt.value=null,Vo=void 0,fn(e),Be.value=e}function Kc(e){if(Ct!==null)clearTimeout(Ct),Ct=null;if(Be.value===e)Be.value=null;if(Yt.value===e)Yt.value=null;Vo=void 0}function fo(){let e=Be.value,t=e?R.value.get(e):void 0;if(e&&t&&Xp(t)){let n=e,o=Date.now();if(Yt.value=n,Vo=t.data.appCheckpoint?.updatedAt,Ct!==null)clearTimeout(Ct);let r=()=>{let a=R.value.get(n)?.data.appCheckpoint?.updatedAt;if(a!==void 0&&a!==Vo){Kc(n);return}if(Date.now()-o>=tS){Kc(n);return}Ct=setTimeout(r,uf)};Ct=setTimeout(r,uf);return}if(Ct!==null)clearTimeout(Ct),Ct=null;Yt.value=null,Vo=void 0,Be.value=null}function Ss(){let e=Gc(Array.from(R.value.values()),Array.from(Re.value.values()),"grid");if(e.nodePositions.size===0&&e.groupBounds.size===0)return;$t(()=>{for(let[t,n]of e.nodePositions.entries())rt(t,{position:n});for(let[t,n]of e.groupBounds.entries())ws(t,{position:{x:n.x,y:n.y},size:{width:n.width,height:n.height}},{skipGroupChildTranslation:!0})}),Je()}function ks(){let e=Gc(Array.from(R.value.values()),Array.from(Re.value.values()),"graph");if(e.nodePositions.size===0&&e.groupBounds.size===0)return;$t(()=>{for(let[t,n]of e.nodePositions.entries())rt(t,{position:n});for(let[t,n]of e.groupBounds.entries())ws(t,{position:{x:n.x,y:n.y},size:{width:n.width,height:n.height}},{skipGroupChildTranslation:!0})}),Je()}var Of="pmx-canvas-iframe-probe";var sS="/api/canvas/iframe-probe",aS=3000,ht=V(null);function cS(){let e=new URLSearchParams(window.location.search).get("iframe-mode");return e==="srcdoc"||e==="src"?e:null}function Lf(e=aS){return new Promise((t)=>{let n=document.createElement("iframe");n.setAttribute("data-pmx-iframe-probe",""),n.style.cssText="position:fixed;width:1px;height:1px;left:-9999px;border:none",n.setAttribute("sandbox","allow-scripts");let o=(a)=>{window.clearTimeout(s),window.removeEventListener("message",r),n.remove(),t(a)},r=(a)=>{if(a.source!==n.contentWindow)return;if(a.data?.source!==Of)return;o(!0)},s=window.setTimeout(()=>o(!1),e);window.addEventListener("message",r),n.addEventListener("error",()=>o(!1)),n.src=sS,(document.body??document.documentElement).appendChild(n)})}var Cs=null;function lS(){try{return window.self!==window.top}catch{return!0}}function uS(){return window.__PMX_AMP_ORB===!0}function Df(e={}){if(ht.value)return Promise.resolve(ht.value);if(Cs)return Cs;let t=cS();if(t)return ht.value=t,Promise.resolve(t);if(!(e.embedded??lS()))return ht.value="src",Lf(e.probeTimeoutMs).then((n)=>{if(!n&&ht.value==="src")ht.value="srcdoc"}),Promise.resolve("src");if(e.ampOrb??uS())return ht.value="srcdoc",Promise.resolve("srcdoc");return Cs=Lf(e.probeTimeoutMs).then((n)=>{let o=n?"src":"srcdoc";return ht.value=o,o}),Cs}function dS(e){let t=e.split(".").pop()?.toLowerCase()??"";return{ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",py:"Python",rs:"Rust",go:"Go",rb:"Ruby",java:"Java",kt:"Kotlin",swift:"Swift",c:"C",cpp:"C++",h:"C/C++",css:"CSS",html:"HTML",json:"JSON",yaml:"YAML",yml:"YAML",md:"Markdown",toml:"TOML",sql:"SQL",sh:"Shell",bash:"Shell",xml:"XML",graphql:"GraphQL",proto:"Protobuf"}[t]??(t.toUpperCase()||"Text")}var rl=500;function pS(e){let t=e.toLowerCase();if(t.endsWith(".csv"))return",";if(t.endsWith(".tsv"))return"\t";return null}function fS(e,t){let n=[],o=[],r="",s=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(a=!0,s){if(u==='"')if(e[l+1]==='"')r+='"',l++;else s=!1;else if(u==="\r"&&e[l+1]===`
|
|
37
|
+
`)r+=`
|
|
38
|
+
`,l++;else r+=u;continue}if(u==='"'&&r==="")s=!0;else if(u===t)o.push(r),r="";else if(u===`
|
|
39
|
+
`||u==="\r"){if(u==="\r"&&e[l+1]===`
|
|
40
|
+
`)l++;o.push(r),r="",n.push(o),o=[],a=!1}else r+=u}if(a)o.push(r),n.push(o);let c=n.shift()??[];return{header:c,rows:n.map((l)=>Array.from({length:c.length},(u,d)=>l[d]??""))}}function il(e){if(!Number.isFinite(e)||e<0)return"";if(e<1024)return`${Math.round(e)} B`;let t=["KB","MB","GB","TB"],n=e/1024,o=0;while(n>=1024&&o<t.length-1)n/=1024,o++;return`${n<10?n.toFixed(1):Math.round(n)} ${t[o]}`}function Ts({node:e,expanded:t=!1}){let n=e.data.path||e.data.content||"",o=e.data.title||n.split("/").pop()||"File",r=e.data.fileContent,s=e.data.updatedAt,a=e.data.lineCount,c=e.data.byteSize,l=e.data.binary===!0,u=e.data.truncated===!0,p=e.data.mimeType==="application/pdf"||n.toLowerCase().endsWith(".pdf"),m=l||p,[f,y]=L(r??""),[v,x]=L(!r&&!!n&&!m),[h,g]=L(null),[b,O]=L(0);D(()=>{if(!n)return;if(m){x(!1);return}if(r!==void 0){y(r),x(!1);return}let B=!1;return x(!0),g(null),Dr(n).then(({content:q})=>{if(B)return;if(!q&&q!==""){g("File not found"),x(!1);return}y(q),x(!1);let Y=q.split(`
|
|
41
|
+
`).length;re(e.id,{fileContent:q,lineCount:Y}),ft(e.id,{data:{fileContent:q,lineCount:Y}})}).catch(()=>{if(!B)g("Failed to load file"),x(!1)}),()=>{B=!0}},[n,r,m]),D(()=>{if(r!==void 0&&r!==f)y(r)},[r]);let F=M(()=>{if(!n)return;if(m){O((B)=>B+1);return}x(!0),g(null),re(e.id,{fileContent:void 0}),ft(e.id,{data:{fileContent:void 0}}),Dr(n).then(({content:B})=>{y(B),x(!1);let q=B.split(`
|
|
42
|
+
`).length,Y=new Date().toISOString();re(e.id,{fileContent:B,lineCount:q,updatedAt:Y}),ft(e.id,{data:{fileContent:B,lineCount:q,updatedAt:Y}})}).catch(()=>{g("Failed to reload"),x(!1)})},[n,e.id,m]),_=dS(n),k=f.split(`
|
|
43
|
+
`),T=`${String(k.length).length+1}ch`,P=pS(n),Z=Ie(()=>{if(!P||m||!f)return null;let B=fS(f,P);return B.header.length>=2?B:null},[f,P,m]),j=`/api/canvas/file-bytes?nodeId=${encodeURIComponent(e.id)}${b?`&v=${b}`:""}`,I=ht.value==="srcdoc",H=m||Z!==null,U=u?i("div",{class:"file-node-notice",children:["Showing the first ",il(f.length)," of ",il(c??f.length)]},void 0,!0,void 0,this):null;if(!n)return i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No file path set"},void 0,!1,void 0,this);return i("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"var(--mono)",fontSize:t?"13px":"11px"},children:[i("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",borderBottom:"1px solid var(--c-line)",flexShrink:0},children:[i("span",{style:{fontSize:"9px",padding:"1px 5px",background:"var(--c-accent-12)",color:"var(--c-accent)",borderRadius:"3px",fontWeight:600},children:_},void 0,!1,void 0,this),i("span",{style:{color:"var(--c-text-soft)",fontSize:t?"12px":"10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},title:n,children:n},void 0,!1,void 0,this),a!==void 0&&i("span",{style:{color:"var(--c-dim)",fontSize:"10px",flexShrink:0},children:[a," lines"]},void 0,!0,void 0,this),s&&i("span",{style:{color:"var(--c-dim)",fontSize:"10px",flexShrink:0},children:new Date(s).toLocaleTimeString()},void 0,!1,void 0,this),i("button",{type:"button",class:"ax-node-action",title:"Mark this file as AX evidence",onClick:(B)=>{B.stopPropagation(),zn(e,"ax.evidence.add",{kind:"file",title:n.split("/").pop()||n,ref:n},"Marked as evidence")},style:{background:"none",border:"none",color:"var(--c-muted)",cursor:"pointer",padding:"2px 4px",fontSize:"12px",flexShrink:0},children:"⊕"},void 0,!1,void 0,this),i("button",{type:"button",onClick:F,title:"Reload file",style:{background:"none",border:"none",color:"var(--c-muted)",cursor:"pointer",padding:"2px 4px",fontSize:"12px",flexShrink:0},children:"↻"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{style:{flex:1,minHeight:0,overflow:H?"hidden":"auto",padding:H?0:"8px 0",background:t?"var(--c-panel-soft)":void 0,borderRadius:t?"0 0 8px 8px":void 0},children:[p&&(I?i("div",{class:"file-node-placeholder",children:[i("div",{children:"PDF preview is unavailable in this embedded host."},void 0,!1,void 0,this),i("a",{class:"file-node-link",href:j,target:"_blank",rel:"noreferrer",children:"Open PDF"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i("iframe",{src:j,title:o,sandbox:"",style:{width:"100%",height:"100%",border:"none",display:"block"}},void 0,!1,void 0,this)),!p&&l&&i("div",{class:"file-node-placeholder",children:[i("div",{class:"file-node-placeholder-name",children:o},void 0,!1,void 0,this),i("div",{children:"Binary file"},void 0,!1,void 0,this),c!==void 0&&i("div",{children:il(c)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!m&&i(ye,{children:[v&&i("div",{style:{color:"var(--c-dim)",padding:"12px",fontStyle:"italic"},children:"Loading…"},void 0,!1,void 0,this),h&&i("div",{style:{color:"var(--c-danger)",padding:"12px"},children:h},void 0,!1,void 0,this),!v&&!h&&(Z?i("div",{class:"file-table-shell",children:[U,Z.rows.length>rl&&i("div",{class:"file-node-notice",children:["Showing ",rl," of ",Z.rows.length," rows"]},void 0,!0,void 0,this),i("div",{class:"file-table-wrap",children:i("table",{class:"file-table",children:[i("thead",{children:i("tr",{children:Z.header.map((B,q)=>i("th",{children:B},q,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("tbody",{children:Z.rows.slice(0,rl).map((B,q)=>i("tr",{children:B.map((Y,be)=>i("td",{children:Y},be,!1,void 0,this))},q,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i(ye,{children:[U,i("pre",{style:{margin:0,lineHeight:"1.55",tabSize:2},children:k.map((B,q)=>i("div",{style:{display:"flex",minHeight:"1.55em"},children:[i("span",{style:{width:T,minWidth:T,textAlign:"right",color:"var(--c-dim)",paddingRight:"12px",paddingLeft:"10px",userSelect:"none",flexShrink:0,opacity:0.6},children:q+1},void 0,!1,void 0,this),i("code",{style:{color:"var(--c-text)",whiteSpace:"pre",paddingRight:"10px"},children:B||`
|
|
44
|
+
`},void 0,!1,void 0,this)]},q,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this))]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var mS=new Set(["title","__type","content","strictSize","arrangeLocked"]);function Es({node:e}){let t=e.data,o=(typeof t.content==="string"?t.content:"").split(/\r\n|\r|\n|\\n/).map((s)=>s.trimEnd()).filter((s)=>s.length>0),r=Object.entries(t).filter(([s])=>!mS.has(s));if(o.length===0&&r.length===0)return i("div",{style:{color:"var(--c-dim)",fontSize:"12px",fontStyle:"italic"},children:"No ledger data"},void 0,!1,void 0,this);return i("div",{style:{display:"flex",flexDirection:"column",gap:"4px",fontSize:"12px"},children:[o.length>0&&i("div",{style:{display:"flex",flexDirection:"column"},children:o.map((s,a)=>i("div",{style:{padding:"3px 0",borderBottom:a<o.length-1?"1px solid rgba(45,55,90,0.3)":"none",color:"var(--c-text)",fontFamily:"var(--mono)",fontSize:"11px",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s},a,!1,void 0,this))},void 0,!1,void 0,this),r.map(([s,a])=>i("div",{style:{display:"flex",justifyContent:"space-between",gap:"8px",padding:"3px 0",borderBottom:"1px solid rgba(45,55,90,0.3)"},children:[i("span",{style:{color:"var(--c-muted)",fontSize:"11px",flexShrink:0},children:s.replace(/([A-Z])/g," $1").replace(/^./,(c)=>c.toUpperCase())},void 0,!1,void 0,this),i("span",{style:{color:"var(--c-text)",fontFamily:"var(--mono)",fontSize:"11px",textAlign:"right",wordBreak:"break-word"},children:typeof a==="object"?JSON.stringify(a):String(a??"—")},void 0,!1,void 0,this)]},s,!0,void 0,this))]},void 0,!0,void 0,this)}var qr=typeof navigator<"u"&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ff=qr?"⌘":"Ctrl";function Ze(e){return qr?`${Ff}${e}`:`${Ff}+${e}`}function As(e,t){let{selectionStart:n,selectionEnd:o,value:r}=e,s=r.slice(n,o),a=r.slice(Math.max(0,n-t.length),n),c=r.slice(o,o+t.length);if(a===t&&c===t){let l=r.slice(0,n-t.length)+s+r.slice(o+t.length);en(e,l,n-t.length,o-t.length);return}if(s){let l=r.slice(0,n)+t+s+t+r.slice(o);en(e,l,n+t.length,o+t.length)}else{let l=r.slice(0,n)+t+t+r.slice(o);en(e,l,n+t.length,n+t.length)}}function Vr(e,t){let{selectionStart:n,selectionEnd:o,value:r}=e,s=r.lastIndexOf(`
|
|
45
|
+
`,n-1)+1,a=r.indexOf(`
|
|
46
|
+
`,o),c=a===-1?r.length:a,l=r.slice(s,c);if(l.startsWith(t)){let d=r.slice(0,s)+l.slice(t.length)+r.slice(c);en(e,d,Math.max(s,n-t.length),Math.max(s,o-t.length));return}let u=r.slice(0,s)+t+r.slice(s);en(e,u,n+t.length,o+t.length)}function hS(e){let{selectionStart:t,selectionEnd:n,value:o}=e,r=o.slice(t,n);if(r){let s=o.slice(0,t)+`[${r}](url)`+o.slice(n),a=t+r.length+3;en(e,s,a,a+3)}else{let s=o.slice(0,t)+"[text](url)"+o.slice(n);en(e,s,t+1,t+5)}}function gS(e){let{selectionStart:t,selectionEnd:n,value:o}=e,r=o.slice(t,n),s="```";if(r){let a=o.slice(0,t)+`\`\`\`
|
|
47
|
+
${r}
|
|
48
|
+
\`\`\``+o.slice(n);en(e,a,t+3+1,t+3+1+r.length)}else{let a=o.slice(0,t)+"```\n\n```"+o.slice(n);en(e,a,t+3+1,t+3+1)}}function jf(e,t){let{selectionStart:n,selectionEnd:o,value:r}=e,s=r.lastIndexOf(`
|
|
49
|
+
`,n-1)+1,a=r.indexOf(`
|
|
50
|
+
`,o),c=a===-1?r.length:a,l=r.slice(s,c).split(`
|
|
51
|
+
`),u=n,d=o,p=l.map((f,y)=>{if(t){if(f.startsWith(" ")){if(y===0)u=Math.max(s,u-2);return d-=2,f.slice(2)}else if(f.startsWith("\t")){if(y===0)u=Math.max(s,u-1);return d-=1,f.slice(1)}return f}else{if(y===0)u+=2;return d+=2," "+f}}),m=r.slice(0,s)+p.join(`
|
|
52
|
+
`)+r.slice(c);en(e,m,u,d)}function en(e,t,n,o){let r=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set;if(r)r.call(e,t);else e.value=t;e.selectionStart=n,e.selectionEnd=o,e.dispatchEvent(new Event("input",{bubbles:!0}))}var Is=[{key:"bold",label:"Bold",icon:"B",shortcut:"b",action:(e)=>As(e,"**")},{key:"italic",label:"Italic",icon:"I",shortcut:"i",action:(e)=>As(e,"_")},{key:"strike",label:"Strikethrough",icon:"S",shortcut:"u",action:(e)=>As(e,"~~")},{key:"code",label:"Inline code",icon:"`",shortcut:"e",action:(e)=>As(e,"`")},{key:"link",label:"Link",icon:"\uD83D\uDD17",shortcut:"k",action:hS},{key:"h1",label:"Heading 1",icon:"H1",action:(e)=>Vr(e,"# ")},{key:"h2",label:"Heading 2",icon:"H2",action:(e)=>Vr(e,"## ")},{key:"quote",label:"Blockquote",icon:"❝",action:(e)=>Vr(e,"> ")},{key:"ul",label:"Bullet list",icon:"•",action:(e)=>Vr(e,"- ")},{key:"ol",label:"Numbered list",icon:"1.",action:(e)=>Vr(e,"1. ")},{key:"codeblock",label:"Code block",icon:"{ }",action:gS}];function Zf(e,t){if(!(e.metaKey||e.ctrlKey))return!1;let n=Is.find((o)=>o.shortcut===e.key);if(!n)return!1;return e.preventDefault(),n.action(t),!0}function Hf(e){if(e.selectionStart===e.selectionEnd)return null;let t=document.createElement("div"),n=getComputedStyle(e),o=["fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","wordSpacing","textIndent","whiteSpace","wordWrap","overflowWrap","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing","width"];for(let d of o)t.style[d]=n[d];t.style.position="absolute",t.style.visibility="hidden",t.style.overflow="hidden",t.style.height="auto",t.style.top="0",t.style.left="0";let r=e.value,s=document.createTextNode(r.slice(0,e.selectionStart)),a=document.createElement("span");a.textContent=r.slice(e.selectionStart,e.selectionEnd)||".",t.appendChild(s),t.appendChild(a),t.appendChild(document.createTextNode(r.slice(e.selectionEnd))),document.body.appendChild(t);let c=a.getBoundingClientRect(),l=t.getBoundingClientRect(),u=e.getBoundingClientRect();return document.body.removeChild(t),{top:u.top+(c.top-l.top)-e.scrollTop,left:u.left+(c.left-l.left)-e.scrollLeft,width:c.width}}var vS=Is.filter((e)=>e.shortcut),yS=Is.filter((e)=>!e.shortcut);function sl({textareaRef:e}){let[t,n]=L(!1),[o,r]=L({top:0,left:0}),s=N(null),a=N(null),c=M(()=>{let u=e.current;if(!u||u.selectionStart===u.selectionEnd){n(!1);return}let d=Hf(u);if(!d){n(!1);return}let p=380,m=Math.max(8,Math.min(d.left+d.width/2-p/2,window.innerWidth-p-8));r({top:d.top-40,left:m}),n(!0)},[e]);D(()=>{let u=e.current;if(!u)return;let d=()=>{if(a.current)clearTimeout(a.current);a.current=setTimeout(c,50)},p=()=>{a.current=setTimeout(()=>n(!1),200)},m=(f)=>{if(f.shiftKey||f.key.startsWith("Arrow"))d()};return u.addEventListener("select",d),u.addEventListener("mouseup",d),u.addEventListener("keyup",m),u.addEventListener("blur",p),()=>{if(u.removeEventListener("select",d),u.removeEventListener("mouseup",d),u.removeEventListener("keyup",m),u.removeEventListener("blur",p),a.current)clearTimeout(a.current)}},[e,c]);let l=M((u)=>{let d=e.current;if(d)u.action(d),d.focus()},[e]);if(!t)return null;return i("div",{ref:s,class:"md-format-bar",style:{top:`${o.top}px`,left:`${o.left}px`},onMouseDown:(u)=>u.preventDefault(),children:[vS.map((u)=>i("button",{type:"button",class:`md-format-btn md-format-btn-${u.key}`,title:`${u.label} (${Ze(u.shortcut.toUpperCase())})`,onClick:()=>l(u),children:u.icon},u.key,!1,void 0,this)),i("div",{class:"md-format-divider"},void 0,!1,void 0,this),yS.map((u)=>i("button",{type:"button",class:`md-format-btn md-format-btn-${u.key}`,title:u.label,onClick:()=>l(u),children:u.icon},u.key,!1,void 0,this))]},void 0,!0,void 0,this)}var bm=Hw(rm(),1);function $S(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o))e[o]=n[o]}return e}function fl(e,t){return Array(t+1).join(e)}function am(e){return e.replace(/^\n*/,"")}function cm(e){var t=e.length;while(t>0&&e[t-1]===`
|
|
53
|
+
`)t--;return e.substring(0,t)}function lm(e){return cm(am(e))}var MS=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function ml(e){return hl(e,MS)}var um=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function dm(e){return hl(e,um)}function OS(e){return fm(e,um)}var pm=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function LS(e){return hl(e,pm)}function DS(e){return fm(e,pm)}function hl(e,t){return t.indexOf(e.nodeName)>=0}function fm(e,t){return e.getElementsByTagName&&t.some(function(n){return e.getElementsByTagName(n).length})}var FS=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function mm(e){return FS.reduce(function(t,n){return t.replace(n[0],n[1])},e)}var gt={};gt.paragraph={filter:"p",replacement:function(e){return`
|
|
54
|
+
|
|
55
|
+
`+e+`
|
|
56
|
+
|
|
57
|
+
`}};gt.lineBreak={filter:"br",replacement:function(e,t,n){return n.br+`
|
|
58
|
+
`}};gt.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,n){var o=Number(t.nodeName.charAt(1));if(n.headingStyle==="setext"&&o<3){var r=fl(o===1?"=":"-",e.length);return`
|
|
59
|
+
|
|
60
|
+
`+e+`
|
|
61
|
+
`+r+`
|
|
62
62
|
|
|
63
63
|
`}else return`
|
|
64
64
|
|
|
65
|
-
`+
|
|
65
|
+
`+fl("#",o)+" "+e+`
|
|
66
66
|
|
|
67
|
-
`}};
|
|
67
|
+
`}};gt.blockquote={filter:"blockquote",replacement:function(e){return e=lm(e).replace(/^/gm,"> "),`
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
`+e+`
|
|
70
70
|
|
|
71
|
-
`}};
|
|
72
|
-
|
|
71
|
+
`}};gt.list={filter:["ul","ol"],replacement:function(e,t){var n=t.parentNode;if(n.nodeName==="LI"&&n.lastElementChild===t)return`
|
|
72
|
+
`+e;else return`
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
`+e+`
|
|
75
75
|
|
|
76
|
-
`}};
|
|
77
|
-
`:"")
|
|
78
|
-
`+" ".repeat(
|
|
79
|
-
`:"")}};
|
|
76
|
+
`}};gt.listItem={filter:"li",replacement:function(e,t,n){var o=n.bulletListMarker+" ",r=t.parentNode;if(r.nodeName==="OL"){var s=r.getAttribute("start"),a=Array.prototype.indexOf.call(r.children,t);o=(s?Number(s)+a:a+1)+". "}var c=/\n$/.test(e);return e=lm(e)+(c?`
|
|
77
|
+
`:""),e=e.replace(/\n/gm,`
|
|
78
|
+
`+" ".repeat(o.length)),o+e+(t.nextSibling?`
|
|
79
|
+
`:"")}};gt.indentedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="indented"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,n){return`
|
|
80
80
|
|
|
81
|
-
`+
|
|
81
|
+
`+t.firstChild.textContent.replace(/\n/g,`
|
|
82
82
|
`)+`
|
|
83
83
|
|
|
84
|
-
`}};
|
|
84
|
+
`}};gt.fencedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="fenced"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,n){var o=t.firstChild.getAttribute("class")||"",r=(o.match(/language-(\S+)/)||[null,""])[1],s=t.firstChild.textContent,a=n.fence.charAt(0),c=3,l=new RegExp("^"+a+"{3,}","gm"),u;while(u=l.exec(s))if(u[0].length>=c)c=u[0].length+1;var d=fl(a,c);return`
|
|
85
85
|
|
|
86
|
-
`+
|
|
87
|
-
`+
|
|
88
|
-
`+
|
|
86
|
+
`+d+r+`
|
|
87
|
+
`+s.replace(/\n$/,"")+`
|
|
88
|
+
`+d+`
|
|
89
89
|
|
|
90
|
-
`}};
|
|
90
|
+
`}};gt.horizontalRule={filter:"hr",replacement:function(e,t,n){return`
|
|
91
91
|
|
|
92
|
-
`+
|
|
92
|
+
`+n.hr+`
|
|
93
93
|
|
|
94
|
-
`}};
|
|
94
|
+
`}};gt.inlineLink={filter:function(e,t){return t.linkStyle==="inlined"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t){var n=gl(t.getAttribute("href")),o=vl(zs(t.getAttribute("title"))),r=o?' "'+o+'"':"";return"["+e+"]("+n+r+")"}};gt.referenceLink={filter:function(e,t){return t.linkStyle==="referenced"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t,n){var o=gl(t.getAttribute("href")),r=zs(t.getAttribute("title"));if(r)r=' "'+vl(r)+'"';var s,a;switch(n.linkReferenceStyle){case"collapsed":s="["+e+"][]",a="["+e+"]: "+o+r;break;case"shortcut":s="["+e+"]",a="["+e+"]: "+o+r;break;default:var c=this.references.length+1;s="["+e+"]["+c+"]",a="["+c+"]: "+o+r}return this.references.push(a),s},references:[],append:function(e){var t="";if(this.references.length)t=`
|
|
95
95
|
|
|
96
96
|
`+this.references.join(`
|
|
97
97
|
`)+`
|
|
98
98
|
|
|
99
|
-
`,this.references=[];return
|
|
100
|
-
`):""}function
|
|
99
|
+
`,this.references=[];return t}};gt.emphasis={filter:["em","i"],replacement:function(e,t,n){if(!e.trim())return"";return n.emDelimiter+e+n.emDelimiter}};gt.strong={filter:["strong","b"],replacement:function(e,t,n){if(!e.trim())return"";return n.strongDelimiter+e+n.strongDelimiter}};gt.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n=e.parentNode.nodeName==="PRE"&&!t;return e.nodeName==="CODE"&&!n},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",n="`",o=e.match(/`+/gm)||[];while(o.indexOf(n)!==-1)n=n+"`";return n+t+e+t+n}};gt.image={filter:"img",replacement:function(e,t){var n=mm(zs(t.getAttribute("alt"))),o=gl(t.getAttribute("src")||""),r=zs(t.getAttribute("title")),s=r?' "'+vl(r)+'"':"";return o?"":""}};function zs(e){return e?e.replace(/(\n+\s*)+/g,`
|
|
100
|
+
`):""}function gl(e){var t=e.replace(/([<>()])/g,"\\$1");return t.indexOf(" ")>=0?"<"+t+">":t}function vl(e){return e.replace(/"/g,"\\\"")}function hm(e){this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[];for(var t in e.rules)this.array.push(e.rules[t])}hm.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){if(e.isBlank)return this.blankRule;var t;if(t=ul(this.array,e,this.options))return t;if(t=ul(this._keep,e,this.options))return t;if(t=ul(this._remove,e,this.options))return t;return this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};function ul(e,t,n){for(var o=0;o<e.length;o++){var r=e[o];if(jS(r,t,n))return r}return}function jS(e,t,n){var o=e.filter;if(typeof o==="string"){if(o===t.nodeName.toLowerCase())return!0}else if(Array.isArray(o)){if(o.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if(typeof o==="function"){if(o.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}function ZS(e){var{element:t,isBlock:n,isVoid:o}=e,r=e.isPre||function(p){return p.nodeName==="PRE"};if(!t.firstChild||r(t))return;var s=null,a=!1,c=null,l=im(c,t,r);while(l!==t){if(l.nodeType===3||l.nodeType===4){var u=l.data.replace(/[ \r\n\t]+/g," ");if((!s||/ $/.test(s.data))&&!a&&u[0]===" ")u=u.substr(1);if(!u){l=dl(l);continue}l.data=u,s=l}else if(l.nodeType===1){if(n(l)||l.nodeName==="BR"){if(s)s.data=s.data.replace(/ $/,"");s=null,a=!1}else if(o(l)||r(l))s=null,a=!0;else if(s)a=!1}else{l=dl(l);continue}var d=im(c,l,r);c=l,l=d}if(s){if(s.data=s.data.replace(/ $/,""),!s.data)dl(s)}}function dl(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function im(e,t,n){if(e&&e.parentNode===t||n(t))return t.nextSibling||t.parentNode;return t.firstChild||t.nextSibling||t.parentNode}var yl=typeof window<"u"?window:{};function HS(){var e=yl.DOMParser,t=!1;try{if(new e().parseFromString("","text/html"))t=!0}catch(n){}return t}function BS(){var e=function(){};if(US())e.prototype.parseFromString=function(t){var n=new window.ActiveXObject("htmlfile");return n.designMode="on",n.open(),n.write(t),n.close(),n};else e.prototype.parseFromString=function(t){var n=document.implementation.createHTMLDocument("");return n.open(),n.write(t),n.close(),n};return e}function US(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){if(yl.ActiveXObject)e=!0}return e}var WS=HS()?yl.DOMParser:BS();function qS(e,t){var n;if(typeof e==="string"){var o=VS().parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html");n=o.getElementById("turndown-root")}else n=e.cloneNode(!0);return ZS({element:n,isBlock:ml,isVoid:dm,isPre:t.preformattedCode?GS:null}),n}var pl;function VS(){return pl=pl||new WS,pl}function GS(e){return e.nodeName==="PRE"||e.nodeName==="CODE"}function XS(e,t){return e.isBlock=ml(e),e.isCode=e.nodeName==="CODE"||e.parentNode.isCode,e.isBlank=KS(e),e.flankingWhitespace=JS(e,t),e}function KS(e){return!dm(e)&&!LS(e)&&/^\s*$/i.test(e.textContent)&&!OS(e)&&!DS(e)}function JS(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var n=YS(e.textContent);if(n.leadingAscii&&sm("left",e,t))n.leading=n.leadingNonAscii;if(n.trailingAscii&&sm("right",e,t))n.trailing=n.trailingNonAscii;return{leading:n.leading,trailing:n.trailing}}function YS(e){var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}}function sm(e,t,n){var o,r,s;if(e==="left")o=t.previousSibling,r=/ $/;else o=t.nextSibling,r=/^ /;if(o){if(o.nodeType===3)s=r.test(o.nodeValue);else if(n.preformattedCode&&o.nodeName==="CODE")s=!1;else if(o.nodeType===1&&!ml(o))s=r.test(o.textContent)}return s}var QS=Array.prototype.reduce;function Gr(e){if(!(this instanceof Gr))return new Gr(e);var t={rules:gt,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(n,o){return o.isBlock?`
|
|
101
101
|
|
|
102
|
-
`:""},keepReplacement:function(
|
|
102
|
+
`:""},keepReplacement:function(n,o){return o.isBlock?`
|
|
103
103
|
|
|
104
|
-
`+
|
|
104
|
+
`+o.outerHTML+`
|
|
105
105
|
|
|
106
|
-
`:
|
|
106
|
+
`:o.outerHTML},defaultReplacement:function(n,o){return o.isBlock?`
|
|
107
107
|
|
|
108
|
-
`+
|
|
108
|
+
`+n+`
|
|
109
109
|
|
|
110
|
-
`:
|
|
110
|
+
`:n}};this.options=$S({},t,e),this.rules=new hm(this.options)}Gr.prototype={turndown:function(e){if(!nk(e))throw TypeError(e+" is not a string, or an element/document/fragment node.");if(e==="")return"";var t=gm.call(this,new qS(e,this.options));return ek.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if(typeof e==="function")e(this);else throw TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return mm(e)}};function gm(e){var t=this;return QS.call(e.childNodes,function(n,o){o=new XS(o,t.options);var r="";if(o.nodeType===3)r=o.isCode?o.nodeValue:t.escape(o.nodeValue);else if(o.nodeType===1)r=tk.call(t,o);return vm(n,r)},"")}function ek(e){var t=this;return this.rules.forEach(function(n){if(typeof n.append==="function")e=vm(e,n.append(t.options))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function tk(e){var t=this.rules.forNode(e),n=gm.call(this,e),o=e.flankingWhitespace;if(o.leading||o.trailing)n=n.trim();return o.leading+t.replacement(n,e,this.options)+o.trailing}function vm(e,t){var n=cm(e),o=am(t),r=Math.max(e.length-n.length,t.length-o.length),s=`
|
|
111
111
|
|
|
112
|
-
`.substring(0,_);return v+z+J}function cP($){return $!=null&&(typeof $==="string"||$.nodeType&&($.nodeType===1||$.nodeType===9||$.nodeType===11))}function Bv(){let $=window.getSelection(),U=$&&$.rangeCount>0?$.getRangeAt(0).cloneRange():null;S4("Link URL","https://example.com").then((v)=>{if(!v)return;let J=v.trim().toLowerCase();if(J.startsWith("javascript:")||J.startsWith("data:"))return;if(U){let _=window.getSelection();_?.removeAllRanges(),_?.addRange(U)}document.execCommand("createLink",!1,v)})}function sZ(){let $=window.getSelection();if(!$||$.rangeCount===0)return;let U=$.getRangeAt(0);if(U.collapsed)return;let v=U.toString(),J=document.createElement("code");J.textContent=v,U.deleteContents(),U.insertNode(J);let _=document.createRange();_.setStartAfter(J),_.setEndAfter(J),$.removeAllRanges(),$.addRange(_)}var Xv=8,lP=[{kind:"exec",command:"bold",icon:"B",title:`Bold (${d$("B")})`},{kind:"exec",command:"italic",icon:"I",title:`Italic (${d$("I")})`},{kind:"exec",command:"strikeThrough",icon:"S",title:"Strikethrough"},{kind:"code",icon:"{ }",title:"Inline code",dividerBefore:!0},{kind:"block",tag:"H1",icon:"H1",title:"Heading 1",dividerBefore:!0},{kind:"block",tag:"H2",icon:"H2",title:"Heading 2"},{kind:"block",tag:"H3",icon:"H3",title:"Heading 3"},{kind:"block",tag:"P",icon:"¶",title:"Paragraph"},{kind:"block",tag:"BLOCKQUOTE",icon:"❝",title:"Quote",dividerBefore:!0},{kind:"exec",command:"insertUnorderedList",icon:"•",title:"Bullet list"},{kind:"exec",command:"insertOrderedList",icon:"1.",title:"Numbered list"},{kind:"link",icon:"\uD83D\uDD17",title:`Link (${d$("K")})`,dividerBefore:!0}];function rP($){switch($.kind){case"exec":document.execCommand($.command);return;case"block":document.execCommand("formatBlock",!1,$.tag);return;case"code":sZ();return;case"link":Bv();return}}function eZ({hostRef:$,onChange:U}){let[v,J]=f(!1),[_,z]=f({top:0,left:0}),[K,W]=f(0),O=C(null),Y=C(null),Z=j(()=>{let B=$.current;if(!B){J(!1);return}let L=window.getSelection();if(!L||L.rangeCount===0||L.isCollapsed){J(!1);return}let F=L.getRangeAt(0);if(!B.contains(F.commonAncestorContainer)){J(!1);return}let k=F.getBoundingClientRect();if(k.width===0&&k.height===0){J(!1);return}let H=K||420,P=Math.max(Xv,Math.min(k.left+k.width/2-H/2,window.innerWidth-H-Xv)),b=Math.max(Xv,k.top-Xv-36);z({top:b,left:P}),J(!0)},[$,K]),q=j(()=>{if(Y.current!==null)return;Y.current=requestAnimationFrame(()=>{Y.current=null,Z()})},[Z]);u(()=>{return document.addEventListener("selectionchange",q),window.addEventListener("scroll",q,!0),window.addEventListener("resize",q),()=>{if(document.removeEventListener("selectionchange",q),window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q),Y.current!==null)cancelAnimationFrame(Y.current)}},[q]),g2(()=>{if(!v)return;let B=O.current;if(!B)return;let L=B.getBoundingClientRect().width;if(L&&Math.abs(L-K)>1)W(L)},[v,K]);let X=j((B)=>{rP(B),U(),Z()},[U,Z]);if(!v)return null;return G("div",{ref:O,class:"md-inline-format-bar",style:{top:`${_.top}px`,left:`${_.left}px`},onMouseDown:(B)=>B.preventDefault(),children:lP.flatMap((B,L)=>{let F=G("button",{type:"button",class:"md-inline-format-btn",title:B.title,onClick:()=>X(B),children:B.icon},`btn-${L}`,!1,void 0,this);return B.dividerBefore?[G("span",{class:"md-inline-format-divider"},`div-${L}`,!1,void 0,this),F]:[F]})},void 0,!1,void 0,this)}var G5=null;function iP(){if(G5)return G5;let $=new a0({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*",bulletListMarker:"-"});return $.use($q.gfm),G5=$,$}function Uq({initialHtml:$,className:U,onChange:v,onSave:J}){let _=C(null),z=C($);u(()=>{let X=_.current;if(!X)return;X.innerHTML=z.current;for(let B of X.querySelectorAll('input[type="checkbox"][disabled]'))B.removeAttribute("disabled")},[]);let K=j(()=>{let X=_.current;if(!X)return"";return iP().turndown(X.innerHTML)},[]),W=j(()=>{v(K())},[v,K]),O=j(()=>{let X=_.current;if(!X||!X.isConnected||X.innerHTML==="")return;J?.(K())},[J,K]),Y=j((X)=>{if(!(X.metaKey||X.ctrlKey))return;if(X.key==="s"){X.preventDefault(),O();return}if(X.key==="b"){X.preventDefault(),document.execCommand("bold"),W();return}if(X.key==="i"){X.preventDefault(),document.execCommand("italic"),W();return}if(X.key==="k")X.preventDefault(),Bv(),W()},[W,O]),Z=j((X)=>{let B=X.target;if(B instanceof HTMLInputElement&&B.type==="checkbox")B.toggleAttribute("checked",B.checked),W()},[W]),q=j((X)=>{let B=X.clipboardData?.getData("text/plain");if(B==null)return;X.preventDefault(),document.execCommand("insertText",!1,B),W()},[W]);return G(A$,{children:[G("div",{ref:_,class:U,contentEditable:!0,spellcheck:!1,onInput:W,onKeyDown:Y,onPaste:q,onClick:Z,onBlur:O},void 0,!1,void 0,this),G(eZ,{hostRef:_,onChange:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function W5({html:$,className:U,style:v,onTaskToggle:J}){let _=C(null),z=C(J);return z.current=J,u(()=>{let W=_.current;if(!W)return;if(W.replaceChildren(),!$)return;let O=document.createElement("template");if(O.innerHTML=$,W.append(O.content.cloneNode(!0)),z.current)for(let Y of W.querySelectorAll('input[type="checkbox"][disabled]'))Y.removeAttribute("disabled")},[$]),G("div",{ref:_,class:U,style:v,onClick:J?(W)=>{let O=z.current,Y=_.current;if(!Y||!O)return;let Z=W.target,q=null;if(Z instanceof HTMLInputElement&&Z.type==="checkbox")q=Z;else{let L=Z.closest("li")?.querySelector(':scope > input[type="checkbox"]');if(L&&W.clientX<=L.getBoundingClientRect().right+6)q=L}if(!q)return;W.stopPropagation();let X=[...Y.querySelectorAll('input[type="checkbox"]')].indexOf(q);if(X>=0)O(X)}:void 0},void 0,!1,void 0,this)}function pP($,U){let v=-1;return $.replace(/^(\s*(?:[-*+]|\d+[.)])\s+\[)([ xX])(\])/gm,(J,_,z,K)=>{if(v+=1,v!==U)return J;return`${_}${z===" "?"x":" "}${K}`})}function Hv({node:$,expanded:U=!1}){let v=$.data.path,[J,_]=f(""),[z,K]=f(""),[W,O]=f(!1),[Y,Z]=f(!1),[q,X]=f(!1),[B,L]=f(!1),F=C(null),k=C(null),H=C(""),P=C(null),b=$.data.reviewActive;u(()=>{let l=!1;return(async()=>{let T;if(v){let t=await h0(v);if(l)return;T=t.content}else if($.data.content)T=$.data.content;else{O(!0);return}_(T);let r=await R4(T);if(l)return;K(r),O(!0),W$($.id,{content:T,rendered:r})})(),()=>{l=!0}},[v,$.id,$.data.content]);let V=j(async(l)=>{let T=l.target.value;_(T),L(!0);let r=await R4(T);K(r)},[]),E=j(async(l)=>{if(!v){let r=await R4(l);K(r),L(!1),W$($.id,{content:l,rendered:r}),await A6($.id,{content:l,data:{rendered:r}});return}X(!0);let T=await FY(v,l);if(X(!1),T.ok){let r=await R4(l);K(r),L(!1),W$($.id,{content:l,rendered:r,savedAt:T.updatedAt}),await A6($.id,{content:l,data:{rendered:r,savedAt:T.updatedAt}})}},[v,$.id]),A=j(async()=>{if(!B)return;await E(J)},[B,J,E]),I=j((l)=>{if((l.metaKey||l.ctrlKey)&&l.key==="s"){l.preventDefault(),A();return}let T=F.current;if(T&&bZ(l,T))return;if(T&&l.key==="Tab")l.preventDefault(),kZ(T,l.shiftKey)},[A]);P.current=E;let N=j((l)=>{if(_(l),L(!0),H.current=l,k.current!==null)window.clearTimeout(k.current);k.current=window.setTimeout(()=>{k.current=null,E(l)},800)},[E]),R=j((l)=>{if(_(l),H.current=l,k.current!==null)window.clearTimeout(k.current),k.current=null;E(l)},[E]);u(()=>{return()=>{if(k.current===null)return;window.clearTimeout(k.current),k.current=null;let l=P.current;if(l)l(H.current)}},[$.id]);let p=b?G("div",{style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-ok-10)",color:"var(--c-ok)",borderBottom:"1px solid var(--c-ok-20)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600},children:"Review active"},void 0,!1,void 0,this):null;if(Y&&U)return G("div",{class:"md-editor-expanded",onKeyDown:I,children:[G("div",{class:"md-editor-toolbar",children:[G("button",{type:"button",class:"md-toolbar-btn",onClick:()=>Z(!1),children:"← Back to document"},void 0,!1,void 0,this),G("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[v&&G("span",{class:"md-toolbar-path",children:v.split("/").pop()},void 0,!1,void 0,this),G("button",{type:"button",class:`md-toolbar-btn${B?" md-toolbar-btn-primary":""}`,onClick:A,disabled:!B||q,children:q?"Saving…":B?"Save":"Saved"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"md-editor-split",children:[G("div",{style:{flex:1,position:"relative",display:"flex",flexDirection:"column"},children:[G("textarea",{ref:F,value:J,onInput:V,spellcheck:!1},void 0,!1,void 0,this),G(d8,{textareaRef:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(W5,{html:z,className:"md-preview"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(Y)return G("div",{class:"md-editor-split",style:{height:"100%"},onKeyDown:I,children:[G("div",{style:{flex:1,position:"relative",display:"flex",flexDirection:"column"},children:[G("textarea",{ref:F,value:J,onInput:V,spellcheck:!1},void 0,!1,void 0,this),G(d8,{textareaRef:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(W5,{html:z,className:"md-preview"},void 0,!1,void 0,this),G("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[G("button",{type:"button",onClick:()=>Z(!1),style:{padding:"4px 10px",fontSize:"11px",background:"var(--c-input-bg)",border:"1px solid var(--c-line)",borderRadius:"6px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Document"},void 0,!1,void 0,this),G("button",{type:"button",onClick:A,disabled:!B||q,style:{padding:"4px 10px",fontSize:"11px",background:B?"var(--c-accent-25)":"var(--c-input-bg)",border:`1px solid ${B?"var(--c-accent)":"var(--c-line)"}`,borderRadius:"6px",color:B?"var(--c-text)":"var(--c-dim)",cursor:B?"pointer":"default"},children:q?"Saving…":B?"Save":"Saved"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(U)return G("div",{style:{height:"100%",position:"relative"},children:[p,G("div",{class:"md-reader",children:W?G(Uq,{initialHtml:z||"<p><br></p>",className:"md-reader-content md-reader-editable",onChange:N,onSave:R},$.id,!1,void 0,this):G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"24px"},children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("button",{type:"button",class:"md-edit-fab",onClick:()=>Z(!0),children:"</> Source"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("div",{style:{height:"100%",position:"relative"},children:[p,G(W5,{html:z,style:{padding:z?"0":"12px",color:z?void 0:"var(--c-dim)"},onTaskToggle:(l)=>{let T=pP(J,l);if(T!==J)R(T)}},void 0,!1,void 0,this),!W&&G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"Loading…"},void 0,!1,void 0,this),W&&!z&&G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"Empty node"},void 0,!1,void 0,this),G("button",{type:"button",class:"md-edit-btn",onClick:()=>Q4($.id),children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Qv="pmx-canvas-ax",Lv="pmx-canvas-ax-ack",t6="pmx-canvas-html-node",Fv="pmx-canvas-ext-app-alive",O5="pmx-canvas-ext-app-paint-probe";function _q($,U){switch($){case"html":return typeof U.html==="string"&&U.html.length>0||typeof U.content==="string"&&U.content.length>0;case"mermaid":return typeof U.content==="string"&&U.content.trim().length>0;case"json-render":case"graph":return!0;case"mcp-app":return U.viewerType==="web-artifact"&&typeof U.path==="string"&&U.path.length>0||typeof U.url==="string"&&U.url.length>0;case"webpage":return typeof U.url==="string"&&U.url.length>0;default:return!1}}var Y5="allow-scripts allow-popups allow-popups-to-escape-sandbox";function RU($){let U=5381;for(let v=0;v<$.length;v+=1)U=(U<<5)+U+$.charCodeAt(v)|0;return(U>>>0).toString(36)}function s0($,U={}){let v=new URLSearchParams;if(v.set("theme",U.theme??$6.value),U.themeToken)v.set("themeToken",U.themeToken);if(U.present)v.set("present","1");if(U.presentToken)v.set("presentToken",U.presentToken);if(U.v)v.set("v",U.v);if(U.axToken)v.set("axToken",U.axToken);if(U.frameToken)v.set("frameToken",U.frameToken);return`/api/canvas/surface/${encodeURIComponent($)}?${v.toString()}`}function Pv($){return _q($.type,$.data)}async function kv($){let U=s0($.id);if(!(await AY($.id,U)).opened)window.open(U,"_blank","noopener")}var oP={markdown:{width:360,height:180},context:{width:360,height:180},file:{width:360,height:200},diff:{width:420,height:240},mermaid:{width:360,height:240},status:{width:280,height:120},ledger:{width:320,height:200},image:{width:240,height:180},html:{width:420,height:280},webpage:{width:420,height:280},"json-render":{width:420,height:280},graph:{width:420,height:280},"mcp-app":{width:480,height:320}};function vq($){return oP[$]}var TU=37,dP=600,nP=1400,tP=24;function aP($){return $.type==="html"||$.type==="mermaid"||$.type==="json-render"||$.type==="graph"||$.type==="mcp-app"||$.type==="webpage"}function sP($){if($.type==="html")return $.data.presentation!==!0;if($.type==="mermaid")return!0;if($.type==="json-render"||$.type==="graph")return!0;if($.type==="mcp-app")return $.data.viewerType==="web-artifact";return!1}function Jq($){return $.collapsed===!0||$.data.strictSize===!0||$.data.userResized===!0||$.type==="group"}function Z5($){return!Jq($)&&!aP($)}function zq($,U){if(!Z5($)||U<=0)return null;let v=Math.min(U+TU,dP),J=vq($.type);return J?Math.max(v,J.height):v}function q5($){return sP($)&&!Jq($)}function Kq($,U){if(!q5($)||U<=0)return null;let v=Math.min(U+TU+tP,nP);return v>$.size.height+8?v:null}function yU($,U,v){let J=C($);J.current=$;let _=C(null);u(()=>{if(!v)return;function z(K){if(K.source!==U.current?.contentWindow)return;let W=K.data;if(!W||W.source!=="pmx-canvas-frame"||W.type!=="content-height"||W.token!==v)return;let O=J.current,Y=typeof W.height==="number"?W.height:0,Z=Kq(O,Y);if(Z===null)return;if(IU(O.id,{width:O.size.width,height:Z}),_.current!==null)window.clearTimeout(_.current);_.current=window.setTimeout(()=>{v6({recordHistory:!1}),_.current=null},300)}return window.addEventListener("message",z),()=>{if(window.removeEventListener("message",z),_.current!==null)window.clearTimeout(_.current),_.current=null}},[$.id,v])}function eP($){try{return new URL($,window.location.origin).origin===window.location.origin}catch{return!1}}function CU($){let U=w6.value,[v,J]=f(null),_=Boolean($)&&eP($),z=U==="srcdoc"&&_;if(u(()=>{if(!z)return;let K=!1;return fetch(`${$}${$.includes("?")?"&":"?"}inline-assets=1`,{credentials:"same-origin"}).then((W)=>W.ok?W.text():Promise.reject(Error(`HTTP ${W.status}`))).then((W)=>{if(!K)J({url:$,html:W})}).catch((W)=>{if(console.error("[surface-frame] srcdoc fetch failed, falling back to src:",$,W),!K)J({url:$,html:""})}),()=>{K=!0}},[z,$]),!$)return{};if(!z)return U===null&&_?{}:{src:$};if(v)return v.html?{srcdoc:v.html}:{src:v.url};return{}}function bv({node:$,expanded:U=!1}){let v=C(null),J=$6.value,_=u$(()=>`theme-${crypto.randomUUID()}`,[]),z=u$(()=>`frame-${crypto.randomUUID()}`,[]),K=typeof $.data.content==="string"?$.data.content:"",W=u$(()=>RU(K),[K]),O=u$(()=>K?s0($.id,{theme:J,themeToken:_,v:W,frameToken:z}):"",[K,_,W,$.id,z]),Y=CU(O);yU($,v,U?"":z);let Z=()=>{v.current?.contentWindow?.postMessage({source:t6,type:"theme-update",token:_,theme:J},"*")};if(u(Z,[J,_]),!K)return G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No diagram source set"},void 0,!1,void 0,this);return G("iframe",{ref:v,class:"html-node-frame",title:typeof $.data.title==="string"?$.data.title:"Mermaid diagram",sandbox:"allow-scripts",...Y,onLoad:Z,style:{width:"100%",height:"100%",minHeight:U?"70vh":"300px",border:"none",background:"var(--c-bg)",borderRadius:"6px",display:"block"}},void 0,!1,void 0,this)}var B5=["dark","light","high-contrast","midnight","sepia","arctic","ember","forest","volt"];function e0($){return typeof $==="string"&&B5.includes($)}function X5($,U="dark"){return e0($)?$:U}var DU={dark:{label:"Dark",scheme:"dark",swatchBg:"#081524",swatchAccent:"#4BBCFF"},light:{label:"Light",scheme:"light",swatchBg:"#F4EFE6",swatchAccent:"#1A7ABF"},"high-contrast":{label:"High contrast",scheme:"dark",swatchBg:"#000000",swatchAccent:"#00ffff"},midnight:{label:"Midnight",scheme:"dark",swatchBg:"#0A0D1C",swatchAccent:"#8B96FF"},sepia:{label:"Sepia",scheme:"light",swatchBg:"#F2E7D5",swatchAccent:"#B4632C"},arctic:{label:"Arctic",scheme:"dark",swatchBg:"#20242E",swatchAccent:"#7FC8DE"},ember:{label:"Ember",scheme:"dark",swatchBg:"#0B0B0C",swatchAccent:"#F34E1C"},forest:{label:"Forest",scheme:"dark",swatchBg:"#0C1712",swatchAccent:"#5CCF8F"},volt:{label:"Volt",scheme:"dark",swatchBg:"#0B0D0B",swatchAccent:"#DFDFC1"}};function jU($){return DU[X5($)].scheme}var Q={};w4(Q,{xor:()=>mB,xid:()=>YB,void:()=>VB,uuidv7:()=>_B,uuidv6:()=>UB,uuidv4:()=>$B,uuid:()=>eq,util:()=>h,url:()=>vB,uppercase:()=>oU,unknown:()=>E$,union:()=>D$,undefined:()=>DB,ulid:()=>OB,uint64:()=>yB,uint32:()=>SB,tuple:()=>wG,trim:()=>eU,treeifyError:()=>g5,transform:()=>pJ,toUpperCase:()=>U0,toLowerCase:()=>$0,toJSONSchema:()=>kJ,templateLiteral:()=>tB,symbol:()=>CB,superRefine:()=>aG,success:()=>oB,stringbool:()=>vX,stringFormat:()=>bB,string:()=>g,strictObject:()=>uB,startsWith:()=>nU,slugify:()=>_0,size:()=>r1,setErrorMap:()=>MM,set:()=>lB,safeParseAsync:()=>vG,safeParse:()=>_G,safeEncodeAsync:()=>YG,safeEncode:()=>WG,safeDecodeAsync:()=>ZG,safeDecode:()=>OG,registry:()=>iv,regexes:()=>s6,regex:()=>iU,refine:()=>tG,record:()=>x$,readonly:()=>rG,property:()=>QJ,promise:()=>aB,prettifyError:()=>N5,preprocess:()=>E_,prefault:()=>EG,positive:()=>qJ,pipe:()=>R_,partialRecord:()=>xB,parseAsync:()=>UG,parse:()=>$G,overwrite:()=>W4,optional:()=>l$,object:()=>a,number:()=>w$,nullish:()=>pB,nullable:()=>S_,null:()=>Z0,normalize:()=>sU,nonpositive:()=>XJ,nonoptional:()=>uG,nonnegative:()=>HJ,never:()=>iJ,negative:()=>BJ,nativeEnum:()=>rB,nanoid:()=>KB,nan:()=>dB,multipleOf:()=>G1,minSize:()=>b4,minLength:()=>E4,mime:()=>aU,meta:()=>UX,maxSize:()=>W1,maxLength:()=>i1,map:()=>cB,mac:()=>BB,lte:()=>l6,lt:()=>P4,lowercase:()=>pU,looseRecord:()=>hB,looseObject:()=>X6,locales:()=>A_,literal:()=>U$,length:()=>p1,lazy:()=>oG,ksuid:()=>ZB,keyof:()=>EB,jwt:()=>kB,json:()=>JX,iso:()=>q1,ipv6:()=>XB,ipv4:()=>qB,intersection:()=>q0,int64:()=>TB,int32:()=>NB,int:()=>gJ,instanceof:()=>_X,includes:()=>dU,httpUrl:()=>JB,hostname:()=>MB,hex:()=>AB,hash:()=>IB,guid:()=>sq,gte:()=>y6,gt:()=>k4,globalRegistry:()=>B6,getErrorMap:()=>AM,function:()=>sB,fromJSONSchema:()=>KX,formatError:()=>O_,float64:()=>gB,float32:()=>wB,flattenError:()=>W_,file:()=>iB,exactOptional:()=>CG,enum:()=>H6,endsWith:()=>tU,encodeAsync:()=>KG,encode:()=>JG,emoji:()=>zB,email:()=>aq,e164:()=>PB,discriminatedUnion:()=>j_,describe:()=>$X,decodeAsync:()=>GG,decode:()=>zG,date:()=>fB,custom:()=>aJ,cuid2:()=>WB,cuid:()=>GB,core:()=>u4,config:()=>U6,coerce:()=>eG,codec:()=>nB,clone:()=>T6,cidrv6:()=>QB,cidrv4:()=>HB,check:()=>eB,catch:()=>hG,boolean:()=>_6,bigint:()=>RB,base64url:()=>FB,base64:()=>LB,array:()=>Q$,any:()=>jB,_function:()=>sB,_default:()=>VG,_ZodString:()=>NJ,ZodXor:()=>bG,ZodXID:()=>jJ,ZodVoid:()=>PG,ZodUnknown:()=>LG,ZodUnion:()=>D_,ZodUndefined:()=>XG,ZodUUID:()=>M4,ZodURL:()=>T_,ZodULID:()=>DJ,ZodType:()=>q$,ZodTuple:()=>IG,ZodTransform:()=>TG,ZodTemplateLiteral:()=>iG,ZodSymbol:()=>BG,ZodSuccess:()=>mG,ZodStringFormat:()=>f$,ZodString:()=>K0,ZodSet:()=>NG,ZodRecord:()=>V_,ZodRealError:()=>f6,ZodReadonly:()=>lG,ZodPromise:()=>dG,ZodPrefault:()=>fG,ZodPipe:()=>nJ,ZodOptional:()=>oJ,ZodObject:()=>C_,ZodNumberFormat:()=>o1,ZodNumber:()=>W0,ZodNullable:()=>DG,ZodNull:()=>HG,ZodNonOptional:()=>dJ,ZodNever:()=>FG,ZodNanoID:()=>TJ,ZodNaN:()=>cG,ZodMap:()=>gG,ZodMAC:()=>qG,ZodLiteral:()=>SG,ZodLazy:()=>pG,ZodKSUID:()=>VJ,ZodJWT:()=>lJ,ZodIssueCode:()=>bM,ZodIntersection:()=>AG,ZodISOTime:()=>IJ,ZodISODuration:()=>wJ,ZodISODateTime:()=>MJ,ZodISODate:()=>AJ,ZodIPv6:()=>EJ,ZodIPv4:()=>fJ,ZodGUID:()=>N_,ZodFunction:()=>nG,ZodFirstPartyTypeKind:()=>sG,ZodFile:()=>RG,ZodExactOptional:()=>yG,ZodError:()=>PM,ZodEnum:()=>z0,ZodEmoji:()=>RJ,ZodEmail:()=>SJ,ZodE164:()=>cJ,ZodDiscriminatedUnion:()=>MG,ZodDefault:()=>jG,ZodDate:()=>y_,ZodCustomStringFormat:()=>G0,ZodCustom:()=>f_,ZodCodec:()=>tJ,ZodCatch:()=>xG,ZodCUID2:()=>CJ,ZodCUID:()=>yJ,ZodCIDRv6:()=>mJ,ZodCIDRv4:()=>uJ,ZodBoolean:()=>O0,ZodBigIntFormat:()=>rJ,ZodBigInt:()=>Y0,ZodBase64URL:()=>hJ,ZodBase64:()=>xJ,ZodArray:()=>kG,ZodAny:()=>QG,TimePrecision:()=>R7,NEVER:()=>H5,$output:()=>A7,$input:()=>I7,$brand:()=>Q5});var u4={};w4(u4,{version:()=>k3,util:()=>h,treeifyError:()=>g5,toJSONSchema:()=>kJ,toDotPath:()=>qq,safeParseAsync:()=>q_,safeParse:()=>hU,safeEncodeAsync:()=>Pq,safeEncode:()=>Lq,safeDecodeAsync:()=>kq,safeDecode:()=>Fq,registry:()=>iv,regexes:()=>s6,process:()=>R$,prettifyError:()=>N5,parseAsync:()=>Z_,parse:()=>Y_,meta:()=>OK,locales:()=>A_,isValidJWT:()=>mq,isValidBase64URL:()=>uq,isValidBase64:()=>c3,initializeContext:()=>O1,globalRegistry:()=>B6,globalConfig:()=>$_,formatError:()=>O_,flattenError:()=>W_,finalize:()=>Z1,extractDefs:()=>Y1,encodeAsync:()=>Hq,encode:()=>Bq,describe:()=>WK,decodeAsync:()=>Qq,decode:()=>Xq,createToJSONSchemaMethod:()=>ZK,createStandardJSONSchemaMethod:()=>J0,config:()=>U6,clone:()=>T6,_xor:()=>nb,_xid:()=>_J,_void:()=>e7,_uuidv7:()=>tv,_uuidv6:()=>nv,_uuidv4:()=>dv,_uuid:()=>ov,_url:()=>w_,_uppercase:()=>oU,_unknown:()=>a7,_union:()=>db,_undefined:()=>d7,_ulid:()=>UJ,_uint64:()=>p7,_uint32:()=>x7,_tuple:()=>sb,_trim:()=>eU,_transform:()=>zM,_toUpperCase:()=>U0,_toLowerCase:()=>$0,_templateLiteral:()=>XM,_symbol:()=>o7,_superRefine:()=>GK,_success:()=>YM,_stringbool:()=>YK,_stringFormat:()=>v0,_string:()=>g7,_startsWith:()=>nU,_slugify:()=>_0,_size:()=>r1,_set:()=>UM,_safeParseAsync:()=>cU,_safeParse:()=>xU,_safeEncodeAsync:()=>Tv,_safeEncode:()=>Sv,_safeDecodeAsync:()=>yv,_safeDecode:()=>Rv,_regex:()=>iU,_refine:()=>KK,_record:()=>eb,_readonly:()=>BM,_property:()=>QJ,_promise:()=>QM,_positive:()=>qJ,_pipe:()=>qM,_parseAsync:()=>mU,_parse:()=>uU,_overwrite:()=>W4,_optional:()=>KM,_number:()=>j7,_nullable:()=>GM,_null:()=>n7,_normalize:()=>sU,_nonpositive:()=>XJ,_nonoptional:()=>OM,_nonnegative:()=>HJ,_never:()=>s7,_negative:()=>BJ,_nativeEnum:()=>vM,_nanoid:()=>sv,_nan:()=>_K,_multipleOf:()=>G1,_minSize:()=>b4,_minLength:()=>E4,_min:()=>y6,_mime:()=>aU,_maxSize:()=>W1,_maxLength:()=>i1,_max:()=>l6,_map:()=>$M,_mac:()=>S7,_lte:()=>l6,_lt:()=>P4,_lowercase:()=>pU,_literal:()=>JM,_length:()=>p1,_lazy:()=>HM,_ksuid:()=>vJ,_jwt:()=>ZJ,_isoTime:()=>C7,_isoDuration:()=>D7,_isoDateTime:()=>T7,_isoDate:()=>y7,_ipv6:()=>zJ,_ipv4:()=>JJ,_intersection:()=>ab,_int64:()=>i7,_int32:()=>m7,_int:()=>f7,_includes:()=>dU,_guid:()=>I_,_gte:()=>y6,_gt:()=>k4,_float64:()=>u7,_float32:()=>E7,_file:()=>JK,_enum:()=>_M,_endsWith:()=>tU,_encodeAsync:()=>gv,_encode:()=>Iv,_emoji:()=>av,_email:()=>pv,_e164:()=>YJ,_discriminatedUnion:()=>tb,_default:()=>WM,_decodeAsync:()=>Nv,_decode:()=>wv,_date:()=>$K,_custom:()=>zK,_cuid2:()=>$J,_cuid:()=>ev,_coercedString:()=>N7,_coercedNumber:()=>V7,_coercedDate:()=>UK,_coercedBoolean:()=>c7,_coercedBigint:()=>r7,_cidrv6:()=>GJ,_cidrv4:()=>KJ,_check:()=>dq,_catch:()=>ZM,_boolean:()=>h7,_bigint:()=>l7,_base64url:()=>OJ,_base64:()=>WJ,_array:()=>vK,_any:()=>t7,TimePrecision:()=>R7,NEVER:()=>H5,JSONSchemaGenerator:()=>nK,JSONSchema:()=>nq,Doc:()=>Vv,$output:()=>A7,$input:()=>I7,$constructor:()=>M,$brand:()=>Q5,$ZodXor:()=>Kz,$ZodXID:()=>y3,$ZodVoid:()=>_z,$ZodUnknown:()=>$z,$ZodUnion:()=>L_,$ZodUndefined:()=>a3,$ZodUUID:()=>A3,$ZodURL:()=>w3,$ZodULID:()=>T3,$ZodType:()=>Y$,$ZodTuple:()=>lv,$ZodTransform:()=>Hz,$ZodTemplateLiteral:()=>gz,$ZodSymbol:()=>t3,$ZodSuccess:()=>bz,$ZodStringFormat:()=>V$,$ZodString:()=>l1,$ZodSet:()=>Zz,$ZodRegistry:()=>w7,$ZodRecord:()=>Oz,$ZodRealError:()=>V6,$ZodReadonly:()=>wz,$ZodPromise:()=>Sz,$ZodPrefault:()=>Pz,$ZodPipe:()=>Iz,$ZodOptional:()=>rv,$ZodObjectJIT:()=>zz,$ZodObject:()=>cq,$ZodNumberFormat:()=>d3,$ZodNumber:()=>hv,$ZodNullable:()=>Lz,$ZodNull:()=>s3,$ZodNonOptional:()=>kz,$ZodNever:()=>Uz,$ZodNanoID:()=>N3,$ZodNaN:()=>Az,$ZodMap:()=>Yz,$ZodMAC:()=>m3,$ZodLiteral:()=>Bz,$ZodLazy:()=>Rz,$ZodKSUID:()=>C3,$ZodJWT:()=>p3,$ZodIntersection:()=>Wz,$ZodISOTime:()=>V3,$ZodISODuration:()=>f3,$ZodISODateTime:()=>D3,$ZodISODate:()=>j3,$ZodIPv6:()=>u3,$ZodIPv4:()=>E3,$ZodGUID:()=>M3,$ZodFunction:()=>Nz,$ZodFile:()=>Xz,$ZodExactOptional:()=>Qz,$ZodError:()=>G_,$ZodEnum:()=>qz,$ZodEncodeError:()=>x1,$ZodEmoji:()=>g3,$ZodEmail:()=>I3,$ZodE164:()=>i3,$ZodDiscriminatedUnion:()=>Gz,$ZodDefault:()=>Fz,$ZodDate:()=>vz,$ZodCustomStringFormat:()=>o3,$ZodCustom:()=>Tz,$ZodCodec:()=>F_,$ZodCheckUpperCase:()=>B3,$ZodCheckStringFormat:()=>lU,$ZodCheckStartsWith:()=>H3,$ZodCheckSizeEquals:()=>G3,$ZodCheckRegex:()=>Z3,$ZodCheckProperty:()=>L3,$ZodCheckOverwrite:()=>P3,$ZodCheckNumberFormat:()=>v3,$ZodCheckMultipleOf:()=>_3,$ZodCheckMinSize:()=>K3,$ZodCheckMinLength:()=>O3,$ZodCheckMimeType:()=>F3,$ZodCheckMaxSize:()=>z3,$ZodCheckMaxLength:()=>W3,$ZodCheckLowerCase:()=>q3,$ZodCheckLessThan:()=>Dv,$ZodCheckLengthEquals:()=>Y3,$ZodCheckIncludes:()=>X3,$ZodCheckGreaterThan:()=>jv,$ZodCheckEndsWith:()=>Q3,$ZodCheckBigIntFormat:()=>J3,$ZodCheck:()=>m$,$ZodCatch:()=>Mz,$ZodCUID2:()=>R3,$ZodCUID:()=>S3,$ZodCIDRv6:()=>h3,$ZodCIDRv4:()=>x3,$ZodBoolean:()=>Q_,$ZodBigIntFormat:()=>n3,$ZodBigInt:()=>cv,$ZodBase64URL:()=>r3,$ZodBase64:()=>l3,$ZodAsyncError:()=>F4,$ZodArray:()=>Jz,$ZodAny:()=>e3});var H5=Object.freeze({status:"aborted"});function M($,U,v){function J(W,O){if(!W._zod)Object.defineProperty(W,"_zod",{value:{def:O,constr:K,traits:new Set},enumerable:!1});if(W._zod.traits.has($))return;W._zod.traits.add($),U(W,O);let Y=K.prototype,Z=Object.keys(Y);for(let q=0;q<Z.length;q++){let X=Z[q];if(!(X in W))W[X]=Y[X].bind(W)}}let _=v?.Parent??Object;class z extends _{}Object.defineProperty(z,"name",{value:$});function K(W){var O;let Y=v?.Parent?new z:this;J(Y,W),(O=Y._zod).deferred??(O.deferred=[]);for(let Z of Y._zod.deferred)Z();return Y}return Object.defineProperty(K,"init",{value:J}),Object.defineProperty(K,Symbol.hasInstance,{value:(W)=>{if(v?.Parent&&W instanceof v.Parent)return!0;return W?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}var Q5=Symbol("zod_brand");class F4 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class x1 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var $_={};function U6($){if($)Object.assign($_,$);return $_}var h={};w4(h,{unwrapMessage:()=>U_,uint8ArrayToHex:()=>Ik,uint8ArrayToBase64url:()=>Mk,uint8ArrayToBase64:()=>Oq,stringifyPrimitive:()=>m,slugify:()=>P5,shallowClone:()=>b5,safeExtend:()=>Qk,required:()=>Pk,randomString:()=>Ok,propertyKeyTypes:()=>J_,promiseAllObject:()=>Wk,primitiveTypes:()=>M5,prefixIssues:()=>c6,pick:()=>Bk,partial:()=>Fk,parsedType:()=>x,optionalKeys:()=>A5,omit:()=>Xk,objectClone:()=>zk,numKeys:()=>Yk,nullish:()=>v1,normalizeParams:()=>c,mergeDefs:()=>f4,merge:()=>Lk,jsonStringifyReplacer:()=>VU,joinValues:()=>w,issue:()=>EU,isPlainObject:()=>z1,isObject:()=>h1,hexToUint8Array:()=>Ak,getSizableOrigin:()=>z_,getParsedType:()=>Zk,getLengthableOrigin:()=>K_,getEnumValues:()=>__,getElementAtPath:()=>Gk,floatSafeRemainder:()=>F5,finalizeIssue:()=>j6,extend:()=>Hk,escapeRegex:()=>a6,esc:()=>Mv,defineLazy:()=>X$,createTransparentProxy:()=>qk,cloneDef:()=>Kk,clone:()=>T6,cleanRegex:()=>v_,cleanEnum:()=>kk,captureStackTrace:()=>Av,cached:()=>fU,base64urlToUint8Array:()=>bk,base64ToUint8Array:()=>Wq,assignProp:()=>J1,assertNotEqual:()=>Uk,assertNever:()=>vk,assertIs:()=>_k,assertEqual:()=>$k,assert:()=>Jk,allowsEval:()=>k5,aborted:()=>K1,NUMBER_FORMAT_RANGES:()=>I5,Class:()=>Yq,BIGINT_FORMAT_RANGES:()=>w5});function $k($){return $}function Uk($){return $}function _k($){}function vk($){throw Error("Unexpected value in exhaustive check")}function Jk($){}function __($){let U=Object.values($).filter((J)=>typeof J==="number");return Object.entries($).filter(([J,_])=>U.indexOf(+J)===-1).map(([J,_])=>_)}function w($,U="|"){return $.map((v)=>m(v)).join(U)}function VU($,U){if(typeof U==="bigint")return U.toString();return U}function fU($){return{get value(){{let v=$();return Object.defineProperty(this,"value",{value:v}),v}throw Error("cached value already set")}}}function v1($){return $===null||$===void 0}function v_($){let U=$.startsWith("^")?1:0,v=$.endsWith("$")?$.length-1:$.length;return $.slice(U,v)}function F5($,U){let v=($.toString().split(".")[1]||"").length,J=U.toString(),_=(J.split(".")[1]||"").length;if(_===0&&/\d?e-\d?/.test(J)){let O=J.match(/\d?e-(\d?)/);if(O?.[1])_=Number.parseInt(O[1])}let z=v>_?v:_,K=Number.parseInt($.toFixed(z).replace(".","")),W=Number.parseInt(U.toFixed(z).replace(".",""));return K%W/10**z}var Gq=Symbol("evaluating");function X$($,U,v){let J=void 0;Object.defineProperty($,U,{get(){if(J===Gq)return;if(J===void 0)J=Gq,J=v();return J},set(_){Object.defineProperty($,U,{value:_})},configurable:!0})}function zk($){return Object.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}function J1($,U,v){Object.defineProperty($,U,{value:v,writable:!0,enumerable:!0,configurable:!0})}function f4(...$){let U={};for(let v of $){let J=Object.getOwnPropertyDescriptors(v);Object.assign(U,J)}return Object.defineProperties({},U)}function Kk($){return f4($._zod.def)}function Gk($,U){if(!U)return $;return U.reduce((v,J)=>v?.[J],$)}function Wk($){let U=Object.keys($),v=U.map((J)=>$[J]);return Promise.all(v).then((J)=>{let _={};for(let z=0;z<U.length;z++)_[U[z]]=J[z];return _})}function Ok($=10){let v="";for(let J=0;J<$;J++)v+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return v}function Mv($){return JSON.stringify($)}function P5($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Av="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function h1($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var k5=fU(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function z1($){if(h1($)===!1)return!1;let U=$.constructor;if(U===void 0)return!0;if(typeof U!=="function")return!0;let v=U.prototype;if(h1(v)===!1)return!1;if(Object.prototype.hasOwnProperty.call(v,"isPrototypeOf")===!1)return!1;return!0}function b5($){if(z1($))return{...$};if(Array.isArray($))return[...$];return $}function Yk($){let U=0;for(let v in $)if(Object.prototype.hasOwnProperty.call($,v))U++;return U}var Zk=($)=>{let U=typeof $;switch(U){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map<"u"&&$ instanceof Map)return"map";if(typeof Set<"u"&&$ instanceof Set)return"set";if(typeof Date<"u"&&$ instanceof Date)return"date";if(typeof File<"u"&&$ instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${U}`)}},J_=new Set(["string","number","symbol"]),M5=new Set(["string","number","bigint","boolean","symbol","undefined"]);function a6($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T6($,U,v){let J=new $._zod.constr(U??$._zod.def);if(!U||v?.parent)J._zod.parent=$;return J}function c($){let U=$;if(!U)return{};if(typeof U==="string")return{error:()=>U};if(U?.message!==void 0){if(U?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");U.error=U.message}if(delete U.message,typeof U.error==="string")return{...U,error:()=>U.error};return U}function qk($){let U;return new Proxy({},{get(v,J,_){return U??(U=$()),Reflect.get(U,J,_)},set(v,J,_,z){return U??(U=$()),Reflect.set(U,J,_,z)},has(v,J){return U??(U=$()),Reflect.has(U,J)},deleteProperty(v,J){return U??(U=$()),Reflect.deleteProperty(U,J)},ownKeys(v){return U??(U=$()),Reflect.ownKeys(U)},getOwnPropertyDescriptor(v,J){return U??(U=$()),Reflect.getOwnPropertyDescriptor(U,J)},defineProperty(v,J,_){return U??(U=$()),Reflect.defineProperty(U,J,_)}})}function m($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function A5($){return Object.keys($).filter((U)=>{return $[U]._zod.optin==="optional"&&$[U]._zod.optout==="optional"})}var I5={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},w5={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Bk($,U){let v=$._zod.def,J=v.checks;if(J&&J.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let z=f4($._zod.def,{get shape(){let K={};for(let W in U){if(!(W in v.shape))throw Error(`Unrecognized key: "${W}"`);if(!U[W])continue;K[W]=v.shape[W]}return J1(this,"shape",K),K},checks:[]});return T6($,z)}function Xk($,U){let v=$._zod.def,J=v.checks;if(J&&J.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let z=f4($._zod.def,{get shape(){let K={...$._zod.def.shape};for(let W in U){if(!(W in v.shape))throw Error(`Unrecognized key: "${W}"`);if(!U[W])continue;delete K[W]}return J1(this,"shape",K),K},checks:[]});return T6($,z)}function Hk($,U){if(!z1(U))throw Error("Invalid input to extend: expected a plain object");let v=$._zod.def.checks;if(v&&v.length>0){let z=$._zod.def.shape;for(let K in U)if(Object.getOwnPropertyDescriptor(z,K)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let _=f4($._zod.def,{get shape(){let z={...$._zod.def.shape,...U};return J1(this,"shape",z),z}});return T6($,_)}function Qk($,U){if(!z1(U))throw Error("Invalid input to safeExtend: expected a plain object");let v=f4($._zod.def,{get shape(){let J={...$._zod.def.shape,...U};return J1(this,"shape",J),J}});return T6($,v)}function Lk($,U){let v=f4($._zod.def,{get shape(){let J={...$._zod.def.shape,...U._zod.def.shape};return J1(this,"shape",J),J},get catchall(){return U._zod.def.catchall},checks:[]});return T6($,v)}function Fk($,U,v){let _=U._zod.def.checks;if(_&&_.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let K=f4(U._zod.def,{get shape(){let W=U._zod.def.shape,O={...W};if(v)for(let Y in v){if(!(Y in W))throw Error(`Unrecognized key: "${Y}"`);if(!v[Y])continue;O[Y]=$?new $({type:"optional",innerType:W[Y]}):W[Y]}else for(let Y in W)O[Y]=$?new $({type:"optional",innerType:W[Y]}):W[Y];return J1(this,"shape",O),O},checks:[]});return T6(U,K)}function Pk($,U,v){let J=f4(U._zod.def,{get shape(){let _=U._zod.def.shape,z={..._};if(v)for(let K in v){if(!(K in z))throw Error(`Unrecognized key: "${K}"`);if(!v[K])continue;z[K]=new $({type:"nonoptional",innerType:_[K]})}else for(let K in _)z[K]=new $({type:"nonoptional",innerType:_[K]});return J1(this,"shape",z),z}});return T6(U,J)}function K1($,U=0){if($.aborted===!0)return!0;for(let v=U;v<$.issues.length;v++)if($.issues[v]?.continue!==!0)return!0;return!1}function c6($,U){return U.map((v)=>{var J;return(J=v).path??(J.path=[]),v.path.unshift($),v})}function U_($){return typeof $==="string"?$:$?.message}function j6($,U,v){let J={...$,path:$.path??[]};if(!$.message){let _=U_($.inst?._zod.def?.error?.($))??U_(U?.error?.($))??U_(v.customError?.($))??U_(v.localeError?.($))??"Invalid input";J.message=_}if(delete J.inst,delete J.continue,!U?.reportInput)delete J.input;return J}function z_($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function K_($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function x($){let U=typeof $;switch(U){case"number":return Number.isNaN($)?"nan":"number";case"object":{if($===null)return"null";if(Array.isArray($))return"array";let v=$;if(v&&Object.getPrototypeOf(v)!==Object.prototype&&"constructor"in v&&v.constructor)return v.constructor.name}}return U}function EU(...$){let[U,v,J]=$;if(typeof U==="string")return{message:U,code:"custom",input:v,inst:J};return{...U}}function kk($){return Object.entries($).filter(([U,v])=>{return Number.isNaN(Number.parseInt(U,10))}).map((U)=>U[1])}function Wq($){let U=atob($),v=new Uint8Array(U.length);for(let J=0;J<U.length;J++)v[J]=U.charCodeAt(J);return v}function Oq($){let U="";for(let v=0;v<$.length;v++)U+=String.fromCharCode($[v]);return btoa(U)}function bk($){let U=$.replace(/-/g,"+").replace(/_/g,"/"),v="=".repeat((4-U.length%4)%4);return Wq(U+v)}function Mk($){return Oq($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ak($){let U=$.replace(/^0x/,"");if(U.length%2!==0)throw Error("Invalid hex string length");let v=new Uint8Array(U.length/2);for(let J=0;J<U.length;J+=2)v[J/2]=Number.parseInt(U.slice(J,J+2),16);return v}function Ik($){return Array.from($).map((U)=>U.toString(16).padStart(2,"0")).join("")}class Yq{constructor(...$){}}var Zq=($,U)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:U,enumerable:!1}),$.message=JSON.stringify(U,VU,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},G_=M("$ZodError",Zq),V6=M("$ZodError",Zq,{Parent:Error});function W_($,U=(v)=>v.message){let v={},J=[];for(let _ of $.issues)if(_.path.length>0)v[_.path[0]]=v[_.path[0]]||[],v[_.path[0]].push(U(_));else J.push(U(_));return{formErrors:J,fieldErrors:v}}function O_($,U=(v)=>v.message){let v={_errors:[]},J=(_)=>{for(let z of _.issues)if(z.code==="invalid_union"&&z.errors.length)z.errors.map((K)=>J({issues:K}));else if(z.code==="invalid_key")J({issues:z.issues});else if(z.code==="invalid_element")J({issues:z.issues});else if(z.path.length===0)v._errors.push(U(z));else{let K=v,W=0;while(W<z.path.length){let O=z.path[W];if(W!==z.path.length-1)K[O]=K[O]||{_errors:[]};else K[O]=K[O]||{_errors:[]},K[O]._errors.push(U(z));K=K[O],W++}}};return J($),v}function g5($,U=(v)=>v.message){let v={errors:[]},J=(_,z=[])=>{var K,W;for(let O of _.issues)if(O.code==="invalid_union"&&O.errors.length)O.errors.map((Y)=>J({issues:Y},O.path));else if(O.code==="invalid_key")J({issues:O.issues},O.path);else if(O.code==="invalid_element")J({issues:O.issues},O.path);else{let Y=[...z,...O.path];if(Y.length===0){v.errors.push(U(O));continue}let Z=v,q=0;while(q<Y.length){let X=Y[q],B=q===Y.length-1;if(typeof X==="string")Z.properties??(Z.properties={}),(K=Z.properties)[X]??(K[X]={errors:[]}),Z=Z.properties[X];else Z.items??(Z.items=[]),(W=Z.items)[X]??(W[X]={errors:[]}),Z=Z.items[X];if(B)Z.errors.push(U(O));q++}}};return J($),v}function qq($){let U=[],v=$.map((J)=>typeof J==="object"?J.key:J);for(let J of v)if(typeof J==="number")U.push(`[${J}]`);else if(typeof J==="symbol")U.push(`[${JSON.stringify(String(J))}]`);else if(/[^\w$]/.test(J))U.push(`[${JSON.stringify(J)}]`);else{if(U.length)U.push(".");U.push(J)}return U.join("")}function N5($){let U=[],v=[...$.issues].sort((J,_)=>(J.path??[]).length-(_.path??[]).length);for(let J of v)if(U.push(`✖ ${J.message}`),J.path?.length)U.push(` → at ${qq(J.path)}`);return U.join(`
|
|
113
|
-
`)}var uU=($)=>(U,v,J,_)=>{let z=J?Object.assign(J,{async:!1}):{async:!1},K=U._zod.run({value:v,issues:[]},z);if(K instanceof Promise)throw new F4;if(K.issues.length){let W=new(_?.Err??$)(K.issues.map((O)=>j6(O,z,U6())));throw Av(W,_?.callee),W}return K.value},Y_=uU(V6),mU=($)=>async(U,v,J,_)=>{let z=J?Object.assign(J,{async:!0}):{async:!0},K=U._zod.run({value:v,issues:[]},z);if(K instanceof Promise)K=await K;if(K.issues.length){let W=new(_?.Err??$)(K.issues.map((O)=>j6(O,z,U6())));throw Av(W,_?.callee),W}return K.value},Z_=mU(V6),xU=($)=>(U,v,J)=>{let _=J?{...J,async:!1}:{async:!1},z=U._zod.run({value:v,issues:[]},_);if(z instanceof Promise)throw new F4;return z.issues.length?{success:!1,error:new($??G_)(z.issues.map((K)=>j6(K,_,U6())))}:{success:!0,data:z.value}},hU=xU(V6),cU=($)=>async(U,v,J)=>{let _=J?Object.assign(J,{async:!0}):{async:!0},z=U._zod.run({value:v,issues:[]},_);if(z instanceof Promise)z=await z;return z.issues.length?{success:!1,error:new $(z.issues.map((K)=>j6(K,_,U6())))}:{success:!0,data:z.value}},q_=cU(V6),Iv=($)=>(U,v,J)=>{let _=J?Object.assign(J,{direction:"backward"}):{direction:"backward"};return uU($)(U,v,_)},Bq=Iv(V6),wv=($)=>(U,v,J)=>{return uU($)(U,v,J)},Xq=wv(V6),gv=($)=>async(U,v,J)=>{let _=J?Object.assign(J,{direction:"backward"}):{direction:"backward"};return mU($)(U,v,_)},Hq=gv(V6),Nv=($)=>async(U,v,J)=>{return mU($)(U,v,J)},Qq=Nv(V6),Sv=($)=>(U,v,J)=>{let _=J?Object.assign(J,{direction:"backward"}):{direction:"backward"};return xU($)(U,v,_)},Lq=Sv(V6),Rv=($)=>(U,v,J)=>{return xU($)(U,v,J)},Fq=Rv(V6),Tv=($)=>async(U,v,J)=>{let _=J?Object.assign(J,{direction:"backward"}):{direction:"backward"};return cU($)(U,v,_)},Pq=Tv(V6),yv=($)=>async(U,v,J)=>{return cU($)(U,v,J)},kq=yv(V6);var s6={};w4(s6,{xid:()=>y5,uuid7:()=>Rk,uuid6:()=>Sk,uuid4:()=>Nk,uuid:()=>c1,uppercase:()=>U3,unicodeEmail:()=>bq,undefined:()=>e5,ulid:()=>T5,time:()=>p5,string:()=>d5,sha512_hex:()=>tk,sha512_base64url:()=>sk,sha512_base64:()=>ak,sha384_hex:()=>ok,sha384_base64url:()=>nk,sha384_base64:()=>dk,sha256_hex:()=>rk,sha256_base64url:()=>pk,sha256_base64:()=>ik,sha1_hex:()=>hk,sha1_base64url:()=>lk,sha1_base64:()=>ck,rfc5322Email:()=>yk,number:()=>B_,null:()=>s5,nanoid:()=>D5,md5_hex:()=>uk,md5_base64url:()=>xk,md5_base64:()=>mk,mac:()=>x5,lowercase:()=>$3,ksuid:()=>C5,ipv6:()=>m5,ipv4:()=>u5,integer:()=>t5,idnEmail:()=>Ck,html5Email:()=>Tk,hostname:()=>Vk,hex:()=>Ek,guid:()=>V5,extendedDuration:()=>gk,emoji:()=>E5,email:()=>f5,e164:()=>r5,duration:()=>j5,domain:()=>fk,datetime:()=>o5,date:()=>i5,cuid2:()=>R5,cuid:()=>S5,cidrv6:()=>c5,cidrv4:()=>h5,browserEmail:()=>Dk,boolean:()=>a5,bigint:()=>n5,base64url:()=>Cv,base64:()=>l5});var S5=/^[cC][^\s-]{8,}$/,R5=/^[0-9a-z]+$/,T5=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,y5=/^[0-9a-vA-V]{20}$/,C5=/^[A-Za-z0-9]{27}$/,D5=/^[a-zA-Z0-9_-]{21}$/,j5=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gk=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,V5=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,c1=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},Nk=c1(4),Sk=c1(6),Rk=c1(7),f5=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tk=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,yk=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,bq=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Ck=bq,Dk=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,jk="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function E5(){return new RegExp(jk,"u")}var u5=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,m5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,x5=($)=>{let U=a6($??":");return new RegExp(`^(?:[0-9A-F]{2}${U}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${U}){5}[0-9a-f]{2}$`)},h5=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,c5=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,l5=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cv=/^[A-Za-z0-9_-]*$/,Vk=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,fk=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,r5=/^\+[1-9]\d{6,14}$/,Mq="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",i5=new RegExp(`^${Mq}$`);function Aq($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function p5($){return new RegExp(`^${Aq($)}$`)}function o5($){let U=Aq({precision:$.precision}),v=["Z"];if($.local)v.push("");if($.offset)v.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let J=`${U}(?:${v.join("|")})`;return new RegExp(`^${Mq}T(?:${J})$`)}var d5=($)=>{let U=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${U}$`)},n5=/^-?\d+n?$/,t5=/^-?\d+$/,B_=/^-?\d+(?:\.\d+)?$/,a5=/^(?:true|false)$/i,s5=/^null$/i;var e5=/^undefined$/i;var $3=/^[^A-Z]*$/,U3=/^[^a-z]*$/,Ek=/^[0-9a-fA-F]*$/;function X_($,U){return new RegExp(`^[A-Za-z0-9+/]{${$}}${U}$`)}function H_($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var uk=/^[0-9a-fA-F]{32}$/,mk=X_(22,"=="),xk=H_(22),hk=/^[0-9a-fA-F]{40}$/,ck=X_(27,"="),lk=H_(27),rk=/^[0-9a-fA-F]{64}$/,ik=X_(43,"="),pk=H_(43),ok=/^[0-9a-fA-F]{96}$/,dk=X_(64,""),nk=H_(64),tk=/^[0-9a-fA-F]{128}$/,ak=X_(86,"=="),sk=H_(86);var m$=M("$ZodCheck",($,U)=>{var v;$._zod??($._zod={}),$._zod.def=U,(v=$._zod).onattach??(v.onattach=[])}),wq={number:"number",bigint:"bigint",object:"date"},Dv=M("$ZodCheckLessThan",($,U)=>{m$.init($,U);let v=wq[typeof U.value];$._zod.onattach.push((J)=>{let _=J._zod.bag,z=(U.inclusive?_.maximum:_.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(U.value<z)if(U.inclusive)_.maximum=U.value;else _.exclusiveMaximum=U.value}),$._zod.check=(J)=>{if(U.inclusive?J.value<=U.value:J.value<U.value)return;J.issues.push({origin:v,code:"too_big",maximum:typeof U.value==="object"?U.value.getTime():U.value,input:J.value,inclusive:U.inclusive,inst:$,continue:!U.abort})}}),jv=M("$ZodCheckGreaterThan",($,U)=>{m$.init($,U);let v=wq[typeof U.value];$._zod.onattach.push((J)=>{let _=J._zod.bag,z=(U.inclusive?_.minimum:_.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(U.value>z)if(U.inclusive)_.minimum=U.value;else _.exclusiveMinimum=U.value}),$._zod.check=(J)=>{if(U.inclusive?J.value>=U.value:J.value>U.value)return;J.issues.push({origin:v,code:"too_small",minimum:typeof U.value==="object"?U.value.getTime():U.value,input:J.value,inclusive:U.inclusive,inst:$,continue:!U.abort})}}),_3=M("$ZodCheckMultipleOf",($,U)=>{m$.init($,U),$._zod.onattach.push((v)=>{var J;(J=v._zod.bag).multipleOf??(J.multipleOf=U.value)}),$._zod.check=(v)=>{if(typeof v.value!==typeof U.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof v.value==="bigint"?v.value%U.value===BigInt(0):F5(v.value,U.value)===0)return;v.issues.push({origin:typeof v.value,code:"not_multiple_of",divisor:U.value,input:v.value,inst:$,continue:!U.abort})}}),v3=M("$ZodCheckNumberFormat",($,U)=>{m$.init($,U),U.format=U.format||"float64";let v=U.format?.includes("int"),J=v?"int":"number",[_,z]=I5[U.format];$._zod.onattach.push((K)=>{let W=K._zod.bag;if(W.format=U.format,W.minimum=_,W.maximum=z,v)W.pattern=t5}),$._zod.check=(K)=>{let W=K.value;if(v){if(!Number.isInteger(W)){K.issues.push({expected:J,format:U.format,code:"invalid_type",continue:!1,input:W,inst:$});return}if(!Number.isSafeInteger(W)){if(W>0)K.issues.push({input:W,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:J,inclusive:!0,continue:!U.abort});else K.issues.push({input:W,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:J,inclusive:!0,continue:!U.abort});return}}if(W<_)K.issues.push({origin:"number",input:W,code:"too_small",minimum:_,inclusive:!0,inst:$,continue:!U.abort});if(W>z)K.issues.push({origin:"number",input:W,code:"too_big",maximum:z,inclusive:!0,inst:$,continue:!U.abort})}}),J3=M("$ZodCheckBigIntFormat",($,U)=>{m$.init($,U);let[v,J]=w5[U.format];$._zod.onattach.push((_)=>{let z=_._zod.bag;z.format=U.format,z.minimum=v,z.maximum=J}),$._zod.check=(_)=>{let z=_.value;if(z<v)_.issues.push({origin:"bigint",input:z,code:"too_small",minimum:v,inclusive:!0,inst:$,continue:!U.abort});if(z>J)_.issues.push({origin:"bigint",input:z,code:"too_big",maximum:J,inclusive:!0,inst:$,continue:!U.abort})}}),z3=M("$ZodCheckMaxSize",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.size!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag.maximum??Number.POSITIVE_INFINITY;if(U.maximum<_)J._zod.bag.maximum=U.maximum}),$._zod.check=(J)=>{let _=J.value;if(_.size<=U.maximum)return;J.issues.push({origin:z_(_),code:"too_big",maximum:U.maximum,inclusive:!0,input:_,inst:$,continue:!U.abort})}}),K3=M("$ZodCheckMinSize",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.size!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(U.minimum>_)J._zod.bag.minimum=U.minimum}),$._zod.check=(J)=>{let _=J.value;if(_.size>=U.minimum)return;J.issues.push({origin:z_(_),code:"too_small",minimum:U.minimum,inclusive:!0,input:_,inst:$,continue:!U.abort})}}),G3=M("$ZodCheckSizeEquals",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.size!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag;_.minimum=U.size,_.maximum=U.size,_.size=U.size}),$._zod.check=(J)=>{let _=J.value,z=_.size;if(z===U.size)return;let K=z>U.size;J.issues.push({origin:z_(_),...K?{code:"too_big",maximum:U.size}:{code:"too_small",minimum:U.size},inclusive:!0,exact:!0,input:J.value,inst:$,continue:!U.abort})}}),W3=M("$ZodCheckMaxLength",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.length!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag.maximum??Number.POSITIVE_INFINITY;if(U.maximum<_)J._zod.bag.maximum=U.maximum}),$._zod.check=(J)=>{let _=J.value;if(_.length<=U.maximum)return;let K=K_(_);J.issues.push({origin:K,code:"too_big",maximum:U.maximum,inclusive:!0,input:_,inst:$,continue:!U.abort})}}),O3=M("$ZodCheckMinLength",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.length!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(U.minimum>_)J._zod.bag.minimum=U.minimum}),$._zod.check=(J)=>{let _=J.value;if(_.length>=U.minimum)return;let K=K_(_);J.issues.push({origin:K,code:"too_small",minimum:U.minimum,inclusive:!0,input:_,inst:$,continue:!U.abort})}}),Y3=M("$ZodCheckLengthEquals",($,U)=>{var v;m$.init($,U),(v=$._zod.def).when??(v.when=(J)=>{let _=J.value;return!v1(_)&&_.length!==void 0}),$._zod.onattach.push((J)=>{let _=J._zod.bag;_.minimum=U.length,_.maximum=U.length,_.length=U.length}),$._zod.check=(J)=>{let _=J.value,z=_.length;if(z===U.length)return;let K=K_(_),W=z>U.length;J.issues.push({origin:K,...W?{code:"too_big",maximum:U.length}:{code:"too_small",minimum:U.length},inclusive:!0,exact:!0,input:J.value,inst:$,continue:!U.abort})}}),lU=M("$ZodCheckStringFormat",($,U)=>{var v,J;if(m$.init($,U),$._zod.onattach.push((_)=>{let z=_._zod.bag;if(z.format=U.format,U.pattern)z.patterns??(z.patterns=new Set),z.patterns.add(U.pattern)}),U.pattern)(v=$._zod).check??(v.check=(_)=>{if(U.pattern.lastIndex=0,U.pattern.test(_.value))return;_.issues.push({origin:"string",code:"invalid_format",format:U.format,input:_.value,...U.pattern?{pattern:U.pattern.toString()}:{},inst:$,continue:!U.abort})});else(J=$._zod).check??(J.check=()=>{})}),Z3=M("$ZodCheckRegex",($,U)=>{lU.init($,U),$._zod.check=(v)=>{if(U.pattern.lastIndex=0,U.pattern.test(v.value))return;v.issues.push({origin:"string",code:"invalid_format",format:"regex",input:v.value,pattern:U.pattern.toString(),inst:$,continue:!U.abort})}}),q3=M("$ZodCheckLowerCase",($,U)=>{U.pattern??(U.pattern=$3),lU.init($,U)}),B3=M("$ZodCheckUpperCase",($,U)=>{U.pattern??(U.pattern=U3),lU.init($,U)}),X3=M("$ZodCheckIncludes",($,U)=>{m$.init($,U);let v=a6(U.includes),J=new RegExp(typeof U.position==="number"?`^.{${U.position}}${v}`:v);U.pattern=J,$._zod.onattach.push((_)=>{let z=_._zod.bag;z.patterns??(z.patterns=new Set),z.patterns.add(J)}),$._zod.check=(_)=>{if(_.value.includes(U.includes,U.position))return;_.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:U.includes,input:_.value,inst:$,continue:!U.abort})}}),H3=M("$ZodCheckStartsWith",($,U)=>{m$.init($,U);let v=new RegExp(`^${a6(U.prefix)}.*`);U.pattern??(U.pattern=v),$._zod.onattach.push((J)=>{let _=J._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(v)}),$._zod.check=(J)=>{if(J.value.startsWith(U.prefix))return;J.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:U.prefix,input:J.value,inst:$,continue:!U.abort})}}),Q3=M("$ZodCheckEndsWith",($,U)=>{m$.init($,U);let v=new RegExp(`.*${a6(U.suffix)}$`);U.pattern??(U.pattern=v),$._zod.onattach.push((J)=>{let _=J._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(v)}),$._zod.check=(J)=>{if(J.value.endsWith(U.suffix))return;J.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:U.suffix,input:J.value,inst:$,continue:!U.abort})}});function Iq($,U,v){if($.issues.length)U.issues.push(...c6(v,$.issues))}var L3=M("$ZodCheckProperty",($,U)=>{m$.init($,U),$._zod.check=(v)=>{let J=U.schema._zod.run({value:v.value[U.property],issues:[]},{});if(J instanceof Promise)return J.then((_)=>Iq(_,v,U.property));Iq(J,v,U.property);return}}),F3=M("$ZodCheckMimeType",($,U)=>{m$.init($,U);let v=new Set(U.mime);$._zod.onattach.push((J)=>{J._zod.bag.mime=U.mime}),$._zod.check=(J)=>{if(v.has(J.value.type))return;J.issues.push({code:"invalid_value",values:U.mime,input:J.value.type,inst:$,continue:!U.abort})}}),P3=M("$ZodCheckOverwrite",($,U)=>{m$.init($,U),$._zod.check=(v)=>{v.value=U.tx(v.value)}});class Vv{constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let v=$.split(`
|
|
114
|
-
`)
|
|
115
|
-
`))}}var k3={major:4,minor:3,patch:6};var Y$=M("$ZodType",($,U)=>{var v;$??($={}),$._zod.def=U,$._zod.bag=$._zod.bag||{},$._zod.version=k3;let J=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))J.unshift($);for(let _ of J)for(let z of _._zod.onattach)z($);if(J.length===0)(v=$._zod).deferred??(v.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let _=(K,W,O)=>{let Y=K1(K),Z;for(let q of W){if(q._zod.def.when){if(!q._zod.def.when(K))continue}else if(Y)continue;let X=K.issues.length,B=q._zod.check(K);if(B instanceof Promise&&O?.async===!1)throw new F4;if(Z||B instanceof Promise)Z=(Z??Promise.resolve()).then(async()=>{if(await B,K.issues.length===X)return;if(!Y)Y=K1(K,X)});else{if(K.issues.length===X)continue;if(!Y)Y=K1(K,X)}}if(Z)return Z.then(()=>{return K});return K},z=(K,W,O)=>{if(K1(K))return K.aborted=!0,K;let Y=_(W,J,O);if(Y instanceof Promise){if(O.async===!1)throw new F4;return Y.then((Z)=>$._zod.parse(Z,O))}return $._zod.parse(Y,O)};$._zod.run=(K,W)=>{if(W.skipChecks)return $._zod.parse(K,W);if(W.direction==="backward"){let Y=$._zod.parse({value:K.value,issues:[]},{...W,skipChecks:!0});if(Y instanceof Promise)return Y.then((Z)=>{return z(Z,K,W)});return z(Y,K,W)}let O=$._zod.parse(K,W);if(O instanceof Promise){if(W.async===!1)throw new F4;return O.then((Y)=>_(Y,J,W))}return _(O,J,W)}}X$($,"~standard",()=>({validate:(_)=>{try{let z=hU($,_);return z.success?{value:z.data}:{issues:z.error?.issues}}catch(z){return q_($,_).then((K)=>K.success?{value:K.data}:{issues:K.error?.issues})}},vendor:"zod",version:1}))}),l1=M("$ZodString",($,U)=>{Y$.init($,U),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??d5($._zod.bag),$._zod.parse=(v,J)=>{if(U.coerce)try{v.value=String(v.value)}catch(_){}if(typeof v.value==="string")return v;return v.issues.push({expected:"string",code:"invalid_type",input:v.value,inst:$}),v}}),V$=M("$ZodStringFormat",($,U)=>{lU.init($,U),l1.init($,U)}),M3=M("$ZodGUID",($,U)=>{U.pattern??(U.pattern=V5),V$.init($,U)}),A3=M("$ZodUUID",($,U)=>{if(U.version){let J={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[U.version];if(J===void 0)throw Error(`Invalid UUID version: "${U.version}"`);U.pattern??(U.pattern=c1(J))}else U.pattern??(U.pattern=c1());V$.init($,U)}),I3=M("$ZodEmail",($,U)=>{U.pattern??(U.pattern=f5),V$.init($,U)}),w3=M("$ZodURL",($,U)=>{V$.init($,U),$._zod.check=(v)=>{try{let J=v.value.trim(),_=new URL(J);if(U.hostname){if(U.hostname.lastIndex=0,!U.hostname.test(_.hostname))v.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:U.hostname.source,input:v.value,inst:$,continue:!U.abort})}if(U.protocol){if(U.protocol.lastIndex=0,!U.protocol.test(_.protocol.endsWith(":")?_.protocol.slice(0,-1):_.protocol))v.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:U.protocol.source,input:v.value,inst:$,continue:!U.abort})}if(U.normalize)v.value=_.href;else v.value=J;return}catch(J){v.issues.push({code:"invalid_format",format:"url",input:v.value,inst:$,continue:!U.abort})}}}),g3=M("$ZodEmoji",($,U)=>{U.pattern??(U.pattern=E5()),V$.init($,U)}),N3=M("$ZodNanoID",($,U)=>{U.pattern??(U.pattern=D5),V$.init($,U)}),S3=M("$ZodCUID",($,U)=>{U.pattern??(U.pattern=S5),V$.init($,U)}),R3=M("$ZodCUID2",($,U)=>{U.pattern??(U.pattern=R5),V$.init($,U)}),T3=M("$ZodULID",($,U)=>{U.pattern??(U.pattern=T5),V$.init($,U)}),y3=M("$ZodXID",($,U)=>{U.pattern??(U.pattern=y5),V$.init($,U)}),C3=M("$ZodKSUID",($,U)=>{U.pattern??(U.pattern=C5),V$.init($,U)}),D3=M("$ZodISODateTime",($,U)=>{U.pattern??(U.pattern=o5(U)),V$.init($,U)}),j3=M("$ZodISODate",($,U)=>{U.pattern??(U.pattern=i5),V$.init($,U)}),V3=M("$ZodISOTime",($,U)=>{U.pattern??(U.pattern=p5(U)),V$.init($,U)}),f3=M("$ZodISODuration",($,U)=>{U.pattern??(U.pattern=j5),V$.init($,U)}),E3=M("$ZodIPv4",($,U)=>{U.pattern??(U.pattern=u5),V$.init($,U),$._zod.bag.format="ipv4"}),u3=M("$ZodIPv6",($,U)=>{U.pattern??(U.pattern=m5),V$.init($,U),$._zod.bag.format="ipv6",$._zod.check=(v)=>{try{new URL(`http://[${v.value}]`)}catch{v.issues.push({code:"invalid_format",format:"ipv6",input:v.value,inst:$,continue:!U.abort})}}}),m3=M("$ZodMAC",($,U)=>{U.pattern??(U.pattern=x5(U.delimiter)),V$.init($,U),$._zod.bag.format="mac"}),x3=M("$ZodCIDRv4",($,U)=>{U.pattern??(U.pattern=h5),V$.init($,U)}),h3=M("$ZodCIDRv6",($,U)=>{U.pattern??(U.pattern=c5),V$.init($,U),$._zod.check=(v)=>{let J=v.value.split("/");try{if(J.length!==2)throw Error();let[_,z]=J;if(!z)throw Error();let K=Number(z);if(`${K}`!==z)throw Error();if(K<0||K>128)throw Error();new URL(`http://[${_}]`)}catch{v.issues.push({code:"invalid_format",format:"cidrv6",input:v.value,inst:$,continue:!U.abort})}}});function c3($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var l3=M("$ZodBase64",($,U)=>{U.pattern??(U.pattern=l5),V$.init($,U),$._zod.bag.contentEncoding="base64",$._zod.check=(v)=>{if(c3(v.value))return;v.issues.push({code:"invalid_format",format:"base64",input:v.value,inst:$,continue:!U.abort})}});function uq($){if(!Cv.test($))return!1;let U=$.replace(/[-_]/g,(J)=>J==="-"?"+":"/"),v=U.padEnd(Math.ceil(U.length/4)*4,"=");return c3(v)}var r3=M("$ZodBase64URL",($,U)=>{U.pattern??(U.pattern=Cv),V$.init($,U),$._zod.bag.contentEncoding="base64url",$._zod.check=(v)=>{if(uq(v.value))return;v.issues.push({code:"invalid_format",format:"base64url",input:v.value,inst:$,continue:!U.abort})}}),i3=M("$ZodE164",($,U)=>{U.pattern??(U.pattern=r5),V$.init($,U)});function mq($,U=null){try{let v=$.split(".");if(v.length!==3)return!1;let[J]=v;if(!J)return!1;let _=JSON.parse(atob(J));if("typ"in _&&_?.typ!=="JWT")return!1;if(!_.alg)return!1;if(U&&(!("alg"in _)||_.alg!==U))return!1;return!0}catch{return!1}}var p3=M("$ZodJWT",($,U)=>{V$.init($,U),$._zod.check=(v)=>{if(mq(v.value,U.alg))return;v.issues.push({code:"invalid_format",format:"jwt",input:v.value,inst:$,continue:!U.abort})}}),o3=M("$ZodCustomStringFormat",($,U)=>{V$.init($,U),$._zod.check=(v)=>{if(U.fn(v.value))return;v.issues.push({code:"invalid_format",format:U.format,input:v.value,inst:$,continue:!U.abort})}}),hv=M("$ZodNumber",($,U)=>{Y$.init($,U),$._zod.pattern=$._zod.bag.pattern??B_,$._zod.parse=(v,J)=>{if(U.coerce)try{v.value=Number(v.value)}catch(K){}let _=v.value;if(typeof _==="number"&&!Number.isNaN(_)&&Number.isFinite(_))return v;let z=typeof _==="number"?Number.isNaN(_)?"NaN":!Number.isFinite(_)?"Infinity":void 0:void 0;return v.issues.push({expected:"number",code:"invalid_type",input:_,inst:$,...z?{received:z}:{}}),v}}),d3=M("$ZodNumberFormat",($,U)=>{v3.init($,U),hv.init($,U)}),Q_=M("$ZodBoolean",($,U)=>{Y$.init($,U),$._zod.pattern=a5,$._zod.parse=(v,J)=>{if(U.coerce)try{v.value=Boolean(v.value)}catch(z){}let _=v.value;if(typeof _==="boolean")return v;return v.issues.push({expected:"boolean",code:"invalid_type",input:_,inst:$}),v}}),cv=M("$ZodBigInt",($,U)=>{Y$.init($,U),$._zod.pattern=n5,$._zod.parse=(v,J)=>{if(U.coerce)try{v.value=BigInt(v.value)}catch(_){}if(typeof v.value==="bigint")return v;return v.issues.push({expected:"bigint",code:"invalid_type",input:v.value,inst:$}),v}}),n3=M("$ZodBigIntFormat",($,U)=>{J3.init($,U),cv.init($,U)}),t3=M("$ZodSymbol",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(typeof _==="symbol")return v;return v.issues.push({expected:"symbol",code:"invalid_type",input:_,inst:$}),v}}),a3=M("$ZodUndefined",($,U)=>{Y$.init($,U),$._zod.pattern=e5,$._zod.values=new Set([void 0]),$._zod.optin="optional",$._zod.optout="optional",$._zod.parse=(v,J)=>{let _=v.value;if(typeof _>"u")return v;return v.issues.push({expected:"undefined",code:"invalid_type",input:_,inst:$}),v}}),s3=M("$ZodNull",($,U)=>{Y$.init($,U),$._zod.pattern=s5,$._zod.values=new Set([null]),$._zod.parse=(v,J)=>{let _=v.value;if(_===null)return v;return v.issues.push({expected:"null",code:"invalid_type",input:_,inst:$}),v}}),e3=M("$ZodAny",($,U)=>{Y$.init($,U),$._zod.parse=(v)=>v}),$z=M("$ZodUnknown",($,U)=>{Y$.init($,U),$._zod.parse=(v)=>v}),Uz=M("$ZodNever",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{return v.issues.push({expected:"never",code:"invalid_type",input:v.value,inst:$}),v}}),_z=M("$ZodVoid",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(typeof _>"u")return v;return v.issues.push({expected:"void",code:"invalid_type",input:_,inst:$}),v}}),vz=M("$ZodDate",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{if(U.coerce)try{v.value=new Date(v.value)}catch(W){}let _=v.value,z=_ instanceof Date;if(z&&!Number.isNaN(_.getTime()))return v;return v.issues.push({expected:"date",code:"invalid_type",input:_,...z?{received:"Invalid Date"}:{},inst:$}),v}});function Nq($,U,v){if($.issues.length)U.issues.push(...c6(v,$.issues));U.value[v]=$.value}var Jz=M("$ZodArray",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(!Array.isArray(_))return v.issues.push({expected:"array",code:"invalid_type",input:_,inst:$}),v;v.value=Array(_.length);let z=[];for(let K=0;K<_.length;K++){let W=_[K],O=U.element._zod.run({value:W,issues:[]},J);if(O instanceof Promise)z.push(O.then((Y)=>Nq(Y,v,K)));else Nq(O,v,K)}if(z.length)return Promise.all(z).then(()=>v);return v}});function xv($,U,v,J,_){if($.issues.length){if(_&&!(v in J))return;U.issues.push(...c6(v,$.issues))}if($.value===void 0){if(v in J)U.value[v]=void 0}else U.value[v]=$.value}function xq($){let U=Object.keys($.shape);for(let J of U)if(!$.shape?.[J]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${J}": expected a Zod schema`);let v=A5($.shape);return{...$,keys:U,keySet:new Set(U),numKeys:U.length,optionalKeys:new Set(v)}}function hq($,U,v,J,_,z){let K=[],W=_.keySet,O=_.catchall._zod,Y=O.def.type,Z=O.optout==="optional";for(let q in U){if(W.has(q))continue;if(Y==="never"){K.push(q);continue}let X=O.run({value:U[q],issues:[]},J);if(X instanceof Promise)$.push(X.then((B)=>xv(B,v,q,U,Z)));else xv(X,v,q,U,Z)}if(K.length)v.issues.push({code:"unrecognized_keys",keys:K,input:U,inst:z});if(!$.length)return v;return Promise.all($).then(()=>{return v})}var cq=M("$ZodObject",($,U)=>{if(Y$.init($,U),!Object.getOwnPropertyDescriptor(U,"shape")?.get){let W=U.shape;Object.defineProperty(U,"shape",{get:()=>{let O={...W};return Object.defineProperty(U,"shape",{value:O}),O}})}let J=fU(()=>xq(U));X$($._zod,"propValues",()=>{let W=U.shape,O={};for(let Y in W){let Z=W[Y]._zod;if(Z.values){O[Y]??(O[Y]=new Set);for(let q of Z.values)O[Y].add(q)}}return O});let _=h1,z=U.catchall,K;$._zod.parse=(W,O)=>{K??(K=J.value);let Y=W.value;if(!_(Y))return W.issues.push({expected:"object",code:"invalid_type",input:Y,inst:$}),W;W.value={};let Z=[],q=K.shape;for(let X of K.keys){let B=q[X],L=B._zod.optout==="optional",F=B._zod.run({value:Y[X],issues:[]},O);if(F instanceof Promise)Z.push(F.then((k)=>xv(k,W,X,Y,L)));else xv(F,W,X,Y,L)}if(!z)return Z.length?Promise.all(Z).then(()=>W):W;return hq(Z,Y,W,O,J.value,$)}}),zz=M("$ZodObjectJIT",($,U)=>{cq.init($,U);let v=$._zod.parse,J=fU(()=>xq(U)),_=(X)=>{let B=new Vv(["shape","payload","ctx"]),L=J.value,F=(b)=>{let V=Mv(b);return`shape[${V}]._zod.run({ value: input[${V}], issues: [] }, ctx)`};B.write("const input = payload.value;");let k=Object.create(null),H=0;for(let b of L.keys)k[b]=`key_${H++}`;B.write("const newResult = {};");for(let b of L.keys){let V=k[b],E=Mv(b),I=X[b]?._zod?.optout==="optional";if(B.write(`const ${V} = ${F(b)};`),I)B.write(`
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
payload.issues = payload.issues.concat(${V}.issues.map(iss => ({
|
|
112
|
+
`.substring(0,r);return n+s+o}function nk(e){return e!=null&&(typeof e==="string"||e.nodeType&&(e.nodeType===1||e.nodeType===9||e.nodeType===11))}function Ps(){let e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).cloneRange():null;sn("Link URL","https://example.com").then((n)=>{if(!n)return;let o=n.trim().toLowerCase();if(o.startsWith("javascript:")||o.startsWith("data:"))return;if(t){let r=window.getSelection();r?.removeAllRanges(),r?.addRange(t)}document.execCommand("createLink",!1,n)})}function ym(){let e=window.getSelection();if(!e||e.rangeCount===0)return;let t=e.getRangeAt(0);if(t.collapsed)return;let n=t.toString(),o=document.createElement("code");o.textContent=n,t.deleteContents(),t.insertNode(o);let r=document.createRange();r.setStartAfter(o),r.setEndAfter(o),e.removeAllRanges(),e.addRange(r)}var Ns=8,ok=[{kind:"exec",command:"bold",icon:"B",title:`Bold (${Ze("B")})`},{kind:"exec",command:"italic",icon:"I",title:`Italic (${Ze("I")})`},{kind:"exec",command:"strikeThrough",icon:"S",title:"Strikethrough"},{kind:"code",icon:"{ }",title:"Inline code",dividerBefore:!0},{kind:"block",tag:"H1",icon:"H1",title:"Heading 1",dividerBefore:!0},{kind:"block",tag:"H2",icon:"H2",title:"Heading 2"},{kind:"block",tag:"H3",icon:"H3",title:"Heading 3"},{kind:"block",tag:"P",icon:"¶",title:"Paragraph"},{kind:"block",tag:"BLOCKQUOTE",icon:"❝",title:"Quote",dividerBefore:!0},{kind:"exec",command:"insertUnorderedList",icon:"•",title:"Bullet list"},{kind:"exec",command:"insertOrderedList",icon:"1.",title:"Numbered list"},{kind:"link",icon:"\uD83D\uDD17",title:`Link (${Ze("K")})`,dividerBefore:!0}];function rk(e){switch(e.kind){case"exec":document.execCommand(e.command);return;case"block":document.execCommand("formatBlock",!1,e.tag);return;case"code":ym();return;case"link":Ps();return}}function xm({hostRef:e,onChange:t}){let[n,o]=L(!1),[r,s]=L({top:0,left:0}),[a,c]=L(0),l=N(null),u=N(null),d=M(()=>{let f=e.current;if(!f){o(!1);return}let y=window.getSelection();if(!y||y.rangeCount===0||y.isCollapsed){o(!1);return}let v=y.getRangeAt(0);if(!f.contains(v.commonAncestorContainer)){o(!1);return}let x=v.getBoundingClientRect();if(x.width===0&&x.height===0){o(!1);return}let h=a||420,g=Math.max(Ns,Math.min(x.left+x.width/2-h/2,window.innerWidth-h-Ns)),b=Math.max(Ns,x.top-Ns-36);s({top:b,left:g}),o(!0)},[e,a]),p=M(()=>{if(u.current!==null)return;u.current=requestAnimationFrame(()=>{u.current=null,d()})},[d]);D(()=>(document.addEventListener("selectionchange",p),window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{if(document.removeEventListener("selectionchange",p),window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),u.current!==null)cancelAnimationFrame(u.current)}),[p]),Ui(()=>{if(!n)return;let f=l.current;if(!f)return;let y=f.getBoundingClientRect().width;if(y&&Math.abs(y-a)>1)c(y)},[n,a]);let m=M((f)=>{rk(f),t(),d()},[t,d]);if(!n)return null;return i("div",{ref:l,class:"md-inline-format-bar",style:{top:`${r.top}px`,left:`${r.left}px`},onMouseDown:(f)=>f.preventDefault(),children:ok.flatMap((f,y)=>{let v=i("button",{type:"button",class:"md-inline-format-btn",title:f.title,onClick:()=>m(f),children:f.icon},`btn-${y}`,!1,void 0,this);return f.dividerBefore?[i("span",{class:"md-inline-format-divider"},`div-${y}`,!1,void 0,this),v]:[v]})},void 0,!1,void 0,this)}var xl=null;function ik(){if(xl)return xl;let e=new Gr({headingStyle:"atx",codeBlockStyle:"fenced",emDelimiter:"*",bulletListMarker:"-"});return e.use(bm.gfm),xl=e,e}function wm({initialHtml:e,className:t,onChange:n,onSave:o}){let r=N(null),s=N(e);D(()=>{let m=r.current;if(!m)return;m.innerHTML=s.current;for(let f of m.querySelectorAll('input[type="checkbox"][disabled]'))f.removeAttribute("disabled")},[]);let a=M(()=>{let m=r.current;if(!m)return"";return ik().turndown(m.innerHTML)},[]),c=M(()=>{n(a())},[n,a]),l=M(()=>{let m=r.current;if(!m||!m.isConnected||m.innerHTML==="")return;o?.(a())},[o,a]),u=M((m)=>{if(!(m.metaKey||m.ctrlKey))return;if(m.key==="s"){m.preventDefault(),l();return}if(m.key==="b"){m.preventDefault(),document.execCommand("bold"),c();return}if(m.key==="i"){m.preventDefault(),document.execCommand("italic"),c();return}if(m.key==="k")m.preventDefault(),Ps(),c()},[c,l]),d=M((m)=>{let f=m.target;if(f instanceof HTMLInputElement&&f.type==="checkbox")f.toggleAttribute("checked",f.checked),c()},[c]),p=M((m)=>{let f=m.clipboardData?.getData("text/plain");if(f==null)return;m.preventDefault(),document.execCommand("insertText",!1,f),c()},[c]);return i(ye,{children:[i("div",{ref:r,class:t,contentEditable:!0,spellcheck:!1,onInput:c,onKeyDown:u,onPaste:p,onClick:d,onBlur:l},void 0,!1,void 0,this),i(xm,{hostRef:r,onChange:c},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function bl({html:e,className:t,style:n,onTaskToggle:o}){let r=N(null),s=N(o);return s.current=o,D(()=>{let c=r.current;if(!c)return;if(c.replaceChildren(),!e)return;let l=document.createElement("template");if(l.innerHTML=e,c.append(l.content.cloneNode(!0)),s.current)for(let u of c.querySelectorAll('input[type="checkbox"][disabled]'))u.removeAttribute("disabled")},[e]),i("div",{ref:r,class:t,style:n,onClick:o?(c)=>{let l=s.current,u=r.current;if(!u||!l)return;let d=c.target,p=null;if(d instanceof HTMLInputElement&&d.type==="checkbox")p=d;else{let y=d.closest("li")?.querySelector(':scope > input[type="checkbox"]');if(y&&c.clientX<=y.getBoundingClientRect().right+6)p=y}if(!p)return;c.stopPropagation();let m=[...u.querySelectorAll('input[type="checkbox"]')].indexOf(p);if(m>=0)l(m)}:void 0},void 0,!1,void 0,this)}function sk(e,t){let n=-1;return e.replace(/^(\s*(?:[-*+]|\d+[.)])\s+\[)([ xX])(\])/gm,(o,r,s,a)=>{if(n+=1,n!==t)return o;return`${r}${s===" "?"x":" "}${a}`})}function Rs({node:e,expanded:t=!1}){let n=e.data.path,[o,r]=L(""),[s,a]=L(""),[c,l]=L(!1),[u,d]=L(!1),[p,m]=L(!1),[f,y]=L(!1),v=N(null),x=N(null),h=N(""),g=N(null),b=e.data.reviewActive;D(()=>{let j=!1;return(async()=>{let I;if(n){let U=await Dr(n);if(j)return;I=U.content}else if(e.data.content)I=e.data.content;else{l(!0);return}r(I);let H=await an(I);if(j)return;a(H),l(!0),re(e.id,{content:I,rendered:H})})(),()=>{j=!0}},[n,e.id,e.data.content]);let O=M(async(j)=>{let I=j.target.value;r(I),y(!0);let H=await an(I);a(H)},[]),F=M(async(j)=>{if(!n){let H=await an(j);a(H),y(!1),re(e.id,{content:j,rendered:H}),await ft(e.id,{content:j,data:{rendered:H}});return}m(!0);let I=await Lp(n,j);if(m(!1),I.ok){let H=await an(j);a(H),y(!1),re(e.id,{content:j,rendered:H,savedAt:I.updatedAt}),await ft(e.id,{content:j,data:{rendered:H,savedAt:I.updatedAt}})}},[n,e.id]),_=M(async()=>{if(!f)return;await F(o)},[f,o,F]),k=M((j)=>{if((j.metaKey||j.ctrlKey)&&j.key==="s"){j.preventDefault(),_();return}let I=v.current;if(I&&Zf(j,I))return;if(I&&j.key==="Tab")j.preventDefault(),jf(I,j.shiftKey)},[_]);g.current=F;let T=M((j)=>{if(r(j),y(!0),h.current=j,x.current!==null)window.clearTimeout(x.current);x.current=window.setTimeout(()=>{x.current=null,F(j)},800)},[F]),P=M((j)=>{if(r(j),h.current=j,x.current!==null)window.clearTimeout(x.current),x.current=null;F(j)},[F]);D(()=>()=>{if(x.current===null)return;window.clearTimeout(x.current),x.current=null;let j=g.current;if(j)j(h.current)},[e.id]);let Z=b?i("div",{style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-ok-10)",color:"var(--c-ok)",borderBottom:"1px solid var(--c-ok-20)",textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600},children:"Review active"},void 0,!1,void 0,this):null;if(u&&t)return i("div",{class:"md-editor-expanded",onKeyDown:k,children:[i("div",{class:"md-editor-toolbar",children:[i("button",{type:"button",class:"md-toolbar-btn",onClick:()=>d(!1),children:"← Back to document"},void 0,!1,void 0,this),i("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[n&&i("span",{class:"md-toolbar-path",children:n.split("/").pop()},void 0,!1,void 0,this),i("button",{type:"button",class:`md-toolbar-btn${f?" md-toolbar-btn-primary":""}`,onClick:_,disabled:!f||p,children:p?"Saving…":f?"Save":"Saved"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"md-editor-split",children:[i("div",{style:{flex:1,position:"relative",display:"flex",flexDirection:"column"},children:[i("textarea",{ref:v,value:o,onInput:O,spellcheck:!1},void 0,!1,void 0,this),i(sl,{textareaRef:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(bl,{html:s,className:"md-preview"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(u)return i("div",{class:"md-editor-split",style:{height:"100%"},onKeyDown:k,children:[i("div",{style:{flex:1,position:"relative",display:"flex",flexDirection:"column"},children:[i("textarea",{ref:v,value:o,onInput:O,spellcheck:!1},void 0,!1,void 0,this),i(sl,{textareaRef:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(bl,{html:s,className:"md-preview"},void 0,!1,void 0,this),i("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[i("button",{type:"button",onClick:()=>d(!1),style:{padding:"4px 10px",fontSize:"11px",background:"var(--c-input-bg)",border:"1px solid var(--c-line)",borderRadius:"6px",color:"var(--c-text-soft)",cursor:"pointer"},children:"Document"},void 0,!1,void 0,this),i("button",{type:"button",onClick:_,disabled:!f||p,style:{padding:"4px 10px",fontSize:"11px",background:f?"var(--c-accent-25)":"var(--c-input-bg)",border:`1px solid ${f?"var(--c-accent)":"var(--c-line)"}`,borderRadius:"6px",color:f?"var(--c-text)":"var(--c-dim)",cursor:f?"pointer":"default"},children:p?"Saving…":f?"Save":"Saved"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(t)return i("div",{style:{height:"100%",position:"relative"},children:[Z,i("div",{class:"md-reader",children:c?i(wm,{initialHtml:s||"<p><br></p>",className:"md-reader-content md-reader-editable",onChange:T,onSave:P},e.id,!1,void 0,this):i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"24px"},children:"Loading…"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("button",{type:"button",class:"md-edit-fab",onClick:()=>d(!0),children:"</> Source"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("div",{style:{height:"100%",position:"relative"},children:[Z,i(bl,{html:s,style:{padding:s?"0":"12px",color:s?void 0:"var(--c-dim)"},onTaskToggle:(j)=>{let I=sk(o,j);if(I!==o)P(I)}},void 0,!1,void 0,this),!c&&i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"Loading…"},void 0,!1,void 0,this),c&&!s&&i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"Empty node"},void 0,!1,void 0,this),i("button",{type:"button",class:"md-edit-btn",onClick:()=>Qt(e.id),children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $s="pmx-canvas-ax",Ms="pmx-canvas-ax-ack",Ot="pmx-canvas-html-node",Os="pmx-canvas-ext-app-alive",wl="pmx-canvas-ext-app-paint-probe";function _m(e,t){switch(e){case"html":return typeof t.html==="string"&&t.html.length>0||typeof t.content==="string"&&t.content.length>0;case"mermaid":return typeof t.content==="string"&&t.content.trim().length>0;case"json-render":case"graph":return!0;case"mcp-app":return t.viewerType==="web-artifact"&&typeof t.path==="string"&&t.path.length>0||typeof t.url==="string"&&t.url.length>0;case"webpage":return typeof t.url==="string"&&t.url.length>0;default:return!1}}var _l="allow-scripts allow-popups allow-popups-to-escape-sandbox";function nr(e){let t=5381;for(let n=0;n<e.length;n+=1)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Xr(e,t={}){let n=new URLSearchParams;if(n.set("theme",t.theme??Ge.value),t.themeToken)n.set("themeToken",t.themeToken);if(t.present)n.set("present","1");if(t.presentToken)n.set("presentToken",t.presentToken);if(t.v)n.set("v",t.v);if(t.axToken)n.set("axToken",t.axToken);if(t.frameToken)n.set("frameToken",t.frameToken);return`/api/canvas/surface/${encodeURIComponent(e)}?${n.toString()}`}function Ls(e){return _m(e.type,e.data)}async function Ds(e){let t=Xr(e.id);if(!(await Hp(e.id,t)).opened)window.open(t,"_blank","noopener")}var ak={markdown:{width:360,height:180},context:{width:360,height:180},file:{width:360,height:200},diff:{width:420,height:240},mermaid:{width:360,height:240},status:{width:280,height:120},ledger:{width:320,height:200},image:{width:240,height:180},html:{width:420,height:280},webpage:{width:420,height:280},"json-render":{width:420,height:280},graph:{width:420,height:280},"mcp-app":{width:480,height:320}};function Sm(e){return ak[e]}var or=37,ck=600,lk=1400,uk=24;function dk(e){return e.type==="html"||e.type==="mermaid"||e.type==="json-render"||e.type==="graph"||e.type==="mcp-app"||e.type==="webpage"}function pk(e){if(e.type==="html")return e.data.presentation!==!0;if(e.type==="mermaid")return!0;if(e.type==="json-render"||e.type==="graph")return!0;if(e.type==="mcp-app")return e.data.viewerType==="web-artifact";return!1}function km(e){return e.collapsed===!0||e.data.strictSize===!0||e.data.userResized===!0||e.type==="group"}function Sl(e){return!km(e)&&!dk(e)}function Cm(e,t){if(!Sl(e)||t<=0)return null;let n=Math.min(t+or,ck),o=Sm(e.type);return o?Math.max(n,o.height):n}function kl(e){return pk(e)&&!km(e)}function Tm(e,t){if(!kl(e)||t<=0)return null;let n=Math.min(t+or+uk,lk);return n>e.size.height+8?n:null}function rr(e,t,n){let o=N(e);o.current=e;let r=N(null);D(()=>{if(!n)return;function s(a){if(a.source!==t.current?.contentWindow)return;let c=a.data;if(!c||c.source!=="pmx-canvas-frame"||c.type!=="content-height"||c.token!==n)return;let l=o.current,u=typeof c.height==="number"?c.height:0,d=Tm(l,u);if(d===null)return;if(Jo(l.id,{width:l.size.width,height:d}),r.current!==null)window.clearTimeout(r.current);r.current=window.setTimeout(()=>{Je({recordHistory:!1}),r.current=null},300)}return window.addEventListener("message",s),()=>{if(window.removeEventListener("message",s),r.current!==null)window.clearTimeout(r.current),r.current=null}},[e.id,n])}function fk(e){try{return new URL(e,window.location.origin).origin===window.location.origin}catch{return!1}}function ir(e){let t=ht.value,[n,o]=L(null),r=Boolean(e)&&fk(e),s=t==="srcdoc"&&r;if(D(()=>{if(!s)return;let a=!1;return fetch(`${e}${e.includes("?")?"&":"?"}inline-assets=1`,{credentials:"same-origin"}).then((c)=>c.ok?c.text():Promise.reject(Error(`HTTP ${c.status}`))).then((c)=>{if(!a)o({url:e,html:c})}).catch((c)=>{if(console.error("[surface-frame] srcdoc fetch failed, falling back to src:",e,c),!a)o({url:e,html:""})}),()=>{a=!0}},[s,e]),!e)return{};if(!s)return t===null&&r?{}:{src:e};if(n)return n.html?{srcdoc:n.html}:{src:n.url};return{}}function Fs({node:e,expanded:t=!1}){let n=N(null),o=Ge.value,r=Ie(()=>`theme-${crypto.randomUUID()}`,[]),s=Ie(()=>`frame-${crypto.randomUUID()}`,[]),a=typeof e.data.content==="string"?e.data.content:"",c=Ie(()=>nr(a),[a]),l=Ie(()=>a?Xr(e.id,{theme:o,themeToken:r,v:c,frameToken:s}):"",[a,r,c,e.id,s]),u=ir(l);rr(e,n,t?"":s);let d=()=>{n.current?.contentWindow?.postMessage({source:Ot,type:"theme-update",token:r,theme:o},"*")};if(D(d,[o,r]),!a)return i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No diagram source set"},void 0,!1,void 0,this);return i("iframe",{ref:n,class:"html-node-frame",title:typeof e.data.title==="string"?e.data.title:"Mermaid diagram",sandbox:"allow-scripts",...u,onLoad:d,style:{width:"100%",height:"100%",minHeight:t?"70vh":"300px",border:"none",background:"var(--c-bg)",borderRadius:"6px",display:"block"}},void 0,!1,void 0,this)}var Cl=["dark","light","high-contrast","midnight","sepia","arctic","ember","forest","volt"];function Kr(e){return typeof e==="string"&&Cl.includes(e)}function Tl(e,t="dark"){return Kr(e)?e:t}var sr={dark:{label:"Dark",scheme:"dark",swatchBg:"#081524",swatchAccent:"#4BBCFF"},light:{label:"Light",scheme:"light",swatchBg:"#F4EFE6",swatchAccent:"#1A7ABF"},"high-contrast":{label:"High contrast",scheme:"dark",swatchBg:"#000000",swatchAccent:"#00ffff"},midnight:{label:"Midnight",scheme:"dark",swatchBg:"#0A0D1C",swatchAccent:"#8B96FF"},sepia:{label:"Sepia",scheme:"light",swatchBg:"#F2E7D5",swatchAccent:"#B4632C"},arctic:{label:"Arctic",scheme:"dark",swatchBg:"#20242E",swatchAccent:"#7FC8DE"},ember:{label:"Ember",scheme:"dark",swatchBg:"#0B0B0C",swatchAccent:"#F34E1C"},forest:{label:"Forest",scheme:"dark",swatchBg:"#0C1712",swatchAccent:"#5CCF8F"},volt:{label:"Volt",scheme:"dark",swatchBg:"#0B0D0B",swatchAccent:"#DFDFC1"}};function ar(e){return sr[Tl(e)].scheme}var xP=Object.freeze({status:"aborted"});function A(e,t,n){function o(c,l){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);let u=a.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){let m=d[p];if(!(m in c))c[m]=u[m].bind(c)}}let r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function a(c){var l;let u=n?.Parent?new s:this;o(u,c),(l=u._zod).deferred??(l.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:(c)=>{if(n?.Parent&&c instanceof n.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var bP=Symbol("zod_brand");class mn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Jr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}var js={};function Lt(e){if(e)Object.assign(js,e);return js}function Hs(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function Al(e,t="|"){return e.map((n)=>Nl(n)).join(t)}function Yr(e,t){if(typeof t==="bigint")return t.toString();return t}function Qr(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw Error("cached value already set")}}}function Bs(e){return e===null||e===void 0}function Us(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Am(e,t){let n=(e.toString().split(".")[1]||"").length,o=t.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let l=o.match(/\d?e-(\d?)/);if(l?.[1])r=Number.parseInt(l[1])}let s=n>r?n:r,a=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return a%c/10**s}var Em=Symbol("evaluating");function we(e,t,n){let o=void 0;Object.defineProperty(e,t,{get(){if(o===Em)return;if(o===void 0)o=Em,o=n();return o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function mo(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function On(...e){let t={};for(let n of e){let o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Il(e){return JSON.stringify(e)}function Im(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var zl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var zm=Qr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ho(e){if(cr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(cr(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Pl(e){if(ho(e))return{...e};if(Array.isArray(e))return[...e];return e}var Pm=new Set(["string","number","symbol"]);function Ln(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tn(e,t,n){let o=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)o._zod.parent=e;return o}function J(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Nl(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Nm(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Rm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function mk(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=On(e._zod.def,{get shape(){let a={};for(let c in t){if(!(c in n.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;a[c]=n.shape[c]}return mo(this,"shape",a),a},checks:[]});return tn(e,s)}function hk(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=On(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let c in t){if(!(c in n.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete a[c]}return mo(this,"shape",a),a},checks:[]});return tn(e,s)}function gk(e,t){if(!ho(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let s=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(s,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=On(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return mo(this,"shape",s),s}});return tn(e,r)}function vk(e,t){if(!ho(t))throw Error("Invalid input to safeExtend: expected a plain object");let n=On(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return mo(this,"shape",o),o}});return tn(e,n)}function yk(e,t){let n=On(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return mo(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return tn(e,n)}function xk(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=On(t._zod.def,{get shape(){let c=t._zod.def.shape,l={...c};if(n)for(let u in n){if(!(u in c))throw Error(`Unrecognized key: "${u}"`);if(!n[u])continue;l[u]=e?new e({type:"optional",innerType:c[u]}):c[u]}else for(let u in c)l[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return mo(this,"shape",l),l},checks:[]});return tn(t,a)}function bk(e,t,n){let o=On(t._zod.def,{get shape(){let r=t._zod.def.shape,s={...r};if(n)for(let a in n){if(!(a in s))throw Error(`Unrecognized key: "${a}"`);if(!n[a])continue;s[a]=new e({type:"nonoptional",innerType:r[a]})}else for(let a in r)s[a]=new e({type:"nonoptional",innerType:r[a]});return mo(this,"shape",s),s}});return tn(t,o)}function go(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Dn(e,t){return t.map((n)=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function Zs(e){return typeof e==="string"?e:e?.message}function nn(e,t,n){let o={...e,path:e.path??[]};if(!e.message){let r=Zs(e.inst?._zod.def?.error?.(e))??Zs(t?.error?.(e))??Zs(n.customError?.(e))??Zs(n.localeError?.(e))??"Invalid input";o.message=r}if(delete o.inst,delete o.continue,!t?.reportInput)delete o.input;return o}function Ws(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function $m(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function vo(...e){let[t,n,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:o};return{...t}}var Mm=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Yr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},qs=A("$ZodError",Mm),Rl=A("$ZodError",Mm,{Parent:Error});function Om(e,t=(n)=>n.message){let n={},o=[];for(let r of e.issues)if(r.path.length>0)n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r));else o.push(t(r));return{formErrors:o,fieldErrors:n}}function Lm(e,t=(n)=>n.message){let n={_errors:[]},o=(r)=>{for(let s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>o({issues:a}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let a=n,c=0;while(c<s.path.length){let l=s.path[c];if(c!==s.path.length-1)a[l]=a[l]||{_errors:[]};else a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(s));a=a[l],c++}}};return o(e),n}var Vs=(e)=>(t,n,o,r)=>{let s=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new mn;if(a.issues.length){let c=new(r?.Err??e)(a.issues.map((l)=>nn(l,s,Lt())));throw zl(c,r?.callee),c}return a.value};var Gs=(e)=>async(t,n,o,r)=>{let s=o?Object.assign(o,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(r?.Err??e)(a.issues.map((l)=>nn(l,s,Lt())));throw zl(c,r?.callee),c}return a.value};var ei=(e)=>(t,n,o)=>{let r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new mn;return s.issues.length?{success:!1,error:new(e??qs)(s.issues.map((a)=>nn(a,r,Lt())))}:{success:!0,data:s.value}},ti=ei(Rl),ni=(e)=>async(t,n,o)=>{let r=o?Object.assign(o,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((a)=>nn(a,r,Lt())))}:{success:!0,data:s.value}},Xs=ni(Rl),Dm=(e)=>(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Vs(e)(t,n,r)};var Fm=(e)=>(t,n,o)=>Vs(e)(t,n,o);var jm=(e)=>async(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Gs(e)(t,n,r)};var Zm=(e)=>async(t,n,o)=>Gs(e)(t,n,o);var Hm=(e)=>(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ei(e)(t,n,r)};var Bm=(e)=>(t,n,o)=>ei(e)(t,n,o);var Um=(e)=>async(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ni(e)(t,n,r)};var Wm=(e)=>async(t,n,o)=>ni(e)(t,n,o);var qm=/^[cC][^\s-]{8,}$/,Vm=/^[0-9a-z]+$/,Gm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xm=/^[0-9a-vA-V]{20}$/,Km=/^[A-Za-z0-9]{27}$/,Jm=/^[a-zA-Z0-9_-]{21}$/,Ym=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Qm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$l=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var eh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _k="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function th(){return new RegExp(_k,"u")}var nh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,oh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var rh=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ih=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ml=/^[A-Za-z0-9_-]*$/;var ah=/^\+[1-9]\d{6,14}$/,ch="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",lh=new RegExp(`^${ch}$`);function uh(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function dh(e){return new RegExp(`^${uh(e)}$`)}function ph(e){let t=uh({precision:e.precision}),n=["Z"];if(e.local)n.push("");if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${n.join("|")})`;return new RegExp(`^${ch}T(?:${o})$`)}var fh=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var mh=/^-?\d+$/,Ol=/^-?\d+(?:\.\d+)?$/,hh=/^(?:true|false)$/i,gh=/^null$/i;var vh=/^undefined$/i;var yh=/^[^A-Z]*$/,xh=/^[^a-z]*$/;var it=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bh={number:"number",bigint:"bigint",object:"date"},Ll=A("$ZodCheckLessThan",(e,t)=>{it.init(e,t);let n=bh[typeof t.value];e._zod.onattach.push((o)=>{let r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)r.maximum=t.value;else r.exclusiveMaximum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dl=A("$ZodCheckGreaterThan",(e,t)=>{it.init(e,t);let n=bh[typeof t.value];e._zod.onattach.push((o)=>{let r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)r.minimum=t.value;else r.exclusiveMinimum=t.value}),e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wh=A("$ZodCheckMultipleOf",(e,t)=>{it.init(e,t),e._zod.onattach.push((n)=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?n.value%t.value===BigInt(0):Am(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),_h=A("$ZodCheckNumberFormat",(e,t)=>{it.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),o=n?"int":"number",[r,s]=Rm[t.format];e._zod.onattach.push((a)=>{let c=a._zod.bag;if(c.format=t.format,c.minimum=r,c.maximum=s,n)c.pattern=mh}),e._zod.check=(a)=>{let c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(c<r)a.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort});if(c>s)a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Sh=A("$ZodCheckMaxLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=(o)=>{let r=o.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push((o)=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<r)o._zod.bag.maximum=t.maximum}),e._zod.check=(o)=>{let r=o.value;if(r.length<=t.maximum)return;let a=Ws(r);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kh=A("$ZodCheckMinLength",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=(o)=>{let r=o.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push((o)=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>r)o._zod.bag.minimum=t.minimum}),e._zod.check=(o)=>{let r=o.value;if(r.length>=t.minimum)return;let a=Ws(r);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ch=A("$ZodCheckLengthEquals",(e,t)=>{var n;it.init(e,t),(n=e._zod.def).when??(n.when=(o)=>{let r=o.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push((o)=>{let r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=(o)=>{let r=o.value,s=r.length;if(s===t.length)return;let a=Ws(r),c=s>t.length;o.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),oi=A("$ZodCheckStringFormat",(e,t)=>{var n,o;if(it.init(e,t),e._zod.onattach.push((r)=>{let s=r._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(n=e._zod).check??(n.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),Th=A("$ZodCheckRegex",(e,t)=>{oi.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Eh=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=yh),oi.init(e,t)}),Ah=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xh),oi.init(e,t)}),Ih=A("$ZodCheckIncludes",(e,t)=>{it.init(e,t);let n=Ln(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push((r)=>{let s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.includes(t.includes,t.position))return;r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),zh=A("$ZodCheckStartsWith",(e,t)=>{it.init(e,t);let n=new RegExp(`^${Ln(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((o)=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ph=A("$ZodCheckEndsWith",(e,t)=>{it.init(e,t);let n=new RegExp(`.*${Ln(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((o)=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var Nh=A("$ZodCheckOverwrite",(e,t)=>{it.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Fl{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
113
|
+
`).filter((s)=>s),o=Math.min(...n.map((s)=>s.length-s.trimStart().length)),r=n.map((s)=>s.slice(o)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of r)this.content.push(s)}compile(){let e=Function,t=this?.args,o=[...(this?.content??[""]).map((r)=>` ${r}`)];return new e(...t,o.join(`
|
|
114
|
+
`))}}var $h={major:4,minor:3,patch:6};var $e=A("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$h;let o=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))o.unshift(e);for(let r of o)for(let s of r._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(a,c,l)=>{let u=go(a),d;for(let p of c){if(p._zod.def.when){if(!p._zod.def.when(a))continue}else if(u)continue;let m=a.issues.length,f=p._zod.check(a);if(f instanceof Promise&&l?.async===!1)throw new mn;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await f,a.issues.length===m)return;if(!u)u=go(a,m)});else{if(a.issues.length===m)continue;if(!u)u=go(a,m)}}if(d)return d.then(()=>a);return a},s=(a,c,l)=>{if(go(a))return a.aborted=!0,a;let u=r(c,o,l);if(u instanceof Promise){if(l.async===!1)throw new mn;return u.then((d)=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((d)=>s(d,a,c));return s(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new mn;return l.then((u)=>r(u,o,c))}return r(l,o,c)}}we(e,"~standard",()=>({validate:(r)=>{try{let s=ti(e,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Xs(e,r).then((a)=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Qs=A("$ZodString",(e,t)=>{$e.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fh(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),De=A("$ZodStringFormat",(e,t)=>{oi.init(e,t),Qs.init(e,t)}),Bh=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Qm),De.init(e,t)}),Uh=A("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$l(o))}else t.pattern??(t.pattern=$l());De.init(e,t)}),Wh=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=eh),De.init(e,t)}),qh=A("$ZodURL",(e,t)=>{De.init(e,t),e._zod.check=(n)=>{try{let o=n.value.trim(),r=new URL(o);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(r.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})}if(t.normalize)n.value=r.href;else n.value=o;return}catch(o){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Vh=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=th()),De.init(e,t)}),Gh=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jm),De.init(e,t)}),Xh=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=qm),De.init(e,t)}),Kh=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Vm),De.init(e,t)}),Jh=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Gm),De.init(e,t)}),Yh=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Xm),De.init(e,t)}),Qh=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Km),De.init(e,t)}),eg=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ph(t)),De.init(e,t)}),tg=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lh),De.init(e,t)}),ng=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=dh(t)),De.init(e,t)}),og=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ym),De.init(e,t)}),rg=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=nh),De.init(e,t),e._zod.bag.format="ipv4"}),ig=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=oh),De.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(n)=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}});var sg=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=rh),De.init(e,t)}),ag=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ih),De.init(e,t),e._zod.check=(n)=>{let o=n.value.split("/");try{if(o.length!==2)throw Error();let[r,s]=o;if(!s)throw Error();let a=Number(s);if(`${a}`!==s)throw Error();if(a<0||a>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function cg(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var lg=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=sh),De.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(n)=>{if(cg(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ck(e){if(!Ml.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return cg(n)}var ug=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ml),De.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(n)=>{if(Ck(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),dg=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ah),De.init(e,t)});function Tk(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[o]=n;if(!o)return!1;let r=JSON.parse(atob(o));if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&(!("alg"in r)||r.alg!==t))return!1;return!0}catch{return!1}}var pg=A("$ZodJWT",(e,t)=>{De.init(e,t),e._zod.check=(n)=>{if(Tk(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Zl=A("$ZodNumber",(e,t)=>{$e.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ol,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch(a){}let r=n.value;if(typeof r==="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r==="number"?Number.isNaN(r)?"NaN":!Number.isFinite(r)?"Infinity":void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),fg=A("$ZodNumberFormat",(e,t)=>{_h.init(e,t),Zl.init(e,t)}),mg=A("$ZodBoolean",(e,t)=>{$e.init(e,t),e._zod.pattern=hh,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let r=n.value;if(typeof r==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}});var hg=A("$ZodUndefined",(e,t)=>{$e.init(e,t),e._zod.pattern=vh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{let r=n.value;if(typeof r>"u")return n;return n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),gg=A("$ZodNull",(e,t)=>{$e.init(e,t),e._zod.pattern=gh,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{let r=n.value;if(r===null)return n;return n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}});var vg=A("$ZodUnknown",(e,t)=>{$e.init(e,t),e._zod.parse=(n)=>n}),yg=A("$ZodNever",(e,t)=>{$e.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Mh(e,t,n){if(e.issues.length)t.issues.push(...Dn(n,e.issues));t.value[n]=e.value}var xg=A("$ZodArray",(e,t)=>{$e.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let s=[];for(let a=0;a<r.length;a++){let c=r[a],l=t.element._zod.run({value:c,issues:[]},o);if(l instanceof Promise)s.push(l.then((u)=>Mh(u,n,a)));else Mh(l,n,a)}if(s.length)return Promise.all(s).then(()=>n);return n}});function Ys(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...Dn(n,e.issues))}if(e.value===void 0){if(n in o)t.value[n]=void 0}else t.value[n]=e.value}function bg(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${o}": expected a Zod schema`);let n=Nm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wg(e,t,n,o,r,s){let a=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,d=l.optout==="optional";for(let p in t){if(c.has(p))continue;if(u==="never"){a.push(p);continue}let m=l.run({value:t[p],issues:[]},o);if(m instanceof Promise)e.push(m.then((f)=>Ys(f,n,p,t,d)));else Ys(m,n,p,t,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s});if(!e.length)return n;return Promise.all(e).then(()=>n)}var Ek=A("$ZodObject",(e,t)=>{if($e.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}let o=Qr(()=>bg(t));we(e._zod,"propValues",()=>{let c=t.shape,l={};for(let u in c){let d=c[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(let p of d.values)l[u].add(p)}}return l});let r=cr,s=t.catchall,a;e._zod.parse=(c,l)=>{a??(a=o.value);let u=c.value;if(!r(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};let d=[],p=a.shape;for(let m of a.keys){let f=p[m],y=f._zod.optout==="optional",v=f._zod.run({value:u[m],issues:[]},l);if(v instanceof Promise)d.push(v.then((x)=>Ys(x,c,m,u,y)));else Ys(v,c,m,u,y)}if(!s)return d.length?Promise.all(d).then(()=>c):c;return wg(d,u,c,l,o.value,e)}}),_g=A("$ZodObjectJIT",(e,t)=>{Ek.init(e,t);let n=e._zod.parse,o=Qr(()=>bg(t)),r=(m)=>{let f=new Fl(["shape","payload","ctx"]),y=o.value,v=(b)=>{let O=Il(b);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};f.write("const input = payload.value;");let x=Object.create(null),h=0;for(let b of y.keys)x[b]=`key_${h++}`;f.write("const newResult = {};");for(let b of y.keys){let O=x[b],F=Il(b),k=m[b]?._zod?.optout==="optional";if(f.write(`const ${O} = ${v(b)};`),k)f.write(`
|
|
115
|
+
if (${O}.issues.length) {
|
|
116
|
+
if (${F} in input) {
|
|
117
|
+
payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
|
|
119
118
|
...iss,
|
|
120
|
-
path: iss.path ? [${
|
|
119
|
+
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
121
120
|
})));
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
if (${
|
|
126
|
-
if (${
|
|
127
|
-
newResult[${
|
|
124
|
+
if (${O}.value === undefined) {
|
|
125
|
+
if (${F} in input) {
|
|
126
|
+
newResult[${F}] = undefined;
|
|
128
127
|
}
|
|
129
128
|
} else {
|
|
130
|
-
newResult[${
|
|
129
|
+
newResult[${F}] = ${O}.value;
|
|
131
130
|
}
|
|
132
131
|
|
|
133
|
-
`);else
|
|
134
|
-
if (${
|
|
135
|
-
payload.issues = payload.issues.concat(${
|
|
132
|
+
`);else f.write(`
|
|
133
|
+
if (${O}.issues.length) {
|
|
134
|
+
payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
|
|
136
135
|
...iss,
|
|
137
|
-
path: iss.path ? [${
|
|
136
|
+
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
138
137
|
})));
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
if (${
|
|
142
|
-
if (${
|
|
143
|
-
newResult[${
|
|
140
|
+
if (${O}.value === undefined) {
|
|
141
|
+
if (${F} in input) {
|
|
142
|
+
newResult[${F}] = undefined;
|
|
144
143
|
}
|
|
145
144
|
} else {
|
|
146
|
-
newResult[${
|
|
145
|
+
newResult[${F}] = ${O}.value;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
`)}B.write("payload.value = newResult;"),B.write("return payload;");let P=B.compile();return(b,V)=>P(X,b,V)},z,K=h1,W=!$_.jitless,Y=W&&k5.value,Z=U.catchall,q;$._zod.parse=(X,B)=>{q??(q=J.value);let L=X.value;if(!K(L))return X.issues.push({expected:"object",code:"invalid_type",input:L,inst:$}),X;if(W&&Y&&B?.async===!1&&B.jitless!==!0){if(!z)z=_(U.shape);if(X=z(X,B),!Z)return X;return hq([],L,X,B,q,$)}return v(X,B)}});function Sq($,U,v,J){for(let z of $)if(z.issues.length===0)return U.value=z.value,U;let _=$.filter((z)=>!K1(z));if(_.length===1)return U.value=_[0].value,_[0];return U.issues.push({code:"invalid_union",input:U.value,inst:v,errors:$.map((z)=>z.issues.map((K)=>j6(K,J,U6())))}),U}var L_=M("$ZodUnion",($,U)=>{Y$.init($,U),X$($._zod,"optin",()=>U.options.some((_)=>_._zod.optin==="optional")?"optional":void 0),X$($._zod,"optout",()=>U.options.some((_)=>_._zod.optout==="optional")?"optional":void 0),X$($._zod,"values",()=>{if(U.options.every((_)=>_._zod.values))return new Set(U.options.flatMap((_)=>Array.from(_._zod.values)));return}),X$($._zod,"pattern",()=>{if(U.options.every((_)=>_._zod.pattern)){let _=U.options.map((z)=>z._zod.pattern);return new RegExp(`^(${_.map((z)=>v_(z.source)).join("|")})$`)}return});let v=U.options.length===1,J=U.options[0]._zod.run;$._zod.parse=(_,z)=>{if(v)return J(_,z);let K=!1,W=[];for(let O of U.options){let Y=O._zod.run({value:_.value,issues:[]},z);if(Y instanceof Promise)W.push(Y),K=!0;else{if(Y.issues.length===0)return Y;W.push(Y)}}if(!K)return Sq(W,_,$,z);return Promise.all(W).then((O)=>{return Sq(O,_,$,z)})}});function Rq($,U,v,J){let _=$.filter((z)=>z.issues.length===0);if(_.length===1)return U.value=_[0].value,U;if(_.length===0)U.issues.push({code:"invalid_union",input:U.value,inst:v,errors:$.map((z)=>z.issues.map((K)=>j6(K,J,U6())))});else U.issues.push({code:"invalid_union",input:U.value,inst:v,errors:[],inclusive:!1});return U}var Kz=M("$ZodXor",($,U)=>{L_.init($,U),U.inclusive=!1;let v=U.options.length===1,J=U.options[0]._zod.run;$._zod.parse=(_,z)=>{if(v)return J(_,z);let K=!1,W=[];for(let O of U.options){let Y=O._zod.run({value:_.value,issues:[]},z);if(Y instanceof Promise)W.push(Y),K=!0;else W.push(Y)}if(!K)return Rq(W,_,$,z);return Promise.all(W).then((O)=>{return Rq(O,_,$,z)})}}),Gz=M("$ZodDiscriminatedUnion",($,U)=>{U.inclusive=!1,L_.init($,U);let v=$._zod.parse;X$($._zod,"propValues",()=>{let _={};for(let z of U.options){let K=z._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${U.options.indexOf(z)}"`);for(let[W,O]of Object.entries(K)){if(!_[W])_[W]=new Set;for(let Y of O)_[W].add(Y)}}return _});let J=fU(()=>{let _=U.options,z=new Map;for(let K of _){let W=K._zod.propValues?.[U.discriminator];if(!W||W.size===0)throw Error(`Invalid discriminated union option at index "${U.options.indexOf(K)}"`);for(let O of W){if(z.has(O))throw Error(`Duplicate discriminator value "${String(O)}"`);z.set(O,K)}}return z});$._zod.parse=(_,z)=>{let K=_.value;if(!h1(K))return _.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),_;let W=J.value.get(K?.[U.discriminator]);if(W)return W._zod.run(_,z);if(U.unionFallback)return v(_,z);return _.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:U.discriminator,input:K,path:[U.discriminator],inst:$}),_}}),Wz=M("$ZodIntersection",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value,z=U.left._zod.run({value:_,issues:[]},J),K=U.right._zod.run({value:_,issues:[]},J);if(z instanceof Promise||K instanceof Promise)return Promise.all([z,K]).then(([O,Y])=>{return Tq(v,O,Y)});return Tq(v,z,K)}});function b3($,U){if($===U)return{valid:!0,data:$};if($ instanceof Date&&U instanceof Date&&+$===+U)return{valid:!0,data:$};if(z1($)&&z1(U)){let v=Object.keys(U),J=Object.keys($).filter((z)=>v.indexOf(z)!==-1),_={...$,...U};for(let z of J){let K=b3($[z],U[z]);if(!K.valid)return{valid:!1,mergeErrorPath:[z,...K.mergeErrorPath]};_[z]=K.data}return{valid:!0,data:_}}if(Array.isArray($)&&Array.isArray(U)){if($.length!==U.length)return{valid:!1,mergeErrorPath:[]};let v=[];for(let J=0;J<$.length;J++){let _=$[J],z=U[J],K=b3(_,z);if(!K.valid)return{valid:!1,mergeErrorPath:[J,...K.mergeErrorPath]};v.push(K.data)}return{valid:!0,data:v}}return{valid:!1,mergeErrorPath:[]}}function Tq($,U,v){let J=new Map,_;for(let W of U.issues)if(W.code==="unrecognized_keys"){_??(_=W);for(let O of W.keys){if(!J.has(O))J.set(O,{});J.get(O).l=!0}}else $.issues.push(W);for(let W of v.issues)if(W.code==="unrecognized_keys")for(let O of W.keys){if(!J.has(O))J.set(O,{});J.get(O).r=!0}else $.issues.push(W);let z=[...J].filter(([,W])=>W.l&&W.r).map(([W])=>W);if(z.length&&_)$.issues.push({..._,keys:z});if(K1($))return $;let K=b3(U.value,v.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var lv=M("$ZodTuple",($,U)=>{Y$.init($,U);let v=U.items;$._zod.parse=(J,_)=>{let z=J.value;if(!Array.isArray(z))return J.issues.push({input:z,inst:$,expected:"tuple",code:"invalid_type"}),J;J.value=[];let K=[],W=[...v].reverse().findIndex((Z)=>Z._zod.optin!=="optional"),O=W===-1?0:v.length-W;if(!U.rest){let Z=z.length>v.length,q=z.length<O-1;if(Z||q)return J.issues.push({...Z?{code:"too_big",maximum:v.length,inclusive:!0}:{code:"too_small",minimum:v.length},input:z,inst:$,origin:"array"}),J}let Y=-1;for(let Z of v){if(Y++,Y>=z.length){if(Y>=O)continue}let q=Z._zod.run({value:z[Y],issues:[]},_);if(q instanceof Promise)K.push(q.then((X)=>fv(X,J,Y)));else fv(q,J,Y)}if(U.rest){let Z=z.slice(v.length);for(let q of Z){Y++;let X=U.rest._zod.run({value:q,issues:[]},_);if(X instanceof Promise)K.push(X.then((B)=>fv(B,J,Y)));else fv(X,J,Y)}}if(K.length)return Promise.all(K).then(()=>J);return J}});function fv($,U,v){if($.issues.length)U.issues.push(...c6(v,$.issues));U.value[v]=$.value}var Oz=M("$ZodRecord",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(!z1(_))return v.issues.push({expected:"record",code:"invalid_type",input:_,inst:$}),v;let z=[],K=U.keyType._zod.values;if(K){v.value={};let W=new Set;for(let Y of K)if(typeof Y==="string"||typeof Y==="number"||typeof Y==="symbol"){W.add(typeof Y==="number"?Y.toString():Y);let Z=U.valueType._zod.run({value:_[Y],issues:[]},J);if(Z instanceof Promise)z.push(Z.then((q)=>{if(q.issues.length)v.issues.push(...c6(Y,q.issues));v.value[Y]=q.value}));else{if(Z.issues.length)v.issues.push(...c6(Y,Z.issues));v.value[Y]=Z.value}}let O;for(let Y in _)if(!W.has(Y))O=O??[],O.push(Y);if(O&&O.length>0)v.issues.push({code:"unrecognized_keys",input:_,inst:$,keys:O})}else{v.value={};for(let W of Reflect.ownKeys(_)){if(W==="__proto__")continue;let O=U.keyType._zod.run({value:W,issues:[]},J);if(O instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof W==="string"&&B_.test(W)&&O.issues.length){let q=U.keyType._zod.run({value:Number(W),issues:[]},J);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(q.issues.length===0)O=q}if(O.issues.length){if(U.mode==="loose")v.value[W]=_[W];else v.issues.push({code:"invalid_key",origin:"record",issues:O.issues.map((q)=>j6(q,J,U6())),input:W,path:[W],inst:$});continue}let Z=U.valueType._zod.run({value:_[W],issues:[]},J);if(Z instanceof Promise)z.push(Z.then((q)=>{if(q.issues.length)v.issues.push(...c6(W,q.issues));v.value[O.value]=q.value}));else{if(Z.issues.length)v.issues.push(...c6(W,Z.issues));v.value[O.value]=Z.value}}}if(z.length)return Promise.all(z).then(()=>v);return v}}),Yz=M("$ZodMap",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(!(_ instanceof Map))return v.issues.push({expected:"map",code:"invalid_type",input:_,inst:$}),v;let z=[];v.value=new Map;for(let[K,W]of _){let O=U.keyType._zod.run({value:K,issues:[]},J),Y=U.valueType._zod.run({value:W,issues:[]},J);if(O instanceof Promise||Y instanceof Promise)z.push(Promise.all([O,Y]).then(([Z,q])=>{yq(Z,q,v,K,_,$,J)}));else yq(O,Y,v,K,_,$,J)}if(z.length)return Promise.all(z).then(()=>v);return v}});function yq($,U,v,J,_,z,K){if($.issues.length)if(J_.has(typeof J))v.issues.push(...c6(J,$.issues));else v.issues.push({code:"invalid_key",origin:"map",input:_,inst:z,issues:$.issues.map((W)=>j6(W,K,U6()))});if(U.issues.length)if(J_.has(typeof J))v.issues.push(...c6(J,U.issues));else v.issues.push({origin:"map",code:"invalid_element",input:_,inst:z,key:J,issues:U.issues.map((W)=>j6(W,K,U6()))});v.value.set($.value,U.value)}var Zz=M("$ZodSet",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(!(_ instanceof Set))return v.issues.push({input:_,inst:$,expected:"set",code:"invalid_type"}),v;let z=[];v.value=new Set;for(let K of _){let W=U.valueType._zod.run({value:K,issues:[]},J);if(W instanceof Promise)z.push(W.then((O)=>Cq(O,v)));else Cq(W,v)}if(z.length)return Promise.all(z).then(()=>v);return v}});function Cq($,U){if($.issues.length)U.issues.push(...$.issues);U.value.add($.value)}var qz=M("$ZodEnum",($,U)=>{Y$.init($,U);let v=__(U.entries),J=new Set(v);$._zod.values=J,$._zod.pattern=new RegExp(`^(${v.filter((_)=>J_.has(typeof _)).map((_)=>typeof _==="string"?a6(_):_.toString()).join("|")})$`),$._zod.parse=(_,z)=>{let K=_.value;if(J.has(K))return _;return _.issues.push({code:"invalid_value",values:v,input:K,inst:$}),_}}),Bz=M("$ZodLiteral",($,U)=>{if(Y$.init($,U),U.values.length===0)throw Error("Cannot create literal schema with no valid values");let v=new Set(U.values);$._zod.values=v,$._zod.pattern=new RegExp(`^(${U.values.map((J)=>typeof J==="string"?a6(J):J?a6(J.toString()):String(J)).join("|")})$`),$._zod.parse=(J,_)=>{let z=J.value;if(v.has(z))return J;return J.issues.push({code:"invalid_value",values:U.values,input:z,inst:$}),J}}),Xz=M("$ZodFile",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{let _=v.value;if(_ instanceof File)return v;return v.issues.push({expected:"file",code:"invalid_type",input:_,inst:$}),v}}),Hz=M("$ZodTransform",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{if(J.direction==="backward")throw new x1($.constructor.name);let _=U.transform(v.value,v);if(J.async)return(_ instanceof Promise?_:Promise.resolve(_)).then((K)=>{return v.value=K,v});if(_ instanceof Promise)throw new F4;return v.value=_,v}});function Dq($,U){if($.issues.length&&U===void 0)return{issues:[],value:void 0};return $}var rv=M("$ZodOptional",($,U)=>{Y$.init($,U),$._zod.optin="optional",$._zod.optout="optional",X$($._zod,"values",()=>{return U.innerType._zod.values?new Set([...U.innerType._zod.values,void 0]):void 0}),X$($._zod,"pattern",()=>{let v=U.innerType._zod.pattern;return v?new RegExp(`^(${v_(v.source)})?$`):void 0}),$._zod.parse=(v,J)=>{if(U.innerType._zod.optin==="optional"){let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>Dq(z,v.value));return Dq(_,v.value)}if(v.value===void 0)return v;return U.innerType._zod.run(v,J)}}),Qz=M("$ZodExactOptional",($,U)=>{rv.init($,U),X$($._zod,"values",()=>U.innerType._zod.values),X$($._zod,"pattern",()=>U.innerType._zod.pattern),$._zod.parse=(v,J)=>{return U.innerType._zod.run(v,J)}}),Lz=M("$ZodNullable",($,U)=>{Y$.init($,U),X$($._zod,"optin",()=>U.innerType._zod.optin),X$($._zod,"optout",()=>U.innerType._zod.optout),X$($._zod,"pattern",()=>{let v=U.innerType._zod.pattern;return v?new RegExp(`^(${v_(v.source)}|null)$`):void 0}),X$($._zod,"values",()=>{return U.innerType._zod.values?new Set([...U.innerType._zod.values,null]):void 0}),$._zod.parse=(v,J)=>{if(v.value===null)return v;return U.innerType._zod.run(v,J)}}),Fz=M("$ZodDefault",($,U)=>{Y$.init($,U),$._zod.optin="optional",X$($._zod,"values",()=>U.innerType._zod.values),$._zod.parse=(v,J)=>{if(J.direction==="backward")return U.innerType._zod.run(v,J);if(v.value===void 0)return v.value=U.defaultValue,v;let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>jq(z,U));return jq(_,U)}});function jq($,U){if($.value===void 0)$.value=U.defaultValue;return $}var Pz=M("$ZodPrefault",($,U)=>{Y$.init($,U),$._zod.optin="optional",X$($._zod,"values",()=>U.innerType._zod.values),$._zod.parse=(v,J)=>{if(J.direction==="backward")return U.innerType._zod.run(v,J);if(v.value===void 0)v.value=U.defaultValue;return U.innerType._zod.run(v,J)}}),kz=M("$ZodNonOptional",($,U)=>{Y$.init($,U),X$($._zod,"values",()=>{let v=U.innerType._zod.values;return v?new Set([...v].filter((J)=>J!==void 0)):void 0}),$._zod.parse=(v,J)=>{let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>Vq(z,$));return Vq(_,$)}});function Vq($,U){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:U});return $}var bz=M("$ZodSuccess",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{if(J.direction==="backward")throw new x1("ZodSuccess");let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>{return v.value=z.issues.length===0,v});return v.value=_.issues.length===0,v}}),Mz=M("$ZodCatch",($,U)=>{Y$.init($,U),X$($._zod,"optin",()=>U.innerType._zod.optin),X$($._zod,"optout",()=>U.innerType._zod.optout),X$($._zod,"values",()=>U.innerType._zod.values),$._zod.parse=(v,J)=>{if(J.direction==="backward")return U.innerType._zod.run(v,J);let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>{if(v.value=z.value,z.issues.length)v.value=U.catchValue({...v,error:{issues:z.issues.map((K)=>j6(K,J,U6()))},input:v.value}),v.issues=[];return v});if(v.value=_.value,_.issues.length)v.value=U.catchValue({...v,error:{issues:_.issues.map((z)=>j6(z,J,U6()))},input:v.value}),v.issues=[];return v}}),Az=M("$ZodNaN",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{if(typeof v.value!=="number"||!Number.isNaN(v.value))return v.issues.push({input:v.value,inst:$,expected:"nan",code:"invalid_type"}),v;return v}}),Iz=M("$ZodPipe",($,U)=>{Y$.init($,U),X$($._zod,"values",()=>U.in._zod.values),X$($._zod,"optin",()=>U.in._zod.optin),X$($._zod,"optout",()=>U.out._zod.optout),X$($._zod,"propValues",()=>U.in._zod.propValues),$._zod.parse=(v,J)=>{if(J.direction==="backward"){let z=U.out._zod.run(v,J);if(z instanceof Promise)return z.then((K)=>Ev(K,U.in,J));return Ev(z,U.in,J)}let _=U.in._zod.run(v,J);if(_ instanceof Promise)return _.then((z)=>Ev(z,U.out,J));return Ev(_,U.out,J)}});function Ev($,U,v){if($.issues.length)return $.aborted=!0,$;return U._zod.run({value:$.value,issues:$.issues},v)}var F_=M("$ZodCodec",($,U)=>{Y$.init($,U),X$($._zod,"values",()=>U.in._zod.values),X$($._zod,"optin",()=>U.in._zod.optin),X$($._zod,"optout",()=>U.out._zod.optout),X$($._zod,"propValues",()=>U.in._zod.propValues),$._zod.parse=(v,J)=>{if((J.direction||"forward")==="forward"){let z=U.in._zod.run(v,J);if(z instanceof Promise)return z.then((K)=>uv(K,U,J));return uv(z,U,J)}else{let z=U.out._zod.run(v,J);if(z instanceof Promise)return z.then((K)=>uv(K,U,J));return uv(z,U,J)}}});function uv($,U,v){if($.issues.length)return $.aborted=!0,$;if((v.direction||"forward")==="forward"){let _=U.transform($.value,$);if(_ instanceof Promise)return _.then((z)=>mv($,z,U.out,v));return mv($,_,U.out,v)}else{let _=U.reverseTransform($.value,$);if(_ instanceof Promise)return _.then((z)=>mv($,z,U.in,v));return mv($,_,U.in,v)}}function mv($,U,v,J){if($.issues.length)return $.aborted=!0,$;return v._zod.run({value:U,issues:$.issues},J)}var wz=M("$ZodReadonly",($,U)=>{Y$.init($,U),X$($._zod,"propValues",()=>U.innerType._zod.propValues),X$($._zod,"values",()=>U.innerType._zod.values),X$($._zod,"optin",()=>U.innerType?._zod?.optin),X$($._zod,"optout",()=>U.innerType?._zod?.optout),$._zod.parse=(v,J)=>{if(J.direction==="backward")return U.innerType._zod.run(v,J);let _=U.innerType._zod.run(v,J);if(_ instanceof Promise)return _.then(fq);return fq(_)}});function fq($){return $.value=Object.freeze($.value),$}var gz=M("$ZodTemplateLiteral",($,U)=>{Y$.init($,U);let v=[];for(let J of U.parts)if(typeof J==="object"&&J!==null){if(!J._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...J._zod.traits].shift()}`);let _=J._zod.pattern instanceof RegExp?J._zod.pattern.source:J._zod.pattern;if(!_)throw Error(`Invalid template literal part: ${J._zod.traits}`);let z=_.startsWith("^")?1:0,K=_.endsWith("$")?_.length-1:_.length;v.push(_.slice(z,K))}else if(J===null||M5.has(typeof J))v.push(a6(`${J}`));else throw Error(`Invalid template literal part: ${J}`);$._zod.pattern=new RegExp(`^${v.join("")}$`),$._zod.parse=(J,_)=>{if(typeof J.value!=="string")return J.issues.push({input:J.value,inst:$,expected:"string",code:"invalid_type"}),J;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(J.value))return J.issues.push({input:J.value,inst:$,code:"invalid_format",format:U.format??"template_literal",pattern:$._zod.pattern.source}),J;return J}}),Nz=M("$ZodFunction",($,U)=>{return Y$.init($,U),$._def=U,$._zod.def=U,$.implement=(v)=>{if(typeof v!=="function")throw Error("implement() must be called with a function");return function(...J){let _=$._def.input?Y_($._def.input,J):J,z=Reflect.apply(v,this,_);if($._def.output)return Y_($._def.output,z);return z}},$.implementAsync=(v)=>{if(typeof v!=="function")throw Error("implementAsync() must be called with a function");return async function(...J){let _=$._def.input?await Z_($._def.input,J):J,z=await Reflect.apply(v,this,_);if($._def.output)return await Z_($._def.output,z);return z}},$._zod.parse=(v,J)=>{if(typeof v.value!=="function")return v.issues.push({code:"invalid_type",expected:"function",input:v.value,inst:$}),v;if($._def.output&&$._def.output._zod.def.type==="promise")v.value=$.implementAsync(v.value);else v.value=$.implement(v.value);return v},$.input=(...v)=>{let J=$.constructor;if(Array.isArray(v[0]))return new J({type:"function",input:new lv({type:"tuple",items:v[0],rest:v[1]}),output:$._def.output});return new J({type:"function",input:v[0],output:$._def.output})},$.output=(v)=>{return new $.constructor({type:"function",input:$._def.input,output:v})},$}),Sz=M("$ZodPromise",($,U)=>{Y$.init($,U),$._zod.parse=(v,J)=>{return Promise.resolve(v.value).then((_)=>U.innerType._zod.run({value:_,issues:[]},J))}}),Rz=M("$ZodLazy",($,U)=>{Y$.init($,U),X$($._zod,"innerType",()=>U.getter()),X$($._zod,"pattern",()=>$._zod.innerType?._zod?.pattern),X$($._zod,"propValues",()=>$._zod.innerType?._zod?.propValues),X$($._zod,"optin",()=>$._zod.innerType?._zod?.optin??void 0),X$($._zod,"optout",()=>$._zod.innerType?._zod?.optout??void 0),$._zod.parse=(v,J)=>{return $._zod.innerType._zod.run(v,J)}}),Tz=M("$ZodCustom",($,U)=>{m$.init($,U),Y$.init($,U),$._zod.parse=(v,J)=>{return v},$._zod.check=(v)=>{let J=v.value,_=U.fn(J);if(_ instanceof Promise)return _.then((z)=>Eq(z,v,J,$));Eq(_,v,J,$);return}});function Eq($,U,v,J){if(!$){let _={code:"custom",input:v,inst:J,path:[...J._zod.def.path??[]],continue:!J._zod.def.abort};if(J._zod.def.params)_.params=J._zod.def.params;U.issues.push(EU(_))}}var A_={};w4(A_,{zhTW:()=>b7,zhCN:()=>k7,yo:()=>M7,vi:()=>P7,uz:()=>F7,ur:()=>L7,uk:()=>M_,ua:()=>Q7,tr:()=>H7,th:()=>X7,ta:()=>B7,sv:()=>q7,sl:()=>Z7,ru:()=>Y7,pt:()=>O7,ps:()=>G7,pl:()=>W7,ota:()=>K7,no:()=>z7,nl:()=>J7,ms:()=>v7,mk:()=>_7,lt:()=>U7,ko:()=>$7,km:()=>k_,kh:()=>ez,ka:()=>sz,ja:()=>az,it:()=>tz,is:()=>nz,id:()=>dz,hy:()=>oz,hu:()=>pz,he:()=>iz,frCA:()=>rz,fr:()=>lz,fi:()=>cz,fa:()=>hz,es:()=>xz,eo:()=>mz,en:()=>P_,de:()=>uz,da:()=>Ez,cs:()=>fz,ca:()=>Vz,bg:()=>jz,be:()=>Dz,az:()=>Cz,ar:()=>yz});var $b=()=>{let $={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function U(_){return $[_]??null}let v={regex:"مدخل",email:"بريد إلكتروني",url:"رابط",emoji:"إيموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاريخ ووقت بمعيار ISO",date:"تاريخ بمعيار ISO",time:"وقت بمعيار ISO",duration:"مدة بمعيار ISO",ipv4:"عنوان IPv4",ipv6:"عنوان IPv6",cidrv4:"مدى عناوين بصيغة IPv4",cidrv6:"مدى عناوين بصيغة IPv6",base64:"نَص بترميز base64-encoded",base64url:"نَص بترميز base64url-encoded",json_string:"نَص على هيئة JSON",e164:"رقم هاتف بمعيار E.164",jwt:"JWT",template_literal:"مدخل"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`مدخلات غير مقبولة: يفترض إدخال instanceof ${_.expected}، ولكن تم إدخال ${W}`;return`مدخلات غير مقبولة: يفترض إدخال ${z}، ولكن تم إدخال ${W}`}case"invalid_value":if(_.values.length===1)return`مدخلات غير مقبولة: يفترض إدخال ${m(_.values[0])}`;return`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return` أكبر من اللازم: يفترض أن تكون ${_.origin??"القيمة"} ${z} ${_.maximum.toString()} ${K.unit??"عنصر"}`;return`أكبر من اللازم: يفترض أن تكون ${_.origin??"القيمة"} ${z} ${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`أصغر من اللازم: يفترض لـ ${_.origin} أن يكون ${z} ${_.minimum.toString()} ${K.unit}`;return`أصغر من اللازم: يفترض لـ ${_.origin} أن يكون ${z} ${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`نَص غير مقبول: يجب أن يبدأ بـ "${_.prefix}"`;if(z.format==="ends_with")return`نَص غير مقبول: يجب أن ينتهي بـ "${z.suffix}"`;if(z.format==="includes")return`نَص غير مقبول: يجب أن يتضمَّن "${z.includes}"`;if(z.format==="regex")return`نَص غير مقبول: يجب أن يطابق النمط ${z.pattern}`;return`${v[z.format]??_.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${_.divisor}`;case"unrecognized_keys":return`معرف${_.keys.length>1?"ات":""} غريب${_.keys.length>1?"ة":""}: ${w(_.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${_.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${_.origin}`;default:return"مدخل غير مقبول"}}};function yz(){return{localeError:$b()}}var Ub=()=>{let $={string:{unit:"simvol",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"element",verb:"olmalıdır"},set:{unit:"element",verb:"olmalıdır"}};function U(_){return $[_]??null}let v={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Yanlış dəyər: gözlənilən instanceof ${_.expected}, daxil olan ${W}`;return`Yanlış dəyər: gözlənilən ${z}, daxil olan ${W}`}case"invalid_value":if(_.values.length===1)return`Yanlış dəyər: gözlənilən ${m(_.values[0])}`;return`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Çox böyük: gözlənilən ${_.origin??"dəyər"} ${z}${_.maximum.toString()} ${K.unit??"element"}`;return`Çox böyük: gözlənilən ${_.origin??"dəyər"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Çox kiçik: gözlənilən ${_.origin} ${z}${_.minimum.toString()} ${K.unit}`;return`Çox kiçik: gözlənilən ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Yanlış mətn: "${z.prefix}" ilə başlamalıdır`;if(z.format==="ends_with")return`Yanlış mətn: "${z.suffix}" ilə bitməlidir`;if(z.format==="includes")return`Yanlış mətn: "${z.includes}" daxil olmalıdır`;if(z.format==="regex")return`Yanlış mətn: ${z.pattern} şablonuna uyğun olmalıdır`;return`Yanlış ${v[z.format]??_.format}`}case"not_multiple_of":return`Yanlış ədəd: ${_.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${_.keys.length>1?"lar":""}: ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${_.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function Cz(){return{localeError:Ub()}}function lq($,U,v,J){let _=Math.abs($),z=_%10,K=_%100;if(K>=11&&K<=19)return J;if(z===1)return U;if(z>=2&&z<=4)return v;return J}var _b=()=>{let $={string:{unit:{one:"сімвал",few:"сімвалы",many:"сімвалаў"},verb:"мець"},array:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},set:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},file:{unit:{one:"байт",few:"байты",many:"байтаў"},verb:"мець"}};function U(_){return $[_]??null}let v={regex:"увод",email:"email адрас",url:"URL",emoji:"эмодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата і час",date:"ISO дата",time:"ISO час",duration:"ISO працягласць",ipv4:"IPv4 адрас",ipv6:"IPv6 адрас",cidrv4:"IPv4 дыяпазон",cidrv6:"IPv6 дыяпазон",base64:"радок у фармаце base64",base64url:"радок у фармаце base64url",json_string:"JSON радок",e164:"нумар E.164",jwt:"JWT",template_literal:"увод"},J={nan:"NaN",number:"лік",array:"масіў"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Няправільны ўвод: чакаўся instanceof ${_.expected}, атрымана ${W}`;return`Няправільны ўвод: чакаўся ${z}, атрымана ${W}`}case"invalid_value":if(_.values.length===1)return`Няправільны ўвод: чакалася ${m(_.values[0])}`;return`Няправільны варыянт: чакаўся адзін з ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K){let W=Number(_.maximum),O=lq(W,K.unit.one,K.unit.few,K.unit.many);return`Занадта вялікі: чакалася, што ${_.origin??"значэнне"} павінна ${K.verb} ${z}${_.maximum.toString()} ${O}`}return`Занадта вялікі: чакалася, што ${_.origin??"значэнне"} павінна быць ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K){let W=Number(_.minimum),O=lq(W,K.unit.one,K.unit.few,K.unit.many);return`Занадта малы: чакалася, што ${_.origin} павінна ${K.verb} ${z}${_.minimum.toString()} ${O}`}return`Занадта малы: чакалася, што ${_.origin} павінна быць ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Няправільны радок: павінен пачынацца з "${z.prefix}"`;if(z.format==="ends_with")return`Няправільны радок: павінен заканчвацца на "${z.suffix}"`;if(z.format==="includes")return`Няправільны радок: павінен змяшчаць "${z.includes}"`;if(z.format==="regex")return`Няправільны радок: павінен адпавядаць шаблону ${z.pattern}`;return`Няправільны ${v[z.format]??_.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${_.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${_.keys.length>1?"ключы":"ключ"}: ${w(_.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${_.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${_.origin}`;default:return"Няправільны ўвод"}}};function Dz(){return{localeError:_b()}}var vb=()=>{let $={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function U(_){return $[_]??null}let v={regex:"вход",email:"имейл адрес",url:"URL",emoji:"емоджи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO време",date:"ISO дата",time:"ISO време",duration:"ISO продължителност",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"base64-кодиран низ",base64url:"base64url-кодиран низ",json_string:"JSON низ",e164:"E.164 номер",jwt:"JWT",template_literal:"вход"},J={nan:"NaN",number:"число",array:"масив"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Невалиден вход: очакван instanceof ${_.expected}, получен ${W}`;return`Невалиден вход: очакван ${z}, получен ${W}`}case"invalid_value":if(_.values.length===1)return`Невалиден вход: очакван ${m(_.values[0])}`;return`Невалидна опция: очаквано едно от ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Твърде голямо: очаква се ${_.origin??"стойност"} да съдържа ${z}${_.maximum.toString()} ${K.unit??"елемента"}`;return`Твърде голямо: очаква се ${_.origin??"стойност"} да бъде ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Твърде малко: очаква се ${_.origin} да съдържа ${z}${_.minimum.toString()} ${K.unit}`;return`Твърде малко: очаква се ${_.origin} да бъде ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Невалиден низ: трябва да започва с "${z.prefix}"`;if(z.format==="ends_with")return`Невалиден низ: трябва да завършва с "${z.suffix}"`;if(z.format==="includes")return`Невалиден низ: трябва да включва "${z.includes}"`;if(z.format==="regex")return`Невалиден низ: трябва да съвпада с ${z.pattern}`;let K="Невалиден";if(z.format==="emoji")K="Невалидно";if(z.format==="datetime")K="Невалидно";if(z.format==="date")K="Невалидна";if(z.format==="time")K="Невалидно";if(z.format==="duration")K="Невалидна";return`${K} ${v[z.format]??_.format}`}case"not_multiple_of":return`Невалидно число: трябва да бъде кратно на ${_.divisor}`;case"unrecognized_keys":return`Неразпознат${_.keys.length>1?"и":""} ключ${_.keys.length>1?"ове":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Невалиден ключ в ${_.origin}`;case"invalid_union":return"Невалиден вход";case"invalid_element":return`Невалидна стойност в ${_.origin}`;default:return"Невалиден вход"}}};function jz(){return{localeError:vb()}}var Jb=()=>{let $={string:{unit:"caràcters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function U(_){return $[_]??null}let v={regex:"entrada",email:"adreça electrònica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adreça IPv4",ipv6:"adreça IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Tipus invàlid: s'esperava instanceof ${_.expected}, s'ha rebut ${W}`;return`Tipus invàlid: s'esperava ${z}, s'ha rebut ${W}`}case"invalid_value":if(_.values.length===1)return`Valor invàlid: s'esperava ${m(_.values[0])}`;return`Opció invàlida: s'esperava una de ${w(_.values," o ")}`;case"too_big":{let z=_.inclusive?"com a màxim":"menys de",K=U(_.origin);if(K)return`Massa gran: s'esperava que ${_.origin??"el valor"} contingués ${z} ${_.maximum.toString()} ${K.unit??"elements"}`;return`Massa gran: s'esperava que ${_.origin??"el valor"} fos ${z} ${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?"com a mínim":"més de",K=U(_.origin);if(K)return`Massa petit: s'esperava que ${_.origin} contingués ${z} ${_.minimum.toString()} ${K.unit}`;return`Massa petit: s'esperava que ${_.origin} fos ${z} ${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Format invàlid: ha de començar amb "${z.prefix}"`;if(z.format==="ends_with")return`Format invàlid: ha d'acabar amb "${z.suffix}"`;if(z.format==="includes")return`Format invàlid: ha d'incloure "${z.includes}"`;if(z.format==="regex")return`Format invàlid: ha de coincidir amb el patró ${z.pattern}`;return`Format invàlid per a ${v[z.format]??_.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${_.divisor}`;case"unrecognized_keys":return`Clau${_.keys.length>1?"s":""} no reconeguda${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${_.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${_.origin}`;default:return"Entrada invàlida"}}};function Vz(){return{localeError:Jb()}}var zb=()=>{let $={string:{unit:"znaků",verb:"mít"},file:{unit:"bajtů",verb:"mít"},array:{unit:"prvků",verb:"mít"},set:{unit:"prvků",verb:"mít"}};function U(_){return $[_]??null}let v={regex:"regulární výraz",email:"e-mailová adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a čas ve formátu ISO",date:"datum ve formátu ISO",time:"čas ve formátu ISO",duration:"doba trvání ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"řetězec zakódovaný ve formátu base64",base64url:"řetězec zakódovaný ve formátu base64url",json_string:"řetězec ve formátu JSON",e164:"číslo E.164",jwt:"JWT",template_literal:"vstup"},J={nan:"NaN",number:"číslo",string:"řetězec",function:"funkce",array:"pole"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Neplatný vstup: očekáváno instanceof ${_.expected}, obdrženo ${W}`;return`Neplatný vstup: očekáváno ${z}, obdrženo ${W}`}case"invalid_value":if(_.values.length===1)return`Neplatný vstup: očekáváno ${m(_.values[0])}`;return`Neplatná možnost: očekávána jedna z hodnot ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Hodnota je příliš velká: ${_.origin??"hodnota"} musí mít ${z}${_.maximum.toString()} ${K.unit??"prvků"}`;return`Hodnota je příliš velká: ${_.origin??"hodnota"} musí být ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Hodnota je příliš malá: ${_.origin??"hodnota"} musí mít ${z}${_.minimum.toString()} ${K.unit??"prvků"}`;return`Hodnota je příliš malá: ${_.origin??"hodnota"} musí být ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Neplatný řetězec: musí začínat na "${z.prefix}"`;if(z.format==="ends_with")return`Neplatný řetězec: musí končit na "${z.suffix}"`;if(z.format==="includes")return`Neplatný řetězec: musí obsahovat "${z.includes}"`;if(z.format==="regex")return`Neplatný řetězec: musí odpovídat vzoru ${z.pattern}`;return`Neplatný formát ${v[z.format]??_.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${_.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${w(_.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${_.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${_.origin}`;default:return"Neplatný vstup"}}};function fz(){return{localeError:zb()}}var Kb=()=>{let $={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function U(_){return $[_]??null}let v={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslæt",date:"ISO-dato",time:"ISO-klokkeslæt",duration:"ISO-varighed",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},J={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"sæt",file:"fil"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ugyldigt input: forventede instanceof ${_.expected}, fik ${W}`;return`Ugyldigt input: forventede ${z}, fik ${W}`}case"invalid_value":if(_.values.length===1)return`Ugyldig værdi: forventede ${m(_.values[0])}`;return`Ugyldigt valg: forventede en af følgende ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin),W=J[_.origin]??_.origin;if(K)return`For stor: forventede ${W??"value"} ${K.verb} ${z} ${_.maximum.toString()} ${K.unit??"elementer"}`;return`For stor: forventede ${W??"value"} havde ${z} ${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin),W=J[_.origin]??_.origin;if(K)return`For lille: forventede ${W} ${K.verb} ${z} ${_.minimum.toString()} ${K.unit}`;return`For lille: forventede ${W} havde ${z} ${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ugyldig streng: skal starte med "${z.prefix}"`;if(z.format==="ends_with")return`Ugyldig streng: skal ende med "${z.suffix}"`;if(z.format==="includes")return`Ugyldig streng: skal indeholde "${z.includes}"`;if(z.format==="regex")return`Ugyldig streng: skal matche mønsteret ${z.pattern}`;return`Ugyldig ${v[z.format]??_.format}`}case"not_multiple_of":return`Ugyldigt tal: skal være deleligt med ${_.divisor}`;case"unrecognized_keys":return`${_.keys.length>1?"Ukendte nøgler":"Ukendt nøgle"}: ${w(_.keys,", ")}`;case"invalid_key":return`Ugyldig nøgle i ${_.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig værdi i ${_.origin}`;default:return"Ugyldigt input"}}};function Ez(){return{localeError:Kb()}}var Gb=()=>{let $={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function U(_){return $[_]??null}let v={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},J={nan:"NaN",number:"Zahl",array:"Array"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ungültige Eingabe: erwartet instanceof ${_.expected}, erhalten ${W}`;return`Ungültige Eingabe: erwartet ${z}, erhalten ${W}`}case"invalid_value":if(_.values.length===1)return`Ungültige Eingabe: erwartet ${m(_.values[0])}`;return`Ungültige Option: erwartet eine von ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Zu groß: erwartet, dass ${_.origin??"Wert"} ${z}${_.maximum.toString()} ${K.unit??"Elemente"} hat`;return`Zu groß: erwartet, dass ${_.origin??"Wert"} ${z}${_.maximum.toString()} ist`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Zu klein: erwartet, dass ${_.origin} ${z}${_.minimum.toString()} ${K.unit} hat`;return`Zu klein: erwartet, dass ${_.origin} ${z}${_.minimum.toString()} ist`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ungültiger String: muss mit "${z.prefix}" beginnen`;if(z.format==="ends_with")return`Ungültiger String: muss mit "${z.suffix}" enden`;if(z.format==="includes")return`Ungültiger String: muss "${z.includes}" enthalten`;if(z.format==="regex")return`Ungültiger String: muss dem Muster ${z.pattern} entsprechen`;return`Ungültig: ${v[z.format]??_.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${_.divisor} sein`;case"unrecognized_keys":return`${_.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${w(_.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${_.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${_.origin}`;default:return"Ungültige Eingabe"}}};function uz(){return{localeError:Gb()}}var Wb=()=>{let $={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function U(_){return $[_]??null}let v={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;return`Invalid input: expected ${z}, received ${W}`}case"invalid_value":if(_.values.length===1)return`Invalid input: expected ${m(_.values[0])}`;return`Invalid option: expected one of ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Too big: expected ${_.origin??"value"} to have ${z}${_.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${_.origin??"value"} to be ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Too small: expected ${_.origin} to have ${z}${_.minimum.toString()} ${K.unit}`;return`Too small: expected ${_.origin} to be ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Invalid string: must start with "${z.prefix}"`;if(z.format==="ends_with")return`Invalid string: must end with "${z.suffix}"`;if(z.format==="includes")return`Invalid string: must include "${z.includes}"`;if(z.format==="regex")return`Invalid string: must match pattern ${z.pattern}`;return`Invalid ${v[z.format]??_.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${_.divisor}`;case"unrecognized_keys":return`Unrecognized key${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Invalid key in ${_.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${_.origin}`;default:return"Invalid input"}}};function P_(){return{localeError:Wb()}}var Ob=()=>{let $={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function U(_){return $[_]??null}let v={regex:"enigo",email:"retadreso",url:"URL",emoji:"emoĝio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-daŭro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},J={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Nevalida enigo: atendiĝis instanceof ${_.expected}, riceviĝis ${W}`;return`Nevalida enigo: atendiĝis ${z}, riceviĝis ${W}`}case"invalid_value":if(_.values.length===1)return`Nevalida enigo: atendiĝis ${m(_.values[0])}`;return`Nevalida opcio: atendiĝis unu el ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Tro granda: atendiĝis ke ${_.origin??"valoro"} havu ${z}${_.maximum.toString()} ${K.unit??"elementojn"}`;return`Tro granda: atendiĝis ke ${_.origin??"valoro"} havu ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Tro malgranda: atendiĝis ke ${_.origin} havu ${z}${_.minimum.toString()} ${K.unit}`;return`Tro malgranda: atendiĝis ke ${_.origin} estu ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Nevalida karaktraro: devas komenciĝi per "${z.prefix}"`;if(z.format==="ends_with")return`Nevalida karaktraro: devas finiĝi per "${z.suffix}"`;if(z.format==="includes")return`Nevalida karaktraro: devas inkluzivi "${z.includes}"`;if(z.format==="regex")return`Nevalida karaktraro: devas kongrui kun la modelo ${z.pattern}`;return`Nevalida ${v[z.format]??_.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${_.divisor}`;case"unrecognized_keys":return`Nekonata${_.keys.length>1?"j":""} ŝlosilo${_.keys.length>1?"j":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Nevalida ŝlosilo en ${_.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${_.origin}`;default:return"Nevalida enigo"}}};function mz(){return{localeError:Ob()}}var Yb=()=>{let $={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function U(_){return $[_]??null}let v={regex:"entrada",email:"dirección de correo electrónico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duración ISO",ipv4:"dirección IPv4",ipv6:"dirección IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"},J={nan:"NaN",string:"texto",number:"número",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"número grande",symbol:"símbolo",undefined:"indefinido",null:"nulo",function:"función",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeración",union:"unión",literal:"literal",promise:"promesa",void:"vacío",never:"nunca",unknown:"desconocido",any:"cualquiera"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Entrada inválida: se esperaba instanceof ${_.expected}, recibido ${W}`;return`Entrada inválida: se esperaba ${z}, recibido ${W}`}case"invalid_value":if(_.values.length===1)return`Entrada inválida: se esperaba ${m(_.values[0])}`;return`Opción inválida: se esperaba una de ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin),W=J[_.origin]??_.origin;if(K)return`Demasiado grande: se esperaba que ${W??"valor"} tuviera ${z}${_.maximum.toString()} ${K.unit??"elementos"}`;return`Demasiado grande: se esperaba que ${W??"valor"} fuera ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin),W=J[_.origin]??_.origin;if(K)return`Demasiado pequeño: se esperaba que ${W} tuviera ${z}${_.minimum.toString()} ${K.unit}`;return`Demasiado pequeño: se esperaba que ${W} fuera ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Cadena inválida: debe comenzar con "${z.prefix}"`;if(z.format==="ends_with")return`Cadena inválida: debe terminar en "${z.suffix}"`;if(z.format==="includes")return`Cadena inválida: debe incluir "${z.includes}"`;if(z.format==="regex")return`Cadena inválida: debe coincidir con el patrón ${z.pattern}`;return`Inválido ${v[z.format]??_.format}`}case"not_multiple_of":return`Número inválido: debe ser múltiplo de ${_.divisor}`;case"unrecognized_keys":return`Llave${_.keys.length>1?"s":""} desconocida${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Llave inválida en ${J[_.origin]??_.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido en ${J[_.origin]??_.origin}`;default:return"Entrada inválida"}}};function xz(){return{localeError:Yb()}}var Zb=()=>{let $={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function U(_){return $[_]??null}let v={regex:"ورودی",email:"آدرس ایمیل",url:"URL",emoji:"ایموجی",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاریخ و زمان ایزو",date:"تاریخ ایزو",time:"زمان ایزو",duration:"مدت زمان ایزو",ipv4:"IPv4 آدرس",ipv6:"IPv6 آدرس",cidrv4:"IPv4 دامنه",cidrv6:"IPv6 دامنه",base64:"base64-encoded رشته",base64url:"base64url-encoded رشته",json_string:"JSON رشته",e164:"E.164 عدد",jwt:"JWT",template_literal:"ورودی"},J={nan:"NaN",number:"عدد",array:"آرایه"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`ورودی نامعتبر: میبایست instanceof ${_.expected} میبود، ${W} دریافت شد`;return`ورودی نامعتبر: میبایست ${z} میبود، ${W} دریافت شد`}case"invalid_value":if(_.values.length===1)return`ورودی نامعتبر: میبایست ${m(_.values[0])} میبود`;return`گزینه نامعتبر: میبایست یکی از ${w(_.values,"|")} میبود`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`خیلی بزرگ: ${_.origin??"مقدار"} باید ${z}${_.maximum.toString()} ${K.unit??"عنصر"} باشد`;return`خیلی بزرگ: ${_.origin??"مقدار"} باید ${z}${_.maximum.toString()} باشد`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`خیلی کوچک: ${_.origin} باید ${z}${_.minimum.toString()} ${K.unit} باشد`;return`خیلی کوچک: ${_.origin} باید ${z}${_.minimum.toString()} باشد`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`رشته نامعتبر: باید با "${z.prefix}" شروع شود`;if(z.format==="ends_with")return`رشته نامعتبر: باید با "${z.suffix}" تمام شود`;if(z.format==="includes")return`رشته نامعتبر: باید شامل "${z.includes}" باشد`;if(z.format==="regex")return`رشته نامعتبر: باید با الگوی ${z.pattern} مطابقت داشته باشد`;return`${v[z.format]??_.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${_.divisor} باشد`;case"unrecognized_keys":return`کلید${_.keys.length>1?"های":""} ناشناس: ${w(_.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${_.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${_.origin}`;default:return"ورودی نامعتبر"}}};function hz(){return{localeError:Zb()}}var qb=()=>{let $={string:{unit:"merkkiä",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"päivämäärän"}};function U(_){return $[_]??null}let v={regex:"säännöllinen lauseke",email:"sähköpostiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-päivämäärä",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Virheellinen tyyppi: odotettiin instanceof ${_.expected}, oli ${W}`;return`Virheellinen tyyppi: odotettiin ${z}, oli ${W}`}case"invalid_value":if(_.values.length===1)return`Virheellinen syöte: täytyy olla ${m(_.values[0])}`;return`Virheellinen valinta: täytyy olla yksi seuraavista: ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Liian suuri: ${K.subject} täytyy olla ${z}${_.maximum.toString()} ${K.unit}`.trim();return`Liian suuri: arvon täytyy olla ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Liian pieni: ${K.subject} täytyy olla ${z}${_.minimum.toString()} ${K.unit}`.trim();return`Liian pieni: arvon täytyy olla ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Virheellinen syöte: täytyy alkaa "${z.prefix}"`;if(z.format==="ends_with")return`Virheellinen syöte: täytyy loppua "${z.suffix}"`;if(z.format==="includes")return`Virheellinen syöte: täytyy sisältää "${z.includes}"`;if(z.format==="regex")return`Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${z.pattern}`;return`Virheellinen ${v[z.format]??_.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${_.divisor} monikerta`;case"unrecognized_keys":return`${_.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${w(_.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen syöte"}}};function cz(){return{localeError:qb()}}var Bb=()=>{let $={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function U(_){return $[_]??null}let v={regex:"entrée",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"},J={nan:"NaN",number:"nombre",array:"tableau"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Entrée invalide : instanceof ${_.expected} attendu, ${W} reçu`;return`Entrée invalide : ${z} attendu, ${W} reçu`}case"invalid_value":if(_.values.length===1)return`Entrée invalide : ${m(_.values[0])} attendu`;return`Option invalide : une valeur parmi ${w(_.values,"|")} attendue`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Trop grand : ${_.origin??"valeur"} doit ${K.verb} ${z}${_.maximum.toString()} ${K.unit??"élément(s)"}`;return`Trop grand : ${_.origin??"valeur"} doit être ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Trop petit : ${_.origin} doit ${K.verb} ${z}${_.minimum.toString()} ${K.unit}`;return`Trop petit : ${_.origin} doit être ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Chaîne invalide : doit commencer par "${z.prefix}"`;if(z.format==="ends_with")return`Chaîne invalide : doit se terminer par "${z.suffix}"`;if(z.format==="includes")return`Chaîne invalide : doit inclure "${z.includes}"`;if(z.format==="regex")return`Chaîne invalide : doit correspondre au modèle ${z.pattern}`;return`${v[z.format]??_.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${_.divisor}`;case"unrecognized_keys":return`Clé${_.keys.length>1?"s":""} non reconnue${_.keys.length>1?"s":""} : ${w(_.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${_.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${_.origin}`;default:return"Entrée invalide"}}};function lz(){return{localeError:Bb()}}var Xb=()=>{let $={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function U(_){return $[_]??null}let v={regex:"entrée",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Entrée invalide : attendu instanceof ${_.expected}, reçu ${W}`;return`Entrée invalide : attendu ${z}, reçu ${W}`}case"invalid_value":if(_.values.length===1)return`Entrée invalide : attendu ${m(_.values[0])}`;return`Option invalide : attendu l'une des valeurs suivantes ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"≤":"<",K=U(_.origin);if(K)return`Trop grand : attendu que ${_.origin??"la valeur"} ait ${z}${_.maximum.toString()} ${K.unit}`;return`Trop grand : attendu que ${_.origin??"la valeur"} soit ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?"≥":">",K=U(_.origin);if(K)return`Trop petit : attendu que ${_.origin} ait ${z}${_.minimum.toString()} ${K.unit}`;return`Trop petit : attendu que ${_.origin} soit ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Chaîne invalide : doit commencer par "${z.prefix}"`;if(z.format==="ends_with")return`Chaîne invalide : doit se terminer par "${z.suffix}"`;if(z.format==="includes")return`Chaîne invalide : doit inclure "${z.includes}"`;if(z.format==="regex")return`Chaîne invalide : doit correspondre au motif ${z.pattern}`;return`${v[z.format]??_.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${_.divisor}`;case"unrecognized_keys":return`Clé${_.keys.length>1?"s":""} non reconnue${_.keys.length>1?"s":""} : ${w(_.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${_.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${_.origin}`;default:return"Entrée invalide"}}};function rz(){return{localeError:Xb()}}var Hb=()=>{let $={string:{label:"מחרוזת",gender:"f"},number:{label:"מספר",gender:"m"},boolean:{label:"ערך בוליאני",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"תאריך",gender:"m"},array:{label:"מערך",gender:"m"},object:{label:"אובייקט",gender:"m"},null:{label:"ערך ריק (null)",gender:"m"},undefined:{label:"ערך לא מוגדר (undefined)",gender:"m"},symbol:{label:"סימבול (Symbol)",gender:"m"},function:{label:"פונקציה",gender:"f"},map:{label:"מפה (Map)",gender:"f"},set:{label:"קבוצה (Set)",gender:"f"},file:{label:"קובץ",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"ערך לא ידוע",gender:"m"},value:{label:"ערך",gender:"m"}},U={string:{unit:"תווים",shortLabel:"קצר",longLabel:"ארוך"},file:{unit:"בייטים",shortLabel:"קטן",longLabel:"גדול"},array:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},set:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},number:{unit:"",shortLabel:"קטן",longLabel:"גדול"}},v=(Y)=>Y?$[Y]:void 0,J=(Y)=>{let Z=v(Y);if(Z)return Z.label;return Y??$.unknown.label},_=(Y)=>`ה${J(Y)}`,z=(Y)=>{return(v(Y)?.gender??"m")==="f"?"צריכה להיות":"צריך להיות"},K=(Y)=>{if(!Y)return null;return U[Y]??null},W={regex:{label:"קלט",gender:"m"},email:{label:"כתובת אימייל",gender:"f"},url:{label:"כתובת רשת",gender:"f"},emoji:{label:"אימוג'י",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"תאריך וזמן ISO",gender:"m"},date:{label:"תאריך ISO",gender:"m"},time:{label:"זמן ISO",gender:"m"},duration:{label:"משך זמן ISO",gender:"m"},ipv4:{label:"כתובת IPv4",gender:"f"},ipv6:{label:"כתובת IPv6",gender:"f"},cidrv4:{label:"טווח IPv4",gender:"m"},cidrv6:{label:"טווח IPv6",gender:"m"},base64:{label:"מחרוזת בבסיס 64",gender:"f"},base64url:{label:"מחרוזת בבסיס 64 לכתובות רשת",gender:"f"},json_string:{label:"מחרוזת JSON",gender:"f"},e164:{label:"מספר E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"קלט",gender:"m"},includes:{label:"קלט",gender:"m"},lowercase:{label:"קלט",gender:"m"},starts_with:{label:"קלט",gender:"m"},uppercase:{label:"קלט",gender:"m"}},O={nan:"NaN"};return(Y)=>{switch(Y.code){case"invalid_type":{let Z=Y.expected,q=O[Z??""]??J(Z),X=x(Y.input),B=O[X]??$[X]?.label??X;if(/^[A-Z]/.test(Y.expected))return`קלט לא תקין: צריך להיות instanceof ${Y.expected}, התקבל ${B}`;return`קלט לא תקין: צריך להיות ${q}, התקבל ${B}`}case"invalid_value":{if(Y.values.length===1)return`ערך לא תקין: הערך חייב להיות ${m(Y.values[0])}`;let Z=Y.values.map((B)=>m(B));if(Y.values.length===2)return`ערך לא תקין: האפשרויות המתאימות הן ${Z[0]} או ${Z[1]}`;let q=Z[Z.length-1];return`ערך לא תקין: האפשרויות המתאימות הן ${Z.slice(0,-1).join(", ")} או ${q}`}case"too_big":{let Z=K(Y.origin),q=_(Y.origin??"value");if(Y.origin==="string")return`${Z?.longLabel??"ארוך"} מדי: ${q} צריכה להכיל ${Y.maximum.toString()} ${Z?.unit??""} ${Y.inclusive?"או פחות":"לכל היותר"}`.trim();if(Y.origin==="number"){let L=Y.inclusive?`קטן או שווה ל-${Y.maximum}`:`קטן מ-${Y.maximum}`;return`גדול מדי: ${q} צריך להיות ${L}`}if(Y.origin==="array"||Y.origin==="set"){let L=Y.origin==="set"?"צריכה":"צריך",F=Y.inclusive?`${Y.maximum} ${Z?.unit??""} או פחות`:`פחות מ-${Y.maximum} ${Z?.unit??""}`;return`גדול מדי: ${q} ${L} להכיל ${F}`.trim()}let X=Y.inclusive?"<=":"<",B=z(Y.origin??"value");if(Z?.unit)return`${Z.longLabel} מדי: ${q} ${B} ${X}${Y.maximum.toString()} ${Z.unit}`;return`${Z?.longLabel??"גדול"} מדי: ${q} ${B} ${X}${Y.maximum.toString()}`}case"too_small":{let Z=K(Y.origin),q=_(Y.origin??"value");if(Y.origin==="string")return`${Z?.shortLabel??"קצר"} מדי: ${q} צריכה להכיל ${Y.minimum.toString()} ${Z?.unit??""} ${Y.inclusive?"או יותר":"לפחות"}`.trim();if(Y.origin==="number"){let L=Y.inclusive?`גדול או שווה ל-${Y.minimum}`:`גדול מ-${Y.minimum}`;return`קטן מדי: ${q} צריך להיות ${L}`}if(Y.origin==="array"||Y.origin==="set"){let L=Y.origin==="set"?"צריכה":"צריך";if(Y.minimum===1&&Y.inclusive){let k=Y.origin==="set"?"לפחות פריט אחד":"לפחות פריט אחד";return`קטן מדי: ${q} ${L} להכיל ${k}`}let F=Y.inclusive?`${Y.minimum} ${Z?.unit??""} או יותר`:`יותר מ-${Y.minimum} ${Z?.unit??""}`;return`קטן מדי: ${q} ${L} להכיל ${F}`.trim()}let X=Y.inclusive?">=":">",B=z(Y.origin??"value");if(Z?.unit)return`${Z.shortLabel} מדי: ${q} ${B} ${X}${Y.minimum.toString()} ${Z.unit}`;return`${Z?.shortLabel??"קטן"} מדי: ${q} ${B} ${X}${Y.minimum.toString()}`}case"invalid_format":{let Z=Y;if(Z.format==="starts_with")return`המחרוזת חייבת להתחיל ב "${Z.prefix}"`;if(Z.format==="ends_with")return`המחרוזת חייבת להסתיים ב "${Z.suffix}"`;if(Z.format==="includes")return`המחרוזת חייבת לכלול "${Z.includes}"`;if(Z.format==="regex")return`המחרוזת חייבת להתאים לתבנית ${Z.pattern}`;let q=W[Z.format],X=q?.label??Z.format,L=(q?.gender??"m")==="f"?"תקינה":"תקין";return`${X} לא ${L}`}case"not_multiple_of":return`מספר לא תקין: חייב להיות מכפלה של ${Y.divisor}`;case"unrecognized_keys":return`מפתח${Y.keys.length>1?"ות":""} לא מזוה${Y.keys.length>1?"ים":"ה"}: ${w(Y.keys,", ")}`;case"invalid_key":return"שדה לא תקין באובייקט";case"invalid_union":return"קלט לא תקין";case"invalid_element":return`ערך לא תקין ב${_(Y.origin??"array")}`;default:return"קלט לא תקין"}}};function iz(){return{localeError:Hb()}}var Qb=()=>{let $={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function U(_){return $[_]??null}let v={regex:"bemenet",email:"email cím",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO időbélyeg",date:"ISO dátum",time:"ISO idő",duration:"ISO időintervallum",ipv4:"IPv4 cím",ipv6:"IPv6 cím",cidrv4:"IPv4 tartomány",cidrv6:"IPv6 tartomány",base64:"base64-kódolt string",base64url:"base64url-kódolt string",json_string:"JSON string",e164:"E.164 szám",jwt:"JWT",template_literal:"bemenet"},J={nan:"NaN",number:"szám",array:"tömb"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Érvénytelen bemenet: a várt érték instanceof ${_.expected}, a kapott érték ${W}`;return`Érvénytelen bemenet: a várt érték ${z}, a kapott érték ${W}`}case"invalid_value":if(_.values.length===1)return`Érvénytelen bemenet: a várt érték ${m(_.values[0])}`;return`Érvénytelen opció: valamelyik érték várt ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Túl nagy: ${_.origin??"érték"} mérete túl nagy ${z}${_.maximum.toString()} ${K.unit??"elem"}`;return`Túl nagy: a bemeneti érték ${_.origin??"érték"} túl nagy: ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Túl kicsi: a bemeneti érték ${_.origin} mérete túl kicsi ${z}${_.minimum.toString()} ${K.unit}`;return`Túl kicsi: a bemeneti érték ${_.origin} túl kicsi ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Érvénytelen string: "${z.prefix}" értékkel kell kezdődnie`;if(z.format==="ends_with")return`Érvénytelen string: "${z.suffix}" értékkel kell végződnie`;if(z.format==="includes")return`Érvénytelen string: "${z.includes}" értéket kell tartalmaznia`;if(z.format==="regex")return`Érvénytelen string: ${z.pattern} mintának kell megfelelnie`;return`Érvénytelen ${v[z.format]??_.format}`}case"not_multiple_of":return`Érvénytelen szám: ${_.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${_.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${_.origin}`;default:return"Érvénytelen bemenet"}}};function pz(){return{localeError:Qb()}}function rq($,U,v){return Math.abs($)===1?U:v}function rU($){if(!$)return"";let U=["ա","ե","ը","ի","ո","ու","օ"],v=$[$.length-1];return $+(U.includes(v)?"ն":"ը")}var Lb=()=>{let $={string:{unit:{one:"նշան",many:"նշաններ"},verb:"ունենալ"},file:{unit:{one:"բայթ",many:"բայթեր"},verb:"ունենալ"},array:{unit:{one:"տարր",many:"տարրեր"},verb:"ունենալ"},set:{unit:{one:"տարր",many:"տարրեր"},verb:"ունենալ"}};function U(_){return $[_]??null}let v={regex:"մուտք",email:"էլ. հասցե",url:"URL",emoji:"էմոջի",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO ամսաթիվ և ժամ",date:"ISO ամսաթիվ",time:"ISO ժամ",duration:"ISO տևողություն",ipv4:"IPv4 հասցե",ipv6:"IPv6 հասցե",cidrv4:"IPv4 միջակայք",cidrv6:"IPv6 միջակայք",base64:"base64 ձևաչափով տող",base64url:"base64url ձևաչափով տող",json_string:"JSON տող",e164:"E.164 համար",jwt:"JWT",template_literal:"մուտք"},J={nan:"NaN",number:"թիվ",array:"զանգված"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Սխալ մուտքագրում․ սպասվում էր instanceof ${_.expected}, ստացվել է ${W}`;return`Սխալ մուտքագրում․ սպասվում էր ${z}, ստացվել է ${W}`}case"invalid_value":if(_.values.length===1)return`Սխալ մուտքագրում․ սպասվում էր ${m(_.values[1])}`;return`Սխալ տարբերակ․ սպասվում էր հետևյալներից մեկը՝ ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K){let W=Number(_.maximum),O=rq(W,K.unit.one,K.unit.many);return`Չափազանց մեծ արժեք․ սպասվում է, որ ${rU(_.origin??"արժեք")} կունենա ${z}${_.maximum.toString()} ${O}`}return`Չափազանց մեծ արժեք․ սպասվում է, որ ${rU(_.origin??"արժեք")} լինի ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K){let W=Number(_.minimum),O=rq(W,K.unit.one,K.unit.many);return`Չափազանց փոքր արժեք․ սպասվում է, որ ${rU(_.origin)} կունենա ${z}${_.minimum.toString()} ${O}`}return`Չափազանց փոքր արժեք․ սպասվում է, որ ${rU(_.origin)} լինի ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Սխալ տող․ պետք է սկսվի "${z.prefix}"-ով`;if(z.format==="ends_with")return`Սխալ տող․ պետք է ավարտվի "${z.suffix}"-ով`;if(z.format==="includes")return`Սխալ տող․ պետք է պարունակի "${z.includes}"`;if(z.format==="regex")return`Սխալ տող․ պետք է համապատասխանի ${z.pattern} ձևաչափին`;return`Սխալ ${v[z.format]??_.format}`}case"not_multiple_of":return`Սխալ թիվ․ պետք է բազմապատիկ լինի ${_.divisor}-ի`;case"unrecognized_keys":return`Չճանաչված բանալի${_.keys.length>1?"ներ":""}. ${w(_.keys,", ")}`;case"invalid_key":return`Սխալ բանալի ${rU(_.origin)}-ում`;case"invalid_union":return"Սխալ մուտքագրում";case"invalid_element":return`Սխալ արժեք ${rU(_.origin)}-ում`;default:return"Սխալ մուտքագրում"}}};function oz(){return{localeError:Lb()}}var Fb=()=>{let $={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function U(_){return $[_]??null}let v={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Input tidak valid: diharapkan instanceof ${_.expected}, diterima ${W}`;return`Input tidak valid: diharapkan ${z}, diterima ${W}`}case"invalid_value":if(_.values.length===1)return`Input tidak valid: diharapkan ${m(_.values[0])}`;return`Pilihan tidak valid: diharapkan salah satu dari ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Terlalu besar: diharapkan ${_.origin??"value"} memiliki ${z}${_.maximum.toString()} ${K.unit??"elemen"}`;return`Terlalu besar: diharapkan ${_.origin??"value"} menjadi ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Terlalu kecil: diharapkan ${_.origin} memiliki ${z}${_.minimum.toString()} ${K.unit}`;return`Terlalu kecil: diharapkan ${_.origin} menjadi ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`String tidak valid: harus dimulai dengan "${z.prefix}"`;if(z.format==="ends_with")return`String tidak valid: harus berakhir dengan "${z.suffix}"`;if(z.format==="includes")return`String tidak valid: harus menyertakan "${z.includes}"`;if(z.format==="regex")return`String tidak valid: harus sesuai pola ${z.pattern}`;return`${v[z.format]??_.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${_.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${_.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${_.origin}`;default:return"Input tidak valid"}}};function dz(){return{localeError:Fb()}}var Pb=()=>{let $={string:{unit:"stafi",verb:"að hafa"},file:{unit:"bæti",verb:"að hafa"},array:{unit:"hluti",verb:"að hafa"},set:{unit:"hluti",verb:"að hafa"}};function U(_){return $[_]??null}let v={regex:"gildi",email:"netfang",url:"vefslóð",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og tími",date:"ISO dagsetning",time:"ISO tími",duration:"ISO tímalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 tölugildi",jwt:"JWT",template_literal:"gildi"},J={nan:"NaN",number:"númer",array:"fylki"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Rangt gildi: Þú slóst inn ${W} þar sem á að vera instanceof ${_.expected}`;return`Rangt gildi: Þú slóst inn ${W} þar sem á að vera ${z}`}case"invalid_value":if(_.values.length===1)return`Rangt gildi: gert ráð fyrir ${m(_.values[0])}`;return`Ógilt val: má vera eitt af eftirfarandi ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Of stórt: gert er ráð fyrir að ${_.origin??"gildi"} hafi ${z}${_.maximum.toString()} ${K.unit??"hluti"}`;return`Of stórt: gert er ráð fyrir að ${_.origin??"gildi"} sé ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Of lítið: gert er ráð fyrir að ${_.origin} hafi ${z}${_.minimum.toString()} ${K.unit}`;return`Of lítið: gert er ráð fyrir að ${_.origin} sé ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ógildur strengur: verður að byrja á "${z.prefix}"`;if(z.format==="ends_with")return`Ógildur strengur: verður að enda á "${z.suffix}"`;if(z.format==="includes")return`Ógildur strengur: verður að innihalda "${z.includes}"`;if(z.format==="regex")return`Ógildur strengur: verður að fylgja mynstri ${z.pattern}`;return`Rangt ${v[z.format]??_.format}`}case"not_multiple_of":return`Röng tala: verður að vera margfeldi af ${_.divisor}`;case"unrecognized_keys":return`Óþekkt ${_.keys.length>1?"ir lyklar":"ur lykill"}: ${w(_.keys,", ")}`;case"invalid_key":return`Rangur lykill í ${_.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi í ${_.origin}`;default:return"Rangt gildi"}}};function nz(){return{localeError:Pb()}}var kb=()=>{let $={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function U(_){return $[_]??null}let v={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},J={nan:"NaN",number:"numero",array:"vettore"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Input non valido: atteso instanceof ${_.expected}, ricevuto ${W}`;return`Input non valido: atteso ${z}, ricevuto ${W}`}case"invalid_value":if(_.values.length===1)return`Input non valido: atteso ${m(_.values[0])}`;return`Opzione non valida: atteso uno tra ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Troppo grande: ${_.origin??"valore"} deve avere ${z}${_.maximum.toString()} ${K.unit??"elementi"}`;return`Troppo grande: ${_.origin??"valore"} deve essere ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Troppo piccolo: ${_.origin} deve avere ${z}${_.minimum.toString()} ${K.unit}`;return`Troppo piccolo: ${_.origin} deve essere ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Stringa non valida: deve iniziare con "${z.prefix}"`;if(z.format==="ends_with")return`Stringa non valida: deve terminare con "${z.suffix}"`;if(z.format==="includes")return`Stringa non valida: deve includere "${z.includes}"`;if(z.format==="regex")return`Stringa non valida: deve corrispondere al pattern ${z.pattern}`;return`Invalid ${v[z.format]??_.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${_.divisor}`;case"unrecognized_keys":return`Chiav${_.keys.length>1?"i":"e"} non riconosciut${_.keys.length>1?"e":"a"}: ${w(_.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${_.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${_.origin}`;default:return"Input non valido"}}};function tz(){return{localeError:kb()}}var bb=()=>{let $={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function U(_){return $[_]??null}let v={regex:"入力値",email:"メールアドレス",url:"URL",emoji:"絵文字",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日時",date:"ISO日付",time:"ISO時刻",duration:"ISO期間",ipv4:"IPv4アドレス",ipv6:"IPv6アドレス",cidrv4:"IPv4範囲",cidrv6:"IPv6範囲",base64:"base64エンコード文字列",base64url:"base64urlエンコード文字列",json_string:"JSON文字列",e164:"E.164番号",jwt:"JWT",template_literal:"入力値"},J={nan:"NaN",number:"数値",array:"配列"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`無効な入力: instanceof ${_.expected}が期待されましたが、${W}が入力されました`;return`無効な入力: ${z}が期待されましたが、${W}が入力されました`}case"invalid_value":if(_.values.length===1)return`無効な入力: ${m(_.values[0])}が期待されました`;return`無効な選択: ${w(_.values,"、")}のいずれかである必要があります`;case"too_big":{let z=_.inclusive?"以下である":"より小さい",K=U(_.origin);if(K)return`大きすぎる値: ${_.origin??"値"}は${_.maximum.toString()}${K.unit??"要素"}${z}必要があります`;return`大きすぎる値: ${_.origin??"値"}は${_.maximum.toString()}${z}必要があります`}case"too_small":{let z=_.inclusive?"以上である":"より大きい",K=U(_.origin);if(K)return`小さすぎる値: ${_.origin}は${_.minimum.toString()}${K.unit}${z}必要があります`;return`小さすぎる値: ${_.origin}は${_.minimum.toString()}${z}必要があります`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`無効な文字列: "${z.prefix}"で始まる必要があります`;if(z.format==="ends_with")return`無効な文字列: "${z.suffix}"で終わる必要があります`;if(z.format==="includes")return`無効な文字列: "${z.includes}"を含む必要があります`;if(z.format==="regex")return`無効な文字列: パターン${z.pattern}に一致する必要があります`;return`無効な${v[z.format]??_.format}`}case"not_multiple_of":return`無効な数値: ${_.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${_.keys.length>1?"群":""}: ${w(_.keys,"、")}`;case"invalid_key":return`${_.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${_.origin}内の無効な値`;default:return"無効な入力"}}};function az(){return{localeError:bb()}}var Mb=()=>{let $={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function U(_){return $[_]??null}let v={regex:"შეყვანა",email:"ელ-ფოსტის მისამართი",url:"URL",emoji:"ემოჯი",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"თარიღი-დრო",date:"თარიღი",time:"დრო",duration:"ხანგრძლივობა",ipv4:"IPv4 მისამართი",ipv6:"IPv6 მისამართი",cidrv4:"IPv4 დიაპაზონი",cidrv6:"IPv6 დიაპაზონი",base64:"base64-კოდირებული სტრინგი",base64url:"base64url-კოდირებული სტრინგი",json_string:"JSON სტრინგი",e164:"E.164 ნომერი",jwt:"JWT",template_literal:"შეყვანა"},J={nan:"NaN",number:"რიცხვი",string:"სტრინგი",boolean:"ბულეანი",function:"ფუნქცია",array:"მასივი"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`არასწორი შეყვანა: მოსალოდნელი instanceof ${_.expected}, მიღებული ${W}`;return`არასწორი შეყვანა: მოსალოდნელი ${z}, მიღებული ${W}`}case"invalid_value":if(_.values.length===1)return`არასწორი შეყვანა: მოსალოდნელი ${m(_.values[0])}`;return`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${w(_.values,"|")}-დან`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`ზედმეტად დიდი: მოსალოდნელი ${_.origin??"მნიშვნელობა"} ${K.verb} ${z}${_.maximum.toString()} ${K.unit}`;return`ზედმეტად დიდი: მოსალოდნელი ${_.origin??"მნიშვნელობა"} იყოს ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`ზედმეტად პატარა: მოსალოდნელი ${_.origin} ${K.verb} ${z}${_.minimum.toString()} ${K.unit}`;return`ზედმეტად პატარა: მოსალოდნელი ${_.origin} იყოს ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`არასწორი სტრინგი: უნდა იწყებოდეს "${z.prefix}"-ით`;if(z.format==="ends_with")return`არასწორი სტრინგი: უნდა მთავრდებოდეს "${z.suffix}"-ით`;if(z.format==="includes")return`არასწორი სტრინგი: უნდა შეიცავდეს "${z.includes}"-ს`;if(z.format==="regex")return`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${z.pattern}`;return`არასწორი ${v[z.format]??_.format}`}case"not_multiple_of":return`არასწორი რიცხვი: უნდა იყოს ${_.divisor}-ის ჯერადი`;case"unrecognized_keys":return`უცნობი გასაღებ${_.keys.length>1?"ები":"ი"}: ${w(_.keys,", ")}`;case"invalid_key":return`არასწორი გასაღები ${_.origin}-ში`;case"invalid_union":return"არასწორი შეყვანა";case"invalid_element":return`არასწორი მნიშვნელობა ${_.origin}-ში`;default:return"არასწორი შეყვანა"}}};function sz(){return{localeError:Mb()}}var Ab=()=>{let $={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function U(_){return $[_]??null}let v={regex:"ទិន្នន័យបញ្ចូល",email:"អាសយដ្ឋានអ៊ីមែល",url:"URL",emoji:"សញ្ញាអារម្មណ៍",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"កាលបរិច្ឆេទ និងម៉ោង ISO",date:"កាលបរិច្ឆេទ ISO",time:"ម៉ោង ISO",duration:"រយៈពេល ISO",ipv4:"អាសយដ្ឋាន IPv4",ipv6:"អាសយដ្ឋាន IPv6",cidrv4:"ដែនអាសយដ្ឋាន IPv4",cidrv6:"ដែនអាសយដ្ឋាន IPv6",base64:"ខ្សែអក្សរអ៊ិកូដ base64",base64url:"ខ្សែអក្សរអ៊ិកូដ base64url",json_string:"ខ្សែអក្សរ JSON",e164:"លេខ E.164",jwt:"JWT",template_literal:"ទិន្នន័យបញ្ចូល"},J={nan:"NaN",number:"លេខ",array:"អារេ (Array)",null:"គ្មានតម្លៃ (null)"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ instanceof ${_.expected} ប៉ុន្តែទទួលបាន ${W}`;return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${z} ប៉ុន្តែទទួលបាន ${W}`}case"invalid_value":if(_.values.length===1)return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${m(_.values[0])}`;return`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`ធំពេក៖ ត្រូវការ ${_.origin??"តម្លៃ"} ${z} ${_.maximum.toString()} ${K.unit??"ធាតុ"}`;return`ធំពេក៖ ត្រូវការ ${_.origin??"តម្លៃ"} ${z} ${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`តូចពេក៖ ត្រូវការ ${_.origin} ${z} ${_.minimum.toString()} ${K.unit}`;return`តូចពេក៖ ត្រូវការ ${_.origin} ${z} ${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${z.prefix}"`;if(z.format==="ends_with")return`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${z.suffix}"`;if(z.format==="includes")return`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${z.includes}"`;if(z.format==="regex")return`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${z.pattern}`;return`មិនត្រឹមត្រូវ៖ ${v[z.format]??_.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${_.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${w(_.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${_.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${_.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function k_(){return{localeError:Ab()}}function ez(){return k_()}var Ib=()=>{let $={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function U(_){return $[_]??null}let v={regex:"입력",email:"이메일 주소",url:"URL",emoji:"이모지",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 날짜시간",date:"ISO 날짜",time:"ISO 시간",duration:"ISO 기간",ipv4:"IPv4 주소",ipv6:"IPv6 주소",cidrv4:"IPv4 범위",cidrv6:"IPv6 범위",base64:"base64 인코딩 문자열",base64url:"base64url 인코딩 문자열",json_string:"JSON 문자열",e164:"E.164 번호",jwt:"JWT",template_literal:"입력"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`잘못된 입력: 예상 타입은 instanceof ${_.expected}, 받은 타입은 ${W}입니다`;return`잘못된 입력: 예상 타입은 ${z}, 받은 타입은 ${W}입니다`}case"invalid_value":if(_.values.length===1)return`잘못된 입력: 값은 ${m(_.values[0])} 이어야 합니다`;return`잘못된 옵션: ${w(_.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{let z=_.inclusive?"이하":"미만",K=z==="미만"?"이어야 합니다":"여야 합니다",W=U(_.origin),O=W?.unit??"요소";if(W)return`${_.origin??"값"}이 너무 큽니다: ${_.maximum.toString()}${O} ${z}${K}`;return`${_.origin??"값"}이 너무 큽니다: ${_.maximum.toString()} ${z}${K}`}case"too_small":{let z=_.inclusive?"이상":"초과",K=z==="이상"?"이어야 합니다":"여야 합니다",W=U(_.origin),O=W?.unit??"요소";if(W)return`${_.origin??"값"}이 너무 작습니다: ${_.minimum.toString()}${O} ${z}${K}`;return`${_.origin??"값"}이 너무 작습니다: ${_.minimum.toString()} ${z}${K}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`잘못된 문자열: "${z.prefix}"(으)로 시작해야 합니다`;if(z.format==="ends_with")return`잘못된 문자열: "${z.suffix}"(으)로 끝나야 합니다`;if(z.format==="includes")return`잘못된 문자열: "${z.includes}"을(를) 포함해야 합니다`;if(z.format==="regex")return`잘못된 문자열: 정규식 ${z.pattern} 패턴과 일치해야 합니다`;return`잘못된 ${v[z.format]??_.format}`}case"not_multiple_of":return`잘못된 숫자: ${_.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${w(_.keys,", ")}`;case"invalid_key":return`잘못된 키: ${_.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${_.origin}`;default:return"잘못된 입력"}}};function $7(){return{localeError:Ib()}}var b_=($)=>{return $.charAt(0).toUpperCase()+$.slice(1)};function iq($){let U=Math.abs($),v=U%10,J=U%100;if(J>=11&&J<=19||v===0)return"many";if(v===1)return"one";return"few"}var wb=()=>{let $={string:{unit:{one:"simbolis",few:"simboliai",many:"simbolių"},verb:{smaller:{inclusive:"turi būti ne ilgesnė kaip",notInclusive:"turi būti trumpesnė kaip"},bigger:{inclusive:"turi būti ne trumpesnė kaip",notInclusive:"turi būti ilgesnė kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"baitų"},verb:{smaller:{inclusive:"turi būti ne didesnis kaip",notInclusive:"turi būti mažesnis kaip"},bigger:{inclusive:"turi būti ne mažesnis kaip",notInclusive:"turi būti didesnis kaip"}}},array:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}},set:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}}};function U(_,z,K,W){let O=$[_]??null;if(O===null)return O;return{unit:O.unit[z],verb:O.verb[W][K?"inclusive":"notInclusive"]}}let v={regex:"įvestis",email:"el. pašto adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukmė",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 užkoduota eilutė",base64url:"base64url užkoduota eilutė",json_string:"JSON eilutė",e164:"E.164 numeris",jwt:"JWT",template_literal:"įvestis"},J={nan:"NaN",number:"skaičius",bigint:"sveikasis skaičius",string:"eilutė",boolean:"loginė reikšmė",undefined:"neapibrėžta reikšmė",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulinė reikšmė"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Gautas tipas ${W}, o tikėtasi - instanceof ${_.expected}`;return`Gautas tipas ${W}, o tikėtasi - ${z}`}case"invalid_value":if(_.values.length===1)return`Privalo būti ${m(_.values[0])}`;return`Privalo būti vienas iš ${w(_.values,"|")} pasirinkimų`;case"too_big":{let z=J[_.origin]??_.origin,K=U(_.origin,iq(Number(_.maximum)),_.inclusive??!1,"smaller");if(K?.verb)return`${b_(z??_.origin??"reikšmė")} ${K.verb} ${_.maximum.toString()} ${K.unit??"elementų"}`;let W=_.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${b_(z??_.origin??"reikšmė")} turi būti ${W} ${_.maximum.toString()} ${K?.unit}`}case"too_small":{let z=J[_.origin]??_.origin,K=U(_.origin,iq(Number(_.minimum)),_.inclusive??!1,"bigger");if(K?.verb)return`${b_(z??_.origin??"reikšmė")} ${K.verb} ${_.minimum.toString()} ${K.unit??"elementų"}`;let W=_.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${b_(z??_.origin??"reikšmė")} turi būti ${W} ${_.minimum.toString()} ${K?.unit}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Eilutė privalo prasidėti "${z.prefix}"`;if(z.format==="ends_with")return`Eilutė privalo pasibaigti "${z.suffix}"`;if(z.format==="includes")return`Eilutė privalo įtraukti "${z.includes}"`;if(z.format==="regex")return`Eilutė privalo atitikti ${z.pattern}`;return`Neteisingas ${v[z.format]??_.format}`}case"not_multiple_of":return`Skaičius privalo būti ${_.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpažint${_.keys.length>1?"i":"as"} rakt${_.keys.length>1?"ai":"as"}: ${w(_.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga įvestis";case"invalid_element":{let z=J[_.origin]??_.origin;return`${b_(z??_.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function U7(){return{localeError:wb()}}var gb=()=>{let $={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function U(_){return $[_]??null}let v={regex:"внес",email:"адреса на е-пошта",url:"URL",emoji:"емоџи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO датум и време",date:"ISO датум",time:"ISO време",duration:"ISO времетраење",ipv4:"IPv4 адреса",ipv6:"IPv6 адреса",cidrv4:"IPv4 опсег",cidrv6:"IPv6 опсег",base64:"base64-енкодирана низа",base64url:"base64url-енкодирана низа",json_string:"JSON низа",e164:"E.164 број",jwt:"JWT",template_literal:"внес"},J={nan:"NaN",number:"број",array:"низа"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Грешен внес: се очекува instanceof ${_.expected}, примено ${W}`;return`Грешен внес: се очекува ${z}, примено ${W}`}case"invalid_value":if(_.values.length===1)return`Invalid input: expected ${m(_.values[0])}`;return`Грешана опција: се очекува една ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Премногу голем: се очекува ${_.origin??"вредноста"} да има ${z}${_.maximum.toString()} ${K.unit??"елементи"}`;return`Премногу голем: се очекува ${_.origin??"вредноста"} да биде ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Премногу мал: се очекува ${_.origin} да има ${z}${_.minimum.toString()} ${K.unit}`;return`Премногу мал: се очекува ${_.origin} да биде ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Неважечка низа: мора да започнува со "${z.prefix}"`;if(z.format==="ends_with")return`Неважечка низа: мора да завршува со "${z.suffix}"`;if(z.format==="includes")return`Неважечка низа: мора да вклучува "${z.includes}"`;if(z.format==="regex")return`Неважечка низа: мора да одгоара на патернот ${z.pattern}`;return`Invalid ${v[z.format]??_.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${_.divisor}`;case"unrecognized_keys":return`${_.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${w(_.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${_.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${_.origin}`;default:return"Грешен внес"}}};function _7(){return{localeError:gb()}}var Nb=()=>{let $={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function U(_){return $[_]??null}let v={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},J={nan:"NaN",number:"nombor"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Input tidak sah: dijangka instanceof ${_.expected}, diterima ${W}`;return`Input tidak sah: dijangka ${z}, diterima ${W}`}case"invalid_value":if(_.values.length===1)return`Input tidak sah: dijangka ${m(_.values[0])}`;return`Pilihan tidak sah: dijangka salah satu daripada ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Terlalu besar: dijangka ${_.origin??"nilai"} ${K.verb} ${z}${_.maximum.toString()} ${K.unit??"elemen"}`;return`Terlalu besar: dijangka ${_.origin??"nilai"} adalah ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Terlalu kecil: dijangka ${_.origin} ${K.verb} ${z}${_.minimum.toString()} ${K.unit}`;return`Terlalu kecil: dijangka ${_.origin} adalah ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`String tidak sah: mesti bermula dengan "${z.prefix}"`;if(z.format==="ends_with")return`String tidak sah: mesti berakhir dengan "${z.suffix}"`;if(z.format==="includes")return`String tidak sah: mesti mengandungi "${z.includes}"`;if(z.format==="regex")return`String tidak sah: mesti sepadan dengan corak ${z.pattern}`;return`${v[z.format]??_.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${_.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${w(_.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${_.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${_.origin}`;default:return"Input tidak sah"}}};function v7(){return{localeError:Nb()}}var Sb=()=>{let $={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function U(_){return $[_]??null}let v={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},J={nan:"NaN",number:"getal"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ongeldige invoer: verwacht instanceof ${_.expected}, ontving ${W}`;return`Ongeldige invoer: verwacht ${z}, ontving ${W}`}case"invalid_value":if(_.values.length===1)return`Ongeldige invoer: verwacht ${m(_.values[0])}`;return`Ongeldige optie: verwacht één van ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin),W=_.origin==="date"?"laat":_.origin==="string"?"lang":"groot";if(K)return`Te ${W}: verwacht dat ${_.origin??"waarde"} ${z}${_.maximum.toString()} ${K.unit??"elementen"} ${K.verb}`;return`Te ${W}: verwacht dat ${_.origin??"waarde"} ${z}${_.maximum.toString()} is`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin),W=_.origin==="date"?"vroeg":_.origin==="string"?"kort":"klein";if(K)return`Te ${W}: verwacht dat ${_.origin} ${z}${_.minimum.toString()} ${K.unit} ${K.verb}`;return`Te ${W}: verwacht dat ${_.origin} ${z}${_.minimum.toString()} is`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ongeldige tekst: moet met "${z.prefix}" beginnen`;if(z.format==="ends_with")return`Ongeldige tekst: moet op "${z.suffix}" eindigen`;if(z.format==="includes")return`Ongeldige tekst: moet "${z.includes}" bevatten`;if(z.format==="regex")return`Ongeldige tekst: moet overeenkomen met patroon ${z.pattern}`;return`Ongeldig: ${v[z.format]??_.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${_.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${_.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${_.origin}`;default:return"Ongeldige invoer"}}};function J7(){return{localeError:Sb()}}var Rb=()=>{let $={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function U(_){return $[_]??null}let v={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},J={nan:"NaN",number:"tall",array:"liste"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ugyldig input: forventet instanceof ${_.expected}, fikk ${W}`;return`Ugyldig input: forventet ${z}, fikk ${W}`}case"invalid_value":if(_.values.length===1)return`Ugyldig verdi: forventet ${m(_.values[0])}`;return`Ugyldig valg: forventet en av ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`For stor(t): forventet ${_.origin??"value"} til å ha ${z}${_.maximum.toString()} ${K.unit??"elementer"}`;return`For stor(t): forventet ${_.origin??"value"} til å ha ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`For lite(n): forventet ${_.origin} til å ha ${z}${_.minimum.toString()} ${K.unit}`;return`For lite(n): forventet ${_.origin} til å ha ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ugyldig streng: må starte med "${z.prefix}"`;if(z.format==="ends_with")return`Ugyldig streng: må ende med "${z.suffix}"`;if(z.format==="includes")return`Ugyldig streng: må inneholde "${z.includes}"`;if(z.format==="regex")return`Ugyldig streng: må matche mønsteret ${z.pattern}`;return`Ugyldig ${v[z.format]??_.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${_.divisor}`;case"unrecognized_keys":return`${_.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${w(_.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${_.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${_.origin}`;default:return"Ugyldig input"}}};function z7(){return{localeError:Rb()}}var Tb=()=>{let $={string:{unit:"harf",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"unsur",verb:"olmalıdır"},set:{unit:"unsur",verb:"olmalıdır"}};function U(_){return $[_]??null}let v={regex:"giren",email:"epostagâh",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO hengâmı",date:"ISO tarihi",time:"ISO zamanı",duration:"ISO müddeti",ipv4:"IPv4 nişânı",ipv6:"IPv6 nişânı",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-şifreli metin",base64url:"base64url-şifreli metin",json_string:"JSON metin",e164:"E.164 sayısı",jwt:"JWT",template_literal:"giren"},J={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Fâsit giren: umulan instanceof ${_.expected}, alınan ${W}`;return`Fâsit giren: umulan ${z}, alınan ${W}`}case"invalid_value":if(_.values.length===1)return`Fâsit giren: umulan ${m(_.values[0])}`;return`Fâsit tercih: mûteberler ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Fazla büyük: ${_.origin??"value"}, ${z}${_.maximum.toString()} ${K.unit??"elements"} sahip olmalıydı.`;return`Fazla büyük: ${_.origin??"value"}, ${z}${_.maximum.toString()} olmalıydı.`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Fazla küçük: ${_.origin}, ${z}${_.minimum.toString()} ${K.unit} sahip olmalıydı.`;return`Fazla küçük: ${_.origin}, ${z}${_.minimum.toString()} olmalıydı.`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Fâsit metin: "${z.prefix}" ile başlamalı.`;if(z.format==="ends_with")return`Fâsit metin: "${z.suffix}" ile bitmeli.`;if(z.format==="includes")return`Fâsit metin: "${z.includes}" ihtivâ etmeli.`;if(z.format==="regex")return`Fâsit metin: ${z.pattern} nakşına uymalı.`;return`Fâsit ${v[z.format]??_.format}`}case"not_multiple_of":return`Fâsit sayı: ${_.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${_.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function K7(){return{localeError:Tb()}}var yb=()=>{let $={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function U(_){return $[_]??null}let v={regex:"ورودي",email:"بریښنالیک",url:"یو آر ال",emoji:"ایموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"نیټه او وخت",date:"نېټه",time:"وخت",duration:"موده",ipv4:"د IPv4 پته",ipv6:"د IPv6 پته",cidrv4:"د IPv4 ساحه",cidrv6:"د IPv6 ساحه",base64:"base64-encoded متن",base64url:"base64url-encoded متن",json_string:"JSON متن",e164:"د E.164 شمېره",jwt:"JWT",template_literal:"ورودي"},J={nan:"NaN",number:"عدد",array:"ارې"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`ناسم ورودي: باید instanceof ${_.expected} وای, مګر ${W} ترلاسه شو`;return`ناسم ورودي: باید ${z} وای, مګر ${W} ترلاسه شو`}case"invalid_value":if(_.values.length===1)return`ناسم ورودي: باید ${m(_.values[0])} وای`;return`ناسم انتخاب: باید یو له ${w(_.values,"|")} څخه وای`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`ډیر لوی: ${_.origin??"ارزښت"} باید ${z}${_.maximum.toString()} ${K.unit??"عنصرونه"} ولري`;return`ډیر لوی: ${_.origin??"ارزښت"} باید ${z}${_.maximum.toString()} وي`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`ډیر کوچنی: ${_.origin} باید ${z}${_.minimum.toString()} ${K.unit} ولري`;return`ډیر کوچنی: ${_.origin} باید ${z}${_.minimum.toString()} وي`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`ناسم متن: باید د "${z.prefix}" سره پیل شي`;if(z.format==="ends_with")return`ناسم متن: باید د "${z.suffix}" سره پای ته ورسيږي`;if(z.format==="includes")return`ناسم متن: باید "${z.includes}" ولري`;if(z.format==="regex")return`ناسم متن: باید د ${z.pattern} سره مطابقت ولري`;return`${v[z.format]??_.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${_.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${_.keys.length>1?"کلیډونه":"کلیډ"}: ${w(_.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${_.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${_.origin} کې`;default:return"ناسمه ورودي"}}};function G7(){return{localeError:yb()}}var Cb=()=>{let $={string:{unit:"znaków",verb:"mieć"},file:{unit:"bajtów",verb:"mieć"},array:{unit:"elementów",verb:"mieć"},set:{unit:"elementów",verb:"mieć"}};function U(_){return $[_]??null}let v={regex:"wyrażenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ciąg znaków zakodowany w formacie base64",base64url:"ciąg znaków zakodowany w formacie base64url",json_string:"ciąg znaków w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wejście"},J={nan:"NaN",number:"liczba",array:"tablica"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Nieprawidłowe dane wejściowe: oczekiwano instanceof ${_.expected}, otrzymano ${W}`;return`Nieprawidłowe dane wejściowe: oczekiwano ${z}, otrzymano ${W}`}case"invalid_value":if(_.values.length===1)return`Nieprawidłowe dane wejściowe: oczekiwano ${m(_.values[0])}`;return`Nieprawidłowa opcja: oczekiwano jednej z wartości ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Za duża wartość: oczekiwano, że ${_.origin??"wartość"} będzie mieć ${z}${_.maximum.toString()} ${K.unit??"elementów"}`;return`Zbyt duż(y/a/e): oczekiwano, że ${_.origin??"wartość"} będzie wynosić ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Za mała wartość: oczekiwano, że ${_.origin??"wartość"} będzie mieć ${z}${_.minimum.toString()} ${K.unit??"elementów"}`;return`Zbyt mał(y/a/e): oczekiwano, że ${_.origin??"wartość"} będzie wynosić ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Nieprawidłowy ciąg znaków: musi zaczynać się od "${z.prefix}"`;if(z.format==="ends_with")return`Nieprawidłowy ciąg znaków: musi kończyć się na "${z.suffix}"`;if(z.format==="includes")return`Nieprawidłowy ciąg znaków: musi zawierać "${z.includes}"`;if(z.format==="regex")return`Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${z.pattern}`;return`Nieprawidłow(y/a/e) ${v[z.format]??_.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${_.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${_.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${_.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function W7(){return{localeError:Cb()}}var Db=()=>{let $={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function U(_){return $[_]??null}let v={regex:"padrão",email:"endereço de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"duração ISO",ipv4:"endereço IPv4",ipv6:"endereço IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"},J={nan:"NaN",number:"número",null:"nulo"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Tipo inválido: esperado instanceof ${_.expected}, recebido ${W}`;return`Tipo inválido: esperado ${z}, recebido ${W}`}case"invalid_value":if(_.values.length===1)return`Entrada inválida: esperado ${m(_.values[0])}`;return`Opção inválida: esperada uma das ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Muito grande: esperado que ${_.origin??"valor"} tivesse ${z}${_.maximum.toString()} ${K.unit??"elementos"}`;return`Muito grande: esperado que ${_.origin??"valor"} fosse ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Muito pequeno: esperado que ${_.origin} tivesse ${z}${_.minimum.toString()} ${K.unit}`;return`Muito pequeno: esperado que ${_.origin} fosse ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Texto inválido: deve começar com "${z.prefix}"`;if(z.format==="ends_with")return`Texto inválido: deve terminar com "${z.suffix}"`;if(z.format==="includes")return`Texto inválido: deve incluir "${z.includes}"`;if(z.format==="regex")return`Texto inválido: deve corresponder ao padrão ${z.pattern}`;return`${v[z.format]??_.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${_.divisor}`;case"unrecognized_keys":return`Chave${_.keys.length>1?"s":""} desconhecida${_.keys.length>1?"s":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Chave inválida em ${_.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${_.origin}`;default:return"Campo inválido"}}};function O7(){return{localeError:Db()}}function pq($,U,v,J){let _=Math.abs($),z=_%10,K=_%100;if(K>=11&&K<=19)return J;if(z===1)return U;if(z>=2&&z<=4)return v;return J}var jb=()=>{let $={string:{unit:{one:"символ",few:"символа",many:"символов"},verb:"иметь"},file:{unit:{one:"байт",few:"байта",many:"байт"},verb:"иметь"},array:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"},set:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"}};function U(_){return $[_]??null}let v={regex:"ввод",email:"email адрес",url:"URL",emoji:"эмодзи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата и время",date:"ISO дата",time:"ISO время",duration:"ISO длительность",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"строка в формате base64",base64url:"строка в формате base64url",json_string:"JSON строка",e164:"номер E.164",jwt:"JWT",template_literal:"ввод"},J={nan:"NaN",number:"число",array:"массив"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Неверный ввод: ожидалось instanceof ${_.expected}, получено ${W}`;return`Неверный ввод: ожидалось ${z}, получено ${W}`}case"invalid_value":if(_.values.length===1)return`Неверный ввод: ожидалось ${m(_.values[0])}`;return`Неверный вариант: ожидалось одно из ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K){let W=Number(_.maximum),O=pq(W,K.unit.one,K.unit.few,K.unit.many);return`Слишком большое значение: ожидалось, что ${_.origin??"значение"} будет иметь ${z}${_.maximum.toString()} ${O}`}return`Слишком большое значение: ожидалось, что ${_.origin??"значение"} будет ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K){let W=Number(_.minimum),O=pq(W,K.unit.one,K.unit.few,K.unit.many);return`Слишком маленькое значение: ожидалось, что ${_.origin} будет иметь ${z}${_.minimum.toString()} ${O}`}return`Слишком маленькое значение: ожидалось, что ${_.origin} будет ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Неверная строка: должна начинаться с "${z.prefix}"`;if(z.format==="ends_with")return`Неверная строка: должна заканчиваться на "${z.suffix}"`;if(z.format==="includes")return`Неверная строка: должна содержать "${z.includes}"`;if(z.format==="regex")return`Неверная строка: должна соответствовать шаблону ${z.pattern}`;return`Неверный ${v[z.format]??_.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${_.divisor}`;case"unrecognized_keys":return`Нераспознанн${_.keys.length>1?"ые":"ый"} ключ${_.keys.length>1?"и":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${_.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${_.origin}`;default:return"Неверные входные данные"}}};function Y7(){return{localeError:jb()}}var Vb=()=>{let $={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function U(_){return $[_]??null}let v={regex:"vnos",email:"e-poštni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in čas",date:"ISO datum",time:"ISO čas",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 številka",jwt:"JWT",template_literal:"vnos"},J={nan:"NaN",number:"število",array:"tabela"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Neveljaven vnos: pričakovano instanceof ${_.expected}, prejeto ${W}`;return`Neveljaven vnos: pričakovano ${z}, prejeto ${W}`}case"invalid_value":if(_.values.length===1)return`Neveljaven vnos: pričakovano ${m(_.values[0])}`;return`Neveljavna možnost: pričakovano eno izmed ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Preveliko: pričakovano, da bo ${_.origin??"vrednost"} imelo ${z}${_.maximum.toString()} ${K.unit??"elementov"}`;return`Preveliko: pričakovano, da bo ${_.origin??"vrednost"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Premajhno: pričakovano, da bo ${_.origin} imelo ${z}${_.minimum.toString()} ${K.unit}`;return`Premajhno: pričakovano, da bo ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Neveljaven niz: mora se začeti z "${z.prefix}"`;if(z.format==="ends_with")return`Neveljaven niz: mora se končati z "${z.suffix}"`;if(z.format==="includes")return`Neveljaven niz: mora vsebovati "${z.includes}"`;if(z.format==="regex")return`Neveljaven niz: mora ustrezati vzorcu ${z.pattern}`;return`Neveljaven ${v[z.format]??_.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${_.divisor}`;case"unrecognized_keys":return`Neprepoznan${_.keys.length>1?"i ključi":" ključ"}: ${w(_.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${_.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${_.origin}`;default:return"Neveljaven vnos"}}};function Z7(){return{localeError:Vb()}}var fb=()=>{let $={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att innehålla"},set:{unit:"objekt",verb:"att innehålla"}};function U(_){return $[_]??null}let v={regex:"reguljärt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad sträng",base64url:"base64url-kodad sträng",json_string:"JSON-sträng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},J={nan:"NaN",number:"antal",array:"lista"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ogiltig inmatning: förväntat instanceof ${_.expected}, fick ${W}`;return`Ogiltig inmatning: förväntat ${z}, fick ${W}`}case"invalid_value":if(_.values.length===1)return`Ogiltig inmatning: förväntat ${m(_.values[0])}`;return`Ogiltigt val: förväntade en av ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`För stor(t): förväntade ${_.origin??"värdet"} att ha ${z}${_.maximum.toString()} ${K.unit??"element"}`;return`För stor(t): förväntat ${_.origin??"värdet"} att ha ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`För lite(t): förväntade ${_.origin??"värdet"} att ha ${z}${_.minimum.toString()} ${K.unit}`;return`För lite(t): förväntade ${_.origin??"värdet"} att ha ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ogiltig sträng: måste börja med "${z.prefix}"`;if(z.format==="ends_with")return`Ogiltig sträng: måste sluta med "${z.suffix}"`;if(z.format==="includes")return`Ogiltig sträng: måste innehålla "${z.includes}"`;if(z.format==="regex")return`Ogiltig sträng: måste matcha mönstret "${z.pattern}"`;return`Ogiltig(t) ${v[z.format]??_.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${_.divisor}`;case"unrecognized_keys":return`${_.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${w(_.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${_.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${_.origin??"värdet"}`;default:return"Ogiltig input"}}};function q7(){return{localeError:fb()}}var Eb=()=>{let $={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function U(_){return $[_]??null}let v={regex:"உள்ளீடு",email:"மின்னஞ்சல் முகவரி",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO தேதி நேரம்",date:"ISO தேதி",time:"ISO நேரம்",duration:"ISO கால அளவு",ipv4:"IPv4 முகவரி",ipv6:"IPv6 முகவரி",cidrv4:"IPv4 வரம்பு",cidrv6:"IPv6 வரம்பு",base64:"base64-encoded சரம்",base64url:"base64url-encoded சரம்",json_string:"JSON சரம்",e164:"E.164 எண்",jwt:"JWT",template_literal:"input"},J={nan:"NaN",number:"எண்",array:"அணி",null:"வெறுமை"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது instanceof ${_.expected}, பெறப்பட்டது ${W}`;return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${z}, பெறப்பட்டது ${W}`}case"invalid_value":if(_.values.length===1)return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${m(_.values[0])}`;return`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${w(_.values,"|")} இல் ஒன்று`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${_.origin??"மதிப்பு"} ${z}${_.maximum.toString()} ${K.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`;return`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${_.origin??"மதிப்பு"} ${z}${_.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${_.origin} ${z}${_.minimum.toString()} ${K.unit} ஆக இருக்க வேண்டும்`;return`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${_.origin} ${z}${_.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`தவறான சரம்: "${z.prefix}" இல் தொடங்க வேண்டும்`;if(z.format==="ends_with")return`தவறான சரம்: "${z.suffix}" இல் முடிவடைய வேண்டும்`;if(z.format==="includes")return`தவறான சரம்: "${z.includes}" ஐ உள்ளடக்க வேண்டும்`;if(z.format==="regex")return`தவறான சரம்: ${z.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`;return`தவறான ${v[z.format]??_.format}`}case"not_multiple_of":return`தவறான எண்: ${_.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${_.keys.length>1?"கள்":""}: ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${_.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function B7(){return{localeError:Eb()}}var ub=()=>{let $={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function U(_){return $[_]??null}let v={regex:"ข้อมูลที่ป้อน",email:"ที่อยู่อีเมล",url:"URL",emoji:"อิโมจิ",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"วันที่เวลาแบบ ISO",date:"วันที่แบบ ISO",time:"เวลาแบบ ISO",duration:"ช่วงเวลาแบบ ISO",ipv4:"ที่อยู่ IPv4",ipv6:"ที่อยู่ IPv6",cidrv4:"ช่วง IP แบบ IPv4",cidrv6:"ช่วง IP แบบ IPv6",base64:"ข้อความแบบ Base64",base64url:"ข้อความแบบ Base64 สำหรับ URL",json_string:"ข้อความแบบ JSON",e164:"เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",jwt:"โทเคน JWT",template_literal:"ข้อมูลที่ป้อน"},J={nan:"NaN",number:"ตัวเลข",array:"อาร์เรย์ (Array)",null:"ไม่มีค่า (null)"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น instanceof ${_.expected} แต่ได้รับ ${W}`;return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${z} แต่ได้รับ ${W}`}case"invalid_value":if(_.values.length===1)return`ค่าไม่ถูกต้อง: ควรเป็น ${m(_.values[0])}`;return`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"ไม่เกิน":"น้อยกว่า",K=U(_.origin);if(K)return`เกินกำหนด: ${_.origin??"ค่า"} ควรมี${z} ${_.maximum.toString()} ${K.unit??"รายการ"}`;return`เกินกำหนด: ${_.origin??"ค่า"} ควรมี${z} ${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?"อย่างน้อย":"มากกว่า",K=U(_.origin);if(K)return`น้อยกว่ากำหนด: ${_.origin} ควรมี${z} ${_.minimum.toString()} ${K.unit}`;return`น้อยกว่ากำหนด: ${_.origin} ควรมี${z} ${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${z.prefix}"`;if(z.format==="ends_with")return`รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${z.suffix}"`;if(z.format==="includes")return`รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${z.includes}" อยู่ในข้อความ`;if(z.format==="regex")return`รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${z.pattern}`;return`รูปแบบไม่ถูกต้อง: ${v[z.format]??_.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${_.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${w(_.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${_.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${_.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function X7(){return{localeError:ub()}}var mb=()=>{let $={string:{unit:"karakter",verb:"olmalı"},file:{unit:"bayt",verb:"olmalı"},array:{unit:"öğe",verb:"olmalı"},set:{unit:"öğe",verb:"olmalı"}};function U(_){return $[_]??null}let v={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO süre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aralığı",cidrv6:"IPv6 aralığı",base64:"base64 ile şifrelenmiş metin",base64url:"base64url ile şifrelenmiş metin",json_string:"JSON dizesi",e164:"E.164 sayısı",jwt:"JWT",template_literal:"Şablon dizesi"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Geçersiz değer: beklenen instanceof ${_.expected}, alınan ${W}`;return`Geçersiz değer: beklenen ${z}, alınan ${W}`}case"invalid_value":if(_.values.length===1)return`Geçersiz değer: beklenen ${m(_.values[0])}`;return`Geçersiz seçenek: aşağıdakilerden biri olmalı: ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Çok büyük: beklenen ${_.origin??"değer"} ${z}${_.maximum.toString()} ${K.unit??"öğe"}`;return`Çok büyük: beklenen ${_.origin??"değer"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Çok küçük: beklenen ${_.origin} ${z}${_.minimum.toString()} ${K.unit}`;return`Çok küçük: beklenen ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Geçersiz metin: "${z.prefix}" ile başlamalı`;if(z.format==="ends_with")return`Geçersiz metin: "${z.suffix}" ile bitmeli`;if(z.format==="includes")return`Geçersiz metin: "${z.includes}" içermeli`;if(z.format==="regex")return`Geçersiz metin: ${z.pattern} desenine uymalı`;return`Geçersiz ${v[z.format]??_.format}`}case"not_multiple_of":return`Geçersiz sayı: ${_.divisor} ile tam bölünebilmeli`;case"unrecognized_keys":return`Tanınmayan anahtar${_.keys.length>1?"lar":""}: ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} içinde geçersiz anahtar`;case"invalid_union":return"Geçersiz değer";case"invalid_element":return`${_.origin} içinde geçersiz değer`;default:return"Geçersiz değer"}}};function H7(){return{localeError:mb()}}var xb=()=>{let $={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function U(_){return $[_]??null}let v={regex:"вхідні дані",email:"адреса електронної пошти",url:"URL",emoji:"емодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"дата та час ISO",date:"дата ISO",time:"час ISO",duration:"тривалість ISO",ipv4:"адреса IPv4",ipv6:"адреса IPv6",cidrv4:"діапазон IPv4",cidrv6:"діапазон IPv6",base64:"рядок у кодуванні base64",base64url:"рядок у кодуванні base64url",json_string:"рядок JSON",e164:"номер E.164",jwt:"JWT",template_literal:"вхідні дані"},J={nan:"NaN",number:"число",array:"масив"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Неправильні вхідні дані: очікується instanceof ${_.expected}, отримано ${W}`;return`Неправильні вхідні дані: очікується ${z}, отримано ${W}`}case"invalid_value":if(_.values.length===1)return`Неправильні вхідні дані: очікується ${m(_.values[0])}`;return`Неправильна опція: очікується одне з ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Занадто велике: очікується, що ${_.origin??"значення"} ${K.verb} ${z}${_.maximum.toString()} ${K.unit??"елементів"}`;return`Занадто велике: очікується, що ${_.origin??"значення"} буде ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Занадто мале: очікується, що ${_.origin} ${K.verb} ${z}${_.minimum.toString()} ${K.unit}`;return`Занадто мале: очікується, що ${_.origin} буде ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Неправильний рядок: повинен починатися з "${z.prefix}"`;if(z.format==="ends_with")return`Неправильний рядок: повинен закінчуватися на "${z.suffix}"`;if(z.format==="includes")return`Неправильний рядок: повинен містити "${z.includes}"`;if(z.format==="regex")return`Неправильний рядок: повинен відповідати шаблону ${z.pattern}`;return`Неправильний ${v[z.format]??_.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${_.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${_.keys.length>1?"і":""}: ${w(_.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${_.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${_.origin}`;default:return"Неправильні вхідні дані"}}};function M_(){return{localeError:xb()}}function Q7(){return M_()}var hb=()=>{let $={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function U(_){return $[_]??null}let v={regex:"ان پٹ",email:"ای میل ایڈریس",url:"یو آر ایل",emoji:"ایموجی",uuid:"یو یو آئی ڈی",uuidv4:"یو یو آئی ڈی وی 4",uuidv6:"یو یو آئی ڈی وی 6",nanoid:"نینو آئی ڈی",guid:"جی یو آئی ڈی",cuid:"سی یو آئی ڈی",cuid2:"سی یو آئی ڈی 2",ulid:"یو ایل آئی ڈی",xid:"ایکس آئی ڈی",ksuid:"کے ایس یو آئی ڈی",datetime:"آئی ایس او ڈیٹ ٹائم",date:"آئی ایس او تاریخ",time:"آئی ایس او وقت",duration:"آئی ایس او مدت",ipv4:"آئی پی وی 4 ایڈریس",ipv6:"آئی پی وی 6 ایڈریس",cidrv4:"آئی پی وی 4 رینج",cidrv6:"آئی پی وی 6 رینج",base64:"بیس 64 ان کوڈڈ سٹرنگ",base64url:"بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",json_string:"جے ایس او این سٹرنگ",e164:"ای 164 نمبر",jwt:"جے ڈبلیو ٹی",template_literal:"ان پٹ"},J={nan:"NaN",number:"نمبر",array:"آرے",null:"نل"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`غلط ان پٹ: instanceof ${_.expected} متوقع تھا، ${W} موصول ہوا`;return`غلط ان پٹ: ${z} متوقع تھا، ${W} موصول ہوا`}case"invalid_value":if(_.values.length===1)return`غلط ان پٹ: ${m(_.values[0])} متوقع تھا`;return`غلط آپشن: ${w(_.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`بہت بڑا: ${_.origin??"ویلیو"} کے ${z}${_.maximum.toString()} ${K.unit??"عناصر"} ہونے متوقع تھے`;return`بہت بڑا: ${_.origin??"ویلیو"} کا ${z}${_.maximum.toString()} ہونا متوقع تھا`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`بہت چھوٹا: ${_.origin} کے ${z}${_.minimum.toString()} ${K.unit} ہونے متوقع تھے`;return`بہت چھوٹا: ${_.origin} کا ${z}${_.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`غلط سٹرنگ: "${z.prefix}" سے شروع ہونا چاہیے`;if(z.format==="ends_with")return`غلط سٹرنگ: "${z.suffix}" پر ختم ہونا چاہیے`;if(z.format==="includes")return`غلط سٹرنگ: "${z.includes}" شامل ہونا چاہیے`;if(z.format==="regex")return`غلط سٹرنگ: پیٹرن ${z.pattern} سے میچ ہونا چاہیے`;return`غلط ${v[z.format]??_.format}`}case"not_multiple_of":return`غلط نمبر: ${_.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${_.keys.length>1?"ز":""}: ${w(_.keys,"، ")}`;case"invalid_key":return`${_.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${_.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function L7(){return{localeError:hb()}}var cb=()=>{let $={string:{unit:"belgi",verb:"bo‘lishi kerak"},file:{unit:"bayt",verb:"bo‘lishi kerak"},array:{unit:"element",verb:"bo‘lishi kerak"},set:{unit:"element",verb:"bo‘lishi kerak"}};function U(_){return $[_]??null}let v={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},J={nan:"NaN",number:"raqam",array:"massiv"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Noto‘g‘ri kirish: kutilgan instanceof ${_.expected}, qabul qilingan ${W}`;return`Noto‘g‘ri kirish: kutilgan ${z}, qabul qilingan ${W}`}case"invalid_value":if(_.values.length===1)return`Noto‘g‘ri kirish: kutilgan ${m(_.values[0])}`;return`Noto‘g‘ri variant: quyidagilardan biri kutilgan ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Juda katta: kutilgan ${_.origin??"qiymat"} ${z}${_.maximum.toString()} ${K.unit} ${K.verb}`;return`Juda katta: kutilgan ${_.origin??"qiymat"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Juda kichik: kutilgan ${_.origin} ${z}${_.minimum.toString()} ${K.unit} ${K.verb}`;return`Juda kichik: kutilgan ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Noto‘g‘ri satr: "${z.prefix}" bilan boshlanishi kerak`;if(z.format==="ends_with")return`Noto‘g‘ri satr: "${z.suffix}" bilan tugashi kerak`;if(z.format==="includes")return`Noto‘g‘ri satr: "${z.includes}" ni o‘z ichiga olishi kerak`;if(z.format==="regex")return`Noto‘g‘ri satr: ${z.pattern} shabloniga mos kelishi kerak`;return`Noto‘g‘ri ${v[z.format]??_.format}`}case"not_multiple_of":return`Noto‘g‘ri raqam: ${_.divisor} ning karralisi bo‘lishi kerak`;case"unrecognized_keys":return`Noma’lum kalit${_.keys.length>1?"lar":""}: ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} dagi kalit noto‘g‘ri`;case"invalid_union":return"Noto‘g‘ri kirish";case"invalid_element":return`${_.origin} da noto‘g‘ri qiymat`;default:return"Noto‘g‘ri kirish"}}};function F7(){return{localeError:cb()}}var lb=()=>{let $={string:{unit:"ký tự",verb:"có"},file:{unit:"byte",verb:"có"},array:{unit:"phần tử",verb:"có"},set:{unit:"phần tử",verb:"có"}};function U(_){return $[_]??null}let v={regex:"đầu vào",email:"địa chỉ email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ngày giờ ISO",date:"ngày ISO",time:"giờ ISO",duration:"khoảng thời gian ISO",ipv4:"địa chỉ IPv4",ipv6:"địa chỉ IPv6",cidrv4:"dải IPv4",cidrv6:"dải IPv6",base64:"chuỗi mã hóa base64",base64url:"chuỗi mã hóa base64url",json_string:"chuỗi JSON",e164:"số E.164",jwt:"JWT",template_literal:"đầu vào"},J={nan:"NaN",number:"số",array:"mảng"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Đầu vào không hợp lệ: mong đợi instanceof ${_.expected}, nhận được ${W}`;return`Đầu vào không hợp lệ: mong đợi ${z}, nhận được ${W}`}case"invalid_value":if(_.values.length===1)return`Đầu vào không hợp lệ: mong đợi ${m(_.values[0])}`;return`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Quá lớn: mong đợi ${_.origin??"giá trị"} ${K.verb} ${z}${_.maximum.toString()} ${K.unit??"phần tử"}`;return`Quá lớn: mong đợi ${_.origin??"giá trị"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Quá nhỏ: mong đợi ${_.origin} ${K.verb} ${z}${_.minimum.toString()} ${K.unit}`;return`Quá nhỏ: mong đợi ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Chuỗi không hợp lệ: phải bắt đầu bằng "${z.prefix}"`;if(z.format==="ends_with")return`Chuỗi không hợp lệ: phải kết thúc bằng "${z.suffix}"`;if(z.format==="includes")return`Chuỗi không hợp lệ: phải bao gồm "${z.includes}"`;if(z.format==="regex")return`Chuỗi không hợp lệ: phải khớp với mẫu ${z.pattern}`;return`${v[z.format]??_.format} không hợp lệ`}case"not_multiple_of":return`Số không hợp lệ: phải là bội số của ${_.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${w(_.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${_.origin}`;case"invalid_union":return"Đầu vào không hợp lệ";case"invalid_element":return`Giá trị không hợp lệ trong ${_.origin}`;default:return"Đầu vào không hợp lệ"}}};function P7(){return{localeError:lb()}}var rb=()=>{let $={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function U(_){return $[_]??null}let v={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"},J={nan:"NaN",number:"数字",array:"数组",null:"空值(null)"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`无效输入:期望 instanceof ${_.expected},实际接收 ${W}`;return`无效输入:期望 ${z},实际接收 ${W}`}case"invalid_value":if(_.values.length===1)return`无效输入:期望 ${m(_.values[0])}`;return`无效选项:期望以下之一 ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`数值过大:期望 ${_.origin??"值"} ${z}${_.maximum.toString()} ${K.unit??"个元素"}`;return`数值过大:期望 ${_.origin??"值"} ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`数值过小:期望 ${_.origin} ${z}${_.minimum.toString()} ${K.unit}`;return`数值过小:期望 ${_.origin} ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`无效字符串:必须以 "${z.prefix}" 开头`;if(z.format==="ends_with")return`无效字符串:必须以 "${z.suffix}" 结尾`;if(z.format==="includes")return`无效字符串:必须包含 "${z.includes}"`;if(z.format==="regex")return`无效字符串:必须满足正则表达式 ${z.pattern}`;return`无效${v[z.format]??_.format}`}case"not_multiple_of":return`无效数字:必须是 ${_.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${w(_.keys,", ")}`;case"invalid_key":return`${_.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${_.origin} 中包含无效值(value)`;default:return"无效输入"}}};function k7(){return{localeError:rb()}}var ib=()=>{let $={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function U(_){return $[_]??null}let v={regex:"輸入",email:"郵件地址",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 日期時間",date:"ISO 日期",time:"ISO 時間",duration:"ISO 期間",ipv4:"IPv4 位址",ipv6:"IPv6 位址",cidrv4:"IPv4 範圍",cidrv6:"IPv6 範圍",base64:"base64 編碼字串",base64url:"base64url 編碼字串",json_string:"JSON 字串",e164:"E.164 數值",jwt:"JWT",template_literal:"輸入"},J={nan:"NaN"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`無效的輸入值:預期為 instanceof ${_.expected},但收到 ${W}`;return`無效的輸入值:預期為 ${z},但收到 ${W}`}case"invalid_value":if(_.values.length===1)return`無效的輸入值:預期為 ${m(_.values[0])}`;return`無效的選項:預期為以下其中之一 ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`數值過大:預期 ${_.origin??"值"} 應為 ${z}${_.maximum.toString()} ${K.unit??"個元素"}`;return`數值過大:預期 ${_.origin??"值"} 應為 ${z}${_.maximum.toString()}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`數值過小:預期 ${_.origin} 應為 ${z}${_.minimum.toString()} ${K.unit}`;return`數值過小:預期 ${_.origin} 應為 ${z}${_.minimum.toString()}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`無效的字串:必須以 "${z.prefix}" 開頭`;if(z.format==="ends_with")return`無效的字串:必須以 "${z.suffix}" 結尾`;if(z.format==="includes")return`無效的字串:必須包含 "${z.includes}"`;if(z.format==="regex")return`無效的字串:必須符合格式 ${z.pattern}`;return`無效的 ${v[z.format]??_.format}`}case"not_multiple_of":return`無效的數字:必須為 ${_.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${_.keys.length>1?"們":""}:${w(_.keys,"、")}`;case"invalid_key":return`${_.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${_.origin} 中有無效的值`;default:return"無效的輸入值"}}};function b7(){return{localeError:ib()}}var pb=()=>{let $={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function U(_){return $[_]??null}let v={regex:"ẹ̀rọ ìbáwọlé",email:"àdírẹ́sì ìmẹ́lì",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"àkókò ISO",date:"ọjọ́ ISO",time:"àkókò ISO",duration:"àkókò tó pé ISO",ipv4:"àdírẹ́sì IPv4",ipv6:"àdírẹ́sì IPv6",cidrv4:"àgbègbè IPv4",cidrv6:"àgbègbè IPv6",base64:"ọ̀rọ̀ tí a kọ́ ní base64",base64url:"ọ̀rọ̀ base64url",json_string:"ọ̀rọ̀ JSON",e164:"nọ́mbà E.164",jwt:"JWT",template_literal:"ẹ̀rọ ìbáwọlé"},J={nan:"NaN",number:"nọ́mbà",array:"akopọ"};return(_)=>{switch(_.code){case"invalid_type":{let z=J[_.expected]??_.expected,K=x(_.input),W=J[K]??K;if(/^[A-Z]/.test(_.expected))return`Ìbáwọlé aṣìṣe: a ní láti fi instanceof ${_.expected}, àmọ̀ a rí ${W}`;return`Ìbáwọlé aṣìṣe: a ní láti fi ${z}, àmọ̀ a rí ${W}`}case"invalid_value":if(_.values.length===1)return`Ìbáwọlé aṣìṣe: a ní láti fi ${m(_.values[0])}`;return`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${w(_.values,"|")}`;case"too_big":{let z=_.inclusive?"<=":"<",K=U(_.origin);if(K)return`Tó pọ̀ jù: a ní láti jẹ́ pé ${_.origin??"iye"} ${K.verb} ${z}${_.maximum} ${K.unit}`;return`Tó pọ̀ jù: a ní láti jẹ́ ${z}${_.maximum}`}case"too_small":{let z=_.inclusive?">=":">",K=U(_.origin);if(K)return`Kéré ju: a ní láti jẹ́ pé ${_.origin} ${K.verb} ${z}${_.minimum} ${K.unit}`;return`Kéré ju: a ní láti jẹ́ ${z}${_.minimum}`}case"invalid_format":{let z=_;if(z.format==="starts_with")return`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${z.prefix}"`;if(z.format==="ends_with")return`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${z.suffix}"`;if(z.format==="includes")return`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${z.includes}"`;if(z.format==="regex")return`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${z.pattern}`;return`Aṣìṣe: ${v[z.format]??_.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${_.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${w(_.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${_.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${_.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function M7(){return{localeError:pb()}}var oq,A7=Symbol("ZodOutput"),I7=Symbol("ZodInput");class w7{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...U){let v=U[0];if(this._map.set($,v),v&&typeof v==="object"&&"id"in v)this._idmap.set(v.id,$);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove($){let U=this._map.get($);if(U&&typeof U==="object"&&"id"in U)this._idmap.delete(U.id);return this._map.delete($),this}get($){let U=$._zod.parent;if(U){let v={...this.get(U)??{}};delete v.id;let J={...v,...this._map.get($)};return Object.keys(J).length?J:void 0}return this._map.get($)}has($){return this._map.has($)}}function iv(){return new w7}(oq=globalThis).__zod_globalRegistry??(oq.__zod_globalRegistry=iv());var B6=globalThis.__zod_globalRegistry;function g7($,U){return new $({type:"string",...c(U)})}function N7($,U){return new $({type:"string",coerce:!0,...c(U)})}function pv($,U){return new $({type:"string",format:"email",check:"string_format",abort:!1,...c(U)})}function I_($,U){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...c(U)})}function ov($,U){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...c(U)})}function dv($,U){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...c(U)})}function nv($,U){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...c(U)})}function tv($,U){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...c(U)})}function w_($,U){return new $({type:"string",format:"url",check:"string_format",abort:!1,...c(U)})}function av($,U){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...c(U)})}function sv($,U){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...c(U)})}function ev($,U){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...c(U)})}function $J($,U){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...c(U)})}function UJ($,U){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...c(U)})}function _J($,U){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...c(U)})}function vJ($,U){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...c(U)})}function JJ($,U){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...c(U)})}function zJ($,U){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...c(U)})}function S7($,U){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...c(U)})}function KJ($,U){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...c(U)})}function GJ($,U){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...c(U)})}function WJ($,U){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...c(U)})}function OJ($,U){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...c(U)})}function YJ($,U){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...c(U)})}function ZJ($,U){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...c(U)})}var R7={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function T7($,U){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...c(U)})}function y7($,U){return new $({type:"string",format:"date",check:"string_format",...c(U)})}function C7($,U){return new $({type:"string",format:"time",check:"string_format",precision:null,...c(U)})}function D7($,U){return new $({type:"string",format:"duration",check:"string_format",...c(U)})}function j7($,U){return new $({type:"number",checks:[],...c(U)})}function V7($,U){return new $({type:"number",coerce:!0,checks:[],...c(U)})}function f7($,U){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...c(U)})}function E7($,U){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...c(U)})}function u7($,U){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...c(U)})}function m7($,U){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...c(U)})}function x7($,U){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...c(U)})}function h7($,U){return new $({type:"boolean",...c(U)})}function c7($,U){return new $({type:"boolean",coerce:!0,...c(U)})}function l7($,U){return new $({type:"bigint",...c(U)})}function r7($,U){return new $({type:"bigint",coerce:!0,...c(U)})}function i7($,U){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...c(U)})}function p7($,U){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...c(U)})}function o7($,U){return new $({type:"symbol",...c(U)})}function d7($,U){return new $({type:"undefined",...c(U)})}function n7($,U){return new $({type:"null",...c(U)})}function t7($){return new $({type:"any"})}function a7($){return new $({type:"unknown"})}function s7($,U){return new $({type:"never",...c(U)})}function e7($,U){return new $({type:"void",...c(U)})}function $K($,U){return new $({type:"date",...c(U)})}function UK($,U){return new $({type:"date",coerce:!0,...c(U)})}function _K($,U){return new $({type:"nan",...c(U)})}function P4($,U){return new Dv({check:"less_than",...c(U),value:$,inclusive:!1})}function l6($,U){return new Dv({check:"less_than",...c(U),value:$,inclusive:!0})}function k4($,U){return new jv({check:"greater_than",...c(U),value:$,inclusive:!1})}function y6($,U){return new jv({check:"greater_than",...c(U),value:$,inclusive:!0})}function qJ($){return k4(0,$)}function BJ($){return P4(0,$)}function XJ($){return l6(0,$)}function HJ($){return y6(0,$)}function G1($,U){return new _3({check:"multiple_of",...c(U),value:$})}function W1($,U){return new z3({check:"max_size",...c(U),maximum:$})}function b4($,U){return new K3({check:"min_size",...c(U),minimum:$})}function r1($,U){return new G3({check:"size_equals",...c(U),size:$})}function i1($,U){return new W3({check:"max_length",...c(U),maximum:$})}function E4($,U){return new O3({check:"min_length",...c(U),minimum:$})}function p1($,U){return new Y3({check:"length_equals",...c(U),length:$})}function iU($,U){return new Z3({check:"string_format",format:"regex",...c(U),pattern:$})}function pU($){return new q3({check:"string_format",format:"lowercase",...c($)})}function oU($){return new B3({check:"string_format",format:"uppercase",...c($)})}function dU($,U){return new X3({check:"string_format",format:"includes",...c(U),includes:$})}function nU($,U){return new H3({check:"string_format",format:"starts_with",...c(U),prefix:$})}function tU($,U){return new Q3({check:"string_format",format:"ends_with",...c(U),suffix:$})}function QJ($,U,v){return new L3({check:"property",property:$,schema:U,...c(v)})}function aU($,U){return new F3({check:"mime_type",mime:$,...c(U)})}function W4($){return new P3({check:"overwrite",tx:$})}function sU($){return W4((U)=>U.normalize($))}function eU(){return W4(($)=>$.trim())}function $0(){return W4(($)=>$.toLowerCase())}function U0(){return W4(($)=>$.toUpperCase())}function _0(){return W4(($)=>P5($))}function vK($,U,v){return new $({type:"array",element:U,...c(v)})}function db($,U,v){return new $({type:"union",options:U,...c(v)})}function nb($,U,v){return new $({type:"union",options:U,inclusive:!1,...c(v)})}function tb($,U,v,J){return new $({type:"union",options:v,discriminator:U,...c(J)})}function ab($,U,v){return new $({type:"intersection",left:U,right:v})}function sb($,U,v,J){let _=v instanceof Y$;return new $({type:"tuple",items:U,rest:_?v:null,...c(_?J:v)})}function eb($,U,v,J){return new $({type:"record",keyType:U,valueType:v,...c(J)})}function $M($,U,v,J){return new $({type:"map",keyType:U,valueType:v,...c(J)})}function UM($,U,v){return new $({type:"set",valueType:U,...c(v)})}function _M($,U,v){let J=Array.isArray(U)?Object.fromEntries(U.map((_)=>[_,_])):U;return new $({type:"enum",entries:J,...c(v)})}function vM($,U,v){return new $({type:"enum",entries:U,...c(v)})}function JM($,U,v){return new $({type:"literal",values:Array.isArray(U)?U:[U],...c(v)})}function JK($,U){return new $({type:"file",...c(U)})}function zM($,U){return new $({type:"transform",transform:U})}function KM($,U){return new $({type:"optional",innerType:U})}function GM($,U){return new $({type:"nullable",innerType:U})}function WM($,U,v){return new $({type:"default",innerType:U,get defaultValue(){return typeof v==="function"?v():b5(v)}})}function OM($,U,v){return new $({type:"nonoptional",innerType:U,...c(v)})}function YM($,U){return new $({type:"success",innerType:U})}function ZM($,U,v){return new $({type:"catch",innerType:U,catchValue:typeof v==="function"?v:()=>v})}function qM($,U,v){return new $({type:"pipe",in:U,out:v})}function BM($,U){return new $({type:"readonly",innerType:U})}function XM($,U,v){return new $({type:"template_literal",parts:U,...c(v)})}function HM($,U){return new $({type:"lazy",getter:U})}function QM($,U){return new $({type:"promise",innerType:U})}function zK($,U,v){let J=c(v);return J.abort??(J.abort=!0),new $({type:"custom",check:"custom",fn:U,...J})}function KK($,U,v){return new $({type:"custom",check:"custom",fn:U,...c(v)})}function GK($){let U=dq((v)=>{return v.addIssue=(J)=>{if(typeof J==="string")v.issues.push(EU(J,v.value,U._zod.def));else{let _=J;if(_.fatal)_.continue=!1;_.code??(_.code="custom"),_.input??(_.input=v.value),_.inst??(_.inst=U),_.continue??(_.continue=!U._zod.def.abort),v.issues.push(EU(_))}},$(v.value,v)});return U}function dq($,U){let v=new m$({check:"custom",...c(U)});return v._zod.check=$,v}function WK($){let U=new m$({check:"describe"});return U._zod.onattach=[(v)=>{let J=B6.get(v)??{};B6.add(v,{...J,description:$})}],U._zod.check=()=>{},U}function OK($){let U=new m$({check:"meta"});return U._zod.onattach=[(v)=>{let J=B6.get(v)??{};B6.add(v,{...J,...$})}],U._zod.check=()=>{},U}function YK($,U){let v=c(U),J=v.truthy??["true","1","yes","on","y","enabled"],_=v.falsy??["false","0","no","off","n","disabled"];if(v.case!=="sensitive")J=J.map((B)=>typeof B==="string"?B.toLowerCase():B),_=_.map((B)=>typeof B==="string"?B.toLowerCase():B);let z=new Set(J),K=new Set(_),W=$.Codec??F_,O=$.Boolean??Q_,Z=new($.String??l1)({type:"string",error:v.error}),q=new O({type:"boolean",error:v.error}),X=new W({type:"pipe",in:Z,out:q,transform:(B,L)=>{let F=B;if(v.case!=="sensitive")F=F.toLowerCase();if(z.has(F))return!0;else if(K.has(F))return!1;else return L.issues.push({code:"invalid_value",expected:"stringbool",values:[...z,...K],input:L.value,inst:X,continue:!1}),{}},reverseTransform:(B,L)=>{if(B===!0)return J[0]||"true";else return _[0]||"false"},error:v.error});return X}function v0($,U,v,J={}){let _=c(J),z={...c(J),check:"string_format",type:"string",format:U,fn:typeof v==="function"?v:(W)=>v.test(W),..._};if(v instanceof RegExp)z.pattern=v;return new $(z)}function O1($){let U=$?.target??"draft-2020-12";if(U==="draft-4")U="draft-04";if(U==="draft-7")U="draft-07";return{processors:$.processors??{},metadataRegistry:$?.metadata??B6,target:U,unrepresentable:$?.unrepresentable??"throw",override:$?.override??(()=>{}),io:$?.io??"output",counter:0,seen:new Map,cycles:$?.cycles??"ref",reused:$?.reused??"inline",external:$?.external??void 0}}function R$($,U,v={path:[],schemaPath:[]}){var J;let _=$._zod.def,z=U.seen.get($);if(z){if(z.count++,v.schemaPath.includes($))z.cycle=v.path;return z.schema}let K={schema:{},count:1,cycle:void 0,path:v.path};U.seen.set($,K);let W=$._zod.toJSONSchema?.();if(W)K.schema=W;else{let Z={...v,schemaPath:[...v.schemaPath,$],path:v.path};if($._zod.processJSONSchema)$._zod.processJSONSchema(U,K.schema,Z);else{let X=K.schema,B=U.processors[_.type];if(!B)throw Error(`[toJSONSchema]: Non-representable type encountered: ${_.type}`);B($,U,X,Z)}let q=$._zod.parent;if(q){if(!K.ref)K.ref=q;R$(q,U,Z),U.seen.get(q).isParent=!0}}let O=U.metadataRegistry.get($);if(O)Object.assign(K.schema,O);if(U.io==="input"&&C6($))delete K.schema.examples,delete K.schema.default;if(U.io==="input"&&K.schema._prefault)(J=K.schema).default??(J.default=K.schema._prefault);return delete K.schema._prefault,U.seen.get($).schema}function Y1($,U){let v=$.seen.get(U);if(!v)throw Error("Unprocessed schema. This is a bug in Zod.");let J=new Map;for(let K of $.seen.entries()){let W=$.metadataRegistry.get(K[0])?.id;if(W){let O=J.get(W);if(O&&O!==K[0])throw Error(`Duplicate schema id "${W}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);J.set(W,K[0])}}let _=(K)=>{let W=$.target==="draft-2020-12"?"$defs":"definitions";if($.external){let q=$.external.registry.get(K[0])?.id,X=$.external.uri??((L)=>L);if(q)return{ref:X(q)};let B=K[1].defId??K[1].schema.id??`schema${$.counter++}`;return K[1].defId=B,{defId:B,ref:`${X("__shared")}#/${W}/${B}`}}if(K[1]===v)return{ref:"#"};let Y=`${"#"}/${W}/`,Z=K[1].schema.id??`__schema${$.counter++}`;return{defId:Z,ref:Y+Z}},z=(K)=>{if(K[1].schema.$ref)return;let W=K[1],{ref:O,defId:Y}=_(K);if(W.def={...W.schema},Y)W.defId=Y;let Z=W.schema;for(let q in Z)delete Z[q];Z.$ref=O};if($.cycles==="throw")for(let K of $.seen.entries()){let W=K[1];if(W.cycle)throw Error(`Cycle detected: #/${W.cycle?.join("/")}/<root>
|
|
148
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");let g=f.compile();return(b,O)=>g(m,b,O)},s,a=cr,c=!js.jitless,u=c&&zm.value,d=t.catchall,p;e._zod.parse=(m,f)=>{p??(p=o.value);let y=m.value;if(!a(y))return m.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),m;if(c&&u&&f?.async===!1&&f.jitless!==!0){if(!s)s=r(t.shape);if(m=s(m,f),!d)return m;return wg([],y,m,f,p,e)}return n(m,f)}});function Oh(e,t,n,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let r=e.filter((s)=>!go(s));if(r.length===1)return t.value=r[0].value,r[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((a)=>nn(a,o,Lt())))}),t}var Hl=A("$ZodUnion",(e,t)=>{$e.init(e,t),we(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),we(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),we(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),we(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((s)=>s._zod.pattern);return new RegExp(`^(${r.map((s)=>Us(s.source)).join("|")})$`)}return});let n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let a=!1,c=[];for(let l of t.options){let u=l._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)c.push(u),a=!0;else{if(u.issues.length===0)return u;c.push(u)}}if(!a)return Oh(c,r,e,s);return Promise.all(c).then((l)=>Oh(l,r,e,s))}});var Sg=A("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Hl.init(e,t);let n=e._zod.parse;we(e._zod,"propValues",()=>{let r={};for(let s of t.options){let a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,l]of Object.entries(a)){if(!r[c])r[c]=new Set;for(let u of l)r[c].add(u)}}return r});let o=Qr(()=>{let r=t.options,s=new Map;for(let a of r){let c=a._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let l of c){if(s.has(l))throw Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,a)}}return s});e._zod.parse=(r,s)=>{let a=r.value;if(!cr(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let c=o.value.get(a?.[t.discriminator]);if(c)return c._zod.run(r,s);if(t.unionFallback)return n(r,s);return r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),r}}),kg=A("$ZodIntersection",(e,t)=>{$e.init(e,t),e._zod.parse=(n,o)=>{let r=n.value,s=t.left._zod.run({value:r,issues:[]},o),a=t.right._zod.run({value:r,issues:[]},o);if(s instanceof Promise||a instanceof Promise)return Promise.all([s,a]).then(([l,u])=>Lh(n,l,u));return Lh(n,s,a)}});function jl(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ho(e)&&ho(t)){let n=Object.keys(t),o=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),r={...e,...t};for(let s of o){let a=jl(e[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};r[s]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let o=0;o<e.length;o++){let r=e[o],s=t[o],a=jl(r,s);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Lh(e,t,n){let o=new Map,r;for(let c of t.issues)if(c.code==="unrecognized_keys"){r??(r=c);for(let l of c.keys){if(!o.has(l))o.set(l,{});o.get(l).l=!0}}else e.issues.push(c);for(let c of n.issues)if(c.code==="unrecognized_keys")for(let l of c.keys){if(!o.has(l))o.set(l,{});o.get(l).r=!0}else e.issues.push(c);let s=[...o].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&r)e.issues.push({...r,keys:s});if(go(e))return e;let a=jl(t.value,n.value);if(!a.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Cg=A("$ZodRecord",(e,t)=>{$e.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!ho(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;let s=[],a=t.keyType._zod.values;if(a){n.value={};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){c.add(typeof u==="number"?u.toString():u);let d=t.valueType._zod.run({value:r[u],issues:[]},o);if(d instanceof Promise)s.push(d.then((p)=>{if(p.issues.length)n.issues.push(...Dn(u,p.issues));n.value[u]=p.value}));else{if(d.issues.length)n.issues.push(...Dn(u,d.issues));n.value[u]=d.value}}let l;for(let u in r)if(!c.has(u))l=l??[],l.push(u);if(l&&l.length>0)n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(let c of Reflect.ownKeys(r)){if(c==="__proto__")continue;let l=t.keyType._zod.run({value:c,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&Ol.test(c)&&l.issues.length){let p=t.keyType._zod.run({value:Number(c),issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length===0)l=p}if(l.issues.length){if(t.mode==="loose")n.value[c]=r[c];else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((p)=>nn(p,o,Lt())),input:c,path:[c],inst:e});continue}let d=t.valueType._zod.run({value:r[c],issues:[]},o);if(d instanceof Promise)s.push(d.then((p)=>{if(p.issues.length)n.issues.push(...Dn(c,p.issues));n.value[l.value]=p.value}));else{if(d.issues.length)n.issues.push(...Dn(c,d.issues));n.value[l.value]=d.value}}}if(s.length)return Promise.all(s).then(()=>n);return n}});var Tg=A("$ZodEnum",(e,t)=>{$e.init(e,t);let n=Hs(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter((r)=>Pm.has(typeof r)).map((r)=>typeof r==="string"?Ln(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{let a=r.value;if(o.has(a))return r;return r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Eg=A("$ZodLiteral",(e,t)=>{if($e.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((o)=>typeof o==="string"?Ln(o):o?Ln(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var Ag=A("$ZodTransform",(e,t)=>{$e.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Jr(e.constructor.name);let r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then((a)=>(n.value=a,n));if(r instanceof Promise)throw new mn;return n.value=r,n}});function Dh(e,t){if(e.issues.length&&t===void 0)return{issues:[],value:void 0};return e}var Bl=A("$ZodOptional",(e,t)=>{$e.init(e,t),e._zod.optin="optional",e._zod.optout="optional",we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),we(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Us(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((s)=>Dh(s,n.value));return Dh(r,n.value)}if(n.value===void 0)return n;return t.innerType._zod.run(n,o)}}),Ig=A("$ZodExactOptional",(e,t)=>{Bl.init(e,t),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),zg=A("$ZodNullable",(e,t)=>{$e.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Us(n.source)}|null)$`):void 0}),we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>{if(n.value===null)return n;return t.innerType._zod.run(n,o)}}),Pg=A("$ZodDefault",(e,t)=>{$e.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((s)=>Fh(s,t));return Fh(r,t)}});function Fh(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Ng=A("$ZodPrefault",(e,t)=>{$e.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,o)}}),Rg=A("$ZodNonOptional",(e,t)=>{$e.init(e,t),we(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((s)=>jh(s,e));return jh(r,e)}});function jh(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var $g=A("$ZodCatch",(e,t)=>{$e.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then((s)=>{if(n.value=s.value,s.issues.length)n.value=t.catchValue({...n,error:{issues:s.issues.map((a)=>nn(a,o,Lt()))},input:n.value}),n.issues=[];return n});if(n.value=r.value,r.issues.length)n.value=t.catchValue({...n,error:{issues:r.issues.map((s)=>nn(s,o,Lt()))},input:n.value}),n.issues=[];return n}});var Mg=A("$ZodPipe",(e,t)=>{$e.init(e,t),we(e._zod,"values",()=>t.in._zod.values),we(e._zod,"optin",()=>t.in._zod.optin),we(e._zod,"optout",()=>t.out._zod.optout),we(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(n,o);if(s instanceof Promise)return s.then((a)=>Js(a,t.in,o));return Js(s,t.in,o)}let r=t.in._zod.run(n,o);if(r instanceof Promise)return r.then((s)=>Js(s,t.out,o));return Js(r,t.out,o)}});function Js(e,t,n){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Og=A("$ZodReadonly",(e,t)=>{$e.init(e,t),we(e._zod,"propValues",()=>t.innerType._zod.propValues),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"optin",()=>t.innerType?._zod?.optin),we(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);let r=t.innerType._zod.run(n,o);if(r instanceof Promise)return r.then(Zh);return Zh(r)}});function Zh(e){return e.value=Object.freeze(e.value),e}var Lg=A("$ZodCustom",(e,t)=>{it.init(e,t),$e.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=(n)=>{let o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then((s)=>Hh(s,n,o,e));Hh(r,n,o,e);return}});function Hh(e,t,n,o){if(!e){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)r.params=o._zod.def.params;t.issues.push(vo(r))}}var Ak=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(r)=>{switch(r.code){case"invalid_type":{let s=o[r.expected]??r.expected,a=$m(r.input),c=o[a]??a;return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(r.values.length===1)return`Invalid input: expected ${Nl(r.values[0])}`;return`Invalid option: expected one of ${Al(r.values,"|")}`;case"too_big":{let s=r.inclusive?"<=":"<",a=t(r.origin);if(a)return`Too big: expected ${r.origin??"value"} to have ${s}${r.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${r.origin??"value"} to be ${s}${r.maximum.toString()}`}case"too_small":{let s=r.inclusive?">=":">",a=t(r.origin);if(a)return`Too small: expected ${r.origin} to have ${s}${r.minimum.toString()} ${a.unit}`;return`Too small: expected ${r.origin} to be ${s}${r.minimum.toString()}`}case"invalid_format":{let s=r;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??r.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${Al(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}};function Ul(){return{localeError:Ak()}}var Dg,LP=Symbol("ZodOutput"),DP=Symbol("ZodInput");class Fg{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Ik(){return new Fg}(Dg=globalThis).__zod_globalRegistry??(Dg.__zod_globalRegistry=Ik());var yo=globalThis.__zod_globalRegistry;function jg(e,t){return new e({type:"string",...J(t)})}function Zg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function Wl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function Hg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function Bg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function Ug(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function Wg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function qg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function Vg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function Gg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function Xg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function Kg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function Jg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function Yg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function Qg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function ev(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function tv(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function nv(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function ov(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function rv(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function iv(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function sv(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function av(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function cv(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function lv(e,t){return new e({type:"string",format:"date",check:"string_format",...J(t)})}function uv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function dv(e,t){return new e({type:"string",format:"duration",check:"string_format",...J(t)})}function pv(e,t){return new e({type:"number",checks:[],...J(t)})}function fv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function mv(e,t){return new e({type:"boolean",...J(t)})}function hv(e,t){return new e({type:"undefined",...J(t)})}function gv(e,t){return new e({type:"null",...J(t)})}function vv(e){return new e({type:"unknown"})}function yv(e,t){return new e({type:"never",...J(t)})}function ea(e,t){return new Ll({check:"less_than",...J(t),value:e,inclusive:!1})}function ri(e,t){return new Ll({check:"less_than",...J(t),value:e,inclusive:!0})}function ta(e,t){return new Dl({check:"greater_than",...J(t),value:e,inclusive:!1})}function ii(e,t){return new Dl({check:"greater_than",...J(t),value:e,inclusive:!0})}function na(e,t){return new wh({check:"multiple_of",...J(t),value:e})}function oa(e,t){return new Sh({check:"max_length",...J(t),maximum:e})}function lr(e,t){return new kh({check:"min_length",...J(t),minimum:e})}function ra(e,t){return new Ch({check:"length_equals",...J(t),length:e})}function ql(e,t){return new Th({check:"string_format",format:"regex",...J(t),pattern:e})}function Vl(e){return new Eh({check:"string_format",format:"lowercase",...J(e)})}function Gl(e){return new Ah({check:"string_format",format:"uppercase",...J(e)})}function Xl(e,t){return new Ih({check:"string_format",format:"includes",...J(t),includes:e})}function Kl(e,t){return new zh({check:"string_format",format:"starts_with",...J(t),prefix:e})}function Jl(e,t){return new Ph({check:"string_format",format:"ends_with",...J(t),suffix:e})}function Fn(e){return new Nh({check:"overwrite",tx:e})}function Yl(e){return Fn((t)=>t.normalize(e))}function Ql(){return Fn((e)=>e.trim())}function eu(){return Fn((e)=>e.toLowerCase())}function tu(){return Fn((e)=>e.toUpperCase())}function nu(){return Fn((e)=>Im(e))}function xv(e,t,n){return new e({type:"array",element:t,...J(n)})}function bv(e,t,n){let o=J(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function wv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...J(n)})}function _v(e){let t=zk((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(vo(o,n.value,t._zod.def));else{let r=o;if(r.fatal)r.continue=!1;r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(vo(r))}},e(n.value,n)));return t}function zk(e,t){let n=new it({check:"custom",...J(t)});return n._zod.check=e,n}function ou(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??yo,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Xe(e,t,n={path:[],schemaPath:[]}){var o;let r=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,d);else{let m=a.schema,f=t.processors[r.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,m,d)}let p=e._zod.parent;if(p){if(!a.ref)a.ref=p;Xe(p,t,d),t.seen.get(p).isParent=!0}}let l=t.metadataRegistry.get(e);if(l)Object.assign(a.schema,l);if(t.io==="input"&&yt(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&a.schema._prefault)(o=a.schema).default??(o.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function ru(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let o=new Map;for(let a of e.seen.entries()){let c=e.metadataRegistry.get(a[0])?.id;if(c){let l=o.get(c);if(l&&l!==a[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,a[0])}}let r=(a)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(a[0])?.id,m=e.external.uri??((y)=>y);if(p)return{ref:m(p)};let f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${m("__shared")}#/${c}/${f}`}}if(a[1]===n)return{ref:"#"};let u=`${"#"}/${c}/`,d=a[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=(a)=>{if(a[1].schema.$ref)return;let c=a[1],{ref:l,defId:u}=r(a);if(c.def={...c.schema},u)c.defId=u;let d=c.schema;for(let p in d)delete d[p];d.$ref=l};if(e.cycles==="throw")for(let a of e.seen.entries()){let c=a[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
150
149
|
|
|
151
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let K of $.seen.entries()){let W=K[1];if(U===K[0]){z(K);continue}if($.external){let Y=$.external.registry.get(K[0])?.id;if(U!==K[0]&&Y){z(K);continue}}if($.metadataRegistry.get(K[0])?.id){z(K);continue}if(W.cycle){z(K);continue}if(W.count>1){if($.reused==="ref"){z(K);continue}}}}function Z1($,U){let v=$.seen.get(U);if(!v)throw Error("Unprocessed schema. This is a bug in Zod.");let J=(K)=>{let W=$.seen.get(K);if(W.ref===null)return;let O=W.def??W.schema,Y={...O},Z=W.ref;if(W.ref=null,Z){J(Z);let X=$.seen.get(Z),B=X.schema;if(B.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))O.allOf=O.allOf??[],O.allOf.push(B);else Object.assign(O,B);if(Object.assign(O,Y),K._zod.parent===Z)for(let F in O){if(F==="$ref"||F==="allOf")continue;if(!(F in Y))delete O[F]}if(B.$ref&&X.def)for(let F in O){if(F==="$ref"||F==="allOf")continue;if(F in X.def&&JSON.stringify(O[F])===JSON.stringify(X.def[F]))delete O[F]}}let q=K._zod.parent;if(q&&q!==Z){J(q);let X=$.seen.get(q);if(X?.schema.$ref){if(O.$ref=X.schema.$ref,X.def)for(let B in O){if(B==="$ref"||B==="allOf")continue;if(B in X.def&&JSON.stringify(O[B])===JSON.stringify(X.def[B]))delete O[B]}}}$.override({zodSchema:K,jsonSchema:O,path:W.path??[]})};for(let K of[...$.seen.entries()].reverse())J(K[0]);let _={};if($.target==="draft-2020-12")_.$schema="https://json-schema.org/draft/2020-12/schema";else if($.target==="draft-07")_.$schema="http://json-schema.org/draft-07/schema#";else if($.target==="draft-04")_.$schema="http://json-schema.org/draft-04/schema#";else if($.target==="openapi-3.0");if($.external?.uri){let K=$.external.registry.get(U)?.id;if(!K)throw Error("Schema is missing an `id` property");_.$id=$.external.uri(K)}Object.assign(_,v.def??v.schema);let z=$.external?.defs??{};for(let K of $.seen.entries()){let W=K[1];if(W.def&&W.defId)z[W.defId]=W.def}if($.external);else if(Object.keys(z).length>0)if($.target==="draft-2020-12")_.$defs=z;else _.definitions=z;try{let K=JSON.parse(JSON.stringify(_));return Object.defineProperty(K,"~standard",{value:{...U["~standard"],jsonSchema:{input:J0(U,"input",$.processors),output:J0(U,"output",$.processors)}},enumerable:!1,writable:!1}),K}catch(K){throw Error("Error converting schema to JSON.")}}function C6($,U){let v=U??{seen:new Set};if(v.seen.has($))return!1;v.seen.add($);let J=$._zod.def;if(J.type==="transform")return!0;if(J.type==="array")return C6(J.element,v);if(J.type==="set")return C6(J.valueType,v);if(J.type==="lazy")return C6(J.getter(),v);if(J.type==="promise"||J.type==="optional"||J.type==="nonoptional"||J.type==="nullable"||J.type==="readonly"||J.type==="default"||J.type==="prefault")return C6(J.innerType,v);if(J.type==="intersection")return C6(J.left,v)||C6(J.right,v);if(J.type==="record"||J.type==="map")return C6(J.keyType,v)||C6(J.valueType,v);if(J.type==="pipe")return C6(J.in,v)||C6(J.out,v);if(J.type==="object"){for(let _ in J.shape)if(C6(J.shape[_],v))return!0;return!1}if(J.type==="union"){for(let _ of J.options)if(C6(_,v))return!0;return!1}if(J.type==="tuple"){for(let _ of J.items)if(C6(_,v))return!0;if(J.rest&&C6(J.rest,v))return!0;return!1}return!1}var ZK=($,U={})=>(v)=>{let J=O1({...v,processors:U});return R$($,J),Y1(J,$),Z1(J,$)},J0=($,U,v={})=>(J)=>{let{libraryOptions:_,target:z}=J??{},K=O1({..._??{},target:z,io:U,processors:v});return R$($,K),Y1(K,$),Z1(K,$)};var LM={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},qK=($,U,v,J)=>{let _=v;_.type="string";let{minimum:z,maximum:K,format:W,patterns:O,contentEncoding:Y}=$._zod.bag;if(typeof z==="number")_.minLength=z;if(typeof K==="number")_.maxLength=K;if(W){if(_.format=LM[W]??W,_.format==="")delete _.format;if(W==="time")delete _.format}if(Y)_.contentEncoding=Y;if(O&&O.size>0){let Z=[...O];if(Z.length===1)_.pattern=Z[0].source;else if(Z.length>1)_.allOf=[...Z.map((q)=>({...U.target==="draft-07"||U.target==="draft-04"||U.target==="openapi-3.0"?{type:"string"}:{},pattern:q.source}))]}},BK=($,U,v,J)=>{let _=v,{minimum:z,maximum:K,format:W,multipleOf:O,exclusiveMaximum:Y,exclusiveMinimum:Z}=$._zod.bag;if(typeof W==="string"&&W.includes("int"))_.type="integer";else _.type="number";if(typeof Z==="number")if(U.target==="draft-04"||U.target==="openapi-3.0")_.minimum=Z,_.exclusiveMinimum=!0;else _.exclusiveMinimum=Z;if(typeof z==="number"){if(_.minimum=z,typeof Z==="number"&&U.target!=="draft-04")if(Z>=z)delete _.minimum;else delete _.exclusiveMinimum}if(typeof Y==="number")if(U.target==="draft-04"||U.target==="openapi-3.0")_.maximum=Y,_.exclusiveMaximum=!0;else _.exclusiveMaximum=Y;if(typeof K==="number"){if(_.maximum=K,typeof Y==="number"&&U.target!=="draft-04")if(Y<=K)delete _.maximum;else delete _.exclusiveMaximum}if(typeof O==="number")_.multipleOf=O},XK=($,U,v,J)=>{v.type="boolean"},HK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},QK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},LK=($,U,v,J)=>{if(U.target==="openapi-3.0")v.type="string",v.nullable=!0,v.enum=[null];else v.type="null"},FK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},PK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},kK=($,U,v,J)=>{v.not={}},bK=($,U,v,J)=>{},MK=($,U,v,J)=>{},AK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},IK=($,U,v,J)=>{let _=$._zod.def,z=__(_.entries);if(z.every((K)=>typeof K==="number"))v.type="number";if(z.every((K)=>typeof K==="string"))v.type="string";v.enum=z},wK=($,U,v,J)=>{let _=$._zod.def,z=[];for(let K of _.values)if(K===void 0){if(U.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof K==="bigint")if(U.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else z.push(Number(K));else z.push(K);if(z.length===0);else if(z.length===1){let K=z[0];if(v.type=K===null?"null":typeof K,U.target==="draft-04"||U.target==="openapi-3.0")v.enum=[K];else v.const=K}else{if(z.every((K)=>typeof K==="number"))v.type="number";if(z.every((K)=>typeof K==="string"))v.type="string";if(z.every((K)=>typeof K==="boolean"))v.type="boolean";if(z.every((K)=>K===null))v.type="null";v.enum=z}},gK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},NK=($,U,v,J)=>{let _=v,z=$._zod.pattern;if(!z)throw Error("Pattern not found in template literal");_.type="string",_.pattern=z.source},SK=($,U,v,J)=>{let _=v,z={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:W,mime:O}=$._zod.bag;if(K!==void 0)z.minLength=K;if(W!==void 0)z.maxLength=W;if(O)if(O.length===1)z.contentMediaType=O[0],Object.assign(_,z);else Object.assign(_,z),_.anyOf=O.map((Y)=>({contentMediaType:Y}));else Object.assign(_,z)},RK=($,U,v,J)=>{v.type="boolean"},TK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},yK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},CK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},DK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},jK=($,U,v,J)=>{if(U.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},VK=($,U,v,J)=>{let _=v,z=$._zod.def,{minimum:K,maximum:W}=$._zod.bag;if(typeof K==="number")_.minItems=K;if(typeof W==="number")_.maxItems=W;_.type="array",_.items=R$(z.element,U,{...J,path:[...J.path,"items"]})},fK=($,U,v,J)=>{let _=v,z=$._zod.def;_.type="object",_.properties={};let K=z.shape;for(let Y in K)_.properties[Y]=R$(K[Y],U,{...J,path:[...J.path,"properties",Y]});let W=new Set(Object.keys(K)),O=new Set([...W].filter((Y)=>{let Z=z.shape[Y]._zod;if(U.io==="input")return Z.optin===void 0;else return Z.optout===void 0}));if(O.size>0)_.required=Array.from(O);if(z.catchall?._zod.def.type==="never")_.additionalProperties=!1;else if(!z.catchall){if(U.io==="output")_.additionalProperties=!1}else if(z.catchall)_.additionalProperties=R$(z.catchall,U,{...J,path:[...J.path,"additionalProperties"]})},FJ=($,U,v,J)=>{let _=$._zod.def,z=_.inclusive===!1,K=_.options.map((W,O)=>R$(W,U,{...J,path:[...J.path,z?"oneOf":"anyOf",O]}));if(z)v.oneOf=K;else v.anyOf=K},EK=($,U,v,J)=>{let _=$._zod.def,z=R$(_.left,U,{...J,path:[...J.path,"allOf",0]}),K=R$(_.right,U,{...J,path:[...J.path,"allOf",1]}),W=(Y)=>("allOf"in Y)&&Object.keys(Y).length===1,O=[...W(z)?z.allOf:[z],...W(K)?K.allOf:[K]];v.allOf=O},uK=($,U,v,J)=>{let _=v,z=$._zod.def;_.type="array";let K=U.target==="draft-2020-12"?"prefixItems":"items",W=U.target==="draft-2020-12"?"items":U.target==="openapi-3.0"?"items":"additionalItems",O=z.items.map((X,B)=>R$(X,U,{...J,path:[...J.path,K,B]})),Y=z.rest?R$(z.rest,U,{...J,path:[...J.path,W,...U.target==="openapi-3.0"?[z.items.length]:[]]}):null;if(U.target==="draft-2020-12"){if(_.prefixItems=O,Y)_.items=Y}else if(U.target==="openapi-3.0"){if(_.items={anyOf:O},Y)_.items.anyOf.push(Y);if(_.minItems=O.length,!Y)_.maxItems=O.length}else if(_.items=O,Y)_.additionalItems=Y;let{minimum:Z,maximum:q}=$._zod.bag;if(typeof Z==="number")_.minItems=Z;if(typeof q==="number")_.maxItems=q},mK=($,U,v,J)=>{let _=v,z=$._zod.def;_.type="object";let K=z.keyType,O=K._zod.bag?.patterns;if(z.mode==="loose"&&O&&O.size>0){let Z=R$(z.valueType,U,{...J,path:[...J.path,"patternProperties","*"]});_.patternProperties={};for(let q of O)_.patternProperties[q.source]=Z}else{if(U.target==="draft-07"||U.target==="draft-2020-12")_.propertyNames=R$(z.keyType,U,{...J,path:[...J.path,"propertyNames"]});_.additionalProperties=R$(z.valueType,U,{...J,path:[...J.path,"additionalProperties"]})}let Y=K._zod.values;if(Y){let Z=[...Y].filter((q)=>typeof q==="string"||typeof q==="number");if(Z.length>0)_.required=Z}},xK=($,U,v,J)=>{let _=$._zod.def,z=R$(_.innerType,U,J),K=U.seen.get($);if(U.target==="openapi-3.0")K.ref=_.innerType,v.nullable=!0;else v.anyOf=[z,{type:"null"}]},hK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType},cK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType,v.default=JSON.parse(JSON.stringify(_.defaultValue))},lK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);if(z.ref=_.innerType,U.io==="input")v._prefault=JSON.parse(JSON.stringify(_.defaultValue))},rK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType;let K;try{K=_.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}v.default=K},iK=($,U,v,J)=>{let _=$._zod.def,z=U.io==="input"?_.in._zod.def.type==="transform"?_.out:_.in:_.out;R$(z,U,J);let K=U.seen.get($);K.ref=z},pK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType,v.readOnly=!0},oK=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType},PJ=($,U,v,J)=>{let _=$._zod.def;R$(_.innerType,U,J);let z=U.seen.get($);z.ref=_.innerType},dK=($,U,v,J)=>{let _=$._zod.innerType;R$(_,U,J);let z=U.seen.get($);z.ref=_},LJ={string:qK,number:BK,boolean:XK,bigint:HK,symbol:QK,null:LK,undefined:FK,void:PK,never:kK,any:bK,unknown:MK,date:AK,enum:IK,literal:wK,nan:gK,template_literal:NK,file:SK,success:RK,custom:TK,function:yK,transform:CK,map:DK,set:jK,array:VK,object:fK,union:FJ,intersection:EK,tuple:uK,record:mK,nullable:xK,nonoptional:hK,default:cK,prefault:lK,catch:rK,pipe:iK,readonly:pK,promise:oK,optional:PJ,lazy:dK};function kJ($,U){if("_idmap"in $){let J=$,_=O1({...U,processors:LJ}),z={};for(let O of J._idmap.entries()){let[Y,Z]=O;R$(Z,_)}let K={},W={registry:J,uri:U?.uri,defs:z};_.external=W;for(let O of J._idmap.entries()){let[Y,Z]=O;Y1(_,Z),K[Y]=Z1(_,Z)}if(Object.keys(z).length>0){let O=_.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[O]:z}}return{schemas:K}}let v=O1({...U,processors:LJ});return R$($,v),Y1(v,$),Z1(v,$)}class nK{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter($){this.ctx.counter=$}get seen(){return this.ctx.seen}constructor($){let U=$?.target??"draft-2020-12";if(U==="draft-4")U="draft-04";if(U==="draft-7")U="draft-07";this.ctx=O1({processors:LJ,target:U,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,U={path:[],schemaPath:[]}){return R$($,this.ctx,U)}emit($,U){if(U){if(U.cycles)this.ctx.cycles=U.cycles;if(U.reused)this.ctx.reused=U.reused;if(U.external)this.ctx.external=U.external}Y1(this.ctx,$);let v=Z1(this.ctx,$),{"~standard":J,..._}=v;return _}}var nq={};var g_={};w4(g_,{xor:()=>mB,xid:()=>YB,void:()=>VB,uuidv7:()=>_B,uuidv6:()=>UB,uuidv4:()=>$B,uuid:()=>eq,url:()=>vB,unknown:()=>E$,union:()=>D$,undefined:()=>DB,ulid:()=>OB,uint64:()=>yB,uint32:()=>SB,tuple:()=>wG,transform:()=>pJ,templateLiteral:()=>tB,symbol:()=>CB,superRefine:()=>aG,success:()=>oB,stringbool:()=>vX,stringFormat:()=>bB,string:()=>g,strictObject:()=>uB,set:()=>lB,refine:()=>tG,record:()=>x$,readonly:()=>rG,promise:()=>aB,preprocess:()=>E_,prefault:()=>EG,pipe:()=>R_,partialRecord:()=>xB,optional:()=>l$,object:()=>a,number:()=>w$,nullish:()=>pB,nullable:()=>S_,null:()=>Z0,nonoptional:()=>uG,never:()=>iJ,nativeEnum:()=>rB,nanoid:()=>KB,nan:()=>dB,meta:()=>UX,map:()=>cB,mac:()=>BB,looseRecord:()=>hB,looseObject:()=>X6,literal:()=>U$,lazy:()=>oG,ksuid:()=>ZB,keyof:()=>EB,jwt:()=>kB,json:()=>JX,ipv6:()=>XB,ipv4:()=>qB,intersection:()=>q0,int64:()=>TB,int32:()=>NB,int:()=>gJ,instanceof:()=>_X,httpUrl:()=>JB,hostname:()=>MB,hex:()=>AB,hash:()=>IB,guid:()=>sq,function:()=>sB,float64:()=>gB,float32:()=>wB,file:()=>iB,exactOptional:()=>CG,enum:()=>H6,emoji:()=>zB,email:()=>aq,e164:()=>PB,discriminatedUnion:()=>j_,describe:()=>$X,date:()=>fB,custom:()=>aJ,cuid2:()=>WB,cuid:()=>GB,codec:()=>nB,cidrv6:()=>QB,cidrv4:()=>HB,check:()=>eB,catch:()=>hG,boolean:()=>_6,bigint:()=>RB,base64url:()=>FB,base64:()=>LB,array:()=>Q$,any:()=>jB,_function:()=>sB,_default:()=>VG,_ZodString:()=>NJ,ZodXor:()=>bG,ZodXID:()=>jJ,ZodVoid:()=>PG,ZodUnknown:()=>LG,ZodUnion:()=>D_,ZodUndefined:()=>XG,ZodUUID:()=>M4,ZodURL:()=>T_,ZodULID:()=>DJ,ZodType:()=>q$,ZodTuple:()=>IG,ZodTransform:()=>TG,ZodTemplateLiteral:()=>iG,ZodSymbol:()=>BG,ZodSuccess:()=>mG,ZodStringFormat:()=>f$,ZodString:()=>K0,ZodSet:()=>NG,ZodRecord:()=>V_,ZodReadonly:()=>lG,ZodPromise:()=>dG,ZodPrefault:()=>fG,ZodPipe:()=>nJ,ZodOptional:()=>oJ,ZodObject:()=>C_,ZodNumberFormat:()=>o1,ZodNumber:()=>W0,ZodNullable:()=>DG,ZodNull:()=>HG,ZodNonOptional:()=>dJ,ZodNever:()=>FG,ZodNanoID:()=>TJ,ZodNaN:()=>cG,ZodMap:()=>gG,ZodMAC:()=>qG,ZodLiteral:()=>SG,ZodLazy:()=>pG,ZodKSUID:()=>VJ,ZodJWT:()=>lJ,ZodIntersection:()=>AG,ZodIPv6:()=>EJ,ZodIPv4:()=>fJ,ZodGUID:()=>N_,ZodFunction:()=>nG,ZodFile:()=>RG,ZodExactOptional:()=>yG,ZodEnum:()=>z0,ZodEmoji:()=>RJ,ZodEmail:()=>SJ,ZodE164:()=>cJ,ZodDiscriminatedUnion:()=>MG,ZodDefault:()=>jG,ZodDate:()=>y_,ZodCustomStringFormat:()=>G0,ZodCustom:()=>f_,ZodCodec:()=>tJ,ZodCatch:()=>xG,ZodCUID2:()=>CJ,ZodCUID:()=>yJ,ZodCIDRv6:()=>mJ,ZodCIDRv4:()=>uJ,ZodBoolean:()=>O0,ZodBigIntFormat:()=>rJ,ZodBigInt:()=>Y0,ZodBase64URL:()=>hJ,ZodBase64:()=>xJ,ZodArray:()=>kG,ZodAny:()=>QG});var bJ={};w4(bJ,{uppercase:()=>oU,trim:()=>eU,toUpperCase:()=>U0,toLowerCase:()=>$0,startsWith:()=>nU,slugify:()=>_0,size:()=>r1,regex:()=>iU,property:()=>QJ,positive:()=>qJ,overwrite:()=>W4,normalize:()=>sU,nonpositive:()=>XJ,nonnegative:()=>HJ,negative:()=>BJ,multipleOf:()=>G1,minSize:()=>b4,minLength:()=>E4,mime:()=>aU,maxSize:()=>W1,maxLength:()=>i1,lte:()=>l6,lt:()=>P4,lowercase:()=>pU,length:()=>p1,includes:()=>dU,gte:()=>y6,gt:()=>k4,endsWith:()=>tU});var q1={};w4(q1,{time:()=>sK,duration:()=>eK,datetime:()=>tK,date:()=>aK,ZodISOTime:()=>IJ,ZodISODuration:()=>wJ,ZodISODateTime:()=>MJ,ZodISODate:()=>AJ});var MJ=M("ZodISODateTime",($,U)=>{D3.init($,U),f$.init($,U)});function tK($){return T7(MJ,$)}var AJ=M("ZodISODate",($,U)=>{j3.init($,U),f$.init($,U)});function aK($){return y7(AJ,$)}var IJ=M("ZodISOTime",($,U)=>{V3.init($,U),f$.init($,U)});function sK($){return C7(IJ,$)}var wJ=M("ZodISODuration",($,U)=>{f3.init($,U),f$.init($,U)});function eK($){return D7(wJ,$)}var tq=($,U)=>{G_.init($,U),$.name="ZodError",Object.defineProperties($,{format:{value:(v)=>O_($,v)},flatten:{value:(v)=>W_($,v)},addIssue:{value:(v)=>{$.issues.push(v),$.message=JSON.stringify($.issues,VU,2)}},addIssues:{value:(v)=>{$.issues.push(...v),$.message=JSON.stringify($.issues,VU,2)}},isEmpty:{get(){return $.issues.length===0}}})},PM=M("ZodError",tq),f6=M("ZodError",tq,{Parent:Error});var $G=uU(f6),UG=mU(f6),_G=xU(f6),vG=cU(f6),JG=Iv(f6),zG=wv(f6),KG=gv(f6),GG=Nv(f6),WG=Sv(f6),OG=Rv(f6),YG=Tv(f6),ZG=yv(f6);var q$=M("ZodType",($,U)=>{return Y$.init($,U),Object.assign($["~standard"],{jsonSchema:{input:J0($,"input"),output:J0($,"output")}}),$.toJSONSchema=ZK($,{}),$.def=U,$.type=U.type,Object.defineProperty($,"_def",{value:U}),$.check=(...v)=>{return $.clone(h.mergeDefs(U,{checks:[...U.checks??[],...v.map((J)=>typeof J==="function"?{_zod:{check:J,def:{check:"custom"},onattach:[]}}:J)]}),{parent:!0})},$.with=$.check,$.clone=(v,J)=>T6($,v,J),$.brand=()=>$,$.register=(v,J)=>{return v.add($,J),$},$.parse=(v,J)=>$G($,v,J,{callee:$.parse}),$.safeParse=(v,J)=>_G($,v,J),$.parseAsync=async(v,J)=>UG($,v,J,{callee:$.parseAsync}),$.safeParseAsync=async(v,J)=>vG($,v,J),$.spa=$.safeParseAsync,$.encode=(v,J)=>JG($,v,J),$.decode=(v,J)=>zG($,v,J),$.encodeAsync=async(v,J)=>KG($,v,J),$.decodeAsync=async(v,J)=>GG($,v,J),$.safeEncode=(v,J)=>WG($,v,J),$.safeDecode=(v,J)=>OG($,v,J),$.safeEncodeAsync=async(v,J)=>YG($,v,J),$.safeDecodeAsync=async(v,J)=>ZG($,v,J),$.refine=(v,J)=>$.check(tG(v,J)),$.superRefine=(v)=>$.check(aG(v)),$.overwrite=(v)=>$.check(W4(v)),$.optional=()=>l$($),$.exactOptional=()=>CG($),$.nullable=()=>S_($),$.nullish=()=>l$(S_($)),$.nonoptional=(v)=>uG($,v),$.array=()=>Q$($),$.or=(v)=>D$([$,v]),$.and=(v)=>q0($,v),$.transform=(v)=>R_($,pJ(v)),$.default=(v)=>VG($,v),$.prefault=(v)=>EG($,v),$.catch=(v)=>hG($,v),$.pipe=(v)=>R_($,v),$.readonly=()=>rG($),$.describe=(v)=>{let J=$.clone();return B6.add(J,{description:v}),J},Object.defineProperty($,"description",{get(){return B6.get($)?.description},configurable:!0}),$.meta=(...v)=>{if(v.length===0)return B6.get($);let J=$.clone();return B6.add(J,v[0]),J},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(v)=>v($),$}),NJ=M("_ZodString",($,U)=>{l1.init($,U),q$.init($,U),$._zod.processJSONSchema=(J,_,z)=>qK($,J,_,z);let v=$._zod.bag;$.format=v.format??null,$.minLength=v.minimum??null,$.maxLength=v.maximum??null,$.regex=(...J)=>$.check(iU(...J)),$.includes=(...J)=>$.check(dU(...J)),$.startsWith=(...J)=>$.check(nU(...J)),$.endsWith=(...J)=>$.check(tU(...J)),$.min=(...J)=>$.check(E4(...J)),$.max=(...J)=>$.check(i1(...J)),$.length=(...J)=>$.check(p1(...J)),$.nonempty=(...J)=>$.check(E4(1,...J)),$.lowercase=(J)=>$.check(pU(J)),$.uppercase=(J)=>$.check(oU(J)),$.trim=()=>$.check(eU()),$.normalize=(...J)=>$.check(sU(...J)),$.toLowerCase=()=>$.check($0()),$.toUpperCase=()=>$.check(U0()),$.slugify=()=>$.check(_0())}),K0=M("ZodString",($,U)=>{l1.init($,U),NJ.init($,U),$.email=(v)=>$.check(pv(SJ,v)),$.url=(v)=>$.check(w_(T_,v)),$.jwt=(v)=>$.check(ZJ(lJ,v)),$.emoji=(v)=>$.check(av(RJ,v)),$.guid=(v)=>$.check(I_(N_,v)),$.uuid=(v)=>$.check(ov(M4,v)),$.uuidv4=(v)=>$.check(dv(M4,v)),$.uuidv6=(v)=>$.check(nv(M4,v)),$.uuidv7=(v)=>$.check(tv(M4,v)),$.nanoid=(v)=>$.check(sv(TJ,v)),$.guid=(v)=>$.check(I_(N_,v)),$.cuid=(v)=>$.check(ev(yJ,v)),$.cuid2=(v)=>$.check($J(CJ,v)),$.ulid=(v)=>$.check(UJ(DJ,v)),$.base64=(v)=>$.check(WJ(xJ,v)),$.base64url=(v)=>$.check(OJ(hJ,v)),$.xid=(v)=>$.check(_J(jJ,v)),$.ksuid=(v)=>$.check(vJ(VJ,v)),$.ipv4=(v)=>$.check(JJ(fJ,v)),$.ipv6=(v)=>$.check(zJ(EJ,v)),$.cidrv4=(v)=>$.check(KJ(uJ,v)),$.cidrv6=(v)=>$.check(GJ(mJ,v)),$.e164=(v)=>$.check(YJ(cJ,v)),$.datetime=(v)=>$.check(tK(v)),$.date=(v)=>$.check(aK(v)),$.time=(v)=>$.check(sK(v)),$.duration=(v)=>$.check(eK(v))});function g($){return g7(K0,$)}var f$=M("ZodStringFormat",($,U)=>{V$.init($,U),NJ.init($,U)}),SJ=M("ZodEmail",($,U)=>{I3.init($,U),f$.init($,U)});function aq($){return pv(SJ,$)}var N_=M("ZodGUID",($,U)=>{M3.init($,U),f$.init($,U)});function sq($){return I_(N_,$)}var M4=M("ZodUUID",($,U)=>{A3.init($,U),f$.init($,U)});function eq($){return ov(M4,$)}function $B($){return dv(M4,$)}function UB($){return nv(M4,$)}function _B($){return tv(M4,$)}var T_=M("ZodURL",($,U)=>{w3.init($,U),f$.init($,U)});function vB($){return w_(T_,$)}function JB($){return w_(T_,{protocol:/^https?$/,hostname:s6.domain,...h.normalizeParams($)})}var RJ=M("ZodEmoji",($,U)=>{g3.init($,U),f$.init($,U)});function zB($){return av(RJ,$)}var TJ=M("ZodNanoID",($,U)=>{N3.init($,U),f$.init($,U)});function KB($){return sv(TJ,$)}var yJ=M("ZodCUID",($,U)=>{S3.init($,U),f$.init($,U)});function GB($){return ev(yJ,$)}var CJ=M("ZodCUID2",($,U)=>{R3.init($,U),f$.init($,U)});function WB($){return $J(CJ,$)}var DJ=M("ZodULID",($,U)=>{T3.init($,U),f$.init($,U)});function OB($){return UJ(DJ,$)}var jJ=M("ZodXID",($,U)=>{y3.init($,U),f$.init($,U)});function YB($){return _J(jJ,$)}var VJ=M("ZodKSUID",($,U)=>{C3.init($,U),f$.init($,U)});function ZB($){return vJ(VJ,$)}var fJ=M("ZodIPv4",($,U)=>{E3.init($,U),f$.init($,U)});function qB($){return JJ(fJ,$)}var qG=M("ZodMAC",($,U)=>{m3.init($,U),f$.init($,U)});function BB($){return S7(qG,$)}var EJ=M("ZodIPv6",($,U)=>{u3.init($,U),f$.init($,U)});function XB($){return zJ(EJ,$)}var uJ=M("ZodCIDRv4",($,U)=>{x3.init($,U),f$.init($,U)});function HB($){return KJ(uJ,$)}var mJ=M("ZodCIDRv6",($,U)=>{h3.init($,U),f$.init($,U)});function QB($){return GJ(mJ,$)}var xJ=M("ZodBase64",($,U)=>{l3.init($,U),f$.init($,U)});function LB($){return WJ(xJ,$)}var hJ=M("ZodBase64URL",($,U)=>{r3.init($,U),f$.init($,U)});function FB($){return OJ(hJ,$)}var cJ=M("ZodE164",($,U)=>{i3.init($,U),f$.init($,U)});function PB($){return YJ(cJ,$)}var lJ=M("ZodJWT",($,U)=>{p3.init($,U),f$.init($,U)});function kB($){return ZJ(lJ,$)}var G0=M("ZodCustomStringFormat",($,U)=>{o3.init($,U),f$.init($,U)});function bB($,U,v={}){return v0(G0,$,U,v)}function MB($){return v0(G0,"hostname",s6.hostname,$)}function AB($){return v0(G0,"hex",s6.hex,$)}function IB($,U){let v=U?.enc??"hex",J=`${$}_${v}`,_=s6[J];if(!_)throw Error(`Unrecognized hash format: ${J}`);return v0(G0,J,_,U)}var W0=M("ZodNumber",($,U)=>{hv.init($,U),q$.init($,U),$._zod.processJSONSchema=(J,_,z)=>BK($,J,_,z),$.gt=(J,_)=>$.check(k4(J,_)),$.gte=(J,_)=>$.check(y6(J,_)),$.min=(J,_)=>$.check(y6(J,_)),$.lt=(J,_)=>$.check(P4(J,_)),$.lte=(J,_)=>$.check(l6(J,_)),$.max=(J,_)=>$.check(l6(J,_)),$.int=(J)=>$.check(gJ(J)),$.safe=(J)=>$.check(gJ(J)),$.positive=(J)=>$.check(k4(0,J)),$.nonnegative=(J)=>$.check(y6(0,J)),$.negative=(J)=>$.check(P4(0,J)),$.nonpositive=(J)=>$.check(l6(0,J)),$.multipleOf=(J,_)=>$.check(G1(J,_)),$.step=(J,_)=>$.check(G1(J,_)),$.finite=()=>$;let v=$._zod.bag;$.minValue=Math.max(v.minimum??Number.NEGATIVE_INFINITY,v.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(v.maximum??Number.POSITIVE_INFINITY,v.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(v.format??"").includes("int")||Number.isSafeInteger(v.multipleOf??0.5),$.isFinite=!0,$.format=v.format??null});function w$($){return j7(W0,$)}var o1=M("ZodNumberFormat",($,U)=>{d3.init($,U),W0.init($,U)});function gJ($){return f7(o1,$)}function wB($){return E7(o1,$)}function gB($){return u7(o1,$)}function NB($){return m7(o1,$)}function SB($){return x7(o1,$)}var O0=M("ZodBoolean",($,U)=>{Q_.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>XK($,v,J,_)});function _6($){return h7(O0,$)}var Y0=M("ZodBigInt",($,U)=>{cv.init($,U),q$.init($,U),$._zod.processJSONSchema=(J,_,z)=>HK($,J,_,z),$.gte=(J,_)=>$.check(y6(J,_)),$.min=(J,_)=>$.check(y6(J,_)),$.gt=(J,_)=>$.check(k4(J,_)),$.gte=(J,_)=>$.check(y6(J,_)),$.min=(J,_)=>$.check(y6(J,_)),$.lt=(J,_)=>$.check(P4(J,_)),$.lte=(J,_)=>$.check(l6(J,_)),$.max=(J,_)=>$.check(l6(J,_)),$.positive=(J)=>$.check(k4(BigInt(0),J)),$.negative=(J)=>$.check(P4(BigInt(0),J)),$.nonpositive=(J)=>$.check(l6(BigInt(0),J)),$.nonnegative=(J)=>$.check(y6(BigInt(0),J)),$.multipleOf=(J,_)=>$.check(G1(J,_));let v=$._zod.bag;$.minValue=v.minimum??null,$.maxValue=v.maximum??null,$.format=v.format??null});function RB($){return l7(Y0,$)}var rJ=M("ZodBigIntFormat",($,U)=>{n3.init($,U),Y0.init($,U)});function TB($){return i7(rJ,$)}function yB($){return p7(rJ,$)}var BG=M("ZodSymbol",($,U)=>{t3.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>QK($,v,J,_)});function CB($){return o7(BG,$)}var XG=M("ZodUndefined",($,U)=>{a3.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>FK($,v,J,_)});function DB($){return d7(XG,$)}var HG=M("ZodNull",($,U)=>{s3.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>LK($,v,J,_)});function Z0($){return n7(HG,$)}var QG=M("ZodAny",($,U)=>{e3.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>bK($,v,J,_)});function jB(){return t7(QG)}var LG=M("ZodUnknown",($,U)=>{$z.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>MK($,v,J,_)});function E$(){return a7(LG)}var FG=M("ZodNever",($,U)=>{Uz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>kK($,v,J,_)});function iJ($){return s7(FG,$)}var PG=M("ZodVoid",($,U)=>{_z.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>PK($,v,J,_)});function VB($){return e7(PG,$)}var y_=M("ZodDate",($,U)=>{vz.init($,U),q$.init($,U),$._zod.processJSONSchema=(J,_,z)=>AK($,J,_,z),$.min=(J,_)=>$.check(y6(J,_)),$.max=(J,_)=>$.check(l6(J,_));let v=$._zod.bag;$.minDate=v.minimum?new Date(v.minimum):null,$.maxDate=v.maximum?new Date(v.maximum):null});function fB($){return $K(y_,$)}var kG=M("ZodArray",($,U)=>{Jz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>VK($,v,J,_),$.element=U.element,$.min=(v,J)=>$.check(E4(v,J)),$.nonempty=(v)=>$.check(E4(1,v)),$.max=(v,J)=>$.check(i1(v,J)),$.length=(v,J)=>$.check(p1(v,J)),$.unwrap=()=>$.element});function Q$($,U){return vK(kG,$,U)}function EB($){let U=$._zod.def.shape;return H6(Object.keys(U))}var C_=M("ZodObject",($,U)=>{zz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>fK($,v,J,_),h.defineLazy($,"shape",()=>{return U.shape}),$.keyof=()=>H6(Object.keys($._zod.def.shape)),$.catchall=(v)=>$.clone({...$._zod.def,catchall:v}),$.passthrough=()=>$.clone({...$._zod.def,catchall:E$()}),$.loose=()=>$.clone({...$._zod.def,catchall:E$()}),$.strict=()=>$.clone({...$._zod.def,catchall:iJ()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(v)=>{return h.extend($,v)},$.safeExtend=(v)=>{return h.safeExtend($,v)},$.merge=(v)=>h.merge($,v),$.pick=(v)=>h.pick($,v),$.omit=(v)=>h.omit($,v),$.partial=(...v)=>h.partial(oJ,$,v[0]),$.required=(...v)=>h.required(dJ,$,v[0])});function a($,U){let v={type:"object",shape:$??{},...h.normalizeParams(U)};return new C_(v)}function uB($,U){return new C_({type:"object",shape:$,catchall:iJ(),...h.normalizeParams(U)})}function X6($,U){return new C_({type:"object",shape:$,catchall:E$(),...h.normalizeParams(U)})}var D_=M("ZodUnion",($,U)=>{L_.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>FJ($,v,J,_),$.options=U.options});function D$($,U){return new D_({type:"union",options:$,...h.normalizeParams(U)})}var bG=M("ZodXor",($,U)=>{D_.init($,U),Kz.init($,U),$._zod.processJSONSchema=(v,J,_)=>FJ($,v,J,_),$.options=U.options});function mB($,U){return new bG({type:"union",options:$,inclusive:!1,...h.normalizeParams(U)})}var MG=M("ZodDiscriminatedUnion",($,U)=>{D_.init($,U),Gz.init($,U)});function j_($,U,v){return new MG({type:"union",options:U,discriminator:$,...h.normalizeParams(v)})}var AG=M("ZodIntersection",($,U)=>{Wz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>EK($,v,J,_)});function q0($,U){return new AG({type:"intersection",left:$,right:U})}var IG=M("ZodTuple",($,U)=>{lv.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>uK($,v,J,_),$.rest=(v)=>$.clone({...$._zod.def,rest:v})});function wG($,U,v){let J=U instanceof Y$,_=J?v:U;return new IG({type:"tuple",items:$,rest:J?U:null,...h.normalizeParams(_)})}var V_=M("ZodRecord",($,U)=>{Oz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>mK($,v,J,_),$.keyType=U.keyType,$.valueType=U.valueType});function x$($,U,v){return new V_({type:"record",keyType:$,valueType:U,...h.normalizeParams(v)})}function xB($,U,v){let J=T6($);return J._zod.values=void 0,new V_({type:"record",keyType:J,valueType:U,...h.normalizeParams(v)})}function hB($,U,v){return new V_({type:"record",keyType:$,valueType:U,mode:"loose",...h.normalizeParams(v)})}var gG=M("ZodMap",($,U)=>{Yz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>DK($,v,J,_),$.keyType=U.keyType,$.valueType=U.valueType,$.min=(...v)=>$.check(b4(...v)),$.nonempty=(v)=>$.check(b4(1,v)),$.max=(...v)=>$.check(W1(...v)),$.size=(...v)=>$.check(r1(...v))});function cB($,U,v){return new gG({type:"map",keyType:$,valueType:U,...h.normalizeParams(v)})}var NG=M("ZodSet",($,U)=>{Zz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>jK($,v,J,_),$.min=(...v)=>$.check(b4(...v)),$.nonempty=(v)=>$.check(b4(1,v)),$.max=(...v)=>$.check(W1(...v)),$.size=(...v)=>$.check(r1(...v))});function lB($,U){return new NG({type:"set",valueType:$,...h.normalizeParams(U)})}var z0=M("ZodEnum",($,U)=>{qz.init($,U),q$.init($,U),$._zod.processJSONSchema=(J,_,z)=>IK($,J,_,z),$.enum=U.entries,$.options=Object.values(U.entries);let v=new Set(Object.keys(U.entries));$.extract=(J,_)=>{let z={};for(let K of J)if(v.has(K))z[K]=U.entries[K];else throw Error(`Key ${K} not found in enum`);return new z0({...U,checks:[],...h.normalizeParams(_),entries:z})},$.exclude=(J,_)=>{let z={...U.entries};for(let K of J)if(v.has(K))delete z[K];else throw Error(`Key ${K} not found in enum`);return new z0({...U,checks:[],...h.normalizeParams(_),entries:z})}});function H6($,U){let v=Array.isArray($)?Object.fromEntries($.map((J)=>[J,J])):$;return new z0({type:"enum",entries:v,...h.normalizeParams(U)})}function rB($,U){return new z0({type:"enum",entries:$,...h.normalizeParams(U)})}var SG=M("ZodLiteral",($,U)=>{Bz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>wK($,v,J,_),$.values=new Set(U.values),Object.defineProperty($,"value",{get(){if(U.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return U.values[0]}})});function U$($,U){return new SG({type:"literal",values:Array.isArray($)?$:[$],...h.normalizeParams(U)})}var RG=M("ZodFile",($,U)=>{Xz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>SK($,v,J,_),$.min=(v,J)=>$.check(b4(v,J)),$.max=(v,J)=>$.check(W1(v,J)),$.mime=(v,J)=>$.check(aU(Array.isArray(v)?v:[v],J))});function iB($){return JK(RG,$)}var TG=M("ZodTransform",($,U)=>{Hz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>CK($,v,J,_),$._zod.parse=(v,J)=>{if(J.direction==="backward")throw new x1($.constructor.name);v.addIssue=(z)=>{if(typeof z==="string")v.issues.push(h.issue(z,v.value,U));else{let K=z;if(K.fatal)K.continue=!1;K.code??(K.code="custom"),K.input??(K.input=v.value),K.inst??(K.inst=$),v.issues.push(h.issue(K))}};let _=U.transform(v.value,v);if(_ instanceof Promise)return _.then((z)=>{return v.value=z,v});return v.value=_,v}});function pJ($){return new TG({type:"transform",transform:$})}var oJ=M("ZodOptional",($,U)=>{rv.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>PJ($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function l$($){return new oJ({type:"optional",innerType:$})}var yG=M("ZodExactOptional",($,U)=>{Qz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>PJ($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function CG($){return new yG({type:"optional",innerType:$})}var DG=M("ZodNullable",($,U)=>{Lz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>xK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function S_($){return new DG({type:"nullable",innerType:$})}function pB($){return l$(S_($))}var jG=M("ZodDefault",($,U)=>{Fz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>cK($,v,J,_),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function VG($,U){return new jG({type:"default",innerType:$,get defaultValue(){return typeof U==="function"?U():h.shallowClone(U)}})}var fG=M("ZodPrefault",($,U)=>{Pz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>lK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function EG($,U){return new fG({type:"prefault",innerType:$,get defaultValue(){return typeof U==="function"?U():h.shallowClone(U)}})}var dJ=M("ZodNonOptional",($,U)=>{kz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>hK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function uG($,U){return new dJ({type:"nonoptional",innerType:$,...h.normalizeParams(U)})}var mG=M("ZodSuccess",($,U)=>{bz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>RK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function oB($){return new mG({type:"success",innerType:$})}var xG=M("ZodCatch",($,U)=>{Mz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>rK($,v,J,_),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function hG($,U){return new xG({type:"catch",innerType:$,catchValue:typeof U==="function"?U:()=>U})}var cG=M("ZodNaN",($,U)=>{Az.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>gK($,v,J,_)});function dB($){return _K(cG,$)}var nJ=M("ZodPipe",($,U)=>{Iz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>iK($,v,J,_),$.in=U.in,$.out=U.out});function R_($,U){return new nJ({type:"pipe",in:$,out:U})}var tJ=M("ZodCodec",($,U)=>{nJ.init($,U),F_.init($,U)});function nB($,U,v){return new tJ({type:"pipe",in:$,out:U,transform:v.decode,reverseTransform:v.encode})}var lG=M("ZodReadonly",($,U)=>{wz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>pK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function rG($){return new lG({type:"readonly",innerType:$})}var iG=M("ZodTemplateLiteral",($,U)=>{gz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>NK($,v,J,_)});function tB($,U){return new iG({type:"template_literal",parts:$,...h.normalizeParams(U)})}var pG=M("ZodLazy",($,U)=>{Rz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>dK($,v,J,_),$.unwrap=()=>$._zod.def.getter()});function oG($){return new pG({type:"lazy",getter:$})}var dG=M("ZodPromise",($,U)=>{Sz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>oK($,v,J,_),$.unwrap=()=>$._zod.def.innerType});function aB($){return new dG({type:"promise",innerType:$})}var nG=M("ZodFunction",($,U)=>{Nz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>yK($,v,J,_)});function sB($){return new nG({type:"function",input:Array.isArray($?.input)?wG($?.input):$?.input??Q$(E$()),output:$?.output??E$()})}var f_=M("ZodCustom",($,U)=>{Tz.init($,U),q$.init($,U),$._zod.processJSONSchema=(v,J,_)=>TK($,v,J,_)});function eB($){let U=new m$({check:"custom"});return U._zod.check=$,U}function aJ($,U){return zK(f_,$??(()=>!0),U)}function tG($,U={}){return KK(f_,$,U)}function aG($){return GK($)}var $X=WK,UX=OK;function _X($,U={}){let v=new f_({type:"custom",check:"custom",fn:(J)=>J instanceof $,abort:!0,...h.normalizeParams(U)});return v._zod.bag.Class=$,v._zod.check=(J)=>{if(!(J.value instanceof $))J.issues.push({code:"invalid_type",expected:$.name,input:J.value,inst:v,path:[...v._zod.def.path??[]]})},v}var vX=(...$)=>YK({Codec:tJ,Boolean:O0,String:K0},...$);function JX($){let U=oG(()=>{return D$([g($),w$(),_6(),Z0(),Q$(U),x$(g(),U)])});return U}function E_($,U){return R_(pJ($),U)}var bM={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function MM($){U6({customError:$})}function AM(){return U6().customError}var sG;(function($){})(sG||(sG={}));var n={...g_,...bJ,iso:q1},IM=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function wM($,U){let v=$.$schema;if(v==="https://json-schema.org/draft/2020-12/schema")return"draft-2020-12";if(v==="http://json-schema.org/draft-07/schema#")return"draft-7";if(v==="http://json-schema.org/draft-04/schema#")return"draft-4";return U??"draft-2020-12"}function gM($,U){if(!$.startsWith("#"))throw Error("External $ref is not supported, only local refs (#/...) are allowed");let v=$.slice(1).split("/").filter(Boolean);if(v.length===0)return U.rootSchema;let J=U.version==="draft-2020-12"?"$defs":"definitions";if(v[0]===J){let _=v[1];if(!_||!U.defs[_])throw Error(`Reference not found: ${$}`);return U.defs[_]}throw Error(`Reference not found: ${$}`)}function zX($,U){if($.not!==void 0){if(typeof $.not==="object"&&Object.keys($.not).length===0)return n.never();throw Error("not is not supported in Zod (except { not: {} } for never)")}if($.unevaluatedItems!==void 0)throw Error("unevaluatedItems is not supported");if($.unevaluatedProperties!==void 0)throw Error("unevaluatedProperties is not supported");if($.if!==void 0||$.then!==void 0||$.else!==void 0)throw Error("Conditional schemas (if/then/else) are not supported");if($.dependentSchemas!==void 0||$.dependentRequired!==void 0)throw Error("dependentSchemas and dependentRequired are not supported");if($.$ref){let _=$.$ref;if(U.refs.has(_))return U.refs.get(_);if(U.processing.has(_))return n.lazy(()=>{if(!U.refs.has(_))throw Error(`Circular reference not resolved: ${_}`);return U.refs.get(_)});U.processing.add(_);let z=gM(_,U),K=N6(z,U);return U.refs.set(_,K),U.processing.delete(_),K}if($.enum!==void 0){let _=$.enum;if(U.version==="openapi-3.0"&&$.nullable===!0&&_.length===1&&_[0]===null)return n.null();if(_.length===0)return n.never();if(_.length===1)return n.literal(_[0]);if(_.every((K)=>typeof K==="string"))return n.enum(_);let z=_.map((K)=>n.literal(K));if(z.length<2)return z[0];return n.union([z[0],z[1],...z.slice(2)])}if($.const!==void 0)return n.literal($.const);let v=$.type;if(Array.isArray(v)){let _=v.map((z)=>{let K={...$,type:z};return zX(K,U)});if(_.length===0)return n.never();if(_.length===1)return _[0];return n.union(_)}if(!v)return n.any();let J;switch(v){case"string":{let _=n.string();if($.format){let z=$.format;if(z==="email")_=_.check(n.email());else if(z==="uri"||z==="uri-reference")_=_.check(n.url());else if(z==="uuid"||z==="guid")_=_.check(n.uuid());else if(z==="date-time")_=_.check(n.iso.datetime());else if(z==="date")_=_.check(n.iso.date());else if(z==="time")_=_.check(n.iso.time());else if(z==="duration")_=_.check(n.iso.duration());else if(z==="ipv4")_=_.check(n.ipv4());else if(z==="ipv6")_=_.check(n.ipv6());else if(z==="mac")_=_.check(n.mac());else if(z==="cidr")_=_.check(n.cidrv4());else if(z==="cidr-v6")_=_.check(n.cidrv6());else if(z==="base64")_=_.check(n.base64());else if(z==="base64url")_=_.check(n.base64url());else if(z==="e164")_=_.check(n.e164());else if(z==="jwt")_=_.check(n.jwt());else if(z==="emoji")_=_.check(n.emoji());else if(z==="nanoid")_=_.check(n.nanoid());else if(z==="cuid")_=_.check(n.cuid());else if(z==="cuid2")_=_.check(n.cuid2());else if(z==="ulid")_=_.check(n.ulid());else if(z==="xid")_=_.check(n.xid());else if(z==="ksuid")_=_.check(n.ksuid())}if(typeof $.minLength==="number")_=_.min($.minLength);if(typeof $.maxLength==="number")_=_.max($.maxLength);if($.pattern)_=_.regex(new RegExp($.pattern));J=_;break}case"number":case"integer":{let _=v==="integer"?n.number().int():n.number();if(typeof $.minimum==="number")_=_.min($.minimum);if(typeof $.maximum==="number")_=_.max($.maximum);if(typeof $.exclusiveMinimum==="number")_=_.gt($.exclusiveMinimum);else if($.exclusiveMinimum===!0&&typeof $.minimum==="number")_=_.gt($.minimum);if(typeof $.exclusiveMaximum==="number")_=_.lt($.exclusiveMaximum);else if($.exclusiveMaximum===!0&&typeof $.maximum==="number")_=_.lt($.maximum);if(typeof $.multipleOf==="number")_=_.multipleOf($.multipleOf);J=_;break}case"boolean":{J=n.boolean();break}case"null":{J=n.null();break}case"object":{let _={},z=$.properties||{},K=new Set($.required||[]);for(let[O,Y]of Object.entries(z)){let Z=N6(Y,U);_[O]=K.has(O)?Z:Z.optional()}if($.propertyNames){let O=N6($.propertyNames,U),Y=$.additionalProperties&&typeof $.additionalProperties==="object"?N6($.additionalProperties,U):n.any();if(Object.keys(_).length===0){J=n.record(O,Y);break}let Z=n.object(_).passthrough(),q=n.looseRecord(O,Y);J=n.intersection(Z,q);break}if($.patternProperties){let O=$.patternProperties,Y=Object.keys(O),Z=[];for(let X of Y){let B=N6(O[X],U),L=n.string().regex(new RegExp(X));Z.push(n.looseRecord(L,B))}let q=[];if(Object.keys(_).length>0)q.push(n.object(_).passthrough());if(q.push(...Z),q.length===0)J=n.object({}).passthrough();else if(q.length===1)J=q[0];else{let X=n.intersection(q[0],q[1]);for(let B=2;B<q.length;B++)X=n.intersection(X,q[B]);J=X}break}let W=n.object(_);if($.additionalProperties===!1)J=W.strict();else if(typeof $.additionalProperties==="object")J=W.catchall(N6($.additionalProperties,U));else J=W.passthrough();break}case"array":{let{prefixItems:_,items:z}=$;if(_&&Array.isArray(_)){let K=_.map((O)=>N6(O,U)),W=z&&typeof z==="object"&&!Array.isArray(z)?N6(z,U):void 0;if(W)J=n.tuple(K).rest(W);else J=n.tuple(K);if(typeof $.minItems==="number")J=J.check(n.minLength($.minItems));if(typeof $.maxItems==="number")J=J.check(n.maxLength($.maxItems))}else if(Array.isArray(z)){let K=z.map((O)=>N6(O,U)),W=$.additionalItems&&typeof $.additionalItems==="object"?N6($.additionalItems,U):void 0;if(W)J=n.tuple(K).rest(W);else J=n.tuple(K);if(typeof $.minItems==="number")J=J.check(n.minLength($.minItems));if(typeof $.maxItems==="number")J=J.check(n.maxLength($.maxItems))}else if(z!==void 0){let K=N6(z,U),W=n.array(K);if(typeof $.minItems==="number")W=W.min($.minItems);if(typeof $.maxItems==="number")W=W.max($.maxItems);J=W}else J=n.array(n.any());break}default:throw Error(`Unsupported type: ${v}`)}if($.description)J=J.describe($.description);if($.default!==void 0)J=J.default($.default);return J}function N6($,U){if(typeof $==="boolean")return $?n.any():n.never();let v=zX($,U),J=$.type||$.enum!==void 0||$.const!==void 0;if($.anyOf&&Array.isArray($.anyOf)){let W=$.anyOf.map((Y)=>N6(Y,U)),O=n.union(W);v=J?n.intersection(v,O):O}if($.oneOf&&Array.isArray($.oneOf)){let W=$.oneOf.map((Y)=>N6(Y,U)),O=n.xor(W);v=J?n.intersection(v,O):O}if($.allOf&&Array.isArray($.allOf))if($.allOf.length===0)v=J?v:n.any();else{let W=J?v:N6($.allOf[0],U),O=J?0:1;for(let Y=O;Y<$.allOf.length;Y++)W=n.intersection(W,N6($.allOf[Y],U));v=W}if($.nullable===!0&&U.version==="openapi-3.0")v=n.nullable(v);if($.readOnly===!0)v=n.readonly(v);let _={},z=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let W of z)if(W in $)_[W]=$[W];let K=["contentEncoding","contentMediaType","contentSchema"];for(let W of K)if(W in $)_[W]=$[W];for(let W of Object.keys($))if(!IM.has(W))_[W]=$[W];if(Object.keys(_).length>0)U.registry.add(v,_);return v}function KX($,U){if(typeof $==="boolean")return $?n.any():n.never();let v=wM($,U?.defaultTarget),J=$.$defs||$.definitions||{},_={version:v,defs:J,refs:new Map,processing:new Set,rootSchema:$,registry:U?.registry??B6};return N6($,_)}var eG={};w4(eG,{string:()=>NM,number:()=>SM,date:()=>yM,boolean:()=>RM,bigint:()=>TM});function NM($){return N7(K0,$)}function SM($){return V7(W0,$)}function RM($){return c7(O0,$)}function TM($){return r7(Y0,$)}function yM($){return UK(y_,$)}U6(P_());var B1="io.modelcontextprotocol/related-task",eJ="2.0",Q6=aJ(($)=>$!==null&&(typeof $==="object"||typeof $==="function")),GX=D$([g(),w$().int()]),WX=g(),HD=X6({ttl:D$([w$(),Z0()]).optional(),pollInterval:w$().optional()}),CM=a({ttl:w$().optional()}),DM=a({taskId:g()}),$W=X6({progressToken:GX.optional(),[B1]:DM.optional()}),r6=a({_meta:$W.optional()}),u_=r6.extend({task:CM.optional()}),OX=($)=>u_.safeParse($).success,L6=a({method:g(),params:r6.loose().optional()}),e6=a({_meta:$W.optional()}),$4=a({method:g(),params:e6.loose().optional()}),F6=X6({_meta:$W.optional()}),X0=D$([g(),w$().int()]),YX=a({jsonrpc:U$(eJ),id:X0,...L6.shape}).strict(),UW=($)=>YX.safeParse($).success,ZX=a({jsonrpc:U$(eJ),...$4.shape}).strict(),qX=($)=>ZX.safeParse($).success,_W=a({jsonrpc:U$(eJ),id:X0,result:F6}).strict(),m_=($)=>_W.safeParse($).success;var T$;(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError",$[$.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(T$||(T$={}));var vW=a({jsonrpc:U$(eJ),id:X0.optional(),error:a({code:w$().int(),message:g(),data:E$().optional()})}).strict();var BX=($)=>vW.safeParse($).success;var XX=D$([YX,ZX,_W,vW]),QD=D$([_W,vW]),$9=F6.strict(),jM=e6.extend({requestId:X0.optional(),reason:g().optional()}),U9=$4.extend({method:U$("notifications/cancelled"),params:jM}),VM=a({src:g(),mimeType:g().optional(),sizes:Q$(g()).optional(),theme:H6(["light","dark"]).optional()}),x_=a({icons:Q$(VM).optional()}),B0=a({name:g(),title:g().optional()}),h_=B0.extend({...B0.shape,...x_.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),fM=q0(a({applyDefaults:_6().optional()}),x$(g(),E$())),EM=E_(($)=>{if($&&typeof $==="object"&&!Array.isArray($)){if(Object.keys($).length===0)return{form:{}}}return $},q0(a({form:fM.optional(),url:Q6.optional()}),x$(g(),E$()).optional())),uM=X6({list:Q6.optional(),cancel:Q6.optional(),requests:X6({sampling:X6({createMessage:Q6.optional()}).optional(),elicitation:X6({create:Q6.optional()}).optional()}).optional()}),mM=X6({list:Q6.optional(),cancel:Q6.optional(),requests:X6({tools:X6({call:Q6.optional()}).optional()}).optional()}),xM=a({experimental:x$(g(),Q6).optional(),sampling:a({context:Q6.optional(),tools:Q6.optional()}).optional(),elicitation:EM.optional(),roots:a({listChanged:_6().optional()}).optional(),tasks:uM.optional()}),hM=r6.extend({protocolVersion:g(),capabilities:xM,clientInfo:h_}),cM=L6.extend({method:U$("initialize"),params:hM});var lM=a({experimental:x$(g(),Q6).optional(),logging:Q6.optional(),completions:Q6.optional(),prompts:a({listChanged:_6().optional()}).optional(),resources:a({subscribe:_6().optional(),listChanged:_6().optional()}).optional(),tools:a({listChanged:_6().optional()}).optional(),tasks:mM.optional()}),rM=F6.extend({protocolVersion:g(),capabilities:lM,serverInfo:h_,instructions:g().optional()}),iM=$4.extend({method:U$("notifications/initialized"),params:e6.optional()});var X1=L6.extend({method:U$("ping"),params:r6.optional()}),pM=a({progress:w$(),total:l$(w$()),message:l$(g())}),oM=a({...e6.shape,...pM.shape,progressToken:GX}),_9=$4.extend({method:U$("notifications/progress"),params:oM}),dM=r6.extend({cursor:WX.optional()}),c_=L6.extend({params:dM.optional()}),l_=F6.extend({nextCursor:WX.optional()}),nM=H6(["working","input_required","completed","failed","cancelled"]),r_=a({taskId:g(),status:nM,ttl:D$([w$(),Z0()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:l$(w$()),statusMessage:l$(g())}),v9=F6.extend({task:r_}),tM=e6.merge(r_),i_=$4.extend({method:U$("notifications/tasks/status"),params:tM}),J9=L6.extend({method:U$("tasks/get"),params:r6.extend({taskId:g()})}),z9=F6.merge(r_),K9=L6.extend({method:U$("tasks/result"),params:r6.extend({taskId:g()})}),LD=F6.loose(),G9=c_.extend({method:U$("tasks/list")}),W9=l_.extend({tasks:Q$(r_)}),O9=L6.extend({method:U$("tasks/cancel"),params:r6.extend({taskId:g()})}),HX=F6.merge(r_),QX=a({uri:g(),mimeType:l$(g()),_meta:x$(g(),E$()).optional()}),LX=QX.extend({text:g()}),JW=g().refine(($)=>{try{return atob($),!0}catch{return!1}},{message:"Invalid Base64 string"}),FX=QX.extend({blob:JW}),p_=H6(["user","assistant"]),H0=a({audience:Q$(p_).optional(),priority:w$().min(0).max(1).optional(),lastModified:q1.datetime({offset:!0}).optional()}),PX=a({...B0.shape,...x_.shape,uri:g(),description:l$(g()),mimeType:l$(g()),annotations:H0.optional(),_meta:l$(X6({}))}),aM=a({...B0.shape,...x_.shape,uriTemplate:g(),description:l$(g()),mimeType:l$(g()),annotations:H0.optional(),_meta:l$(X6({}))}),zW=c_.extend({method:U$("resources/list")}),o_=l_.extend({resources:Q$(PX)}),KW=c_.extend({method:U$("resources/templates/list")}),GW=l_.extend({resourceTemplates:Q$(aM)}),WW=r6.extend({uri:g()}),sM=WW,OW=L6.extend({method:U$("resources/read"),params:sM}),d_=F6.extend({contents:Q$(D$([LX,FX]))}),YW=$4.extend({method:U$("notifications/resources/list_changed"),params:e6.optional()}),eM=WW,$A=L6.extend({method:U$("resources/subscribe"),params:eM}),UA=WW,_A=L6.extend({method:U$("resources/unsubscribe"),params:UA}),vA=e6.extend({uri:g()}),JA=$4.extend({method:U$("notifications/resources/updated"),params:vA}),zA=a({name:g(),description:l$(g()),required:l$(_6())}),KA=a({...B0.shape,...x_.shape,description:l$(g()),arguments:l$(Q$(zA)),_meta:l$(X6({}))}),ZW=c_.extend({method:U$("prompts/list")}),qW=l_.extend({prompts:Q$(KA)}),GA=r6.extend({name:g(),arguments:x$(g(),g()).optional()}),WA=L6.extend({method:U$("prompts/get"),params:GA}),BW=a({type:U$("text"),text:g(),annotations:H0.optional(),_meta:x$(g(),E$()).optional()}),XW=a({type:U$("image"),data:JW,mimeType:g(),annotations:H0.optional(),_meta:x$(g(),E$()).optional()}),HW=a({type:U$("audio"),data:JW,mimeType:g(),annotations:H0.optional(),_meta:x$(g(),E$()).optional()}),OA=a({type:U$("tool_use"),name:g(),id:g(),input:x$(g(),E$()),_meta:x$(g(),E$()).optional()}),QW=a({type:U$("resource"),resource:D$([LX,FX]),annotations:H0.optional(),_meta:x$(g(),E$()).optional()}),LW=PX.extend({type:U$("resource_link")}),Q0=D$([BW,XW,HW,LW,QW]),YA=a({role:p_,content:Q0}),ZA=F6.extend({description:g().optional(),messages:Q$(YA)}),FW=$4.extend({method:U$("notifications/prompts/list_changed"),params:e6.optional()}),qA=a({title:g().optional(),readOnlyHint:_6().optional(),destructiveHint:_6().optional(),idempotentHint:_6().optional(),openWorldHint:_6().optional()}),BA=a({taskSupport:H6(["required","optional","forbidden"]).optional()}),Y9=a({...B0.shape,...x_.shape,description:g().optional(),inputSchema:a({type:U$("object"),properties:x$(g(),Q6).optional(),required:Q$(g()).optional()}).catchall(E$()),outputSchema:a({type:U$("object"),properties:x$(g(),Q6).optional(),required:Q$(g()).optional()}).catchall(E$()).optional(),annotations:qA.optional(),execution:BA.optional(),_meta:x$(g(),E$()).optional()}),n_=c_.extend({method:U$("tools/list")}),XA=l_.extend({tools:Q$(Y9)}),H1=F6.extend({content:Q$(Q0).default([]),structuredContent:x$(g(),E$()).optional(),isError:_6().optional()}),FD=H1.or(F6.extend({toolResult:E$()})),HA=u_.extend({name:g(),arguments:x$(g(),E$()).optional()}),t_=L6.extend({method:U$("tools/call"),params:HA}),PW=$4.extend({method:U$("notifications/tools/list_changed"),params:e6.optional()}),PD=a({autoRefresh:_6().default(!0),debounceMs:w$().int().nonnegative().default(300)}),kX=H6(["debug","info","notice","warning","error","critical","alert","emergency"]),QA=r6.extend({level:kX}),LA=L6.extend({method:U$("logging/setLevel"),params:QA}),FA=e6.extend({level:kX,logger:g().optional(),data:E$()}),kW=$4.extend({method:U$("notifications/message"),params:FA}),PA=a({name:g().optional()}),kA=a({hints:Q$(PA).optional(),costPriority:w$().min(0).max(1).optional(),speedPriority:w$().min(0).max(1).optional(),intelligencePriority:w$().min(0).max(1).optional()}),bA=a({mode:H6(["auto","required","none"]).optional()}),MA=a({type:U$("tool_result"),toolUseId:g().describe("The unique identifier for the corresponding tool call."),content:Q$(Q0).default([]),structuredContent:a({}).loose().optional(),isError:_6().optional(),_meta:x$(g(),E$()).optional()}),AA=j_("type",[BW,XW,HW]),sJ=j_("type",[BW,XW,HW,OA,MA]),IA=a({role:p_,content:D$([sJ,Q$(sJ)]),_meta:x$(g(),E$()).optional()}),wA=u_.extend({messages:Q$(IA),modelPreferences:kA.optional(),systemPrompt:g().optional(),includeContext:H6(["none","thisServer","allServers"]).optional(),temperature:w$().optional(),maxTokens:w$().int(),stopSequences:Q$(g()).optional(),metadata:Q6.optional(),tools:Q$(Y9).optional(),toolChoice:bA.optional()}),gA=L6.extend({method:U$("sampling/createMessage"),params:wA}),NA=F6.extend({model:g(),stopReason:l$(H6(["endTurn","stopSequence","maxTokens"]).or(g())),role:p_,content:AA}),SA=F6.extend({model:g(),stopReason:l$(H6(["endTurn","stopSequence","maxTokens","toolUse"]).or(g())),role:p_,content:D$([sJ,Q$(sJ)])}),RA=a({type:U$("boolean"),title:g().optional(),description:g().optional(),default:_6().optional()}),TA=a({type:U$("string"),title:g().optional(),description:g().optional(),minLength:w$().optional(),maxLength:w$().optional(),format:H6(["email","uri","date","date-time"]).optional(),default:g().optional()}),yA=a({type:H6(["number","integer"]),title:g().optional(),description:g().optional(),minimum:w$().optional(),maximum:w$().optional(),default:w$().optional()}),CA=a({type:U$("string"),title:g().optional(),description:g().optional(),enum:Q$(g()),default:g().optional()}),DA=a({type:U$("string"),title:g().optional(),description:g().optional(),oneOf:Q$(a({const:g(),title:g()})),default:g().optional()}),jA=a({type:U$("string"),title:g().optional(),description:g().optional(),enum:Q$(g()),enumNames:Q$(g()).optional(),default:g().optional()}),VA=D$([CA,DA]),fA=a({type:U$("array"),title:g().optional(),description:g().optional(),minItems:w$().optional(),maxItems:w$().optional(),items:a({type:U$("string"),enum:Q$(g())}),default:Q$(g()).optional()}),EA=a({type:U$("array"),title:g().optional(),description:g().optional(),minItems:w$().optional(),maxItems:w$().optional(),items:a({anyOf:Q$(a({const:g(),title:g()}))}),default:Q$(g()).optional()}),uA=D$([fA,EA]),mA=D$([jA,VA,uA]),xA=D$([mA,RA,TA,yA]),hA=u_.extend({mode:U$("form").optional(),message:g(),requestedSchema:a({type:U$("object"),properties:x$(g(),xA),required:Q$(g()).optional()})}),cA=u_.extend({mode:U$("url"),message:g(),elicitationId:g(),url:g().url()}),lA=D$([hA,cA]),rA=L6.extend({method:U$("elicitation/create"),params:lA}),iA=e6.extend({elicitationId:g()}),pA=$4.extend({method:U$("notifications/elicitation/complete"),params:iA}),oA=F6.extend({action:H6(["accept","decline","cancel"]),content:E_(($)=>$===null?void 0:$,x$(g(),D$([g(),w$(),_6(),Q$(g())])).optional())}),dA=a({type:U$("ref/resource"),uri:g()});var nA=a({type:U$("ref/prompt"),name:g()}),tA=r6.extend({ref:D$([nA,dA]),argument:a({name:g(),value:g()}),context:a({arguments:x$(g(),g()).optional()}).optional()}),aA=L6.extend({method:U$("completion/complete"),params:tA});var sA=F6.extend({completion:X6({values:Q$(g()).max(100),total:l$(w$().int()),hasMore:l$(_6())})}),eA=a({uri:g().startsWith("file://"),name:g().optional(),_meta:x$(g(),E$()).optional()}),$I=L6.extend({method:U$("roots/list"),params:r6.optional()}),UI=F6.extend({roots:Q$(eA)}),_I=$4.extend({method:U$("notifications/roots/list_changed"),params:e6.optional()}),kD=D$([X1,cM,aA,LA,WA,ZW,zW,KW,OW,$A,_A,t_,n_,J9,K9,G9,O9]),bD=D$([U9,_9,iM,_I,i_]),MD=D$([$9,NA,SA,oA,UI,z9,W9,v9]),AD=D$([X1,gA,rA,$I,J9,K9,G9,O9]),ID=D$([U9,_9,kW,JA,YW,PW,FW,i_,pA]),wD=D$([$9,rM,sA,ZA,qW,o_,GW,d_,H1,XA,z9,W9,v9]);class P$ extends Error{constructor($,U,v){super(`MCP error ${$}: ${U}`);this.code=$,this.data=v,this.name="McpError"}static fromError($,U,v){if($===T$.UrlElicitationRequired&&v){let J=v;if(J.elicitations)return new bX(J.elicitations,U)}return new P$($,U,v)}}class bX extends P${constructor($,U=`URL elicitation${$.length>1?"s":""} required`){super(T$.UrlElicitationRequired,U,{elicitations:$})}get elicitations(){return this.data?.elicitations??[]}}function Z9($){return!!$._zod}function q9($,U){if(Z9($))return hU($,U);return $.safeParse(U)}function MX($){if(!$)return;let U;if(Z9($))U=$._zod?.def?.shape;else U=$.shape;if(!U)return;if(typeof U==="function")try{return U()}catch{return}return U}function AX($){if(Z9($)){let z=$._zod?.def;if(z){if(z.value!==void 0)return z.value;if(Array.isArray(z.values)&&z.values.length>0)return z.values[0]}}let v=$._def;if(v){if(v.value!==void 0)return v.value;if(Array.isArray(v.values)&&v.values.length>0)return v.values[0]}let J=$.value;if(J!==void 0)return J;return}function Q1($){return $==="completed"||$==="failed"||$==="cancelled"}var vI=Symbol("Let zodToJsonSchema decide on which parser to use");var Oj=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function bW($){let v=MX($)?.method;if(!v)throw Error("Schema is missing a method literal");let J=AX(v);if(typeof J!=="string")throw Error("Schema method literal must be a string");return J}function MW($,U){let v=q9($,U);if(!v.success)throw v.error;return v.data}var OI=60000;class s_{constructor($){if(this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(U9,(U)=>{this._oncancel(U)}),this.setNotificationHandler(_9,(U)=>{this._onprogress(U)}),this.setRequestHandler(X1,(U)=>({})),this._taskStore=$?.taskStore,this._taskMessageQueue=$?.taskMessageQueue,this._taskStore)this.setRequestHandler(J9,async(U,v)=>{let J=await this._taskStore.getTask(U.params.taskId,v.sessionId);if(!J)throw new P$(T$.InvalidParams,"Failed to retrieve task: Task not found");return{...J}}),this.setRequestHandler(K9,async(U,v)=>{let J=async()=>{let _=U.params.taskId;if(this._taskMessageQueue){let K;while(K=await this._taskMessageQueue.dequeue(_,v.sessionId)){if(K.type==="response"||K.type==="error"){let W=K.message,O=W.id,Y=this._requestResolvers.get(O);if(Y)if(this._requestResolvers.delete(O),K.type==="response")Y(W);else{let Z=W,q=new P$(Z.error.code,Z.error.message,Z.error.data);Y(q)}else{let Z=K.type==="response"?"Response":"Error";this._onerror(Error(`${Z} handler missing for request ${O}`))}continue}await this._transport?.send(K.message,{relatedRequestId:v.requestId})}}let z=await this._taskStore.getTask(_,v.sessionId);if(!z)throw new P$(T$.InvalidParams,`Task not found: ${_}`);if(!Q1(z.status))return await this._waitForTaskUpdate(_,v.signal),await J();if(Q1(z.status)){let K=await this._taskStore.getTaskResult(_,v.sessionId);return this._clearTaskQueue(_),{...K,_meta:{...K._meta,[B1]:{taskId:_}}}}return await J()};return await J()}),this.setRequestHandler(G9,async(U,v)=>{try{let{tasks:J,nextCursor:_}=await this._taskStore.listTasks(U.params?.cursor,v.sessionId);return{tasks:J,nextCursor:_,_meta:{}}}catch(J){throw new P$(T$.InvalidParams,`Failed to list tasks: ${J instanceof Error?J.message:String(J)}`)}}),this.setRequestHandler(O9,async(U,v)=>{try{let J=await this._taskStore.getTask(U.params.taskId,v.sessionId);if(!J)throw new P$(T$.InvalidParams,`Task not found: ${U.params.taskId}`);if(Q1(J.status))throw new P$(T$.InvalidParams,`Cannot cancel task in terminal status: ${J.status}`);await this._taskStore.updateTaskStatus(U.params.taskId,"cancelled","Client cancelled task execution.",v.sessionId),this._clearTaskQueue(U.params.taskId);let _=await this._taskStore.getTask(U.params.taskId,v.sessionId);if(!_)throw new P$(T$.InvalidParams,`Task not found after cancellation: ${U.params.taskId}`);return{_meta:{},..._}}catch(J){if(J instanceof P$)throw J;throw new P$(T$.InvalidRequest,`Failed to cancel task: ${J instanceof Error?J.message:String(J)}`)}})}async _oncancel($){if(!$.params.requestId)return;this._requestHandlerAbortControllers.get($.params.requestId)?.abort($.params.reason)}_setupTimeout($,U,v,J,_=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(J,U),startTime:Date.now(),timeout:U,maxTotalTimeout:v,resetTimeoutOnProgress:_,onTimeout:J})}_resetTimeout($){let U=this._timeoutInfo.get($);if(!U)return!1;let v=Date.now()-U.startTime;if(U.maxTotalTimeout&&v>=U.maxTotalTimeout)throw this._timeoutInfo.delete($),P$.fromError(T$.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:U.maxTotalTimeout,totalElapsed:v});return clearTimeout(U.timeoutId),U.timeoutId=setTimeout(U.onTimeout,U.timeout),!0}_cleanupTimeout($){let U=this._timeoutInfo.get($);if(U)clearTimeout(U.timeoutId),this._timeoutInfo.delete($)}async connect($){if(this._transport)throw Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=$;let U=this.transport?.onclose;this._transport.onclose=()=>{U?.(),this._onclose()};let v=this.transport?.onerror;this._transport.onerror=(_)=>{v?.(_),this._onerror(_)};let J=this._transport?.onmessage;this._transport.onmessage=(_,z)=>{if(J?.(_,z),m_(_)||BX(_))this._onresponse(_);else if(UW(_))this._onrequest(_,z);else if(qX(_))this._onnotification(_);else this._onerror(Error(`Unknown message type: ${JSON.stringify(_)}`))},await this._transport.start()}_onclose(){let $=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let v of this._timeoutInfo.values())clearTimeout(v.timeoutId);this._timeoutInfo.clear();for(let v of this._requestHandlerAbortControllers.values())v.abort();this._requestHandlerAbortControllers.clear();let U=P$.fromError(T$.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let v of $.values())v(U)}_onerror($){this.onerror?.($)}_onnotification($){let U=this._notificationHandlers.get($.method)??this.fallbackNotificationHandler;if(U===void 0)return;Promise.resolve().then(()=>U($)).catch((v)=>this._onerror(Error(`Uncaught error in notification handler: ${v}`)))}_onrequest($,U){let v=this._requestHandlers.get($.method)??this.fallbackRequestHandler,J=this._transport,_=$.params?._meta?.[B1]?.taskId;if(v===void 0){let Y={jsonrpc:"2.0",id:$.id,error:{code:T$.MethodNotFound,message:"Method not found"}};if(_&&this._taskMessageQueue)this._enqueueTaskMessage(_,{type:"error",message:Y,timestamp:Date.now()},J?.sessionId).catch((Z)=>this._onerror(Error(`Failed to enqueue error response: ${Z}`)));else J?.send(Y).catch((Z)=>this._onerror(Error(`Failed to send an error response: ${Z}`)));return}let z=new AbortController;this._requestHandlerAbortControllers.set($.id,z);let K=OX($.params)?$.params.task:void 0,W=this._taskStore?this.requestTaskStore($,J?.sessionId):void 0,O={signal:z.signal,sessionId:J?.sessionId,_meta:$.params?._meta,sendNotification:async(Y)=>{if(z.signal.aborted)return;let Z={relatedRequestId:$.id};if(_)Z.relatedTask={taskId:_};await this.notification(Y,Z)},sendRequest:async(Y,Z,q)=>{if(z.signal.aborted)throw new P$(T$.ConnectionClosed,"Request was cancelled");let X={...q,relatedRequestId:$.id};if(_&&!X.relatedTask)X.relatedTask={taskId:_};let B=X.relatedTask?.taskId??_;if(B&&W)await W.updateTaskStatus(B,"input_required");return await this.request(Y,Z,X)},authInfo:U?.authInfo,requestId:$.id,requestInfo:U?.requestInfo,taskId:_,taskStore:W,taskRequestedTtl:K?.ttl,closeSSEStream:U?.closeSSEStream,closeStandaloneSSEStream:U?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(K)this.assertTaskHandlerCapability($.method)}).then(()=>v($,O)).then(async(Y)=>{if(z.signal.aborted)return;let Z={result:Y,jsonrpc:"2.0",id:$.id};if(_&&this._taskMessageQueue)await this._enqueueTaskMessage(_,{type:"response",message:Z,timestamp:Date.now()},J?.sessionId);else await J?.send(Z)},async(Y)=>{if(z.signal.aborted)return;let Z={jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(Y.code)?Y.code:T$.InternalError,message:Y.message??"Internal error",...Y.data!==void 0&&{data:Y.data}}};if(_&&this._taskMessageQueue)await this._enqueueTaskMessage(_,{type:"error",message:Z,timestamp:Date.now()},J?.sessionId);else await J?.send(Z)}).catch((Y)=>this._onerror(Error(`Failed to send response: ${Y}`))).finally(()=>{if(this._requestHandlerAbortControllers.get($.id)===z)this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:U,...v}=$.params,J=Number(U),_=this._progressHandlers.get(J);if(!_){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let z=this._responseHandlers.get(J),K=this._timeoutInfo.get(J);if(K&&z&&K.resetTimeoutOnProgress)try{this._resetTimeout(J)}catch(W){this._responseHandlers.delete(J),this._progressHandlers.delete(J),this._cleanupTimeout(J),z(W);return}_(v)}_onresponse($){let U=Number($.id),v=this._requestResolvers.get(U);if(v){if(this._requestResolvers.delete(U),m_($))v($);else{let z=new P$($.error.code,$.error.message,$.error.data);v(z)}return}let J=this._responseHandlers.get(U);if(J===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}this._responseHandlers.delete(U),this._cleanupTimeout(U);let _=!1;if(m_($)&&$.result&&typeof $.result==="object"){let z=$.result;if(z.task&&typeof z.task==="object"){let K=z.task;if(typeof K.taskId==="string")_=!0,this._taskProgressTokens.set(K.taskId,U)}}if(!_)this._progressHandlers.delete(U);if(m_($))J($);else{let z=P$.fromError($.error.code,$.error.message,$.error.data);J(z)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream($,U,v){let{task:J}=v??{};if(!J){try{yield{type:"result",result:await this.request($,U,v)}}catch(z){yield{type:"error",error:z instanceof P$?z:new P$(T$.InternalError,String(z))}}return}let _;try{let z=await this.request($,v9,v);if(z.task)_=z.task.taskId,yield{type:"taskCreated",task:z.task};else throw new P$(T$.InternalError,"Task creation did not return a task");while(!0){let K=await this.getTask({taskId:_},v);if(yield{type:"taskStatus",task:K},Q1(K.status)){if(K.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:_},U,v)};else if(K.status==="failed")yield{type:"error",error:new P$(T$.InternalError,`Task ${_} failed`)};else if(K.status==="cancelled")yield{type:"error",error:new P$(T$.InternalError,`Task ${_} was cancelled`)};return}if(K.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:_},U,v)};return}let W=K.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((O)=>setTimeout(O,W)),v?.signal?.throwIfAborted()}}catch(z){yield{type:"error",error:z instanceof P$?z:new P$(T$.InternalError,String(z))}}}request($,U,v){let{relatedRequestId:J,resumptionToken:_,onresumptiontoken:z,task:K,relatedTask:W}=v??{};return new Promise((O,Y)=>{let Z=(H)=>{Y(H)};if(!this._transport){Z(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod($.method),K)this.assertTaskCapability($.method)}catch(H){Z(H);return}v?.signal?.throwIfAborted();let q=this._requestMessageId++,X={...$,jsonrpc:"2.0",id:q};if(v?.onprogress)this._progressHandlers.set(q,v.onprogress),X.params={...$.params,_meta:{...$.params?._meta||{},progressToken:q}};if(K)X.params={...X.params,task:K};if(W)X.params={...X.params,_meta:{...X.params?._meta||{},[B1]:W}};let B=(H)=>{this._responseHandlers.delete(q),this._progressHandlers.delete(q),this._cleanupTimeout(q),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:q,reason:String(H)}},{relatedRequestId:J,resumptionToken:_,onresumptiontoken:z}).catch((b)=>this._onerror(Error(`Failed to send cancellation: ${b}`)));let P=H instanceof P$?H:new P$(T$.RequestTimeout,String(H));Y(P)};this._responseHandlers.set(q,(H)=>{if(v?.signal?.aborted)return;if(H instanceof Error)return Y(H);try{let P=q9(U,H.result);if(!P.success)Y(P.error);else O(P.data)}catch(P){Y(P)}}),v?.signal?.addEventListener("abort",()=>{B(v?.signal?.reason)});let L=v?.timeout??OI,F=()=>B(P$.fromError(T$.RequestTimeout,"Request timed out",{timeout:L}));this._setupTimeout(q,L,v?.maxTotalTimeout,F,v?.resetTimeoutOnProgress??!1);let k=W?.taskId;if(k){let H=(P)=>{let b=this._responseHandlers.get(q);if(b)b(P);else this._onerror(Error(`Response handler missing for side-channeled request ${q}`))};this._requestResolvers.set(q,H),this._enqueueTaskMessage(k,{type:"request",message:X,timestamp:Date.now()}).catch((P)=>{this._cleanupTimeout(q),Y(P)})}else this._transport.send(X,{relatedRequestId:J,resumptionToken:_,onresumptiontoken:z}).catch((H)=>{this._cleanupTimeout(q),Y(H)})})}async getTask($,U){return this.request({method:"tasks/get",params:$},z9,U)}async getTaskResult($,U,v){return this.request({method:"tasks/result",params:$},U,v)}async listTasks($,U){return this.request({method:"tasks/list",params:$},W9,U)}async cancelTask($,U){return this.request({method:"tasks/cancel",params:$},HX,U)}async notification($,U){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let v=U?.relatedTask?.taskId;if(v){let K={...$,jsonrpc:"2.0",params:{...$.params,_meta:{...$.params?._meta||{},[B1]:U.relatedTask}}};await this._enqueueTaskMessage(v,{type:"notification",message:K,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes($.method)&&!$.params&&!U?.relatedRequestId&&!U?.relatedTask){if(this._pendingDebouncedNotifications.has($.method))return;this._pendingDebouncedNotifications.add($.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete($.method),!this._transport)return;let K={...$,jsonrpc:"2.0"};if(U?.relatedTask)K={...K,params:{...K.params,_meta:{...K.params?._meta||{},[B1]:U.relatedTask}}};this._transport?.send(K,U).catch((W)=>this._onerror(W))});return}let z={...$,jsonrpc:"2.0"};if(U?.relatedTask)z={...z,params:{...z.params,_meta:{...z.params?._meta||{},[B1]:U.relatedTask}}};await this._transport.send(z,U)}setRequestHandler($,U){let v=bW($);this.assertRequestHandlerCapability(v),this._requestHandlers.set(v,(J,_)=>{let z=MW($,J);return Promise.resolve(U(z,_))})}removeRequestHandler($){this._requestHandlers.delete($)}assertCanSetRequestHandler($){if(this._requestHandlers.has($))throw Error(`A request handler for ${$} already exists, which would be overridden`)}setNotificationHandler($,U){let v=bW($);this._notificationHandlers.set(v,(J)=>{let _=MW($,J);return Promise.resolve(U(_))})}removeNotificationHandler($){this._notificationHandlers.delete($)}_cleanupTaskProgressHandler($){let U=this._taskProgressTokens.get($);if(U!==void 0)this._progressHandlers.delete(U),this._taskProgressTokens.delete($)}async _enqueueTaskMessage($,U,v){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let J=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue($,U,v,J)}async _clearTaskQueue($,U){if(this._taskMessageQueue){let v=await this._taskMessageQueue.dequeueAll($,U);for(let J of v)if(J.type==="request"&&UW(J.message)){let _=J.message.id,z=this._requestResolvers.get(_);if(z)z(new P$(T$.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(_);else this._onerror(Error(`Resolver missing for request ${_} during task ${$} cleanup`))}}}async _waitForTaskUpdate($,U){let v=this._options?.defaultTaskPollInterval??1000;try{let J=await this._taskStore?.getTask($);if(J?.pollInterval)v=J.pollInterval}catch{}return new Promise((J,_)=>{if(U.aborted){_(new P$(T$.InvalidRequest,"Request cancelled"));return}let z=setTimeout(J,v);U.addEventListener("abort",()=>{clearTimeout(z),_(new P$(T$.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore($,U){let v=this._taskStore;if(!v)throw Error("No task store configured");return{createTask:async(J)=>{if(!$)throw Error("No request provided");return await v.createTask(J,$.id,{method:$.method,params:$.params},U)},getTask:async(J)=>{let _=await v.getTask(J,U);if(!_)throw new P$(T$.InvalidParams,"Failed to retrieve task: Task not found");return _},storeTaskResult:async(J,_,z)=>{await v.storeTaskResult(J,_,z,U);let K=await v.getTask(J,U);if(K){let W=i_.parse({method:"notifications/tasks/status",params:K});if(await this.notification(W),Q1(K.status))this._cleanupTaskProgressHandler(J)}},getTaskResult:(J)=>{return v.getTaskResult(J,U)},updateTaskStatus:async(J,_,z)=>{let K=await v.getTask(J,U);if(!K)throw new P$(T$.InvalidParams,`Task "${J}" not found - it may have been cleaned up`);if(Q1(K.status))throw new P$(T$.InvalidParams,`Cannot update task "${J}" from terminal status "${K.status}" to "${_}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await v.updateTaskStatus(J,_,z,U);let W=await v.getTask(J,U);if(W){let O=i_.parse({method:"notifications/tasks/status",params:W});if(await this.notification(O),Q1(W.status))this._cleanupTaskProgressHandler(J)}},listTasks:(J)=>{return v.listTasks(J,U)}}}}var AW="2026-01-26";var YI="ui/notifications/tool-input-partial";var ZI=Q.union([Q.literal("light"),Q.literal("dark")]).describe("Color theme preference for the host environment."),e_=Q.union([Q.literal("inline"),Q.literal("fullscreen"),Q.literal("pip")]).describe("Display mode for UI presentation."),qI=Q.union([Q.literal("--color-background-primary"),Q.literal("--color-background-secondary"),Q.literal("--color-background-tertiary"),Q.literal("--color-background-inverse"),Q.literal("--color-background-ghost"),Q.literal("--color-background-info"),Q.literal("--color-background-danger"),Q.literal("--color-background-success"),Q.literal("--color-background-warning"),Q.literal("--color-background-disabled"),Q.literal("--color-text-primary"),Q.literal("--color-text-secondary"),Q.literal("--color-text-tertiary"),Q.literal("--color-text-inverse"),Q.literal("--color-text-ghost"),Q.literal("--color-text-info"),Q.literal("--color-text-danger"),Q.literal("--color-text-success"),Q.literal("--color-text-warning"),Q.literal("--color-text-disabled"),Q.literal("--color-border-primary"),Q.literal("--color-border-secondary"),Q.literal("--color-border-tertiary"),Q.literal("--color-border-inverse"),Q.literal("--color-border-ghost"),Q.literal("--color-border-info"),Q.literal("--color-border-danger"),Q.literal("--color-border-success"),Q.literal("--color-border-warning"),Q.literal("--color-border-disabled"),Q.literal("--color-ring-primary"),Q.literal("--color-ring-secondary"),Q.literal("--color-ring-inverse"),Q.literal("--color-ring-info"),Q.literal("--color-ring-danger"),Q.literal("--color-ring-success"),Q.literal("--color-ring-warning"),Q.literal("--font-sans"),Q.literal("--font-mono"),Q.literal("--font-weight-normal"),Q.literal("--font-weight-medium"),Q.literal("--font-weight-semibold"),Q.literal("--font-weight-bold"),Q.literal("--font-text-xs-size"),Q.literal("--font-text-sm-size"),Q.literal("--font-text-md-size"),Q.literal("--font-text-lg-size"),Q.literal("--font-heading-xs-size"),Q.literal("--font-heading-sm-size"),Q.literal("--font-heading-md-size"),Q.literal("--font-heading-lg-size"),Q.literal("--font-heading-xl-size"),Q.literal("--font-heading-2xl-size"),Q.literal("--font-heading-3xl-size"),Q.literal("--font-text-xs-line-height"),Q.literal("--font-text-sm-line-height"),Q.literal("--font-text-md-line-height"),Q.literal("--font-text-lg-line-height"),Q.literal("--font-heading-xs-line-height"),Q.literal("--font-heading-sm-line-height"),Q.literal("--font-heading-md-line-height"),Q.literal("--font-heading-lg-line-height"),Q.literal("--font-heading-xl-line-height"),Q.literal("--font-heading-2xl-line-height"),Q.literal("--font-heading-3xl-line-height"),Q.literal("--border-radius-xs"),Q.literal("--border-radius-sm"),Q.literal("--border-radius-md"),Q.literal("--border-radius-lg"),Q.literal("--border-radius-xl"),Q.literal("--border-radius-full"),Q.literal("--border-width-regular"),Q.literal("--shadow-hairline"),Q.literal("--shadow-sm"),Q.literal("--shadow-md"),Q.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),BI=Q.record(qI.describe(`Style variables for theming MCP apps.
|
|
150
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(t===a[0]){s(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){s(a);continue}}if(e.metadataRegistry.get(a[0])?.id){s(a);continue}if(c.cycle){s(a);continue}if(c.count>1){if(e.reused==="ref"){s(a);continue}}}}function iu(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){o(d);let m=e.seen.get(d),f=m.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(f);else Object.assign(l,f);if(Object.assign(l,u),a._zod.parent===d)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(!(v in u))delete l[v]}if(f.$ref&&m.def)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(v in m.def&&JSON.stringify(l[v])===JSON.stringify(m.def[v]))delete l[v]}}let p=a._zod.parent;if(p&&p!==d){o(p);let m=e.seen.get(p);if(m?.schema.$ref){if(l.$ref=m.schema.$ref,m.def)for(let f in l){if(f==="$ref"||f==="allOf")continue;if(f in m.def&&JSON.stringify(l[f])===JSON.stringify(m.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())o(a[0]);let r={};if(e.target==="draft-2020-12")r.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")r.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")r.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId)s[c.defId]=c.def}if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")r.$defs=s;else r.definitions=s;try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:si(t,"input",e.processors),output:si(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function yt(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return yt(o.element,n);if(o.type==="set")return yt(o.valueType,n);if(o.type==="lazy")return yt(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return yt(o.innerType,n);if(o.type==="intersection")return yt(o.left,n)||yt(o.right,n);if(o.type==="record"||o.type==="map")return yt(o.keyType,n)||yt(o.valueType,n);if(o.type==="pipe")return yt(o.in,n)||yt(o.out,n);if(o.type==="object"){for(let r in o.shape)if(yt(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(let r of o.options)if(yt(r,n))return!0;return!1}if(o.type==="tuple"){for(let r of o.items)if(yt(r,n))return!0;if(o.rest&&yt(o.rest,n))return!0;return!1}return!1}var Sv=(e,t={})=>(n)=>{let o=ou({...n,processors:t});return Xe(e,o),ru(o,e),iu(o,e)},si=(e,t,n={})=>(o)=>{let{libraryOptions:r,target:s}=o??{},a=ou({...r??{},target:s,io:t,processors:n});return Xe(e,a),ru(a,e),iu(a,e)};var Pk={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},kv=(e,t,n,o)=>{let r=n;r.type="string";let{minimum:s,maximum:a,format:c,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof s==="number")r.minLength=s;if(typeof a==="number")r.maxLength=a;if(c){if(r.format=Pk[c]??c,r.format==="")delete r.format;if(c==="time")delete r.format}if(u)r.contentEncoding=u;if(l&&l.size>0){let d=[...l];if(d.length===1)r.pattern=d[0].source;else if(d.length>1)r.allOf=[...d.map((p)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))]}},Cv=(e,t,n,o)=>{let r=n,{minimum:s,maximum:a,format:c,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))r.type="integer";else r.type="number";if(typeof d==="number")if(t.target==="draft-04"||t.target==="openapi-3.0")r.minimum=d,r.exclusiveMinimum=!0;else r.exclusiveMinimum=d;if(typeof s==="number"){if(r.minimum=s,typeof d==="number"&&t.target!=="draft-04")if(d>=s)delete r.minimum;else delete r.exclusiveMinimum}if(typeof u==="number")if(t.target==="draft-04"||t.target==="openapi-3.0")r.maximum=u,r.exclusiveMaximum=!0;else r.exclusiveMaximum=u;if(typeof a==="number"){if(r.maximum=a,typeof u==="number"&&t.target!=="draft-04")if(u<=a)delete r.maximum;else delete r.exclusiveMaximum}if(typeof l==="number")r.multipleOf=l},Tv=(e,t,n,o)=>{n.type="boolean"};var Ev=(e,t,n,o)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},Av=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")};var Iv=(e,t,n,o)=>{n.not={}};var zv=(e,t,n,o)=>{};var Pv=(e,t,n,o)=>{let r=e._zod.def,s=Hs(r.entries);if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";n.enum=s},Nv=(e,t,n,o)=>{let r=e._zod.def,s=[];for(let a of r.values)if(a===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else s.push(Number(a));else s.push(a);if(s.length===0);else if(s.length===1){let a=s[0];if(n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[a];else n.const=a}else{if(s.every((a)=>typeof a==="number"))n.type="number";if(s.every((a)=>typeof a==="string"))n.type="string";if(s.every((a)=>typeof a==="boolean"))n.type="boolean";if(s.every((a)=>a===null))n.type="null";n.enum=s}};var Rv=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var $v=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var Mv=(e,t,n,o)=>{let r=n,s=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;if(typeof a==="number")r.minItems=a;if(typeof c==="number")r.maxItems=c;r.type="array",r.items=Xe(s.element,t,{...o,path:[...o.path,"items"]})},Ov=(e,t,n,o)=>{let r=n,s=e._zod.def;r.type="object",r.properties={};let a=s.shape;for(let u in a)r.properties[u]=Xe(a[u],t,{...o,path:[...o.path,"properties",u]});let c=new Set(Object.keys(a)),l=new Set([...c].filter((u)=>{let d=s.shape[u]._zod;if(t.io==="input")return d.optin===void 0;else return d.optout===void 0}));if(l.size>0)r.required=Array.from(l);if(s.catchall?._zod.def.type==="never")r.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")r.additionalProperties=!1}else if(s.catchall)r.additionalProperties=Xe(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Lv=(e,t,n,o)=>{let r=e._zod.def,s=r.inclusive===!1,a=r.options.map((c,l)=>Xe(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",l]}));if(s)n.oneOf=a;else n.anyOf=a},Dv=(e,t,n,o)=>{let r=e._zod.def,s=Xe(r.left,t,{...o,path:[...o.path,"allOf",0]}),a=Xe(r.right,t,{...o,path:[...o.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,l=[...c(s)?s.allOf:[s],...c(a)?a.allOf:[a]];n.allOf=l};var Fv=(e,t,n,o)=>{let r=n,s=e._zod.def;r.type="object";let a=s.keyType,l=a._zod.bag?.patterns;if(s.mode==="loose"&&l&&l.size>0){let d=Xe(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(let p of l)r.patternProperties[p.source]=d}else{if(t.target==="draft-07"||t.target==="draft-2020-12")r.propertyNames=Xe(s.keyType,t,{...o,path:[...o.path,"propertyNames"]});r.additionalProperties=Xe(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values;if(u){let d=[...u].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)r.required=d}},jv=(e,t,n,o)=>{let r=e._zod.def,s=Xe(r.innerType,t,o),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=r.innerType,n.nullable=!0;else n.anyOf=[s,{type:"null"}]},Zv=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);s.ref=r.innerType},Hv=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Bv=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);if(s.ref=r.innerType,t.io==="input")n._prefault=JSON.parse(JSON.stringify(r.defaultValue))},Uv=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);s.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},Wv=(e,t,n,o)=>{let r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;Xe(s,t,o);let a=t.seen.get(e);a.ref=s},qv=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0};var su=(e,t,n,o)=>{let r=e._zod.def;Xe(r.innerType,t,o);let s=t.seen.get(e);s.ref=r.innerType};var Fk=A("ZodISODateTime",(e,t)=>{eg.init(e,t),He.init(e,t)});function au(e){return cv(Fk,e)}var jk=A("ZodISODate",(e,t)=>{tg.init(e,t),He.init(e,t)});function Vv(e){return lv(jk,e)}var Zk=A("ZodISOTime",(e,t)=>{ng.init(e,t),He.init(e,t)});function Gv(e){return uv(Zk,e)}var Hk=A("ZodISODuration",(e,t)=>{og.init(e,t),He.init(e,t)});function Xv(e){return dv(Hk,e)}var Kv=(e,t)=>{qs.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(n)=>Lm(e,n)},flatten:{value:(n)=>Om(e,n)},addIssue:{value:(n)=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Yr,2)}},addIssues:{value:(n)=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Yr,2)}},isEmpty:{get(){return e.issues.length===0}}})},mN=A("ZodError",Kv),At=A("ZodError",Kv,{Parent:Error});var Jv=Vs(At),Yv=Gs(At),Qv=ei(At),ey=ni(At),ty=Dm(At),ny=Fm(At),oy=jm(At),ry=Zm(At),iy=Hm(At),sy=Bm(At),ay=Um(At),cy=Wm(At);var Fe=A("ZodType",(e,t)=>($e.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:si(e,"input"),output:si(e,"output")}}),e.toJSONSchema=Sv(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(On(t,{checks:[...t.checks??[],...n.map((o)=>typeof o==="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>tn(e,n,o),e.brand=()=>e,e.register=(n,o)=>(n.add(e,o),e),e.parse=(n,o)=>Jv(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Qv(e,n,o),e.parseAsync=async(n,o)=>Yv(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>ey(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>ty(e,n,o),e.decode=(n,o)=>ny(e,n,o),e.encodeAsync=async(n,o)=>oy(e,n,o),e.decodeAsync=async(n,o)=>ry(e,n,o),e.safeEncode=(n,o)=>iy(e,n,o),e.safeDecode=(n,o)=>sy(e,n,o),e.safeEncodeAsync=async(n,o)=>ay(e,n,o),e.safeDecodeAsync=async(n,o)=>cy(e,n,o),e.refine=(n,o)=>e.check(M0(n,o)),e.superRefine=(n)=>e.check(O0(n)),e.overwrite=(n)=>e.check(Fn(n)),e.optional=()=>Ue(e),e.exactOptional=()=>S0(e),e.nullable=()=>dy(e),e.nullish=()=>Ue(dy(e)),e.nonoptional=(n)=>I0(e,n),e.array=()=>ie(e),e.or=(n)=>ue([e,n]),e.and=(n)=>sa(e,n),e.transform=(n)=>uu(e,gy(n)),e.default=(n)=>T0(e,n),e.prefault=(n)=>A0(e,n),e.catch=(n)=>P0(e,n),e.pipe=(n)=>uu(e,n),e.readonly=()=>$0(e),e.describe=(n)=>{let o=e.clone();return yo.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){return yo.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return yo.get(e);let o=e.clone();return yo.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=(n)=>n(e),e)),py=A("_ZodString",(e,t)=>{Qs.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(o,r,s)=>kv(e,o,r,s);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(ql(...o)),e.includes=(...o)=>e.check(Xl(...o)),e.startsWith=(...o)=>e.check(Kl(...o)),e.endsWith=(...o)=>e.check(Jl(...o)),e.min=(...o)=>e.check(lr(...o)),e.max=(...o)=>e.check(oa(...o)),e.length=(...o)=>e.check(ra(...o)),e.nonempty=(...o)=>e.check(lr(1,...o)),e.lowercase=(o)=>e.check(Vl(o)),e.uppercase=(o)=>e.check(Gl(o)),e.trim=()=>e.check(Ql()),e.normalize=(...o)=>e.check(Yl(...o)),e.toLowerCase=()=>e.check(eu()),e.toUpperCase=()=>e.check(tu()),e.slugify=()=>e.check(nu())}),Wk=A("ZodString",(e,t)=>{Qs.init(e,t),py.init(e,t),e.email=(n)=>e.check(Zg(qk,n)),e.url=(n)=>e.check(qg(Vk,n)),e.jwt=(n)=>e.check(av(c0,n)),e.emoji=(n)=>e.check(Vg(Gk,n)),e.guid=(n)=>e.check(Wl(ly,n)),e.uuid=(n)=>e.check(Hg(ia,n)),e.uuidv4=(n)=>e.check(Bg(ia,n)),e.uuidv6=(n)=>e.check(Ug(ia,n)),e.uuidv7=(n)=>e.check(Wg(ia,n)),e.nanoid=(n)=>e.check(Gg(Xk,n)),e.guid=(n)=>e.check(Wl(ly,n)),e.cuid=(n)=>e.check(Xg(Kk,n)),e.cuid2=(n)=>e.check(Kg(Jk,n)),e.ulid=(n)=>e.check(Jg(Yk,n)),e.base64=(n)=>e.check(rv(i0,n)),e.base64url=(n)=>e.check(iv(s0,n)),e.xid=(n)=>e.check(Yg(Qk,n)),e.ksuid=(n)=>e.check(Qg(e0,n)),e.ipv4=(n)=>e.check(ev(t0,n)),e.ipv6=(n)=>e.check(tv(n0,n)),e.cidrv4=(n)=>e.check(nv(o0,n)),e.cidrv6=(n)=>e.check(ov(r0,n)),e.e164=(n)=>e.check(sv(a0,n)),e.datetime=(n)=>e.check(au(n)),e.date=(n)=>e.check(Vv(n)),e.time=(n)=>e.check(Gv(n)),e.duration=(n)=>e.check(Xv(n))});function S(e){return jg(Wk,e)}var He=A("ZodStringFormat",(e,t)=>{De.init(e,t),py.init(e,t)}),qk=A("ZodEmail",(e,t)=>{Wh.init(e,t),He.init(e,t)});var ly=A("ZodGUID",(e,t)=>{Bh.init(e,t),He.init(e,t)});var ia=A("ZodUUID",(e,t)=>{Uh.init(e,t),He.init(e,t)});var Vk=A("ZodURL",(e,t)=>{qh.init(e,t),He.init(e,t)});var Gk=A("ZodEmoji",(e,t)=>{Vh.init(e,t),He.init(e,t)});var Xk=A("ZodNanoID",(e,t)=>{Gh.init(e,t),He.init(e,t)});var Kk=A("ZodCUID",(e,t)=>{Xh.init(e,t),He.init(e,t)});var Jk=A("ZodCUID2",(e,t)=>{Kh.init(e,t),He.init(e,t)});var Yk=A("ZodULID",(e,t)=>{Jh.init(e,t),He.init(e,t)});var Qk=A("ZodXID",(e,t)=>{Yh.init(e,t),He.init(e,t)});var e0=A("ZodKSUID",(e,t)=>{Qh.init(e,t),He.init(e,t)});var t0=A("ZodIPv4",(e,t)=>{rg.init(e,t),He.init(e,t)});var n0=A("ZodIPv6",(e,t)=>{ig.init(e,t),He.init(e,t)});var o0=A("ZodCIDRv4",(e,t)=>{sg.init(e,t),He.init(e,t)});var r0=A("ZodCIDRv6",(e,t)=>{ag.init(e,t),He.init(e,t)});var i0=A("ZodBase64",(e,t)=>{lg.init(e,t),He.init(e,t)});var s0=A("ZodBase64URL",(e,t)=>{ug.init(e,t),He.init(e,t)});var a0=A("ZodE164",(e,t)=>{dg.init(e,t),He.init(e,t)});var c0=A("ZodJWT",(e,t)=>{pg.init(e,t),He.init(e,t)});var fy=A("ZodNumber",(e,t)=>{Zl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Cv(e,o,r,s),e.gt=(o,r)=>e.check(ta(o,r)),e.gte=(o,r)=>e.check(ii(o,r)),e.min=(o,r)=>e.check(ii(o,r)),e.lt=(o,r)=>e.check(ea(o,r)),e.lte=(o,r)=>e.check(ri(o,r)),e.max=(o,r)=>e.check(ri(o,r)),e.int=(o)=>e.check(uy(o)),e.safe=(o)=>e.check(uy(o)),e.positive=(o)=>e.check(ta(0,o)),e.nonnegative=(o)=>e.check(ii(0,o)),e.negative=(o)=>e.check(ea(0,o)),e.nonpositive=(o)=>e.check(ri(0,o)),e.multipleOf=(o,r)=>e.check(na(o,r)),e.step=(o,r)=>e.check(na(o,r)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??0.5),e.isFinite=!0,e.format=n.format??null});function ae(e){return pv(fy,e)}var l0=A("ZodNumberFormat",(e,t)=>{fg.init(e,t),fy.init(e,t)});function uy(e){return fv(l0,e)}var u0=A("ZodBoolean",(e,t)=>{mg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Tv(e,n,o,r)});function ze(e){return mv(u0,e)}var d0=A("ZodUndefined",(e,t)=>{hg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Av(e,n,o,r)});function du(e){return hv(d0,e)}var p0=A("ZodNull",(e,t)=>{gg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ev(e,n,o,r)});function pu(e){return gv(p0,e)}var f0=A("ZodUnknown",(e,t)=>{vg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>zv(e,n,o,r)});function Ae(){return vv(f0)}var m0=A("ZodNever",(e,t)=>{yg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Iv(e,n,o,r)});function h0(e){return yv(m0,e)}var g0=A("ZodArray",(e,t)=>{xg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Mv(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(lr(n,o)),e.nonempty=(n)=>e.check(lr(1,n)),e.max=(n,o)=>e.check(oa(n,o)),e.length=(n,o)=>e.check(ra(n,o)),e.unwrap=()=>e.element});function ie(e,t){return xv(g0,e,t)}var my=A("ZodObject",(e,t)=>{_g.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ov(e,n,o,r),we(e,"shape",()=>t.shape),e.keyof=()=>_t(Object.keys(e._zod.def.shape)),e.catchall=(n)=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ae()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ae()}),e.strict=()=>e.clone({...e._zod.def,catchall:h0()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=(n)=>gk(e,n),e.safeExtend=(n)=>vk(e,n),e.merge=(n)=>yk(e,n),e.pick=(n)=>mk(e,n),e.omit=(n)=>hk(e,n),e.partial=(...n)=>xk(vy,e,n[0]),e.required=(...n)=>bk(yy,e,n[0])});function C(e,t){let n={type:"object",shape:e??{},...J(t)};return new my(n)}function xt(e,t){return new my({type:"object",shape:e,catchall:Ae(),...J(t)})}var hy=A("ZodUnion",(e,t)=>{Hl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Lv(e,n,o,r),e.options=t.options});function ue(e,t){return new hy({type:"union",options:e,...J(t)})}var v0=A("ZodDiscriminatedUnion",(e,t)=>{hy.init(e,t),Sg.init(e,t)});function fu(e,t,n){return new v0({type:"union",options:t,discriminator:e,...J(n)})}var y0=A("ZodIntersection",(e,t)=>{kg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Dv(e,n,o,r)});function sa(e,t){return new y0({type:"intersection",left:e,right:t})}var x0=A("ZodRecord",(e,t)=>{Cg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fv(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function Te(e,t,n){return new x0({type:"record",keyType:e,valueType:t,...J(n)})}var lu=A("ZodEnum",(e,t)=>{Tg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Pv(e,o,r,s),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{let s={};for(let a of o)if(n.has(a))s[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new lu({...t,checks:[],...J(r),entries:s})},e.exclude=(o,r)=>{let s={...t.entries};for(let a of o)if(n.has(a))delete s[a];else throw Error(`Key ${a} not found in enum`);return new lu({...t,checks:[],...J(r),entries:s})}});function _t(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new lu({type:"enum",entries:n,...J(t)})}var b0=A("ZodLiteral",(e,t)=>{Eg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Nv(e,n,o,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function w(e,t){return new b0({type:"literal",values:Array.isArray(e)?e:[e],...J(t)})}var w0=A("ZodTransform",(e,t)=>{Ag.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>$v(e,n,o,r),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Jr(e.constructor.name);n.addIssue=(s)=>{if(typeof s==="string")n.issues.push(vo(s,n.value,t));else{let a=s;if(a.fatal)a.continue=!1;a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(vo(a))}};let r=t.transform(n.value,n);if(r instanceof Promise)return r.then((s)=>(n.value=s,n));return n.value=r,n}});function gy(e){return new w0({type:"transform",transform:e})}var vy=A("ZodOptional",(e,t)=>{Bl.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>su(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Ue(e){return new vy({type:"optional",innerType:e})}var _0=A("ZodExactOptional",(e,t)=>{Ig.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>su(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function S0(e){return new _0({type:"optional",innerType:e})}var k0=A("ZodNullable",(e,t)=>{zg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function dy(e){return new k0({type:"nullable",innerType:e})}var C0=A("ZodDefault",(e,t)=>{Pg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function T0(e,t){return new C0({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Pl(t)}})}var E0=A("ZodPrefault",(e,t)=>{Ng.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Bv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function A0(e,t){return new E0({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Pl(t)}})}var yy=A("ZodNonOptional",(e,t)=>{Rg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function I0(e,t){return new yy({type:"nonoptional",innerType:e,...J(t)})}var z0=A("ZodCatch",(e,t)=>{$g.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Uv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function P0(e,t){return new z0({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var N0=A("ZodPipe",(e,t)=>{Mg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wv(e,n,o,r),e.in=t.in,e.out=t.out});function uu(e,t){return new N0({type:"pipe",in:e,out:t})}var R0=A("ZodReadonly",(e,t)=>{Og.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>qv(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function $0(e){return new R0({type:"readonly",innerType:e})}var xy=A("ZodCustom",(e,t)=>{Lg.init(e,t),Fe.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Rv(e,n,o,r)});function by(e,t){return bv(xy,e??(()=>!0),t)}function M0(e,t={}){return wv(xy,e,t)}function O0(e){return _v(e)}function mu(e,t){return uu(gy(e),t)}Lt(Ul());var jn="io.modelcontextprotocol/related-task",ca="2.0",st=by((e)=>e!==null&&(typeof e==="object"||typeof e==="function")),_y=ue([S(),ae().int()]),Sy=S(),IR=xt({ttl:ue([ae(),pu()]).optional(),pollInterval:ae().optional()}),L0=C({ttl:ae().optional()}),D0=C({taskId:S()}),hu=xt({progressToken:_y.optional(),[jn]:D0.optional()}),It=C({_meta:hu.optional()}),ci=It.extend({task:L0.optional()}),ky=(e)=>ci.safeParse(e).success,at=C({method:S(),params:It.loose().optional()}),Dt=C({_meta:hu.optional()}),Ft=C({method:S(),params:Dt.loose().optional()}),ct=xt({_meta:hu.optional()}),dr=ue([S(),ae().int()]),Cy=C({jsonrpc:w(ca),id:dr,...at.shape}).strict(),gu=(e)=>Cy.safeParse(e).success,Ty=C({jsonrpc:w(ca),...Ft.shape}).strict(),Ey=(e)=>Ty.safeParse(e).success,vu=C({jsonrpc:w(ca),id:dr,result:ct}).strict(),li=(e)=>vu.safeParse(e).success;var ke;(function(e){e[e.ConnectionClosed=-32000]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ke||(ke={}));var yu=C({jsonrpc:w(ca),id:dr.optional(),error:C({code:ae().int(),message:S(),data:Ae().optional()})}).strict();var Ay=(e)=>yu.safeParse(e).success;var Iy=ue([Cy,Ty,vu,yu]),zR=ue([vu,yu]),xu=ct.strict(),F0=Dt.extend({requestId:dr.optional(),reason:S().optional()}),la=Ft.extend({method:w("notifications/cancelled"),params:F0}),j0=C({src:S(),mimeType:S().optional(),sizes:ie(S()).optional(),theme:_t(["light","dark"]).optional()}),ui=C({icons:ie(j0).optional()}),ur=C({name:S(),title:S().optional()}),di=ur.extend({...ur.shape,...ui.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),Z0=sa(C({applyDefaults:ze().optional()}),Te(S(),Ae())),H0=mu((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.keys(e).length===0)return{form:{}}}return e},sa(C({form:Z0.optional(),url:st.optional()}),Te(S(),Ae()).optional())),B0=xt({list:st.optional(),cancel:st.optional(),requests:xt({sampling:xt({createMessage:st.optional()}).optional(),elicitation:xt({create:st.optional()}).optional()}).optional()}),U0=xt({list:st.optional(),cancel:st.optional(),requests:xt({tools:xt({call:st.optional()}).optional()}).optional()}),W0=C({experimental:Te(S(),st).optional(),sampling:C({context:st.optional(),tools:st.optional()}).optional(),elicitation:H0.optional(),roots:C({listChanged:ze().optional()}).optional(),tasks:B0.optional()}),q0=It.extend({protocolVersion:S(),capabilities:W0,clientInfo:di}),V0=at.extend({method:w("initialize"),params:q0});var G0=C({experimental:Te(S(),st).optional(),logging:st.optional(),completions:st.optional(),prompts:C({listChanged:ze().optional()}).optional(),resources:C({subscribe:ze().optional(),listChanged:ze().optional()}).optional(),tools:C({listChanged:ze().optional()}).optional(),tasks:U0.optional()}),X0=ct.extend({protocolVersion:S(),capabilities:G0,serverInfo:di,instructions:S().optional()}),K0=Ft.extend({method:w("notifications/initialized"),params:Dt.optional()});var xo=at.extend({method:w("ping"),params:It.optional()}),J0=C({progress:ae(),total:Ue(ae()),message:Ue(S())}),Y0=C({...Dt.shape,...J0.shape,progressToken:_y}),ua=Ft.extend({method:w("notifications/progress"),params:Y0}),Q0=It.extend({cursor:Sy.optional()}),pi=at.extend({params:Q0.optional()}),fi=ct.extend({nextCursor:Sy.optional()}),eC=_t(["working","input_required","completed","failed","cancelled"]),mi=C({taskId:S(),status:eC,ttl:ue([ae(),pu()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:Ue(ae()),statusMessage:Ue(S())}),da=ct.extend({task:mi}),tC=Dt.merge(mi),hi=Ft.extend({method:w("notifications/tasks/status"),params:tC}),pa=at.extend({method:w("tasks/get"),params:It.extend({taskId:S()})}),fa=ct.merge(mi),ma=at.extend({method:w("tasks/result"),params:It.extend({taskId:S()})}),PR=ct.loose(),ha=pi.extend({method:w("tasks/list")}),ga=fi.extend({tasks:ie(mi)}),va=at.extend({method:w("tasks/cancel"),params:It.extend({taskId:S()})}),zy=ct.merge(mi),Py=C({uri:S(),mimeType:Ue(S()),_meta:Te(S(),Ae()).optional()}),Ny=Py.extend({text:S()}),bu=S().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ry=Py.extend({blob:bu}),gi=_t(["user","assistant"]),pr=C({audience:ie(gi).optional(),priority:ae().min(0).max(1).optional(),lastModified:au({offset:!0}).optional()}),$y=C({...ur.shape,...ui.shape,uri:S(),description:Ue(S()),mimeType:Ue(S()),annotations:pr.optional(),_meta:Ue(xt({}))}),nC=C({...ur.shape,...ui.shape,uriTemplate:S(),description:Ue(S()),mimeType:Ue(S()),annotations:pr.optional(),_meta:Ue(xt({}))}),wu=pi.extend({method:w("resources/list")}),ya=fi.extend({resources:ie($y)}),_u=pi.extend({method:w("resources/templates/list")}),Su=fi.extend({resourceTemplates:ie(nC)}),ku=It.extend({uri:S()}),oC=ku,Cu=at.extend({method:w("resources/read"),params:oC}),xa=ct.extend({contents:ie(ue([Ny,Ry]))}),Tu=Ft.extend({method:w("notifications/resources/list_changed"),params:Dt.optional()}),rC=ku,iC=at.extend({method:w("resources/subscribe"),params:rC}),sC=ku,aC=at.extend({method:w("resources/unsubscribe"),params:sC}),cC=Dt.extend({uri:S()}),lC=Ft.extend({method:w("notifications/resources/updated"),params:cC}),uC=C({name:S(),description:Ue(S()),required:Ue(ze())}),dC=C({...ur.shape,...ui.shape,description:Ue(S()),arguments:Ue(ie(uC)),_meta:Ue(xt({}))}),Eu=pi.extend({method:w("prompts/list")}),Au=fi.extend({prompts:ie(dC)}),pC=It.extend({name:S(),arguments:Te(S(),S()).optional()}),fC=at.extend({method:w("prompts/get"),params:pC}),Iu=C({type:w("text"),text:S(),annotations:pr.optional(),_meta:Te(S(),Ae()).optional()}),zu=C({type:w("image"),data:bu,mimeType:S(),annotations:pr.optional(),_meta:Te(S(),Ae()).optional()}),Pu=C({type:w("audio"),data:bu,mimeType:S(),annotations:pr.optional(),_meta:Te(S(),Ae()).optional()}),mC=C({type:w("tool_use"),name:S(),id:S(),input:Te(S(),Ae()),_meta:Te(S(),Ae()).optional()}),Nu=C({type:w("resource"),resource:ue([Ny,Ry]),annotations:pr.optional(),_meta:Te(S(),Ae()).optional()}),Ru=$y.extend({type:w("resource_link")}),fr=ue([Iu,zu,Pu,Ru,Nu]),hC=C({role:gi,content:fr}),gC=ct.extend({description:S().optional(),messages:ie(hC)}),$u=Ft.extend({method:w("notifications/prompts/list_changed"),params:Dt.optional()}),vC=C({title:S().optional(),readOnlyHint:ze().optional(),destructiveHint:ze().optional(),idempotentHint:ze().optional(),openWorldHint:ze().optional()}),yC=C({taskSupport:_t(["required","optional","forbidden"]).optional()}),ba=C({...ur.shape,...ui.shape,description:S().optional(),inputSchema:C({type:w("object"),properties:Te(S(),st).optional(),required:ie(S()).optional()}).catchall(Ae()),outputSchema:C({type:w("object"),properties:Te(S(),st).optional(),required:ie(S()).optional()}).catchall(Ae()).optional(),annotations:vC.optional(),execution:yC.optional(),_meta:Te(S(),Ae()).optional()}),wa=pi.extend({method:w("tools/list")}),xC=fi.extend({tools:ie(ba)}),bo=ct.extend({content:ie(fr).default([]),structuredContent:Te(S(),Ae()).optional(),isError:ze().optional()}),NR=bo.or(ct.extend({toolResult:Ae()})),bC=ci.extend({name:S(),arguments:Te(S(),Ae()).optional()}),_a=at.extend({method:w("tools/call"),params:bC}),Mu=Ft.extend({method:w("notifications/tools/list_changed"),params:Dt.optional()}),RR=C({autoRefresh:ze().default(!0),debounceMs:ae().int().nonnegative().default(300)}),My=_t(["debug","info","notice","warning","error","critical","alert","emergency"]),wC=It.extend({level:My}),_C=at.extend({method:w("logging/setLevel"),params:wC}),SC=Dt.extend({level:My,logger:S().optional(),data:Ae()}),Ou=Ft.extend({method:w("notifications/message"),params:SC}),kC=C({name:S().optional()}),CC=C({hints:ie(kC).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),TC=C({mode:_t(["auto","required","none"]).optional()}),EC=C({type:w("tool_result"),toolUseId:S().describe("The unique identifier for the corresponding tool call."),content:ie(fr).default([]),structuredContent:C({}).loose().optional(),isError:ze().optional(),_meta:Te(S(),Ae()).optional()}),AC=fu("type",[Iu,zu,Pu]),aa=fu("type",[Iu,zu,Pu,mC,EC]),IC=C({role:gi,content:ue([aa,ie(aa)]),_meta:Te(S(),Ae()).optional()}),zC=ci.extend({messages:ie(IC),modelPreferences:CC.optional(),systemPrompt:S().optional(),includeContext:_t(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:ie(S()).optional(),metadata:st.optional(),tools:ie(ba).optional(),toolChoice:TC.optional()}),PC=at.extend({method:w("sampling/createMessage"),params:zC}),NC=ct.extend({model:S(),stopReason:Ue(_t(["endTurn","stopSequence","maxTokens"]).or(S())),role:gi,content:AC}),RC=ct.extend({model:S(),stopReason:Ue(_t(["endTurn","stopSequence","maxTokens","toolUse"]).or(S())),role:gi,content:ue([aa,ie(aa)])}),$C=C({type:w("boolean"),title:S().optional(),description:S().optional(),default:ze().optional()}),MC=C({type:w("string"),title:S().optional(),description:S().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:_t(["email","uri","date","date-time"]).optional(),default:S().optional()}),OC=C({type:_t(["number","integer"]),title:S().optional(),description:S().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),LC=C({type:w("string"),title:S().optional(),description:S().optional(),enum:ie(S()),default:S().optional()}),DC=C({type:w("string"),title:S().optional(),description:S().optional(),oneOf:ie(C({const:S(),title:S()})),default:S().optional()}),FC=C({type:w("string"),title:S().optional(),description:S().optional(),enum:ie(S()),enumNames:ie(S()).optional(),default:S().optional()}),jC=ue([LC,DC]),ZC=C({type:w("array"),title:S().optional(),description:S().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:C({type:w("string"),enum:ie(S())}),default:ie(S()).optional()}),HC=C({type:w("array"),title:S().optional(),description:S().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:C({anyOf:ie(C({const:S(),title:S()}))}),default:ie(S()).optional()}),BC=ue([ZC,HC]),UC=ue([FC,jC,BC]),WC=ue([UC,$C,MC,OC]),qC=ci.extend({mode:w("form").optional(),message:S(),requestedSchema:C({type:w("object"),properties:Te(S(),WC),required:ie(S()).optional()})}),VC=ci.extend({mode:w("url"),message:S(),elicitationId:S(),url:S().url()}),GC=ue([qC,VC]),XC=at.extend({method:w("elicitation/create"),params:GC}),KC=Dt.extend({elicitationId:S()}),JC=Ft.extend({method:w("notifications/elicitation/complete"),params:KC}),YC=ct.extend({action:_t(["accept","decline","cancel"]),content:mu((e)=>e===null?void 0:e,Te(S(),ue([S(),ae(),ze(),ie(S())])).optional())}),QC=C({type:w("ref/resource"),uri:S()});var eT=C({type:w("ref/prompt"),name:S()}),tT=It.extend({ref:ue([eT,QC]),argument:C({name:S(),value:S()}),context:C({arguments:Te(S(),S()).optional()}).optional()}),nT=at.extend({method:w("completion/complete"),params:tT});var oT=ct.extend({completion:xt({values:ie(S()).max(100),total:Ue(ae().int()),hasMore:Ue(ze())})}),rT=C({uri:S().startsWith("file://"),name:S().optional(),_meta:Te(S(),Ae()).optional()}),iT=at.extend({method:w("roots/list"),params:It.optional()}),sT=ct.extend({roots:ie(rT)}),aT=Ft.extend({method:w("notifications/roots/list_changed"),params:Dt.optional()}),$R=ue([xo,V0,nT,_C,fC,Eu,wu,_u,Cu,iC,aC,_a,wa,pa,ma,ha,va]),MR=ue([la,ua,K0,aT,hi]),OR=ue([xu,NC,RC,YC,sT,fa,ga,da]),LR=ue([xo,PC,XC,iT,pa,ma,ha,va]),DR=ue([la,ua,Ou,lC,Tu,Mu,$u,hi,JC]),FR=ue([xu,X0,oT,gC,Au,ya,Su,xa,bo,xC,fa,ga,da]);class fe extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`);this.code=e,this.data=n,this.name="McpError"}static fromError(e,t,n){if(e===ke.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Oy(o.elicitations,t)}return new fe(e,t,n)}}class Oy extends fe{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(ke.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function Sa(e){return!!e._zod}function ka(e,t){if(Sa(e))return ti(e,t);return e.safeParse(t)}function Ly(e){if(!e)return;let t;if(Sa(e))t=e._zod?.def?.shape;else t=e.shape;if(!t)return;if(typeof t==="function")try{return t()}catch{return}return t}function Dy(e){if(Sa(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}let o=e.value;if(o!==void 0)return o;return}function Zn(e){return e==="completed"||e==="failed"||e==="cancelled"}var cT=Symbol("Let zodToJsonSchema decide on which parser to use");var P$=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Lu(e){let n=Ly(e)?.method;if(!n)throw Error("Schema is missing a method literal");let o=Dy(n);if(typeof o!=="string")throw Error("Schema method literal must be a string");return o}function Du(e,t){let n=ka(e,t);if(!n.success)throw n.error;return n.data}var mT=60000;class Ca{constructor(e){if(this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(la,(t)=>{this._oncancel(t)}),this.setNotificationHandler(ua,(t)=>{this._onprogress(t)}),this.setRequestHandler(xo,(t)=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore)this.setRequestHandler(pa,async(t,n)=>{let o=await this._taskStore.getTask(t.params.taskId,n.sessionId);if(!o)throw new fe(ke.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ma,async(t,n)=>{let o=async()=>{let r=t.params.taskId;if(this._taskMessageQueue){let a;while(a=await this._taskMessageQueue.dequeue(r,n.sessionId)){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,p=new fe(d.error.code,d.error.message,d.error.data);u(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let s=await this._taskStore.getTask(r,n.sessionId);if(!s)throw new fe(ke.InvalidParams,`Task not found: ${r}`);if(!Zn(s.status))return await this._waitForTaskUpdate(r,n.signal),await o();if(Zn(s.status)){let a=await this._taskStore.getTaskResult(r,n.sessionId);return this._clearTaskQueue(r),{...a,_meta:{...a._meta,[jn]:{taskId:r}}}}return await o()};return await o()}),this.setRequestHandler(ha,async(t,n)=>{try{let{tasks:o,nextCursor:r}=await this._taskStore.listTasks(t.params?.cursor,n.sessionId);return{tasks:o,nextCursor:r,_meta:{}}}catch(o){throw new fe(ke.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(va,async(t,n)=>{try{let o=await this._taskStore.getTask(t.params.taskId,n.sessionId);if(!o)throw new fe(ke.InvalidParams,`Task not found: ${t.params.taskId}`);if(Zn(o.status))throw new fe(ke.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(t.params.taskId);let r=await this._taskStore.getTask(t.params.taskId,n.sessionId);if(!r)throw new fe(ke.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...r}}catch(o){if(o instanceof fe)throw o;throw new fe(ke.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}})}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,o,r=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:r,onTimeout:o})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),fe.fromError(ke.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(t)clearTimeout(t.timeoutId),this._timeoutInfo.delete(e)}async connect(e){if(this._transport)throw Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=(r)=>{n?.(r),this._onerror(r)};let o=this._transport?.onmessage;this._transport.onmessage=(r,s)=>{if(o?.(r,s),li(r)||Ay(r))this._onresponse(r);else if(gu(r))this._onrequest(r,s);else if(Ey(r))this._onnotification(r);else this._onerror(Error(`Unknown message type: ${JSON.stringify(r)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let t=fe.fromError(ke.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;if(t===void 0)return;Promise.resolve().then(()=>t(e)).catch((n)=>this._onerror(Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,r=e.params?._meta?.[jn]?.taskId;if(n===void 0){let u={jsonrpc:"2.0",id:e.id,error:{code:ke.MethodNotFound,message:"Method not found"}};if(r&&this._taskMessageQueue)this._enqueueTaskMessage(r,{type:"error",message:u,timestamp:Date.now()},o?.sessionId).catch((d)=>this._onerror(Error(`Failed to enqueue error response: ${d}`)));else o?.send(u).catch((d)=>this._onerror(Error(`Failed to send an error response: ${d}`)));return}let s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);let a=ky(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,l={signal:s.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async(u)=>{if(s.signal.aborted)return;let d={relatedRequestId:e.id};if(r)d.relatedTask={taskId:r};await this.notification(u,d)},sendRequest:async(u,d,p)=>{if(s.signal.aborted)throw new fe(ke.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};if(r&&!m.relatedTask)m.relatedTask={taskId:r};let f=m.relatedTask?.taskId??r;if(f&&c)await c.updateTaskStatus(f,"input_required");return await this.request(u,d,m)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:r,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(a)this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,l)).then(async(u)=>{if(s.signal.aborted)return;let d={result:u,jsonrpc:"2.0",id:e.id};if(r&&this._taskMessageQueue)await this._enqueueTaskMessage(r,{type:"response",message:d,timestamp:Date.now()},o?.sessionId);else await o?.send(d)},async(u)=>{if(s.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:ke.InternalError,message:u.message??"Internal error",...u.data!==void 0&&{data:u.data}}};if(r&&this._taskMessageQueue)await this._enqueueTaskMessage(r,{type:"error",message:d,timestamp:Date.now()},o?.sessionId);else await o?.send(d)}).catch((u)=>this._onerror(Error(`Failed to send response: ${u}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(e.id)===s)this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,o=Number(t),r=this._progressHandlers.get(o);if(!r){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),s(c);return}r(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){if(this._requestResolvers.delete(t),li(e))n(e);else{let s=new fe(e.error.code,e.error.message,e.error.data);n(s)}return}let o=this._responseHandlers.get(t);if(o===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let r=!1;if(li(e)&&e.result&&typeof e.result==="object"){let s=e.result;if(s.task&&typeof s.task==="object"){let a=s.task;if(typeof a.taskId==="string")r=!0,this._taskProgressTokens.set(a.taskId,t)}}if(!r)this._progressHandlers.delete(t);if(li(e))o(e);else{let s=fe.fromError(e.error.code,e.error.message,e.error.data);o(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,t,n)}}catch(s){yield{type:"error",error:s instanceof fe?s:new fe(ke.InternalError,String(s))}}return}let r;try{let s=await this.request(e,da,n);if(s.task)r=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new fe(ke.InternalError,"Task creation did not return a task");while(!0){let a=await this.getTask({taskId:r},n);if(yield{type:"taskStatus",task:a},Zn(a.status)){if(a.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:r},t,n)};else if(a.status==="failed")yield{type:"error",error:new fe(ke.InternalError,`Task ${r} failed`)};else if(a.status==="cancelled")yield{type:"error",error:new fe(ke.InternalError,`Task ${r} was cancelled`)};return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:r},t,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((l)=>setTimeout(l,c)),n?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof fe?s:new fe(ke.InternalError,String(s))}}}request(e,t,n){let{relatedRequestId:o,resumptionToken:r,onresumptiontoken:s,task:a,relatedTask:c}=n??{};return new Promise((l,u)=>{let d=(h)=>{u(h)};if(!this._transport){d(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(e.method),a)this.assertTaskCapability(e.method)}catch(h){d(h);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};if(n?.onprogress)this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}};if(a)m.params={...m.params,task:a};if(c)m.params={...m.params,_meta:{...m.params?._meta||{},[jn]:c}};let f=(h)=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(h)}},{relatedRequestId:o,resumptionToken:r,onresumptiontoken:s}).catch((b)=>this._onerror(Error(`Failed to send cancellation: ${b}`)));let g=h instanceof fe?h:new fe(ke.RequestTimeout,String(h));u(g)};this._responseHandlers.set(p,(h)=>{if(n?.signal?.aborted)return;if(h instanceof Error)return u(h);try{let g=ka(t,h.result);if(!g.success)u(g.error);else l(g.data)}catch(g){u(g)}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let y=n?.timeout??mT,v=()=>f(fe.fromError(ke.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(p,y,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let x=c?.taskId;if(x){let h=(g)=>{let b=this._responseHandlers.get(p);if(b)b(g);else this._onerror(Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,h),this._enqueueTaskMessage(x,{type:"request",message:m,timestamp:Date.now()}).catch((g)=>{this._cleanupTimeout(p),u(g)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:r,onresumptiontoken:s}).catch((h)=>{this._cleanupTimeout(p),u(h)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},fa,t)}async getTaskResult(e,t,n){return this.request({method:"tasks/result",params:e},t,n)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},ga,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},zy,t)}async notification(e,t){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[jn]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};if(t?.relatedTask)a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[jn]:t.relatedTask}}};this._transport?.send(a,t).catch((c)=>this._onerror(c))});return}let s={...e,jsonrpc:"2.0"};if(t?.relatedTask)s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[jn]:t.relatedTask}}};await this._transport.send(s,t)}setRequestHandler(e,t){let n=Lu(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,r)=>{let s=Du(e,o);return Promise.resolve(t(s,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Lu(e);this._notificationHandlers.set(n,(o)=>{let r=Du(e,o);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);if(t!==void 0)this._progressHandlers.delete(t),this._taskProgressTokens.delete(e)}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,o)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let o of n)if(o.type==="request"&&gu(o.message)){let r=o.message.id,s=this._requestResolvers.get(r);if(s)s(new fe(ke.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r);else this._onerror(Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1000;try{let o=await this._taskStore?.getTask(e);if(o?.pollInterval)n=o.pollInterval}catch{}return new Promise((o,r)=>{if(t.aborted){r(new fe(ke.InvalidRequest,"Request cancelled"));return}let s=setTimeout(o,n);t.addEventListener("abort",()=>{clearTimeout(s),r(new fe(ke.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error("No task store configured");return{createTask:async(o)=>{if(!e)throw Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},t)},getTask:async(o)=>{let r=await n.getTask(o,t);if(!r)throw new fe(ke.InvalidParams,"Failed to retrieve task: Task not found");return r},storeTaskResult:async(o,r,s)=>{await n.storeTaskResult(o,r,s,t);let a=await n.getTask(o,t);if(a){let c=hi.parse({method:"notifications/tasks/status",params:a});if(await this.notification(c),Zn(a.status))this._cleanupTaskProgressHandler(o)}},getTaskResult:(o)=>n.getTaskResult(o,t),updateTaskStatus:async(o,r,s)=>{let a=await n.getTask(o,t);if(!a)throw new fe(ke.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Zn(a.status))throw new fe(ke.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,r,s,t);let c=await n.getTask(o,t);if(c){let l=hi.parse({method:"notifications/tasks/status",params:c});if(await this.notification(l),Zn(c.status))this._cleanupTaskProgressHandler(o)}},listTasks:(o)=>n.listTasks(o,t)}}}var Zy="2026-01-26";var hT="ui/notifications/tool-input-partial";var gT=ue([w("light"),w("dark")]).describe("Color theme preference for the host environment."),yi=ue([w("inline"),w("fullscreen"),w("pip")]).describe("Display mode for UI presentation."),vT=ue([w("--color-background-primary"),w("--color-background-secondary"),w("--color-background-tertiary"),w("--color-background-inverse"),w("--color-background-ghost"),w("--color-background-info"),w("--color-background-danger"),w("--color-background-success"),w("--color-background-warning"),w("--color-background-disabled"),w("--color-text-primary"),w("--color-text-secondary"),w("--color-text-tertiary"),w("--color-text-inverse"),w("--color-text-ghost"),w("--color-text-info"),w("--color-text-danger"),w("--color-text-success"),w("--color-text-warning"),w("--color-text-disabled"),w("--color-border-primary"),w("--color-border-secondary"),w("--color-border-tertiary"),w("--color-border-inverse"),w("--color-border-ghost"),w("--color-border-info"),w("--color-border-danger"),w("--color-border-success"),w("--color-border-warning"),w("--color-border-disabled"),w("--color-ring-primary"),w("--color-ring-secondary"),w("--color-ring-inverse"),w("--color-ring-info"),w("--color-ring-danger"),w("--color-ring-success"),w("--color-ring-warning"),w("--font-sans"),w("--font-mono"),w("--font-weight-normal"),w("--font-weight-medium"),w("--font-weight-semibold"),w("--font-weight-bold"),w("--font-text-xs-size"),w("--font-text-sm-size"),w("--font-text-md-size"),w("--font-text-lg-size"),w("--font-heading-xs-size"),w("--font-heading-sm-size"),w("--font-heading-md-size"),w("--font-heading-lg-size"),w("--font-heading-xl-size"),w("--font-heading-2xl-size"),w("--font-heading-3xl-size"),w("--font-text-xs-line-height"),w("--font-text-sm-line-height"),w("--font-text-md-line-height"),w("--font-text-lg-line-height"),w("--font-heading-xs-line-height"),w("--font-heading-sm-line-height"),w("--font-heading-md-line-height"),w("--font-heading-lg-line-height"),w("--font-heading-xl-line-height"),w("--font-heading-2xl-line-height"),w("--font-heading-3xl-line-height"),w("--border-radius-xs"),w("--border-radius-sm"),w("--border-radius-md"),w("--border-radius-lg"),w("--border-radius-xl"),w("--border-radius-full"),w("--border-width-regular"),w("--shadow-hairline"),w("--shadow-sm"),w("--shadow-md"),w("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),yT=Te(vT.describe(`Style variables for theming MCP apps.
|
|
152
151
|
|
|
153
152
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
154
153
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
155
154
|
|
|
156
155
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
157
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
156
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),ue([S(),du()]).describe(`Style variables for theming MCP apps.
|
|
158
157
|
|
|
159
158
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
160
159
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -166,10 +165,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
166
165
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
167
166
|
|
|
168
167
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
169
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
168
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),xT=C({method:w("ui/open-link"),params:C({url:S().describe("URL to open in the host's browser")})}),RL=C({isError:ze().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),$L=C({isError:ze().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),ML=C({isError:ze().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),bT=C({method:w("ui/notifications/sandbox-proxy-ready"),params:C({})}),Fu=C({connectDomains:ie(S()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
170
169
|
|
|
171
170
|
- Maps to CSP \`connect-src\` directive
|
|
172
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:
|
|
171
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:ie(S()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:ie(S()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:ie(S()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),ju=C({camera:C({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:C({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:C({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:C({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),wT=C({method:w("ui/notifications/size-changed"),params:C({width:ae().optional().describe("New width in pixels."),height:ae().optional().describe("New height in pixels.")})}),OL=C({method:w("ui/notifications/tool-input"),params:C({arguments:Te(S(),Ae().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),LL=C({method:w("ui/notifications/tool-input-partial"),params:C({arguments:Te(S(),Ae().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),DL=C({method:w("ui/notifications/tool-cancelled"),params:C({reason:S().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),_T=C({fonts:S().optional()}),ST=C({variables:yT.optional().describe("CSS variables for theming the app."),css:_T.optional().describe("CSS blocks that apps can inject.")}),FL=C({method:w("ui/resource-teardown"),params:C({})}),kT=Te(S(),Ae()),Fy=C({text:C({}).optional().describe("Host supports text content blocks."),image:C({}).optional().describe("Host supports image content blocks."),audio:C({}).optional().describe("Host supports audio content blocks."),resource:C({}).optional().describe("Host supports resource content blocks."),resourceLink:C({}).optional().describe("Host supports resource link content blocks."),structuredContent:C({}).optional().describe("Host supports structured content.")}),CT=C({method:w("ui/notifications/request-teardown"),params:C({}).optional()}),TT=C({experimental:C({}).optional().describe("Experimental features (structure TBD)."),openLinks:C({}).optional().describe("Host supports opening external URLs."),downloadFile:C({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:C({listChanged:ze().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:C({listChanged:ze().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:C({}).optional().describe("Host accepts log messages."),sandbox:C({permissions:ju.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Fu.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Fy.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Fy.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),ET=C({experimental:C({}).optional().describe("Experimental features (structure TBD)."),tools:C({listChanged:ze().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:ie(yi).optional().describe("Display modes the app supports.")}),AT=C({method:w("ui/notifications/initialized"),params:C({}).optional()}),jL=C({csp:Fu.optional().describe("Content Security Policy configuration for UI resources."),permissions:ju.optional().describe("Sandbox permissions requested by the UI resource."),domain:S().optional().describe(`Dedicated origin for view sandbox.
|
|
173
172
|
|
|
174
173
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
175
174
|
|
|
@@ -177,19 +176,19 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
177
176
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
178
177
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
179
178
|
|
|
180
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
179
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:ze().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
181
180
|
|
|
182
181
|
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
183
182
|
|
|
184
183
|
- \`true\`: request visible border + background
|
|
185
184
|
- \`false\`: request no visible border + background
|
|
186
|
-
- omitted: host decides border`)}),
|
|
185
|
+
- omitted: host decides border`)}),jy=C({method:w("ui/request-display-mode"),params:C({mode:yi.describe("The display mode being requested.")})}),ZL=C({mode:yi.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),IT=ue([w("model"),w("app")]).describe("Tool visibility scope - who can access the tool."),HL=C({resourceUri:S().optional(),visibility:ie(IT).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
187
186
|
- "model": Tool visible to and callable by the agent
|
|
188
|
-
- "app": Tool callable by the app from this server only`)}),
|
|
189
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Q.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:Q.string().optional().describe("User's timezone in IANA format."),userAgent:Q.string().optional().describe("Host application identifier."),platform:Q.union([Q.literal("web"),Q.literal("desktop"),Q.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:Q.object({touch:Q.boolean().optional().describe("Whether the device supports touch input."),hover:Q.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:Q.object({top:Q.number().describe("Top safe area inset in pixels."),right:Q.number().describe("Right safe area inset in pixels."),bottom:Q.number().describe("Bottom safe area inset in pixels."),left:Q.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),fI=Q.object({method:Q.literal("ui/notifications/host-context-changed"),params:gX.describe("Partial context update containing only changed fields.")}),EI=Q.object({method:Q.literal("ui/update-model-context"),params:Q.object({content:Q.array(Q0).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Q.record(Q.string(),Q.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),uI=Q.object({method:Q.literal("ui/initialize"),params:Q.object({appInfo:h_.describe("App identification (name and version)."),appCapabilities:RI.describe("Features and capabilities this app provides."),protocolVersion:Q.string().describe("Protocol version this app supports.")})}),mI=Q.object({protocolVersion:Q.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:h_.describe("Host application identification and version."),hostCapabilities:SI.describe("Features and capabilities provided by the host."),hostContext:gX.describe("Rich context about the host environment.")}).passthrough();class B9{eventTarget;eventSource;messageListener;constructor($=window.parent,U){this.eventTarget=$,this.eventSource=U,this.messageListener=(v)=>{if(U&&v.source!==this.eventSource){console.debug("Ignoring message from unknown source",v);return}let J=XX.safeParse(v.data);if(J.success)console.debug("Parsed message",J.data),this.onmessage?.(J.data);else if(v.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",J.error.message,v);else console.error("Failed to parse message",J.error.message,v),this.onerror?.(Error("Invalid JSON-RPC message received: "+J.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send($,U){if($.method!==YI)console.debug("Sending message",$);this.eventTarget.postMessage($,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}class xI extends s_{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;constructor($,U={},v={autoResize:!0}){super(v);this._appInfo=$,this._capabilities=U,this.options=v,this.setRequestHandler(X1,(J)=>{return console.log("Received ping:",J.params),{}}),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput($){this.setNotificationHandler(kI,(U)=>$(U.params))}set ontoolinputpartial($){this.setNotificationHandler(bI,(U)=>$(U.params))}set ontoolresult($){this.setNotificationHandler(VI,(U)=>$(U.params))}set ontoolcancelled($){this.setNotificationHandler(MI,(U)=>$(U.params))}set onhostcontextchanged($){this.setNotificationHandler(fI,(U)=>{this._hostContext={...this._hostContext,...U.params},$(U.params)})}set onteardown($){this.setRequestHandler(wI,(U,v)=>$(U.params,v))}set oncalltool($){this.setRequestHandler(t_,(U,v)=>$(U.params,v))}set onlisttools($){this.setRequestHandler(n_,(U,v)=>$(U.params,v))}assertCapabilityForMethod($){}assertRequestHandlerCapability($){switch($){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${$})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${$} registered`)}}assertNotificationCapability($){}assertTaskCapability($){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability($){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool($,U){if(typeof $==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${$}"). Did you mean: callServerTool({ name: "${$}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:$},H1,U)}async readServerResource($,U){return await this.request({method:"resources/read",params:$},d_,U)}async listServerResources($,U){return await this.request({method:"resources/list",params:$},o_,U)}sendMessage($,U){return this.request({method:"ui/message",params:$},LI,U)}sendLog($){return this.notification({method:"notifications/message",params:$})}updateModelContext($,U){return this.request({method:"ui/update-model-context",params:$},$9,U)}openLink($,U){return this.request({method:"ui/open-link",params:$},HI,U)}sendOpenLink=this.openLink;downloadFile($,U){return this.request({method:"ui/download-file",params:$},QI,U)}requestTeardown($={}){return this.notification({method:"ui/notifications/request-teardown",params:$})}requestDisplayMode($,U){return this.request({method:"ui/request-display-mode",params:$},yI,U)}sendSizeChanged($){return this.notification({method:"ui/notifications/size-changed",params:$})}setupSizeChangedNotifications(){let $=!1,U=0,v=0,J=()=>{if($)return;$=!0,requestAnimationFrame(()=>{$=!1;let z=document.documentElement,K=z.style.width,W=z.style.height;z.style.width="fit-content",z.style.height="max-content";let O=z.getBoundingClientRect();z.style.width=K,z.style.height=W;let Y=window.innerWidth-z.clientWidth,Z=Math.ceil(O.width+Y),q=Math.ceil(O.height);if(Z!==U||q!==v)U=Z,v=q,this.sendSizeChanged({width:Z,height:q})})};J();let _=new ResizeObserver(J);return _.observe(document.documentElement),_.observe(document.body),()=>_.disconnect()}async connect($=new B9(window.parent,window.parent),U){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect($);try{let v=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:AW}},mI,U);if(v===void 0)throw Error(`Server sent invalid initialize result: ${v}`);if(this._hostCapabilities=v.hostCapabilities,this._hostInfo=v.hostInfo,this._hostContext=v.hostContext,await this.notification({method:"ui/notifications/initialized"}),this.options?.autoResize)this.setupSizeChangedNotifications()}catch(v){throw this.close(),v}}}function NX($){if(!$)return"";let U=[];if($.camera)U.push("camera");if($.microphone)U.push("microphone");if($.geolocation)U.push("geolocation");if($.clipboardWrite)U.push("clipboard-write");return U.join("; ")}var hI=[AW];class gW extends s_{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;constructor($,U,v,J){super(J);this._client=$,this._hostInfo=U,this._capabilities=v,this._hostContext=J?.hostContext||{},this.setRequestHandler(uI,(_)=>this._oninitialize(_)),this.setRequestHandler(X1,(_,z)=>{return this.onping?.(_.params,z),{}}),this.setRequestHandler(wX,(_)=>{return{mode:this._hostContext.displayMode??"inline"}})}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;set onsizechange($){this.setNotificationHandler(PI,(U)=>$(U.params))}set onsandboxready($){this.setNotificationHandler(FI,(U)=>$(U.params))}set oninitialized($){this.setNotificationHandler(TI,(U)=>$(U.params))}set onmessage($){this.setRequestHandler(jI,async(U,v)=>{return $(U.params,v)})}set onopenlink($){this.setRequestHandler(XI,async(U,v)=>{return $(U.params,v)})}set ondownloadfile($){this.setRequestHandler(DI,async(U,v)=>{return $(U.params,v)})}set onrequestteardown($){this.setNotificationHandler(NI,(U)=>$(U.params))}set onrequestdisplaymode($){this.setRequestHandler(wX,async(U,v)=>{return $(U.params,v)})}set onloggingmessage($){this.setNotificationHandler(kW,async(U)=>{$(U.params)})}set onupdatemodelcontext($){this.setRequestHandler(EI,async(U,v)=>{return $(U.params,v)})}set oncalltool($){this.setRequestHandler(t_,async(U,v)=>{return $(U.params,v)})}sendToolListChanged($={}){return this.notification({method:"notifications/tools/list_changed",params:$})}set onlistresources($){this.setRequestHandler(zW,async(U,v)=>{return $(U.params,v)})}set onlistresourcetemplates($){this.setRequestHandler(KW,async(U,v)=>{return $(U.params,v)})}set onreadresource($){this.setRequestHandler(OW,async(U,v)=>{return $(U.params,v)})}sendResourceListChanged($={}){return this.notification({method:"notifications/resources/list_changed",params:$})}set onlistprompts($){this.setRequestHandler(ZW,async(U,v)=>{return $(U.params,v)})}sendPromptListChanged($={}){return this.notification({method:"notifications/prompts/list_changed",params:$})}assertCapabilityForMethod($){}assertRequestHandlerCapability($){}assertNotificationCapability($){}assertTaskCapability($){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability($){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize($){let U=$.params.protocolVersion;return this._appCapabilities=$.params.appCapabilities,this._appInfo=$.params.appInfo,{protocolVersion:hI.includes(U)?U:AW,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext($){let U={},v=!1;for(let J of Object.keys($)){let _=this._hostContext[J],z=$[J];if(cI(_,z))continue;U[J]=z,v=!0}if(v)this._hostContext=$,this.sendHostContextChange(U)}sendHostContextChange($){return this.notification({method:"ui/notifications/host-context-changed",params:$})}sendToolInput($){return this.notification({method:"ui/notifications/tool-input",params:$})}sendToolInputPartial($){return this.notification({method:"ui/notifications/tool-input-partial",params:$})}sendToolResult($){return this.notification({method:"ui/notifications/tool-result",params:$})}sendToolCancelled($){return this.notification({method:"ui/notifications/tool-cancelled",params:$})}sendSandboxResourceReady($){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:$})}teardownResource($,U){return this.request({method:"ui/resource-teardown",params:$},gI,U)}sendResourceTeardown=this.teardownResource;async connect($){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._client){let U=this._client.getServerCapabilities();if(!U)throw Error("Client server capabilities not available");if(U.tools){if(this.oncalltool=async(v,J)=>{return this._client.request({method:"tools/call",params:v},H1,{signal:J.signal})},U.tools.listChanged)this._client.setNotificationHandler(PW,(v)=>this.sendToolListChanged(v.params))}if(U.resources){if(this.onlistresources=async(v,J)=>{return this._client.request({method:"resources/list",params:v},o_,{signal:J.signal})},this.onlistresourcetemplates=async(v,J)=>{return this._client.request({method:"resources/templates/list",params:v},GW,{signal:J.signal})},this.onreadresource=async(v,J)=>{return this._client.request({method:"resources/read",params:v},d_,{signal:J.signal})},U.resources.listChanged)this._client.setNotificationHandler(YW,(v)=>this.sendResourceListChanged(v.params))}if(U.prompts){if(this.onlistprompts=async(v,J)=>{return this._client.request({method:"prompts/list",params:v},qW,{signal:J.signal})},U.prompts.listChanged)this._client.setNotificationHandler(FW,(v)=>this.sendPromptListChanged(v.params))}}return super.connect($)}}function cI($,U){return JSON.stringify($)===JSON.stringify(U)}function NW($){return $!==null&&typeof $==="object"&&!Array.isArray($)}function lI($){return NW($)&&Array.isArray($.content)&&$.content.every((U)=>NW(U)&&typeof U.type==="string")}function rI(...$){for(let U of $)if(typeof U==="string"){if(U.trim().length>0)return U}return}function iI($){if(typeof $==="string")return $;if($===void 0)return;try{return JSON.stringify($)}catch(U){return console.debug("[ext-app-tool-result] stringify failed",U),String($)}}function SW($){let U=$.success===!1;if(lI($.result))return{...$.result,isError:$.result.isError===!0||U};let v=NW($.result)?$.result:null,J=rI($.detailedContent,$.content,v?.detailedContent,v?.content,v?.textResultForLlm,v?.text,v?.message,typeof $.result==="string"?$.result:void 0,$.error)??iI($.result);return{content:J?[{type:"text",text:J}]:[],isError:U}}function SX($,U){if($===U)return!0;if($.isError!==U.isError)return!1;try{let v=JSON.stringify($),J=JSON.stringify(U);if(v===void 0||J===void 0)return!1;if(Math.abs(v.length-J.length)>2000000)return!1;return v===J}catch{return!1}}function RX($){return Boolean($)&&typeof $==="object"&&$!==null&&!Array.isArray($)&&"ok"in $&&typeof $.ok==="boolean"}async function pI($,U){let v=await fetch("/api/canvas/frame-documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:$,sandbox:U})}),J=await v.json();if(!v.ok||!RX(J)||!J.ok||typeof J.url!=="string"){let _=RX(J)&&J.error?J.error:`Frame document request failed with HTTP ${v.status}`;throw Error(_)}return J.url}function TX($,U){let v=w6.value,[J,_]=f(null),[z,K]=f(0),W=C(0);u(()=>{if(_(null),!$||v!=="src")return;let Y=!1;return W.current=f1.value,pI($,U).then((Z)=>{if(!Y)_(Z)}).catch((Z)=>{console.error("[iframe-document] failed to create frame document:",Z)}),()=>{Y=!0}},[$,U,v,z]);let O=f1.value;return u(()=>{if(v!=="src"||O===W.current)return;if(!J){K((Z)=>Z+1);return}let Y=!1;return fetch(J,{method:"HEAD"}).then((Z)=>{if(Y)return;if(Z.ok){W.current=O;return}K((q)=>q+1)}).catch(()=>{}),()=>{Y=!0}},[O,J,v]),u$(()=>{if(v==="srcdoc"&&$)return{attributes:{srcdoc:$},ready:!0,key:`srcdoc-${RU($)}`};return{attributes:J?{src:J}:{},ready:Boolean(J),key:J??""}},[J,v,$])}function L0($){let{enabled:U,token:v,nodeId:J,sourceSurface:_,iframeRef:z}=$;u(()=>{if(!U||!v)return;function K(W){if(W.source!==z.current?.contentWindow)return;let O=W.data;if(!O||O.source!==Qv||O.token!==v||O.nodeId!==J)return;let Y=O.interaction;if(!Y||typeof Y.type!=="string")return;let Z=Y.type;l2({type:Z,sourceNodeId:J,sourceSurface:_,...Y.payload&&typeof Y.payload==="object"?{payload:Y.payload}:{}}).then((q)=>{if(q.ok)PU("context","AX interaction",Z,[J]);else PU("remove","AX interaction rejected",q.error??q.code??"",[J]);z.current?.contentWindow?.postMessage({source:Lv,token:v,...O.correlationId?{correlationId:O.correlationId}:{},interaction:{type:Z},result:q},"*")})}return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[U,v,J,_])}async function d1($,U){let J=await(await fetch($,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)})).json();if(!J.ok)throw Error(J.error??`Request failed: ${$}`);return J.result}function n1($){return/AppleWebKit/.test($)&&!/Chrome|Chromium|CriOS|Edg|Android/.test($)}function oI($){let{userAgent:U,visibilityState:v,rect:J,viewport:_,alreadyRearmed:z}=$;if(z)return!1;if(!n1(U))return!1;if(v!=="hidden")return!1;if(J.width<=0||J.height<=0)return!1;return J.bottom>0&&J.right>0&&J.top<_.height&&J.left<_.width}var uX=1000,yX=7000;function W6($,U){if(typeof window>"u")return;let v=window;if(v.__PMX_EXTAPP_LOG??=[],v.__PMX_EXTAPP_LOG.length<500)v.__PMX_EXTAPP_LOG.push({t:Date.now(),nodeId:$,event:U});dI({t:Date.now(),nodeId:$,event:U})}var CX=[],RW=null;function dI($){if(CX.push({...$,...typeof document<"u"?{visibility:document.visibilityState}:{}}),RW)return;RW=setTimeout(()=>{RW=null;let U=CX.splice(0);if(U.length===0)return;fetch("/api/canvas/debug/ext-app-recovery",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:U})}).catch(()=>{})},1500)}var DX=Promise.resolve();function jX($){DX=DX.then(async()=>{if(!$.remount())return;await $.awaitBoot(),await new Promise((U)=>setTimeout(U,uX))}).catch(()=>{})}function nI($,U){let v=typeof $.data.html==="string"?$.data.html:"",J=typeof $.data.serverName==="string"?$.data.serverName:"",_=typeof $.data.appSessionId==="string"?$.data.appSessionId:"",z=typeof $.data.sessionStatus==="string"?$.data.sessionStatus:"";return`${$.id}:${U}:${J}:${_}:${z}:${v}`}function tI($,U){if($==="fullscreen")return{nextMode:"fullscreen",shouldExpand:!U,shouldCollapse:!1};if($==="inline")return{nextMode:"inline",shouldExpand:!1,shouldCollapse:U};return{nextMode:$,shouldExpand:!1,shouldCollapse:!1}}async function VX($,U,v){if(await $.sendToolInput({arguments:U}),v)await $.sendToolResult(v)}function aI($){return typeof $==="string"&&$.trim().length>0?$.trim():Y5}function sI($,U){return`<script data-pmx-canvas-ax-bridge>
|
|
187
|
+
- "app": Tool callable by the app from this server only`)}),BL=C({mimeTypes:ie(S()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),zT=C({method:w("ui/download-file"),params:C({contents:ie(ue([Nu,Ru])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),PT=C({method:w("ui/message"),params:C({role:w("user").describe('Message role, currently only "user" is supported.'),content:ie(fr).describe("Message content blocks (text, image, etc.).")})}),UL=C({method:w("ui/notifications/sandbox-resource-ready"),params:C({html:S().describe("HTML content to load into the inner iframe."),sandbox:S().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Fu.optional().describe("CSP configuration from resource metadata."),permissions:ju.optional().describe("Sandbox permissions from resource metadata.")})}),WL=C({method:w("ui/notifications/tool-result"),params:bo.describe("Standard MCP tool execution result.")}),Hy=C({toolInfo:C({id:dr.optional().describe("JSON-RPC id of the tools/call request."),tool:ba.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:gT.optional().describe("Current color theme preference."),styles:ST.optional().describe("Style configuration for theming the app."),displayMode:yi.optional().describe("How the UI is currently displayed."),availableDisplayModes:ie(yi).optional().describe("Display modes the host supports."),containerDimensions:ue([C({height:ae().describe("Fixed container height in pixels.")}),C({maxHeight:ue([ae(),du()]).optional().describe("Maximum container height in pixels.")})]).and(ue([C({width:ae().describe("Fixed container width in pixels.")}),C({maxWidth:ue([ae(),du()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
188
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:S().optional().describe("User's language and region preference in BCP 47 format."),timeZone:S().optional().describe("User's timezone in IANA format."),userAgent:S().optional().describe("Host application identifier."),platform:ue([w("web"),w("desktop"),w("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:C({touch:ze().optional().describe("Whether the device supports touch input."),hover:ze().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:C({top:ae().describe("Top safe area inset in pixels."),right:ae().describe("Right safe area inset in pixels."),bottom:ae().describe("Bottom safe area inset in pixels."),left:ae().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),qL=C({method:w("ui/notifications/host-context-changed"),params:Hy.describe("Partial context update containing only changed fields.")}),NT=C({method:w("ui/update-model-context"),params:C({content:ie(fr).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Te(S(),Ae().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),RT=C({method:w("ui/initialize"),params:C({appInfo:di.describe("App identification (name and version)."),appCapabilities:ET.describe("Features and capabilities this app provides."),protocolVersion:S().describe("Protocol version this app supports.")})}),VL=C({protocolVersion:S().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:di.describe("Host application identification and version."),hostCapabilities:TT.describe("Features and capabilities provided by the host."),hostContext:Hy.describe("Rich context about the host environment.")}).passthrough();class Zu{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(n)=>{if(t&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let o=Iy.safeParse(n.data);if(o.success)console.debug("Parsed message",o.data),this.onmessage?.(o.data);else if(n.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",o.error.message,n);else console.error("Failed to parse message",o.error.message,n),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==hT)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}function By(e){if(!e)return"";let t=[];if(e.camera)t.push("camera");if(e.microphone)t.push("microphone");if(e.geolocation)t.push("geolocation");if(e.clipboardWrite)t.push("clipboard-write");return t.join("; ")}var $T=[Zy];class Hu extends Ca{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;constructor(e,t,n,o){super(o);this._client=e,this._hostInfo=t,this._capabilities=n,this._hostContext=o?.hostContext||{},this.setRequestHandler(RT,(r)=>this._oninitialize(r)),this.setRequestHandler(xo,(r,s)=>(this.onping?.(r.params,s),{})),this.setRequestHandler(jy,(r)=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;set onsizechange(e){this.setNotificationHandler(wT,(t)=>e(t.params))}set onsandboxready(e){this.setNotificationHandler(bT,(t)=>e(t.params))}set oninitialized(e){this.setNotificationHandler(AT,(t)=>e(t.params))}set onmessage(e){this.setRequestHandler(PT,async(t,n)=>e(t.params,n))}set onopenlink(e){this.setRequestHandler(xT,async(t,n)=>e(t.params,n))}set ondownloadfile(e){this.setRequestHandler(zT,async(t,n)=>e(t.params,n))}set onrequestteardown(e){this.setNotificationHandler(CT,(t)=>e(t.params))}set onrequestdisplaymode(e){this.setRequestHandler(jy,async(t,n)=>e(t.params,n))}set onloggingmessage(e){this.setNotificationHandler(Ou,async(t)=>{e(t.params)})}set onupdatemodelcontext(e){this.setRequestHandler(NT,async(t,n)=>e(t.params,n))}set oncalltool(e){this.setRequestHandler(_a,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:"notifications/tools/list_changed",params:e})}set onlistresources(e){this.setRequestHandler(wu,async(t,n)=>e(t.params,n))}set onlistresourcetemplates(e){this.setRequestHandler(_u,async(t,n)=>e(t.params,n))}set onreadresource(e){this.setRequestHandler(Cu,async(t,n)=>e(t.params,n))}sendResourceListChanged(e={}){return this.notification({method:"notifications/resources/list_changed",params:e})}set onlistprompts(e){this.setRequestHandler(Eu,async(t,n)=>e(t.params,n))}sendPromptListChanged(e={}){return this.notification({method:"notifications/prompts/list_changed",params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(e){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:$T.includes(t)?t:Zy,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let o of Object.keys(e)){let r=this._hostContext[o],s=e[o];if(MT(r,s))continue;t[o]=s,n=!0}if(n)this._hostContext=e,this.sendHostContextChange(t)}sendHostContextChange(e){return this.notification({method:"ui/notifications/host-context-changed",params:e})}sendToolInput(e){return this.notification({method:"ui/notifications/tool-input",params:e})}sendToolInputPartial(e){return this.notification({method:"ui/notifications/tool-input-partial",params:e})}sendToolResult(e){return this.notification({method:"ui/notifications/tool-result",params:e})}sendToolCancelled(e){return this.notification({method:"ui/notifications/tool-cancelled",params:e})}sendSandboxResourceReady(e){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:e})}teardownResource(e,t){return this.request({method:"ui/resource-teardown",params:e},kT,t)}sendResourceTeardown=this.teardownResource;async connect(e){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._client){let t=this._client.getServerCapabilities();if(!t)throw Error("Client server capabilities not available");if(t.tools){if(this.oncalltool=async(n,o)=>this._client.request({method:"tools/call",params:n},bo,{signal:o.signal}),t.tools.listChanged)this._client.setNotificationHandler(Mu,(n)=>this.sendToolListChanged(n.params))}if(t.resources){if(this.onlistresources=async(n,o)=>this._client.request({method:"resources/list",params:n},ya,{signal:o.signal}),this.onlistresourcetemplates=async(n,o)=>this._client.request({method:"resources/templates/list",params:n},Su,{signal:o.signal}),this.onreadresource=async(n,o)=>this._client.request({method:"resources/read",params:n},xa,{signal:o.signal}),t.resources.listChanged)this._client.setNotificationHandler(Tu,(n)=>this.sendResourceListChanged(n.params))}if(t.prompts){if(this.onlistprompts=async(n,o)=>this._client.request({method:"prompts/list",params:n},Au,{signal:o.signal}),t.prompts.listChanged)this._client.setNotificationHandler($u,(n)=>this.sendPromptListChanged(n.params))}}return super.connect(e)}}function MT(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Bu(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function OT(e){return Bu(e)&&Array.isArray(e.content)&&e.content.every((t)=>Bu(t)&&typeof t.type==="string")}function LT(...e){for(let t of e)if(typeof t==="string"){if(t.trim().length>0)return t}return}function DT(e){if(typeof e==="string")return e;if(e===void 0)return;try{return JSON.stringify(e)}catch(t){return console.debug("[ext-app-tool-result] stringify failed",t),String(e)}}function Uu(e){let t=e.success===!1;if(OT(e.result))return{...e.result,isError:e.result.isError===!0||t};let n=Bu(e.result)?e.result:null,o=LT(e.detailedContent,e.content,n?.detailedContent,n?.content,n?.textResultForLlm,n?.text,n?.message,typeof e.result==="string"?e.result:void 0,e.error)??DT(e.result);return{content:o?[{type:"text",text:o}]:[],isError:t}}function Uy(e,t){if(e===t)return!0;if(e.isError!==t.isError)return!1;try{let n=JSON.stringify(e),o=JSON.stringify(t);if(n===void 0||o===void 0)return!1;if(Math.abs(n.length-o.length)>2000000)return!1;return n===o}catch{return!1}}function Wy(e){return Boolean(e)&&typeof e==="object"&&e!==null&&!Array.isArray(e)&&"ok"in e&&typeof e.ok==="boolean"}async function FT(e,t){let n=await fetch("/api/canvas/frame-documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:e,sandbox:t})}),o=await n.json();if(!n.ok||!Wy(o)||!o.ok||typeof o.url!=="string"){let r=Wy(o)&&o.error?o.error:`Frame document request failed with HTTP ${n.status}`;throw Error(r)}return o.url}function qy(e,t){let n=ht.value,[o,r]=L(null),[s,a]=L(0),c=N(0);D(()=>{if(r(null),!e||n!=="src")return;let u=!1;return c.current=lo.value,FT(e,t).then((d)=>{if(!u)r(d)}).catch((d)=>{console.error("[iframe-document] failed to create frame document:",d)}),()=>{u=!0}},[e,t,n,s]);let l=lo.value;return D(()=>{if(n!=="src"||l===c.current)return;if(!o){a((d)=>d+1);return}let u=!1;return fetch(o,{method:"HEAD"}).then((d)=>{if(u)return;if(d.ok){c.current=l;return}a((p)=>p+1)}).catch(()=>{}),()=>{u=!0}},[l,o,n]),Ie(()=>{if(n==="srcdoc"&&e)return{attributes:{srcdoc:e},ready:!0,key:`srcdoc-${nr(e)}`};return{attributes:o?{src:o}:{},ready:Boolean(o),key:o??""}},[o,n,e])}function mr(e){let{enabled:t,token:n,nodeId:o,sourceSurface:r,iframeRef:s}=e;D(()=>{if(!t||!n)return;function a(c){if(c.source!==s.current?.contentWindow)return;let l=c.data;if(!l||l.source!==$s||l.token!==n||l.nodeId!==o)return;let u=l.interaction;if(!u||typeof u.type!=="string")return;let d=u.type;as({type:d,sourceNodeId:o,sourceSurface:r,...u.payload&&typeof u.payload==="object"?{payload:u.payload}:{}}).then((p)=>{if(p.ok)qo("context","AX interaction",d,[o]);else qo("remove","AX interaction rejected",p.error??p.code??"",[o]);s.current?.contentWindow?.postMessage({source:Ms,token:n,...l.correlationId?{correlationId:l.correlationId}:{},interaction:{type:d},result:p},"*")})}return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[t,n,o,r])}async function wo(e,t){let o=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();if(!o.ok)throw Error(o.error??`Request failed: ${e}`);return o.result}function _o(e){return/AppleWebKit/.test(e)&&!/Chrome|Chromium|CriOS|Edg|Android/.test(e)}function jT(e){let{userAgent:t,visibilityState:n,rect:o,viewport:r,alreadyRearmed:s}=e;if(s)return!1;if(!_o(t))return!1;if(n!=="hidden")return!1;if(o.width<=0||o.height<=0)return!1;return o.bottom>0&&o.right>0&&o.top<r.height&&o.left<r.width}var ex=1000,Vy=7000;function tt(e,t){if(typeof window>"u")return;let n=window;if(n.__PMX_EXTAPP_LOG??=[],n.__PMX_EXTAPP_LOG.length<500)n.__PMX_EXTAPP_LOG.push({t:Date.now(),nodeId:e,event:t});ZT({t:Date.now(),nodeId:e,event:t})}var Gy=[],Wu=null;function ZT(e){if(Gy.push({...e,...typeof document<"u"?{visibility:document.visibilityState}:{}}),Wu)return;Wu=setTimeout(()=>{Wu=null;let t=Gy.splice(0);if(t.length===0)return;fetch("/api/canvas/debug/ext-app-recovery",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:t})}).catch(()=>{})},1500)}var Xy=Promise.resolve();function Ky(e){Xy=Xy.then(async()=>{if(!e.remount())return;await e.awaitBoot(),await new Promise((t)=>setTimeout(t,ex))}).catch(()=>{})}function HT(e,t){let n=typeof e.data.html==="string"?e.data.html:"",o=typeof e.data.serverName==="string"?e.data.serverName:"",r=typeof e.data.appSessionId==="string"?e.data.appSessionId:"",s=typeof e.data.sessionStatus==="string"?e.data.sessionStatus:"";return`${e.id}:${t}:${o}:${r}:${s}:${n}`}function BT(e,t){if(e==="fullscreen")return{nextMode:"fullscreen",shouldExpand:!t,shouldCollapse:!1};if(e==="inline")return{nextMode:"inline",shouldExpand:!1,shouldCollapse:t};return{nextMode:e,shouldExpand:!1,shouldCollapse:!1}}async function Jy(e,t,n){if(await e.sendToolInput({arguments:t}),n)await e.sendToolResult(n)}function UT(e){return typeof e==="string"&&e.trim().length>0?e.trim():_l}function WT(e,t){return`<script data-pmx-canvas-ax-bridge>
|
|
190
189
|
(function () {
|
|
191
|
-
const PMX_AX_TOKEN = ${JSON.stringify(
|
|
192
|
-
const PMX_AX_NODE_ID = ${JSON.stringify(
|
|
190
|
+
const PMX_AX_TOKEN = ${JSON.stringify(e)};
|
|
191
|
+
const PMX_AX_NODE_ID = ${JSON.stringify(t)};
|
|
193
192
|
window.PMX_AX = window.PMX_AX || {};
|
|
194
193
|
const pending = new Map();
|
|
195
194
|
const ackListeners = [];
|
|
@@ -204,7 +203,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
204
203
|
}, 10000);
|
|
205
204
|
pending.set(correlationId, function (result) { clearTimeout(timer); resolve(result); });
|
|
206
205
|
window.parent.postMessage({
|
|
207
|
-
source: '${
|
|
206
|
+
source: '${$s}',
|
|
208
207
|
token: PMX_AX_TOKEN,
|
|
209
208
|
nodeId: PMX_AX_NODE_ID,
|
|
210
209
|
correlationId: correlationId,
|
|
@@ -217,7 +216,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
217
216
|
};
|
|
218
217
|
window.addEventListener('message', function (event) {
|
|
219
218
|
const m = event.data;
|
|
220
|
-
if (!m || m.source !== '${
|
|
219
|
+
if (!m || m.source !== '${Ms}' || m.token !== PMX_AX_TOKEN) return;
|
|
221
220
|
const result = m.result || { ok: false };
|
|
222
221
|
const resolver = m.correlationId ? pending.get(m.correlationId) : undefined;
|
|
223
222
|
if (resolver) { pending.delete(m.correlationId); resolver(result); }
|
|
@@ -227,45 +226,89 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
227
226
|
try { window.dispatchEvent(new CustomEvent('pmx-ax-ack', { detail: { result: result, interaction: m.interaction || null } })); } catch (e) {}
|
|
228
227
|
});
|
|
229
228
|
})();
|
|
230
|
-
</script>`}function
|
|
229
|
+
</script>`}function qT(e,t){return`<script data-pmx-canvas-boot-beacon>
|
|
231
230
|
(function () {
|
|
232
|
-
var TOKEN = ${JSON.stringify(
|
|
233
|
-
var NODE_ID = ${JSON.stringify(
|
|
234
|
-
window.parent.postMessage({ source: '${
|
|
231
|
+
var TOKEN = ${JSON.stringify(e)};
|
|
232
|
+
var NODE_ID = ${JSON.stringify(t)};
|
|
233
|
+
window.parent.postMessage({ source: '${Os}', token: TOKEN, nodeId: NODE_ID }, '*');
|
|
235
234
|
// Paint-tick answers (Finding N): a double rAF only fires when this frame's
|
|
236
235
|
// rendering pipeline is actually running — a frame whose layer WebKit never
|
|
237
236
|
// composites stays silent, and that silence drives the parent's recovery
|
|
238
237
|
// ladder. One unsolicited tick at boot, then on-demand answers to probes.
|
|
239
|
-
// Content oracle (Finding N, 0.5.
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
|
|
238
|
+
// Content oracle v2 (Finding N, 0.5.1 reopen): a LAID-OUT canvas passed the
|
|
239
|
+
// 0.5.1 oracle even when nothing was ever drawn into it — Excalidraw mounts
|
|
240
|
+
// its canvas element the moment React renders, so blank cream tiles read
|
|
241
|
+
// paint-ok (content-verified), the ladder concluded success, and Retry
|
|
242
|
+
// never engaged (Copilot 0.5.1 report: A/C/E cream with a green trail).
|
|
243
|
+
// The oracle now samples the canvas's PIXELS: a readable main drawing
|
|
244
|
+
// surface with uniform pixels is not content, whatever shell chrome or
|
|
245
|
+
// boilerplate text the document laid out around it.
|
|
246
|
+
function canvasInk(el) {
|
|
245
247
|
try {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
if (!el.width || !el.height) return 'blank';
|
|
249
|
+
var sw = Math.min(96, el.width);
|
|
250
|
+
var sh = Math.min(64, el.height);
|
|
251
|
+
var probe = document.createElement('canvas');
|
|
252
|
+
probe.width = sw;
|
|
253
|
+
probe.height = sh;
|
|
254
|
+
var ctx = probe.getContext('2d', { willReadFrequently: true });
|
|
255
|
+
if (!ctx) return 'unknown';
|
|
256
|
+
ctx.drawImage(el, 0, 0, sw, sh);
|
|
257
|
+
var d = ctx.getImageData(0, 0, sw, sh).data;
|
|
258
|
+
var r = d[0], g = d[1], b = d[2], a = d[3];
|
|
259
|
+
for (var i = 4; i < d.length; i += 4) {
|
|
260
|
+
if (Math.abs(d[i] - r) > 3 || Math.abs(d[i + 1] - g) > 3 || Math.abs(d[i + 2] - b) > 3 || Math.abs(d[i + 3] - a) > 3) return 'ink';
|
|
261
|
+
}
|
|
262
|
+
return 'blank';
|
|
263
|
+
} catch (e) {
|
|
264
|
+
return 'unknown'; // tainted or WebGL-unreadable: pixels cannot be judged
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function contentVerdict() {
|
|
268
|
+
try {
|
|
269
|
+
var canvases = document.querySelectorAll('canvas');
|
|
270
|
+
var blankMain = false;
|
|
271
|
+
var unreadable = false;
|
|
272
|
+
for (var i = 0; i < canvases.length; i++) {
|
|
273
|
+
var r = canvases[i].getBoundingClientRect();
|
|
274
|
+
if (r.width <= 8 || r.height <= 8) continue;
|
|
275
|
+
var ink = canvasInk(canvases[i]);
|
|
276
|
+
if (ink === 'ink') return { content: true, detail: 'ink' };
|
|
277
|
+
if (ink === 'unknown') unreadable = true;
|
|
278
|
+
else if (r.width >= 160 && r.height >= 120) blankMain = true;
|
|
279
|
+
}
|
|
280
|
+
// A readable, never-painted main surface vetoes everything below:
|
|
281
|
+
// toolbar icons and shell text around a blank drawing surface is
|
|
282
|
+
// exactly the false green the human reports as an empty cream tile.
|
|
283
|
+
if (blankMain) return { content: false, detail: 'blank-canvas' };
|
|
284
|
+
if (unreadable) return { content: true, detail: 'canvas-unreadable' };
|
|
285
|
+
var svgs = document.querySelectorAll('svg');
|
|
286
|
+
for (var j = 0; j < svgs.length; j++) {
|
|
287
|
+
var sr = svgs[j].getBoundingClientRect();
|
|
288
|
+
if (sr.width > 8 && sr.height > 8 && svgs[j].querySelector('path, rect, circle, ellipse, line, polyline, polygon, text, image, use')) {
|
|
289
|
+
return { content: true, detail: 'svg' };
|
|
290
|
+
}
|
|
250
291
|
}
|
|
251
292
|
var body = document.body;
|
|
252
|
-
|
|
293
|
+
if (body && body.innerText && body.innerText.trim().length > 0) return { content: true, detail: 'text' };
|
|
294
|
+
return { content: false, detail: 'empty' };
|
|
253
295
|
} catch (e) {
|
|
254
|
-
return false;
|
|
296
|
+
return { content: false, detail: 'probe-error' };
|
|
255
297
|
}
|
|
256
298
|
}
|
|
257
299
|
function sendPaintTick() {
|
|
258
300
|
requestAnimationFrame(function () {
|
|
259
301
|
requestAnimationFrame(function () {
|
|
260
|
-
|
|
302
|
+
var v = contentVerdict();
|
|
303
|
+
window.parent.postMessage({ source: '${Os}', token: TOKEN, nodeId: NODE_ID, kind: 'paint-tick', content: v.content, detail: v.detail }, '*');
|
|
261
304
|
});
|
|
262
305
|
});
|
|
263
306
|
}
|
|
264
307
|
window.addEventListener('message', function (event) {
|
|
265
308
|
var m = event.data;
|
|
266
|
-
if (m && m.source === '${
|
|
309
|
+
if (m && m.source === '${wl}' && m.token === TOKEN) sendPaintTick();
|
|
267
310
|
});
|
|
268
311
|
sendPaintTick();
|
|
269
312
|
})();
|
|
270
|
-
</script>`}function fX(){return"<style data-pmx-canvas-ext-app-base>html, body { background: transparent !important; }</style>"}function EX($,U){if(!U)return $;let v=/<head\b[^>]*>/i.exec($);if(v?.index!==void 0){let _=v.index+v[0].length;return`${$.slice(0,_)}${U}${$.slice(_)}`}let J=/<body\b[^>]*>/i.exec($);if(J?.index!==void 0){let _=J.index+J[0].length;return`${$.slice(0,_)}${U}${$.slice(_)}`}return`${U}${$}`}function F0($,U){if(Number.isFinite($)&&$>0)return Math.round($);if(Number.isFinite(U)&&U>0)return Math.round(U);return 1}function TW($,U){let v=$?.getBoundingClientRect();return{width:F0($?.clientWidth??0,F0(v?.width??0,U.width)),height:F0($?.clientHeight??0,F0(v?.height??0,U.height))}}function $w($,U){return typeof $==="number"&&Number.isFinite($)&&$>0&&!U}function Uw($,U){return Math.max(F0($,1),F0(U,1))}function mX({node:$,expanded:U=!1}){let v=C(null),J=C(null),_=C(null),z=C(null),K=C({}),W=C(void 0),O=C(!1),Y=C(void 0),Z=C(null),q=C(!1),X=C(null),B=C(0),L=C([]),F=C(!1),k=C(!1),H=C([]),P=C(!1),b=C(!1),V=C(!1),E=C(!1),[A,I]=f("loading"),[N,R]=f(null),[p,l]=f(0),[T,r]=f(!1),[t,i]=f(!1),[o,z$]=f(()=>U||typeof navigator>"u"||typeof window>"u"||!n1(navigator.userAgent)),B$=$.data.html,S6=$.data.serverName,N$=$.data.appSessionId,t$=$.data.toolInput??{},O4=$.data.toolResult,A4=$.data.toolName??"ext-app",S=$.data.toolDefinition,e=$.data.toolCallId,H$=typeof e==="string"||typeof e==="number"?e:void 0,K$=$.data.resourceMeta,_$=$.data.sessionStatus,v$=$.data.sessionError,J$=$.size.height,d=$.id,O$=nI($,p),b6=aI(null),Y4=$.data.axCapabilities?.enabled===!0&&typeof B$==="string"&&B$.length>0,M6=u$(()=>`ax-${crypto.randomUUID()}`,[]),y=Y4?sI(M6,d):"",L$=typeof B$==="string"&&B$.length>0?eI(M6,d):"",i$=TX(EX(B$??"",fX()+L$+y),b6);u(()=>{function $$(Z$){if(Z$.source!==v.current?.contentWindow)return;let k$=Z$.data;if(!k$||k$.source!==Fv||k$.token!==M6||k$.nodeId!==d)return;if(k.current=!0,k$.kind==="paint-tick"){let p$=k$.content===!0;for(let U4 of L.current.splice(0))U4(p$)}}return window.addEventListener("message",$$),()=>window.removeEventListener("message",$$)},[M6,d]),u(()=>{if(o)return;jX({remount:()=>{if(E.current)return!1;return W6(d,"mount-slot"),z$(!0),!0},awaitBoot:()=>new Promise(($$)=>{let Z$=window.setTimeout(k$,yX);function k$(){window.clearTimeout(Z$),$$()}H.current.push(k$)})})},[]),L0({enabled:Y4,token:M6,nodeId:d,sourceSurface:"mcp-app",iframeRef:v});let y$=3,Z4=($$)=>{if(B.current>=y$)return W6(d,`remount-cap-hit (${$$})`),!1;if(P.current)return!0;return B.current+=1,P.current=!0,W6(d,`remount-queued #${B.current} (${$$})`),jX({remount:()=>{if(P.current=!1,E.current||!U&&n$.value===d)return W6(d,"remount-skipped"),r(!1),!1;return b.current=typeof document<"u"&&document.visibilityState==="hidden",W6(d,`remount-run #${B.current}`),I("loading"),l((Z$)=>Z$+1),!0},awaitBoot:()=>new Promise((Z$)=>{let k$=window.setTimeout(p$,yX);function p$(){window.clearTimeout(k$),Z$()}H.current.push(p$)})}),!0},B2=1500,q4=()=>new Promise(($$)=>{let Z$=v.current?.contentWindow;if(!Z$||E.current){$$("timeout");return}let k$=!1,p$=window.setTimeout(()=>{if(k$)return;k$=!0,$$("timeout")},B2);L.current.push((U4)=>{if(k$)return;k$=!0,window.clearTimeout(p$),$$(U4?"content-verified":"tick-no-content")}),Z$.postMessage({source:O5,token:M6},"*")}),I4=async($$)=>{let Z$=Date.now()+$$;while(Date.now()<Z$&&!E.current){if(await q4()==="content-verified")return!0;await new Promise((k$)=>window.setTimeout(k$,400))}return!1},XL=()=>new Promise(($$)=>{let Z$=v.current;if(!Z$){$$();return}let k$=Z$.style.width,p$=Z$.style.height;Z$.style.width="140%",Z$.style.height="140%",requestAnimationFrame(()=>{requestAnimationFrame(()=>{Z$.style.width=k$,Z$.style.height=p$,W6(d,"soft-expand-cycle"),$$()})})}),HL=600,X2=()=>{if(typeof document>"u"||typeof navigator>"u"||typeof window>"u")return;let $$=v.current;if(!$$||E.current)return;if(!oI({userAgent:navigator.userAgent,visibilityState:document.visibilityState,rect:$$.getBoundingClientRect(),viewport:{width:window.innerWidth,height:window.innerHeight},alreadyRearmed:V.current}))return;V.current=!0,window.setTimeout(()=>{if(E.current||document.visibilityState==="visible")return;B.current=0,i(!1),b.current=!1,W6(d,"assume-visible-rearm"),Z4("assume-visible")},HL)},_8=($$="")=>typeof document<"u"&&document.visibilityState==="hidden"?`paint-ok (content-verified)${$$} (host hidden)`:`paint-ok (content-verified)${$$}`,QL=async()=>{if(typeof navigator>"u"||typeof window>"u")return;if(!n1(navigator.userAgent))return;r(!0);let $$=await q4();if($$==="content-verified"){W6(d,_8()),r(!1),X2();return}if(W6(d,$$==="tick-no-content"?"paint-fail (tick without content)":"paint-fail (no tick)"),await XL(),$$=await q4(),$$==="content-verified"){W6(d,_8(" (after soft-expand)")),r(!1),X2();return}if(E.current)return;if($$==="tick-no-content"&&await I4(3000)){W6(d,_8(" (after content wait)")),r(!1),X2();return}if(E.current)return;if(!Z4("paint-fail"))W6(d,"recovery-exhausted"),r(!1),i(!0),X2()};u(()=>{if(U)return;if(typeof document>"u"||typeof navigator>"u"||typeof window>"u")return;if(!n1(navigator.userAgent))return;function $$(){if(document.visibilityState!=="visible")return;if(!b.current||E.current)return;b.current=!1,B.current=0,i(!1),W6(d,"visible-again-rearm"),Z4("visible-after-hidden-boot")}return document.addEventListener("visibilitychange",$$),()=>document.removeEventListener("visibilitychange",$$)},[U,d]);let LL=6000;u(()=>{if(typeof navigator>"u"||typeof window>"u")return;if(!n1(navigator.userAgent))return;if(!i$.ready||!o)return;let $$=window.setTimeout(()=>{if(F.current||k.current||E.current)return;Z4("boot-watchdog")},LL);return()=>window.clearTimeout($$)},[O$,i$.ready,U,o]),u(()=>()=>{E.current=!0;for(let $$ of H.current.splice(0))$$();for(let $$ of L.current.splice(0))$$(!1)},[]);let v8=($$)=>jU($$),p4=U||n$.value===d;K.current=t$,W.current=O4;let H2=_$==="error"&&typeof B$==="string"&&B$.length>0,J8=_$==="error"?H2?`Live session unavailable — showing saved content. Reopen the app to restore interactivity.${v$?` (${v$})`:""}`:v$??"Saved app session is unavailable. Reopen the app to restore interactivity.":"Reconnecting saved app session...",z8=($$)=>{let Z$=W.current;if(!$$||!q.current||!Z$)return null;if(Y.current===Z$)return null;if(Y.current&&SX(Y.current,Z$))return Y.current=Z$,null;if(Z.current)return Z.current;let k$=$$.sendToolResult(Z$).then(()=>{Y.current=Z$,O.current=!0,I("done")}).catch((p$)=>{let U4=p$ instanceof Error?p$.message:String(p$);throw R(`Tool result delivery failed: ${U4}`),p$}).finally(()=>{Z.current=null});return Z.current=k$,k$};if(u(()=>{if(!B$||!i$.ready||!o)return;let $$=v.current;if(!$$)return;let Z$=!1,k$=null,p$=null,U4=null,zU=null,S1=null;O.current=!1,Y.current=void 0,Z.current=null,q.current=!1,F.current=!1,k.current=!1;let Q2=()=>{if(!k$)return;clearTimeout(k$),k$=null};return(async()=>{if(!B$)return;let o4=$$.contentWindow;if(!o4)throw Error("Ext-app iframe window is unavailable");let R1=(F$=n$.value===d?"fullscreen":"inline")=>({theme:v8($6.value),platform:"web",containerDimensions:TW($$,{width:$.size.width,height:J$}),displayMode:F$,locale:navigator.language,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,...S?{toolInfo:{id:H$,tool:S}}:{}}),FL=()=>{if(zU!==null)return;zU=requestAnimationFrame(()=>{if(zU=null,Z$||!q.current)return;h$.setHostContext?.(R1())})},MO=()=>{if(S1!==null)return;S1=requestAnimationFrame(()=>{S1=requestAnimationFrame(()=>{if(S1=null,Z$||!q.current)return;h$.sendHostContextChange?.(R1())})})},AO=()=>{if(!n1(navigator.userAgent))return;if(p$)clearTimeout(p$);p$=setTimeout(()=>{if(p$=null,Z$)return;QL()},uX+200)},h$=new gW(null,{name:"PMX Canvas",version:"1.0.0"},{openLinks:{},serverTools:{listChanged:!1},serverResources:{listChanged:!1},logging:{},updateModelContext:{text:{},structuredContent:{}}},{hostContext:R1(p4?"fullscreen":"inline")});h$.onsizechange=async({height:F$})=>{if($w(F$,n$.value===d)){let z6=TW($$.parentElement??$$,{width:$.size.width,height:J$}),p6=Uw(F$,z6.height);$$.style.height=`${p6}px`;let T1=D.value.get(d)?.size??$.size,wO=Math.max(T1.height,p6+TU);if(Math.abs(wO-T1.height)>8){if(IU(d,{width:T1.width,height:wO}),z.current!==null)window.clearTimeout(z.current);z.current=window.setTimeout(()=>{v6({recordHistory:!1}),z.current=null},0)}}return{}},h$.onopenlink=async({url:F$})=>{return window.open(F$,"_blank","noopener"),{}},h$.onsandboxready=async()=>{await h$.sendSandboxResourceReady({html:EX(B$,fX()),sandbox:Y5,...K$?.csp?{csp:K$.csp}:{},...K$?.permissions?{permissions:K$.permissions}:{}})},h$.onrequestdisplaymode=async({mode:F$})=>{let{nextMode:z6,shouldExpand:p6,shouldCollapse:T1}=tI(F$,p4);if(p6)Q4(d);else if(T1)m1();return{mode:z6}},h$.oncalltool=async(F$)=>{if(!N$)throw Error(J8);try{let z6=await d1("/api/ext-app/call-tool",{sessionId:N$,nodeId:d,serverName:S6,toolName:F$.name,arguments:F$.arguments??{}});return R(null),z6}catch(z6){let p6=z6 instanceof Error?z6.message:String(z6);throw R(`Tool call failed: ${p6}`),z6}},h$.setRequestHandler(n_,async()=>{if(!N$)return{tools:[]};return d1("/api/ext-app/list-tools",{sessionId:N$})}),h$.onlistresources=async()=>N$?d1("/api/ext-app/list-resources",{sessionId:N$}):{resources:[]},h$.onlistresourcetemplates=async()=>N$?d1("/api/ext-app/list-resource-templates",{sessionId:N$}):{resourceTemplates:[]},h$.onreadresource=async(F$)=>{if(!N$)throw Error(J8);return d1("/api/ext-app/read-resource",{sessionId:N$,uri:F$.uri})},h$.onlistprompts=async()=>N$?d1("/api/ext-app/list-prompts",{sessionId:N$}):{prompts:[]},h$.onupdatemodelcontext=async(F$)=>{if(!N$)return{};return await d1("/api/ext-app/model-context",{nodeId:d,...Array.isArray(F$.content)?{content:F$.content}:{},...F$.structuredContent&&typeof F$.structuredContent==="object"?{structuredContent:F$.structuredContent}:{}}),{}};let K8=new B9(o4,o4);if(h$.oninitialized=()=>{if(Z$)return;Q2(),q.current=!0,F.current=!0,W6(d,"initialized"),I("ready"),R(null),Promise.resolve(h$.sendHostContextChange(R1(p4?"fullscreen":"inline"))).then(()=>VX(h$,K.current,void 0)).then(()=>z8(h$)).then(()=>{let F$=()=>{for(let z6 of H.current.splice(0))z6()};if(typeof navigator<"u"&&n1(navigator.userAgent))I4(4000).then((z6)=>{W6(d,z6?"settled (content-verified)":"settled (content-timeout)"),F$()});else W6(d,"settled"),F$();MO(),AO()}).catch((F$)=>{let z6=F$ instanceof Error?F$.message:String(F$);R(`Bridge bootstrap failed: ${z6}`)})},k$=setTimeout(()=>{if(Z$||q.current)return;let F$=W.current,z6=R1(p4?"fullscreen":"inline");q.current=!0,h$.setHostContext?.(z6),Promise.resolve(h$.sendHostContextChange(z6)).then(()=>VX(h$,K.current,F$)).then(()=>{if(O.current=Boolean(F$),F$)Y.current=F$;if(I(F$?"done":"ready"),R(null),MO(),AO(),k.current){W6(d,"settled (fallback)");for(let p6 of H.current.splice(0))p6()}}).catch((p6)=>{let T1=p6 instanceof Error?p6.message:String(p6);R(`Bridge bootstrap fallback failed: ${T1}`)})},1200),await h$.connect(K8),Z$){Q2(),await K8.close();return}if(J.current=h$,_.current=K8,U4=new ResizeObserver(FL),U4.observe($$),$$.parentElement)U4.observe($$.parentElement);let IO=!0;X.current=$6.subscribe((F$)=>{if(IO){IO=!1;return}if(Z$)return;h$.setHostContext?.({...R1(),theme:v8(F$)}),h$.sendHostContextChange?.(R1())}),z8(h$)})().catch((o4)=>{Q2(),console.error("[ext-app] Bridge init failed:",o4),R(o4?.message??"Bridge initialization failed")}),()=>{if(Z$=!0,Q2(),p$)clearTimeout(p$),p$=null;if(U4?.disconnect(),U4=null,zU!==null)cancelAnimationFrame(zU),zU=null;if(S1!==null)cancelAnimationFrame(S1),S1=null;if(q.current=!1,Z.current=null,X.current?.(),X.current=null,z.current!==null)window.clearTimeout(z.current),z.current=null;if(J.current=null,_.current)_.current.close().catch((o4)=>{console.error("[ext-app] transport close failed:",o4)}),_.current=null}},[O$,i$.key,o]),u(()=>{if(O4&&J.current&&(A==="ready"||A==="done"))z8(J.current)},[O4,A]),u(()=>{let $$=J.current;if(v.current)v.current.style.height="100%";if(!$$||!q.current)return;let Z$=null,k$=null;return Z$=requestAnimationFrame(()=>{Z$=null,k$=requestAnimationFrame(()=>{if(k$=null,!q.current)return;let p$={theme:v8($6.value),platform:"web",containerDimensions:TW(v.current,{width:$.size.width,height:J$}),displayMode:p4?"fullscreen":"inline",locale:navigator.language,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};$$.setHostContext?.(p$),$$.sendHostContextChange?.(p$)})}),()=>{if(Z$!==null)cancelAnimationFrame(Z$);if(k$!==null)cancelAnimationFrame(k$)}},[p4,J$]),!B$)return G("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--c-muted)",fontSize:"13px",flexDirection:"column",gap:"8px"},children:[G("div",{style:{opacity:0.6},children:["Loading ",A4," viewer..."]},void 0,!0,void 0,this),G("div",{style:{width:"24px",height:"24px",border:"2px solid var(--c-line)",borderTopColor:"var(--c-muted)",borderRadius:"50%",animation:"spin 1s linear infinite"}},void 0,!1,void 0,this),G("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("div",{style:{flex:1,width:"100%",height:"100%",minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[_$&&_$!=="ready"&&G("div",{style:{padding:"6px 10px",fontSize:"11px",background:_$==="error"&&!H2?"var(--c-danger-12)":"var(--c-warn-10)",color:_$==="error"&&!H2?"var(--c-danger)":"var(--c-warn)",borderBottom:`1px solid ${_$==="error"&&!H2?"var(--c-danger-12)":"var(--c-warn-15)"}`},children:J8},void 0,!1,void 0,this),N&&G("div",{style:{padding:"6px 10px",fontSize:"11px",background:"var(--c-danger-12)",color:"var(--c-danger)",borderBottom:"1px solid var(--c-danger-12)",display:"flex",alignItems:"center",gap:"6px"},children:[G("span",{children:"⚠"},void 0,!1,void 0,this),G("span",{style:{flex:1},children:N},void 0,!1,void 0,this),G("button",{type:"button",onClick:()=>{R(null),I("loading"),l(($$)=>$$+1)},style:{background:"var(--c-surface-hover)",border:"1px solid var(--c-danger-12)",borderRadius:"3px",color:"var(--c-danger)",cursor:"pointer",fontSize:"10px",padding:"1px 6px"},children:"Retry"},void 0,!1,void 0,this),G("button",{type:"button",onClick:()=>R(null),style:{background:"none",border:"none",color:"var(--c-danger)",cursor:"pointer",fontSize:"13px",padding:"0 2px"},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{style:{flex:1,position:"relative",display:"flex",minHeight:0,height:"100%"},children:[o&&G("iframe",{ref:v,...i$.attributes,sandbox:b6,allow:NX(K$?.permissions),style:{flex:1,width:"100%",height:"100%",minHeight:0,border:"none",background:"var(--c-panel)",pointerEvents:p4&&A!=="loading"?"auto":"none"},title:`Ext App: ${A4}`},O$,!1,void 0,this),t&&!N&&G("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",background:"var(--c-panel)",color:"var(--c-warn)",fontSize:"12px"},children:[G("div",{children:"App surface failed to paint."},void 0,!1,void 0,this),G("button",{type:"button",onClick:($$)=>{$$.stopPropagation(),W6(d,"manual-retry"),B.current=0,i(!1),I("loading"),l((Z$)=>Z$+1)},style:{background:"var(--c-surface-hover)",border:"1px solid var(--c-warn-15)",borderRadius:"4px",color:"var(--c-warn)",cursor:"pointer",fontSize:"11px",padding:"3px 10px"},children:"Retry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(A==="loading"||T)&&!N&&!t&&G("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",background:"var(--c-panel)",color:"var(--c-muted)",fontSize:"12px",pointerEvents:"none"},children:[G("div",{style:{width:"22px",height:"22px",border:"2px solid var(--c-line)",borderTopColor:"var(--c-muted)",borderRadius:"50%",animation:"spin 1s linear infinite"}},void 0,!1,void 0,this),G("div",{children:A==="loading"?`Connecting to ${A4}...`:"Finishing paint..."},void 0,!1,void 0,this),G("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!p4&&!(t&&!N)&&G("button",{type:"button",onClick:($$)=>{$$.stopPropagation(),Q4(d)},class:"ext-app-preview-catcher",title:"Click to open",style:{position:"absolute",top:0,right:"56px",bottom:"56px",left:0,background:"transparent",border:"none",padding:0,margin:0,cursor:"zoom-in"},"aria-label":"Open full view to edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function _w($,U,v,J,_,z,K){if(!$)return $;try{let W=new URL($,window.location.origin);if(W.searchParams.set("theme",jU($6.value)),U)W.searchParams.set("display","expanded");if(typeof v==="number")W.searchParams.set("v",String(v));if(J)W.searchParams.set("axToken",J);if(_)W.searchParams.set("axNodeId",_);if(z)W.searchParams.set("frameToken",z);if(K)W.searchParams.set("fit","content");return W.toString()}catch{return $}}function vw($,U=window.location.origin){if(!$)return!1;try{let v=new URL(U).origin,J=new URL($,v);return J.origin===v&&J.pathname.startsWith("/api/canvas/frame-documents/")}catch{return!1}}function L1({node:$,expanded:U=!1}){if($.data.mode==="ext-app")return G(mX,{node:$,expanded:U},void 0,!1,void 0,this);return G(Jw,{node:$,expanded:U},void 0,!1,void 0,this)}function Jw({node:$,expanded:U}){let v=C(null),J=$.type==="mcp-app"&&$.data.viewerType==="web-artifact",_=$.type==="json-render"||$.type==="graph",z=$.data.axCapabilities?.enabled,W=(_||J)&&(J?z===!0:z!==!1),O=J?"mcp-app":"json-render",Y=u$(()=>W?`ax-${crypto.randomUUID()}`:"",[W]),Z=q5($)&&!U,q=u$(()=>Z?`frame-${crypto.randomUUID()}`:"",[Z]);yU($,v,q),L0({enabled:W&&Boolean(Y),token:Y,nodeId:$.id,sourceSurface:O,iframeRef:v});let X=G4.value,B=()=>{if(!W||!Y||X==null)return;v.current?.contentWindow?.postMessage({source:t6,type:"ax-update",token:Y,state:X},"*")};u(B,[W,Y,X]);let L=typeof $.data.specVersion==="number"?$.data.specVersion:void 0,F=_w($.data.url||"",U,L,Y||void 0,W?$.id:void 0,q||void 0,Z),k=CU(F),H=$.data.sourceServer||"",P=$.data.hostMode||"hosted",b=$.data.fallbackReason,V=$.data.trustedDomain===!0||vw(F);if(P==="fallback")return G("div",{style:{display:"flex",flexDirection:"column",gap:"8px",fontSize:"12px"},children:[G("div",{style:{color:"var(--c-warn)",display:"flex",alignItems:"center",gap:"6px"},children:[G("span",{children:"⚠"},void 0,!1,void 0,this),G("span",{children:"Cannot embed — opened externally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&G("div",{style:{color:"var(--c-muted)",fontSize:"11px"},children:["Reason: ",b]},void 0,!0,void 0,this),G("a",{href:F,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--c-accent)",fontSize:"12px",wordBreak:"break-all"},children:F},void 0,!1,void 0,this),H&&G("div",{style:{color:"var(--c-dim)",fontSize:"10px"},children:["Source: ",H]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return G("div",{style:{height:"100%",display:"flex",flexDirection:"column",...U?{flex:1,minHeight:0,width:"100%"}:{}},children:[!V&&G("div",{style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-warn-10)",color:"var(--c-warn)",borderBottom:"1px solid var(--c-warn-15)"},children:"Unverified domain"},void 0,!1,void 0,this),G("iframe",{ref:v,...k,class:"mcp-app-frame",sandbox:"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",allow:"clipboard-read; clipboard-write",loading:w6.value==="srcdoc"?void 0:"lazy",onLoad:B,style:{flex:1,minHeight:0,width:"100%"},title:`MCP App: ${H}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var zw=null;function P0(){zw=null}var xX={idle:"var(--c-muted)",running:"var(--c-accent)",planning:"var(--c-thinking)",thinking:"var(--c-thinking)",drafting:"var(--c-accent)",tooling:"var(--c-accent)",review:"var(--c-ok)","waiting-approval":"var(--c-warn)",waiting:"var(--c-warn-alt)"};function Kw($){let U=typeof $.data.phase==="string"&&$.data.phase.trim().length>0?$.data.phase.trim():"";if(U)return U;let v=typeof $.data.content==="string"&&$.data.content.trim().length>0?$.data.content.trim():"";if(v)return v;return(typeof $.data.status==="string"&&$.data.status.trim().length>0?$.data.status.trim():"")||"idle"}function X9({node:$}){let U=Kw($),v=$.data.detail||"",J=$.data.message||"",_=$.data.level||"ok",z=$.data.activeTool,K=$.data.subagent,W=xX[U]??"var(--c-muted)",O=U!=="idle";return G("div",{style:{display:"flex",flexDirection:"column",gap:"8px",fontSize:"12px"},children:[G("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[G("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:W,boxShadow:O?`0 0 8px ${W}`:"none",animation:O?"pulse 1.5s infinite":"none",flexShrink:0}},void 0,!1,void 0,this),G("span",{style:{fontWeight:600,color:W,textTransform:"uppercase",letterSpacing:"0.05em"},children:U},void 0,!1,void 0,this),v&&G("span",{style:{color:"var(--c-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z&&G("div",{style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--c-warn)"},children:[G("span",{style:{fontSize:"10px"},children:"⚙"},void 0,!1,void 0,this),G("span",{style:{fontFamily:"var(--mono)",fontSize:"11px"},children:z},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&K.state!=="completed"&&G("div",{style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--c-subagent)"},children:[G("span",{style:{fontSize:"10px"},children:"⠉"},void 0,!1,void 0,this),G("span",{children:K.name},void 0,!1,void 0,this),G("span",{style:{color:"var(--c-muted)",fontSize:"10px"},children:["(",K.state,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),J&&G("div",{style:{color:_==="warn"?"var(--c-warn)":_==="error"?"var(--c-danger)":"var(--c-muted)",lineHeight:1.4},children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function k0($){return typeof $==="string"&&$.trim().length>0?$.trim():null}function hX($){if(typeof $==="string"){let _=k0($);return _?{title:"Evidence warning",detail:_}:null}if(!$||typeof $!=="object")return null;let U=$,v=k0(U.title)??"Evidence warning",J=k0(U.detail);return J?{title:v,detail:J}:null}function Gw($){let U=[],v=hX($.data.warning);if(v)U.push(v);let J=$.data.warnings;if(Array.isArray(J))for(let z of J){let K=hX(z);if(K)U.push(K)}let _=k0($.data.validationStatus)?.toLowerCase();if(_==="failed"||_==="invalid")U.push({title:"Image failed validation",detail:k0($.data.validationMessage)??"Review this image before using it as evidence."});return U}function Ww($){let U=[$.data.title,$.data.caption,$.data.alt,$.data.src,$.data.path].map((v)=>k0(v)?.toLowerCase()??"").join(" ");if(U.length===0)return!1;return["login","log in","sign in","signin","password","2fa","mfa","authenticate","authentication","sso"].some((v)=>U.includes(v))}function cX($){let U=Gw($);if(U.length>0)return U;if(Ww($))return[{title:"Captured login page",detail:"This image looks like an auth screen. Treat it as environment context, not product evidence."}];return[]}function H9({node:$,expanded:U=!1}){let v=$.data.src||"",J=$.data.alt||$.data.title||"Image",_=$.data.caption||"",z=cX($),K=v.startsWith("data:")||v.startsWith("http://")||v.startsWith("https://")?v:`/api/canvas/image/${$.id}`,[W,O]=f(!1),[Y,Z]=f(!1),[q,X]=f(1),[B,L]=f({x:0,y:0}),[F,k]=f({w:0,h:0}),H=C(null),P=C(!1),b=C({x:0,y:0}),V=j((r)=>{let t=r.target;k({w:t.naturalWidth,h:t.naturalHeight}),O(!0),Z(!1)},[]),E=j(()=>{Z(!0),O(!1)},[]);u(()=>{X(1),L({x:0,y:0})},[v]);let A=j((r)=>{r.preventDefault(),r.stopPropagation();let t=r.deltaY>0?0.9:1.1;X((i)=>Math.max(0.25,Math.min(10,i*t)))},[]),I=j((r)=>{if(q<=1)return;r.stopPropagation(),P.current=!0,b.current={x:r.clientX,y:r.clientY},r.target.setPointerCapture(r.pointerId)},[q]),N=j((r)=>{if(!P.current)return;let t=r.clientX-b.current.x,i=r.clientY-b.current.y;b.current={x:r.clientX,y:r.clientY},L((o)=>({x:o.x+t,y:o.y+i}))},[]),R=j(()=>{P.current=!1},[]),p=j(()=>{X(1),L({x:0,y:0})},[]);if(!v)return G("div",{class:"image-node-empty",children:[G("div",{class:"image-node-empty-icon",children:"\uD83D\uDDBC"},void 0,!1,void 0,this),G("div",{class:"image-node-empty-text",children:"No image source"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let l=F.w>0?`${F.w}×${F.h}`:"",T=Math.round(q*100);return G("div",{class:`image-node ${U?"image-node-expanded":""}`,ref:H,children:[z.length>0&&G("div",{class:"image-node-warning-stack",children:z.map((r)=>G("div",{class:"image-node-warning",children:[G("span",{class:"image-node-warning-title",children:r.title},void 0,!1,void 0,this),G("span",{class:"image-node-warning-detail",children:r.detail},void 0,!1,void 0,this)]},`${r.title}-${r.detail}`,!0,void 0,this))},void 0,!1,void 0,this),G("div",{class:"image-node-viewport",onWheel:A,onPointerDown:I,onPointerMove:N,onPointerUp:R,style:{cursor:q>1?"grab":"default"},children:[!W&&!Y&&G("div",{class:"image-node-loading",children:"Loading…"},void 0,!1,void 0,this),Y&&G("div",{class:"image-node-error",children:[G("div",{class:"image-node-error-icon",children:"⚠"},void 0,!1,void 0,this),G("div",{children:"Failed to load image"},void 0,!1,void 0,this),G("div",{class:"image-node-error-path",children:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("img",{src:K,alt:J,onLoad:V,onError:E,draggable:!1,style:{transform:`translate(${B.x}px, ${B.y}px) scale(${q})`,opacity:W?1:0,display:Y?"none":"block"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(_||l||q!==1)&&G("div",{class:"image-node-footer",children:[_&&G("span",{class:"image-node-caption",children:_},void 0,!1,void 0,this),G("span",{class:"image-node-meta",children:[l&&G("span",{children:l},void 0,!1,void 0,this),q!==1&&G("button",{type:"button",class:"image-node-zoom-reset",onClick:p,title:"Reset zoom",children:[T,"% ↺"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function lX({node:$}){if(($.data.children??[]).filter((J)=>D.value.has(J)).length>0)return null;return G("div",{class:"group-empty-hint",children:"Drop nodes here — release while the frame lights up to add them"},void 0,!1,void 0,this)}function Ow($){try{return new URL($).host}catch{return $}}function Yw($){if(!$)return null;let U=new Date($);return Number.isNaN(U.getTime())?null:U.toLocaleString()}function Q9({node:$,expanded:U=!1}){let v=typeof $.data.url==="string"?$.data.url:"",J=typeof $.data.pageTitle==="string"?$.data.pageTitle:"",_=typeof $.data.description==="string"?$.data.description:"",z=typeof $.data.excerpt==="string"?$.data.excerpt:typeof $.data.content==="string"?$.data.content:"",K=typeof $.data.status==="string"?$.data.status:"idle",W=typeof $.data.error==="string"?$.data.error:"",O=Yw(typeof $.data.fetchedAt==="string"?$.data.fetchedAt:void 0),Y=typeof $.data.statusCode==="number"?$.data.statusCode:null,Z=typeof $.data.imageUrl==="string"?$.data.imageUrl:"",q=$.data.frameBlocked===!0,X=typeof $.data.frameBlockedReason==="string"?$.data.frameBlockedReason:"",[B,L]=f(!1),[F,k]=f(U);u(()=>{if(U)k(!0)},[U]);let H=j(async()=>{if(!v||B)return;L(!0);try{await c2($.id)}finally{L(!1)}},[$.id,B,v]);if(!v)return G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No webpage URL set"},void 0,!1,void 0,this);let P=K==="ready"?"var(--c-ok)":K==="error"?"var(--c-danger)":"var(--c-warn)";return G("div",{style:{display:"flex",flexDirection:"column",gap:"12px",height:"100%"},children:[G("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[G("div",{style:{minWidth:0,flex:1},children:[G("div",{style:{fontSize:"12px",color:"var(--c-muted)"},children:Ow(v)},void 0,!1,void 0,this),G("div",{style:{fontSize:U?"18px":"15px",fontWeight:700,color:"var(--c-text)"},children:J||$.data.title||v},void 0,!1,void 0,this),G("a",{href:v,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--c-accent)",fontSize:"12px",wordBreak:"break-all",textDecoration:"none"},children:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"999px",background:"rgba(255,255,255,0.04)",color:P,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.04em",flexShrink:0},children:[G("span",{style:{width:"7px",height:"7px",borderRadius:"999px",background:P}},void 0,!1,void 0,this),K]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),(_||Z)&&G("div",{style:{display:"grid",gridTemplateColumns:Z&&U?"160px 1fr":"1fr",gap:"12px",alignItems:"start"},children:[Z&&U&&G("img",{src:Z,alt:J||"Webpage preview image",style:{width:"160px",height:"96px",objectFit:"cover",borderRadius:"10px",border:"1px solid var(--c-line)",background:"var(--c-panel-soft)"}},void 0,!1,void 0,this),_&&G("p",{style:{margin:0,color:"var(--c-text-soft)",lineHeight:1.5,fontSize:U?"14px":"12px"},children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[G("button",{type:"button",onClick:H,disabled:B,style:{border:"1px solid var(--c-line)",background:"var(--c-panel-soft)",color:"var(--c-text)",borderRadius:"8px",padding:"6px 10px",cursor:B?"progress":"pointer",fontSize:"12px"},children:B||K==="fetching"?"Refreshing…":"Refresh"},void 0,!1,void 0,this),U&&!q&&G("button",{type:"button",onClick:()=>k((b)=>!b),style:{border:"1px solid var(--c-line)",background:"var(--c-panel-soft)",color:"var(--c-text)",borderRadius:"8px",padding:"6px 10px",cursor:"pointer",fontSize:"12px"},children:F?"Hide live preview":"Show live preview"},void 0,!1,void 0,this),G("button",{type:"button",onClick:()=>window.open(v,"_blank","noopener"),style:{border:"1px solid var(--c-line)",background:"transparent",color:"var(--c-accent)",borderRadius:"8px",padding:"6px 10px",cursor:"pointer",fontSize:"12px"},children:"Open in browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&q&&G("div",{style:{border:"1px solid var(--c-line)",borderRadius:"12px",overflow:"hidden",background:"var(--c-panel-soft)"},children:[G("div",{style:{padding:"8px 12px",fontSize:"11px",color:"var(--c-muted)",borderBottom:"1px solid var(--c-line)",background:"rgba(255,255,255,0.03)"},children:"Live preview unavailable. This site refuses embedding, so PMX Canvas cannot show it inline."},void 0,!1,void 0,this),G("div",{style:{padding:"20px",color:"var(--c-text-soft)",lineHeight:1.6,fontSize:"13px"},children:X||"The remote site blocks iframe embedding."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&F&&!q&&G("div",{style:{border:"1px solid var(--c-line)",borderRadius:"12px",overflow:"hidden",background:"var(--c-panel-soft)"},children:[G("div",{style:{padding:"8px 12px",fontSize:"11px",color:"var(--c-muted)",borderBottom:"1px solid var(--c-line)",background:"rgba(255,255,255,0.03)"},children:"Live preview (best effort). If this stays blank, the site likely blocks framing. The cached text snapshot below still works."},void 0,!1,void 0,this),G("iframe",{class:"webpage-node-iframe",title:J||$.data.title||v,src:v,loading:"lazy",referrerPolicy:"no-referrer",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts",style:{display:"block",width:"100%",height:U?"320px":"180px",border:"none",background:"#fff"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(O||Y!==null)&&G("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",color:"var(--c-muted)",fontSize:"11px"},children:[O&&G("span",{children:["Fetched ",O]},void 0,!0,void 0,this),Y!==null&&G("span",{children:["HTTP ",Y]},void 0,!0,void 0,this),q&&G("span",{children:"Preview blocked by site"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W&&G("div",{style:{color:"var(--c-danger)",fontSize:"12px",lineHeight:1.5},children:W},void 0,!1,void 0,this),G("div",{style:{flex:1,minHeight:0,overflow:"auto",border:"1px solid var(--c-line)",borderRadius:"10px",background:"var(--c-panel-soft)",padding:U?"14px":"10px"},children:z?G("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.55,color:"var(--c-text)",fontSize:U?"14px":"12px"},children:z},void 0,!1,void 0,this):G("div",{style:{color:"var(--c-dim)",fontStyle:"italic"},children:K==="error"?"No cached page text available.":"Waiting for page text..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function rX($){return $.type==="html"&&$.data.presentation===!0}function $2({node:$,expanded:U=!1,presentation:v=!1,presentationExitToken:J,autoFocus:_=!1}){let z=C(null),K=$6.value,W=u$(()=>`theme-${crypto.randomUUID()}`,[]),O=u$(()=>`ax-${crypto.randomUUID()}`,[]),Y=u$(()=>`frame-${crypto.randomUUID()}`,[]),Z=typeof $.data.html==="string"?$.data.html:typeof $.data.content==="string"?$.data.content:"",q=u$(()=>RU(Z),[Z]),X=u$(()=>Z?s0($.id,{theme:K,themeToken:W,present:v,presentToken:J,v:q,axToken:O,frameToken:Y}):"",[Z,v,J,W,q,$.id,O,Y]),B=CU(X);yU($,z,U?"":Y),L0({enabled:!0,token:O,nodeId:$.id,sourceSurface:"html-node",iframeRef:z}),u(()=>{if(z.current?.contentWindow?.postMessage({source:t6,type:"theme-update",token:W,theme:K},"*"),_)z.current?.focus()},[K,W]);let L=$.data.axCapabilities,F=L?.enabled===!0&&(!Array.isArray(L.allowed)||L.allowed.length>0),k=G4.value;u(()=>{if(!F||k==null)return;z.current?.contentWindow?.postMessage({source:t6,type:"ax-update",token:O,state:k},"*")},[F,k,O]),u(()=>{if(!_)return;let P=window.setTimeout(()=>z.current?.focus(),0);return()=>window.clearTimeout(P)},[_,X]);let H=()=>{if(z.current?.contentWindow?.postMessage({source:t6,type:"theme-update",token:W,theme:K},"*"),F&&G4.value!=null)z.current?.contentWindow?.postMessage({source:t6,type:"ax-update",token:O,state:G4.value},"*");if(_)z.current?.focus()};if(!Z)return G("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No HTML content set"},void 0,!1,void 0,this);return G("iframe",{ref:z,class:v?"html-node-frame html-node-frame-presentation":"html-node-frame",title:typeof $.data.title==="string"?$.data.title:"HTML node",sandbox:"allow-scripts",...B,tabIndex:_?0:void 0,onLoad:H,style:{width:"100%",height:"100%",minHeight:v?0:U?"70vh":"300px",border:"none",background:"var(--c-bg)",borderRadius:v?0:"6px",display:"block"}},void 0,!1,void 0,this)}var yW=null;async function iX(){if(!yW)yW=await PY();return yW}function pX($,U){if(!$)return null;let v=$.toLowerCase(),J=U.find((z)=>z.name.toLowerCase()===v);if(J)return J.name;let _=U.filter((z)=>z.name.toLowerCase().startsWith(v));return _.length===1?_[0].name:null}function Zw($){return $.replace(/<script[\s>][\s\S]*?<\/script>/gi,"").replace(/<iframe[\s>][\s\S]*?<\/iframe>/gi,"").replace(/<object[\s>][\s\S]*?<\/object>/gi,"").replace(/<embed[\s>][\s\S]*?(?:\/>|<\/embed>)/gi,"").replace(/<link[\s>][\s\S]*?(?:\/>|<\/link>)/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/href\s*=\s*"javascript:[^"]*"/gi,'href="#"').replace(/href\s*=\s*'javascript:[^']*'/gi,"href='#'")}function qw({html:$}){let U=C(null);return u(()=>{let v=U.current;if(!v)return;if(v.replaceChildren(),!$)return;let J=document.createElement("template");J.innerHTML=$,v.append(J.content.cloneNode(!0))},[$]),G("div",{ref:U},void 0,!1,void 0,this)}function Bw($,U){return`${$.role}:${$.status??"none"}:${U}:${$.text}`}function oX({count:$}){if($===0)return null;return G("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--c-accent)",background:"rgba(70,182,255,0.08)",borderRadius:"var(--radius-sm)",flexShrink:0},children:["✦"," ",$," context node",$!==1?"s":""," attached"]},void 0,!0,void 0,this)}function dX({message:$,onDismiss:U}){if(!$)return null;return G("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--c-danger)",background:"rgba(255,80,80,0.08)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[G("span",{style:{flex:1},children:$},void 0,!1,void 0,this),G("button",{type:"button",onClick:U,style:{background:"none",border:"none",color:"var(--c-danger)",cursor:"pointer",fontSize:"13px",padding:"0 2px"},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L9({node:$,expanded:U=!1}){let v=Array.isArray($.data.turns)?$.data.turns:[],J=v.length===0,_=$.data.text||"",z=$.data.status||"draft",K=J?z:$.data.threadStatus||"draft",W=K==="draft",O=K==="pending"||K==="sending",Y=K==="streaming",Z=K==="answered",[q,X]=f(""),[B,L]=f(""),[F,k]=f(null),[H,P]=f(new Map),b=C(null),V=C(null),E=v[v.length-1],A=`${v.length}:${E?.role??""}:${E?.status??""}:${Math.floor((E?.text?.length??0)/200)}`;u(()=>{if(U&&W&&b.current)b.current.focus()},[U,W]),u(()=>{if(!A)return;if(V.current)V.current.scrollTo({top:V.current.scrollHeight,behavior:"smooth"})},[A]);let I=C(null),N=C(v);N.current=v,u(()=>{let t=v.some((o)=>o.role==="assistant"&&o.status==="streaming"),i=()=>{let o=!1,B$=N.current.map((S6,N$)=>({turn:S6,index:N$})).filter(({turn:S6})=>S6.role==="assistant"&&S6.text);if(B$.length===0)return;return Promise.all(B$.map(async({turn:S6,index:N$})=>{let t$=await R4(S6.text);return{index:N$,html:Zw(t$)}})).then((S6)=>{if(o)return;let N$=new Map;for(let t$ of S6)N$.set(t$.index,t$.html);P(N$)}),()=>{o=!0}};if(!t){if(I.current)clearTimeout(I.current),I.current=null;return i()}if(I.current)clearTimeout(I.current);return I.current=setTimeout(()=>{I.current=null,i()},400),()=>{if(I.current)clearTimeout(I.current),I.current=null}},[v]);let R=j(async()=>{let t=q.trim();if(!t)return;let i=q;k(null),W$($.id,{turns:[{role:"user",text:t,status:"pending"}],threadStatus:"pending",text:t}),X("");let o=Array.isArray($.data.contextNodeIds)?$.data.contextNodeIds:void 0;if(!(await c0(t,$.position,$.id,o,$.id)).ok)W$($.id,{turns:[],threadStatus:"draft",text:"",status:"draft"}),X(i),k("Failed to send prompt. Your draft has been restored.")},[q,$.id,$.position,$.data.contextNodeIds]),p=j(async()=>{let t=B.trim();if(!t)return;let i=B;k(null);let o=Array.isArray($.data.turns)?[...$.data.turns]:[];if(o.push({role:"user",text:t,status:"pending"}),W$($.id,{turns:o,threadStatus:"pending"}),L(""),!(await kY($.id,t)).ok)o.pop(),W$($.id,{turns:o,threadStatus:"answered"}),L(i),k("Failed to send reply. Your draft has been restored.")},[B,$.id,$.data.turns]),l=j((t)=>{if(t.key==="Enter"&&(t.metaKey||t.ctrlKey)){t.preventDefault(),R();return}if(t.key==="Tab"&&q.startsWith("/")){t.preventDefault();let i=q.slice(1).split(/\s/)[0];if(i)iX().then((o)=>{let z$=pX(i,o);if(z$)X(`/${z$}`)})}},[R,q]),T=j((t)=>{if(t.key==="Enter"&&(t.metaKey||t.ctrlKey)){t.preventDefault(),p();return}if(t.key==="Tab"&&B.startsWith("/")){t.preventDefault();let i=B.slice(1).split(/\s/)[0];if(i)iX().then((o)=>{let z$=pX(i,o);if(z$)L(`/${z$}`)})}},[p,B]),r=Array.isArray($.data.contextNodeIds)?$.data.contextNodeIds.length:0;if(W&&v.length===0)return G("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%",gap:"8px"},children:[G(oX,{count:r},void 0,!1,void 0,this),G(dX,{message:F,onDismiss:()=>k(null)},void 0,!1,void 0,this),G("textarea",{ref:b,value:q,onInput:(t)=>X(t.target.value),onKeyDown:l,placeholder:"Ask the agent something…",spellcheck:!1,style:{flex:1,resize:"none",background:"rgba(10,14,30,0.4)",border:"1px solid var(--c-line)",borderRadius:"var(--radius-sm)",color:"var(--c-text)",fontFamily:"var(--font)",fontSize:"13px",lineHeight:"1.5",padding:"8px 10px",outline:"none"}},void 0,!1,void 0,this),G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:["⌘","+Enter to send"]},void 0,!0,void 0,this),G("button",{type:"button",onClick:R,disabled:!q.trim(),style:{padding:"5px 14px",fontSize:"12px",fontWeight:600,background:q.trim()?"var(--c-accent)":"var(--c-line)",color:q.trim()?"var(--c-contrast-fg)":"var(--c-muted)",border:"none",borderRadius:"var(--radius-sm)",cursor:q.trim()?"pointer":"default"},children:"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(J)return G("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[G("div",{style:{flex:1,padding:"2px 0",fontSize:"13px",lineHeight:"1.55",color:"var(--c-text)",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"auto"},children:_},void 0,!1,void 0,this),G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"6px",borderTop:"1px solid var(--c-line)",marginTop:"4px"},children:G("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:O?"var(--c-warn)":Z?"var(--c-ok)":"var(--c-muted)"},children:O?"Sending…":Z?"Answered":z},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[G(oX,{count:r},void 0,!1,void 0,this),G(dX,{message:F,onDismiss:()=>k(null)},void 0,!1,void 0,this),G("div",{ref:V,style:{flex:1,overflow:"auto",minHeight:0},children:v.map((t,i)=>G("div",{children:[i>0&&G("div",{class:"thread-turn-divider"},void 0,!1,void 0,this),t.role==="user"?G("div",{class:"thread-turn-user",children:[G("div",{class:"thread-turn-role",children:[G("span",{class:"status-dot"},void 0,!1,void 0,this),"You"]},void 0,!0,void 0,this),G("div",{style:{fontSize:U?"15px":"13px",lineHeight:U?"1.7":"1.55",color:"var(--c-text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t.text},void 0,!1,void 0,this)]},void 0,!0,void 0,this):G("div",{class:"thread-turn-assistant",children:[G("div",{class:"thread-turn-role",children:[G("span",{class:`status-dot${t.status==="streaming"?" pulsing":""}`},void 0,!1,void 0,this),"PMX"]},void 0,!0,void 0,this),t.status==="streaming"&&!t.text&&G("div",{style:{height:"2px",background:"linear-gradient(90deg, transparent, var(--c-ok), transparent)",animation:"response-stream-pulse 1.5s ease-in-out infinite",borderRadius:"1px",marginBottom:"4px"}},void 0,!1,void 0,this),G("div",{class:U?"md-reader-content":void 0,style:{fontSize:U?void 0:"13px",lineHeight:U?void 0:"1.55",opacity:t.text?1:0.4},children:H.get(i)?G(A$,{children:[G(qw,{html:H.get(i)??""},void 0,!1,void 0,this),t.status==="streaming"&&G("span",{class:"streaming-cursor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):G("div",{style:{color:"var(--c-muted)",fontStyle:"italic"},children:t.status==="streaming"?"Waiting for response…":t.text||"Empty response"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Bw(t,i),!0,void 0,this))},void 0,!1,void 0,this),G("div",{style:{flexShrink:0,borderTop:"1px solid var(--c-line)",marginTop:"4px",paddingTop:"6px"},children:[G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:Z?"6px":0},children:[G("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:Y?"var(--c-accent)":O?"var(--c-warn)":Z?"var(--c-ok)":"var(--c-muted)"},children:Y?"Streaming…":O?"Sending…":Z?"Answered":K},void 0,!1,void 0,this),G("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:[v.length," turn",v.length!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z&&G("div",{class:"thread-reply-area",children:[G("textarea",{value:B,onInput:(t)=>L(t.target.value),onKeyDown:T,placeholder:"Reply…",spellcheck:!1,rows:2,style:{width:"100%",resize:"none",background:"rgba(10,14,30,0.4)",border:"1px solid var(--c-line)",borderRadius:"var(--radius-sm)",color:"var(--c-text)",fontFamily:"var(--font)",fontSize:"12px",lineHeight:"1.5",padding:"6px 8px",outline:"none"}},void 0,!1,void 0,this),G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"4px"},children:[G("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:["⌘","+Enter"]},void 0,!0,void 0,this),G("button",{type:"button",onClick:p,disabled:!B.trim(),style:{padding:"3px 10px",fontSize:"11px",fontWeight:600,background:B.trim()?"var(--c-accent)":"var(--c-line)",color:B.trim()?"var(--c-contrast-fg)":"var(--c-muted)",border:"none",borderRadius:"var(--radius-sm)",cursor:B.trim()?"pointer":"default"},children:"Reply"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Xw($){return $.replace(/<script[\s>][\s\S]*?<\/script>/gi,"").replace(/<iframe[\s>][\s\S]*?<\/iframe>/gi,"").replace(/<object[\s>][\s\S]*?<\/object>/gi,"").replace(/<embed[\s>][\s\S]*?(?:\/>|<\/embed>)/gi,"").replace(/<link[\s>][\s\S]*?(?:\/>|<\/link>)/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/href\s*=\s*"javascript:[^"]*"/gi,'href="#"').replace(/href\s*=\s*'javascript:[^']*'/gi,"href='#'")}function Hw({html:$}){let U=C(null);return u(()=>{let v=U.current;if(!v)return;if(v.replaceChildren(),!$)return;let J=document.createElement("template");J.innerHTML=$,v.append(J.content.cloneNode(!0))},[$]),G("div",{ref:U},void 0,!1,void 0,this)}function F9({node:$,expanded:U=!1}){let v=$.data.content||"",J=$.data.status||"streaming",[_,z]=f(""),K=J==="streaming",W=J==="complete";u(()=>{if(!v){z("");return}let Y=!1;return R4(v).then((Z)=>{if(!Y)z(Xw(Z))}),()=>{Y=!0}},[v]);let O=j(()=>{c0("",{x:$.position.x,y:$.position.y+$.size.height+24},$.id)},[$]);return G("div",{class:"response-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[K&&G("div",{class:"response-streaming-bar",style:{height:"2px",background:"linear-gradient(90deg, transparent, var(--c-accent), transparent)",animation:"response-stream-pulse 1.5s ease-in-out infinite",borderRadius:"1px",marginBottom:"4px",flexShrink:0}},void 0,!1,void 0,this),G("div",{class:U?"md-reader":void 0,style:{flex:1,overflow:"auto",minHeight:0,opacity:v?1:0.4,transition:"opacity 0.2s ease"},children:_?G("div",{class:U?"md-reader-content":void 0,children:G(Hw,{html:_},void 0,!1,void 0,this)},void 0,!1,void 0,this):G("div",{style:{color:"var(--c-muted)",fontStyle:"italic",fontSize:"13px"},children:K?"Waiting for response…":"Empty response"},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"6px",borderTop:"1px solid var(--c-line)",marginTop:"4px",flexShrink:0},children:[G("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:K?"var(--c-accent)":W?"var(--c-ok)":"var(--c-muted)"},children:K?"Streaming…":W?"Complete":J},void 0,!1,void 0,this),W&&G("button",{type:"button",onClick:O,style:{padding:"3px 10px",fontSize:"11px",background:"rgba(70,182,255,0.1)",border:"1px solid rgba(70,182,255,0.3)",borderRadius:"var(--radius-sm)",color:"var(--c-accent)",cursor:"pointer"},children:"Reply"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function nX($){return{toolName:$.toolName||$.title||"unknown",category:$.category||"other",status:$.status||"running",duration:$.duration||"",resultSummary:$.resultSummary||$.content||"",error:$.error||""}}var tX={mcp:"var(--c-accent)",file:"var(--c-warn)",subagent:"var(--c-purple)",other:"var(--c-muted)"},Qw={running:"⠋",success:"✓",failed:"✕"},Lw={running:"var(--c-accent)",success:"var(--c-ok)",failed:"var(--c-danger)"};function P9({node:$}){let{toolName:U,category:v,status:J,duration:_,resultSummary:z,error:K}=nX($.data),W=tX[v]??tX.other,O=Qw[J]??"◌",Y=Lw[J]??"var(--c-muted)",Z=J==="running",q=K?K.slice(0,30):z.length>30?`${z.slice(0,28)}…`:z;return G("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"0 12px",height:"100%",overflow:"hidden"},children:[G("span",{style:{fontSize:"14px",color:Y,flexShrink:0,animation:Z?"pulse 1.5s infinite":"none"},children:O},void 0,!1,void 0,this),G("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[G("div",{style:{fontFamily:"var(--mono)",fontSize:"11px",fontWeight:600,color:W,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:U},void 0,!1,void 0,this),q&&G("div",{style:{fontSize:"10px",color:K?"var(--c-danger)":"var(--c-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3},children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&G("span",{style:{fontSize:"9px",padding:"1px 5px",borderRadius:"3px",background:"rgba(255,255,255,0.06)",color:"var(--c-muted)",flexShrink:0,whiteSpace:"nowrap"},children:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function DW($){let U=D.value.get($);if(!U)return null;return{left:U.position.x,top:U.position.y,width:U.size.width,height:U.size.height}}function Fw($){let U=$.map((O)=>DW(O)).filter((O)=>O!==null);if(U.length===0)return null;let v=Math.min(...U.map((O)=>O.left)),J=Math.min(...U.map((O)=>O.top)),_=Math.max(...U.map((O)=>O.left+O.width)),z=Math.max(...U.map((O)=>O.top+O.height)),K=54,W=46;return{left:v-K,top:J-W,width:_-v+K*2,height:z-J+W*2}}function CW($,U){return{left:`${$.left}px`,top:`${$.top}px`,width:`${$.width}px`,height:`${$.height}px`,borderRadius:`${U}px`}}function aX(){let $=Array.from(qU.value),U=Array.from(BU.value),v=j2.value;if($.length===0&&U.length===0)return null;let J=[...D.value.values()],_=J.length>0?(Math.max(...J.map((z)=>z.position.x+z.size.width))-Math.min(...J.map((z)=>z.position.x)))*(Math.max(...J.map((z)=>z.position.y+z.size.height))-Math.min(...J.map((z)=>z.position.y))):0;return G("div",{class:"attention-field-layer","aria-hidden":"true",children:[v.map((z)=>{let K=Fw(z.nodeIds);if(!K)return null;if(_>0&&K.width*K.height>=_*0.75)return null;return G("div",{class:"attention-field-region",style:CW(K,42)},z.id,!1,void 0,this)}),U.map((z)=>{let K=DW(z);if(!K)return null;return G("div",{class:"attention-field-node attention-field-secondary",style:CW({left:K.left-18,top:K.top-18,width:K.width+36,height:K.height+36},28)},`secondary-${z}`,!1,void 0,this)}),$.map((z)=>{let K=DW(z);if(!K)return null;return G("div",{class:"attention-field-node attention-field-primary",style:CW({left:K.left-24,top:K.top-24,width:K.width+48,height:K.height+48},30)},`primary-${z}`,!1,void 0,this)})]},void 0,!0,void 0,this)}var Pw=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif"]),kw=new Set(["md","mdx","markdown"]);function bw($){let U=$.split(".").pop()?.toLowerCase()??"";if(Pw.has(U))return"image";if(kw.has(U))return"markdown";return"file"}async function k9($,U,v){let K=Math.ceil(Math.sqrt($.length));for(let W=0;W<$.length;W++){let O=$[W],Y=W%K,Z=Math.floor(W/K),q=U-K*420/2+Y*420,X=v-150+Z*320,B=bw(O.name),L=O.name;if(B==="image"){let F=new FileReader,k=await new Promise((H)=>{F.onload=()=>H(F.result),F.readAsDataURL(O)});await n6({type:"image",title:L,content:k,x:q,y:X,width:400,height:300})}else{let F=await O.text(),k=B==="markdown"||B==="file";await n6({type:B,title:L,content:F,x:q,y:X,width:k?720:400,height:k?500:300})}}}var s$=s(new Map),M0=s(null),Mw=480,Aw=320,Iw=650,U2=new Map,b0=new Map,b9=new Map,x4=null;function jW($){s$.value=$,ww()}function VW($){let U=U2.get($);if(U)clearTimeout(U),U2.delete($)}function fW($){let U=b0.get($);if(U)clearTimeout(U),b0.delete($)}function eX($){if(VW($.id),fW($.id),!s$.value.has($.id))b9.set($.id,Date.now());let U=new Map(s$.value);U.set($.id,{...$,phase:"forming"}),jW(U)}function _2($){if(VW($),fW($),b9.delete($),!s$.value.has($))return;let U=new Map(s$.value);U.delete($),jW(U)}function sX($,U,v,J){let _=s$.value.get($);if(!_||_.phase===U)return;let z=new Map(s$.value);z.set($,{..._,phase:U,...J?{settledNodeId:J}:{}}),jW(z),VW($),U2.set($,setTimeout(()=>_2($),v))}function $H($,U,v,J){fW($);let _=Date.now()-(b9.get($)??0),z=Math.max(0,Iw-_);if(z===0){sX($,U,v,J);return}b0.set($,setTimeout(()=>{b0.delete($),sX($,U,v,J)},z))}function UH($,U){$H($,"settling",Mw,U)}function EW($){$H($,"dissolving",Aw)}function uW(){for(let $ of U2.values())clearTimeout($);U2.clear();for(let $ of b0.values())clearTimeout($);if(b0.clear(),b9.clear(),x4)clearInterval(x4),x4=null;M0.value=null,s$.value=new Map}function ww(){if(x4||s$.value.size===0)return;x4=setInterval(()=>{let $=Date.now();for(let U of s$.value.values())if(U.phase==="forming"&&U.expiresAt<=$)EW(U.id);if(s$.value.size===0&&x4)clearInterval(x4),x4=null},1000),x4.unref?.()}var gw={fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"};function g$({size:$=16,children:U,...v}){return G("svg",{width:$,height:$,viewBox:"0 0 16 16",...gw,...v,children:U},void 0,!1,void 0,this)}function A9($){return G(g$,{...$,children:[G("polyline",{points:"1 5 1 1 5 1"},void 0,!1,void 0,this),G("polyline",{points:"11 1 15 1 15 5"},void 0,!1,void 0,this),G("polyline",{points:"15 11 15 15 11 15"},void 0,!1,void 0,this),G("polyline",{points:"5 15 1 15 1 11"},void 0,!1,void 0,this),G("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vH($){return G(g$,{...$,children:[G("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),G("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this),G("line",{x1:"5",y1:"7",x2:"9",y2:"7"},void 0,!1,void 0,this),G("line",{x1:"7",y1:"5",x2:"7",y2:"9"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function JH($){return G(g$,{...$,children:[G("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),G("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this),G("line",{x1:"5",y1:"7",x2:"9",y2:"7"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function t1($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"4",x2:"9.5",y2:"4"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"12",x2:"9.5",y2:"12"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"6.5",x2:"4",y2:"9.5"},void 0,!1,void 0,this),G("line",{x1:"12",y1:"6.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function I9($){return G(g$,{...$,children:[G("rect",{x:"1",y:"2",width:"14",height:"12",rx:"1.5"},void 0,!1,void 0,this),G("rect",{x:"8",y:"7",width:"6",height:"6",rx:"1",fill:"currentColor","fill-opacity":"0.2"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function zH($){return G(g$,{...$,children:[G("circle",{cx:"8",cy:"8",r:"3"},void 0,!1,void 0,this),G("line",{x1:"8",y1:"1",x2:"8",y2:"3"},void 0,!1,void 0,this),G("line",{x1:"8",y1:"13",x2:"8",y2:"15"},void 0,!1,void 0,this),G("line",{x1:"1",y1:"8",x2:"3",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"13",y1:"8",x2:"15",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"3.05",y1:"3.05",x2:"4.46",y2:"4.46"},void 0,!1,void 0,this),G("line",{x1:"11.54",y1:"11.54",x2:"12.95",y2:"12.95"},void 0,!1,void 0,this),G("line",{x1:"3.05",y1:"12.95",x2:"4.46",y2:"11.54"},void 0,!1,void 0,this),G("line",{x1:"11.54",y1:"4.46",x2:"12.95",y2:"3.05"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function w9($){return G(g$,{...$,children:G("path",{d:"M13 9.5A5.5 5.5 0 1 1 6.5 3 4.5 4.5 0 0 0 13 9.5Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function mW($){return G(g$,{...$,children:[G("path",{d:"M3 13l2.8-.7L13 5.1 10.9 3 3.7 10.2 3 13Z"},void 0,!1,void 0,this),G("path",{d:"M9.8 4.1l2.1 2.1"},void 0,!1,void 0,this),G("path",{d:"M2.5 14h11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function xW($){return G(g$,{...$,children:[G("path",{d:"M3 10.5 8.5 5a2 2 0 0 1 2.8 0l1.7 1.7a2 2 0 0 1 0 2.8L8.5 14H5.8L3 11.2Z"},void 0,!1,void 0,this),G("path",{d:"M7.5 6 12 10.5"},void 0,!1,void 0,this),G("path",{d:"M8.5 14H14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function hW($){return G(g$,{...$,children:[G("path",{d:"M3 4h10"},void 0,!1,void 0,this),G("path",{d:"M8 4v8"},void 0,!1,void 0,this),G("path",{d:"M6 12h4"},void 0,!1,void 0,this),G("path",{d:"M4.5 4 4 6"},void 0,!1,void 0,this),G("path",{d:"M11.5 4 12 6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function KH($){return G(g$,{...$,children:[G("rect",{x:"1",y:"4",width:"14",height:"10",rx:"1.5"},void 0,!1,void 0,this),G("path",{d:"M5.5 4 L6.5 2.5 H9.5 L10.5 4"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"9",r:"2.3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function GH($){return G(g$,{...$,children:[G("circle",{cx:"8",cy:"8",r:"6"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"8",r:"3"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"8",r:"0.8",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function WH($){return G(g$,{...$,children:[G("circle",{cx:"8",cy:"8",r:"6"},void 0,!1,void 0,this),G("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"10.5"},void 0,!1,void 0,this),G("line",{x1:"10.5",y1:"5.5",x2:"5.5",y2:"10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function OH($){return G(g$,{...$,children:[G("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),G("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function YH($){return G(g$,{...$,children:[G("rect",{x:"1",y:"3",width:"14",height:"10",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"6",x2:"5",y2:"6"},void 0,!1,void 0,this),G("line",{x1:"7.5",y1:"6",x2:"8.5",y2:"6"},void 0,!1,void 0,this),G("line",{x1:"11",y1:"6",x2:"12",y2:"6"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"10",x2:"12",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function I0($){return G(g$,{...$,children:G("path",{d:"M2 13 L2 4 A2 2 0 0 1 4 2 L12 2 A2 2 0 0 1 14 4 L14 9 A2 2 0 0 1 12 11 L5 11 Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function ZH({size:$=22,class:U}){return G("svg",{width:$,height:$,viewBox:"0 0 64 64",xmlns:"http://www.w3.org/2000/svg",class:U,"aria-hidden":"true",children:[G("rect",{x:"8",y:"8",width:"48",height:"48",rx:"7",fill:"none",stroke:"currentColor","stroke-width":"2.2",opacity:"0.35"},void 0,!1,void 0,this),G("rect",{x:"16",y:"16",width:"32",height:"32",rx:"5",fill:"none",stroke:"currentColor","stroke-width":"2.2",opacity:"0.6"},void 0,!1,void 0,this),G("rect",{x:"24",y:"24",width:"16",height:"16",rx:"3",fill:"none",stroke:"currentColor","stroke-width":"2.2"},void 0,!1,void 0,this),G("rect",{x:"29",y:"29",width:"6",height:"6",rx:"1",fill:"currentColor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function qH({size:$=15}){return G("svg",{width:$,height:$,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:G("path",{d:"M3 2l10 5.5-4.2 1.3L7.5 13z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function BH({size:$=15}){return G("svg",{width:$,height:$,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:G("path",{d:"M5 7.5V3.8a1 1 0 0 1 2 0V7m0-3.9a1 1 0 0 1 2 0V7m0-2.7a1 1 0 0 1 2 0V7.4m0-.9a1 1 0 0 1 2 0v3.2A4.3 4.3 0 0 1 8.7 14H8a4.3 4.3 0 0 1-3.6-2L2.7 9.3a1 1 0 0 1 1.6-1.2L5 9.2"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function XH({size:$=15}){return G("svg",{width:$,height:$,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:G("path",{d:"M6 4.5L2.5 8 6 11.5M10 4.5L13.5 8 10 11.5"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function F1($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"6",x2:"10",y2:"6"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"8.5",x2:"8",y2:"8.5"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"11",x2:"11",y2:"11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Nw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"9",rx:"1.5"},void 0,!1,void 0,this),G("path",{d:"M4 13.5 L5.5 11.5 L8 11.5"},void 0,!1,void 0,this),G("polyline",{points:"5 6 7 8 5 10"},void 0,!1,void 0,this),G("line",{x1:"8",y1:"10",x2:"11",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Sw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"9",rx:"1.5"},void 0,!1,void 0,this),G("path",{d:"M12 13.5 L10.5 11.5 L8 11.5"},void 0,!1,void 0,this),G("circle",{cx:"5",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"11",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function M9($){return G(g$,{...$,children:[G("path",{d:"M3 1.5h6l3.5 3.5v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2.5a1 1 0 0 1 1-1z"},void 0,!1,void 0,this),G("polyline",{points:"9 1.5 9 5 12.5 5"},void 0,!1,void 0,this),G("line",{x1:"4.5",y1:"8.5",x2:"10.5",y2:"8.5"},void 0,!1,void 0,this),G("line",{x1:"4.5",y1:"11",x2:"9",y2:"11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function cW($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("circle",{cx:"5.5",cy:"6.5",r:"1.2"},void 0,!1,void 0,this),G("path",{d:"M1.8 12 L6 8.5 L9 11 L11.5 9 L14.2 12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function A0($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"1.5",y1:"5.5",x2:"14.5",y2:"5.5"},void 0,!1,void 0,this),G("circle",{cx:"3.3",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"5",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"6.7",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"8",x2:"12",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"4",y1:"10",x2:"10",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rw($){return G(g$,{...$,children:[G("rect",{x:"2",y:"4",width:"12",height:"10",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"2",y1:"6.5",x2:"14",y2:"6.5"},void 0,!1,void 0,this),G("path",{d:"M11 1.5 L11 4"},void 0,!1,void 0,this),G("circle",{cx:"11",cy:"4",r:"1.6",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function lW($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"1.5","stroke-dasharray":"2 1.5"},void 0,!1,void 0,this),G("rect",{x:"4",y:"4",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this),G("rect",{x:"8.5",y:"4",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this),G("rect",{x:"6.25",y:"8.5",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Tw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("circle",{cx:"4.5",cy:"8",r:"1.1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"6.5",x2:"12.5",y2:"6.5"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"8",x2:"11",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"9.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function yw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("path",{d:"M3.5 10.5 L6 6.5 L8.5 9.5 L12.5 5"},void 0,!1,void 0,this),G("circle",{cx:"12.5",cy:"5",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Cw($){return G(g$,{...$,children:[G("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"4.5",y1:"5.5",x2:"11.5",y2:"5.5"},void 0,!1,void 0,this),G("line",{x1:"4.5",y1:"8",x2:"11.5",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"4.5",y1:"10.5",x2:"8",y2:"10.5"},void 0,!1,void 0,this),G("line",{x1:"6.5",y1:"2",x2:"6.5",y2:"14",opacity:"0.45"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Dw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this),G("path",{d:"M4 11 L4 6 L6 8.5 L8 6 L8 11"},void 0,!1,void 0,this),G("path",{d:"M10 11 L10 6 L12.5 11 L12.5 6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function jw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("polyline",{points:"10 5 13 5 13 8"},void 0,!1,void 0,this),G("line",{x1:"13",y1:"5",x2:"8",y2:"10"},void 0,!1,void 0,this),G("path",{d:"M6 6 L3.5 6 L3.5 11.5 L10 11.5 L10 9"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vw($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("path",{d:"M7 5.5 C 5.5 5.5 5.5 8 4 8 C 5.5 8 5.5 10.5 7 10.5"},void 0,!1,void 0,this),G("path",{d:"M9 5.5 C 10.5 5.5 10.5 8 12 8 C 10.5 8 10.5 10.5 9 10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _H($){return G(g$,{...$,children:[G("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),G("line",{x1:"5.2",y1:"6",x2:"8",y2:"8"},void 0,!1,void 0,this),G("line",{x1:"8",y1:"8",x2:"10.8",y2:"6"},void 0,!1,void 0,this),G("line",{x1:"8",y1:"8",x2:"8",y2:"11"},void 0,!1,void 0,this),G("circle",{cx:"5.2",cy:"6",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"10.8",cy:"6",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),G("circle",{cx:"8",cy:"11",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function h4($){switch($){case"markdown":return F1;case"prompt":return Nw;case"response":return Sw;case"file":return M9;case"diff":return M9;case"mermaid":return _H;case"image":return cW;case"webpage":return A0;case"context":return Rw;case"group":return lW;case"status":return Tw;case"trace":return yw;case"ledger":return Cw;case"mcp-app":return Dw;case"ext-app":return jw;case"json-render":return Vw;case"graph":return _H;case"html":return A0;default:return F1}}var HH={width:260,height:150},fw={markdown:{width:300,height:170},status:{width:280,height:110},context:{width:300,height:200},trace:{width:220,height:64},file:{width:300,height:190},image:{width:260,height:200},webpage:{width:320,height:210},html:{width:320,height:210},group:{width:340,height:210},graph:{width:320,height:210},"json-render":{width:320,height:210},"mcp-app":{width:340,height:230}};function iW($){return!!$&&$ in Z6}function c4($){if(!$)return null;let U=D.value.get($);if(!U)return null;return{left:U.position.x,top:U.position.y,width:U.size.width,height:U.size.height}}function rW($){return{x:$.left+$.width/2,y:$.top+$.height/2}}function v2($){let U=typeof $.confidence!=="number"?0.82:0.4+Math.max(0,Math.min(1,$.confidence))*0.55;return $.auto?U*0.62:U}function QH($,U){let v=Math.max(40,Math.abs(U.x-$.x)/2);return`M ${$.x} ${$.y} C ${$.x+v} ${$.y}, ${U.x-v} ${U.y}, ${U.x} ${U.y}`}function pW({intent:$}){let U=iW($.nodeType)?h4($.nodeType):null,v=$.label||$.kind,J=typeof $.confidence==="number"?`${Math.round($.confidence*100)}%`:null;return G("div",{class:"intent-info",onMouseEnter:()=>M0.value=$.id,onMouseLeave:()=>{if(M0.value===$.id)M0.value=null},children:[G("div",{class:"intent-chip",children:[typeof $.seq==="number"&&G("span",{class:"intent-seq",children:$.seq},void 0,!1,void 0,this),U&&G("span",{class:"intent-chip-icon","aria-hidden":"true",children:G(U,{size:12},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"intent-chip-label",children:v},void 0,!1,void 0,this),J&&G("span",{class:"intent-confidence",children:J},void 0,!1,void 0,this),$.phase==="forming"&&!$.auto&&G("button",{type:"button",class:"intent-veto",title:"Veto this move (Esc)","aria-label":"Veto this move",onClick:(_)=>{_.stopPropagation(),D1($)},children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.reason&&G("div",{class:"intent-reason",children:$.reason},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function LH({intent:$,rect:U}){let v=iW($.nodeType)?h4($.nodeType):null,J=iW($.nodeType)?Z6[$.nodeType]:"Node";return G("div",{class:`intent-ghost intent-ghost-box is-${$.phase}${$.auto?" is-auto":""}`,"data-intent-id":$.id,style:{left:`${U.left}px`,top:`${U.top}px`,width:`${U.width}px`,height:`${U.height}px`,opacity:v2($)},children:[G("div",{class:"intent-ghost-titlebar",children:[G("span",{class:"intent-ghost-icon","aria-hidden":"true",children:v?G(v,{size:13},void 0,!1,void 0,this):"◇"},void 0,!1,void 0,this),G("span",{class:"intent-ghost-badge",children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(pW,{intent:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function FH({intent:$,rect:U,variant:v}){return G("div",{class:`intent-ghost intent-ghost-${v} is-${$.phase}${$.auto?" is-auto":""}`,"data-intent-id":$.id,style:{left:`${U.left}px`,top:`${U.top}px`,width:`${U.width}px`,height:`${U.height}px`,opacity:v2($)},children:[v==="edit"&&G("div",{class:"intent-edit-bar"},void 0,!1,void 0,this),G(pW,{intent:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ew($){let U=$.phase==="settling"?c4($.settledNodeId):null;switch($.kind){case"create":{if(!$.position)return null;let v=$.nodeType&&fw[$.nodeType]||HH,J=U??{left:$.position.x,top:$.position.y,...v};return G(LH,{intent:$,rect:J},$.id,!1,void 0,this)}case"move":{if(!$.position)return null;let J=c4($.nodeId)??HH,_=U??{left:$.position.x,top:$.position.y,width:J.width,height:J.height};return G(LH,{intent:$,rect:_},$.id,!1,void 0,this)}case"remove":{let v=U??c4($.nodeId);if(!v)return null;return G(FH,{intent:$,rect:v,variant:"remove"},$.id,!1,void 0,this)}case"edit":{let v=U??c4($.nodeId);if(!v)return null;return G(FH,{intent:$,rect:v,variant:"edit"},$.id,!1,void 0,this)}case"connect":{if(!$.edge)return null;let v=c4($.edge.from),J=c4($.edge.to);if(!v||!J)return null;let _={x:(v.left+v.width/2+J.left+J.width/2)/2,y:(v.top+v.height/2+J.top+J.height/2)/2},z={left:_.x-110,top:_.y-18,width:220,height:36};return G("div",{class:`intent-ghost intent-ghost-connect is-${$.phase}${$.auto?" is-auto":""}`,"data-intent-id":$.id,style:{left:`${z.left}px`,top:`${z.top}px`,width:`${z.width}px`,opacity:v2($)},children:G(pW,{intent:$},void 0,!1,void 0,this)},$.id,!1,void 0,this)}default:return null}}function PH(){let $=Array.from(s$.value.values());if(u(()=>{function U(v){if(v.key!=="Escape")return;let J=M0.value;if(!J)return;let _=s$.value.get(J);if(!_||_.phase!=="forming")return;v.stopImmediatePropagation(),v.preventDefault(),D1(_)}return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[]),$.length===0)return null;return G("div",{class:"intent-layer",children:[G("svg",{class:"intent-line-layer",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:[G("defs",{children:G("marker",{id:"intent-arrow",markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:G("path",{d:"M0,0 L6,3 L0,6 Z",class:"intent-arrow-head"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),$.map((U)=>{if(U.kind==="connect"&&U.edge){let v=c4(U.edge.from),J=c4(U.edge.to);if(!v||!J)return null;return G("path",{d:QH(rW(v),rW(J)),class:`intent-edge type-${U.edge.type}`,style:{opacity:v2(U)}},`line-${U.id}`,!1,void 0,this)}if(U.kind==="move"&&U.position){let v=c4(U.nodeId);if(!v)return null;let J=v,_={x:U.position.x+J.width/2,y:U.position.y+J.height/2};return G("path",{d:QH(rW(v),_),class:"intent-trail",markerEnd:"url(#intent-arrow)",style:{opacity:v2(U)}},`line-${U.id}`,!1,void 0,this)}return null})]},void 0,!0,void 0,this),$.map(Ew)]},void 0,!0,void 0,this)}var kH=32000;var g9="Agent session";function bH($){return $.some((U)=>U.attached)}function MH($){return $.filter((U)=>!U.attached)}function w0($){switch($.phase){case"thinking":return"Thinking";case"tooling":return $.detail?`Running ${$.detail}`:"Working";case"waiting-approval":return"Waiting on you";default:return"Idle"}}function P1($){let U=5381;for(let v=0;v<$.length;v++)U=(U<<5)+U+$.charCodeAt(v)|0;return(U%360+360)%360}var O6=s([]),dW=s({used:0,total:kH}),k1=s([]),a1=s(!1),g0=s(!1),nW=s(null),AH=["var(--c-purple)","var(--c-accent)","var(--c-ok)","var(--c-warn)","var(--c-danger)"],oW=new Map;function N9($){let U=oW.get($);if(U)return U;let v=AH[oW.size%AH.length];return oW.set($,v),v}function IH($){return($.trim().replace(/^[^a-z0-9]+/i,"").charAt(0)||$.trim().charAt(0)||"?").toUpperCase()}function S9($,U=Date.now()){let v=U-Date.parse($);if(!Number.isFinite(v)||v<5000)return"now";if(v<60000)return`${Math.floor(v/1000)}s`;if(v<3600000)return`${Math.floor(v/60000)}m`;return`${Math.floor(v/3600000)}h`}var k6=r$(()=>bH(O6.value)),tW=r$(()=>MH(O6.value)),wH=r$(()=>{let $=new Set;return[...O6.value].filter((U)=>U.label!==g9).sort((U,v)=>Number(v.attached)-Number(U.attached)).map((U)=>({value:U.sessionId==="browser"?U.label:U.sessionId,label:U.label,attached:U.attached,steerable:U.attached||U.steerable===!0,pendingSteers:U.pendingSteers??0,polling:U.lastClaimAt!==void 0&&Date.now()-Date.parse(U.lastClaimAt)<300000})).filter((U)=>$.has(U.value)?!1:($.add(U.value),!0))}),gH=r$(()=>O6.value.filter(($)=>$.attached)),N0=r$(()=>O6.value.find(($)=>$.attached)??null);function uw($){let U=new Set;for(let v of $)if(v.nodeId&&v.kind!=="create")U.add(v.nodeId);return U}var NH=r$(()=>uw(s$.value.values()));function R9($,U){if($.cursor)return{x:$.cursor.x,y:$.cursor.y};if(!$.focusNodeId)return null;let v=U($.focusNodeId);if(!v)return null;return{x:v.position.x+Math.max(24,v.size.width-28),y:v.position.y+16}}function aW($){if(!$)return;if(Array.isArray($.presences))O6.value=$.presences;if($.budget&&Number.isFinite($.budget.used)&&Number.isFinite($.budget.total))dW.value={used:$.budget.used,total:$.budget.total};if(Array.isArray($.activity))k1.value=$.activity}function SH(){let $=C(new Map),U=G$.value.scale,v=D.value,J=1/Math.max(0.05,U),_=O6.value.map((z)=>{let K=R9(z,(O)=>v.get(O));if(K)$.current.set(z.sessionId,K);let W=K??$.current.get(z.sessionId)??null;return W?{presence:z,position:W}:null}).filter((z)=>z!==null);if(_.length===0)return null;return G("div",{class:"agent-presence-layer","aria-hidden":"true",children:_.map(({presence:z,position:K})=>G("div",{class:`agent-cursor phase-${z.phase}${z.attached?"":" is-external"}${z.parentAgentId?" is-worker":""}`,"data-session-id":z.sessionId,style:{transform:`translate(${K.x}px, ${K.y}px)`,"--identity-color":`hsl(${P1(z.sessionId)} 65% 62%)`},children:G("div",{class:"agent-cursor-inner",style:{transform:`scale(${J})`},children:[G("svg",{class:"agent-cursor-glyph",width:"16",height:"18",viewBox:"0 0 16 18","aria-hidden":"true",children:G("path",{d:"M1.5 1.5L14.5 9.2 8.3 10.6 5.2 16.5z",fill:"currentColor",stroke:"var(--c-bg)","stroke-width":"1.2"},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"agent-cursor-chip",children:[G("span",{class:"agent-cursor-dot"},void 0,!1,void 0,this),G("span",{class:"agent-cursor-label",children:w0(z)},void 0,!1,void 0,this),G("span",{class:"agent-cursor-who",children:z.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},z.sessionId,!1,void 0,this))},void 0,!1,void 0,this)}var RH=30000;var sW=80;function mw($,U){try{let v=window.sessionStorage.getItem($);if(v)return v;let J=U();return window.sessionStorage.setItem($,J),J}catch{return U()}}var D9=mw("pmx-canvas-human-client",()=>`tab-${Math.random().toString(36).slice(2,8)}`);function xw(){try{let $=new URLSearchParams(window.location.search).get("name")?.trim();if($)return window.localStorage.setItem("pmx-canvas-human-name",$),$;let U=window.localStorage.getItem("pmx-canvas-human-name")?.trim();if(U)return U}catch{}return`guest-${D9.slice(-4)}`}var yH=s(xw()),CH=s([]),eW=r$(()=>CH.value.filter(($)=>$.clientId!==D9)),s1=s(new Map);function $O($){if(!$||!Array.isArray($.humans))return;CH.value=$.humans}var y9=null,j9=null,DH=0,J2=null;function C9($){_4("humanPresence","/api/canvas/human-presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:D9,name:yH.value,...$})})}function TH(){J2=null,DH=Date.now(),C9({cursor:j9,grabbingNodeId:y9})}function V9($){j9=$;let U=Date.now()-DH;if(U>=sW){if(J2)clearTimeout(J2);TH()}else if(!J2)J2=setTimeout(TH,sW-U)}function UO($){y9=$,C9({cursor:j9,grabbingNodeId:$})}function hw($,U){let v=new Map(s1.value);v.set($,U),s1.value=v,setTimeout(()=>{let J=new Map(s1.value);if(J.get($)===U)J.delete($),s1.value=J},6000)}function jH($,U){let v=[...s$.value.values()].filter((_)=>_.nodeId===$&&!_.auto&&_.phase==="forming");if(v.length===0)return;let J=yH.value;hw($,J);for(let _ of v)D1({id:_.id,kind:_.kind,label:_.label,reason:`${J} took over “${U}” mid-edit — yield and requeue the change once it is released`}).then((z)=>{if(z)_2(_.id)});_4("yieldEvent","/api/canvas/ax/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"yield",summary:`${J} grabbed “${U}” mid-edit — agent yielded, change requeued`,nodeIds:[$],source:"browser"})})}var T9=null;function VH(){C9({cursor:j9,grabbingNodeId:y9}),T9=setInterval(()=>C9({grabbingNodeId:y9}),3000);let $=()=>{try{navigator.sendBeacon?.("/api/canvas/human-presence",new Blob([JSON.stringify({clientId:D9,left:!0})],{type:"application/json"}))}catch{}};return window.addEventListener("pagehide",$),()=>{if(T9)clearInterval(T9);T9=null,window.removeEventListener("pagehide",$)}}function l4($=1000){let[U,v]=f(()=>Date.now());return u(()=>{if($<=0)return;v(Date.now());let J=window.setInterval(()=>v(Date.now()),$);return()=>window.clearInterval(J)},[$]),U}function fH(){let $=l4(eW.value.length>0?5000:0),U=eW.value.filter((J)=>J.cursor!==null&&(!J.lastSeenAt||$-Date.parse(J.lastSeenAt)<RH+5000));if(U.length===0)return null;let v=1/Math.max(0.05,G$.value.scale);return G("div",{class:"human-presence-layer","aria-hidden":"true",children:U.map((J)=>G("div",{class:`human-cursor${J.grabbingNodeId?" is-grabbing":""}`,"data-client-id":J.clientId,style:{transform:`translate(${J.cursor.x}px, ${J.cursor.y}px)`},children:G("div",{class:"human-cursor-inner",style:{transform:`scale(${v})`},children:[G("svg",{class:"human-cursor-glyph",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:G("path",{d:"M3 2 L13 8 L8.5 9.5 L6.5 14 Z",fill:"currentColor",stroke:"var(--c-bg)","stroke-width":"1"},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"human-cursor-tag",children:J.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},J.clientId,!1,void 0,this))},void 0,!1,void 0,this)}function f9($,U){let{POSITIVE_INFINITY:v,POSITIVE_INFINITY:J,NEGATIVE_INFINITY:_,NEGATIVE_INFINITY:z}=Number,K=0;for(let W of $)K+=1,v=Math.min(v,W.position.x),J=Math.min(J,W.position.y),_=Math.max(_,W.position.x+W.size.width),z=Math.max(z,W.position.y+W.size.height);if(K===0)return null;return{x:v-U,y:J-U,width:_-v+U*2,height:z-J+U*2}}function vO(){let $=G4.value;return $&&typeof $==="object"?$:{}}var EH=r$(()=>vO().workItems??[]),uH=r$(()=>vO().approvalGates??[]),e1=r$(()=>uH.value.filter(($)=>$.status==="pending")),b1=r$(()=>{let $=vO().policy?.scope;return $&&Array.isArray($.nodeIds)&&$.nodeIds.length>0?{nodeIds:$.nodeIds,padding:typeof $.padding==="number"?$.padding:40}:null});async function mH($){return(await u6("setScopeFence","/api/canvas/ax/policy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:$&&$.length>0?{nodeIds:$}:null,source:"browser"})})).ok}var xH=r$(()=>uH.value.filter(($)=>$.status==="held")),hH=s({events:[],evidence:[],steering:[]}),$U=s("all");function JO($){if($==="update")return"update";if($==="steer"||$==="steering"||$==="yield")return"steer";if($==="assistant-message")return"assistant";if($==="evidence")return"evidence";return"event"}var cw=new Set(["api","mcp","sdk","cli"]);function _O($,U){if($?.trim())return $.trim();let v=U?.trim();if(v&&!cw.has(v))return v;return null}var lw=/^(node|edge|group|annotation|jsonrender|graph|render)\.|^arrange$|^canvas\.clear$|^snapshot\.restore$/,cH=s(null),z2=s(new Set),rw={prompt:"Prompt","assistant-message":"Assistant","tool-start":"Tool run","tool-result":"Tool result",failure:"Failure",approval:"Approval",steering:"Steering",command:"Command",note:"Note",policy:"Policy",yield:"Yield"};function iw($,U=40,v=[],J=null,_="all"){let z=v.find((O)=>lw.test(O.op)),K=[...v.map((O)=>({id:`update-${O.id}`,kind:"update",label:"Update",body:O.summary,createdAt:O.at,who:O.sessionId??null,...J?.actor==="agent"&&z?.id===O.id?{undoable:!0}:{}})),...$.events.map((O)=>({id:`event-${O.id}`,kind:O.kind,label:rw[O.kind]??O.kind,body:O.detail?`${O.summary} — ${O.detail}`:O.summary,createdAt:O.createdAt,who:_O(O.agentId,O.source)})),...$.evidence.map((O)=>({id:`evidence-${O.id}`,kind:"evidence",label:"Evidence",body:O.body?`${O.title} — ${O.body}`:O.title,createdAt:O.createdAt,who:_O(O.agentId,O.source)})),...$.steering.map((O)=>{let Y=O.agentId??(O.source&&O.source!=="browser"?O.source:null),Z=O.target?`→ ${O.target} · `:Y?"→ all · ":"",q=O.target&&O.delivered===!1?` — waiting for ${O.target} to pick it up`:"";return{id:`steer-${O.id}`,kind:"steer",label:"Steer",body:`${Y?`${Y} `:""}${Z}${O.message}${q}`,createdAt:O.createdAt,who:_O(O.agentId,O.source)}})],W=_==="all"?K:K.filter((O)=>JO(O.kind)===_);return W.sort((O,Y)=>O.createdAt<Y.createdAt?1:O.createdAt>Y.createdAt?-1:0),W.slice(0,U)}var lH=r$(()=>iw(hH.value,40,k1.value,cH.value,$U.value));async function M1(){let[$,U]=await Promise.all([M$("refreshTimeline","/api/canvas/ax/timeline?limit=40",null),M$("refreshHistoryTop","/api/canvas/history",null)]);if(U)cH.value=U.top??null;if(!$)return;hH.value={events:Array.isArray($.events)?$.events:[],evidence:Array.isArray($.evidence)?$.evidence:[],steering:Array.isArray($.steering)?$.steering:[]}}async function zO($){if(!(await u6("undoAgentEdit","/api/canvas/undo",{method:"POST"})).ok)return!1;return z2.value=new Set([...z2.value,$.id]),await _4("undoAgentEditSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:`Undid your edit: ${$.body} — it was reverted on the board.`,source:"browser"})}),M1(),!0}async function KO($=!1){let U=await u6($?"redo":"undo",$?"/api/canvas/redo":"/api/canvas/undo",{method:"POST"});if(U.ok)M1();return U.ok}async function rH($,U){if(!(await u6("resolveGate",`/api/canvas/ax/approval/${encodeURIComponent($.id)}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:U,source:"browser"})})).ok)return!1;if(U==="rejected")await _4("rejectGateSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:`Rejected gate "${$.title}" — do not proceed with it.`,source:"browser"})});return!0}async function iH($){return(await u6("reopenGate",`/api/canvas/ax/approval/${encodeURIComponent($.id)}/reopen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"browser"})})).ok}async function pH($,U){return(await u6("sendSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:$,source:"browser",...U?{target:U}:{}})})).ok}async function A1(){return(await u6("startSession","/api/canvas/ax/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"browser",label:g9,attached:!0,phase:"idle"})})).ok}async function E9($){return(await u6("endSession","/api/canvas/ax/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:$.source,agentId:$.agentId,attached:!1,endedBy:"human"})})).ok}var u9=s(null);function oH($){let{counts:U,snapshot:v}=$;if(typeof $.label!=="string"||typeof $.endedAt!=="string")return;u9.value={label:$.label,endedAt:$.endedAt,endedBy:$.endedBy==="human"||$.endedBy==="agent"||$.endedBy==="idle-timeout"?$.endedBy:void 0,unchanged:$.unchanged===!0,counts:{items:Number(U?.items??0)||0,done:Number(U?.done??0)||0,cancelled:Number(U?.cancelled??0)||0,rejected:Number(U?.rejected??0)||0,held:Number(U?.held??0)||0},snapshot:v&&typeof v.id==="string"?{id:v.id,name:String(v.name??"")}:null}}function dH(){u9.value=null}function nH(){if(!k6.value)return null;let $=b1.value;if(!$)return null;let U=D.value,v=$.nodeIds.map((z)=>U.get(z)).filter((z)=>z!==void 0),J=f9(v,$.padding);if(!J)return null;let _=1/Math.max(0.05,G$.value.scale);return G("div",{class:"scope-fence","data-fenced-count":v.length,style:{transform:`translate(${J.x}px, ${J.y}px)`,width:`${J.width}px`,height:`${J.height}px`},"aria-hidden":"true",children:[G("span",{class:"scope-fence-pill scope-fence-pill-top",style:{transform:`scale(${_})`},children:["Agent scope · ",v.length," node",v.length===1?"":"s"]},void 0,!0,void 0,this),G("span",{class:"scope-fence-pill scope-fence-pill-bottom",style:{transform:`scale(${_})`},children:"writes outside are blocked · reads allowed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var m9={markdown:"var(--c-accent)","mcp-app":"var(--c-ok)",webpage:"var(--c-warn)","json-render":"var(--c-ok)",graph:"var(--c-purple)",prompt:"var(--c-accent)",response:"var(--c-ok)",status:"var(--c-warn)",context:"var(--c-muted)",ledger:"var(--c-dim)",trace:"var(--c-purple)",file:"var(--c-accent)",diff:"var(--c-ok)",mermaid:"var(--c-purple)",image:"var(--c-ok)",html:"var(--c-warn)",group:"var(--c-accent)"};function pw($){let U=typeof $==="number"&&Number.isFinite($)?Math.floor($):1;return Math.max(1,Math.min(20,U))}function x9($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function K2($){return typeof $==="string"&&$.length>0}function tH($){let U=$.axStep;if(!x9(U))return null;if(!K2(U.flowId)||!K2(U.workItemId))return null;if(typeof U.index!=="number"||typeof U.total!=="number")return null;return{flowId:U.flowId,index:U.index,total:U.total,workItemId:U.workItemId}}function aH($){let U=$.axFlow;if(!x9(U)||!K2(U.flowId)||!Array.isArray(U.steps))return null;let v=[];for(let _ of U.steps){if(!x9(_)||!K2(_.nodeId)||!K2(_.workItemId))return null;if(typeof _.index!=="number")return null;v.push({index:_.index,nodeId:_.nodeId,workItemId:_.workItemId,title:typeof _.title==="string"?_.title:""})}if(v.length===0)return null;let J=x9(U.loop)?U.loop:{};return{flowId:U.flowId,title:typeof U.title==="string"?U.title:"Flow",steps:v,loop:{running:J.running===!0,run:typeof J.run==="number"&&Number.isFinite(J.run)?Math.max(0,Math.floor(J.run)):0,maxRuns:pw(J.maxRuns)}}}var ow={position:"sticky",bottom:"calc(-1 * var(--ax-dock-bleed, 12px))",marginTop:"12px",marginLeft:"calc(-1 * var(--ax-dock-bleed, 12px))",marginRight:"calc(-1 * var(--ax-dock-bleed, 12px))",marginBottom:"calc(-1 * var(--ax-dock-bleed, 12px))",padding:"9px var(--ax-dock-pad, 12px) 10px",background:"var(--c-panel-overlay)",borderTop:"1px solid var(--c-line)",backdropFilter:"blur(6px)"},eH={display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},$Q={fontSize:"10px",color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginRight:"auto"},UQ={...V1,background:"var(--c-accent-25)",color:"var(--c-text)"},dw=[{status:"in-progress",label:"Start",toast:"Step started"},{status:"done",label:"Done",toast:"Step done"},{status:"blocked",label:"Blocked",toast:"Step blocked"}];async function sH($,U,v){let J={...U,loop:v};W$($.id,{axFlow:J}),await A6($.id,{data:{axFlow:J}})}function _Q($){return typeof $?.axWorkStatus==="string"?$.axWorkStatus:"todo"}function nw({node:$,flow:U}){let[v,J]=f(""),{running:_,run:z,maxRuns:K}=U.loop,W=async()=>{await sH($,U,{running:!0,run:z>=K?0:z,maxRuns:K});let Y=U.steps.find((q)=>_Q(D.value.get(q.nodeId)?.data)!=="done"),Z=Y??U.steps[U.steps.length-1];await a4($,"ax.work.update",{id:Z.workItemId,status:Y?"in-progress":"done"},"Loop running")},O=async()=>{let Y=v.trim();if(!Y)return;await a4($,"ax.steer",{message:Y},"Steering sent"),J("")};return G("div",{class:"ax-flow-controls",style:{...eH,marginTop:"6px",rowGap:"4px"},children:[G("span",{class:"ax-flow-runs",style:$Q,children:_?`Loop running · run ${z+1}/${K}`:`Loop idle · ${z}/${K} runs`},void 0,!1,void 0,this),_?G("button",{type:"button",class:"ax-node-action",style:UQ,title:"Stop the loop now. The stop is persisted on this node, so it survives a refresh and no further step is opened.",onClick:(Y)=>{Y.stopPropagation(),sH($,U,{...U.loop,running:!1})},children:"Stop"},void 0,!1,void 0,this):G("button",{type:"button",class:"ax-node-action",style:V1,title:"Run this flow as a loop: each completed step opens the next one, and the last step starts the next run — until the run cap is reached or you press Stop.",onClick:(Y)=>{Y.stopPropagation(),W()},children:"Run loop"},void 0,!1,void 0,this),G("input",{class:"ax-flow-steer-input",value:v,placeholder:"Steer the agent…","aria-label":"Steer the agent",onInput:(Y)=>J(Y.target.value),onClick:(Y)=>Y.stopPropagation(),onKeyDown:(Y)=>{if(Y.key!=="Enter")return;Y.stopPropagation(),O()},style:{flex:"1 1 120px",minWidth:"90px",fontSize:"10px",padding:"3px 6px",borderRadius:"4px",border:"1px solid var(--c-line)",background:"var(--c-panel-overlay)",color:"var(--c-text)"}},void 0,!1,void 0,this),G("button",{type:"button",class:"ax-node-action",style:V1,title:"Send a steering message to the agent working this flow.",onClick:(Y)=>{Y.stopPropagation(),O()},children:"Steer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function h9({node:$}){let U=tH($.data);if(!U)return null;let v=aH($.data),J=_Q($.data);return G("div",{class:"ax-step-dock",style:ow,children:[G("div",{class:"ax-step-controls",style:eH,children:[G("span",{class:"ax-step-position",style:$Q,children:["Step ",U.index,"/",U.total]},void 0,!0,void 0,this),dw.map((_)=>G("button",{type:"button",class:"ax-node-action","aria-pressed":J===_.status,style:J===_.status?UQ:V1,title:`Set this step's work item to "${_.status}".`,onClick:(z)=>{z.stopPropagation(),a4($,"ax.work.update",{id:U.workItemId,status:_.status},_.toast)},children:_.label},_.status,!1,void 0,this))]},void 0,!0,void 0,this),v&&G(nw,{node:$,flow:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var S0=8,UU=s(null),R0=[],T0=[],zQ=null;function vQ($){let U=$?.data.parentGroup;return typeof U==="string"&&U.length>0?U:null}function JQ($){if(!$||!Array.isArray($.data.children))return[];return $.data.children.filter((U)=>typeof U==="string")}function tw($,U){let v=new Map(U.map((W)=>[W.id,W])),J=new Set([$]),_=v.get($);if(!_)return J;let z=vQ(_);while(z&&!J.has(z))J.add(z),z=vQ(v.get(z));if(_.type!=="group")return J;let K=[...JQ(_)];while(K.length>0){let W=K.pop();if(!W||J.has(W))continue;J.add(W);let O=v.get(W);if(O?.type==="group")K.push(...JQ(O))}return J}function KQ($,U){R0=[],T0=[],zQ=$;let v=Array.from(U),J=tw($,v);for(let _ of v){if(J.has(_.id))continue;let z=_.position.x,K=_.position.x+_.size.width,W=_.position.x+_.size.width/2,O=_.position.y,Y=_.position.y+_.size.height,Z=_.position.y+_.size.height/2;R0.push({val:z,minY:O,maxY:Y}),R0.push({val:K,minY:O,maxY:Y}),R0.push({val:W,minY:O,maxY:Y}),T0.push({val:O,minX:z,maxX:K}),T0.push({val:Y,minX:z,maxX:K}),T0.push({val:Z,minX:z,maxX:K})}}function GQ(){R0=[],T0=[],zQ=null}function WQ($,U,v,J){let _=[$,$+v/2,$+v],z=[U,U+J/2,U+J],K=[0,v/2,v],W=[0,J/2,J],O=null,Y=S0+1,Z=null;for(let F=0;F<3;F++){let k=_[F];for(let H of R0){let P=Math.abs(k-H.val);if(P<Y)Y=P,O=H.val-K[F],Z={axis:"x",pos:H.val,from:Math.min(H.minY,U),to:Math.max(H.maxY,U+J)}}}let q=null,X=S0+1,B=null;for(let F=0;F<3;F++){let k=z[F];for(let H of T0){let P=Math.abs(k-H.val);if(P<X)X=P,q=H.val-W[F],B={axis:"y",pos:H.val,from:Math.min(H.minX,$),to:Math.max(H.maxX,$+v)}}}let L=[];if(Z&&Y<=S0)L.push(Z);if(B&&X<=S0)L.push(B);return{x:O!==null&&Y<=S0?O:$,y:q!==null&&X<=S0?q:U,guides:L}}function OQ({nodeId:$,viewport:U,onMove:v,onDragEnd:J}){let _=C(!1),z=C({x:0,y:0}),K=C({x:0,y:0});return j((O,Y,Z)=>{O.stopPropagation(),O.preventDefault(),_.current=!0,document.documentElement.classList.add("is-node-dragging"),window.getSelection()?.removeAllRanges(),z.current={x:O.clientX,y:O.clientY},K.current={x:Y,y:Z};let q=null,X=null,B=()=>{if(X=null,!_.current||!q)return;let k=q;q=null;let H=U.value.scale,P=(k.x-z.current.x)/H,b=(k.y-z.current.y)/H;v($,K.current.x+P,K.current.y+b)},L=(k)=>{if(!_.current)return;if(q={x:k.clientX,y:k.clientY},X!==null)return;X=window.requestAnimationFrame(B)},F=()=>{if(X!==null)window.cancelAnimationFrame(X),B();_.current=!1,document.documentElement.classList.remove("is-node-dragging"),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F),document.removeEventListener("pointercancel",F),J()};document.addEventListener("pointermove",L),document.addEventListener("pointerup",F),document.addEventListener("pointercancel",F)},[$,U,v,J])}var aw=200,sw=100;function YQ({nodeId:$,viewport:U,onResize:v,onResizeEnd:J}){let _=C(!1),z=C({x:0,y:0}),K=C({w:0,h:0});return j((O,Y,Z)=>{O.stopPropagation(),O.preventDefault(),_.current=!0,z.current={x:O.clientX,y:O.clientY},K.current={w:Y,h:Z},document.documentElement.classList.add("is-node-resizing");let q=null,X=null,B=()=>{if(X=null,!_.current||!q)return;let k=q;q=null;let H=U.value.scale,P=(k.x-z.current.x)/H,b=(k.y-z.current.y)/H;v($,Math.max(aw,K.current.w+P),Math.max(sw,K.current.h+b))},L=(k)=>{if(!_.current)return;if(q={x:k.clientX,y:k.clientY},X!==null)return;X=window.requestAnimationFrame(B)},F=()=>{if(X!==null)window.cancelAnimationFrame(X),B();_.current=!1,document.documentElement.classList.remove("is-node-resizing"),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",F),document.removeEventListener("pointercancel",F),J()};document.addEventListener("pointermove",L),document.addEventListener("pointerup",F),document.addEventListener("pointercancel",F)},[$,U,v,J])}var ew={ArrowLeft:{dx:-1,dy:0},ArrowRight:{dx:1,dy:0},ArrowUp:{dx:0,dy:-1},ArrowDown:{dx:0,dy:1}};function $g($,U,v){let J=$.position.x+$.size.width/2,_=$.position.y+$.size.height/2,z=null,K=Number.POSITIVE_INFINITY;for(let W of v){if(W.id===$.id)continue;let O=W.position.x+W.size.width/2-J,Y=W.position.y+W.size.height/2-_,Z=O*U.dx+Y*U.dy;if(Z<=0)continue;let q=Math.abs(O*U.dy)+Math.abs(Y*U.dx);if(q>Z)continue;let X=Z+q*2;if(X<K)K=X,z=W}return z}var Ug=0.4,_g=0.55,vg=175;function Jg($,U,v=0){if(!Number.isFinite($)||$>=1)return 1;let _=Math.min(2.2,1/Math.max($,0.01));if(Number.isFinite(U)&&U>0)_=Math.min(_,U*Ug/TU);if(Number.isFinite(v)&&v>0)_=Math.min(_,v*_g/vg);return Math.max(1,_)}function ZQ({node:$,children:U,onContextMenu:v}){let J=C$.value===$.id,_=I$.value.has($.id),z=j$.value.has($.id),K=qU.value.has($.id),W=!K&&BU.value.has($.id),O=V2.value.has($.id),Y=!J&&tY.value.has($.id),Z=e4.value,q=Z!==null&&Z.has($.id),X=Z!==null&&!Z.has($.id),[B,L]=f(!1),F=C(null),k=j((y,L$,i$)=>{let y$=WQ(L$,i$,$.size.width,$.size.height),Z4=D.value.get(y);if(Z4?.position.x===y$.x&&Z4.position.y===y$.y){UU.value=y$.guides.length>0?y$.guides:null;return}q6(y,{position:{x:y$.x,y:y$.y}}),UU.value=y$.guides.length>0?y$.guides:null,$Z(y)},[$.size.width,$.size.height]),H=C(null),P=j(()=>{if(GQ(),UU.value=null,UO(null),H.current)document.removeEventListener("keydown",H.current),H.current=null;v6();let y=y4.value;if(eY(),!y||y.nodeId!==$.id)return;if(y.mode==="add")N8(y.groupId,[$.id]);else{let L$=D.value.get(y.groupId),i$=Array.isArray(L$?.data.children)?L$.data.children.filter((y$)=>typeof y$==="string"&&y$!==$.id):[];r2(y.groupId,i$)}},[$.id]),b=OQ({nodeId:$.id,viewport:G$,onMove:k,onDragEnd:P}),V=j((y,L$,i$)=>{let y$=D.value.get(y);if(y$?.size.width===L$&&y$.size.height===i$)return;q6(y,{size:{width:L$,height:i$}})},[]),E=j(()=>{W$($.id,{userResized:!0}),A6($.id,{data:{userResized:!0}}),v6()},[$.id]),A=YQ({nodeId:$.id,viewport:G$,onResize:V,onResizeEnd:E}),I=j((y)=>{y.stopPropagation(),y.preventDefault(),o$.value={fromId:$.id,fromX:$.position.x+$.size.width/2,fromY:$.position.y+$.size.height/2,cursorX:$.position.x+$.size.width/2,cursorY:$.position.y+$.size.height/2,targetId:null}},[$.id,$.position.x,$.position.y,$.size.width,$.size.height]),N=j((y)=>{if(B)return;if(R6.value==="connect"){I(y);return}if(y.shiftKey){y.stopPropagation(),m8($.id);return}if(V4($.id),UO($.id),jH($.id,typeof $.data.title==="string"&&$.data.title?$.data.title:$.type),KQ($.id,D.value.values()),$.type!=="group"){let L$=(i$)=>{if(i$.key==="Escape")sY()};H.current=L$,document.addEventListener("keydown",L$)}b(y,$.position.x,$.position.y)},[$.id,$.type,$.data.title,$.position.x,$.position.y,b,B,I]),R=j((y)=>{if(y.stopPropagation(),R6.value==="connect"){I(y);return}if(y.shiftKey){m8($.id);return}V4($.id)},[$.id,I]),p=j((y)=>{if(v)v(y,$.id)},[v,$.id]),l=j((y)=>{let L$=y.target;if(L$&&L$!==y.currentTarget&&L$.closest('input, textarea, [contenteditable="true"]'))return;let i$=ew[y.key];if(i$){y.preventDefault();let y$=$g($,i$,D.value.values());if(!y$)return;V4(y$.id),requestAnimationFrame(()=>{document.querySelector(`.canvas-node[data-node-id="${CSS.escape(y$.id)}"]`)?.focus()})}else if(y.key==="Enter"&&y.target===y.currentTarget&&r0.has($.type))y.preventDefault(),Q4($.id)},[$]),T=j((y)=>{y.stopPropagation(),L(!0),requestAnimationFrame(()=>F.current?.focus())},[]),r=$.data.title||($.type==="file"?($.data.path||$.data.content||"").split(/[\\/]/).pop()??"":"")||Z6[$.type],t=j((y)=>{let L$=y.trim();if(L$&&L$!==r)W$($.id,{title:L$}),A6($.id,{title:L$});L(!1)},[$.id,r]),i=C(null),o=C(!1),z$=C(null);u(()=>{if(o.current||!Z5($))return;let y=i.current;if(!y)return;let L$=new ResizeObserver(()=>{if(o.current){L$.disconnect();return}let i$=y.scrollHeight,y$=zq($,i$);if(y$===null)return;if(Math.abs(y$-$.size.height)>8){if(IU($.id,{width:$.size.width,height:y$}),z$.current!==null)window.clearTimeout(z$.current);z$.current=window.setTimeout(()=>{v6({recordHistory:!1}),z$.current=null},0)}o.current=!0,L$.disconnect()});return L$.observe(y),()=>{if(L$.disconnect(),z$.current!==null)window.clearTimeout(z$.current),z$.current=null}},[$.id,$.type,$.data.mode,$.data.strictSize,$.collapsed,$.size.width,$.size.height]);let B$=$.pinned,S6=$.type==="trace",N$=S6&&$.data.status==="running",t$=$.type==="group",O4=$.data.strictSize===!0,A4=Math.max(G$.value.scale,0.01),S=Jg(A4,$.collapsed?0:$.size.height,$.size.width),e=t$&&$.data.color?$.data.color:void 0,H$={left:`${$.position.x}px`,top:`${$.position.y}px`,width:`${$.size.width}px`,height:$.collapsed?"auto":`${$.size.height}px`,zIndex:$.zIndex,"--node-chrome-scale":S.toFixed(3),...e?{"--group-color":e}:{}},K$=k6.value&&NH.value.has($.id),_$=["canvas-node",J?"active":"",Y?"neighbor":"",q?"search-match":"",X?"search-dimmed":"",_?"selected":"",z?"context-pinned":"",K?"attention-focus-primary":"",W?"attention-focus-secondary":"",O?"attention-pulse":"",B$?"pinned":"",S6?"trace-node":"",N$?"trace-running":"",t$?"group-node":"",O4?"strict-size":"",K$?"agent-mutating":""].filter(Boolean).join(" "),v$=t$?(Array.isArray($.data.children)?$.data.children:[]).filter((y)=>typeof y==="string"&&D.value.has(y)):[],[J$,d]=f(!1),O$=y4.value,b6=t$&&O$?.groupId===$.id&&O$.mode==="add",E6=t$&&O$?.groupId===$.id&&O$.mode==="remove",Y4=o$.value?.targetId===$.id,M6=t$?[...new Set(v$.map((y)=>D.value.get(y)?.type).filter((y)=>!!y))].slice(0,4):[];if(t$&&$.collapsed)return G("div",{class:`${_$} group-chip`,"data-node-type":$.type,style:{...H$,width:"auto",height:"auto"},onPointerDown:R,onContextMenu:p,title:"Expand group","data-testid":"group-chip",children:G("div",{class:"node-titlebar group-chip-inner",onPointerDown:N,children:[G("button",{type:"button",class:"group-chip-expand","aria-label":`Expand group ${r}`,onClick:(y)=>{y.stopPropagation(),wU($.id)},children:"▸"},void 0,!1,void 0,this),G("div",{class:"group-chip-text",children:[G("div",{class:"group-chip-name",children:r},void 0,!1,void 0,this),G("div",{class:"group-chip-meta",children:[M6.map((y)=>G("span",{class:"group-kind-dot",style:{background:m9[y]},"aria-hidden":"true"},y,!1,void 0,this)),G("span",{class:"group-chip-count",children:[v$.length," node",v$.length===1?"":"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return G("div",{class:`${_$}${b6?" is-drop-target":""}${E6?" is-drop-source":""}${Y4?" is-edge-target":""}${t$&&J$?" group-menu-open":""}`,"data-node-type":$.type,"data-node-id":$.id,style:H$,tabIndex:J?0:-1,onKeyDown:l,onPointerDown:R,onMouseDown:(y)=>{if(y.shiftKey)y.preventDefault()},onContextMenu:p,children:[t$&&G("div",{class:"node-titlebar group-edge-row",onPointerDown:N,children:[G("span",{class:"group-name-pill",children:[B?G("input",{ref:F,class:"node-title-input group-title-input",value:r,onBlur:(y)=>t(y.target.value),onKeyDown:(y)=>{if(y.key==="Enter")t(y.target.value);if(y.key==="Escape")L(!1)},onClick:(y)=>y.stopPropagation()},void 0,!1,void 0,this):G("span",{class:"group-name",onDblClick:T,title:`${r} — double-click to rename`,children:r},void 0,!1,void 0,this),G("span",{class:"group-count",children:v$.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"group-edge-spacer"},void 0,!1,void 0,this),G("span",{class:"group-actions",role:"toolbar","aria-label":`${r} actions`,children:[G("button",{type:"button",class:"group-action",title:"Auto-arrange children","aria-label":"Auto-arrange children",disabled:v$.length===0,onClick:(y)=>{y.stopPropagation(),N8($.id,v$,"grid")},children:G("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","aria-hidden":"true",children:[G("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G("button",{type:"button",class:"group-action",title:"Collapse group","aria-label":"Collapse group",onClick:(y)=>{y.stopPropagation(),wU($.id)},children:G("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:G("path",{d:"M3 10 L8 5 L13 10"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("button",{type:"button",class:"group-action",title:"Rename · Ungroup · Pin all to context","aria-label":"Group menu","aria-expanded":J$,onClick:(y)=>{y.stopPropagation(),d((L$)=>!L$)},children:"⋯"},void 0,!1,void 0,this),J$&&G("div",{class:"group-menu",role:"menu",onPointerDown:(y)=>y.stopPropagation(),children:[G("button",{type:"button",role:"menuitem",onClick:(y)=>{y.stopPropagation(),d(!1),L(!0),requestAnimationFrame(()=>F.current?.focus())},children:"Rename"},void 0,!1,void 0,this),G("button",{type:"button",role:"menuitem",onClick:(y)=>{y.stopPropagation(),d(!1),h6($.id),HU($.id)},children:"Ungroup"},void 0,!1,void 0,this),G("button",{type:"button",role:"menuitem",disabled:v$.length===0,onClick:(y)=>{y.stopPropagation(),d(!1),Uv(v$)},children:"Pin all to context"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!t$&&G("div",{class:"node-titlebar",onPointerDown:N,children:[G("span",{class:"node-type-icon","aria-hidden":"true",children:(()=>{let y=h4($.type);return G(y,{size:Math.round(14*S)},void 0,!1,void 0,this)})()},void 0,!1,void 0,this),typeof $.data.axWorkStatus==="string"&&G("span",{class:`node-ax-status node-ax-status-${$.data.axWorkStatus}`,children:$.data.axWorkStatus},void 0,!1,void 0,this),B?G("input",{ref:F,class:"node-title-input",value:r,onBlur:(y)=>t(y.target.value),onKeyDown:(y)=>{if(y.key==="Enter")t(y.target.value);if(y.key==="Escape")L(!1)},onClick:(y)=>y.stopPropagation()},void 0,!1,void 0,this):G("span",{class:"node-title",onDblClick:T,title:`${r} — double-click to rename`,children:r},void 0,!1,void 0,this),G("div",{class:"node-controls",children:[B$&&G("span",{class:"pin-indicator",title:"Pinned",children:"⊙"},void 0,!1,void 0,this),G("button",{type:"button",class:`ctx-pin-btn${z?" ctx-pin-active":""}`,onClick:(y)=>{y.stopPropagation(),$1($.id)},title:z?"Remove from context":"Add to context",children:"✦"},void 0,!1,void 0,this),Pv($)&&G("button",{type:"button",onClick:(y)=>{y.stopPropagation(),kv($)},title:"Open as site",children:"↗"},void 0,!1,void 0,this),r0.has($.type)&&G("button",{type:"button",onClick:(y)=>{y.stopPropagation(),Q4($.id)},title:"Expand (focus mode)",children:"⤢"},void 0,!1,void 0,this),G("button",{type:"button",onClick:(y)=>{y.stopPropagation(),wU($.id)},title:$.collapsed?"Expand":"Collapse",children:$.collapsed?"▸":"▾"},void 0,!1,void 0,this),G("button",{type:"button",onClick:(y)=>{y.stopPropagation(),h6($.id),n4($.id)},title:"Close",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!$.collapsed&&G("div",{ref:i,class:"node-body",children:[U,G(h9,{node:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!$.collapsed&&G("div",{class:"node-resize-handle",onPointerDown:(y)=>A(y,$.size.width,$.size.height)},void 0,!1,void 0,this),_&&["tl","tr","bl","br"].map((y)=>G("span",{class:`node-selection-handle is-${y}`,"aria-hidden":"true"},y,!1,void 0,this)),s1.value.has($.id)&&G("span",{class:"node-yield-pill","data-testid":"yield-pill",children:[G("span",{class:"node-yield-dot","aria-hidden":"true"},void 0,!1,void 0,this),s1.value.get($.id)," took over — agent yielded"]},void 0,!0,void 0,this),!t$&&["top","right","bottom","left"].map((y)=>G("div",{class:`node-port node-port-${y}`,onPointerDown:(L$)=>{L$.stopPropagation(),L$.preventDefault();let i$=$.position.x+$.size.width/2,y$=$.position.y+$.size.height/2,Z4=$.size.width/2,B2=$.size.height/2,q4,I4;switch(y){case"top":q4=i$,I4=y$-B2;break;case"bottom":q4=i$,I4=y$+B2;break;case"left":q4=i$-Z4,I4=y$;break;case"right":q4=i$+Z4,I4=y$;break}o$.value={fromId:$.id,fromX:q4,fromY:I4,cursorX:q4,cursorY:I4}}},y,!1,void 0,this))]},void 0,!0,void 0,this)}var zg={relation:"var(--c-muted)","depends-on":"var(--c-warn)",flow:"var(--c-accent)",references:"var(--c-muted)"},Kg=new Set(["depends-on","flow"]);function Gg($){if(!Number.isFinite($)||$<=0)return 1;return $<1?1/$:1}function Wg($,U){let v=`${8*U} ${4*U}`;if($.style==="dashed")return v;if($.style==="dotted")return`${3*U} ${3*U}`;if($.type==="references"&&!$.style)return v;return}function c9($,U){let v=$.position.x+$.size.width/2,J=$.position.y+$.size.height/2,_=U.position.x+U.size.width/2,z=U.position.y+U.size.height/2,K=_-v,W=z-J,O=$.size.width/2,Y=$.size.height/2,Z=Math.abs(W/(K||0.001)),q=Y/(O||0.001);if(Z>q){let B=W>0?1:-1;return{x:v+Y/Z*(K>0?1:-1),y:J+Y*B,side:B>0?"bottom":"top"}}let X=K>0?1:-1;return{x:v+O*X,y:J+Z*O*(W>0?1:-1),side:X>0?"right":"left"}}function l9($,U){switch($.side){case"top":return{x:$.x,y:$.y-U};case"bottom":return{x:$.x,y:$.y+U};case"left":return{x:$.x-U,y:$.y};case"right":return{x:$.x+U,y:$.y}}}function Og($,U,v,J,_,z,K,W){return{x:0.125*$+0.375*v+0.375*_+0.125*K,y:0.125*U+0.375*J+0.375*z+0.125*W}}function Yg({edge:$,fromNode:U,toNode:v,focused:J,dimmed:_,selected:z,scale:K,onContextMenu:W}){let O=c9(U,v),Y=c9(v,U),Z=Y.x-O.x,q=Y.y-O.y,X=Math.sqrt(Z*Z+q*q),B=Math.min(Math.max(X*0.35,32),160),L=l9(O,B),F=l9(Y,B),k=`M ${O.x} ${O.y} C ${L.x} ${L.y}, ${F.x} ${F.y}, ${Y.x} ${Y.y}`,H=zg[$.type],P=Kg.has($.type),b=Wg($,K),V=Math.min(K,2.2),E=$.label&&K<=3.4?Og(O.x,O.y,L.x,L.y,F.x,F.y,Y.x,Y.y):null,A=`edge-path-${$.id}`;return G("g",{children:[G("path",{d:k,fill:"none",stroke:"transparent","stroke-width":12*K,style:{cursor:"pointer",pointerEvents:"stroke"},onClick:(I)=>{I.stopPropagation(),C4.value=$.id},onContextMenu:W?(I)=>W(I,$.id):void 0},void 0,!1,void 0,this),(J||z)&&G("path",{d:k,fill:"none",stroke:H,"stroke-width":6*K,"stroke-dasharray":b,opacity:z?0.3:0.15,style:{filter:"blur(3px)"}},void 0,!1,void 0,this),G("path",{id:A,d:k,class:z?"edge-selected":void 0,fill:"none",stroke:H,"stroke-width":(z?3:J?2.5:1.5)*K,"stroke-dasharray":b,"marker-end":P?"url(#edge-arrow)":void 0,opacity:z?1:_?0.2:J?1:0.85,style:{transition:"opacity 0.2s, stroke-width 0.2s"}},void 0,!1,void 0,this),$.animated&&G("circle",{r:3*K,fill:H,opacity:"0.9",children:G("animateMotion",{dur:"2s",repeatCount:"indefinite",children:G("mpath",{href:`#${A}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),E&&$.label&&G("g",{transform:`translate(${E.x}, ${E.y})`,children:[G("rect",{class:"edge-label-bg",x:-($.label.length*3.5+8)*V,y:-10*V,width:($.label.length*7+16)*V,height:20*V,rx:4*V},void 0,!1,void 0,this),G("text",{class:"edge-label","text-anchor":"middle","dominant-baseline":"central",fill:"var(--c-text)",children:$.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qQ({nodes:$,edges:U,onEdgeContextMenu:v}){let J=$.value,_=Array.from(U.value.values()),z=C$.value,K=z!==null,W=e4.value,O=W!==null,Y=Gg(G$.value.scale);if(_.length===0&&!o$.value)return null;let Z=96,q=Array.from(J.values());if(q.length===0)return null;let X=Math.min(...q.map((P)=>P.position.x))-Z,B=Math.min(...q.map((P)=>P.position.y))-Z,L=Math.max(...q.map((P)=>P.position.x+P.size.width))+Z,F=Math.max(...q.map((P)=>P.position.y+P.size.height))+Z,k=Math.max(1,L-X),H=Math.max(1,F-B);return G("svg",{"aria-label":"Canvas connections",role:"img",viewBox:`${X} ${B} ${k} ${H}`,width:k,height:H,style:{position:"absolute",top:`${B}px`,left:`${X}px`,pointerEvents:"none",overflow:"visible","--edge-chrome-scale":Y.toFixed(3),"--edge-label-scale":Math.min(Y,2.2).toFixed(3)},children:[G("title",{children:"Canvas connections"},void 0,!1,void 0,this),G("defs",{children:G("marker",{id:"edge-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:8*Math.min(Y,2.2),markerHeight:8*Math.min(Y,2.2),orient:"auto-start-reverse",children:G("path",{d:"M 0 1 L 10 5 L 0 9 z",fill:"currentColor",opacity:"0.75"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),_.map((P)=>{let b=$v(P.from),V=$v(P.to);if(!b||!V||b.id===V.id)return null;let E=K&&(P.from===z||P.to===z),A=O&&!(W.has(P.from)||W.has(P.to));return G(Yg,{edge:P,fromNode:b,toNode:V,focused:E,dimmed:K&&!E||A,selected:C4.value===P.id,scale:Y,onContextMenu:v},P.id,!1,void 0,this)}),o$.value&&(()=>{let P=o$.value,b=$v(P.fromId),V={position:{x:P.cursorX,y:P.cursorY},size:{width:1,height:1}},E;if(b){let A=c9(b,V),I=c9(V,b),N=I.x-A.x,R=I.y-A.y,p=Math.sqrt(N*N+R*R),l=Math.min(Math.max(p*0.35,32),160),T=l9(A,l),r=l9(I,l);E=`M ${A.x} ${A.y} C ${T.x} ${T.y}, ${r.x} ${r.y}, ${I.x} ${I.y}`}else{let A=P.cursorX-P.fromX,I=P.cursorY-P.fromY,N=Math.sqrt(A*A+I*I),R=Math.min(N*0.25,80),p=A/(N||1),l=I/(N||1);E=`M ${P.fromX} ${P.fromY} C ${P.fromX+p*R} ${P.fromY+l*R}, ${P.cursorX-p*R} ${P.cursorY-l*R}, ${P.cursorX} ${P.cursorY}`}return G("g",{children:[G("path",{d:E,fill:"none",stroke:"var(--c-accent)","stroke-width":6*Y,opacity:"0.1",style:{filter:"blur(3px)"}},void 0,!1,void 0,this),G("path",{d:E,fill:"none",stroke:"var(--c-accent)","stroke-width":2*Y,"stroke-dasharray":`${6*Y} ${4*Y}`,opacity:"0.8"},void 0,!1,void 0,this),G("circle",{cx:P.cursorX,cy:P.cursorY,r:5*Y,fill:"var(--c-accent)",opacity:"0.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})()]},void 0,!0,void 0,this)}function Zg($){let[U,...v]=$;if(!U)return"";return v.reduce((J,_)=>`${J} L ${_.x} ${_.y}`,`M ${U.x} ${U.y}`)}function GO({annotations:$}){if($.length===0)return null;return G("svg",{class:"annotation-layer","aria-hidden":"true",children:$.map((U)=>{let v=U.color==="currentColor"?"var(--c-annotation)":U.color;if(U.type==="text"){let J=U.points[0];if(!J||!U.text)return null;return G("text",{x:J.x,y:J.y,fill:v,"font-size":U.width,"font-family":"var(--font)","font-weight":"700",opacity:"0.95",children:U.text},U.id,!1,void 0,this)}return G("path",{d:Zg(U.points),fill:"none",stroke:v,"stroke-width":U.width,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.9"},U.id,!1,void 0,this)})},void 0,!1,void 0,this)}var qg=0.1,Bg=4,BQ=1;function XQ($){return Math.min(Bg,Math.max(qg,$))}function HQ({viewport:$,onViewportChange:U,onViewportCommit:v,disabled:J=!1}){let _=C(null),z=C(!1),K=C({x:0,y:0}),W=C(0),O=C(null),Y=j((H)=>{if(O.current!==null)window.clearTimeout(O.current);O.current=window.setTimeout(()=>{O.current=null,v(H)},140)},[v]);function Z(H){if(H.deltaMode!==0)return H.deltaX===0;return H.deltaX===0&&Number.isInteger(H.deltaY)&&Math.abs(H.deltaY)>=50}let q=j((H)=>{if(J)return;H.preventDefault();let P=$.value;if(H.ctrlKey||H.metaKey||Z(H)){let b=_.current?.getBoundingClientRect();if(!b)return;let V=H.clientX-b.left,E=H.clientY-b.top,A=-H.deltaY*0.002,I=XQ(P.scale*(1+A)),N=I/P.scale,R={x:V-N*(V-P.x),y:E-N*(E-P.y),scale:I};U(R),Y(R)}else{let b={x:P.x-H.deltaX*BQ,y:P.y-H.deltaY*BQ,scale:P.scale};U(b),Y(b)}},[J,$,U,Y]),X=j((H)=>{if(J)return;let P=_.current;if(!P)return;if(H.button===1)H.preventDefault();else if(AU()){if(H.target!==P)return}else return;z.current=!0,K.current={x:H.clientX,y:H.clientY},P.setPointerCapture(H.pointerId)},[J]),B=j((H)=>{if(!z.current)return;if(J)return;let P=H.clientX-K.current.x,b=H.clientY-K.current.y;K.current={x:H.clientX,y:H.clientY};let V=$.value;U({x:V.x+P,y:V.y+b,scale:V.scale})},[J,$,U]),L=j(()=>{if(z.current)v($.value);z.current=!1},[v,$]),F=j((H)=>{if(J)return;if(H.touches.length!==2){W.current=0;return}H.preventDefault();let P=H.touches[0],b=H.touches[1],V=Math.hypot(b.clientX-P.clientX,b.clientY-P.clientY),E=(P.clientX+b.clientX)/2,A=(P.clientY+b.clientY)/2;if(W.current>0){let I=$.value,N=_.current?.getBoundingClientRect();if(!N)return;let R=E-N.left,p=A-N.top,l=V/W.current,T=XQ(I.scale*l),r=T/I.scale,t={x:R-r*(R-I.x),y:p-r*(p-I.y),scale:T};U(t),Y(t)}W.current=V},[J,$,U,Y]),k=j(()=>{if(O.current!==null)window.clearTimeout(O.current),O.current=null;v($.value),W.current=0},[v,$]);return u(()=>{let H=_.current;if(!H)return;return H.addEventListener("wheel",q,{passive:!1}),H.addEventListener("pointerdown",X),H.addEventListener("pointermove",B),H.addEventListener("pointerup",L),H.addEventListener("pointercancel",L),H.addEventListener("touchmove",F,{passive:!1}),H.addEventListener("touchend",k),()=>{if(O.current!==null)window.clearTimeout(O.current);H.removeEventListener("wheel",q),H.removeEventListener("pointerdown",X),H.removeEventListener("pointermove",B),H.removeEventListener("pointerup",L),H.removeEventListener("pointercancel",L),H.removeEventListener("touchmove",F),H.removeEventListener("touchend",k)}},[q,X,B,L,F,k]),_}function Xg($){switch($.type){case"markdown":return G(Hv,{node:$},void 0,!1,void 0,this);case"mcp-app":return G(L1,{node:$},void 0,!1,void 0,this);case"webpage":return G(Q9,{node:$},void 0,!1,void 0,this);case"json-render":return G(L1,{node:$},void 0,!1,void 0,this);case"graph":return G(L1,{node:$},void 0,!1,void 0,this);case"prompt":return G(L9,{node:$},void 0,!1,void 0,this);case"response":return G(F9,{node:$},void 0,!1,void 0,this);case"status":return G(X9,{node:$},void 0,!1,void 0,this);case"context":return G(a2,{node:$},void 0,!1,void 0,this);case"ledger":return G(Ov,{node:$},void 0,!1,void 0,this);case"trace":return G(P9,{node:$},void 0,!1,void 0,this);case"file":return G(Wv,{node:$},void 0,!1,void 0,this);case"diff":return G(s2,{node:$},void 0,!1,void 0,this);case"mermaid":return G(bv,{node:$},void 0,!1,void 0,this);case"image":return G(H9,{node:$},void 0,!1,void 0,this);case"html":return G($2,{node:$},void 0,!1,void 0,this);case"group":return G(lX,{node:$},void 0,!1,void 0,this);default:return G("div",{children:"Unknown node type"},void 0,!1,void 0,this)}}function Hg($,U,v){let J=v.x-U.x,_=v.y-U.y,z=J*J+_*_;if(z===0)return Math.hypot($.x-U.x,$.y-U.y);let K=Math.max(0,Math.min(1,(($.x-U.x)*J+($.y-U.y)*_)/z));return Math.hypot($.x-(U.x+K*J),$.y-(U.y+K*_))}function Qg($,U,v){for(let J=$.length-1;J>=0;J--){let _=$[J];if(!_)continue;let z=v+_.width;if(U.x<_.bounds.x-z||U.x>_.bounds.x+_.bounds.width+z||U.y<_.bounds.y-z||U.y>_.bounds.y+_.bounds.height+z)continue;if(_.type==="text")return _;for(let K=1;K<_.points.length;K++){let W=_.points[K-1],O=_.points[K];if(W&&O&&Hg(U,W,O)<=v+_.width/2)return _}}return null}var WO="currentColor",QQ=4,LQ=24,Lg=14,FQ={width:520,height:420};function Fg($){let U=$.trim();if(!U||/\s/.test(U))return null;let v=/^[a-z][a-z0-9+.-]*:/i.test(U)?U:`https://${U}`;try{let J=new URL(v);if(J.protocol!=="http:"&&J.protocol!=="https:")return null;return J.toString()}catch{return null}}function OO($){let U=$.trim();if(!U)return[];let v=U.includes(`
|
|
271
|
-
`)?U.split(/\r?\n/):U.split(/\s+/),J=new Set,_=[];for(let z of v){let K=z.trim();if(!K||K.startsWith("#"))continue;let W=Fg(K);if(!W||J.has(W))continue;J.add(W),_.push(W)}return _}function Pg($){let U=OO($.getData("text/uri-list"));if(U.length>0)return U;return OO($.getData("text/plain"))}function kg($){if(!$)return!1;return $.types.includes("text/uri-list")||$.types.includes("text/plain")}function PQ($){if(!($ instanceof HTMLElement))return!1;return Boolean($.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'))}function bg($,U,v=new Set){let J=[],_=0;for(let z of $){if(v.has(z.id))continue;if(U&&z.id===U)continue;if(z.type==="group")J.splice(_++,0,z);else J.push(z)}return J}function kQ({onNodeContextMenu:$,onEdgeContextMenu:U,onCanvasContextMenu:v,annotationMode:J=!1,annotationTool:_=null}){let z=G$.value,K=C(!1),W=C(null),O=C(!1),Y=C([]),[Z,q]=f(null),[X,B]=f(null),[L,F]=f(null),k=C(null),[H,P]=f(!1),b=C(0),V=C(null),E=C(null);u(()=>{let S=null,e=B4(()=>{G$.value;let H$=E.current;if(!H$)return;if(H$.style.willChange="transform",S)clearTimeout(S);S=setTimeout(()=>{H$.style.willChange="auto"},180)});return()=>{if(S)clearTimeout(S);e()}},[]);let A=HQ({viewport:G$,disabled:J,onViewportChange:(S)=>{if(K.current||J)return;NU(),WZ(S)},onViewportCommit:(S)=>{if(K.current||J)return;NU(),YZ(S)}}),I=j((S)=>{k.current=S,F(S)},[]),N=j(async(S,e,H$)=>{if(S.length===0)return;let{width:K$,height:_$}=FQ,v$=24,J$=Math.ceil(Math.sqrt(S.length)),d=Math.ceil(S.length/J$),O$=J$*K$+Math.max(0,J$-1)*v$,b6=d*_$+Math.max(0,d-1)*v$;for(let E6=0;E6<S.length;E6++){let Y4=E6%J$,M6=Math.floor(E6/J$),y=e-O$/2+Y4*(K$+v$),L$=H$-b6/2+M6*(_$+v$);await n6({type:"webpage",content:S[E6],x:y,y:L$,width:K$,height:_$})}},[]),R=j((S)=>{let e=A.current;if(!e)return;if(_==="eraser"){if((S.target instanceof Element?S.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;S.preventDefault(),S.stopPropagation();let d=e.getBoundingClientRect(),O$=G$.value,b6={x:(S.clientX-d.left-O$.x)/O$.scale,y:(S.clientY-d.top-O$.y)/O$.scale},E6=Qg(Array.from(bU.value.values()),b6,Lg/O$.scale);if(E6)GZ(E6.id);return}if(_==="text"){if((S.target instanceof Element?S.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;S.preventDefault(),S.stopPropagation(),C$.value=null,I6();let d=e.getBoundingClientRect(),O$=G$.value;I({x:(S.clientX-d.left-O$.x)/O$.scale,y:(S.clientY-d.top-O$.y)/O$.scale,value:""});return}if(_==="pen"){if((S.target instanceof Element?S.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;S.preventDefault(),S.stopPropagation(),C$.value=null,I6(),O.current=!0;let d=e.getBoundingClientRect(),O$=G$.value,b6={x:(S.clientX-d.left-O$.x)/O$.scale,y:(S.clientY-d.top-O$.y)/O$.scale};Y.current=[b6],B({id:"draft-annotation",type:"freehand",points:[b6],bounds:{x:0,y:0,width:0,height:0},color:WO,width:QQ,createdAt:""}),e.setPointerCapture(S.pointerId);return}if(S.target!==e)return;if(AU()||S.button===1){if(!S.shiftKey&&!V.current)C$.value=null,I6();return}S.preventDefault(),S.stopPropagation(),K.current=!0;let H$=e.getBoundingClientRect(),K$=S.clientX-H$.left,_$=S.clientY-H$.top,v$={startX:K$,startY:_$,currentX:K$,currentY:_$};V.current=v$,q(v$),e.setPointerCapture(S.pointerId)},[_,A]);u(()=>{return B4(()=>{let S=G$.value,e=W.current,H$=A.current;if(!e||!H$)return;let K$=H$.getBoundingClientRect();V9({x:(e.x-K$.left-S.x)/S.scale,y:(e.y-K$.top-S.y)/S.scale})})},[]);let p=j((S)=>{{let K$=A.current;if(K$){W.current={x:S.clientX,y:S.clientY};let _$=K$.getBoundingClientRect(),v$=G$.value;V9({x:(S.clientX-_$.left-v$.x)/v$.scale,y:(S.clientY-_$.top-v$.y)/v$.scale})}}if(O.current){let K$=A.current;if(!K$)return;let _$=K$.getBoundingClientRect(),v$=G$.value,J$={x:(S.clientX-_$.left-v$.x)/v$.scale,y:(S.clientY-_$.top-v$.y)/v$.scale},d=Y.current.at(-1);if(d&&Math.hypot(J$.x-d.x,J$.y-d.y)<2)return;Y.current=[...Y.current,J$],B((O$)=>O$?{...O$,points:Y.current}:null);return}if(!K.current||!V.current)return;let e=A.current?.getBoundingClientRect();if(!e)return;let H$={...V.current,currentX:S.clientX-e.left,currentY:S.clientY-e.top};V.current=H$,q(H$)},[A]),l=j((S)=>{if(O.current){O.current=!1;let J$=Y.current;if(Y.current=[],B(null),J$.length>=2)r8({points:J$,color:WO,width:QQ});let d=A.current;if(d?.hasPointerCapture(S.pointerId))d.releasePointerCapture(S.pointerId);return}let e=V.current;if(!K.current||!e)return;K.current=!1,V.current=null;let H$=Math.min(e.startX,e.currentX),K$=Math.max(e.startX,e.currentX),_$=Math.min(e.startY,e.currentY),v$=Math.max(e.startY,e.currentY);if(K$-H$<=5&&v$-_$<=5)C$.value=null,I6();if(K$-H$>5||v$-_$>5){let J$=G$.value,d=(H$-J$.x)/J$.scale,O$=(K$-J$.x)/J$.scale,b6=(_$-J$.y)/J$.scale,E6=(v$-J$.y)/J$.scale,Y4=[];for(let M6 of D.value.values()){let y=M6.position.x,L$=M6.position.y;if(y+M6.size.width>d&&y<O$&&L$+M6.size.height>b6&&L$<E6)Y4.push(M6.id)}if(Y4.length>0)aY(Y4)}q(null)},[]);u(()=>{if(J)return;if(!O.current&&!X&&!L)return;O.current=!1,Y.current=[],B(null),I(null)},[J,X,I,L]);let T=j(()=>{let S=k.current;if(!S)return;let e=S.value.trim();if(I(null),!e)return;let H$={x:S.x,y:S.y};r8({type:"text",points:[H$],color:WO,width:LQ,text:e})},[I]);u(()=>{if(_!=="text"&&L)I(null)},[_,I,L]),u(()=>{let S=(_$,v$,J$)=>{let d=null;for(let O$ of D.value.values()){if(O$.id===J$||O$.type==="group")continue;if(_$>=O$.position.x&&_$<=O$.position.x+O$.size.width&&v$>=O$.position.y&&v$<=O$.position.y+O$.size.height)d=O$.id}return d};function e(_$){if(!o$.value)return;let v$=A.current;if(!v$)return;let J$=v$.getBoundingClientRect(),d=G$.value,O$=(_$.clientX-J$.left-d.x)/d.scale,b6=(_$.clientY-J$.top-d.y)/d.scale;o$.value={...o$.value,cursorX:O$,cursorY:b6,targetId:S(O$,b6,o$.value.fromId)}}function H$(){let _$=o$.value;if(!_$)return;o$.value=null;let v$=_$.targetId;if(!v$)return;if(_$.withLabel){S4("Edge label","label text").then((J$)=>{j1(_$.fromId,v$,"relation",J$??void 0)});return}j1(_$.fromId,v$,"relation",void 0)}function K$(_$){let v$=o$.value;if(!v$)return;if(_$.key==="Escape")_$.preventDefault(),o$.value=null;else if(_$.key==="l"||_$.key==="L")_$.preventDefault(),o$.value={...v$,withLabel:!v$.withLabel}}return document.addEventListener("pointermove",e),document.addEventListener("pointerup",H$),document.addEventListener("keydown",K$),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",H$),document.removeEventListener("keydown",K$)}},[A]);let r=j((S)=>{if(J)return;let e=A.current;if(!e||S.target!==e)return;let H$=e.getBoundingClientRect(),K$=G$.value,_$=(S.clientX-H$.left-K$.x)/K$.scale,v$=(S.clientY-H$.top-K$.y)/K$.scale,J$=520,d=360;n6({type:"markdown",title:"New note",x:_$-J$/2,y:v$-d/2,width:J$,height:d})},[J,A]),t=j((S)=>{if(J)return;if(!v)return;let e=A.current;if(!e)return;if((S.target instanceof Element?S.target:null)?.closest(".canvas-node"))return;let K$=e.getBoundingClientRect(),_$=G$.value,v$=(S.clientX-K$.left-_$.x)/_$.scale,J$=(S.clientY-K$.top-_$.y)/_$.scale;v(S,v$,J$)},[J,A,v]),i=j((S)=>{if(S.preventDefault(),b.current++,S.dataTransfer?.types.includes("Files")||kg(S.dataTransfer))P(!0)},[]),o=j((S)=>{if(S.preventDefault(),S.dataTransfer)S.dataTransfer.dropEffect="copy"},[]),z$=j((S)=>{if(S.preventDefault(),b.current--,b.current<=0)b.current=0,P(!1)},[]),B$=j(async(S)=>{S.preventDefault(),P(!1),b.current=0;let e=A.current;if(!e||!S.dataTransfer)return;let H$=e.getBoundingClientRect(),K$=G$.value,_$=(S.clientX-H$.left-K$.x)/K$.scale,v$=(S.clientY-H$.top-K$.y)/K$.scale,J$=Array.from(S.dataTransfer.files);if(J$.length===0){let d=Pg(S.dataTransfer);await N(d,_$,v$);return}await k9(J$,_$,v$)},[A,N]);u(()=>{let S=async(e)=>{if(e.defaultPrevented)return;if(PQ(e.target instanceof Element?e.target:null))return;if(PQ(document.activeElement))return;let H$=e.clipboardData?.getData("text/plain")??"",K$=OO(H$);if(K$.length===0)return;let _$=A.current;if(!_$)return;e.preventDefault();let v$=_$.getBoundingClientRect(),J$=G$.value,d=(v$.width/2-J$.x)/J$.scale,O$=(v$.height/2-J$.y)/J$.scale;await N(K$,d,O$)};return document.addEventListener("paste",S),()=>{document.removeEventListener("paste",S)}},[A,N]);let S6=bg(D.value.values(),n$.value,new Set(h8.value.keys())),N$=y4.value,t$=N$?D.value.get(N$.groupId):void 0,O4=N$?D.value.get(N$.nodeId):void 0,A4=null;if(Z){let S=Math.min(Z.startX,Z.currentX),e=Math.min(Z.startY,Z.currentY),H$=Math.abs(Z.currentX-Z.startX),K$=Math.abs(Z.currentY-Z.startY);A4={position:"absolute",left:`${S}px`,top:`${e}px`,width:`${H$}px`,height:`${K$}px`,pointerEvents:"none"}}return G("div",{class:`canvas-viewport${AU()?" pan-mode":""}`,ref:A,tabIndex:0,onPointerDown:R,onPointerMove:p,onPointerLeave:()=>{W.current=null,V9(null)},onPointerUp:l,onContextMenu:t,onDblClick:r,onDragEnter:i,onDragOver:o,onDragLeave:z$,onDrop:B$,style:{width:"100%",height:"100%",position:"relative",overflow:"hidden",cursor:_==="eraser"?"cell":_==="text"?"text":J||o$.value||K.current||R6.value==="connect"?"crosshair":AU()?"grab":"default"},children:[G("div",{ref:E,class:"canvas-world",style:{transform:`matrix(${z.scale}, 0, 0, ${z.scale}, ${z.x}, ${z.y})`,transformOrigin:"0 0",position:"absolute",top:0,left:0},children:[G(aX,{},void 0,!1,void 0,this),G(nH,{},void 0,!1,void 0,this),G(PH,{},void 0,!1,void 0,this),G(SH,{},void 0,!1,void 0,this),G(fH,{},void 0,!1,void 0,this),G(qQ,{nodes:D,edges:c$,onEdgeContextMenu:U},void 0,!1,void 0,this),o$.value&&G("div",{class:"edge-hint-pill","data-testid":"edge-hint",style:{left:`${o$.value.cursorX+14}px`,top:`${o$.value.cursorY+14}px`},children:[G("span",{class:"edge-hint-main",children:o$.value.targetId?"release to connect":"drag onto a node"},void 0,!1,void 0,this),G("span",{class:"edge-hint-keys",children:["esc cancels · L labels",o$.value.withLabel?" · label on":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N$&&t$&&O4&&G("div",{class:"drop-pill","data-testid":"drop-pill",style:{left:`${O4.position.x}px`,top:`${O4.position.y+O4.size.height+10}px`},children:[G("span",{class:"drop-pill-text",children:N$.mode==="add"?`release to add to ${String(t$.data.title??"group")}`:`release to remove from ${String(t$.data.title??"group")}`},void 0,!1,void 0,this),G("span",{class:"drop-pill-hint",children:N$.mode==="add"?"esc keeps it out":"esc keeps it in"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(GO,{annotations:Array.from(bU.value.values())},void 0,!1,void 0,this),X&&X.points.length>=2&&G(GO,{annotations:[X]},void 0,!1,void 0,this),S6.map((S)=>G(ZQ,{node:S,onContextMenu:$,children:Xg(S)},S.id,!1,void 0,this)),UU.value&&G("svg",{class:"snap-guides-svg",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:UU.value.map((S,e)=>S.axis==="x"?G("line",{x1:S.pos,y1:S.from-20,x2:S.pos,y2:S.to+20,class:"snap-guide-line"},e,!1,void 0,this):G("line",{x1:S.from-20,y1:S.pos,x2:S.to+20,y2:S.pos,class:"snap-guide-line"},e,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J&&G("div",{class:`annotation-capture-layer${_==="eraser"?" erasing":""}${_==="text"?" text":""}`,"aria-hidden":"true"},void 0,!1,void 0,this),L&&G("input",{class:"annotation-text-input",value:L.value,autoFocus:!0,style:{left:`${L.x*z.scale+z.x}px`,top:`${L.y*z.scale+z.y}px`,fontSize:`${LQ*z.scale}px`},onInput:(S)=>I({...L,value:S.target.value}),onBlur:T,onPointerDown:(S)=>S.stopPropagation(),onKeyDown:(S)=>{if(S.key==="Enter")S.preventDefault(),T();if(S.key==="Escape")S.preventDefault(),I(null)}},void 0,!1,void 0,this),A4&&G("div",{class:"lasso-rect",style:A4},void 0,!1,void 0,this),H&&G("div",{class:"drop-zone-overlay",children:G("div",{class:"drop-zone-indicator",children:[G("div",{class:"drop-zone-icon",children:"+"},void 0,!1,void 0,this),G("div",{class:"drop-zone-label",children:"Drop files or URLs to add to canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function bQ(){let $=[...j$.value],U=D.value,[v,J]=f(""),[_,z]=f(!1),K=wH.value,[W,O]=f(null),Y=K.length>=2,Z=!Y&&K.length===1&&K[0].steerable?K[0]:null,q=Y?W?K.find((L)=>L.value===W&&L.steerable)??null:null:Z,X=q?.value??null,B=async()=>{let L=v.trim();if(!L||_)return;z(!0);let F=await pH(L,X);if(z(!1),F)J("")};return G("div",{class:"command-bar","data-testid":"command-bar",children:[$.length>0&&G("div",{class:"command-bar-chips","aria-label":"Pinned context",children:[$.map((L)=>{let F=U.get(L),k=typeof F?.data.title==="string"&&F.data.title.trim()?F.data.title:F?.type??L;return G("span",{class:"command-bar-chip","data-node-id":L,children:[G("span",{class:"command-bar-chip-glyph","aria-hidden":"true",children:"✦"},void 0,!1,void 0,this),G("span",{class:"command-bar-chip-label",title:k,children:k},void 0,!1,void 0,this),G("button",{type:"button",class:"command-bar-chip-unpin","aria-label":`Unpin ${k}`,title:"Remove from context",onClick:()=>$1(L),children:"×"},void 0,!1,void 0,this)]},L,!0,void 0,this)}),G("span",{class:"command-bar-chips-note",children:"in agent context"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"command-bar-composer",children:[G(I0,{size:15,class:"command-bar-icon"},void 0,!1,void 0,this),Y&&G("select",{class:"command-bar-target","aria-label":"Steer which agent",title:"Connected agents — steering reaches all of them unless you address one",value:X??"",onChange:(L)=>O(L.target.value||null),children:[G("option",{value:"",children:"All agents"},void 0,!1,void 0,this),K.map((L)=>{let F=L.pendingSteers&&L.pendingSteers>0?` · ${L.pendingSteers} queued`:"",k=L.polling?" · polling":"";return G("option",{value:L.value,disabled:!L.steerable,children:L.attached?`${L.label}${k}${F}`:L.steerable?`${L.label} · writer${k}${F}`:`${L.label} · no inbox`},L.value,!1,void 0,this)})]},void 0,!0,void 0,this),G("input",{class:"command-bar-input",type:"text",value:v,placeholder:`Steer ${q?.label??"the agent"}, or ${d$("K")} to search the board…`,"aria-label":"Steer the agent",disabled:_,onInput:(L)=>J(L.target.value),onKeyDown:(L)=>{if(L.key==="Enter")L.preventDefault(),B()}},void 0,!1,void 0,this),G("button",{type:"button",class:"command-bar-send",disabled:_||!v.trim(),onClick:()=>void B(),children:_?"Sending…":"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var YO=r$(()=>{if(x6.value==="disconnected")return"reconnecting";if(x6.value==="connected"&&!K4.value&&f1.value>1)return"resyncing";return null});function MQ(){let $=YO.value;if(!$)return null;if($==="reconnecting"){let U=E1.value,v=u1.value;return G("div",{class:"connection-banner is-reconnecting",role:"status","data-testid":"connection-banner",children:[G("span",{class:"connection-banner-glyph","aria-hidden":"true",children:"↻"},void 0,!1,void 0,this),G("span",{class:"connection-banner-text",children:[G("b",{children:"Reconnecting…"},void 0,!1,void 0,this)," live updates are paused; edits still save, the board may be stale until the stream returns."]},void 0,!0,void 0,this),G("span",{class:"connection-banner-meta",children:[U>0?`retry ${U}`:"retrying",v>0?` · ${Math.max(1,Math.round(v/1000))}s`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return G("div",{class:"connection-banner is-resyncing",role:"status","data-testid":"connection-banner",children:[G("span",{class:"connection-banner-glyph","aria-hidden":"true",children:"⟳"},void 0,!1,void 0,this),G("span",{class:"connection-banner-text",children:[G("b",{children:"Resyncing from snapshot"},void 0,!1,void 0,this)," — the event cursor went stale; the board reloads without losing local edits."]},void 0,!0,void 0,this),G("span",{class:"connection-banner-progress","aria-hidden":"true",children:G("span",{class:"connection-banner-progress-fill"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Mg={markdown:{width:520,height:360},group:{width:600,height:400},html:{width:720,height:640},image:{width:720,height:520},file:{width:720,height:600},webpage:{width:520,height:420}};async function i6($){if($.x!==void 0&&$.y!==void 0)return n6($);let U=Mg[$.type]??{width:360,height:200},v=$.width??U.width,J=$.height??U.height,_=C1(),z=G$.value,K=await n6({...$,width:v,height:J,x:Math.round((_.x-z.x)/z.scale-v/2),y:Math.round((_.y-z.y)/z.scale-J/2)});if(K.ok&&K.id)G6(K.id);return K}var r9=!1,AQ=!1,_U=null,y0=null;function ZO(){return r9}function i9(){r9=!1,AQ=!0,IQ()}function IQ(){if(_U&&y0)_U.removeEventListener("change",y0);_U=null,y0=null}function Ag(){if(typeof window>"u"||!window.location)return null;let $=new URLSearchParams(window.location.search).get("theme");if($==="auto")return"auto";return e0($)?$:null}function wQ($){if(AQ)return;let U=Ag();if(!U)return;if(IQ(),r9=!0,U!=="auto"){$(U);return}_U=window.matchMedia("(prefers-color-scheme: light)"),y0=()=>{if(r9&&_U)$(_U.matches?"light":"dark")},y0(),_U.addEventListener("change",y0)}var Ig='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function C0($,U,v={}){u(()=>{if(!U)return;let J=$.current;if(!J)return;let _=document.activeElement,z=v.restoreTo,K=()=>Array.from(J.querySelectorAll(Ig)),W=v.initial?.current??K()[0];if(W&&!J.contains(document.activeElement))W.focus();let O=(Y)=>{if(Y.key!=="Tab")return;let Z=K();if(Z.length===0)return;let q=Z[0],X=Z[Z.length-1],B=document.activeElement;if(Y.shiftKey&&(B===q||!J.contains(B)))Y.preventDefault(),X.focus();else if(!Y.shiftKey&&B===X)Y.preventDefault(),q.focus()};return J.addEventListener("keydown",O),()=>{if(J.removeEventListener("keydown",O),z)requestAnimationFrame(()=>z()?.focus());else if(_&&document.contains(_)&&_!==document.body)_.focus()}},[$,U,v.initial,v.restoreTo])}function wg($,U){let v=$.toLowerCase(),J=U.toLowerCase(),_=[],z=0,K=0,W=-1;for(let O=0;O<J.length&&z<v.length;O++)if(J[O]===v[z]){if(_.push(O),K+=W===O-1?10:1,O===0||J[O-1]===" "||J[O-1]==="-"||J[O-1]==="_")K+=5;W=O,z++}return{match:z===v.length,score:K,indices:_}}function gg($,U){if(U.length===0)return $;let v=[],J=0;for(let _ of U){if(_>J)v.push($.slice(J,_));v.push(G("mark",{children:$[_]},_,!1,void 0,this)),J=_+1}if(J<$.length)v.push($.slice(J));return v}var qO={md:"markdown",app:"mcp-app",web:"webpage",ui:"json-render",chart:"graph",ctx:"context",log:"ledger"};function Ng($){let U=$.toLowerCase().trim();if(U.startsWith("type:")){let v=U.slice(5).trim(),_=Object.keys(Z6).find((K)=>K.startsWith(v));if(_)return{typeFilter:_,remaining:""};let z=qO[v];if(z)return{typeFilter:z,remaining:""}}if(qO[U])return{typeFilter:qO[U],remaining:""};return{typeFilter:null,remaining:$}}function gQ({onClose:$,onToggleMinimap:U}){let[v,J]=f(""),[_,z]=f(0),K=C(null),W=C(null),O=C(null);C0(O,!0,{initial:K}),u(()=>{setTimeout(()=>K.current?.focus(),30)},[]);let Y=j(()=>{let H=[];for(let b of D.value.values()){let V=b.data.title||Z6[b.type],E=b.data.content||b.data.path||"",A=b.type==="group"&&Array.isArray(b.data.children)?b.data.children.length:0;H.push({id:`node:${b.id}`,kind:"node",label:V,description:b.type==="group"?`group · ${A} node${A===1?"":"s"}`:E.length>60?`${Z6[b.type].toLowerCase()} · ${E.slice(0,60)}…`:E?`${Z6[b.type].toLowerCase()} · ${E}`:Z6[b.type].toLowerCase(),icon:h4(b.type),nodeType:b.type,action:()=>{G6(b.id),$()}})}let P=[{label:"New markdown note",shortcut:"M",icon:F1,iconTone:"accent",action:()=>{i6({type:"markdown",title:"New note",width:520,height:360}),$()}},...k6.value?[]:[{label:"Start agent session",icon:I0,iconTone:"purple",action:()=>{A1(),$()}}],{label:"Fit view",shortcut:"F",icon:A9,iconTone:"muted",action:()=>{SU(d6().width,d6().height),$()}},{label:"Auto-arrange (grid)",icon:t1,iconTone:"muted",action:()=>{zv(),$()}},{label:"Auto-arrange (graph-aware)",icon:t1,iconTone:"muted",action:()=>{Kv(),$()}},{label:"Toggle minimap",icon:I9,iconTone:"muted",action:()=>{U(),$()}},{label:"Toggle theme (dark/light)",icon:w9,iconTone:"muted",action:()=>{let b=$6.value==="dark"?"light":"dark";i9(),document.documentElement.setAttribute("data-theme",b),P0(),$6.value=b,h2(b),$()}}];for(let b of P)H.push({id:`action:${b.label}`,kind:"action",label:b.label,...b.shortcut?{shortcut:b.shortcut}:{},icon:b.icon,...b.iconTone?{iconTone:b.iconTone}:{},action:b.action});return H},[$,U]),{typeFilter:Z,remaining:q}=Ng(v),X=Y(),B;if(!v.trim())B=X.map((H)=>({...H,score:0,indices:[]}));else{B=[];for(let H of X){if(Z){if(H.kind!=="node"||H.nodeType!==Z)continue;if(!q){B.push({...H,score:0,indices:[]});continue}}let P=wg(q||v,H.label);if(P.match)B.push({...H,score:P.score,indices:P.indices})}B.sort((H,P)=>P.score-H.score)}B=[...B.filter((H)=>H.kind==="action"),...B.filter((H)=>H.kind==="node")];let L=B.findIndex((H)=>H.kind==="node");u(()=>{if(!v.trim()){e4.value=null;return}let H=new Set;for(let P of B)if(P.kind==="node")H.add(P.id.slice(5));e4.value=H.size>0?H:null},[v,B]),u(()=>{return()=>{e4.value=null}},[]);let F=Math.min(_,Math.max(0,B.length-1)),k=j((H)=>{if(H.key==="ArrowDown")H.preventDefault(),z((P)=>Math.min(P+1,B.length-1));else if(H.key==="ArrowUp")H.preventDefault(),z((P)=>Math.max(P-1,0));else if(H.key==="Enter"){if(H.preventDefault(),B[F])B[F].action()}else if(H.key==="Escape")H.preventDefault(),H.stopPropagation(),$()},[B,F,$]);return u(()=>{let H=W.current;if(!H)return;H.children[F]?.scrollIntoView({block:"nearest"})},[F]),u(()=>{z(0)},[v]),G("div",{class:"command-palette-backdrop",onMouseDown:$,children:G("div",{ref:O,class:"command-palette",role:"dialog","aria-modal":"true","aria-label":"Search and commands",onMouseDown:(H)=>H.stopPropagation(),children:[G("div",{class:"command-palette-search",children:[G("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[G("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),G("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("input",{ref:K,type:"text",class:"command-palette-input",value:v,onInput:(H)=>J(H.target.value),onKeyDown:k,placeholder:"Search nodes, run actions, jump to…","aria-label":"Search nodes, run actions, jump to"},void 0,!1,void 0,this),G("kbd",{class:"command-palette-esc",children:"esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"command-palette-results",ref:W,children:[B.length===0&&G("div",{class:"command-palette-empty",children:"No matching nodes or actions"},void 0,!1,void 0,this),B.map((H,P)=>{let b=H.icon,V=P===0&&H.kind==="action"?"Actions":P===L?"Jump to":null;return G("div",{class:"command-palette-row",children:[V&&G("div",{class:"command-palette-group",children:V},void 0,!1,void 0,this),G("button",{type:"button",class:`command-palette-item${P===F?" selected":""}`,onMouseEnter:()=>z(P),onClick:()=>H.action(),children:[G("span",{class:`command-palette-icon tone-${H.iconTone??"kind"}`,"aria-hidden":"true",children:G(b,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"command-palette-label",children:[H.indices.length>0?gg(H.label,H.indices):H.label,H.description&&G("span",{class:"command-palette-desc",children:[" — ",H.description]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.shortcut&&G("kbd",{class:"command-palette-kbd",children:H.shortcut},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},H.id,!0,void 0,this)})]},void 0,!0,void 0,this),G("div",{class:"command-palette-hint",children:[G("span",{children:"↑↓ navigate"},void 0,!1,void 0,this),G("span",{children:"↵ open"},void 0,!1,void 0,this),G("span",{children:"esc close"},void 0,!1,void 0,this),G("span",{children:"type: filter"},void 0,!1,void 0,this),G("span",{class:"command-palette-hint-spacer"},void 0,!1,void 0,this),G("span",{children:d$("K")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function NQ(){let[$,U]=f(null),v=j((K,W)=>{K.preventDefault(),K.stopPropagation(),U({kind:"node",x:K.clientX,y:K.clientY,nodeId:W})},[]),J=j((K,W,O)=>{K.preventDefault(),K.stopPropagation(),U({kind:"canvas",x:K.clientX,y:K.clientY,canvasX:W,canvasY:O})},[]),_=j((K,W)=>{K.preventDefault(),K.stopPropagation(),U({kind:"edge",x:K.clientX,y:K.clientY,edgeId:W})},[]),z=j(()=>U(null),[]);return u(()=>{if(!$)return;let K=()=>U(null),W=(O)=>{if(O.key==="Escape")U(null)};return document.addEventListener("click",K),document.addEventListener("keydown",W),()=>{document.removeEventListener("click",K),document.removeEventListener("keydown",W)}},[$]),{menu:$,openNodeMenu:v,openCanvasMenu:J,openEdgeMenu:_,closeMenu:z}}var Sg="#4bbcFF",Rg=[{label:"Blue",value:"#3b82f6"},{label:"Green",value:"#22c55e"},{label:"Yellow",value:"#eab308"},{label:"Red",value:"#ef4444"},{label:"Gray",value:"#6b7280"},{label:"Purple",value:"#a855f7"}];function SQ({menu:$,onClose:U}){let v;if($.kind==="node"){let W=D.value.get($.nodeId);if(!W)return null;v=Vg(W)}else if($.kind==="edge"){let W=$.edgeId,O=c$.value.get(W);v=[{label:O?.label?`Edit label “${O.label.slice(0,18)}${O.label.length>18?"…":""}”`:"Add label…",action:()=>{S4("Edge label (empty clears it)","label text",{initial:O?.label??"",allowEmpty:!0,confirm:"Save"}).then((Y)=>{if(Y===null)return;i2(W,{label:Y})})}},{separator:!0},...["flow","depends-on","relation","references"].map((Y)=>({label:`${O?.type===Y?"✓":" "} ${Y}`,action:()=>void i2(W,{type:Y})})),{separator:!0},...["solid","dashed","dotted"].map((Y)=>({label:`${(O?.style??"solid")===Y?"✓":" "} ${Y}`,action:()=>void i2(W,{style:Y})})),{separator:!0},{label:"Delete edge",danger:!0,action:()=>void p2(W)}]}else v=jg($.canvasX,$.canvasY);let J=new Map,_=v.some((W)=>W.render)?v.length*32+168:v.length*32+8,z=Math.min($.x,Math.max(12,window.innerWidth-240)),K=Math.min($.y,Math.max(12,window.innerHeight-_));return G("div",{class:"context-menu",style:{position:"fixed",left:`${z}px`,top:`${K}px`,zIndex:1e4},onPointerDown:(W)=>W.stopPropagation(),onClick:(W)=>W.stopPropagation(),children:v.map((W)=>{let O=W.separator?"separator":W.render?"custom":`${W.label??"item"}:${W.shortcut??""}`,Y=(J.get(O)??0)+1;J.set(O,Y);let Z=`${O}:${Y}`;if(W.separator)return G("div",{class:"context-menu-separator"},Z,!1,void 0,this);if(W.render)return G("div",{class:"context-menu-custom",children:W.render(U)},Z,!1,void 0,this);return G("button",{type:"button",class:`context-menu-item${W.danger?" is-danger":""}`,onClick:()=>{W.action?.(),U()},children:[G("span",{class:"context-menu-label",children:W.label},void 0,!1,void 0,this),W.shortcut&&G("span",{class:"context-menu-shortcut",children:W.shortcut},void 0,!1,void 0,this)]},Z,!0,void 0,this)})},void 0,!1,void 0,this)}function Tg($){return(typeof $.data.path==="string"?$.data.path.trim():"")||null}function p9($){let U=$.trim().toLowerCase(),v=U.match(/^#([0-9a-f]{3})$/);if(v){let[J,_,z]=v[1].split("");return`#${J}${J}${_}${_}${z}${z}`}return U}function RQ($){if(typeof $.data.color!=="string"||!$.data.color.trim())return null;return p9($.data.color)}function yg($){let U=RQ($);return U&&/^#[0-9a-f]{6}$/.test(U)?U:p9(Sg)}function BO($,U){let v=U?p9(U):null;q6($.id,{data:{...$.data,color:v}}),A6($.id,{data:{color:v}})}function Cg($,U){let v=RQ($);return G("div",{class:"context-menu-section",children:[G("div",{class:"context-menu-section-header",children:[G("span",{class:"context-menu-section-label",children:"Group color"},void 0,!1,void 0,this),G("button",{type:"button",class:"context-menu-reset",onClick:()=>{BO($,null),U()},children:"Theme default"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"context-menu-color-grid",children:Rg.map((J)=>{let _=p9(J.value);return G("button",{type:"button",class:`context-menu-color-swatch${v===_?" active":""}`,"aria-label":`Set group color to ${J.label}`,title:J.label,style:{"--swatch-color":J.value},onClick:()=>{BO($,J.value),U()},children:[G("span",{class:"context-menu-color-dot",style:{"--swatch-color":J.value}},void 0,!1,void 0,this),G("span",{children:J.label},void 0,!1,void 0,this)]},J.value,!0,void 0,this)})},void 0,!1,void 0,this),G("label",{class:"context-menu-color-custom",children:[G("span",{children:"Custom"},void 0,!1,void 0,this),G("input",{type:"color",class:"context-menu-color-input","aria-label":"Custom group color",value:yg($),onClick:(J)=>J.stopPropagation(),onInput:(J)=>{BO($,J.currentTarget.value),U()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function HO($,U,v,J){return{x:$-v/2,y:U-J/2}}function Dg($,U){return $.trim().replace(/[?#].*$/,"").split("/").filter(Boolean).at(-1)||U}async function XO($){let U=await S4($.promptLabel,$.placeholder??"");if(!U)return;let v=U.trim();if(!v)return;let J=HO($.canvasX,$.canvasY,$.width,$.height);if(!(await n6({type:$.type,...$.type!=="webpage"?{title:Dg(v,$.titleFallback)}:{},content:v,x:J.x,y:J.y,width:$.width,height:$.height})).ok)console.error(`[canvas-menu] ${$.errorMessage}`)}function jg($,U){return[{label:"New note",action:()=>{let _=HO($,U,520,360);n6({type:"markdown",title:"New note",x:_.x,y:_.y,width:520,height:360})}},{label:"Open webpage...",action:()=>{XO({promptLabel:"Webpage URL:",type:"webpage",canvasX:$,canvasY:U,width:520,height:420,placeholder:"https://example.com",titleFallback:"Webpage",errorMessage:"Could not create webpage node. Enter a valid http(s) URL."})}},{label:"Open file...",action:()=>{XO({promptLabel:"Workspace path or absolute file path:",type:"file",canvasX:$,canvasY:U,width:720,height:500,placeholder:"src/server/server.ts",titleFallback:"File",errorMessage:"Could not create file node. Check the path and try again."})}},{label:"Open image...",action:()=>{XO({promptLabel:"Image path, URL, or data URI:",type:"image",canvasX:$,canvasY:U,width:480,height:360,placeholder:"artifacts/architecture.png",titleFallback:"Image",errorMessage:"Could not create image node. Check the image source and try again."})}},{separator:!0},{label:"New group",action:()=>{let _=HO($,U,600,400);XU({title:"Group",x:_.x,y:_.y,width:600,height:400})}}]}function Vg($){let U=[],v=Tg($);if(U.push({label:"Focus",action:()=>G6($.id)}),r0.has($.type))U.push({label:"Expand",shortcut:"⤢",action:()=>Q4($.id)});U.push({label:$.collapsed?"Expand":"Collapse",action:()=>wU($.id)});let J=j$.value.has($.id);U.push({label:J?"Unpin from context":"Pin as context",action:()=>$1($.id)}),U.push({label:$.pinned?"Unlock position":"Lock position (no auto-arrange)",action:()=>{let O=!$.pinned;q6($.id,{pinned:O}),A6($.id,{pinned:O}),v6()}});let _=e2.value;if(_&&_.from!==$.id){let O=D.value.get(_.from),Y=O?(O.data.title||O.id).slice(0,20):_.from;U.push({label:`Connect from "${Y}"`,action:()=>{j1(_.from,$.id,"relation"),e2.value=null}})}U.push({label:_?"Connect from here (replace)":"Connect from here",action:()=>{e2.value={from:$.id}}});let z=Array.from(c$.value.values()).filter((O)=>O.from===$.id||O.to===$.id).length;if(z>0)U.push({label:`${z} edge${z!==1?"s":""} connected`});if(U.push({separator:!0}),($.type==="markdown"||$.type==="file"||$.type==="image")&&v)U.push({label:"Open in browser",action:()=>{window.open(`/artifact?path=${encodeURIComponent(v)}`,"_blank","noopener")}}),U.push({label:"Copy path",action:()=>{navigator.clipboard.writeText(v)}});if($.type==="mcp-app"||$.type==="json-render"||$.type==="graph")if($.data.chartConfig){let O=$.data.chartConfig.title||"chart";U.push({label:"Copy chart data",action:()=>{navigator.clipboard.writeText(JSON.stringify($.data.chartConfig,null,2))}})}else{let O=$.data.url;if(U.push({label:"Open in browser",action:()=>{if(O)window.open(O,"_blank")}}),U.push({label:"Focus in TUI",action:()=>LY("mcp-app-focus",{url:O})}),$.type==="json-render"||$.type==="graph")U.push({label:"Copy spec",action:()=>{navigator.clipboard.writeText(JSON.stringify($.data.spec??$.data.graphConfig??{},null,2))}})}if($.type==="webpage"){let O=typeof $.data.url==="string"?$.data.url:"";U.push({label:"Refresh webpage",action:()=>{c2($.id)}}),U.push({label:"Open in browser",action:()=>{if(O)window.open(O,"_blank","noopener")}}),U.push({label:"Copy URL",action:()=>{if(O)navigator.clipboard.writeText(O)}})}if($.type==="group"){let O=$.data.children??[];if(U.push({separator:!0}),U.push({render:(Y)=>Cg($,Y)}),O.length>0)U.push({label:`Ungroup (${O.length} node${O.length!==1?"s":""})`,action:()=>{h6($.id),HU($.id)}})}let K=typeof $.data.parentGroup==="string"?$.data.parentGroup:null,W=K?D.value.get(K):void 0;if(W&&W.type==="group"){let O=typeof W.data.title==="string"&&W.data.title?W.data.title:"frame",Y=Array.isArray(W.data.children)?W.data.children.filter((Z)=>Z!==$.id):[];U.push({label:`Remove from “${O}”`,action:()=>{r2(W.id,Y)}})}return U.push({separator:!0}),U.push({label:$.type==="group"?"Delete frame (children stay)":"Delete",danger:!0,action:()=>{h6($.id),n4($.id)}}),U}function TQ(){let $=j$.value.size;if($===0||X4.value)return null;return G("div",{class:"context-pin-bar",children:[G("span",{class:"context-pin-bar-count",children:["✦"," ",$," node",$!==1?"s":""," in context"]},void 0,!0,void 0,this),G("button",{type:"button",class:"context-pin-bar-btn context-pin-bar-clear",onClick:JZ,title:"Clear all context pins",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function G2($,U){console.error(`[tool-rail] ${$} failed`,U)}function r4($){let U={image:{message:"Image URL (https://… or data:image/…)",placeholder:"https://example.com/diagram.png"},file:{message:"Workspace file path",placeholder:"src/server/server.ts"},webpage:{message:"Page URL",placeholder:"https://example.com"}};S4(U[$].message,U[$].placeholder).then((v)=>{if(!v)return;i6({type:$,content:v}).catch((J)=>G2(`create ${$}`,J))})}function Y6({label:$,shortcut:U,detail:v,ariaLabel:J,active:_,menuOpen:z,onClick:K,btnRef:W,children:O}){let[Y,Z]=f(null),q=(L)=>{let F=L.currentTarget.getBoundingClientRect();Z({left:F.right+10,top:F.top+F.height/2})},X=()=>Z(null),B=J??(U?`${$} (${U})`:v?`${$} (${v})`:$);return G(A$,{children:[G("button",{ref:W,type:"button",class:`rail-btn${_?" active":""}`,"aria-label":B,"aria-pressed":_===void 0?void 0:_,onClick:(L)=>{X(),K(L)},onPointerEnter:q,onPointerLeave:X,onFocus:q,onBlur:X,children:O},void 0,!1,void 0,this),Y&&!z&&G("span",{class:"toolbar-tooltip rail-tooltip",role:"tooltip","data-testid":"rail-tooltip",style:{left:`${Y.left}px`,top:`${Y.top}px`},children:[G("span",{class:"toolbar-tooltip-label",children:$},void 0,!1,void 0,this),(U||v)&&G("span",{class:"toolbar-tooltip-meta",children:[U&&G("kbd",{class:"toolbar-tooltip-shortcut",children:U},void 0,!1,void 0,this),v&&G("span",{children:v},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function yQ({minimapVisible:$,onToggleMinimap:U,snapshotOpen:v,onToggleSnapshot:J,snapshotBtnRef:_,onOpenPalette:z,onOpenShortcuts:K,annotationTool:W,onSetAnnotationTool:O}){let Y=R6.value,Z=MU.value,q=Array.from(D.value.values()).filter((I)=>I.type==="trace").length,X=c$.value.size,[B,L]=f(null),[F,k]=f(null),H=C(null),P=(I)=>(N)=>{if(B===I){L(null);return}let R=N.currentTarget.getBoundingClientRect();k({top:R.top,bottom:R.bottom,right:R.right}),L(I)},b=(I)=>F?I?{position:"fixed",left:`${F.right+8}px`,bottom:`${window.innerHeight-F.bottom}px`,top:"auto",right:"auto"}:{position:"fixed",left:`${F.right+8}px`,top:`${F.top}px`,right:"auto"}:void 0;u(()=>{if(!B)return;let I=(R)=>{if(H.current&&R.target instanceof Node&&!H.current.contains(R.target))L(null)},N=(R)=>{if(R.key==="Escape")L(null)};return document.addEventListener("pointerdown",I),document.addEventListener("keydown",N),()=>{document.removeEventListener("pointerdown",I),document.removeEventListener("keydown",N)}},[B]);let V=(I)=>{i9(),document.documentElement.setAttribute("data-theme",I),P0(),$6.value=I,h2(I),L(null)},E=X5($6.value),A=(I,N={})=>{fetch(`/api/workbench/intent?_ts=${Date.now()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:I,payload:N})}).catch((R)=>G2("sendIntent",R))};return G("div",{class:"tool-rail",ref:H,role:"toolbar","aria-label":"Canvas tools","aria-orientation":"vertical",children:[G("span",{class:"rail-brand",title:"PMX Canvas","aria-label":"PMX Canvas",children:G(ZH,{size:22},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("div",{class:"rail-divider"},void 0,!1,void 0,this),G(Y6,{label:"Select",shortcut:"V",active:Y==="select",onClick:()=>R6.value="select",children:G(qH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Pan",shortcut:"Space",active:Y==="pan",onClick:()=>R6.value="pan",children:G(BH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Connect",shortcut:"C",active:Y==="connect",onClick:()=>R6.value="connect",children:G("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[G("circle",{cx:"4",cy:"4",r:"2"},void 0,!1,void 0,this),G("circle",{cx:"12",cy:"12",r:"2"},void 0,!1,void 0,this),G("path",{d:"M5.5 5.5 C 8 8, 8 8, 10.5 10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G("div",{class:"rail-divider"},void 0,!1,void 0,this),G(Y6,{label:"Markdown note",shortcut:"M",onClick:()=>void i6({type:"markdown",title:"New note",width:520,height:360}).catch((I)=>G2("create markdown",I)),children:G(F1,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Image",shortcut:"I",onClick:()=>r4("image"),children:G(cW,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"File",shortcut:"Shift+F",onClick:()=>r4("file"),children:G(M9,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Webpage",shortcut:"W",onClick:()=>r4("webpage"),children:G(A0,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"HTML surface",shortcut:"H",onClick:()=>void i6({type:"html",title:"HTML surface"}).catch((I)=>G2("create html",I)),children:G(XH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Group",shortcut:"G",onClick:()=>void i6({type:"group",title:"Group"}).catch((I)=>G2("create group",I)),children:G(lW,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"toolbar-menu-anchor",children:[G(Y6,{label:"Annotate",shortcut:"A",detail:"Draw · Text note · Eraser",active:W!==null,menuOpen:B==="annotate",onClick:P("annotate"),children:W==="eraser"?G(xW,{},void 0,!1,void 0,this):W==="text"?G(hW,{},void 0,!1,void 0,this):G(mW,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),B==="annotate"&&G("div",{class:"toolbar-menu",style:b(!1),role:"menu","aria-label":"Annotate",children:[G("button",{type:"button",class:`toolbar-menu-item${W==="pen"?" active":""}`,onClick:()=>{O(W==="pen"?null:"pen"),L(null)},children:[G(mW,{},void 0,!1,void 0,this),G("span",{children:W==="pen"?"Stop annotating":"Draw (A)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:`toolbar-menu-item${W==="text"?" active":""}`,onClick:()=>{O(W==="text"?null:"text"),L(null)},children:[G(hW,{},void 0,!1,void 0,this),G("span",{children:W==="text"?"Stop text notes":"Text note"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:`toolbar-menu-item${W==="eraser"?" active":""}`,onClick:()=>{O(W==="eraser"?null:"eraser"),L(null)},children:[G(xW,{},void 0,!1,void 0,this),G("span",{children:W==="eraser"?"Stop erasing":"Eraser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"rail-spacer"},void 0,!1,void 0,this),G(Y6,{label:"Search & commands",shortcut:d$("K"),onClick:z,children:G(OH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Arrange",detail:X>0?"graph-aware":"grid",onClick:()=>X>0?Kv():zv(),children:G(t1,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:Z?"Disable trace":"Enable trace",active:Z,onClick:()=>A("trace-toggle",{enabled:!Z}),children:G(GH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),(Z||q>0)&&G(Y6,{label:"Clear trace",onClick:()=>A("trace-clear"),children:G(WH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:$?"Hide minimap":"Show minimap",active:$,onClick:U,children:G(I9,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(Y6,{label:"Snapshots",active:v,onClick:J,btnRef:_,children:G(KH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"toolbar-menu-anchor",children:[G(Y6,{label:"Theme",detail:DU[E].label,menuOpen:B==="theme",ariaLabel:"Choose theme",active:B==="theme",onClick:P("theme"),children:jU(E)==="dark"?G(zH,{},void 0,!1,void 0,this):G(w9,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),B==="theme"&&G("div",{class:"toolbar-menu",style:b(!0),role:"menu","aria-label":"Theme",children:B5.map((I)=>G("button",{type:"button",role:"menuitemradio","aria-checked":E===I,class:`toolbar-menu-item${E===I?" active":""}`,onClick:()=>V(I),children:[G("span",{class:"theme-swatch",style:{background:DU[I].swatchBg},children:G("span",{class:"theme-swatch-dot",style:{background:DU[I].swatchAccent}},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{children:DU[I].label},void 0,!1,void 0,this),E===I&&G("span",{class:"toolbar-menu-check","aria-hidden":"true",children:"✓"},void 0,!1,void 0,this)]},I,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(Y6,{label:"Shortcuts",shortcut:"?",onClick:K,children:G(YH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function CQ({onOpenPalette:$}){let U=C(null),v=()=>{i6({type:"markdown",title:"New note",width:520,height:360}).catch(()=>{})},J=async(_)=>{if(!_||_.length===0)return;let z=C1(),K=G$.value;await k9(Array.from(_),(z.x-K.x)/K.scale,(z.y-K.y)/K.scale)};return G("div",{class:"empty-state","data-testid":"empty-state",children:[G("svg",{class:"empty-state-mark",width:"52",height:"52",viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[G("rect",{x:"8",y:"8",width:"48",height:"48",rx:"7"},void 0,!1,void 0,this),G("rect",{x:"20",y:"20",width:"24",height:"24",rx:"4","stroke-dasharray":"4 4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{children:[G("div",{class:"empty-state-title",children:"Nothing on this board yet"},void 0,!1,void 0,this),G("div",{class:"empty-state-sub",children:"Drop files anywhere, paste a link, or start from a note."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"empty-state-grid",children:[G("button",{type:"button",class:"empty-state-action",onClick:v,children:[G(F1,{size:16,class:"tone-accent"},void 0,!1,void 0,this),G("span",{class:"empty-state-action-label",children:"New markdown note"},void 0,!1,void 0,this),G("kbd",{children:"M"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"empty-state-action",onClick:()=>U.current?.click(),children:[G("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",class:"tone-warn","aria-hidden":"true",children:[G("path",{d:"M8 10 V2 M8 2 L5 5 M8 2 L11 5"},void 0,!1,void 0,this),G("path",{d:"M2 10 V13 H14 V10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"empty-state-action-label",children:"Drop files"},void 0,!1,void 0,this),G("span",{class:"empty-state-action-hint",children:"or pick"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"empty-state-action",onClick:()=>r4("webpage"),children:[G(A0,{size:16,class:"tone-ok"},void 0,!1,void 0,this),G("span",{class:"empty-state-action-label",children:"Paste a link"},void 0,!1,void 0,this),G("kbd",{children:d$("V")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"empty-state-action is-agent",onClick:()=>void A1(),children:[G(I0,{size:16,class:"tone-purple"},void 0,!1,void 0,this),G("span",{class:"empty-state-action-label",children:"Start agent session"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"empty-state-hint",onClick:$,children:["? shortcuts · ",d$("K")," palette"]},void 0,!0,void 0,this),G("input",{ref:U,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:(_)=>{let z=_.currentTarget;J(z.files).finally(()=>{z.value=""})}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function QO({presence:$,size:U=18}){return G("span",{class:"writer-avatar",style:{background:N9($.sessionId),width:`${U}px`,height:`${U}px`},"aria-hidden":"true",children:IH($.label)},void 0,!1,void 0,this)}function DQ(){let $=tW.value;if(k6.value||$.length===0)return null;let U=$.reduce((_,z)=>_+z.opCount,0),v=$.length===1?$[0].label:`${$.length} writers`,J=a1.value;return G("button",{type:"button",class:"external-indicator","data-testid":"external-indicator","aria-expanded":J,title:`${$.length} external writer${$.length===1?"":"s"} on this board — click for activity`,onClick:()=>{a1.value=!J},children:[G("span",{class:"external-indicator-avatars",children:$.slice(0,3).map((_)=>G(QO,{presence:_},_.sessionId,!1,void 0,this))},void 0,!1,void 0,this),G("span",{class:"external-indicator-label",children:v},void 0,!1,void 0,this),G("span",{class:"external-indicator-ops hud-collapsible-text",children:[U," op",U===1?"":"s"]},void 0,!0,void 0,this),G("span",{class:"external-indicator-dot","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fg($){if($==="node.add"||$==="jsonrender.add"||$==="graph.add"||$==="group.create")return{glyph:"+",tone:"ok"};if($==="node.remove"||$==="edge.remove"||$==="canvas.clear")return{glyph:"×",tone:"danger"};if($==="edge.add")return{glyph:"⟶",tone:"accent"};if($.startsWith("ax."))return{glyph:"◆",tone:"purple"};return{glyph:"✎",tone:"accent"}}function Eg($){return $.reduce((U,v)=>v.lastSeenAt>U?v.lastSeenAt:U,"")}function ug(){return[...s$.value.values()].filter(($)=>!$.auto&&$.phase==="forming")}function jQ(){let $=a1.value,U=tW.value,v=l4($?1e4:0);if(u(()=>{if(!$)return;let W=(O)=>{if(O.key!=="Escape")return;if(g0.value)g0.value=!1;else a1.value=!1};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[$]),!$||k6.value||U.length===0)return null;let J=nW.value,_=ug().filter((W)=>!J||(W.source??"")===J),z=k1.value.filter((W)=>!J||W.sessionId===J),K=(W,O)=>G("button",{type:"button",class:`activity-filter${J===W?" is-active":""}`,style:W?{"--writer":N9(W)}:void 0,"aria-pressed":J===W,onClick:()=>{nW.value=W},children:O},void 0,!1,void 0,this);return G("div",{class:"activity-feed","data-testid":"activity-feed",role:"dialog","aria-label":"External activity",children:[G("div",{class:"activity-feed-head",children:[G("span",{class:"external-indicator-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("div",{class:"activity-feed-titles",children:[G("div",{class:"activity-feed-title",children:["External activity — ",U.length," writer",U.length===1?"":"s"]},void 0,!0,void 0,this),G("div",{class:"activity-feed-sub",children:[U.reduce((W,O)=>W+O.opCount,0)," writes · last"," ",S9(Eg(U),v)," · no session attached"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"activity-feed-close","aria-label":"Close activity feed",onClick:()=>{a1.value=!1},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"activity-filters",children:[K(null,"All"),U.map((W)=>K(W.sessionId,W.label))]},void 0,!0,void 0,this),G("div",{class:"activity-rows",children:[_.map((W)=>G("div",{class:"activity-row is-pending","data-testid":"activity-proposal",children:[G("span",{class:"activity-glyph tone-purple","aria-hidden":"true",children:"▢"},void 0,!1,void 0,this),G("div",{class:"activity-main",children:[G("div",{class:"activity-text",children:["Proposing: ",G("b",{children:W.label?.trim()||`${W.kind} intent`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"activity-meta",children:[W.reason?.trim()||"Intent signalled — a real veto window before the mutation",W.source?` · ${W.source}`:""]},void 0,!0,void 0,this),G("div",{class:"activity-actions",children:[G("button",{type:"button",class:"activity-veto",onClick:()=>{D1(W).then((O)=>{if(O)_2(W.id)})},children:"Veto"},void 0,!1,void 0,this),G("span",{class:"activity-hint",children:"or hover ghost + Esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"activity-age",children:"now"},void 0,!1,void 0,this)]},W.id,!0,void 0,this)),z.length===0&&_.length===0&&G("div",{class:"activity-empty",children:"No writes yet."},void 0,!1,void 0,this),z.map((W)=>{let{glyph:O,tone:Y}=fg(W.op);return G("div",{class:"activity-row","data-testid":"activity-row","data-op":W.op,children:[G("span",{class:`activity-glyph tone-${Y}`,"aria-hidden":"true",children:O},void 0,!1,void 0,this),G("div",{class:"activity-main",children:[G("div",{class:"activity-text",children:W.summary},void 0,!1,void 0,this),G("div",{class:"activity-writer",style:{color:N9(W.sessionId)},children:W.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"activity-age",children:S9(W.at,v)},void 0,!1,void 0,this)]},W.id,!0,void 0,this)})]},void 0,!0,void 0,this),G("div",{class:"activity-feed-foot",children:[G("span",{class:"activity-feed-note",children:"All writes ghost first · Esc vetoes"},void 0,!1,void 0,this),G("button",{type:"button",class:"activity-feed-link",onClick:()=>{g0.value=!0},children:"Writers"},void 0,!1,void 0,this),G("button",{type:"button",class:"activity-feed-link is-accent",onClick:()=>{a1.value=!1,A1()},children:"Start session ↗"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function mg(){let $=[];if(b1.value)$.push("scoped");if(e1.value.length>0)$.push("gated");return $.length>0?$.join(" + "):"open"}function VQ(){let $=g0.value,U=l4($?1e4:0),v=C(null);if(C0(v,$),!$)return null;let J=O6.value.filter((K)=>K.attached),_=O6.value.filter((K)=>!K.attached),z=()=>{g0.value=!1};return G(A$,{children:[G("div",{class:"writers-scrim",onClick:z,"aria-hidden":"true"},void 0,!1,void 0,this),G("div",{ref:v,class:"writers-sheet","data-testid":"writers-sheet",role:"dialog","aria-modal":"true","aria-label":"Connected writers",children:[G("div",{class:"writers-head",children:[G("span",{class:"writers-title",children:"Connected writers"},void 0,!1,void 0,this),G("span",{class:"writers-board",children:D4.value.slice(0,12)},void 0,!1,void 0,this),G("button",{type:"button",class:"activity-feed-close","aria-label":"Close writers",onClick:z,children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"writers-body",children:[G("div",{class:"writers-section",children:"Agent sessions"},void 0,!1,void 0,this),J.length===0&&G("div",{class:"writers-empty",children:"None attached — start one from the top bar."},void 0,!1,void 0,this),J.map((K)=>G("div",{class:"writers-row",children:[G(QO,{presence:K,size:20},void 0,!1,void 0,this),G("span",{class:"writers-name",children:K.label},void 0,!1,void 0,this),G("span",{class:"writers-config",children:mg()},void 0,!1,void 0,this)]},K.sessionId,!0,void 0,this)),G("div",{class:"writers-section",children:"External writers · MCP"},void 0,!1,void 0,this),_.length===0&&G("div",{class:"writers-empty",children:"No external writers right now."},void 0,!1,void 0,this),_.map((K)=>G("div",{class:"writers-row",children:[G(QO,{presence:K,size:20},void 0,!1,void 0,this),G("span",{class:"writers-name is-mono",children:K.label},void 0,!1,void 0,this),G("span",{class:"writers-meta",children:[K.source!==K.label?`${K.source} · `:"","wrote"," ",S9(K.lastSeenAt,U)," ago"]},void 0,!0,void 0,this)]},K.sessionId,!0,void 0,this))]},void 0,!0,void 0,this),G("div",{class:"writers-foot",children:[G("span",{class:"writers-note",children:"Local-first: any process on this machine can connect and write. Every write ghosts first — veto is the control, not permissions."},void 0,!1,void 0,this),G("button",{type:"button",class:"writers-done",onClick:z,children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function fQ($,U){switch($.type){case"markdown":return G(Hv,{node:$,expanded:U},void 0,!1,void 0,this);case"mcp-app":return G(L1,{node:$,expanded:U},void 0,!1,void 0,this);case"webpage":return G(Q9,{node:$,expanded:U},void 0,!1,void 0,this);case"json-render":return G(L1,{node:$,expanded:U},void 0,!1,void 0,this);case"graph":return G(L1,{node:$,expanded:U},void 0,!1,void 0,this);case"prompt":return G(L9,{node:$},void 0,!1,void 0,this);case"response":return G(F9,{node:$,expanded:U},void 0,!1,void 0,this);case"status":return G(X9,{node:$},void 0,!1,void 0,this);case"context":return G(a2,{node:$,expanded:U},void 0,!1,void 0,this);case"ledger":return G(Ov,{node:$},void 0,!1,void 0,this);case"trace":return G(P9,{node:$},void 0,!1,void 0,this);case"file":return G(Wv,{node:$,expanded:U},void 0,!1,void 0,this);case"diff":return G(s2,{node:$},void 0,!1,void 0,this);case"mermaid":return G(bv,{node:$,expanded:U},void 0,!1,void 0,this);case"image":return G(H9,{node:$,expanded:U},void 0,!1,void 0,this);case"html":return G($2,{node:$,expanded:U},void 0,!1,void 0,this);default:return G("div",{children:"Unknown node type"},void 0,!1,void 0,this)}}function EQ($){switch($.type){case"markdown":return $.data.content||"";case"diff":return $.data.content||"";case"mermaid":return $.data.content||"";case"file":return $.data.fileContent||"";case"webpage":return $.data.content||"";case"html":return $.data.html||$.data.content||"";case"json-render":case"graph":return JSON.stringify($.data.spec??$.data.graphConfig??{},null,2);default:return""}}function xg($){if(!$)return 0;return $.split(/\s+/).filter(Boolean).length}function hg($,U){return $!==null&&typeof $==="object"&&$.source===t6&&$.type==="presentation-exit"&&$.token===U}function cg($){return $==="ArrowRight"||$==="PageDown"||$===" "||$==="ArrowLeft"||$==="PageUp"||$==="Home"||$==="End"}function uQ($){return $ instanceof HTMLElement&&Boolean($.closest(".html-presentation-exit"))}function mQ(){let $=n$.value,U=$?D.value.get($):void 0,[v,J]=f(!1),[_,z]=f(!1),[K,W]=f(""),O=C(null),Y=C(null),Z=j(()=>{z(!1),m1()},[]),q=j(()=>{W(`presentation-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),z(!0)},[]),X=j((i)=>{document.querySelector(".html-presentation-overlay iframe.html-node-frame-presentation")?.contentWindow?.postMessage({source:t6,token:K,...i},"*")},[K]),B=j(()=>{z(!1)},[]),L=j((i)=>{if(i.key==="Escape"){i.preventDefault(),i.stopPropagation(),z(!1);return}if(i.key==="Tab"&&!uQ(i.target)){i.preventDefault(),i.stopPropagation(),Y.current?.focus();return}if((i.key===" "||i.key==="Enter")&&uQ(i.target))return;if(!cg(i.key))return;i.preventDefault(),i.stopPropagation(),X({type:"presentation-key",key:i.key})},[X]),F=j((i)=>{if(i.target.classList.contains("expanded-overlay-backdrop"))m1()},[]),k=j(()=>{if(!U)return;let i=EQ(U);if(!i)return;navigator.clipboard.writeText(i).then(()=>{J(!0),setTimeout(()=>J(!1),1500)})},[U]),H=j(()=>{if(!$)return;$1($)},[$]);u(()=>{z(!1)},[$]),g2(()=>{if(!_)return;let i=()=>{let B$=O.current;if(!B$||B$.contains(document.activeElement))return;B$.focus()},o=[0,50,150].map((B$)=>window.setTimeout(i,B$)),z$=(B$)=>{if(!hg(B$.data,K))return;z(!1)};return document.addEventListener("keydown",L,!0),window.addEventListener("message",z$),()=>{o.forEach((B$)=>{window.clearTimeout(B$)}),document.removeEventListener("keydown",L,!0),window.removeEventListener("message",z$)}},[L,K,_]);let P=C(null),b=j(()=>$?document.querySelector(`.canvas-node[data-node-id="${CSS.escape($)}"]`):null,[$]);if(C0(P,U!==void 0,{restoreTo:b}),!U)return null;let V=U.data.title||U.data.path?.split("/").pop()||Z6[U.type],E=EQ(U),A=xg(E),I=$?j$.value.has($):!1,N=E.length>0,R=H4.value===$,p=U.type==="mcp-app"||U.type==="webpage"||U.type==="json-render"||U.type==="graph",l=rX(U),T=h4(U.type),r=U.data.provenance&&typeof U.data.provenance==="object"?U.data.provenance:null,t=r?[r.sourceKind,r.sourceUri,r.syncedAt?`synced ${r.syncedAt.slice(11,16)}`:null].filter((i)=>typeof i==="string"&&i.length>0).join(" · "):null;return G("div",{class:"expanded-overlay-backdrop",onPointerDown:F,style:{pointerEvents:R?"none":"auto"},children:G("div",{ref:P,class:`expanded-overlay-panel${I?" is-pinned":""}`,role:"dialog","aria-modal":"true","aria-label":V,"data-testid":"expanded-node",children:[G("div",{class:"expanded-header",children:[G("span",{class:"expanded-kind-icon","aria-hidden":"true",children:G(T,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"expanded-title",children:V},void 0,!1,void 0,this),G("span",{class:"expanded-kind-pill",children:Z6[U.type]},void 0,!1,void 0,this),G("button",{type:"button",class:`expanded-pin${I?" is-on":""}`,onClick:H,title:I?"In agent context — click to unpin":"Pin as agent context","aria-pressed":I,children:"✦"},void 0,!1,void 0,this),G("span",{class:"expanded-spacer"},void 0,!1,void 0,this),G("div",{class:"expanded-actions",children:[N&&G("button",{type:"button",class:"expanded-action-btn",onClick:k,title:"Copy content to clipboard",children:v?"Copied!":"Copy"},void 0,!1,void 0,this),Pv(U)&&G("button",{type:"button",class:"expanded-action-btn",onClick:()=>void kv(U),title:"Open as a full-page site in the system browser",children:"Open in tab ↗"},void 0,!1,void 0,this),l&&G("button",{type:"button",class:"expanded-action-btn expanded-action-primary",onClick:q,title:"Present this HTML node fullscreen",children:"Present"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("button",{type:"button",class:"expanded-close",onClick:Z,title:"Close (Esc)","aria-label":"Close",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:`expanded-body${p?" is-embedded":""}`,children:p?G("div",{style:{flex:1,minHeight:0,display:"flex"},children:fQ(U,!0)},void 0,!1,void 0,this):fQ(U,!0)},void 0,!1,void 0,this),G("div",{style:{"--ax-dock-bleed":"0px","--ax-dock-pad":"16px"},children:G(h9,{node:U},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("div",{class:"expanded-footer",children:[G("span",{class:"expanded-footer-meta",children:[t,A>0?`${A.toLocaleString()} word${A!==1?"s":""}`:null].filter(Boolean).join(" · ")||Z6[U.type].toLowerCase()},void 0,!1,void 0,this),G("span",{class:"expanded-spacer"},void 0,!1,void 0,this),G("span",{class:`expanded-footer-hint${R?" is-saving":""}`,children:R?"Saving edits…":"esc or click outside to close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l&&_&&G("div",{ref:O,class:"html-presentation-overlay",role:"dialog","aria-modal":"true","aria-label":`Present ${V}`,tabIndex:-1,onKeyDownCapture:L,children:[G("button",{ref:Y,type:"button",class:"html-presentation-exit",onClick:B,title:"Exit presentation (Esc)","aria-label":"Exit presentation",children:"Exit presentation"},void 0,!1,void 0,this),G("div",{class:"html-presentation-stage",children:G($2,{node:U,expanded:!0,presentation:!0,presentationExitToken:K},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var hQ=168,cQ=112,o9=20;function xQ($,U,v,J){let _=Array.from($.values()),z=0,K=0,W=1000,O=800;if(_.length>0){z=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,W=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY;for(let k of _)z=Math.min(z,k.position.x),K=Math.min(K,k.position.y),W=Math.max(W,k.position.x+k.size.width),O=Math.max(O,k.position.y+k.size.height)}let Y=-U.x/U.scale,Z=-U.y/U.scale,q=Y+v/U.scale,X=Z+J/U.scale,B={minX:Math.min(z,Y)-o9,minY:Math.min(K,Z)-o9,maxX:Math.max(W,q)+o9,maxY:Math.max(O,X)+o9},L=B.maxX-B.minX||1,F=B.maxY-B.minY||1;return{bounds:B,scale:Math.min(hQ/L,cQ/F)}}function lQ({viewport:$,nodes:U,onNavigate:v,containerWidth:J,containerHeight:_}){let z=C(null),K=C(!1),W=U.value,O=$.value,Y=xQ(W,O,J,_),{bounds:Z,scale:q}=Y,X=(A)=>(A-Z.minX)*q,B=(A)=>(A-Z.minY)*q,L=j((A)=>{let I=z.current;if(!I)return;let N=I.getBoundingClientRect(),R=(A.clientX-N.left)/N.width*hQ,p=(A.clientY-N.top)/N.height*cQ,l=xQ(U.value,$.value,J,_),T=$.value,r=J/T.scale,t=_/T.scale,i=R/l.scale+l.bounds.minX,o=p/l.scale+l.bounds.minY;v(-(i-r/2)*T.scale,-(o-t/2)*T.scale)},[U,$,J,_,v]),F=j((A)=>{A.stopPropagation(),A.preventDefault(),K.current=!0,L(A);let I=(R)=>{if(K.current)L(R)},N=()=>{K.current=!1,document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",N)};document.addEventListener("pointermove",I),document.addEventListener("pointerup",N)},[L]),k=I$.value,H=b1.value,P=H?f9(H.nodeIds.map((A)=>W.get(A)).filter((A)=>A!==void 0),H.padding):null,b=O6.value.map((A)=>({id:A.sessionId,phase:A.phase,worker:A.parentAgentId!=null,external:!A.attached,at:R9(A,(I)=>W.get(I))})).filter((A)=>A.at!==null),V=-O.x/O.scale,E=-O.y/O.scale;return G("div",{ref:z,class:"minimap","data-testid":"minimap",title:"Click to jump · drag the frame to pan",onPointerDown:F,children:[Array.from(W.values()).map((A)=>{let I=A.type==="group";return G("span",{class:`minimap-node${I?" is-group":""}${k.has(A.id)?" is-selected":""}`,"data-kind":A.type,style:{left:`${X(A.position.x)}px`,top:`${B(A.position.y)}px`,width:`${Math.max(I?6:4,A.size.width*q)}px`,height:`${Math.max(I?5:3,A.size.height*q)}px`,"--kind":m9[A.type]}},A.id,!1,void 0,this)}),P&&G("span",{class:"minimap-fence",style:{left:`${X(P.x)}px`,top:`${B(P.y)}px`,width:`${P.width*q}px`,height:`${P.height*q}px`}},void 0,!1,void 0,this),b.map((A)=>G("span",{class:`minimap-presence phase-${A.phase}${A.worker?" is-worker":""}${A.external?" is-external":""}`,style:{left:`${X(A.at.x)-4}px`,top:`${B(A.at.y)-4}px`,"--identity-color":`hsl(${P1(A.id)} 65% 62%)`}},A.id,!1,void 0,this)),G("span",{class:"minimap-frame",style:{left:`${X(V)}px`,top:`${B(E)}px`,width:`${J/O.scale*q}px`,height:`${_/O.scale*q}px`}},void 0,!1,void 0,this),G("span",{class:"minimap-zoom",children:[Math.round(O.scale*100),"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function J6({label:$,shortcut:U,body:v,align:J="center",side:_="down",tapToOpen:z=!1,children:K}){return G("span",{class:`toolbar-tooltip-anchor toolbar-tooltip-anchor-${J}${_==="up"?" toolbar-tooltip-anchor-up":""}${z?" toolbar-tooltip-anchor-tap":""}`,tabIndex:z?-1:void 0,children:[K,G("span",{class:"toolbar-tooltip",role:"tooltip",children:[G("span",{class:"toolbar-tooltip-label",children:$},void 0,!1,void 0,this),v&&G("span",{class:"toolbar-tooltip-body",children:v},void 0,!1,void 0,this),U&&G("span",{class:"toolbar-tooltip-meta",children:G("kbd",{class:"toolbar-tooltip-shortcut",children:U},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function rQ(){let $=I$.value.size,U=j(()=>{let W=Array.from(I$.value);if(W.length===0)return;Uv(W),I6()},[]),v=j(()=>{let W=Array.from(I$.value);if(W.length===0)return;XU({title:"Group",childIds:W}),I6()},[]),J=j(()=>{let W=Array.from(I$.value);for(let O=0;O<W.length;O++)for(let Y=O+1;Y<W.length;Y++)j1(W[O],W[Y],"relation");I6()},[]),_=j(()=>{let W=Array.from(I$.value);for(let O of W)h6(O),n4(O);I6()},[]);if($===0)return null;let z=$>=2,K=!k6.value&&j$.value.size>0&&!X4.value;return G("div",{class:`selection-bar${K?" is-above-pin-bar":""}`,role:"toolbar","aria-label":"Selection",children:[G("span",{class:"selection-bar-count",children:[$," node",$!==1?"s":""," selected"]},void 0,!0,void 0,this),z&&G(A$,{children:[G("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),G(J6,{label:"Align left",side:"up",children:G("button",{type:"button",class:"selection-bar-icon","aria-label":"Align left",onClick:()=>c8("left"),children:G("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[G("line",{x1:"2.5",y1:"2",x2:"2.5",y2:"14"},void 0,!1,void 0,this),G("rect",{x:"5",y:"3.5",width:"8",height:"3.5",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"5",y:"9",width:"5",height:"3.5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Align top",side:"up",children:G("button",{type:"button",class:"selection-bar-icon","aria-label":"Align top",onClick:()=>c8("top"),children:G("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[G("line",{x1:"2",y1:"2.5",x2:"14",y2:"2.5"},void 0,!1,void 0,this),G("rect",{x:"3.5",y:"5",width:"3.5",height:"8",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"9",y:"5",width:"3.5",height:"5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Distribute horizontally",body:"Evens the gaps. A selection that cannot fit flows into a clean row instead of overlapping.",side:"up",children:G("button",{type:"button",class:"selection-bar-icon","aria-label":"Distribute",disabled:$<3,onClick:()=>_Z(),children:G("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","aria-hidden":"true",children:[G("rect",{x:"1.5",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"6.25",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this),G("rect",{x:"11",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Auto-arrange selection",side:"up",children:G("button",{type:"button",class:"selection-bar-icon","aria-label":"Auto-arrange",onClick:()=>vZ(),children:G(t1,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),G(J6,{label:"Group the selection",shortcut:"G",side:"up",children:G("button",{type:"button",class:"selection-bar-action",onClick:v,children:[G("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-dasharray":"3 2.5","aria-hidden":"true",children:G("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"Group"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Connect every pair",side:"up",children:G("button",{type:"button",class:"selection-bar-action",onClick:J,children:"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(J6,{label:"Pin to agent context",side:"up",children:G("button",{type:"button",class:"selection-bar-action is-pin",onClick:U,children:[G("span",{"aria-hidden":"true",children:"✦"},void 0,!1,void 0,this),"Pin as context"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),G(J6,{label:"Delete selection",side:"up",children:G("button",{type:"button",class:"selection-bar-icon is-danger","aria-label":"Delete selection",onClick:_,children:G("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[G("path",{d:"M2.5 4 H13.5"},void 0,!1,void 0,this),G("path",{d:"M5.5 4 V2.5 H10.5 V4"},void 0,!1,void 0,this),G("path",{d:"M4 4 L4.8 13.5 H11.2 L12 4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Clear selection",shortcut:"Esc",side:"up",children:G("button",{type:"button",class:"selection-bar-icon",onClick:I6,"aria-label":"Clear selection",children:"×"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function d9($,U=Date.now()){if(!$.expiresAt)return null;let v=Date.parse($.expiresAt);if(!Number.isFinite(v))return null;return Math.max(0,v-U)}function n9($){let U=Math.max(0,Math.ceil($/1000)),v=Math.floor(U/60),J=U%60;return`${v}:${String(J).padStart(2,"0")}`}var lg={todo:"queued","in-progress":"running",blocked:"awaiting",done:"done",cancelled:"vetoed"},rg={todo:"queued","in-progress":"running",blocked:"awaiting",done:"done",cancelled:"cancelled"},iQ=[{id:"all",label:"All",hint:"Everything below in one feed, newest first"},{id:"update",label:"Updates",hint:"Board edits agents made — nodes, edges, pins, work items"},{id:"steer",label:"Steer",hint:"Instructions sent to agents — by you from the composer, or agent-to-agent"},{id:"assistant",label:"Assistant",hint:"Messages agents posted for you to read"},{id:"event",label:"Events",hint:"Run telemetry — tool runs, approvals, failures, policy notes"},{id:"evidence",label:"Evidence",hint:"Proof agents recorded — test results, artifacts, links"}],pQ=Object.fromEntries(iQ.map(($)=>[$.id,$.hint])),ig={policy:"warn",prompt:"accent","assistant-message":"muted","tool-start":"accent","tool-result":"ok",failure:"danger",approval:"warn",steering:"purple",command:"accent",note:"muted",evidence:"ok",steer:"purple",update:"purple",yield:"warn"};function LO($){let U=new Date($);if(Number.isNaN(U.getTime()))return"";return`${String(U.getHours()).padStart(2,"0")}:${String(U.getMinutes()).padStart(2,"0")}`}function pg({item:$}){let U=lg[$.status]??"queued",v=$.nodeIds[0];return G("li",{class:`session-item status-${U}`,"data-work-item-id":$.id,children:[G("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),G("div",{class:"session-item-main",children:[G("button",{type:"button",class:"session-item-title",title:v?"Focus the linked node":void 0,disabled:!v,onClick:()=>v&&G6(v),children:$.title},void 0,!1,void 0,this),$.detail&&G("div",{class:"session-item-detail",children:$.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"session-item-status",children:rg[$.status]??U},void 0,!1,void 0,this),G("span",{class:"session-item-time",children:LO($.updatedAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function og({gate:$,now:U}){let[v,J]=f(null),_=async(W)=>{J(W),await rH($,W),J(null)},z=$.nodeIds[0],K=d9($,U);return G("li",{class:"session-item status-awaiting session-gate","data-gate-id":$.id,children:[G("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),G("div",{class:"session-item-main",children:[G("button",{type:"button",class:"session-item-title",title:z?"Focus the linked node":void 0,disabled:!z,onClick:()=>z&&G6(z),children:$.title},void 0,!1,void 0,this),$.detail&&G("div",{class:"session-item-detail",children:$.detail},void 0,!1,void 0,this),K!==null&&G("div",{class:"session-gate-ttl","data-testid":"gate-countdown",children:["auto-holds in ",n9(K)," if unanswered"]},void 0,!0,void 0,this),G("div",{class:"session-gate-actions",children:[G("button",{type:"button",class:"session-gate-approve",disabled:v!==null,onClick:()=>void _("approved"),children:v==="approved"?"Approving…":"Approve"},void 0,!1,void 0,this),G("button",{type:"button",class:"session-gate-reject",disabled:v!==null,onClick:()=>void _("rejected"),children:v==="rejected"?"Rejecting…":"Reject"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"session-item-time",children:LO($.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function dg({gate:$}){let[U,v]=f(!1);return G("li",{class:"session-item status-vetoed session-gate-held","data-gate-id":$.id,children:[G("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),G("div",{class:"session-item-main",children:[G("span",{class:"session-item-title",children:$.title},void 0,!1,void 0,this),G("div",{class:"session-item-detail",children:"Auto-held — no answer in time, the action did not proceed."},void 0,!1,void 0,this),G("div",{class:"session-gate-actions",children:G("button",{type:"button",class:"session-gate-reject",disabled:U,onClick:()=>{v(!0),iH($).finally(()=>v(!1))},children:U?"Reopening…":"Reopen"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("span",{class:"session-item-status",children:"held"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ng(){let $=b1.value,U=I$.value.size,[v,J]=f(!1),_=(z)=>{J(!0),mH(z).finally(()=>J(!1))};return G("div",{class:`session-scope${$?" is-fenced":""}`,"data-testid":"session-scope",children:[G("span",{class:"session-scope-dot","aria-hidden":"true"},void 0,!1,void 0,this),$?G(A$,{children:[G("span",{class:"session-scope-text",children:["Scoped to ",G("strong",{children:$.nodeIds.length},void 0,!1,void 0,this)," node",$.nodeIds.length===1?"":"s"," · writes outside are blocked"]},void 0,!0,void 0,this),G("button",{type:"button",class:"session-scope-action",disabled:v,onClick:()=>_(null),children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):G(A$,{children:[G("span",{class:"session-scope-text",children:"Unscoped — the agent may write anywhere"},void 0,!1,void 0,this),G("button",{type:"button",class:"session-scope-action",disabled:v||U===0,title:U===0?"Select nodes on the canvas first":"Fence the agent to the selected nodes",onClick:()=>_([...I$.value]),children:["Fence to selection",U>0?` (${U})`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function tg($){if($==="browser")return"you";return O6.value.find((v)=>v.sessionId===$||v.source===$)?.label??$}function ag({entry:$}){let U=z2.value.has($.id);return G("li",{class:`session-timeline-row tone-${ig[$.kind]??"muted"}`,children:[G("span",{class:"session-timeline-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("div",{class:"session-timeline-main",children:[G("div",{class:"session-timeline-head",children:[G("span",{class:"session-timeline-label",title:pQ[JO($.kind)],children:$.label},void 0,!1,void 0,this),$.who&&G("span",{class:"session-timeline-who",style:{"--identity-color":`hsl(${P1($.who)} 65% 62%)`},children:tg($.who)},void 0,!1,void 0,this),G("span",{class:"session-item-time",children:LO($.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"session-timeline-body",children:$.body},void 0,!1,void 0,this),$.undoable&&!U&&G("button",{type:"button",class:"session-timeline-undo","data-testid":"timeline-undo",onClick:()=>void zO($),children:"↩ undo this edit"},void 0,!1,void 0,this),U&&G("div",{class:"session-timeline-undone",children:"undone · steering sent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function oQ(){let[$,U]=f(!1),v=N0.value,J=EH.value,_=e1.value,z=xH.value,K=lH.value,[W,O]=f(!1),[Y,Z]=f(null),q=l4();if(u(()=>{M1()},[]),$)return G("aside",{class:"session-panel is-collapsed","aria-label":"Session (collapsed)",children:[G("button",{type:"button",class:"session-collapse",onClick:()=>U(!1),title:"Expand session panel",children:"‹"},void 0,!1,void 0,this),G("span",{class:"session-collapsed-label",children:"Session"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("aside",{class:"session-panel","aria-label":"Session",children:[G("header",{class:"session-panel-header",children:[G("span",{class:"session-panel-title",children:"Session"},void 0,!1,void 0,this),v&&G("span",{class:`session-live phase-${v.phase}`,title:w0(v),children:[G("span",{class:"session-live-dot","aria-hidden":"true"},void 0,!1,void 0,this),"live"]},void 0,!0,void 0,this),G("span",{class:"top-bar-spacer"},void 0,!1,void 0,this),v&&G("button",{type:"button",class:"session-end",title:"End this session — a receipt and a snapshot of the board follow",onClick:()=>void E9(v),children:"End"},void 0,!1,void 0,this),G("button",{type:"button",class:"session-collapse",onClick:()=>U(!0),title:"Collapse session panel",children:"›"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G(ng,{},void 0,!1,void 0,this),(()=>{let X=K.find((B)=>B.undoable&&!z2.value.has(B.id));if(!X)return null;return G("div",{class:"session-undo-row","data-testid":"session-undo-row",children:[G("span",{class:"session-undo-text",title:X.body,children:["Agent edit on top: ",X.body]},void 0,!0,void 0,this),G("button",{type:"button",class:"session-undo-btn",onClick:()=>void zO(X),children:"↩ Undo"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})(),G("div",{class:"session-panel-body",children:[G("section",{class:"session-section",children:(()=>{let X=J.filter((b)=>b.status==="in-progress"||b.status==="todo").length,B=J.filter((b)=>b.status!=="cancelled"),L=B.filter((b)=>b.status==="done").length,F=J.length-B.length,k=_.length>0,H=W||k,P=X>0?`${X} running`:B.length>0?`${L}/${B.length} done${F>0?` · ${F} cancelled`:""}`:J.length>0?`${J.length} cancelled`:"none yet";return G(A$,{children:[G("button",{type:"button",class:"session-section-toggle","aria-expanded":H,"data-testid":"work-items-toggle",onClick:()=>O((b)=>!b),children:[G("span",{class:"session-section-title",children:"Work items"},void 0,!1,void 0,this),G("span",{class:"session-work-summary",children:[X>0&&G("span",{class:"session-work-dot","aria-hidden":"true"},void 0,!1,void 0,this),P]},void 0,!0,void 0,this),G("span",{class:`session-section-chevron${H?" is-open":""}`,"aria-hidden":"true",children:"›"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&(_.length===0&&z.length===0&&J.length===0?G("div",{class:"session-empty",children:"No work items yet — the agent's tasks and gates appear here."},void 0,!1,void 0,this):G("ul",{class:"session-list","aria-live":"polite","aria-label":"Work items and gates",children:[_.map((b)=>G(og,{gate:b,now:q},b.id,!1,void 0,this)),z.map((b)=>G(dg,{gate:b},b.id,!1,void 0,this)),J.map((b)=>G(pg,{item:b},b.id,!1,void 0,this))]},void 0,!0,void 0,this))]},void 0,!0,void 0,this)})()},void 0,!1,void 0,this),G("section",{class:"session-section",children:[G("h3",{class:"session-section-title",children:"Timeline"},void 0,!1,void 0,this),G("div",{class:"session-timeline-filters",role:"group","aria-label":"Filter timeline",children:iQ.map((X)=>G("button",{type:"button",class:`activity-filter${$U.value===X.id?" is-active":""}`,"aria-pressed":$U.value===X.id,title:X.hint,onMouseEnter:()=>Z(X.id),onMouseLeave:()=>Z((B)=>B===X.id?null:B),onFocus:()=>Z(X.id),onBlur:()=>Z((B)=>B===X.id?null:B),onClick:()=>{$U.value=X.id},children:X.label},X.id,!1,void 0,this))},void 0,!1,void 0,this),G("div",{class:"session-timeline-hint","data-testid":"timeline-filter-hint",children:pQ[Y??$U.value]},void 0,!1,void 0,this),K.length===0?G("div",{class:"session-empty",children:$U.value==="all"?"Nothing recorded yet.":"Nothing of this kind yet."},void 0,!1,void 0,this):G("ul",{class:"session-list session-timeline","aria-live":"polite","aria-label":"Timeline",children:K.map((X)=>G(ag,{entry:X},X.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function FO($){if(!$||typeof $!=="object")return null;let U=$,v=(J)=>Array.isArray(J)?J.length:0;return{added:v(U.addedNodes)+v(U.addedEdges),removed:v(U.removedNodes)+v(U.removedEdges),modified:v(U.modifiedNodes)}}function dQ({onOpenSnapshots:$}){let U=u9.value,[v,J]=f(null),[_,z]=f(!1);if(!U)return null;let K=async()=>{if(!U.snapshot)return;z(!0);try{let Y=await fetch(`/api/canvas/snapshots/${encodeURIComponent(U.snapshot.id)}/diff`,{headers:{"x-pmx-workbench":"1"}});if(Y.ok){let Z=await Y.json();J(FO(Z.diff)??{added:0,removed:0,modified:0})}}finally{z(!1)}},W=new Date(U.endedAt),O=Number.isNaN(W.getTime())?"":`${String(W.getHours()).padStart(2,"0")}:${String(W.getMinutes()).padStart(2,"0")}`;return G("div",{class:"session-receipt","data-testid":"session-receipt",role:"status",children:[G("div",{class:"session-receipt-head",children:[G("span",{class:"session-receipt-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("span",{class:"session-receipt-title",children:[U.endedBy==="human"?"Session ended by you":U.endedBy==="idle-timeout"?"Session ended — idle timeout":U.endedBy==="agent"?"Session ended by the agent":"Session ended",O?` · ${O}`:""]},void 0,!0,void 0,this),G("button",{type:"button",class:"session-receipt-close",onClick:dH,"aria-label":"Dismiss receipt",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"session-receipt-tiles",children:[G("div",{class:"session-receipt-tile",children:[G("span",{class:"session-receipt-tile-label",children:"Items"},void 0,!1,void 0,this),G("span",{class:"session-receipt-tile-value",children:U.counts.items},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"session-receipt-tile",children:[G("span",{class:"session-receipt-tile-label",children:"Done"},void 0,!1,void 0,this),G("span",{class:"session-receipt-tile-value tone-ok",children:U.counts.done},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.counts.cancelled>0&&G("div",{class:"session-receipt-tile",children:[G("span",{class:"session-receipt-tile-label",children:"Cancelled"},void 0,!1,void 0,this),G("span",{class:"session-receipt-tile-value tone-muted",children:U.counts.cancelled},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.counts.rejected>0&&G("div",{class:"session-receipt-tile",children:[G("span",{class:"session-receipt-tile-label",children:"Rejected"},void 0,!1,void 0,this),G("span",{class:"session-receipt-tile-value tone-danger",children:U.counts.rejected},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.counts.held>0&&G("div",{class:"session-receipt-tile",children:[G("span",{class:"session-receipt-tile-label",children:"Held"},void 0,!1,void 0,this),G("span",{class:"session-receipt-tile-value tone-warn",children:U.counts.held},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"session-receipt-note",children:U.snapshot?"A snapshot of the board from before this session is saved — restore it to undo the session.":U.unchanged?"This session changed nothing on the board — no snapshot kept.":"The board was empty when the session started — nothing to restore."},void 0,!1,void 0,this),v&&G("div",{class:"session-receipt-diff","data-testid":"session-receipt-diff",children:["This session: ",v.added," added · ",v.removed," removed · ",v.modified," modified"]},void 0,!0,void 0,this),G("div",{class:"session-receipt-actions",children:[U.snapshot&&G("button",{type:"button",class:"session-receipt-primary",disabled:_,onClick:()=>void K(),children:_?"Comparing…":"View diff"},void 0,!1,void 0,this),G("button",{type:"button",class:"session-receipt-secondary",title:"Open the History drawer — saved boards and past sessions",onClick:$,children:"History"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var sg=[{title:"Tools",shortcuts:[{keys:"V",desc:"Select tool — drag empty space to lasso"},{keys:"Space (hold)",desc:"Pan — drag anywhere moves the board"},{keys:"A",desc:"Annotate — draw on the canvas"}]},{title:"Navigation",shortcuts:[{keys:d$("K"),desc:"Command palette — search nodes & actions"},{keys:"Tab / Shift+Tab",desc:"Cycle through nodes"},{keys:"← ↑ → ↓",desc:"Walk graph along edges (when node focused)"},{keys:"F",desc:"Fit all nodes on screen"},{keys:d$("0"),desc:"Reset viewport to origin"},{keys:`${d$("+")} / ${d$("−")}`,desc:"Zoom in / out"}]},{title:"Creation",shortcuts:[{keys:"M",desc:"New markdown note"},{keys:"I / W / H",desc:"New image / webpage / HTML surface"},{keys:"Shift+F",desc:"New file node (workspace path)"},{keys:"G / Shift+G",desc:"Group the selection (new frame when empty) / ungroup"},{keys:"Double-click",desc:"Create new markdown note on canvas"},{keys:"Drag port → node",desc:"Connect two nodes (hover to reveal ports)"}]},{title:"Selection",shortcuts:[{keys:"Click",desc:"Focus node (highlights neighbors & edges)"},{keys:"Shift+Click",desc:"Toggle node in multi-selection"},{keys:"Drag empty space",desc:"Lasso select multiple nodes"},{keys:n0?"Delete / ⌫":"Delete / Backspace",desc:"Delete the selection (or the focused node)"},{keys:n0?"⌘Z / ⇧⌘Z":"Ctrl+Z / Ctrl+Y",desc:"Undo / redo — agent edits included"},{keys:"Esc",desc:"Clear selection / close overlay"}]},{title:"View",shortcuts:[{keys:"?",desc:"Toggle this shortcut overlay"},{keys:"Minimap",desc:"Click/drag to navigate (toggle in the rail)"},{keys:"Right-click",desc:"Context menu — dock, focus, connect"}]}];function nQ({onClose:$}){return G("div",{class:"shortcut-overlay-backdrop",onMouseDown:$,children:G("div",{class:"shortcut-overlay",onMouseDown:(U)=>U.stopPropagation(),children:[G("div",{class:"shortcut-overlay-header",children:[G("span",{class:"shortcut-overlay-title",children:"Keyboard Shortcuts"},void 0,!1,void 0,this),G("span",{class:"shortcut-overlay-hint",children:["Press ",G("kbd",{children:"?"},void 0,!1,void 0,this)," or ",G("kbd",{children:"Esc"},void 0,!1,void 0,this)," to close"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"shortcut-overlay-body",children:sg.map((U)=>G("div",{class:"shortcut-group",children:[G("div",{class:"shortcut-group-title",children:U.title},void 0,!1,void 0,this),U.shortcuts.map((v)=>G("div",{class:"shortcut-row",children:[G("kbd",{class:"shortcut-keys",children:v.keys},void 0,!1,void 0,this),G("span",{class:"shortcut-desc",children:v.desc},void 0,!1,void 0,this)]},v.keys,!0,void 0,this))]},U.title,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var tQ="Before session · ";function aQ($){let U=new Date($);if(Number.isNaN(U.getTime()))return"";return`${String(U.getHours()).padStart(2,"0")}:${String(U.getMinutes()).padStart(2,"0")}`}function eg($){let U=Date.now()-new Date($).getTime(),v=Math.floor(U/60000);if(v<1)return"just now";if(v<60)return`${v}m ago`;let J=Math.floor(v/60);if(J<24)return`${J}h ago`;return`${Math.floor(J/24)}d ago`}function t9($){if(!$.startsWith(tQ))return null;let U=$.slice(tQ.length),v=U.lastIndexOf(" · ");return v>0?U.slice(0,v):U}function sQ({open:$,onClose:U,anchorRef:v}){let[J,_]=f([]),[z,K]=f(!1),[W,O]=f(!1),[Y,Z]=f(null),[q,X]=f(""),[B,L]=f(null),[F,k]=f({}),H=C(null),P=C(null);u(()=>{if(!$)return;K(!0),gY().then((N)=>{_(N),K(!1)})},[$]),u(()=>{if($)setTimeout(()=>P.current?.focus(),50)},[$]),u(()=>{if(!$)return;let N=(R)=>{let p=H.current,l=v.current;if(p&&!p.contains(R.target)&&l&&!l.contains(R.target))U()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[$,U]),u(()=>{if(!$)return;let N=(R)=>{if(R.key==="Escape")U()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[$,U]);let b=j(async()=>{let N=q.trim();if(!N)return;O(!0);let R=await NY(N);if(O(!1),R.ok&&R.snapshot)_((p)=>[R.snapshot,...p]),X("")},[q]),V=j(async(N)=>{L(null),Z(N);let R=await SY(N);if(Z(null),R.ok)U()},[U]),E=j(async(N)=>{if((await RY(N)).ok)_((p)=>p.filter((l)=>l.id!==N));L(null)},[]),A=j(async(N)=>{k((p)=>({...p,[N]:"loading"}));let R=await M$("snapshotDiff",`/api/canvas/snapshots/${encodeURIComponent(N)}/diff`,{});k((p)=>({...p,[N]:FO(R.diff)??{added:0,removed:0,modified:0}}))},[]);if(!$)return null;let I=(N,R)=>B?.id===N.id?G(A$,{children:[G("button",{type:"button",class:`snapshot-action-btn ${B.action==="delete"?"snapshot-action-confirm":"snapshot-action-restore"}`,onClick:()=>B.action==="delete"?E(N.id):V(N.id),title:B.action==="delete"?"Confirm delete":"Confirm restore",disabled:Y!==null,children:B.action==="delete"?"Delete":Y===N.id?"Restoring…":"Confirm"},void 0,!1,void 0,this),G("button",{type:"button",class:"snapshot-action-btn",onClick:()=>L(null),title:"Cancel",disabled:Y!==null,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):G(A$,{children:[G("button",{type:"button",class:"snapshot-action-btn snapshot-action-restore",onClick:()=>L({id:N.id,action:"restore"}),title:"Restore this snapshot — replaces the current canvas (undoable)",disabled:Y!==null,children:Y===N.id?"Restoring…":R},void 0,!1,void 0,this),G("button",{type:"button",class:"snapshot-action-btn snapshot-action-delete",onClick:()=>L({id:N.id,action:"delete"}),title:"Delete this snapshot","aria-label":"Delete snapshot",disabled:Y!==null,children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return G("div",{ref:H,class:"snapshot-panel","data-testid":"history-drawer",role:"dialog","aria-label":"History",children:[G("div",{class:"snapshot-panel-header",children:[G("span",{class:"snapshot-panel-title",children:"History"},void 0,!1,void 0,this),G("span",{class:"snapshot-panel-sub",children:"snapshots + sessions"},void 0,!1,void 0,this),G("span",{class:"snapshot-panel-spacer"},void 0,!1,void 0,this),G("button",{type:"button",class:"snapshot-panel-close",onClick:U,title:"Close","aria-label":"Close history",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"snapshot-save-form",children:[G("input",{ref:P,type:"text",class:"snapshot-name-input",value:q,onInput:(N)=>X(N.target.value),onKeyDown:(N)=>{if(N.key==="Enter")b()},placeholder:"Save a snapshot as…","aria-label":"Snapshot name",maxLength:80,disabled:W},void 0,!1,void 0,this),G("button",{type:"button",class:"snapshot-save-btn",onClick:b,disabled:!q.trim()||W,children:W?"…":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"snapshot-restore-note",children:"Restoring replaces the current canvas. You can undo it if needed."},void 0,!1,void 0,this),G("div",{class:"snapshot-list",children:[z&&G("div",{class:"snapshot-empty",children:"Loading…"},void 0,!1,void 0,this),!z&&J.length===0&&G("div",{class:"snapshot-empty",children:"No history yet. Save a snapshot, or start an agent session — it snapshots for you."},void 0,!1,void 0,this),!z&&[...J.filter((N)=>t9(N.name)===null),...J.some((N)=>t9(N.name)!==null)?[{id:"__sessions-header__"}]:[],...J.filter((N)=>t9(N.name)!==null)].map((N)=>{if(N.id==="__sessions-header__")return G("div",{class:"snapshot-section-header","data-testid":"history-sessions-header",children:"Sessions"},N.id,!1,void 0,this);let R=t9(N.name),p=F[N.id];if(R!==null)return G("div",{class:"snapshot-item is-session","data-testid":"history-session",children:[G("div",{class:"snapshot-item-head",children:[G("span",{class:"snapshot-session-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("span",{class:"snapshot-item-name",children:["Agent session — ",R]},void 0,!0,void 0,this),G("span",{class:"snapshot-item-time",children:aQ(N.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"snapshot-item-meta",children:["snapshot at session start · ",N.nodeCount," node",N.nodeCount!==1?"s":"",p&&p!=="loading"&&G("span",{class:"snapshot-item-diff",children:[" ","· since: ",p.added," added · ",p.removed," removed · ",p.modified," modified"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"snapshot-item-actions is-session",children:[G("button",{type:"button",class:"snapshot-action-btn snapshot-action-diff",disabled:p==="loading",onClick:()=>void A(N.id),children:p==="loading"?"Comparing…":"View diff"},void 0,!1,void 0,this),I(N,"Restore pre-state")]},void 0,!0,void 0,this)]},N.id,!0,void 0,this);return G("div",{class:"snapshot-item","data-testid":"history-snapshot",children:[G("div",{class:"snapshot-item-head",children:[G("span",{class:"snapshot-item-glyph","aria-hidden":"true",children:"◫"},void 0,!1,void 0,this),G("span",{class:"snapshot-item-name",children:N.name},void 0,!1,void 0,this),G("span",{class:"snapshot-item-time",children:aQ(N.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G("div",{class:"snapshot-item-meta",children:[N.nodeCount," node",N.nodeCount!==1?"s":"",N.edgeCount>0?` · ${N.edgeCount} edge${N.edgeCount!==1?"s":""}`:""," · ",eg(N.createdAt)]},void 0,!0,void 0,this),G("div",{class:"snapshot-item-actions",children:I(N,"Restore")},void 0,!1,void 0,this)]},N.id,!0,void 0,this)})]},void 0,!0,void 0,this),G("div",{class:"snapshot-panel-foot",children:"Every agent session start writes a snapshot automatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $N(){let $=gH.value;if($.length===0)return null;return G(A$,{children:$.map((U)=>{let v=O6.value.filter((J)=>J.parentAgentId!=null&&(J.parentAgentId===U.sessionId||J.parentAgentId===U.source)).length;return G(J6,{label:`Agent session — ${U.label}`,tapToOpen:!0,body:"What this attached agent is doing right now: idle, thinking, running a tool, or waiting on your approval. Steer it from the composer below.",children:G("span",{class:`agent-chip phase-${U.phase}`,"data-phase":U.phase,style:{"--identity-color":`hsl(${P1(U.sessionId)} 65% 62%)`},children:[G("span",{class:"agent-chip-dot","aria-hidden":"true"},void 0,!1,void 0,this),G("span",{class:"agent-chip-label",children:w0(U)},void 0,!1,void 0,this),G("span",{class:"agent-chip-who hud-collapsible-text",children:U.label},void 0,!1,void 0,this),v>0&&G("span",{class:"agent-chip-workers",children:["+",v," worker",v===1?"":"s"]},void 0,!0,void 0,this),G("button",{type:"button",class:"agent-chip-end","aria-label":`End ${U.label} session`,title:`End ${U.label}'s session`,onClick:(J)=>{J.stopPropagation(),E9({source:U.source,agentId:U.agentId})},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},U.sessionId,!1,void 0,this)})},void 0,!1,void 0,this)}function UN(){let $=e1.value.length,U=N0.value!==null&&$>0,v=l4(U?1000:0);if(!U)return null;let J=e1.value.map((_)=>d9(_,v)).filter((_)=>_!==null).sort((_,z)=>_-z)[0];return G(J6,{label:"Approval gates waiting on you",tapToOpen:!0,body:"The agent is blocked until you approve or reject in the session panel; unanswered gates auto-hold when the countdown runs out.",children:G("span",{class:"gate-badge",children:[$," gate",$===1?"":"s",J!==void 0&&` · ${n9(J)}`]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function _N($){if($>0.9)return"danger";if($>=0.7)return"warn";return"ok"}function W2($){return $>=1000?`${($/1000).toFixed($>=1e4?0:1)}k`:String($)}function vN(){let $=N0.value;if(!$)return null;let U=dW.value,v=$.contextUsage,J=v?v.used:U.used,_=v?v.total:U.total,z=_>0?Math.min(1,J/_):0,K=Math.round(z*100),W=v?{label:`Context window — reported by ${$.label}`,body:`${W2(v.used)} of ${W2(v.total)} tokens of the agent's actual context window are used. Your ✦-pinned nodes account for ≈ ${W2(U.used)} tokens of it.`}:{label:"Pins — pinned-context size (estimate)",body:`The nodes you pinned (✦) are what the agent is asked to carry as context: ≈ ${W2(U.used)} of a ${W2(U.total)}-token budget. When the agent's host reports its real context window, this meter switches to showing that instead.`};return G(J6,{label:W.label,body:W.body,tapToOpen:!0,children:G("span",{class:`context-budget tone-${_N(z)}`,"data-mode":v?"window":"pins",children:[G("span",{class:"context-budget-caption hud-collapsible-text",children:v?"Context":"Pins"},void 0,!1,void 0,this),G("span",{class:"context-budget-track","aria-hidden":"true",children:G("span",{class:"context-budget-fill",style:{width:`${K}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"context-budget-label","data-testid":"budget-label",children:[J>0&&K===0?"<1":K,"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function JN(){let[$,U]=f(!1);if(N0.value)return null;return G(J6,{label:"Start an agent session",body:"Attaches a session to this board: the next agent that writes here is adopted into it, and you get the panel, composer, and receipt.",children:G("button",{type:"button",class:"start-session-btn",disabled:$,onClick:()=>{U(!0),A1().finally(()=>U(!1))},children:[G("span",{class:"start-session-dot","aria-hidden":"true"},void 0,!1,void 0,this),"Start agent session",G("span",{class:"beta-tag",children:"beta"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function eQ(){let $=x6.value,U=K4.value,v=G$.value,J=D.value.size,_=c$.value.size,z=MU.value,K=Array.from(D.value.values()).filter((B)=>B.type==="trace").length,[W,O]=f("");u(()=>{let B=!1;return fetch("/health").then((L)=>L.ok?L.json():null).then((L)=>{if(B||typeof L?.workspace!=="string"||!L.workspace)return;let F=L.workspace.replace(/[\\/]+$/,"").split(/[\\/]/).pop();if(F)O(F)}).catch(()=>{}),()=>{B=!0}},[]);let Y=YO.value,Z=Y??($==="connected"&&!U?"syncing":$),q=U?[`${J} node${J!==1?"s":""}`,..._>0?[`${_} edge${_!==1?"s":""}`]:[],...K>0?[`${K} trace${K!==1?"s":""}`]:z?["trace armed"]:[]].join(" · "):"Syncing canvas…",X=()=>{let B=d6();SU(B.width,B.height)};return G("div",{class:"top-bar",children:[G(J6,{label:`Canvas status: ${Z}`,tapToOpen:!0,body:"Live updates stream in over SSE; amber means reconnecting.",align:"start",children:G("span",{class:`connection-dot ${Y??$}`,"aria-label":`Canvas status: ${Z}`},void 0,!1,void 0,this)},void 0,!1,void 0,this),G("span",{class:"top-bar-title",title:W||"PMX Canvas",children:W||"PMX Canvas"},void 0,!1,void 0,this),G("span",{class:"top-bar-meta hud-collapsible-text",children:D4.value?D4.value.slice(0,12):"…"},void 0,!1,void 0,this),G("span",{class:"top-bar-meta hud-collapsible-text",children:q},void 0,!1,void 0,this),G("span",{class:"top-bar-spacer"},void 0,!1,void 0,this),G($N,{},void 0,!1,void 0,this),G(UN,{},void 0,!1,void 0,this),G(vN,{},void 0,!1,void 0,this),G(DQ,{},void 0,!1,void 0,this),G(JN,{},void 0,!1,void 0,this),G("div",{class:"top-bar-sep"},void 0,!1,void 0,this),G(J6,{label:"Zoom out",shortcut:d$("−"),children:G("button",{type:"button",class:"top-bar-btn",onClick:()=>gU(0.8),"aria-label":"Zoom out",children:G(JH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Reset zoom",shortcut:d$("0"),children:G("button",{type:"button",class:"top-bar-zoom-label",onClick:()=>U1({x:0,y:0,scale:1},250),"aria-label":"Reset view",children:[Math.round(v.scale*100),"%"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Zoom in",shortcut:d$("+"),children:G("button",{type:"button",class:"top-bar-btn",onClick:()=>gU(1.25),"aria-label":"Zoom in",children:G(vH,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),G(J6,{label:"Fit all",shortcut:"F",align:"end",children:G("button",{type:"button",class:"top-bar-btn",onClick:X,"aria-label":"Fit canvas",children:G(A9,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $L($,U,v,J,_){return $.x<J.position.x+J.size.width+_&&$.x+U+_>J.position.x&&$.y<J.position.y+J.size.height+_&&$.y+v+_>J.position.y}function zN($,U,v,J,_){return J.some((z)=>$L($,U,v,z,_))}function KN($,U,v,J,_){return J.find((z)=>$L($,U,v,z,_))}function a9($,U,v,J=24){if($.length===0)return{x:40,y:80};let _=$[$.length-1],z={x:_.position.x+_.size.width+J,y:_.position.y};if(!zN(z,U,v,$,J))return z;let K=40,W=80,O=3000,Y=W;for(let q=0;q<20;q++){let X=K;while(X+U<O){let F=KN({x:X,y:Y},U,v,$,J);if(!F)return{x:X,y:Y};X=F.position.x+F.size.width+J}Y=$.filter((F)=>F.position.y<=Y+v+J&&F.position.y+F.size.height+J>Y).reduce((F,k)=>Math.max(F,k.position.y+k.size.height),Y)+J}let Z=$.reduce((q,X)=>Math.max(q,X.position.y+X.size.height),0);return{x:K,y:Z+J}}var I1={status:{x:40,y:80,w:300,h:120},markdown:{x:380,y:80,w:720,h:600},context:{x:1130,y:80,w:320,h:400},"mcp-app":{x:380,y:720,w:960,h:600},webpage:{x:380,y:80,w:520,h:420},"json-render":{x:380,y:720,w:840,h:620},graph:{x:380,y:720,w:760,h:520},ledger:{x:1130,y:520,w:320,h:280},trace:{x:40,y:900,w:200,h:56},file:{x:380,y:80,w:720,h:600},diff:{x:380,y:80,w:640,h:420},mermaid:{x:380,y:80,w:640,h:460},image:{x:380,y:80,w:720,h:520},html:{x:380,y:80,w:720,h:640},group:{x:220,y:60,w:840,h:560},prompt:{x:380,y:1260,w:520,h:400},response:{x:380,y:1480,w:720,h:400}};function O2($,U,v,J={}){let _=I1[U];return{id:$,type:U,position:J.position??{x:_.x,y:_.y},size:J.size??{width:_.w,height:_.h},zIndex:U==="status"?0:1,collapsed:!1,pinned:!1,data:v}}var vU=null,$8=null,s9=0,w1=null,GN=3000,WN=2000,UL=5000,Y2=!1,i4=null,D0=null,N1=0,g1=null;function ON(){if(typeof location>"u"||typeof window>"u")return null;let $=new URLSearchParams(location.search).get("transport");if($==="poll"||$==="sse")return $;if(window.__PMX_AMP_ORB===!0)return"poll";return null}var j0=new Map;function Z2($){let U=0;for(let v=0;v<$.length;v++)U=(U<<5)-U+$.charCodeAt(v)|0;return Math.abs(U).toString(36)}function U8($){if(!$8)return $;let U=$8.get($.id);if(!U)return $;return{...$,position:U.position??$.position,size:U.size??$.size,collapsed:U.collapsed??$.collapsed,pinned:U.pinned??$.pinned}}function q2($,U,v){return U8(O2($,U,v))}function YN(){return a9([...D.value.values()],I1.markdown.w,I1.markdown.h)}function V0(){if(!D.value.has("status-main"))j4(q2("status-main","status",{phase:"idle",message:"",elapsed:0}))}function ZN($,U){let v=`md-${Z2($)}`;if(D.value.get(v))W$(v,{path:$,title:U}),C$.value=v;else{let _=YN(),z=q2(v,"markdown",{path:$,title:U,content:"",rendered:""});z.position=_,j4(z),G6(v)}}function qN($){if(D.value.get("context-main"))W$("context-main",{cards:$});else if($.length>0){let J=q2("context-main","context",{cards:$});j4(J)}}function BN($){let U=$.url,v=`mcp-${Z2(U)}`;if(D.value.get(v))W$(v,$);else j4(q2(v,"mcp-app",$)),G6(v)}function XN($){let U=$.toolCallId,J=(typeof $.nodeId==="string"&&$.nodeId.length>0?$.nodeId:null)??(U.startsWith("ext-app-")?U:`ext-app-${U}`);if(D.value.get(J)){W$(J,$);return}let{serverName:z,toolName:K}=$;if(z&&K){for(let[k,H]of D.value.entries())if(H.type==="mcp-app"&&H.data.mode==="ext-app"&&H.data.serverName===z&&H.data.toolName===K&&!H.data.toolResult){W$(k,{...$});return}}let{_x:W,_y:O,_width:Y,_height:Z}=$,q=I1["mcp-app"],X=Y??q.w,B=Z??q.h,L=W===void 0||O===void 0?a9([...D.value.values()],X,B):null,F=U8(O2(J,"mcp-app",{mode:"ext-app",...$},{position:{x:W??L?.x??q.x,y:O??L?.y??q.y},size:{width:X,height:B}}));j4(F),G6(J,{recordHistory:!1})}function HN($){let U=$.startsWith("ext-app-")?$:`ext-app-${$}`;if(D.value.has(U))return U;let v=`ext-app-${$}`;if(v!==U&&D.value.has(v))return v;for(let[J,_]of D.value.entries())if(_.type==="mcp-app"&&_.data.mode==="ext-app"&&_.data.toolCallId===$)return J;return null}function KL($){let U=typeof $.nodeId==="string"&&$.nodeId.length>0?$.nodeId:null;if(U&&D.value.has(U))return U;if(typeof $.toolCallId!=="string"||!$.toolCallId)return null;return HN($.toolCallId)}function GL($,U){if(typeof $!=="string"||!$)return null;if(typeof U!=="string"||!U)return null;let v=null;for(let[J,_]of D.value.entries())if(_.type==="mcp-app"&&_.data.mode==="ext-app"&&_.data.serverName===$&&_.data.toolName===U&&!_.data.toolResult){if(v)return null;v=J}return v}function WL($){if(D.value.get("ledger-main"))W$("ledger-main",$);else{let J=q2("ledger-main","ledger",$);J.collapsed=!0,j4(J)}}function PO($){if(!e0($))return;if(document.documentElement.setAttribute("data-theme",$),P0(),$6.value!==$)$6.value=$}function QN($){return $==="markdown"||$==="mcp-app"||$==="webpage"||$==="json-render"||$==="graph"||$==="prompt"||$==="response"||$==="status"||$==="context"||$==="ledger"||$==="trace"||$==="file"||$==="diff"||$==="mermaid"||$==="image"||$==="html"||$==="group"}function LN($){return $==="relation"||$==="depends-on"||$==="flow"||$==="references"}function kO($){if(!$||typeof $!=="object")return null;let U=$;if(typeof U.x!=="number"||typeof U.y!=="number")return null;return{x:U.x,y:U.y}}function OL($){if(!$||typeof $!=="object")return null;let U=$;if(typeof U.width!=="number"||typeof U.height!=="number")return null;return{width:U.width,height:U.height}}function FN($){let U=kO($),v=OL($);return U&&v?{...U,...v}:null}function PN($){if(typeof $.id!=="string"||!$.id)return null;if(!QN($.type))return null;let U=kO($.position),v=OL($.size);if(!U||!v)return null;let J=$.data&&typeof $.data==="object"?Object.fromEntries(Object.entries($.data)):{};return{id:$.id,type:$.type,position:U,size:v,zIndex:typeof $.zIndex==="number"?$.zIndex:1,collapsed:$.collapsed===!0,pinned:$.pinned===!0,data:J}}function kN($){if(typeof $.id!=="string"||!$.id)return null;if(typeof $.from!=="string"||!$.from)return null;if(typeof $.to!=="string"||!$.to)return null;if(!LN($.type))return null;return{id:$.id,from:$.from,to:$.to,type:$.type,...typeof $.label==="string"?{label:$.label}:{},...$.style==="solid"||$.style==="dashed"||$.style==="dotted"?{style:$.style}:{},...$.animated===!0?{animated:!0}:{}}}function bN($){if(typeof $.id!=="string"||!$.id)return null;if($.type!=="freehand"&&$.type!=="text")return null;if(!Array.isArray($.points))return null;let U=$.points.map((J)=>kO(J)).filter((J)=>J!==null),v=FN($.bounds);if(U.length<($.type==="text"?1:2)||!v)return null;return{id:$.id,type:$.type,points:U,bounds:v,color:typeof $.color==="string"?$.color:"#f97316",width:typeof $.width==="number"?$.width:4,...typeof $.text==="string"?{text:$.text}:{},...typeof $.label==="string"?{label:$.label}:{},createdAt:typeof $.createdAt==="string"?$.createdAt:""}}var _L="pmx-canvas-version-reload";function MN($,U){if(typeof window>"u")return;let v=window,J=(z,K)=>typeof z==="string"&&z!==""&&z!=="unknown"&&typeof K==="string"&&K!==""&&K!=="unknown"&&z!==K;if(!J($,v.__PMX_BOOT_SERVER_VERSION)&&!J(U,v.__PMX_BOOT_BUNDLE_STAMP))return;let _=`${String($)}::${String(U)}`;try{if(window.sessionStorage.getItem(_L)===_)return;window.sessionStorage.setItem(_L,_)}catch{return}window.location.reload()}function AN($){let U=k1.value[0]?.id;if(aW($),k6.value&&k1.value[0]?.id!==U)M1()}function IN($){oH($)}var vL=null;function wN($){$O($)}function gN($){if(D4.value=$.sessionId||"",x6.value="connected",f1.value+=1,MN($.version,$.bundleStamp),l0(),MY().then(aW),vL?.(),!m2)vL=VH();if(M$("fetchHumanPresence","/api/canvas/human-presence",null).then($O),g8().then((U)=>{if(G4.value=U,k6.value)M1()}),typeof $.theme==="string"&&!ZO())PO($.theme);if($.ledgerSummary)WL($.ledgerSummary)}function NN($){if(typeof $.path!=="string"||!$.path)return;let U=$.path,v=(typeof $.title==="string"?$.title:"")||U.split("/").pop()||"Untitled";if(ZN(U,v),$.ledgerSummary)WL($.ledgerSummary)}function SN($){V0(),W$("status-main",{message:typeof $.message==="string"?$.message:String($.message??""),level:$.level??"ok",source:$.source})}function RN($){V0(),W$("status-main",{phase:$.phase,detail:$.detail})}function TN($){let U=$.cards??[];qN(U)}function yN($){if(typeof $.url==="string"&&$.url)BN({url:$.url,sourceServer:$.sourceServer,sourceTool:$.sourceTool,inferredType:$.inferredType,trustedDomain:$.trustedDomain,hostMode:$.hostMode??"hosted"})}function CN($){let U=$.sessions??[];for(let v of U){let J=v.url;if(!J)continue;let _=`mcp-${Z2(J)}`;if(D.value.has(_))W$(_,{sessionState:v.state,lastSeenAt:v.lastSeenAt})}}function DN($){if(typeof $.url==="string"&&$.url){let U=`mcp-${Z2($.url)}`;if(D.value.has(U))W$(U,{hostMode:"fallback",fallbackReason:$.reasonCode})}}function jN($){let v=D.value.get("context-main");if(!v)return;let J=(v.data.auxTabs??[]).concat($);W$("context-main",{auxTabs:J})}function VN($){if(D.value.has("context-main"))if($.mode==="all")W$("context-main",{auxTabs:[]});else{let J=D.value.get("context-main");if(!J)return;let _=(J.data.auxTabs??[]).filter((z)=>z.id!==$.id);W$("context-main",{auxTabs:_})}}function fN($){V0(),W$("status-main",{phase:"idle",lastCompletion:{tokenCount:$.tokenCount,artifactCount:$.artifactCount}})}function EN($){V0(),W$("status-main",{phase:"tooling",detail:`${$.name}`,activeTool:$.name})}function uN($){V0(),W$("status-main",{activeTool:null})}function mN($){if($.state==="active"&&$.path){let v=`md-${Z2($.path)}`;if(D.value.has(v))W$(v,{reviewActive:!0})}}function xN($){if(typeof $.toolCallId!=="string"||!$.toolCallId)return;XN({toolCallId:$.toolCallId,...typeof $.nodeId==="string"&&$.nodeId.length>0?{nodeId:$.nodeId}:{},title:$.title,html:$.html,toolInput:$.toolInput,serverName:$.serverName,toolName:$.toolName,appSessionId:$.appSessionId,resourceUri:$.resourceUri,toolDefinition:$.toolDefinition,resourceMeta:$.resourceMeta,hostMode:"hosted",trustedDomain:!0,...$.chartConfig?{chartConfig:$.chartConfig}:{},...typeof $.x==="number"&&{_x:$.x},...typeof $.y==="number"&&{_y:$.y},...typeof $.width==="number"&&{_width:$.width},...typeof $.height==="number"&&{_height:$.height}})}function hN($){if(typeof $.toolCallId!=="string"||!$.toolCallId)return;let U=KL($)??GL($.serverName,$.toolName);if(!U)return;if(D.value.has(U))W$(U,{html:$.html})}function cN($){if(typeof $.toolCallId!=="string"||!$.toolCallId)return;let U=KL($)??GL($.serverName,$.toolName);if(!U)return;if(D.value.has(U)){if($.success===!1){h6(U);return}W$(U,{toolResult:SW({result:$.result,success:typeof $.success==="boolean"?$.success:void 0,error:typeof $.error==="string"?$.error:void 0,content:typeof $.content==="string"?$.content:void 0,detailedContent:typeof $.detailedContent==="string"?$.detailedContent:void 0})})}}function lN($){V0(),W$("status-main",{subagent:{state:$.state,name:$.agentDisplayName??$.agentName}})}function rN($){let U=$.nodeId;if(!U)return;let v=$.text||"",J=$.position,_=$.parentNodeId,z=$.contextNodeIds;if($.threadNodeId&&D.value.has($.threadNodeId)){let K=$.threadNodeId,W=D.value.get(K);if(!W)return;let O=Array.isArray(W.data.turns)?[...W.data.turns]:[],Y=O[O.length-1];if(!Y||Y.role!=="user"||Y.text!==v)O.push({role:"user",text:v,status:"pending"});W$(K,{turns:O,threadStatus:"pending"});return}if(!D.value.has(U)){let K=J??I1.prompt;j4(U8(O2(U,"prompt",{text:v,turns:v?[{role:"user",text:v,status:"pending"}]:[],threadStatus:v?"pending":"draft",status:v?"pending":"draft",parentNodeId:_,contextNodeIds:z},{position:{x:K.x,y:K.y}}))),G6(U)}if(_&&D.value.has(_))Jv({id:`edge-${_}-${U}`,from:_,to:U,type:"flow",style:"dashed"})}function iN($){let{nodeId:U,status:v}=$;if(U&&D.value.has(U))W$(U,{status:v})}function pN($){let{responseNodeId:U,promptNodeId:v}=$;if(!U)return;let J=v?D.value.get(v):void 0;if(J&&Array.isArray(J.data.turns)){j0.set(U,v);let z=[...J.data.turns];z.push({role:"assistant",text:"",status:"streaming"}),W$(v,{turns:z,threadStatus:"streaming",_activeResponseId:U}),G6(v);return}let _=J?{x:J.position.x,y:J.position.y+J.size.height+24}:{x:I1.response.x,y:I1.response.y};if(!D.value.has(U))j4(U8(O2(U,"response",{content:"",status:"streaming",promptNodeId:v},{position:_})));if(v)Jv({id:`edge-${v}-${U}`,from:v,to:U,type:"flow",animated:!0});G6(U)}function oN($){let U=$.responseNodeId;if(!U)return;let v=j0.get(U);if(v){let J=D.value.get(v);if(J&&Array.isArray(J.data.turns)){let _=[...J.data.turns],z=_[_.length-1];if(z&&z.role==="assistant")z.text=$.content,z.status="streaming";W$(v,{turns:_,threadStatus:"streaming"})}return}if(!D.value.has(U))return;W$(U,{content:$.content,status:"streaming"})}function dN($){let U=$.responseNodeId;if(!U)return;let v=j0.get(U);if(v){let z=D.value.get(v);if(z&&Array.isArray(z.data.turns)){let K=[...z.data.turns],W=K[K.length-1];if(W&&W.role==="assistant")W.text=$.content,W.status="complete";W$(v,{turns:K,threadStatus:"answered",_activeResponseId:void 0})}j0.delete(U);return}if(!D.value.has(U))return;W$(U,{content:$.content,status:"complete"});let _=D.value.get(U)?.data.promptNodeId;if(_){let z=`edge-${_}-${U}`,K=c$.value.get(z);if(K)KZ(z),Jv({...K,animated:!1})}}function nN($){let U=$.layout;if(!U?.nodes)return;let v=!K4.value;K4.value=!0;let J=U.nodes.map(PN).filter((W)=>W!==null),_=Array.isArray(U.edges)?U.edges.map(kN).filter((W)=>W!==null):Array.from(c$.value.values()),z=Array.isArray(U.annotations)?U.annotations.map(bN).filter((W)=>W!==null):void 0,K=U.viewport?{x:typeof U.viewport.x==="number"?U.viewport.x:0,y:typeof U.viewport.y==="number"?U.viewport.y:0,scale:typeof U.viewport.scale==="number"?U.viewport.scale:1}:void 0;NU(),qZ({...K?{viewport:K}:{},nodes:J,edges:_,...z?{annotations:z}:{}},{applyViewport:v}),V8({event:"canvas-layout-update",data:$})}function tN($){if($<=1)return 500;if($===2)return 1000;return Math.min(2500,1500+($-3)*500)}function aN($){let U=$.nodeId;if(U&&D.value.has(U)){if($.noPan===!0){V4(U);return}G6(U)}}function sN($){let U=$.viewport;if(!U)return;let v=typeof U.x==="number"?U.x:0,J=typeof U.y==="number"?U.y:0,_=typeof U.scale==="number"?U.scale:1;NU(),OZ({x:v,y:J,scale:_})}function eN($){if(D.value.get("context-main"))W$("context-main",{currentTokens:$.currentTokens,tokenLimit:$.tokenLimit,messagesLength:$.messagesLength,utilization:$.utilization,nearLimit:$.nearLimit})}function $S($){MU.value=$.enabled===!0}function US($){if(typeof $.theme==="string"&&!ZO())PO($.theme)}function _S($){let U=Array.isArray($.nodeIds)?$.nodeIds.filter((v)=>typeof v==="string"):[];zZ(U),V8({event:"context-pins-changed",data:$})}var e9=null;function JL(){if(e9)clearTimeout(e9);e9=setTimeout(()=>{if(e9=null,g8().then(($)=>{G4.value=$}),k6.value)M1()},150)}function vS($){let U=$.intent;if(!U||typeof U.id!=="string"||typeof U.kind!=="string"||typeof U.expiresAt!=="number")return;eX(U)}function JS($){let U=typeof $.id==="string"?$.id:"";if(!U)return;if($.settled===!0)UH(U,typeof $.nodeId==="string"?$.nodeId:void 0);else EW(U)}var YL={connected:gN,"workbench-open":NN,"canvas-status":SN,"execution-phase":RN,"context-cards":TN,"mcp-app-candidate":yN,"mcp-app-host-snapshot":CN,"mcp-app-host-fallback":DN,"aux-open":jN,"aux-close":VN,"assistant-complete":fN,"tool-start":EN,"tool-complete":uN,"review-state":mN,"subagent-status":lN,"ext-app-open":xN,"ext-app-update":hN,"ext-app-result":cN,"context-pins-changed":_S,"canvas-layout-update":nN,"canvas-focus-node":aN,"canvas-viewport-update":sN,"context-usage":eN,"trace-state":$S,"theme-changed":US,"canvas-prompt-created":rN,"canvas-prompt-status":iN,"canvas-response-start":pN,"canvas-response-delta":oN,"canvas-response-complete":dN,"ax-state-changed":JL,"ax-event-created":JL,"ax-intent":vS,"ax-intent-clear":JS,"agent-presence":AN,"human-presence":wN,"agent-session-ended":IN};function ZL($,U){let v=YL[$];if(!v)return;let J=v;try{J(U)}catch(_){console.warn(`[sse-bridge] Handler for "${$}" failed:`,_)}}function zL(){Y2=!0,N1+=1;let $=N1;x6.value="connecting";let U=null,v=!1,J=async()=>{if($!==N1)return;try{let _=new URLSearchParams;if(D0!==null)_.set("since",String(D0));let z=D4.value;if(z)_.set("session",z);let K=_.toString(),W=await fetch(`/api/workbench/poll${K?`?${K}`:""}`);if($!==N1)return;if(!W.ok)throw Error(`poll failed with HTTP ${W.status}`);let O=await W.json();if($!==N1)return;if(!O.ok)throw Error("poll returned ok: false");let Y=U;if(U=O.sessionId??null,Y!==null&&O.sessionId&&Y!==O.sessionId&&!O.snapshot){D0=null,i4=setTimeout(()=>void J(),0);return}if(O.snapshot&&v)$8=i8(),K4.value=!1,j8(),uW(),j0.clear();for(let Z of O.events)ZL(Z.event,Z.payload);v=!0,D0=O.seq,E1.value=0,u1.value=0,x6.value="connected",i4=setTimeout(()=>void J(),WN)}catch(_){if($!==N1)return;console.warn("[sse-bridge] poll transport error:",_),x6.value="disconnected",E1.value+=1,u1.value=UL,i4=setTimeout(()=>void J(),UL)}};return J(),()=>{if(N1+=1,Y2=!1,D0=null,i4)clearTimeout(i4),i4=null}}function bO(){if(wQ(PO),$8=i8(),K4.value=!1,j8(),uW(),j0.clear(),w1)clearTimeout(w1),w1=null;let $=ON();if($==="poll"||Y2)return zL();let U=D4.value,v=U?`/api/workbench/events?session=${U}`:"/api/workbench/events";x6.value="connecting";let J=new EventSource(v);vU=J;let _=!1;if(g1)clearTimeout(g1);if(g1=null,$!=="sse")g1=setTimeout(()=>{if(g1=null,_||vU!==J)return;console.warn("[sse-bridge] No SSE event within watchdog window — switching to polling transport."),window.dispatchEvent(new Event("pmx-canvas-boot-extend")),J.close(),vU=null,zL()},GN);for(let[z]of Object.entries(YL))J.addEventListener(z,(K)=>{_=!0;try{ZL(z,JSON.parse(K.data))}catch(W){console.warn(`[sse-bridge] Failed to parse "${z}" event:`,W)}});return J.onopen=()=>{if(vU!==J)return;s9=0,E1.value=0,u1.value=0,x6.value="connected"},J.onerror=()=>{if(vU!==J)return;x6.value="disconnected",J.close(),vU=null,s9+=1;let z=tN(s9);E1.value=s9,u1.value=z,w1=setTimeout(()=>{w1=null,bO()},z)},()=>{if(w1)clearTimeout(w1),w1=null;if(g1)clearTimeout(g1),g1=null;if(Y2){if(N1+=1,Y2=!1,D0=null,i4)clearTimeout(i4),i4=null}J.close(),vU=null}}function JU($,U){console.error(`[app] ${$} failed`,U)}function qL(){let[$,U]=f(!0),[v,J]=f(!1),[_,z]=f(!1),[K,W]=f(!1),[O,Y]=f(null),Z=C(null),{menu:q,openNodeMenu:X,openCanvasMenu:B,openEdgeMenu:L,closeMenu:F}=NQ(),k=K4.value,H=k6.value,P=j(()=>U((R)=>!R),[]),b=j(()=>J((R)=>!R),[]),V=j(()=>J(!1),[]),E=j((R)=>Y(R),[]),A=j((R,p)=>{U1({x:R,y:p,scale:G$.value.scale},200)},[]);u(()=>{return bO()},[]),u(()=>{let R=null,p=()=>{if(R!==null)window.clearTimeout(R);R=window.setTimeout(()=>{R=null,l0()},400)};return window.addEventListener("resize",p),()=>{if(R!==null)window.clearTimeout(R);window.removeEventListener("resize",p)}},[]),u(()=>{let R=(T)=>{let r=(T.metaKey||T.ctrlKey)&&!T.altKey;if(r&&T.key==="k"){T.preventDefault(),z((o)=>!o);return}if(T.key==="Escape"&&O){T.preventDefault(),Y(null);return}if(T.key==="Escape"&&n$.value&&!H4.value){T.preventDefault(),m1();return}if(T.key==="Escape"&&_){T.preventDefault(),z(!1);return}if(T.key==="Escape"&&K){T.preventDefault(),W(!1);return}let t=T.target,i=t?.tagName;if(i==="INPUT"||i==="TEXTAREA"||t?.isContentEditable)return;if(T.key===" "&&!T.repeat&&!r){T.preventDefault(),d0.value=!0;return}if(T.key==="?"||T.key==="/"&&T.shiftKey){T.preventDefault(),W((o)=>!o);return}if(r&&(T.key==="z"||T.key==="Z"))T.preventDefault(),KO(T.shiftKey);else if(r&&(T.key==="y"||T.key==="Y"))T.preventDefault(),KO(!0);else if(r&&T.key==="0")T.preventDefault(),U1({x:0,y:0,scale:1},250);else if(r&&(T.key==="="||T.key==="+"))T.preventDefault(),gU(1.25);else if(r&&T.key==="-")T.preventDefault(),gU(0.8);else if(T.key==="Escape"){if(I$.value.size>0||C4.value!==null){I6();return}C$.value=null,F()}else if(T.key==="Tab")T.preventDefault(),XZ(T.shiftKey?-1:1);else if(T.key==="Delete"||T.key==="Backspace"){if(C4.value!==null){let z$=C4.value;T.preventDefault(),C4.value=null,p2(z$).catch((B$)=>JU("delete-edge",B$));return}let o=I$.value.size>0?[...I$.value]:C$.value?[C$.value]:[];if(o.length===0)return;T.preventDefault();for(let z$ of o)h6(z$),n4(z$).catch((B$)=>JU("delete",B$));I6(),C$.value=null}else if(C$.value&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(T.key)){T.preventDefault();let o=T.key.replace("Arrow","").toLowerCase();HZ(o)}else if(!r&&!T.altKey){let o=T.key.toLowerCase();if(o==="v"&&!T.shiftKey)R6.value="select";else if(o==="c"&&!T.shiftKey&&!r)T.preventDefault(),R6.value=R6.value==="connect"?"select":"connect";else if(o==="m"&&!T.shiftKey)T.preventDefault(),i6({type:"markdown",title:"New note",width:520,height:360}).catch((z$)=>JU("create markdown",z$));else if(o==="a"&&!T.shiftKey)T.preventDefault(),Y((z$)=>z$==="pen"?null:"pen");else if(o==="g"&&!T.shiftKey){T.preventDefault();let z$=Array.from(I$.value);if(z$.length>=2)XU({title:"Group",childIds:z$}).catch((B$)=>JU("group selection",B$)),I6();else i6({type:"group",title:"Group"}).catch((B$)=>JU("create group",B$))}else if(o==="g"&&T.shiftKey){T.preventDefault();for(let z$ of UZ())h6(z$),HU(z$).catch((B$)=>JU("ungroup",B$));I6()}else if(o==="i"&&!T.shiftKey)T.preventDefault(),r4("image");else if(o==="w"&&!T.shiftKey)T.preventDefault(),r4("webpage");else if(o==="h"&&!T.shiftKey)T.preventDefault(),i6({type:"html",title:"HTML surface"}).catch((z$)=>JU("create html",z$));else if(o==="f"&&T.shiftKey)T.preventDefault(),r4("file");else if(o==="f"&&!T.shiftKey){T.preventDefault();let z$=d6();SU(z$.width,z$.height)}}},p=(T)=>{if(T.key===" ")d0.value=!1},l=()=>{d0.value=!1};return document.addEventListener("keydown",R),document.addEventListener("keyup",p),window.addEventListener("blur",l),()=>{document.removeEventListener("keydown",R),document.removeEventListener("keyup",p),window.removeEventListener("blur",l)}},[O,F,_,K]),u(()=>{let R=window.setTimeout(()=>void l0(),250);return()=>window.clearTimeout(R)},[H]),u(()=>{if(!k)return;let R=window.__pmxCanvasBootstrapReady;if(typeof R==="function")R()},[k]);let I=Array.from(D.value.values()),N=d6();return G("div",{class:"app-shell","data-session-active":H?"true":"false",children:[G(yQ,{minimapVisible:$,onToggleMinimap:P,snapshotOpen:v,onToggleSnapshot:b,snapshotBtnRef:Z,onOpenPalette:()=>z(!0),onOpenShortcuts:()=>W((R)=>!R),annotationTool:O,onSetAnnotationTool:E},void 0,!1,void 0,this),G("div",{class:"app-main",children:[G(eQ,{},void 0,!1,void 0,this),G(MQ,{},void 0,!1,void 0,this),G("div",{class:"canvas-region",ref:(R)=>BY(R),children:[G(kQ,{onNodeContextMenu:X,onCanvasContextMenu:B,onEdgeContextMenu:L,annotationMode:O!==null,annotationTool:O},void 0,!1,void 0,this),G(qY,{},void 0,!1,void 0,this),G(ZY,{},void 0,!1,void 0,this),G(jQ,{},void 0,!1,void 0,this),G(VQ,{},void 0,!1,void 0,this),k&&I.length===0&&s$.value.size===0&&G(CQ,{onOpenPalette:()=>z(!0)},void 0,!1,void 0,this),I$.value.size>0&&G(rQ,{},void 0,!1,void 0,this),H?G(bQ,{},void 0,!1,void 0,this):j$.value.size>0&&G(TQ,{},void 0,!1,void 0,this),G(dQ,{onOpenSnapshots:()=>J(!0)},void 0,!1,void 0,this),G(QY,{},void 0,!1,void 0,this),n$.value&&G(mQ,{},void 0,!1,void 0,this),G(sQ,{open:v,onClose:V,anchorRef:Z},void 0,!1,void 0,this),$&&G(lQ,{viewport:G$,nodes:D,edges:c$,onNavigate:A,containerWidth:N.width,containerHeight:N.height},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H&&G(oQ,{},void 0,!1,void 0,this),q&&G(SQ,{menu:q,onClose:F},void 0,!1,void 0,this),_&&G(gQ,{onClose:()=>z(!1),onToggleMinimap:P},void 0,!1,void 0,this),K&&G(nQ,{onClose:()=>W(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}FZ();var BL=document.getElementById("app");if(BL)xO(G(qL,{},void 0,!1,void 0,this),BL);
|
|
313
|
+
</script>`}function Yy(){return"<style data-pmx-canvas-ext-app-base>html, body { background: transparent !important; }</style>"}function Qy(e,t){if(!t)return e;let n=/<head\b[^>]*>/i.exec(e);if(n?.index!==void 0){let r=n.index+n[0].length;return`${e.slice(0,r)}${t}${e.slice(r)}`}let o=/<body\b[^>]*>/i.exec(e);if(o?.index!==void 0){let r=o.index+o[0].length;return`${e.slice(0,r)}${t}${e.slice(r)}`}return`${t}${e}`}function hr(e,t){if(Number.isFinite(e)&&e>0)return Math.round(e);if(Number.isFinite(t)&&t>0)return Math.round(t);return 1}function qu(e,t){let n=e?.getBoundingClientRect();return{width:hr(e?.clientWidth??0,hr(n?.width??0,t.width)),height:hr(e?.clientHeight??0,hr(n?.height??0,t.height))}}function VT(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>0&&!t}function GT(e,t){return Math.max(hr(e,1),hr(t,1))}function tx({node:e,expanded:t=!1}){let n=N(null),o=N(null),r=N(null),s=N(null),a=N({}),c=N(void 0),l=N(!1),u=N(void 0),d=N(null),p=N(!1),m=N(null),f=N(0),y=N([]),v=N(""),x=N(!1),h=N(!1),g=N([]),b=N(!1),O=N(!1),F=N(!1),_=N(!1),[k,T]=L("loading"),[P,Z]=L(null),[j,I]=L(0),[H,U]=L(!1),[B,q]=L(!1),[Y,be]=L(()=>t||typeof navigator>"u"||typeof window>"u"||!_o(navigator.userAgent)),Me=e.data.html,Pt=e.data.serverName,ce=e.data.appSessionId,Qn=e.data.toolInput??{},qt=e.data.toolResult,Vt=e.data.toolName??"ext-app",E=e.data.toolDefinition,G=e.data.toolCallId,le=typeof G==="string"||typeof G==="number"?G:void 0,te=e.data.resourceMeta,X=e.data.sessionStatus,ee=e.data.sessionError,Q=e.size.height,W=e.id,se=HT(e,j),pt=UT(null),Gt=e.data.axCapabilities?.enabled===!0&&typeof Me==="string"&&Me.length>0,z=Ie(()=>`ax-${crypto.randomUUID()}`,[]),de=Gt?WT(z,W):"",Oe=typeof Me==="string"&&Me.length>0?qT(z,W):"",me=qy(Qy(Me??"",Yy()+Oe+de),pt);D(()=>{function K(ne){if(ne.source!==n.current?.contentWindow)return;let he=ne.data;if(!he||he.source!==Os||he.token!==z||he.nodeId!==W)return;if(h.current=!0,he.kind==="paint-tick"){let Pe=he,Nt={content:Pe.content===!0,detail:typeof Pe.detail==="string"?Pe.detail:""};for(let Cn of y.current.splice(0))Cn(Nt)}}return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[z,W]),D(()=>{if(Y)return;Ky({remount:()=>{if(_.current)return!1;return tt(W,"mount-slot"),be(!0),!0},awaitBoot:()=>new Promise((K)=>{let ne=window.setTimeout(he,Vy);function he(){window.clearTimeout(ne),K()}g.current.push(he)})})},[]),mr({enabled:Gt,token:z,nodeId:W,sourceSurface:"mcp-app",iframeRef:n});let eo=3,to=(K)=>{if(f.current>=eo)return tt(W,`remount-cap-hit (${K})`),!1;if(b.current)return!0;return f.current+=1,b.current=!0,tt(W,`remount-queued #${f.current} (${K})`),Ky({remount:()=>{if(b.current=!1,_.current||!t&&Be.value===W)return tt(W,"remount-skipped"),U(!1),!1;return O.current=typeof document<"u"&&document.visibilityState==="hidden",tt(W,`remount-run #${f.current}`),T("loading"),I((ne)=>ne+1),!0},awaitBoot:()=>new Promise((ne)=>{let he=window.setTimeout(Pe,Vy);function Pe(){window.clearTimeout(he),ne()}g.current.push(Pe)})}),!0},Sn=1500,Xt=()=>new Promise((K)=>{let ne=n.current?.contentWindow;if(!ne||_.current){K("timeout");return}let he=!1,Pe=window.setTimeout(()=>{if(he)return;he=!0,K("timeout")},Sn);y.current.push((Nt)=>{if(he)return;he=!0,window.clearTimeout(Pe),v.current=Nt.detail,K(Nt.content?"content-verified":"tick-no-content")}),ne.postMessage({source:wl,token:z},"*")}),Fd=async(K)=>{let ne=Date.now()+K;while(Date.now()<ne&&!_.current){if(await Xt()==="content-verified")return!0;await new Promise((he)=>window.setTimeout(he,400))}return!1},Pw=()=>new Promise((K)=>{let ne=n.current;if(!ne){K();return}let he=ne.style.width,Pe=ne.style.height;ne.style.width="140%",ne.style.height="140%",requestAnimationFrame(()=>{requestAnimationFrame(()=>{ne.style.width=he,ne.style.height=Pe,tt(W,"soft-expand-cycle"),K()})})}),Nw=600,Ni=()=>{if(typeof document>"u"||typeof navigator>"u"||typeof window>"u")return;let K=n.current;if(!K||_.current)return;if(!jT({userAgent:navigator.userAgent,visibilityState:document.visibilityState,rect:K.getBoundingClientRect(),viewport:{width:window.innerWidth,height:window.innerHeight},alreadyRearmed:F.current}))return;F.current=!0,window.setTimeout(()=>{if(_.current||document.visibilityState==="visible")return;f.current=0,q(!1),O.current=!1,tt(W,"assume-visible-rearm"),to("assume-visible")},Nw)},mc=(K="")=>{let ne=v.current?` [${v.current}]`:"";return typeof document<"u"&&document.visibilityState==="hidden"?`paint-ok (content-verified)${ne}${K} (host hidden)`:`paint-ok (content-verified)${ne}${K}`},Rw=async()=>{if(typeof navigator>"u"||typeof window>"u")return;if(!_o(navigator.userAgent))return;U(!0);let K=await Xt();if(K==="content-verified"){tt(W,mc()),U(!1),Ni();return}if(tt(W,K==="tick-no-content"?`paint-fail (tick without content: ${v.current||"unknown"})`:"paint-fail (no tick)"),await Pw(),K=await Xt(),K==="content-verified"){tt(W,mc(" (after soft-expand)")),U(!1),Ni();return}if(_.current)return;if(K==="tick-no-content"&&await Fd(3000)){tt(W,mc(" (after content wait)")),U(!1),Ni();return}if(_.current)return;if(!to("paint-fail"))tt(W,"recovery-exhausted"),U(!1),q(!0),Ni()};D(()=>{if(t)return;if(typeof document>"u"||typeof navigator>"u"||typeof window>"u")return;if(!_o(navigator.userAgent))return;function K(){if(document.visibilityState!=="visible")return;if(!O.current||_.current)return;O.current=!1,f.current=0,q(!1),tt(W,"visible-again-rearm"),to("visible-after-hidden-boot")}return document.addEventListener("visibilitychange",K),()=>document.removeEventListener("visibilitychange",K)},[t,W]);let $w=6000;D(()=>{if(typeof navigator>"u"||typeof window>"u")return;if(!_o(navigator.userAgent))return;if(!me.ready||!Y)return;let K=window.setTimeout(()=>{if(x.current||h.current||_.current)return;to("boot-watchdog")},$w);return()=>window.clearTimeout(K)},[se,me.ready,t,Y]),D(()=>()=>{_.current=!0;for(let K of g.current.splice(0))K();for(let K of y.current.splice(0))K({content:!1,detail:"unmounted"})},[]);let hc=(K)=>ar(K),kn=t||Be.value===W;a.current=Qn,c.current=qt;let Ri=X==="error"&&typeof Me==="string"&&Me.length>0,gc=X==="error"?Ri?`Live session unavailable — showing saved content. Reopen the app to restore interactivity.${ee?` (${ee})`:""}`:ee??"Saved app session is unavailable. Reopen the app to restore interactivity.":"Reconnecting saved app session...",vc=(K)=>{let ne=c.current;if(!K||!p.current||!ne)return null;if(u.current===ne)return null;if(u.current&&Uy(u.current,ne))return u.current=ne,null;if(d.current)return d.current;let he=K.sendToolResult(ne).then(()=>{u.current=ne,l.current=!0,T("done")}).catch((Pe)=>{let Nt=Pe instanceof Error?Pe.message:String(Pe);throw Z(`Tool result delivery failed: ${Nt}`),Pe}).finally(()=>{d.current=null});return d.current=he,he};if(D(()=>{if(!Me||!me.ready||!Y)return;let K=n.current;if(!K)return;let ne=!1,he=null,Pe=null,Nt=null,Cn=null,no=null;l.current=!1,u.current=void 0,d.current=null,p.current=!1,x.current=!1,h.current=!1;let $i=()=>{if(!he)return;clearTimeout(he),he=null};return(async()=>{if(!Me)return;let Tn=K.contentWindow;if(!Tn)throw Error("Ext-app iframe window is unavailable");let oo=(pe=Be.value===W?"fullscreen":"inline")=>({theme:hc(Ge.value),platform:"web",containerDimensions:qu(K,{width:e.size.width,height:Q}),displayMode:pe,locale:navigator.language,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,...E?{toolInfo:{id:le,tool:E}}:{}}),Mw=()=>{if(Cn!==null)return;Cn=requestAnimationFrame(()=>{if(Cn=null,ne||!p.current)return;Ne.setHostContext?.(oo())})},jd=()=>{if(no!==null)return;no=requestAnimationFrame(()=>{no=requestAnimationFrame(()=>{if(no=null,ne||!p.current)return;Ne.sendHostContextChange?.(oo())})})},Zd=()=>{if(!_o(navigator.userAgent))return;if(Pe)clearTimeout(Pe);Pe=setTimeout(()=>{if(Pe=null,ne)return;Rw()},ex+200)},Ne=new Hu(null,{name:"PMX Canvas",version:"1.0.0"},{openLinks:{},serverTools:{listChanged:!1},serverResources:{listChanged:!1},logging:{},updateModelContext:{text:{},structuredContent:{}}},{hostContext:oo(kn?"fullscreen":"inline")});Ne.onsizechange=async({height:pe})=>{if(VT(pe,Be.value===W)){let Ye=qu(K.parentElement??K,{width:e.size.width,height:Q}),Rt=GT(pe,Ye.height);K.style.height=`${Rt}px`;let ro=R.value.get(W)?.size??e.size,Bd=Math.max(ro.height,Rt+or);if(Math.abs(Bd-ro.height)>8){if(Jo(W,{width:ro.width,height:Bd}),s.current!==null)window.clearTimeout(s.current);s.current=window.setTimeout(()=>{Je({recordHistory:!1}),s.current=null},0)}}return{}},Ne.onopenlink=async({url:pe})=>(window.open(pe,"_blank","noopener"),{}),Ne.onsandboxready=async()=>{await Ne.sendSandboxResourceReady({html:Qy(Me,Yy()),sandbox:_l,...te?.csp?{csp:te.csp}:{},...te?.permissions?{permissions:te.permissions}:{}})},Ne.onrequestdisplaymode=async({mode:pe})=>{let{nextMode:Ye,shouldExpand:Rt,shouldCollapse:ro}=BT(pe,kn);if(Rt)Qt(W);else if(ro)fo();return{mode:Ye}},Ne.oncalltool=async(pe)=>{if(!ce)throw Error(gc);try{let Ye=await wo("/api/ext-app/call-tool",{sessionId:ce,nodeId:W,serverName:Pt,toolName:pe.name,arguments:pe.arguments??{}});return Z(null),Ye}catch(Ye){let Rt=Ye instanceof Error?Ye.message:String(Ye);throw Z(`Tool call failed: ${Rt}`),Ye}},Ne.setRequestHandler(wa,async()=>{if(!ce)return{tools:[]};return wo("/api/ext-app/list-tools",{sessionId:ce})}),Ne.onlistresources=async()=>ce?wo("/api/ext-app/list-resources",{sessionId:ce}):{resources:[]},Ne.onlistresourcetemplates=async()=>ce?wo("/api/ext-app/list-resource-templates",{sessionId:ce}):{resourceTemplates:[]},Ne.onreadresource=async(pe)=>{if(!ce)throw Error(gc);return wo("/api/ext-app/read-resource",{sessionId:ce,uri:pe.uri})},Ne.onlistprompts=async()=>ce?wo("/api/ext-app/list-prompts",{sessionId:ce}):{prompts:[]},Ne.onupdatemodelcontext=async(pe)=>{if(!ce)return{};return await wo("/api/ext-app/model-context",{nodeId:W,...Array.isArray(pe.content)?{content:pe.content}:{},...pe.structuredContent&&typeof pe.structuredContent==="object"?{structuredContent:pe.structuredContent}:{}}),{}};let yc=new Zu(Tn,Tn);if(Ne.oninitialized=()=>{if(ne)return;$i(),p.current=!0,x.current=!0,tt(W,"initialized"),T("ready"),Z(null),Promise.resolve(Ne.sendHostContextChange(oo(kn?"fullscreen":"inline"))).then(()=>Jy(Ne,a.current,void 0)).then(()=>vc(Ne)).then(()=>{let pe=()=>{for(let Ye of g.current.splice(0))Ye()};if(typeof navigator<"u"&&_o(navigator.userAgent))Fd(4000).then((Ye)=>{tt(W,Ye?"settled (content-verified)":`settled (content-timeout${v.current?`: ${v.current}`:""})`),pe()});else tt(W,"settled"),pe();jd(),Zd()}).catch((pe)=>{let Ye=pe instanceof Error?pe.message:String(pe);Z(`Bridge bootstrap failed: ${Ye}`)})},he=setTimeout(()=>{if(ne||p.current)return;let pe=c.current,Ye=oo(kn?"fullscreen":"inline");p.current=!0,Ne.setHostContext?.(Ye),Promise.resolve(Ne.sendHostContextChange(Ye)).then(()=>Jy(Ne,a.current,pe)).then(()=>{if(l.current=Boolean(pe),pe)u.current=pe;if(T(pe?"done":"ready"),Z(null),jd(),Zd(),h.current){tt(W,"settled (fallback)");for(let Rt of g.current.splice(0))Rt()}}).catch((Rt)=>{let ro=Rt instanceof Error?Rt.message:String(Rt);Z(`Bridge bootstrap fallback failed: ${ro}`)})},1200),await Ne.connect(yc),ne){$i(),await yc.close();return}if(o.current=Ne,r.current=yc,Nt=new ResizeObserver(Mw),Nt.observe(K),K.parentElement)Nt.observe(K.parentElement);let Hd=!0;m.current=Ge.subscribe((pe)=>{if(Hd){Hd=!1;return}if(ne)return;Ne.setHostContext?.({...oo(),theme:hc(pe)}),Ne.sendHostContextChange?.(oo())}),vc(Ne)})().catch((Tn)=>{$i(),console.error("[ext-app] Bridge init failed:",Tn),Z(Tn?.message??"Bridge initialization failed")}),()=>{if(ne=!0,$i(),Pe)clearTimeout(Pe),Pe=null;if(Nt?.disconnect(),Nt=null,Cn!==null)cancelAnimationFrame(Cn),Cn=null;if(no!==null)cancelAnimationFrame(no),no=null;if(p.current=!1,d.current=null,m.current?.(),m.current=null,s.current!==null)window.clearTimeout(s.current),s.current=null;if(o.current=null,r.current)r.current.close().catch((Tn)=>{console.error("[ext-app] transport close failed:",Tn)}),r.current=null}},[se,me.key,Y]),D(()=>{if(qt&&o.current&&(k==="ready"||k==="done"))vc(o.current)},[qt,k]),D(()=>{let K=o.current;if(n.current)n.current.style.height="100%";if(!K||!p.current)return;let ne=null,he=null;return ne=requestAnimationFrame(()=>{ne=null,he=requestAnimationFrame(()=>{if(he=null,!p.current)return;let Pe={theme:hc(Ge.value),platform:"web",containerDimensions:qu(n.current,{width:e.size.width,height:Q}),displayMode:kn?"fullscreen":"inline",locale:navigator.language,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};K.setHostContext?.(Pe),K.sendHostContextChange?.(Pe)})}),()=>{if(ne!==null)cancelAnimationFrame(ne);if(he!==null)cancelAnimationFrame(he)}},[kn,Q]),!Me)return i("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--c-muted)",fontSize:"13px",flexDirection:"column",gap:"8px"},children:[i("div",{style:{opacity:0.6},children:["Loading ",Vt," viewer..."]},void 0,!0,void 0,this),i("div",{style:{width:"24px",height:"24px",border:"2px solid var(--c-line)",borderTopColor:"var(--c-muted)",borderRadius:"50%",animation:"spin 1s linear infinite"}},void 0,!1,void 0,this),i("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("div",{style:{flex:1,width:"100%",height:"100%",minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[X&&X!=="ready"&&i("div",{style:{padding:"6px 10px",fontSize:"11px",background:X==="error"&&!Ri?"var(--c-danger-12)":"var(--c-warn-10)",color:X==="error"&&!Ri?"var(--c-danger)":"var(--c-warn)",borderBottom:`1px solid ${X==="error"&&!Ri?"var(--c-danger-12)":"var(--c-warn-15)"}`},children:gc},void 0,!1,void 0,this),P&&i("div",{style:{padding:"6px 10px",fontSize:"11px",background:"var(--c-danger-12)",color:"var(--c-danger)",borderBottom:"1px solid var(--c-danger-12)",display:"flex",alignItems:"center",gap:"6px"},children:[i("span",{children:"⚠"},void 0,!1,void 0,this),i("span",{style:{flex:1},children:P},void 0,!1,void 0,this),i("button",{type:"button",onClick:()=>{Z(null),T("loading"),I((K)=>K+1)},style:{background:"var(--c-surface-hover)",border:"1px solid var(--c-danger-12)",borderRadius:"3px",color:"var(--c-danger)",cursor:"pointer",fontSize:"10px",padding:"1px 6px"},children:"Retry"},void 0,!1,void 0,this),i("button",{type:"button",onClick:()=>Z(null),style:{background:"none",border:"none",color:"var(--c-danger)",cursor:"pointer",fontSize:"13px",padding:"0 2px"},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{style:{flex:1,position:"relative",display:"flex",minHeight:0,height:"100%"},children:[Y&&i("iframe",{ref:n,...me.attributes,sandbox:pt,allow:By(te?.permissions),style:{flex:1,width:"100%",height:"100%",minHeight:0,border:"none",background:"var(--c-panel)",pointerEvents:kn&&k!=="loading"?"auto":"none"},title:`Ext App: ${Vt}`},se,!1,void 0,this),B&&!P&&i("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",background:"var(--c-panel)",color:"var(--c-warn)",fontSize:"12px"},children:[i("div",{children:"App surface failed to paint."},void 0,!1,void 0,this),i("button",{type:"button",onClick:(K)=>{K.stopPropagation(),tt(W,"manual-retry"),f.current=0,q(!1),T("loading"),I((ne)=>ne+1)},style:{background:"var(--c-surface-hover)",border:"1px solid var(--c-warn-15)",borderRadius:"4px",color:"var(--c-warn)",cursor:"pointer",fontSize:"11px",padding:"3px 10px"},children:"Retry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(k==="loading"||H)&&!P&&!B&&i("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"10px",background:"var(--c-panel)",color:"var(--c-muted)",fontSize:"12px",pointerEvents:"none"},children:[i("div",{style:{width:"22px",height:"22px",border:"2px solid var(--c-line)",borderTopColor:"var(--c-muted)",borderRadius:"50%",animation:"spin 1s linear infinite"}},void 0,!1,void 0,this),i("div",{children:k==="loading"?`Connecting to ${Vt}...`:"Finishing paint..."},void 0,!1,void 0,this),i("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!kn&&!(B&&!P)&&i("button",{type:"button",onClick:(K)=>{K.stopPropagation(),Qt(W)},class:"ext-app-preview-catcher",title:"Click to open",style:{position:"absolute",top:0,right:"56px",bottom:"56px",left:0,background:"transparent",border:"none",padding:0,margin:0,cursor:"zoom-in"},"aria-label":"Open full view to edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function XT(e,t,n,o,r,s,a){if(!e)return e;try{let c=new URL(e,window.location.origin);if(c.searchParams.set("theme",ar(Ge.value)),t)c.searchParams.set("display","expanded");if(typeof n==="number")c.searchParams.set("v",String(n));if(o)c.searchParams.set("axToken",o);if(r)c.searchParams.set("axNodeId",r);if(s)c.searchParams.set("frameToken",s);if(a)c.searchParams.set("fit","content");return c.toString()}catch{return e}}function KT(e,t=window.location.origin){if(!e)return!1;try{let n=new URL(t).origin,o=new URL(e,n);return o.origin===n&&o.pathname.startsWith("/api/canvas/frame-documents/")}catch{return!1}}function Hn({node:e,expanded:t=!1}){if(e.data.mode==="ext-app")return i(tx,{node:e,expanded:t},void 0,!1,void 0,this);return i(JT,{node:e,expanded:t},void 0,!1,void 0,this)}function JT({node:e,expanded:t}){let n=N(null),o=e.type==="mcp-app"&&e.data.viewerType==="web-artifact",r=e.type==="json-render"||e.type==="graph",s=e.data.axCapabilities?.enabled,c=(r||o)&&(o?s===!0:s!==!1),l=o?"mcp-app":"json-render",u=Ie(()=>c?`ax-${crypto.randomUUID()}`:"",[c]),d=kl(e)&&!t,p=Ie(()=>d?`frame-${crypto.randomUUID()}`:"",[d]);rr(e,n,p),mr({enabled:c&&Boolean(u),token:u,nodeId:e.id,sourceSurface:l,iframeRef:n});let m=Wt.value,f=()=>{if(!c||!u||m==null)return;n.current?.contentWindow?.postMessage({source:Ot,type:"ax-update",token:u,state:m},"*")};D(f,[c,u,m]);let y=typeof e.data.specVersion==="number"?e.data.specVersion:void 0,v=XT(e.data.url||"",t,y,u||void 0,c?e.id:void 0,p||void 0,d),x=ir(v),h=e.data.sourceServer||"",g=e.data.hostMode||"hosted",b=e.data.fallbackReason,O=e.data.trustedDomain===!0||KT(v);if(g==="fallback")return i("div",{style:{display:"flex",flexDirection:"column",gap:"8px",fontSize:"12px"},children:[i("div",{style:{color:"var(--c-warn)",display:"flex",alignItems:"center",gap:"6px"},children:[i("span",{children:"⚠"},void 0,!1,void 0,this),i("span",{children:"Cannot embed — opened externally"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&i("div",{style:{color:"var(--c-muted)",fontSize:"11px"},children:["Reason: ",b]},void 0,!0,void 0,this),i("a",{href:v,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--c-accent)",fontSize:"12px",wordBreak:"break-all"},children:v},void 0,!1,void 0,this),h&&i("div",{style:{color:"var(--c-dim)",fontSize:"10px"},children:["Source: ",h]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);return i("div",{style:{height:"100%",display:"flex",flexDirection:"column",...t?{flex:1,minHeight:0,width:"100%"}:{}},children:[!O&&i("div",{style:{padding:"4px 8px",fontSize:"10px",background:"var(--c-warn-10)",color:"var(--c-warn)",borderBottom:"1px solid var(--c-warn-15)"},children:"Unverified domain"},void 0,!1,void 0,this),i("iframe",{ref:n,...x,class:"mcp-app-frame",sandbox:"allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",allow:"clipboard-read; clipboard-write",loading:ht.value==="srcdoc"?void 0:"lazy",onLoad:f,style:{flex:1,minHeight:0,width:"100%"},title:`MCP App: ${h}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var YT=null;function gr(){YT=null}var nx={idle:"var(--c-muted)",running:"var(--c-accent)",planning:"var(--c-thinking)",thinking:"var(--c-thinking)",drafting:"var(--c-accent)",tooling:"var(--c-accent)",review:"var(--c-ok)","waiting-approval":"var(--c-warn)",waiting:"var(--c-warn-alt)"};function QT(e){let t=typeof e.data.phase==="string"&&e.data.phase.trim().length>0?e.data.phase.trim():"";if(t)return t;let n=typeof e.data.content==="string"&&e.data.content.trim().length>0?e.data.content.trim():"";if(n)return n;return(typeof e.data.status==="string"&&e.data.status.trim().length>0?e.data.status.trim():"")||"idle"}function Ta({node:e}){let t=QT(e),n=e.data.detail||"",o=e.data.message||"",r=e.data.level||"ok",s=e.data.activeTool,a=e.data.subagent,c=nx[t]??"var(--c-muted)",l=t!=="idle";return i("div",{style:{display:"flex",flexDirection:"column",gap:"8px",fontSize:"12px"},children:[i("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:c,boxShadow:l?`0 0 8px ${c}`:"none",animation:l?"pulse 1.5s infinite":"none",flexShrink:0}},void 0,!1,void 0,this),i("span",{style:{fontWeight:600,color:c,textTransform:"uppercase",letterSpacing:"0.05em"},children:t},void 0,!1,void 0,this),n&&i("span",{style:{color:"var(--c-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&i("div",{style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--c-warn)"},children:[i("span",{style:{fontSize:"10px"},children:"⚙"},void 0,!1,void 0,this),i("span",{style:{fontFamily:"var(--mono)",fontSize:"11px"},children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&a.state!=="completed"&&i("div",{style:{display:"flex",alignItems:"center",gap:"6px",color:"var(--c-subagent)"},children:[i("span",{style:{fontSize:"10px"},children:"⠉"},void 0,!1,void 0,this),i("span",{children:a.name},void 0,!1,void 0,this),i("span",{style:{color:"var(--c-muted)",fontSize:"10px"},children:["(",a.state,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),o&&i("div",{style:{color:r==="warn"?"var(--c-warn)":r==="error"?"var(--c-danger)":"var(--c-muted)",lineHeight:1.4},children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vr(e){return typeof e==="string"&&e.trim().length>0?e.trim():null}function ox(e){if(typeof e==="string"){let r=vr(e);return r?{title:"Evidence warning",detail:r}:null}if(!e||typeof e!=="object")return null;let t=e,n=vr(t.title)??"Evidence warning",o=vr(t.detail);return o?{title:n,detail:o}:null}function eE(e){let t=[],n=ox(e.data.warning);if(n)t.push(n);let o=e.data.warnings;if(Array.isArray(o))for(let s of o){let a=ox(s);if(a)t.push(a)}let r=vr(e.data.validationStatus)?.toLowerCase();if(r==="failed"||r==="invalid")t.push({title:"Image failed validation",detail:vr(e.data.validationMessage)??"Review this image before using it as evidence."});return t}function tE(e){let t=[e.data.title,e.data.caption,e.data.alt,e.data.src,e.data.path].map((n)=>vr(n)?.toLowerCase()??"").join(" ");if(t.length===0)return!1;return["login","log in","sign in","signin","password","2fa","mfa","authenticate","authentication","sso"].some((n)=>t.includes(n))}function rx(e){let t=eE(e);if(t.length>0)return t;if(tE(e))return[{title:"Captured login page",detail:"This image looks like an auth screen. Treat it as environment context, not product evidence."}];return[]}function Ea({node:e,expanded:t=!1}){let n=e.data.src||"",o=e.data.alt||e.data.title||"Image",r=e.data.caption||"",s=rx(e),a=n.startsWith("data:")||n.startsWith("http://")||n.startsWith("https://")?n:`/api/canvas/image/${e.id}`,[c,l]=L(!1),[u,d]=L(!1),[p,m]=L(1),[f,y]=L({x:0,y:0}),[v,x]=L({w:0,h:0}),h=N(null),g=N(!1),b=N({x:0,y:0}),O=M((H)=>{let U=H.target;x({w:U.naturalWidth,h:U.naturalHeight}),l(!0),d(!1)},[]),F=M(()=>{d(!0),l(!1)},[]);D(()=>{m(1),y({x:0,y:0})},[n]);let _=M((H)=>{H.preventDefault(),H.stopPropagation();let U=H.deltaY>0?0.9:1.1;m((B)=>Math.max(0.25,Math.min(10,B*U)))},[]),k=M((H)=>{if(p<=1)return;H.stopPropagation(),g.current=!0,b.current={x:H.clientX,y:H.clientY},H.target.setPointerCapture(H.pointerId)},[p]),T=M((H)=>{if(!g.current)return;let U=H.clientX-b.current.x,B=H.clientY-b.current.y;b.current={x:H.clientX,y:H.clientY},y((q)=>({x:q.x+U,y:q.y+B}))},[]),P=M(()=>{g.current=!1},[]),Z=M(()=>{m(1),y({x:0,y:0})},[]);if(!n)return i("div",{class:"image-node-empty",children:[i("div",{class:"image-node-empty-icon",children:"\uD83D\uDDBC"},void 0,!1,void 0,this),i("div",{class:"image-node-empty-text",children:"No image source"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let j=v.w>0?`${v.w}×${v.h}`:"",I=Math.round(p*100);return i("div",{class:`image-node ${t?"image-node-expanded":""}`,ref:h,children:[s.length>0&&i("div",{class:"image-node-warning-stack",children:s.map((H)=>i("div",{class:"image-node-warning",children:[i("span",{class:"image-node-warning-title",children:H.title},void 0,!1,void 0,this),i("span",{class:"image-node-warning-detail",children:H.detail},void 0,!1,void 0,this)]},`${H.title}-${H.detail}`,!0,void 0,this))},void 0,!1,void 0,this),i("div",{class:"image-node-viewport",onWheel:_,onPointerDown:k,onPointerMove:T,onPointerUp:P,style:{cursor:p>1?"grab":"default"},children:[!c&&!u&&i("div",{class:"image-node-loading",children:"Loading…"},void 0,!1,void 0,this),u&&i("div",{class:"image-node-error",children:[i("div",{class:"image-node-error-icon",children:"⚠"},void 0,!1,void 0,this),i("div",{children:"Failed to load image"},void 0,!1,void 0,this),i("div",{class:"image-node-error-path",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("img",{src:a,alt:o,onLoad:O,onError:F,draggable:!1,style:{transform:`translate(${f.x}px, ${f.y}px) scale(${p})`,opacity:c?1:0,display:u?"none":"block"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(r||j||p!==1)&&i("div",{class:"image-node-footer",children:[r&&i("span",{class:"image-node-caption",children:r},void 0,!1,void 0,this),i("span",{class:"image-node-meta",children:[j&&i("span",{children:j},void 0,!1,void 0,this),p!==1&&i("button",{type:"button",class:"image-node-zoom-reset",onClick:Z,title:"Reset zoom",children:[I,"% ↺"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function ix({node:e}){if((e.data.children??[]).filter((o)=>R.value.has(o)).length>0)return null;return i("div",{class:"group-empty-hint",children:"Drop nodes here — release while the frame lights up to add them"},void 0,!1,void 0,this)}function nE(e){try{return new URL(e).host}catch{return e}}function oE(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString()}function Aa({node:e,expanded:t=!1}){let n=typeof e.data.url==="string"?e.data.url:"",o=typeof e.data.pageTitle==="string"?e.data.pageTitle:"",r=typeof e.data.description==="string"?e.data.description:"",s=typeof e.data.excerpt==="string"?e.data.excerpt:typeof e.data.content==="string"?e.data.content:"",a=typeof e.data.status==="string"?e.data.status:"idle",c=typeof e.data.error==="string"?e.data.error:"",l=oE(typeof e.data.fetchedAt==="string"?e.data.fetchedAt:void 0),u=typeof e.data.statusCode==="number"?e.data.statusCode:null,d=typeof e.data.imageUrl==="string"?e.data.imageUrl:"",p=e.data.frameBlocked===!0,m=typeof e.data.frameBlockedReason==="string"?e.data.frameBlockedReason:"",[f,y]=L(!1),[v,x]=L(t);D(()=>{if(t)x(!0)},[t]);let h=M(async()=>{if(!n||f)return;y(!0);try{await ss(e.id)}finally{y(!1)}},[e.id,f,n]);if(!n)return i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No webpage URL set"},void 0,!1,void 0,this);let g=a==="ready"?"var(--c-ok)":a==="error"?"var(--c-danger)":"var(--c-warn)";return i("div",{style:{display:"flex",flexDirection:"column",gap:"12px",height:"100%"},children:[i("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[i("div",{style:{minWidth:0,flex:1},children:[i("div",{style:{fontSize:"12px",color:"var(--c-muted)"},children:nE(n)},void 0,!1,void 0,this),i("div",{style:{fontSize:t?"18px":"15px",fontWeight:700,color:"var(--c-text)"},children:o||e.data.title||n},void 0,!1,void 0,this),i("a",{href:n,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--c-accent)",fontSize:"12px",wordBreak:"break-all",textDecoration:"none"},children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"999px",background:"rgba(255,255,255,0.04)",color:g,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.04em",flexShrink:0},children:[i("span",{style:{width:"7px",height:"7px",borderRadius:"999px",background:g}},void 0,!1,void 0,this),a]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),(r||d)&&i("div",{style:{display:"grid",gridTemplateColumns:d&&t?"160px 1fr":"1fr",gap:"12px",alignItems:"start"},children:[d&&t&&i("img",{src:d,alt:o||"Webpage preview image",style:{width:"160px",height:"96px",objectFit:"cover",borderRadius:"10px",border:"1px solid var(--c-line)",background:"var(--c-panel-soft)"}},void 0,!1,void 0,this),r&&i("p",{style:{margin:0,color:"var(--c-text-soft)",lineHeight:1.5,fontSize:t?"14px":"12px"},children:r},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[i("button",{type:"button",onClick:h,disabled:f,style:{border:"1px solid var(--c-line)",background:"var(--c-panel-soft)",color:"var(--c-text)",borderRadius:"8px",padding:"6px 10px",cursor:f?"progress":"pointer",fontSize:"12px"},children:f||a==="fetching"?"Refreshing…":"Refresh"},void 0,!1,void 0,this),t&&!p&&i("button",{type:"button",onClick:()=>x((b)=>!b),style:{border:"1px solid var(--c-line)",background:"var(--c-panel-soft)",color:"var(--c-text)",borderRadius:"8px",padding:"6px 10px",cursor:"pointer",fontSize:"12px"},children:v?"Hide live preview":"Show live preview"},void 0,!1,void 0,this),i("button",{type:"button",onClick:()=>window.open(n,"_blank","noopener"),style:{border:"1px solid var(--c-line)",background:"transparent",color:"var(--c-accent)",borderRadius:"8px",padding:"6px 10px",cursor:"pointer",fontSize:"12px"},children:"Open in browser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t&&p&&i("div",{style:{border:"1px solid var(--c-line)",borderRadius:"12px",overflow:"hidden",background:"var(--c-panel-soft)"},children:[i("div",{style:{padding:"8px 12px",fontSize:"11px",color:"var(--c-muted)",borderBottom:"1px solid var(--c-line)",background:"rgba(255,255,255,0.03)"},children:"Live preview unavailable. This site refuses embedding, so PMX Canvas cannot show it inline."},void 0,!1,void 0,this),i("div",{style:{padding:"20px",color:"var(--c-text-soft)",lineHeight:1.6,fontSize:"13px"},children:m||"The remote site blocks iframe embedding."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t&&v&&!p&&i("div",{style:{border:"1px solid var(--c-line)",borderRadius:"12px",overflow:"hidden",background:"var(--c-panel-soft)"},children:[i("div",{style:{padding:"8px 12px",fontSize:"11px",color:"var(--c-muted)",borderBottom:"1px solid var(--c-line)",background:"rgba(255,255,255,0.03)"},children:"Live preview (best effort). If this stays blank, the site likely blocks framing. The cached text snapshot below still works."},void 0,!1,void 0,this),i("iframe",{class:"webpage-node-iframe",title:o||e.data.title||n,src:n,loading:"lazy",referrerPolicy:"no-referrer",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-presentation allow-scripts",style:{display:"block",width:"100%",height:t?"320px":"180px",border:"none",background:"#fff"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),(l||u!==null)&&i("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",color:"var(--c-muted)",fontSize:"11px"},children:[l&&i("span",{children:["Fetched ",l]},void 0,!0,void 0,this),u!==null&&i("span",{children:["HTTP ",u]},void 0,!0,void 0,this),p&&i("span",{children:"Preview blocked by site"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c&&i("div",{style:{color:"var(--c-danger)",fontSize:"12px",lineHeight:1.5},children:c},void 0,!1,void 0,this),i("div",{style:{flex:1,minHeight:0,overflow:"auto",border:"1px solid var(--c-line)",borderRadius:"10px",background:"var(--c-panel-soft)",padding:t?"14px":"10px"},children:s?i("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.55,color:"var(--c-text)",fontSize:t?"14px":"12px"},children:s},void 0,!1,void 0,this):i("div",{style:{color:"var(--c-dim)",fontStyle:"italic"},children:a==="error"?"No cached page text available.":"Waiting for page text..."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sx(e){return e.type==="html"&&e.data.presentation===!0}function xi({node:e,expanded:t=!1,presentation:n=!1,presentationExitToken:o,autoFocus:r=!1}){let s=N(null),a=Ge.value,c=Ie(()=>`theme-${crypto.randomUUID()}`,[]),l=Ie(()=>`ax-${crypto.randomUUID()}`,[]),u=Ie(()=>`frame-${crypto.randomUUID()}`,[]),d=typeof e.data.html==="string"?e.data.html:typeof e.data.content==="string"?e.data.content:"",p=Ie(()=>nr(d),[d]),m=Ie(()=>d?Xr(e.id,{theme:a,themeToken:c,present:n,presentToken:o,v:p,axToken:l,frameToken:u}):"",[d,n,o,c,p,e.id,l,u]),f=ir(m);rr(e,s,t?"":u),mr({enabled:!0,token:l,nodeId:e.id,sourceSurface:"html-node",iframeRef:s}),D(()=>{if(s.current?.contentWindow?.postMessage({source:Ot,type:"theme-update",token:c,theme:a},"*"),r)s.current?.focus()},[a,c]);let y=e.data.axCapabilities,v=y?.enabled===!0&&(!Array.isArray(y.allowed)||y.allowed.length>0),x=Wt.value;D(()=>{if(!v||x==null)return;s.current?.contentWindow?.postMessage({source:Ot,type:"ax-update",token:l,state:x},"*")},[v,x,l]),D(()=>{if(!r)return;let g=window.setTimeout(()=>s.current?.focus(),0);return()=>window.clearTimeout(g)},[r,m]);let h=()=>{if(s.current?.contentWindow?.postMessage({source:Ot,type:"theme-update",token:c,theme:a},"*"),v&&Wt.value!=null)s.current?.contentWindow?.postMessage({source:Ot,type:"ax-update",token:l,state:Wt.value},"*");if(r)s.current?.focus()};if(!d)return i("div",{style:{color:"var(--c-dim)",fontStyle:"italic",padding:"12px"},children:"No HTML content set"},void 0,!1,void 0,this);return i("iframe",{ref:s,class:n?"html-node-frame html-node-frame-presentation":"html-node-frame",title:typeof e.data.title==="string"?e.data.title:"HTML node",sandbox:"allow-scripts",...f,tabIndex:r?0:void 0,onLoad:h,style:{width:"100%",height:"100%",minHeight:n?0:t?"70vh":"300px",border:"none",background:"var(--c-bg)",borderRadius:n?0:"6px",display:"block"}},void 0,!1,void 0,this)}var Vu=null;async function ax(){if(!Vu)Vu=await Dp();return Vu}function cx(e,t){if(!e)return null;let n=e.toLowerCase(),o=t.find((s)=>s.name.toLowerCase()===n);if(o)return o.name;let r=t.filter((s)=>s.name.toLowerCase().startsWith(n));return r.length===1?r[0].name:null}function rE(e){return e.replace(/<script[\s>][\s\S]*?<\/script>/gi,"").replace(/<iframe[\s>][\s\S]*?<\/iframe>/gi,"").replace(/<object[\s>][\s\S]*?<\/object>/gi,"").replace(/<embed[\s>][\s\S]*?(?:\/>|<\/embed>)/gi,"").replace(/<link[\s>][\s\S]*?(?:\/>|<\/link>)/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/href\s*=\s*"javascript:[^"]*"/gi,'href="#"').replace(/href\s*=\s*'javascript:[^']*'/gi,"href='#'")}function iE({html:e}){let t=N(null);return D(()=>{let n=t.current;if(!n)return;if(n.replaceChildren(),!e)return;let o=document.createElement("template");o.innerHTML=e,n.append(o.content.cloneNode(!0))},[e]),i("div",{ref:t},void 0,!1,void 0,this)}function sE(e,t){return`${e.role}:${e.status??"none"}:${t}:${e.text}`}function lx({count:e}){if(e===0)return null;return i("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--c-accent)",background:"rgba(70,182,255,0.08)",borderRadius:"var(--radius-sm)",flexShrink:0},children:["✦"," ",e," context node",e!==1?"s":""," attached"]},void 0,!0,void 0,this)}function ux({message:e,onDismiss:t}){if(!e)return null;return i("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--c-danger)",background:"rgba(255,80,80,0.08)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[i("span",{style:{flex:1},children:e},void 0,!1,void 0,this),i("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:"var(--c-danger)",cursor:"pointer",fontSize:"13px",padding:"0 2px"},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ia({node:e,expanded:t=!1}){let n=Array.isArray(e.data.turns)?e.data.turns:[],o=n.length===0,r=e.data.text||"",s=e.data.status||"draft",a=o?s:e.data.threadStatus||"draft",c=a==="draft",l=a==="pending"||a==="sending",u=a==="streaming",d=a==="answered",[p,m]=L(""),[f,y]=L(""),[v,x]=L(null),[h,g]=L(new Map),b=N(null),O=N(null),F=n[n.length-1],_=`${n.length}:${F?.role??""}:${F?.status??""}:${Math.floor((F?.text?.length??0)/200)}`;D(()=>{if(t&&c&&b.current)b.current.focus()},[t,c]),D(()=>{if(!_)return;if(O.current)O.current.scrollTo({top:O.current.scrollHeight,behavior:"smooth"})},[_]);let k=N(null),T=N(n);T.current=n,D(()=>{let U=n.some((q)=>q.role==="assistant"&&q.status==="streaming"),B=()=>{let q=!1,be=T.current.map((Me,Pt)=>({turn:Me,index:Pt})).filter(({turn:Me})=>Me.role==="assistant"&&Me.text);if(be.length===0)return;return Promise.all(be.map(async({turn:Me,index:Pt})=>{let ce=await an(Me.text);return{index:Pt,html:rE(ce)}})).then((Me)=>{if(q)return;let Pt=new Map;for(let ce of Me)Pt.set(ce.index,ce.html);g(Pt)}),()=>{q=!0}};if(!U){if(k.current)clearTimeout(k.current),k.current=null;return B()}if(k.current)clearTimeout(k.current);return k.current=setTimeout(()=>{k.current=null,B()},400),()=>{if(k.current)clearTimeout(k.current),k.current=null}},[n]);let P=M(async()=>{let U=p.trim();if(!U)return;let B=p;x(null),re(e.id,{turns:[{role:"user",text:U,status:"pending"}],threadStatus:"pending",text:U}),m("");let q=Array.isArray(e.data.contextNodeIds)?e.data.contextNodeIds:void 0;if(!(await Fr(U,e.position,e.id,q,e.id)).ok)re(e.id,{turns:[],threadStatus:"draft",text:"",status:"draft"}),m(B),x("Failed to send prompt. Your draft has been restored.")},[p,e.id,e.position,e.data.contextNodeIds]),Z=M(async()=>{let U=f.trim();if(!U)return;let B=f;x(null);let q=Array.isArray(e.data.turns)?[...e.data.turns]:[];if(q.push({role:"user",text:U,status:"pending"}),re(e.id,{turns:q,threadStatus:"pending"}),y(""),!(await Fp(e.id,U)).ok)q.pop(),re(e.id,{turns:q,threadStatus:"answered"}),y(B),x("Failed to send reply. Your draft has been restored.")},[f,e.id,e.data.turns]),j=M((U)=>{if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)){U.preventDefault(),P();return}if(U.key==="Tab"&&p.startsWith("/")){U.preventDefault();let B=p.slice(1).split(/\s/)[0];if(B)ax().then((q)=>{let Y=cx(B,q);if(Y)m(`/${Y}`)})}},[P,p]),I=M((U)=>{if(U.key==="Enter"&&(U.metaKey||U.ctrlKey)){U.preventDefault(),Z();return}if(U.key==="Tab"&&f.startsWith("/")){U.preventDefault();let B=f.slice(1).split(/\s/)[0];if(B)ax().then((q)=>{let Y=cx(B,q);if(Y)y(`/${Y}`)})}},[Z,f]),H=Array.isArray(e.data.contextNodeIds)?e.data.contextNodeIds.length:0;if(c&&n.length===0)return i("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%",gap:"8px"},children:[i(lx,{count:H},void 0,!1,void 0,this),i(ux,{message:v,onDismiss:()=>x(null)},void 0,!1,void 0,this),i("textarea",{ref:b,value:p,onInput:(U)=>m(U.target.value),onKeyDown:j,placeholder:"Ask the agent something…",spellcheck:!1,style:{flex:1,resize:"none",background:"rgba(10,14,30,0.4)",border:"1px solid var(--c-line)",borderRadius:"var(--radius-sm)",color:"var(--c-text)",fontFamily:"var(--font)",fontSize:"13px",lineHeight:"1.5",padding:"8px 10px",outline:"none"}},void 0,!1,void 0,this),i("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[i("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:["⌘","+Enter to send"]},void 0,!0,void 0,this),i("button",{type:"button",onClick:P,disabled:!p.trim(),style:{padding:"5px 14px",fontSize:"12px",fontWeight:600,background:p.trim()?"var(--c-accent)":"var(--c-line)",color:p.trim()?"var(--c-contrast-fg)":"var(--c-muted)",border:"none",borderRadius:"var(--radius-sm)",cursor:p.trim()?"pointer":"default"},children:"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this);if(o)return i("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[i("div",{style:{flex:1,padding:"2px 0",fontSize:"13px",lineHeight:"1.55",color:"var(--c-text)",whiteSpace:"pre-wrap",wordBreak:"break-word",overflow:"auto"},children:r},void 0,!1,void 0,this),i("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"6px",borderTop:"1px solid var(--c-line)",marginTop:"4px"},children:i("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:l?"var(--c-warn)":d?"var(--c-ok)":"var(--c-muted)"},children:l?"Sending…":d?"Answered":s},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("div",{class:"prompt-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[i(lx,{count:H},void 0,!1,void 0,this),i(ux,{message:v,onDismiss:()=>x(null)},void 0,!1,void 0,this),i("div",{ref:O,style:{flex:1,overflow:"auto",minHeight:0},children:n.map((U,B)=>i("div",{children:[B>0&&i("div",{class:"thread-turn-divider"},void 0,!1,void 0,this),U.role==="user"?i("div",{class:"thread-turn-user",children:[i("div",{class:"thread-turn-role",children:[i("span",{class:"status-dot"},void 0,!1,void 0,this),"You"]},void 0,!0,void 0,this),i("div",{style:{fontSize:t?"15px":"13px",lineHeight:t?"1.7":"1.55",color:"var(--c-text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:U.text},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i("div",{class:"thread-turn-assistant",children:[i("div",{class:"thread-turn-role",children:[i("span",{class:`status-dot${U.status==="streaming"?" pulsing":""}`},void 0,!1,void 0,this),"PMX"]},void 0,!0,void 0,this),U.status==="streaming"&&!U.text&&i("div",{style:{height:"2px",background:"linear-gradient(90deg, transparent, var(--c-ok), transparent)",animation:"response-stream-pulse 1.5s ease-in-out infinite",borderRadius:"1px",marginBottom:"4px"}},void 0,!1,void 0,this),i("div",{class:t?"md-reader-content":void 0,style:{fontSize:t?void 0:"13px",lineHeight:t?void 0:"1.55",opacity:U.text?1:0.4},children:h.get(B)?i(ye,{children:[i(iE,{html:h.get(B)??""},void 0,!1,void 0,this),U.status==="streaming"&&i("span",{class:"streaming-cursor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i("div",{style:{color:"var(--c-muted)",fontStyle:"italic"},children:U.status==="streaming"?"Waiting for response…":U.text||"Empty response"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},sE(U,B),!0,void 0,this))},void 0,!1,void 0,this),i("div",{style:{flexShrink:0,borderTop:"1px solid var(--c-line)",marginTop:"4px",paddingTop:"6px"},children:[i("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:d?"6px":0},children:[i("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:u?"var(--c-accent)":l?"var(--c-warn)":d?"var(--c-ok)":"var(--c-muted)"},children:u?"Streaming…":l?"Sending…":d?"Answered":a},void 0,!1,void 0,this),i("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:[n.length," turn",n.length!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&i("div",{class:"thread-reply-area",children:[i("textarea",{value:f,onInput:(U)=>y(U.target.value),onKeyDown:I,placeholder:"Reply…",spellcheck:!1,rows:2,style:{width:"100%",resize:"none",background:"rgba(10,14,30,0.4)",border:"1px solid var(--c-line)",borderRadius:"var(--radius-sm)",color:"var(--c-text)",fontFamily:"var(--font)",fontSize:"12px",lineHeight:"1.5",padding:"6px 8px",outline:"none"}},void 0,!1,void 0,this),i("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"4px"},children:[i("span",{style:{fontSize:"10px",color:"var(--c-muted)"},children:["⌘","+Enter"]},void 0,!0,void 0,this),i("button",{type:"button",onClick:Z,disabled:!f.trim(),style:{padding:"3px 10px",fontSize:"11px",fontWeight:600,background:f.trim()?"var(--c-accent)":"var(--c-line)",color:f.trim()?"var(--c-contrast-fg)":"var(--c-muted)",border:"none",borderRadius:"var(--radius-sm)",cursor:f.trim()?"pointer":"default"},children:"Reply"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function aE(e){return e.replace(/<script[\s>][\s\S]*?<\/script>/gi,"").replace(/<iframe[\s>][\s\S]*?<\/iframe>/gi,"").replace(/<object[\s>][\s\S]*?<\/object>/gi,"").replace(/<embed[\s>][\s\S]*?(?:\/>|<\/embed>)/gi,"").replace(/<link[\s>][\s\S]*?(?:\/>|<\/link>)/gi,"").replace(/\bon\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/href\s*=\s*"javascript:[^"]*"/gi,'href="#"').replace(/href\s*=\s*'javascript:[^']*'/gi,"href='#'")}function cE({html:e}){let t=N(null);return D(()=>{let n=t.current;if(!n)return;if(n.replaceChildren(),!e)return;let o=document.createElement("template");o.innerHTML=e,n.append(o.content.cloneNode(!0))},[e]),i("div",{ref:t},void 0,!1,void 0,this)}function za({node:e,expanded:t=!1}){let n=e.data.content||"",o=e.data.status||"streaming",[r,s]=L(""),a=o==="streaming",c=o==="complete";D(()=>{if(!n){s("");return}let u=!1;return an(n).then((d)=>{if(!u)s(aE(d))}),()=>{u=!0}},[n]);let l=M(()=>{Fr("",{x:e.position.x,y:e.position.y+e.size.height+24},e.id)},[e]);return i("div",{class:"response-node-inner",style:{display:"flex",flexDirection:"column",height:"100%"},children:[a&&i("div",{class:"response-streaming-bar",style:{height:"2px",background:"linear-gradient(90deg, transparent, var(--c-accent), transparent)",animation:"response-stream-pulse 1.5s ease-in-out infinite",borderRadius:"1px",marginBottom:"4px",flexShrink:0}},void 0,!1,void 0,this),i("div",{class:t?"md-reader":void 0,style:{flex:1,overflow:"auto",minHeight:0,opacity:n?1:0.4,transition:"opacity 0.2s ease"},children:r?i("div",{class:t?"md-reader-content":void 0,children:i(cE,{html:r},void 0,!1,void 0,this)},void 0,!1,void 0,this):i("div",{style:{color:"var(--c-muted)",fontStyle:"italic",fontSize:"13px"},children:a?"Waiting for response…":"Empty response"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",paddingTop:"6px",borderTop:"1px solid var(--c-line)",marginTop:"4px",flexShrink:0},children:[i("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,color:a?"var(--c-accent)":c?"var(--c-ok)":"var(--c-muted)"},children:a?"Streaming…":c?"Complete":o},void 0,!1,void 0,this),c&&i("button",{type:"button",onClick:l,style:{padding:"3px 10px",fontSize:"11px",background:"rgba(70,182,255,0.1)",border:"1px solid rgba(70,182,255,0.3)",borderRadius:"var(--radius-sm)",color:"var(--c-accent)",cursor:"pointer"},children:"Reply"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function dx(e){return{toolName:e.toolName||e.title||"unknown",category:e.category||"other",status:e.status||"running",duration:e.duration||"",resultSummary:e.resultSummary||e.content||"",error:e.error||""}}var px={mcp:"var(--c-accent)",file:"var(--c-warn)",subagent:"var(--c-purple)",other:"var(--c-muted)"},lE={running:"⠋",success:"✓",failed:"✕"},uE={running:"var(--c-accent)",success:"var(--c-ok)",failed:"var(--c-danger)"};function Pa({node:e}){let{toolName:t,category:n,status:o,duration:r,resultSummary:s,error:a}=dx(e.data),c=px[n]??px.other,l=lE[o]??"◌",u=uE[o]??"var(--c-muted)",d=o==="running",p=a?a.slice(0,30):s.length>30?`${s.slice(0,28)}…`:s;return i("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"0 12px",height:"100%",overflow:"hidden"},children:[i("span",{style:{fontSize:"14px",color:u,flexShrink:0,animation:d?"pulse 1.5s infinite":"none"},children:l},void 0,!1,void 0,this),i("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[i("div",{style:{fontFamily:"var(--mono)",fontSize:"11px",fontWeight:600,color:c,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t},void 0,!1,void 0,this),p&&i("div",{style:{fontSize:"10px",color:a?"var(--c-danger)":"var(--c-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.3},children:p},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&i("span",{style:{fontSize:"9px",padding:"1px 5px",borderRadius:"3px",background:"rgba(255,255,255,0.06)",color:"var(--c-muted)",flexShrink:0,whiteSpace:"nowrap"},children:r},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Xu(e){let t=R.value.get(e);if(!t)return null;return{left:t.position.x,top:t.position.y,width:t.size.width,height:t.size.height}}function dE(e){let t=e.map((l)=>Xu(l)).filter((l)=>l!==null);if(t.length===0)return null;let n=Math.min(...t.map((l)=>l.left)),o=Math.min(...t.map((l)=>l.top)),r=Math.max(...t.map((l)=>l.left+l.width)),s=Math.max(...t.map((l)=>l.top+l.height)),a=54,c=46;return{left:n-a,top:o-c,width:r-n+a*2,height:s-o+c*2}}function Gu(e,t){return{left:`${e.left}px`,top:`${e.top}px`,width:`${e.width}px`,height:`${e.height}px`,borderRadius:`${t}px`}}function fx(){let e=Array.from(Do.value),t=Array.from(Fo.value),n=Yi.value;if(e.length===0&&t.length===0)return null;let o=[...R.value.values()],r=o.length>0?(Math.max(...o.map((s)=>s.position.x+s.size.width))-Math.min(...o.map((s)=>s.position.x)))*(Math.max(...o.map((s)=>s.position.y+s.size.height))-Math.min(...o.map((s)=>s.position.y))):0;return i("div",{class:"attention-field-layer","aria-hidden":"true",children:[n.map((s)=>{let a=dE(s.nodeIds);if(!a)return null;if(r>0&&a.width*a.height>=r*0.75)return null;return i("div",{class:"attention-field-region",style:Gu(a,42)},s.id,!1,void 0,this)}),t.map((s)=>{let a=Xu(s);if(!a)return null;return i("div",{class:"attention-field-node attention-field-secondary",style:Gu({left:a.left-18,top:a.top-18,width:a.width+36,height:a.height+36},28)},`secondary-${s}`,!1,void 0,this)}),e.map((s)=>{let a=Xu(s);if(!a)return null;return i("div",{class:"attention-field-node attention-field-primary",style:Gu({left:a.left-24,top:a.top-24,width:a.width+48,height:a.height+48},30)},`primary-${s}`,!1,void 0,this)})]},void 0,!0,void 0,this)}var pE=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico","avif"]),fE=new Set(["md","mdx","markdown"]);function mE(e){let t=e.split(".").pop()?.toLowerCase()??"";if(pE.has(t))return"image";if(fE.has(t))return"markdown";return"file"}async function Na(e,t,n){let a=Math.ceil(Math.sqrt(e.length));for(let c=0;c<e.length;c++){let l=e[c],u=c%a,d=Math.floor(c/a),p=t-a*420/2+u*420,m=n-150+d*320,f=mE(l.name),y=l.name;if(f==="image"){let v=new FileReader,x=await new Promise((h)=>{v.onload=()=>h(v.result),v.readAsDataURL(l)});await Mt({type:"image",title:y,content:x,x:p,y:m,width:400,height:300})}else{let v=await l.text(),x=f==="markdown"||f==="file";await Mt({type:f,title:y,content:v,x:p,y:m,width:x?720:400,height:x?500:300})}}}var qe=V(new Map),xr=V(null),hE=480,gE=320,vE=650,bi=new Map,yr=new Map,Ra=new Map,vn=null;function Ku(e){qe.value=e,yE()}function Ju(e){let t=bi.get(e);if(t)clearTimeout(t),bi.delete(e)}function Yu(e){let t=yr.get(e);if(t)clearTimeout(t),yr.delete(e)}function hx(e){if(Ju(e.id),Yu(e.id),!qe.value.has(e.id))Ra.set(e.id,Date.now());let t=new Map(qe.value);t.set(e.id,{...e,phase:"forming"}),Ku(t)}function wi(e){if(Ju(e),Yu(e),Ra.delete(e),!qe.value.has(e))return;let t=new Map(qe.value);t.delete(e),Ku(t)}function mx(e,t,n,o){let r=qe.value.get(e);if(!r||r.phase===t)return;let s=new Map(qe.value);s.set(e,{...r,phase:t,...o?{settledNodeId:o}:{}}),Ku(s),Ju(e),bi.set(e,setTimeout(()=>wi(e),n))}function gx(e,t,n,o){Yu(e);let r=Date.now()-(Ra.get(e)??0),s=Math.max(0,vE-r);if(s===0){mx(e,t,n,o);return}yr.set(e,setTimeout(()=>{yr.delete(e),mx(e,t,n,o)},s))}function vx(e,t){gx(e,"settling",hE,t)}function Qu(e){gx(e,"dissolving",gE)}function ed(){for(let e of bi.values())clearTimeout(e);bi.clear();for(let e of yr.values())clearTimeout(e);if(yr.clear(),Ra.clear(),vn)clearInterval(vn),vn=null;xr.value=null,qe.value=new Map}function yE(){if(vn||qe.value.size===0)return;vn=setInterval(()=>{let e=Date.now();for(let t of qe.value.values())if(t.phase==="forming"&&t.expiresAt<=e)Qu(t.id);if(qe.value.size===0&&vn)clearInterval(vn),vn=null},1000),vn.unref?.()}var xE={fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"};function _e({size:e=16,children:t,...n}){return i("svg",{width:e,height:e,viewBox:"0 0 16 16",...xE,...n,children:t},void 0,!1,void 0,this)}function Ma(e){return i(_e,{...e,children:[i("polyline",{points:"1 5 1 1 5 1"},void 0,!1,void 0,this),i("polyline",{points:"11 1 15 1 15 5"},void 0,!1,void 0,this),i("polyline",{points:"15 11 15 15 11 15"},void 0,!1,void 0,this),i("polyline",{points:"5 15 1 15 1 11"},void 0,!1,void 0,this),i("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function xx(e){return i(_e,{...e,children:[i("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),i("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this),i("line",{x1:"5",y1:"7",x2:"9",y2:"7"},void 0,!1,void 0,this),i("line",{x1:"7",y1:"5",x2:"7",y2:"9"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function bx(e){return i(_e,{...e,children:[i("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),i("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this),i("line",{x1:"5",y1:"7",x2:"9",y2:"7"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function So(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"4",x2:"9.5",y2:"4"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"12",x2:"9.5",y2:"12"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"6.5",x2:"4",y2:"9.5"},void 0,!1,void 0,this),i("line",{x1:"12",y1:"6.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Oa(e){return i(_e,{...e,children:[i("rect",{x:"1",y:"2",width:"14",height:"12",rx:"1.5"},void 0,!1,void 0,this),i("rect",{x:"8",y:"7",width:"6",height:"6",rx:"1",fill:"currentColor","fill-opacity":"0.2"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wx(e){return i(_e,{...e,children:[i("circle",{cx:"8",cy:"8",r:"3"},void 0,!1,void 0,this),i("line",{x1:"8",y1:"1",x2:"8",y2:"3"},void 0,!1,void 0,this),i("line",{x1:"8",y1:"13",x2:"8",y2:"15"},void 0,!1,void 0,this),i("line",{x1:"1",y1:"8",x2:"3",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"13",y1:"8",x2:"15",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"3.05",y1:"3.05",x2:"4.46",y2:"4.46"},void 0,!1,void 0,this),i("line",{x1:"11.54",y1:"11.54",x2:"12.95",y2:"12.95"},void 0,!1,void 0,this),i("line",{x1:"3.05",y1:"12.95",x2:"4.46",y2:"11.54"},void 0,!1,void 0,this),i("line",{x1:"11.54",y1:"4.46",x2:"12.95",y2:"3.05"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function La(e){return i(_e,{...e,children:i("path",{d:"M13 9.5A5.5 5.5 0 1 1 6.5 3 4.5 4.5 0 0 0 13 9.5Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function td(e){return i(_e,{...e,children:[i("path",{d:"M3 13l2.8-.7L13 5.1 10.9 3 3.7 10.2 3 13Z"},void 0,!1,void 0,this),i("path",{d:"M9.8 4.1l2.1 2.1"},void 0,!1,void 0,this),i("path",{d:"M2.5 14h11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function nd(e){return i(_e,{...e,children:[i("path",{d:"M3 10.5 8.5 5a2 2 0 0 1 2.8 0l1.7 1.7a2 2 0 0 1 0 2.8L8.5 14H5.8L3 11.2Z"},void 0,!1,void 0,this),i("path",{d:"M7.5 6 12 10.5"},void 0,!1,void 0,this),i("path",{d:"M8.5 14H14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function od(e){return i(_e,{...e,children:[i("path",{d:"M3 4h10"},void 0,!1,void 0,this),i("path",{d:"M8 4v8"},void 0,!1,void 0,this),i("path",{d:"M6 12h4"},void 0,!1,void 0,this),i("path",{d:"M4.5 4 4 6"},void 0,!1,void 0,this),i("path",{d:"M11.5 4 12 6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _x(e){return i(_e,{...e,children:[i("rect",{x:"1",y:"4",width:"14",height:"10",rx:"1.5"},void 0,!1,void 0,this),i("path",{d:"M5.5 4 L6.5 2.5 H9.5 L10.5 4"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"9",r:"2.3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Sx(e){return i(_e,{...e,children:[i("circle",{cx:"8",cy:"8",r:"6"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"8",r:"3"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"8",r:"0.8",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kx(e){return i(_e,{...e,children:[i("circle",{cx:"8",cy:"8",r:"6"},void 0,!1,void 0,this),i("line",{x1:"5.5",y1:"5.5",x2:"10.5",y2:"10.5"},void 0,!1,void 0,this),i("line",{x1:"10.5",y1:"5.5",x2:"5.5",y2:"10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Cx(e){return i(_e,{...e,children:[i("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),i("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Tx(e){return i(_e,{...e,children:[i("rect",{x:"1",y:"3",width:"14",height:"10",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"6",x2:"5",y2:"6"},void 0,!1,void 0,this),i("line",{x1:"7.5",y1:"6",x2:"8.5",y2:"6"},void 0,!1,void 0,this),i("line",{x1:"11",y1:"6",x2:"12",y2:"6"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"10",x2:"12",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wr(e){return i(_e,{...e,children:i("path",{d:"M2 13 L2 4 A2 2 0 0 1 4 2 L12 2 A2 2 0 0 1 14 4 L14 9 A2 2 0 0 1 12 11 L5 11 Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Ex({size:e=22,class:t}){return i("svg",{width:e,height:e,viewBox:"0 0 64 64",xmlns:"http://www.w3.org/2000/svg",class:t,"aria-hidden":"true",children:[i("rect",{x:"8",y:"8",width:"48",height:"48",rx:"7",fill:"none",stroke:"currentColor","stroke-width":"2.2",opacity:"0.35"},void 0,!1,void 0,this),i("rect",{x:"16",y:"16",width:"32",height:"32",rx:"5",fill:"none",stroke:"currentColor","stroke-width":"2.2",opacity:"0.6"},void 0,!1,void 0,this),i("rect",{x:"24",y:"24",width:"16",height:"16",rx:"3",fill:"none",stroke:"currentColor","stroke-width":"2.2"},void 0,!1,void 0,this),i("rect",{x:"29",y:"29",width:"6",height:"6",rx:"1",fill:"currentColor"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ax({size:e=15}){return i("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:i("path",{d:"M3 2l10 5.5-4.2 1.3L7.5 13z"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Ix({size:e=15}){return i("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:i("path",{d:"M5 7.5V3.8a1 1 0 0 1 2 0V7m0-3.9a1 1 0 0 1 2 0V7m0-2.7a1 1 0 0 1 2 0V7.4m0-.9a1 1 0 0 1 2 0v3.2A4.3 4.3 0 0 1 8.7 14H8a4.3 4.3 0 0 1-3.6-2L2.7 9.3a1 1 0 0 1 1.6-1.2L5 9.2"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function zx({size:e=15}){return i("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:i("path",{d:"M6 4.5L2.5 8 6 11.5M10 4.5L13.5 8 10 11.5"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Bn(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"6",x2:"10",y2:"6"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"8.5",x2:"8",y2:"8.5"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"11",x2:"11",y2:"11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function bE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"9",rx:"1.5"},void 0,!1,void 0,this),i("path",{d:"M4 13.5 L5.5 11.5 L8 11.5"},void 0,!1,void 0,this),i("polyline",{points:"5 6 7 8 5 10"},void 0,!1,void 0,this),i("line",{x1:"8",y1:"10",x2:"11",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function wE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"9",rx:"1.5"},void 0,!1,void 0,this),i("path",{d:"M12 13.5 L10.5 11.5 L8 11.5"},void 0,!1,void 0,this),i("circle",{cx:"5",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"11",cy:"7",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $a(e){return i(_e,{...e,children:[i("path",{d:"M3 1.5h6l3.5 3.5v8a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V2.5a1 1 0 0 1 1-1z"},void 0,!1,void 0,this),i("polyline",{points:"9 1.5 9 5 12.5 5"},void 0,!1,void 0,this),i("line",{x1:"4.5",y1:"8.5",x2:"10.5",y2:"8.5"},void 0,!1,void 0,this),i("line",{x1:"4.5",y1:"11",x2:"9",y2:"11"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function rd(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("circle",{cx:"5.5",cy:"6.5",r:"1.2"},void 0,!1,void 0,this),i("path",{d:"M1.8 12 L6 8.5 L9 11 L11.5 9 L14.2 12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function br(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"1.5",y1:"5.5",x2:"14.5",y2:"5.5"},void 0,!1,void 0,this),i("circle",{cx:"3.3",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"5",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"6.7",cy:"4",r:"0.5",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"8",x2:"12",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"4",y1:"10",x2:"10",y2:"10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _E(e){return i(_e,{...e,children:[i("rect",{x:"2",y:"4",width:"12",height:"10",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"2",y1:"6.5",x2:"14",y2:"6.5"},void 0,!1,void 0,this),i("path",{d:"M11 1.5 L11 4"},void 0,!1,void 0,this),i("circle",{cx:"11",cy:"4",r:"1.6",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function id(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"1.5","stroke-dasharray":"2 1.5"},void 0,!1,void 0,this),i("rect",{x:"4",y:"4",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this),i("rect",{x:"8.5",y:"4",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this),i("rect",{x:"6.25",y:"8.5",width:"3.5",height:"3.5",rx:"0.6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function SE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("circle",{cx:"4.5",cy:"8",r:"1.1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"6.5",x2:"12.5",y2:"6.5"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"8",x2:"11",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"9.5",x2:"12",y2:"9.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function kE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("path",{d:"M3.5 10.5 L6 6.5 L8.5 9.5 L12.5 5"},void 0,!1,void 0,this),i("circle",{cx:"12.5",cy:"5",r:"0.9",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function CE(e){return i(_e,{...e,children:[i("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"4.5",y1:"5.5",x2:"11.5",y2:"5.5"},void 0,!1,void 0,this),i("line",{x1:"4.5",y1:"8",x2:"11.5",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"4.5",y1:"10.5",x2:"8",y2:"10.5"},void 0,!1,void 0,this),i("line",{x1:"6.5",y1:"2",x2:"6.5",y2:"14",opacity:"0.45"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function TE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this),i("path",{d:"M4 11 L4 6 L6 8.5 L8 6 L8 11"},void 0,!1,void 0,this),i("path",{d:"M10 11 L10 6 L12.5 11 L12.5 6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function EE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("polyline",{points:"10 5 13 5 13 8"},void 0,!1,void 0,this),i("line",{x1:"13",y1:"5",x2:"8",y2:"10"},void 0,!1,void 0,this),i("path",{d:"M6 6 L3.5 6 L3.5 11.5 L10 11.5 L10 9"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function AE(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("path",{d:"M7 5.5 C 5.5 5.5 5.5 8 4 8 C 5.5 8 5.5 10.5 7 10.5"},void 0,!1,void 0,this),i("path",{d:"M9 5.5 C 10.5 5.5 10.5 8 12 8 C 10.5 8 10.5 10.5 9 10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function yx(e){return i(_e,{...e,children:[i("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"},void 0,!1,void 0,this),i("line",{x1:"5.2",y1:"6",x2:"8",y2:"8"},void 0,!1,void 0,this),i("line",{x1:"8",y1:"8",x2:"10.8",y2:"6"},void 0,!1,void 0,this),i("line",{x1:"8",y1:"8",x2:"8",y2:"11"},void 0,!1,void 0,this),i("circle",{cx:"5.2",cy:"6",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"10.8",cy:"6",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"8",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this),i("circle",{cx:"8",cy:"11",r:"1",fill:"currentColor",stroke:"none"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function yn(e){switch(e){case"markdown":return Bn;case"prompt":return bE;case"response":return wE;case"file":return $a;case"diff":return $a;case"mermaid":return yx;case"image":return rd;case"webpage":return br;case"context":return _E;case"group":return id;case"status":return SE;case"trace":return kE;case"ledger":return CE;case"mcp-app":return TE;case"ext-app":return EE;case"json-render":return AE;case"graph":return yx;case"html":return br;default:return Bn}}var Px={width:260,height:150},IE={markdown:{width:300,height:170},status:{width:280,height:110},context:{width:300,height:200},trace:{width:220,height:64},file:{width:300,height:190},image:{width:260,height:200},webpage:{width:320,height:210},html:{width:320,height:210},group:{width:340,height:210},graph:{width:320,height:210},"json-render":{width:320,height:210},"mcp-app":{width:340,height:230}};function ad(e){return!!e&&e in ot}function xn(e){if(!e)return null;let t=R.value.get(e);if(!t)return null;return{left:t.position.x,top:t.position.y,width:t.size.width,height:t.size.height}}function sd(e){return{x:e.left+e.width/2,y:e.top+e.height/2}}function _i(e){let t=typeof e.confidence!=="number"?0.82:0.4+Math.max(0,Math.min(1,e.confidence))*0.55;return e.auto?t*0.62:t}function Nx(e,t){let n=Math.max(40,Math.abs(t.x-e.x)/2);return`M ${e.x} ${e.y} C ${e.x+n} ${e.y}, ${t.x-n} ${t.y}, ${t.x} ${t.y}`}function cd({intent:e}){let t=ad(e.nodeType)?yn(e.nodeType):null,n=e.label||e.kind,o=typeof e.confidence==="number"?`${Math.round(e.confidence*100)}%`:null;return i("div",{class:"intent-info",onMouseEnter:()=>xr.value=e.id,onMouseLeave:()=>{if(xr.value===e.id)xr.value=null},children:[i("div",{class:"intent-chip",children:[typeof e.seq==="number"&&i("span",{class:"intent-seq",children:e.seq},void 0,!1,void 0,this),t&&i("span",{class:"intent-chip-icon","aria-hidden":"true",children:i(t,{size:12},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"intent-chip-label",children:n},void 0,!1,void 0,this),o&&i("span",{class:"intent-confidence",children:o},void 0,!1,void 0,this),e.phase==="forming"&&!e.auto&&i("button",{type:"button",class:"intent-veto",title:"Veto this move (Esc)","aria-label":"Veto this move",onClick:(r)=>{r.stopPropagation(),so(e)},children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.reason&&i("div",{class:"intent-reason",children:e.reason},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rx({intent:e,rect:t}){let n=ad(e.nodeType)?yn(e.nodeType):null,o=ad(e.nodeType)?ot[e.nodeType]:"Node";return i("div",{class:`intent-ghost intent-ghost-box is-${e.phase}${e.auto?" is-auto":""}`,"data-intent-id":e.id,style:{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,opacity:_i(e)},children:[i("div",{class:"intent-ghost-titlebar",children:[i("span",{class:"intent-ghost-icon","aria-hidden":"true",children:n?i(n,{size:13},void 0,!1,void 0,this):"◇"},void 0,!1,void 0,this),i("span",{class:"intent-ghost-badge",children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(cd,{intent:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $x({intent:e,rect:t,variant:n}){return i("div",{class:`intent-ghost intent-ghost-${n} is-${e.phase}${e.auto?" is-auto":""}`,"data-intent-id":e.id,style:{left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,opacity:_i(e)},children:[n==="edit"&&i("div",{class:"intent-edit-bar"},void 0,!1,void 0,this),i(cd,{intent:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function zE(e){let t=e.phase==="settling"?xn(e.settledNodeId):null;switch(e.kind){case"create":{if(!e.position)return null;let n=e.nodeType&&IE[e.nodeType]||Px,o=t??{left:e.position.x,top:e.position.y,...n};return i(Rx,{intent:e,rect:o},e.id,!1,void 0,this)}case"move":{if(!e.position)return null;let o=xn(e.nodeId)??Px,r=t??{left:e.position.x,top:e.position.y,width:o.width,height:o.height};return i(Rx,{intent:e,rect:r},e.id,!1,void 0,this)}case"remove":{let n=t??xn(e.nodeId);if(!n)return null;return i($x,{intent:e,rect:n,variant:"remove"},e.id,!1,void 0,this)}case"edit":{let n=t??xn(e.nodeId);if(!n)return null;return i($x,{intent:e,rect:n,variant:"edit"},e.id,!1,void 0,this)}case"connect":{if(!e.edge)return null;let n=xn(e.edge.from),o=xn(e.edge.to);if(!n||!o)return null;let r={x:(n.left+n.width/2+o.left+o.width/2)/2,y:(n.top+n.height/2+o.top+o.height/2)/2},s={left:r.x-110,top:r.y-18,width:220,height:36};return i("div",{class:`intent-ghost intent-ghost-connect is-${e.phase}${e.auto?" is-auto":""}`,"data-intent-id":e.id,style:{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,opacity:_i(e)},children:i(cd,{intent:e},void 0,!1,void 0,this)},e.id,!1,void 0,this)}default:return null}}function Mx(){let e=Array.from(qe.value.values());if(D(()=>{function t(n){if(n.key!=="Escape")return;let o=xr.value;if(!o)return;let r=qe.value.get(o);if(!r||r.phase!=="forming")return;n.stopImmediatePropagation(),n.preventDefault(),so(r)}return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[]),e.length===0)return null;return i("div",{class:"intent-layer",children:[i("svg",{class:"intent-line-layer",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:[i("defs",{children:i("marker",{id:"intent-arrow",markerWidth:"8",markerHeight:"8",refX:"6",refY:"3",orient:"auto",children:i("path",{d:"M0,0 L6,3 L0,6 Z",class:"intent-arrow-head"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.map((t)=>{if(t.kind==="connect"&&t.edge){let n=xn(t.edge.from),o=xn(t.edge.to);if(!n||!o)return null;return i("path",{d:Nx(sd(n),sd(o)),class:`intent-edge type-${t.edge.type}`,style:{opacity:_i(t)}},`line-${t.id}`,!1,void 0,this)}if(t.kind==="move"&&t.position){let n=xn(t.nodeId);if(!n)return null;let o=n,r={x:t.position.x+o.width/2,y:t.position.y+o.height/2};return i("path",{d:Nx(sd(n),r),class:"intent-trail",markerEnd:"url(#intent-arrow)",style:{opacity:_i(t)}},`line-${t.id}`,!1,void 0,this)}return null})]},void 0,!0,void 0,this),e.map(zE)]},void 0,!0,void 0,this)}var Ox=32000;var Da="Agent session";function Lx(e){return e.some((t)=>t.attached)}function Dx(e){return e.filter((t)=>!t.attached)}function _r(e){switch(e.phase){case"thinking":return"Thinking";case"tooling":return e.detail?`Running ${e.detail}`:"Working";case"waiting-approval":return"Waiting on you";default:return"Idle"}}function Un(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t%360+360)%360}var ut=V([]),ud=V({used:0,total:Ox}),Wn=V([]),ko=V(!1),Sr=V(!1),dd=V(null),Fx=["var(--c-purple)","var(--c-accent)","var(--c-ok)","var(--c-warn)","var(--c-danger)"],ld=new Map;function Fa(e){let t=ld.get(e);if(t)return t;let n=Fx[ld.size%Fx.length];return ld.set(e,n),n}function jx(e){return(e.trim().replace(/^[^a-z0-9]+/i,"").charAt(0)||e.trim().charAt(0)||"?").toUpperCase()}function ja(e,t=Date.now()){let n=t-Date.parse(e);if(!Number.isFinite(n)||n<5000)return"now";if(n<60000)return`${Math.floor(n/1000)}s`;if(n<3600000)return`${Math.floor(n/60000)}m`;return`${Math.floor(n/3600000)}h`}var dt=Le(()=>Lx(ut.value)),pd=Le(()=>Dx(ut.value)),Zx=Le(()=>{let e=new Set;return[...ut.value].filter((t)=>t.label!==Da).sort((t,n)=>Number(n.attached)-Number(t.attached)).map((t)=>({value:t.sessionId==="browser"?t.label:t.sessionId,label:t.label,attached:t.attached,steerable:t.attached||t.steerable===!0,pendingSteers:t.pendingSteers??0,polling:t.lastClaimAt!==void 0&&Date.now()-Date.parse(t.lastClaimAt)<300000})).filter((t)=>e.has(t.value)?!1:(e.add(t.value),!0))}),Hx=Le(()=>ut.value.filter((e)=>e.attached)),kr=Le(()=>ut.value.find((e)=>e.attached)??null);function PE(e){let t=new Set;for(let n of e)if(n.nodeId&&n.kind!=="create")t.add(n.nodeId);return t}var Bx=Le(()=>PE(qe.value.values()));function Za(e,t){if(e.cursor)return{x:e.cursor.x,y:e.cursor.y};if(!e.focusNodeId)return null;let n=t(e.focusNodeId);if(!n)return null;return{x:n.position.x+Math.max(24,n.size.width-28),y:n.position.y+16}}function fd(e){if(!e)return;if(Array.isArray(e.presences))ut.value=e.presences;if(e.budget&&Number.isFinite(e.budget.used)&&Number.isFinite(e.budget.total))ud.value={used:e.budget.used,total:e.budget.total};if(Array.isArray(e.activity))Wn.value=e.activity}function Ux(){let e=N(new Map),t=oe.value.scale,n=R.value,o=1/Math.max(0.05,t),r=ut.value.map((s)=>{let a=Za(s,(l)=>n.get(l));if(a)e.current.set(s.sessionId,a);let c=a??e.current.get(s.sessionId)??null;return c?{presence:s,position:c}:null}).filter((s)=>s!==null);if(r.length===0)return null;return i("div",{class:"agent-presence-layer","aria-hidden":"true",children:r.map(({presence:s,position:a})=>i("div",{class:`agent-cursor phase-${s.phase}${s.attached?"":" is-external"}${s.parentAgentId?" is-worker":""}`,"data-session-id":s.sessionId,style:{transform:`translate(${a.x}px, ${a.y}px)`,"--identity-color":`hsl(${Un(s.sessionId)} 65% 62%)`},children:i("div",{class:"agent-cursor-inner",style:{transform:`scale(${o})`},children:[i("svg",{class:"agent-cursor-glyph",width:"16",height:"18",viewBox:"0 0 16 18","aria-hidden":"true",children:i("path",{d:"M1.5 1.5L14.5 9.2 8.3 10.6 5.2 16.5z",fill:"currentColor",stroke:"var(--c-bg)","stroke-width":"1.2"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"agent-cursor-chip",children:[i("span",{class:"agent-cursor-dot"},void 0,!1,void 0,this),i("span",{class:"agent-cursor-label",children:_r(s)},void 0,!1,void 0,this),i("span",{class:"agent-cursor-who",children:s.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},s.sessionId,!1,void 0,this))},void 0,!1,void 0,this)}var Wx=30000;var md=80;function NE(e,t){try{let n=window.sessionStorage.getItem(e);if(n)return n;let o=t();return window.sessionStorage.setItem(e,o),o}catch{return t()}}var Wa=NE("pmx-canvas-human-client",()=>`tab-${Math.random().toString(36).slice(2,8)}`);function RE(){try{let e=new URLSearchParams(window.location.search).get("name")?.trim();if(e)return window.localStorage.setItem("pmx-canvas-human-name",e),e;let t=window.localStorage.getItem("pmx-canvas-human-name")?.trim();if(t)return t}catch{}return`guest-${Wa.slice(-4)}`}var Vx=V(RE()),Gx=V([]),hd=Le(()=>Gx.value.filter((e)=>e.clientId!==Wa)),Co=V(new Map);function gd(e){if(!e||!Array.isArray(e.humans))return;Gx.value=e.humans}var Ba=null,qa=null,Xx=0,Si=null;function Ua(e){jt("humanPresence","/api/canvas/human-presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:Wa,name:Vx.value,...e})})}function qx(){Si=null,Xx=Date.now(),Ua({cursor:qa,grabbingNodeId:Ba})}function Va(e){qa=e;let t=Date.now()-Xx;if(t>=md){if(Si)clearTimeout(Si);qx()}else if(!Si)Si=setTimeout(qx,md-t)}function vd(e){Ba=e,Ua({cursor:qa,grabbingNodeId:e})}function $E(e,t){let n=new Map(Co.value);n.set(e,t),Co.value=n,setTimeout(()=>{let o=new Map(Co.value);if(o.get(e)===t)o.delete(e),Co.value=o},6000)}function Kx(e,t){let n=[...qe.value.values()].filter((r)=>r.nodeId===e&&!r.auto&&r.phase==="forming");if(n.length===0)return;let o=Vx.value;$E(e,o);for(let r of n)so({id:r.id,kind:r.kind,label:r.label,reason:`${o} took over “${t}” mid-edit — yield and requeue the change once it is released`}).then((s)=>{if(s)wi(r.id)});jt("yieldEvent","/api/canvas/ax/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:"yield",summary:`${o} grabbed “${t}” mid-edit — agent yielded, change requeued`,nodeIds:[e],source:"browser"})})}var Ha=null;function Jx(){Ua({cursor:qa,grabbingNodeId:Ba}),Ha=setInterval(()=>Ua({grabbingNodeId:Ba}),3000);let e=()=>{try{navigator.sendBeacon?.("/api/canvas/human-presence",new Blob([JSON.stringify({clientId:Wa,left:!0})],{type:"application/json"}))}catch{}};return window.addEventListener("pagehide",e),()=>{if(Ha)clearInterval(Ha);Ha=null,window.removeEventListener("pagehide",e)}}function bn(e=1000){let[t,n]=L(()=>Date.now());return D(()=>{if(e<=0)return;n(Date.now());let o=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(o)},[e]),t}function Yx(){let e=bn(hd.value.length>0?5000:0),t=hd.value.filter((o)=>o.cursor!==null&&(!o.lastSeenAt||e-Date.parse(o.lastSeenAt)<Wx+5000));if(t.length===0)return null;let n=1/Math.max(0.05,oe.value.scale);return i("div",{class:"human-presence-layer","aria-hidden":"true",children:t.map((o)=>i("div",{class:`human-cursor${o.grabbingNodeId?" is-grabbing":""}`,"data-client-id":o.clientId,style:{transform:`translate(${o.cursor.x}px, ${o.cursor.y}px)`},children:i("div",{class:"human-cursor-inner",style:{transform:`scale(${n})`},children:[i("svg",{class:"human-cursor-glyph",width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i("path",{d:"M3 2 L13 8 L8.5 9.5 L6.5 14 Z",fill:"currentColor",stroke:"var(--c-bg)","stroke-width":"1"},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"human-cursor-tag",children:o.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},o.clientId,!1,void 0,this))},void 0,!1,void 0,this)}function Ga(e,t){let{POSITIVE_INFINITY:n,POSITIVE_INFINITY:o,NEGATIVE_INFINITY:r,NEGATIVE_INFINITY:s}=Number,a=0;for(let c of e)a+=1,n=Math.min(n,c.position.x),o=Math.min(o,c.position.y),r=Math.max(r,c.position.x+c.size.width),s=Math.max(s,c.position.y+c.size.height);if(a===0)return null;return{x:n-t,y:o-t,width:r-n+t*2,height:s-o+t*2}}function xd(){let e=Wt.value;return e&&typeof e==="object"?e:{}}var Qx=Le(()=>xd().workItems??[]),eb=Le(()=>xd().approvalGates??[]),To=Le(()=>eb.value.filter((e)=>e.status==="pending")),qn=Le(()=>{let e=xd().policy?.scope;return e&&Array.isArray(e.nodeIds)&&e.nodeIds.length>0?{nodeIds:e.nodeIds,padding:typeof e.padding==="number"?e.padding:40}:null});async function tb(e){return(await kt("setScopeFence","/api/canvas/ax/policy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:e&&e.length>0?{nodeIds:e}:null,source:"browser"})})).ok}var nb=Le(()=>eb.value.filter((e)=>e.status==="held")),ob=V({events:[],evidence:[],steering:[]}),Eo=V("all");function bd(e){if(e==="update")return"update";if(e==="steer"||e==="steering"||e==="yield")return"steer";if(e==="assistant-message")return"assistant";if(e==="evidence")return"evidence";return"event"}var ME=new Set(["api","mcp","sdk","cli"]);function yd(e,t){if(e?.trim())return e.trim();let n=t?.trim();if(n&&!ME.has(n))return n;return null}var OE=/^(node|edge|group|annotation|jsonrender|graph|render)\.|^arrange$|^canvas\.clear$|^snapshot\.restore$/,rb=V(null),ki=V(new Set),LE={prompt:"Prompt","assistant-message":"Assistant","tool-start":"Tool run","tool-result":"Tool result",failure:"Failure",approval:"Approval",steering:"Steering",command:"Command",note:"Note",policy:"Policy",yield:"Yield"};function DE(e,t=40,n=[],o=null,r="all"){let s=n.find((l)=>OE.test(l.op)),a=[...n.map((l)=>({id:`update-${l.id}`,kind:"update",label:"Update",body:l.summary,createdAt:l.at,who:l.sessionId??null,...o?.actor==="agent"&&s?.id===l.id?{undoable:!0}:{}})),...e.events.map((l)=>({id:`event-${l.id}`,kind:l.kind,label:LE[l.kind]??l.kind,body:l.detail?`${l.summary} — ${l.detail}`:l.summary,createdAt:l.createdAt,who:yd(l.agentId,l.source)})),...e.evidence.map((l)=>({id:`evidence-${l.id}`,kind:"evidence",label:"Evidence",body:l.body?`${l.title} — ${l.body}`:l.title,createdAt:l.createdAt,who:yd(l.agentId,l.source)})),...e.steering.map((l)=>{let u=l.agentId??(l.source&&l.source!=="browser"?l.source:null),d=l.target?`→ ${l.target} · `:u?"→ all · ":"",p=l.target&&l.delivered===!1?` — waiting for ${l.target} to pick it up`:"";return{id:`steer-${l.id}`,kind:"steer",label:"Steer",body:`${u?`${u} `:""}${d}${l.message}${p}`,createdAt:l.createdAt,who:yd(l.agentId,l.source)}})],c=r==="all"?a:a.filter((l)=>bd(l.kind)===r);return c.sort((l,u)=>l.createdAt<u.createdAt?1:l.createdAt>u.createdAt?-1:0),c.slice(0,t)}var ib=Le(()=>DE(ob.value,40,Wn.value,rb.value,Eo.value));async function Vn(){let[e,t]=await Promise.all([ve("refreshTimeline","/api/canvas/ax/timeline?limit=40",null),ve("refreshHistoryTop","/api/canvas/history",null)]);if(t)rb.value=t.top??null;if(!e)return;ob.value={events:Array.isArray(e.events)?e.events:[],evidence:Array.isArray(e.evidence)?e.evidence:[],steering:Array.isArray(e.steering)?e.steering:[]}}async function wd(e){if(!(await kt("undoAgentEdit","/api/canvas/undo",{method:"POST"})).ok)return!1;return ki.value=new Set([...ki.value,e.id]),await jt("undoAgentEditSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:`Undid your edit: ${e.body} — it was reverted on the board.`,source:"browser"})}),Vn(),!0}async function _d(e=!1){let t=await kt(e?"redo":"undo",e?"/api/canvas/redo":"/api/canvas/undo",{method:"POST"});if(t.ok)Vn();return t.ok}async function sb(e,t){if(!(await kt("resolveGate",`/api/canvas/ax/approval/${encodeURIComponent(e.id)}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({decision:t,source:"browser"})})).ok)return!1;if(t==="rejected")await jt("rejectGateSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:`Rejected gate "${e.title}" — do not proceed with it.`,source:"browser"})});return!0}async function ab(e){return(await kt("reopenGate",`/api/canvas/ax/approval/${encodeURIComponent(e.id)}/reopen`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"browser"})})).ok}async function cb(e,t){return(await kt("sendSteering","/api/canvas/ax/steer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,source:"browser",...t?{target:t}:{}})})).ok}async function Gn(){return(await kt("startSession","/api/canvas/ax/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:"browser",label:Da,attached:!0,phase:"idle"})})).ok}async function Xa(e){return(await kt("endSession","/api/canvas/ax/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:e.source,agentId:e.agentId,attached:!1,endedBy:"human"})})).ok}var Ka=V(null);function lb(e){let{counts:t,snapshot:n}=e;if(typeof e.label!=="string"||typeof e.endedAt!=="string")return;Ka.value={label:e.label,endedAt:e.endedAt,endedBy:e.endedBy==="human"||e.endedBy==="agent"||e.endedBy==="idle-timeout"?e.endedBy:void 0,unchanged:e.unchanged===!0,counts:{items:Number(t?.items??0)||0,done:Number(t?.done??0)||0,cancelled:Number(t?.cancelled??0)||0,rejected:Number(t?.rejected??0)||0,held:Number(t?.held??0)||0},snapshot:n&&typeof n.id==="string"?{id:n.id,name:String(n.name??"")}:null}}function ub(){Ka.value=null}function db(){if(!dt.value)return null;let e=qn.value;if(!e)return null;let t=R.value,n=e.nodeIds.map((s)=>t.get(s)).filter((s)=>s!==void 0),o=Ga(n,e.padding);if(!o)return null;let r=1/Math.max(0.05,oe.value.scale);return i("div",{class:"scope-fence","data-fenced-count":n.length,style:{transform:`translate(${o.x}px, ${o.y}px)`,width:`${o.width}px`,height:`${o.height}px`},"aria-hidden":"true",children:[i("span",{class:"scope-fence-pill scope-fence-pill-top",style:{transform:`scale(${r})`},children:["Agent scope · ",n.length," node",n.length===1?"":"s"]},void 0,!0,void 0,this),i("span",{class:"scope-fence-pill scope-fence-pill-bottom",style:{transform:`scale(${r})`},children:"writes outside are blocked · reads allowed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Ja={markdown:"var(--c-accent)","mcp-app":"var(--c-ok)",webpage:"var(--c-warn)","json-render":"var(--c-ok)",graph:"var(--c-purple)",prompt:"var(--c-accent)",response:"var(--c-ok)",status:"var(--c-warn)",context:"var(--c-muted)",ledger:"var(--c-dim)",trace:"var(--c-purple)",file:"var(--c-accent)",diff:"var(--c-ok)",mermaid:"var(--c-purple)",image:"var(--c-ok)",html:"var(--c-warn)",group:"var(--c-accent)"};function FE(e){let t=typeof e==="number"&&Number.isFinite(e)?Math.floor(e):1;return Math.max(1,Math.min(20,t))}function Ya(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ci(e){return typeof e==="string"&&e.length>0}function pb(e){let t=e.axStep;if(!Ya(t))return null;if(!Ci(t.flowId)||!Ci(t.workItemId))return null;if(typeof t.index!=="number"||typeof t.total!=="number")return null;return{flowId:t.flowId,index:t.index,total:t.total,workItemId:t.workItemId}}function fb(e){let t=e.axFlow;if(!Ya(t)||!Ci(t.flowId)||!Array.isArray(t.steps))return null;let n=[];for(let r of t.steps){if(!Ya(r)||!Ci(r.nodeId)||!Ci(r.workItemId))return null;if(typeof r.index!=="number")return null;n.push({index:r.index,nodeId:r.nodeId,workItemId:r.workItemId,title:typeof r.title==="string"?r.title:""})}if(n.length===0)return null;let o=Ya(t.loop)?t.loop:{};return{flowId:t.flowId,title:typeof t.title==="string"?t.title:"Flow",steps:n,loop:{running:o.running===!0,run:typeof o.run==="number"&&Number.isFinite(o.run)?Math.max(0,Math.floor(o.run)):0,maxRuns:FE(o.maxRuns)}}}var jE={position:"sticky",bottom:"calc(-1 * var(--ax-dock-bleed, 12px))",marginTop:"12px",marginLeft:"calc(-1 * var(--ax-dock-bleed, 12px))",marginRight:"calc(-1 * var(--ax-dock-bleed, 12px))",marginBottom:"calc(-1 * var(--ax-dock-bleed, 12px))",padding:"9px var(--ax-dock-pad, 12px) 10px",background:"var(--c-panel-overlay)",borderTop:"1px solid var(--c-line)",backdropFilter:"blur(6px)"},hb={display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},gb={fontSize:"10px",color:"var(--c-muted)",textTransform:"uppercase",letterSpacing:"0.04em",marginRight:"auto"},vb={...co,background:"var(--c-accent-25)",color:"var(--c-text)"},ZE=[{status:"in-progress",label:"Start",toast:"Step started"},{status:"done",label:"Done",toast:"Step done"},{status:"blocked",label:"Blocked",toast:"Step blocked"}];async function mb(e,t,n){let o={...t,loop:n};re(e.id,{axFlow:o}),await ft(e.id,{data:{axFlow:o}})}function yb(e){return typeof e?.axWorkStatus==="string"?e.axWorkStatus:"todo"}function HE({node:e,flow:t}){let[n,o]=L(""),{running:r,run:s,maxRuns:a}=t.loop,c=async()=>{await mb(e,t,{running:!0,run:s>=a?0:s,maxRuns:a});let u=t.steps.find((p)=>yb(R.value.get(p.nodeId)?.data)!=="done"),d=u??t.steps[t.steps.length-1];await zn(e,"ax.work.update",{id:d.workItemId,status:u?"in-progress":"done"},"Loop running")},l=async()=>{let u=n.trim();if(!u)return;await zn(e,"ax.steer",{message:u},"Steering sent"),o("")};return i("div",{class:"ax-flow-controls",style:{...hb,marginTop:"6px",rowGap:"4px"},children:[i("span",{class:"ax-flow-runs",style:gb,children:r?`Loop running · run ${s+1}/${a}`:`Loop idle · ${s}/${a} runs`},void 0,!1,void 0,this),r?i("button",{type:"button",class:"ax-node-action",style:vb,title:"Stop the loop now. The stop is persisted on this node, so it survives a refresh and no further step is opened.",onClick:(u)=>{u.stopPropagation(),mb(e,t,{...t.loop,running:!1})},children:"Stop"},void 0,!1,void 0,this):i("button",{type:"button",class:"ax-node-action",style:co,title:"Run this flow as a loop: each completed step opens the next one, and the last step starts the next run — until the run cap is reached or you press Stop.",onClick:(u)=>{u.stopPropagation(),c()},children:"Run loop"},void 0,!1,void 0,this),i("input",{class:"ax-flow-steer-input",value:n,placeholder:"Steer the agent…","aria-label":"Steer the agent",onInput:(u)=>o(u.target.value),onClick:(u)=>u.stopPropagation(),onKeyDown:(u)=>{if(u.key!=="Enter")return;u.stopPropagation(),l()},style:{flex:"1 1 120px",minWidth:"90px",fontSize:"10px",padding:"3px 6px",borderRadius:"4px",border:"1px solid var(--c-line)",background:"var(--c-panel-overlay)",color:"var(--c-text)"}},void 0,!1,void 0,this),i("button",{type:"button",class:"ax-node-action",style:co,title:"Send a steering message to the agent working this flow.",onClick:(u)=>{u.stopPropagation(),l()},children:"Steer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Qa({node:e}){let t=pb(e.data);if(!t)return null;let n=fb(e.data),o=yb(e.data);return i("div",{class:"ax-step-dock",style:jE,children:[i("div",{class:"ax-step-controls",style:hb,children:[i("span",{class:"ax-step-position",style:gb,children:["Step ",t.index,"/",t.total]},void 0,!0,void 0,this),ZE.map((r)=>i("button",{type:"button",class:"ax-node-action","aria-pressed":o===r.status,style:o===r.status?vb:co,title:`Set this step's work item to "${r.status}".`,onClick:(s)=>{s.stopPropagation(),zn(e,"ax.work.update",{id:t.workItemId,status:r.status},r.toast)},children:r.label},r.status,!1,void 0,this))]},void 0,!0,void 0,this),n&&i(HE,{node:e,flow:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var Cr=8,Ao=V(null),Tr=[],Er=[],wb=null;function xb(e){let t=e?.data.parentGroup;return typeof t==="string"&&t.length>0?t:null}function bb(e){if(!e||!Array.isArray(e.data.children))return[];return e.data.children.filter((t)=>typeof t==="string")}function BE(e,t){let n=new Map(t.map((c)=>[c.id,c])),o=new Set([e]),r=n.get(e);if(!r)return o;let s=xb(r);while(s&&!o.has(s))o.add(s),s=xb(n.get(s));if(r.type!=="group")return o;let a=[...bb(r)];while(a.length>0){let c=a.pop();if(!c||o.has(c))continue;o.add(c);let l=n.get(c);if(l?.type==="group")a.push(...bb(l))}return o}function _b(e,t){Tr=[],Er=[],wb=e;let n=Array.from(t),o=BE(e,n);for(let r of n){if(o.has(r.id))continue;let s=r.position.x,a=r.position.x+r.size.width,c=r.position.x+r.size.width/2,l=r.position.y,u=r.position.y+r.size.height,d=r.position.y+r.size.height/2;Tr.push({val:s,minY:l,maxY:u}),Tr.push({val:a,minY:l,maxY:u}),Tr.push({val:c,minY:l,maxY:u}),Er.push({val:l,minX:s,maxX:a}),Er.push({val:u,minX:s,maxX:a}),Er.push({val:d,minX:s,maxX:a})}}function Sb(){Tr=[],Er=[],wb=null}function kb(e,t,n,o){let r=[e,e+n/2,e+n],s=[t,t+o/2,t+o],a=[0,n/2,n],c=[0,o/2,o],l=null,u=Cr+1,d=null;for(let v=0;v<3;v++){let x=r[v];for(let h of Tr){let g=Math.abs(x-h.val);if(g<u)u=g,l=h.val-a[v],d={axis:"x",pos:h.val,from:Math.min(h.minY,t),to:Math.max(h.maxY,t+o)}}}let p=null,m=Cr+1,f=null;for(let v=0;v<3;v++){let x=s[v];for(let h of Er){let g=Math.abs(x-h.val);if(g<m)m=g,p=h.val-c[v],f={axis:"y",pos:h.val,from:Math.min(h.minX,e),to:Math.max(h.maxX,e+n)}}}let y=[];if(d&&u<=Cr)y.push(d);if(f&&m<=Cr)y.push(f);return{x:l!==null&&u<=Cr?l:e,y:p!==null&&m<=Cr?p:t,guides:y}}function Cb({nodeId:e,viewport:t,onMove:n,onDragEnd:o}){let r=N(!1),s=N({x:0,y:0}),a=N({x:0,y:0});return M((l,u,d)=>{l.stopPropagation(),l.preventDefault(),r.current=!0,document.documentElement.classList.add("is-node-dragging"),window.getSelection()?.removeAllRanges(),s.current={x:l.clientX,y:l.clientY},a.current={x:u,y:d};let p=null,m=null,f=()=>{if(m=null,!r.current||!p)return;let x=p;p=null;let h=t.value.scale,g=(x.x-s.current.x)/h,b=(x.y-s.current.y)/h;n(e,a.current.x+g,a.current.y+b)},y=(x)=>{if(!r.current)return;if(p={x:x.clientX,y:x.clientY},m!==null)return;m=window.requestAnimationFrame(f)},v=()=>{if(m!==null)window.cancelAnimationFrame(m),f();r.current=!1,document.documentElement.classList.remove("is-node-dragging"),document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",v),document.removeEventListener("pointercancel",v),o()};document.addEventListener("pointermove",y),document.addEventListener("pointerup",v),document.addEventListener("pointercancel",v)},[e,t,n,o])}var UE=200,WE=100;function Tb({nodeId:e,viewport:t,onResize:n,onResizeEnd:o}){let r=N(!1),s=N({x:0,y:0}),a=N({w:0,h:0});return M((l,u,d)=>{l.stopPropagation(),l.preventDefault(),r.current=!0,s.current={x:l.clientX,y:l.clientY},a.current={w:u,h:d},document.documentElement.classList.add("is-node-resizing");let p=null,m=null,f=()=>{if(m=null,!r.current||!p)return;let x=p;p=null;let h=t.value.scale,g=(x.x-s.current.x)/h,b=(x.y-s.current.y)/h;n(e,Math.max(UE,a.current.w+g),Math.max(WE,a.current.h+b))},y=(x)=>{if(!r.current)return;if(p={x:x.clientX,y:x.clientY},m!==null)return;m=window.requestAnimationFrame(f)},v=()=>{if(m!==null)window.cancelAnimationFrame(m),f();r.current=!1,document.documentElement.classList.remove("is-node-resizing"),document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",v),document.removeEventListener("pointercancel",v),o()};document.addEventListener("pointermove",y),document.addEventListener("pointerup",v),document.addEventListener("pointercancel",v)},[e,t,n,o])}var qE={ArrowLeft:{dx:-1,dy:0},ArrowRight:{dx:1,dy:0},ArrowUp:{dx:0,dy:-1},ArrowDown:{dx:0,dy:1}};function VE(e,t,n){let o=e.position.x+e.size.width/2,r=e.position.y+e.size.height/2,s=null,a=Number.POSITIVE_INFINITY;for(let c of n){if(c.id===e.id)continue;let l=c.position.x+c.size.width/2-o,u=c.position.y+c.size.height/2-r,d=l*t.dx+u*t.dy;if(d<=0)continue;let p=Math.abs(l*t.dy)+Math.abs(u*t.dx);if(p>d)continue;let m=d+p*2;if(m<a)a=m,s=c}return s}var GE=0.4,XE=0.55,KE=175;function JE(e,t,n=0){if(!Number.isFinite(e)||e>=1)return 1;let r=Math.min(2.2,1/Math.max(e,0.01));if(Number.isFinite(t)&&t>0)r=Math.min(r,t*GE/or);if(Number.isFinite(n)&&n>0)r=Math.min(r,n*XE/KE);return Math.max(1,r)}function Eb({node:e,children:t,onContextMenu:n}){let o=Ce.value===e.id,r=xe.value.has(e.id),s=Ee.value.has(e.id),a=Do.value.has(e.id),c=!a&&Fo.value.has(e.id),l=Qi.value.has(e.id),u=!o&&gf.value.has(e.id),d=Nn.value,p=d!==null&&d.has(e.id),m=d!==null&&!d.has(e.id),[f,y]=L(!1),v=N(null),x=M((z,de,Oe)=>{let me=kb(de,Oe,e.size.width,e.size.height),eo=R.value.get(z);if(eo?.position.x===me.x&&eo.position.y===me.y){Ao.value=me.guides.length>0?me.guides:null;return}rt(z,{position:{x:me.x,y:me.y}}),Ao.value=me.guides.length>0?me.guides:null,bf(z)},[e.size.width,e.size.height]),h=N(null),g=M(()=>{if(Sb(),Ao.value=null,vd(null),h.current)document.removeEventListener("keydown",h.current),h.current=null;Je();let z=ln.value;if(xf(),!z||z.nodeId!==e.id)return;if(z.mode==="add")Fc(z.groupId,[e.id]);else{let de=R.value.get(z.groupId),Oe=Array.isArray(de?.data.children)?de.data.children.filter((me)=>typeof me==="string"&&me!==e.id):[];cs(z.groupId,Oe)}},[e.id]),b=Cb({nodeId:e.id,viewport:oe,onMove:x,onDragEnd:g}),O=M((z,de,Oe)=>{let me=R.value.get(z);if(me?.size.width===de&&me.size.height===Oe)return;rt(z,{size:{width:de,height:Oe}})},[]),F=M(()=>{re(e.id,{userResized:!0}),ft(e.id,{data:{userResized:!0}}),Je()},[e.id]),_=Tb({nodeId:e.id,viewport:oe,onResize:O,onResizeEnd:F}),k=M((z)=>{z.stopPropagation(),z.preventDefault(),je.value={fromId:e.id,fromX:e.position.x+e.size.width/2,fromY:e.position.y+e.size.height/2,cursorX:e.position.x+e.size.width/2,cursorY:e.position.y+e.size.height/2,targetId:null}},[e.id,e.position.x,e.position.y,e.size.width,e.size.height]),T=M((z)=>{if(f)return;if(vt.value==="connect"){k(z);return}if(z.shiftKey){z.stopPropagation(),Jc(e.id);return}if(fn(e.id),vd(e.id),Kx(e.id,typeof e.data.title==="string"&&e.data.title?e.data.title:e.type),_b(e.id,R.value.values()),e.type!=="group"){let de=(Oe)=>{if(Oe.key==="Escape")yf()};h.current=de,document.addEventListener("keydown",de)}b(z,e.position.x,e.position.y)},[e.id,e.type,e.data.title,e.position.x,e.position.y,b,f,k]),P=M((z)=>{if(z.stopPropagation(),vt.value==="connect"){k(z);return}if(z.shiftKey){Jc(e.id);return}fn(e.id)},[e.id,k]),Z=M((z)=>{if(n)n(z,e.id)},[n,e.id]),j=M((z)=>{let de=z.target;if(de&&de!==z.currentTarget&&de.closest('input, textarea, [contenteditable="true"]'))return;let Oe=qE[z.key];if(Oe){z.preventDefault();let me=VE(e,Oe,R.value.values());if(!me)return;fn(me.id),requestAnimationFrame(()=>{document.querySelector(`.canvas-node[data-node-id="${CSS.escape(me.id)}"]`)?.focus()})}else if(z.key==="Enter"&&z.target===z.currentTarget&&Zr.has(e.type))z.preventDefault(),Qt(e.id)},[e]),I=M((z)=>{z.stopPropagation(),y(!0),requestAnimationFrame(()=>v.current?.focus())},[]),H=e.data.title||(e.type==="file"?(e.data.path||e.data.content||"").split(/[\\/]/).pop()??"":"")||ot[e.type],U=M((z)=>{let de=z.trim();if(de&&de!==H)re(e.id,{title:de}),ft(e.id,{title:de});y(!1)},[e.id,H]),B=N(null),q=N(!1),Y=N(null);D(()=>{if(q.current||!Sl(e))return;let z=B.current;if(!z)return;let de=new ResizeObserver(()=>{if(q.current){de.disconnect();return}let Oe=z.scrollHeight,me=Cm(e,Oe);if(me===null)return;if(Math.abs(me-e.size.height)>8){if(Jo(e.id,{width:e.size.width,height:me}),Y.current!==null)window.clearTimeout(Y.current);Y.current=window.setTimeout(()=>{Je({recordHistory:!1}),Y.current=null},0)}q.current=!0,de.disconnect()});return de.observe(z),()=>{if(de.disconnect(),Y.current!==null)window.clearTimeout(Y.current),Y.current=null}},[e.id,e.type,e.data.mode,e.data.strictSize,e.collapsed,e.size.width,e.size.height]);let be=e.pinned,Me=e.type==="trace",Pt=Me&&e.data.status==="running",ce=e.type==="group",Qn=e.data.strictSize===!0,qt=Math.max(oe.value.scale,0.01),Vt=JE(qt,e.collapsed?0:e.size.height,e.size.width),E=ce&&e.data.color?e.data.color:void 0,G={left:`${e.position.x}px`,top:`${e.position.y}px`,width:`${e.size.width}px`,height:e.collapsed?"auto":`${e.size.height}px`,zIndex:e.zIndex,"--node-chrome-scale":Vt.toFixed(3),...E?{"--group-color":E}:{}},le=dt.value&&Bx.value.has(e.id),te=["canvas-node",o?"active":"",u?"neighbor":"",p?"search-match":"",m?"search-dimmed":"",r?"selected":"",s?"context-pinned":"",a?"attention-focus-primary":"",c?"attention-focus-secondary":"",l?"attention-pulse":"",be?"pinned":"",Me?"trace-node":"",Pt?"trace-running":"",ce?"group-node":"",Qn?"strict-size":"",le?"agent-mutating":""].filter(Boolean).join(" "),X=ce?(Array.isArray(e.data.children)?e.data.children:[]).filter((z)=>typeof z==="string"&&R.value.has(z)):[],[ee,Q]=L(!1),W=ln.value,se=ce&&W?.groupId===e.id&&W.mode==="add",pt=ce&&W?.groupId===e.id&&W.mode==="remove",St=je.value?.targetId===e.id,Gt=ce?[...new Set(X.map((z)=>R.value.get(z)?.type).filter((z)=>!!z))].slice(0,4):[];if(ce&&e.collapsed)return i("div",{class:`${te} group-chip`,"data-node-type":e.type,style:{...G,width:"auto",height:"auto"},onPointerDown:P,onContextMenu:Z,title:"Expand group","data-testid":"group-chip",children:i("div",{class:"node-titlebar group-chip-inner",onPointerDown:T,children:[i("button",{type:"button",class:"group-chip-expand","aria-label":`Expand group ${H}`,onClick:(z)=>{z.stopPropagation(),Yo(e.id)},children:"▸"},void 0,!1,void 0,this),i("div",{class:"group-chip-text",children:[i("div",{class:"group-chip-name",children:H},void 0,!1,void 0,this),i("div",{class:"group-chip-meta",children:[Gt.map((z)=>i("span",{class:"group-kind-dot",style:{background:Ja[z]},"aria-hidden":"true"},z,!1,void 0,this)),i("span",{class:"group-chip-count",children:[X.length," node",X.length===1?"":"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return i("div",{class:`${te}${se?" is-drop-target":""}${pt?" is-drop-source":""}${St?" is-edge-target":""}${ce&&ee?" group-menu-open":""}`,"data-node-type":e.type,"data-node-id":e.id,style:G,tabIndex:o?0:-1,onKeyDown:j,onPointerDown:P,onMouseDown:(z)=>{if(z.shiftKey)z.preventDefault()},onContextMenu:Z,children:[ce&&i("div",{class:"node-titlebar group-edge-row",onPointerDown:T,children:[i("span",{class:"group-name-pill",children:[f?i("input",{ref:v,class:"node-title-input group-title-input",value:H,onBlur:(z)=>U(z.target.value),onKeyDown:(z)=>{if(z.key==="Enter")U(z.target.value);if(z.key==="Escape")y(!1)},onClick:(z)=>z.stopPropagation()},void 0,!1,void 0,this):i("span",{class:"group-name",onDblClick:I,title:`${H} — double-click to rename`,children:H},void 0,!1,void 0,this),i("span",{class:"group-count",children:X.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"group-edge-spacer"},void 0,!1,void 0,this),i("span",{class:"group-actions",role:"toolbar","aria-label":`${H} actions`,children:[i("button",{type:"button",class:"group-action",title:"Auto-arrange children","aria-label":"Auto-arrange children",disabled:X.length===0,onClick:(z)=>{z.stopPropagation(),Fc(e.id,X,"grid")},children:i("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","aria-hidden":"true",children:[i("rect",{x:"1.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"9.5",y:"1.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"1.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"9.5",y:"9.5",width:"5",height:"5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i("button",{type:"button",class:"group-action",title:"Collapse group","aria-label":"Collapse group",onClick:(z)=>{z.stopPropagation(),Yo(e.id)},children:i("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:i("path",{d:"M3 10 L8 5 L13 10"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("button",{type:"button",class:"group-action",title:"Rename · Ungroup · Pin all to context","aria-label":"Group menu","aria-expanded":ee,onClick:(z)=>{z.stopPropagation(),Q((de)=>!de)},children:"⋯"},void 0,!1,void 0,this),ee&&i("div",{class:"group-menu",role:"menu",onPointerDown:(z)=>z.stopPropagation(),children:[i("button",{type:"button",role:"menuitem",onClick:(z)=>{z.stopPropagation(),Q(!1),y(!0),requestAnimationFrame(()=>v.current?.focus())},children:"Rename"},void 0,!1,void 0,this),i("button",{type:"button",role:"menuitem",onClick:(z)=>{z.stopPropagation(),Q(!1),Et(e.id),Ho(e.id)},children:"Ungroup"},void 0,!1,void 0,this),i("button",{type:"button",role:"menuitem",disabled:X.length===0,onClick:(z)=>{z.stopPropagation(),Q(!1),xs(X)},children:"Pin all to context"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!ce&&i("div",{class:"node-titlebar",onPointerDown:T,children:[i("span",{class:"node-type-icon","aria-hidden":"true",children:(()=>{let z=yn(e.type);return i(z,{size:Math.round(14*Vt)},void 0,!1,void 0,this)})()},void 0,!1,void 0,this),typeof e.data.axWorkStatus==="string"&&i("span",{class:`node-ax-status node-ax-status-${e.data.axWorkStatus}`,children:e.data.axWorkStatus},void 0,!1,void 0,this),f?i("input",{ref:v,class:"node-title-input",value:H,onBlur:(z)=>U(z.target.value),onKeyDown:(z)=>{if(z.key==="Enter")U(z.target.value);if(z.key==="Escape")y(!1)},onClick:(z)=>z.stopPropagation()},void 0,!1,void 0,this):i("span",{class:"node-title",onDblClick:I,title:`${H} — double-click to rename`,children:H},void 0,!1,void 0,this),i("div",{class:"node-controls",children:[be&&i("span",{class:"pin-indicator",title:"Pinned",children:"⊙"},void 0,!1,void 0,this),i("button",{type:"button",class:`ctx-pin-btn${s?" ctx-pin-active":""}`,onClick:(z)=>{z.stopPropagation(),Rn(e.id)},title:s?"Remove from context":"Add to context",children:"✦"},void 0,!1,void 0,this),Ls(e)&&i("button",{type:"button",onClick:(z)=>{z.stopPropagation(),Ds(e)},title:"Open as site",children:"↗"},void 0,!1,void 0,this),Zr.has(e.type)&&i("button",{type:"button",onClick:(z)=>{z.stopPropagation(),Qt(e.id)},title:"Expand (focus mode)",children:"⤢"},void 0,!1,void 0,this),i("button",{type:"button",onClick:(z)=>{z.stopPropagation(),Yo(e.id)},title:e.collapsed?"Expand":"Collapse",children:e.collapsed?"▸":"▾"},void 0,!1,void 0,this),i("button",{type:"button",onClick:(z)=>{z.stopPropagation(),Et(e.id),An(e.id)},title:"Close",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!e.collapsed&&i("div",{ref:B,class:"node-body",children:[t,i(Qa,{node:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!e.collapsed&&i("div",{class:"node-resize-handle",onPointerDown:(z)=>_(z,e.size.width,e.size.height)},void 0,!1,void 0,this),r&&["tl","tr","bl","br"].map((z)=>i("span",{class:`node-selection-handle is-${z}`,"aria-hidden":"true"},z,!1,void 0,this)),Co.value.has(e.id)&&i("span",{class:"node-yield-pill","data-testid":"yield-pill",children:[i("span",{class:"node-yield-dot","aria-hidden":"true"},void 0,!1,void 0,this),Co.value.get(e.id)," took over — agent yielded"]},void 0,!0,void 0,this),!ce&&["top","right","bottom","left"].map((z)=>i("div",{class:`node-port node-port-${z}`,onPointerDown:(de)=>{de.stopPropagation(),de.preventDefault();let Oe=e.position.x+e.size.width/2,me=e.position.y+e.size.height/2,eo=e.size.width/2,to=e.size.height/2,Sn,Xt;switch(z){case"top":Sn=Oe,Xt=me-to;break;case"bottom":Sn=Oe,Xt=me+to;break;case"left":Sn=Oe-eo,Xt=me;break;case"right":Sn=Oe+eo,Xt=me;break}je.value={fromId:e.id,fromX:Sn,fromY:Xt,cursorX:Sn,cursorY:Xt}}},z,!1,void 0,this))]},void 0,!0,void 0,this)}var YE={relation:"var(--c-muted)","depends-on":"var(--c-warn)",flow:"var(--c-accent)",references:"var(--c-muted)"},QE=new Set(["depends-on","flow"]);function eA(e){if(!Number.isFinite(e)||e<=0)return 1;return e<1?1/e:1}function tA(e,t){let n=`${8*t} ${4*t}`;if(e.style==="dashed")return n;if(e.style==="dotted")return`${3*t} ${3*t}`;if(e.type==="references"&&!e.style)return n;return}function ec(e,t){let n=e.position.x+e.size.width/2,o=e.position.y+e.size.height/2,r=t.position.x+t.size.width/2,s=t.position.y+t.size.height/2,a=r-n,c=s-o,l=e.size.width/2,u=e.size.height/2,d=Math.abs(c/(a||0.001)),p=u/(l||0.001);if(d>p){let f=c>0?1:-1;return{x:n+u/d*(a>0?1:-1),y:o+u*f,side:f>0?"bottom":"top"}}let m=a>0?1:-1;return{x:n+l*m,y:o+d*l*(c>0?1:-1),side:m>0?"right":"left"}}function tc(e,t){switch(e.side){case"top":return{x:e.x,y:e.y-t};case"bottom":return{x:e.x,y:e.y+t};case"left":return{x:e.x-t,y:e.y};case"right":return{x:e.x+t,y:e.y}}}function nA(e,t,n,o,r,s,a,c){return{x:0.125*e+0.375*n+0.375*r+0.125*a,y:0.125*t+0.375*o+0.375*s+0.125*c}}function oA({edge:e,fromNode:t,toNode:n,focused:o,dimmed:r,selected:s,scale:a,onContextMenu:c}){let l=ec(t,n),u=ec(n,t),d=u.x-l.x,p=u.y-l.y,m=Math.sqrt(d*d+p*p),f=Math.min(Math.max(m*0.35,32),160),y=tc(l,f),v=tc(u,f),x=`M ${l.x} ${l.y} C ${y.x} ${y.y}, ${v.x} ${v.y}, ${u.x} ${u.y}`,h=YE[e.type],g=QE.has(e.type),b=tA(e,a),O=Math.min(a,2.2),F=e.label&&a<=3.4?nA(l.x,l.y,y.x,y.y,v.x,v.y,u.x,u.y):null,_=`edge-path-${e.id}`;return i("g",{children:[i("path",{d:x,fill:"none",stroke:"transparent","stroke-width":12*a,style:{cursor:"pointer",pointerEvents:"stroke"},onClick:(k)=>{k.stopPropagation(),un.value=e.id},onContextMenu:c?(k)=>c(k,e.id):void 0},void 0,!1,void 0,this),(o||s)&&i("path",{d:x,fill:"none",stroke:h,"stroke-width":6*a,"stroke-dasharray":b,opacity:s?0.3:0.15,style:{filter:"blur(3px)"}},void 0,!1,void 0,this),i("path",{id:_,d:x,class:s?"edge-selected":void 0,fill:"none",stroke:h,"stroke-width":(s?3:o?2.5:1.5)*a,"stroke-dasharray":b,"marker-end":g?"url(#edge-arrow)":void 0,opacity:s?1:r?0.2:o?1:0.85,style:{transition:"opacity 0.2s, stroke-width 0.2s"}},void 0,!1,void 0,this),e.animated&&i("circle",{r:3*a,fill:h,opacity:"0.9",children:i("animateMotion",{dur:"2s",repeatCount:"indefinite",children:i("mpath",{href:`#${_}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),F&&e.label&&i("g",{transform:`translate(${F.x}, ${F.y})`,children:[i("rect",{class:"edge-label-bg",x:-(e.label.length*3.5+8)*O,y:-10*O,width:(e.label.length*7+16)*O,height:20*O,rx:4*O},void 0,!1,void 0,this),i("text",{class:"edge-label","text-anchor":"middle","dominant-baseline":"central",fill:"var(--c-text)",children:e.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ab({nodes:e,edges:t,onEdgeContextMenu:n}){let o=e.value,r=Array.from(t.value.values()),s=Ce.value,a=s!==null,c=Nn.value,l=c!==null,u=eA(oe.value.scale);if(r.length===0&&!je.value)return null;let d=96,p=Array.from(o.values());if(p.length===0)return null;let m=Math.min(...p.map((g)=>g.position.x))-d,f=Math.min(...p.map((g)=>g.position.y))-d,y=Math.max(...p.map((g)=>g.position.x+g.size.width))+d,v=Math.max(...p.map((g)=>g.position.y+g.size.height))+d,x=Math.max(1,y-m),h=Math.max(1,v-f);return i("svg",{"aria-label":"Canvas connections",role:"img",viewBox:`${m} ${f} ${x} ${h}`,width:x,height:h,style:{position:"absolute",top:`${f}px`,left:`${m}px`,pointerEvents:"none",overflow:"visible","--edge-chrome-scale":u.toFixed(3),"--edge-label-scale":Math.min(u,2.2).toFixed(3)},children:[i("title",{children:"Canvas connections"},void 0,!1,void 0,this),i("defs",{children:i("marker",{id:"edge-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerUnits:"userSpaceOnUse",markerWidth:8*Math.min(u,2.2),markerHeight:8*Math.min(u,2.2),orient:"auto-start-reverse",children:i("path",{d:"M 0 1 L 10 5 L 0 9 z",fill:"currentColor",opacity:"0.75"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),r.map((g)=>{let b=ys(g.from),O=ys(g.to);if(!b||!O||b.id===O.id)return null;let F=a&&(g.from===s||g.to===s),_=l&&!(c.has(g.from)||c.has(g.to));return i(oA,{edge:g,fromNode:b,toNode:O,focused:F,dimmed:a&&!F||_,selected:un.value===g.id,scale:u,onContextMenu:n},g.id,!1,void 0,this)}),je.value&&(()=>{let g=je.value,b=ys(g.fromId),O={position:{x:g.cursorX,y:g.cursorY},size:{width:1,height:1}},F;if(b){let _=ec(b,O),k=ec(O,b),T=k.x-_.x,P=k.y-_.y,Z=Math.sqrt(T*T+P*P),j=Math.min(Math.max(Z*0.35,32),160),I=tc(_,j),H=tc(k,j);F=`M ${_.x} ${_.y} C ${I.x} ${I.y}, ${H.x} ${H.y}, ${k.x} ${k.y}`}else{let _=g.cursorX-g.fromX,k=g.cursorY-g.fromY,T=Math.sqrt(_*_+k*k),P=Math.min(T*0.25,80),Z=_/(T||1),j=k/(T||1);F=`M ${g.fromX} ${g.fromY} C ${g.fromX+Z*P} ${g.fromY+j*P}, ${g.cursorX-Z*P} ${g.cursorY-j*P}, ${g.cursorX} ${g.cursorY}`}return i("g",{children:[i("path",{d:F,fill:"none",stroke:"var(--c-accent)","stroke-width":6*u,opacity:"0.1",style:{filter:"blur(3px)"}},void 0,!1,void 0,this),i("path",{d:F,fill:"none",stroke:"var(--c-accent)","stroke-width":2*u,"stroke-dasharray":`${6*u} ${4*u}`,opacity:"0.8"},void 0,!1,void 0,this),i("circle",{cx:g.cursorX,cy:g.cursorY,r:5*u,fill:"var(--c-accent)",opacity:"0.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})()]},void 0,!0,void 0,this)}function rA(e){let[t,...n]=e;if(!t)return"";return n.reduce((o,r)=>`${o} L ${r.x} ${r.y}`,`M ${t.x} ${t.y}`)}function Sd({annotations:e}){if(e.length===0)return null;return i("svg",{class:"annotation-layer","aria-hidden":"true",children:e.map((t)=>{let n=t.color==="currentColor"?"var(--c-annotation)":t.color;if(t.type==="text"){let o=t.points[0];if(!o||!t.text)return null;return i("text",{x:o.x,y:o.y,fill:n,"font-size":t.width,"font-family":"var(--font)","font-weight":"700",opacity:"0.95",children:t.text},t.id,!1,void 0,this)}return i("path",{d:rA(t.points),fill:"none",stroke:n,"stroke-width":t.width,"stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.9"},t.id,!1,void 0,this)})},void 0,!1,void 0,this)}var iA=0.1,sA=4,Ib=1;function zb(e){return Math.min(sA,Math.max(iA,e))}function Pb({viewport:e,onViewportChange:t,onViewportCommit:n,disabled:o=!1}){let r=N(null),s=N(!1),a=N({x:0,y:0}),c=N(0),l=N(null),u=M((h)=>{if(l.current!==null)window.clearTimeout(l.current);l.current=window.setTimeout(()=>{l.current=null,n(h)},140)},[n]);function d(h){if(h.deltaMode!==0)return h.deltaX===0;return h.deltaX===0&&Number.isInteger(h.deltaY)&&Math.abs(h.deltaY)>=50}let p=M((h)=>{if(o)return;h.preventDefault();let g=e.value;if(h.ctrlKey||h.metaKey||d(h)){let b=r.current?.getBoundingClientRect();if(!b)return;let O=h.clientX-b.left,F=h.clientY-b.top,_=-h.deltaY*0.002,k=zb(g.scale*(1+_)),T=k/g.scale,P={x:O-T*(O-g.x),y:F-T*(F-g.y),scale:k};t(P),u(P)}else{let b={x:g.x-h.deltaX*Ib,y:g.y-h.deltaY*Ib,scale:g.scale};t(b),u(b)}},[o,e,t,u]),m=M((h)=>{if(o)return;let g=r.current;if(!g)return;if(h.button===1)h.preventDefault();else if(Ko()){if(h.target!==g)return;h.preventDefault()}else return;s.current=!0,a.current={x:h.clientX,y:h.clientY},g.setPointerCapture(h.pointerId)},[o]),f=M((h)=>{if(!s.current)return;if(o)return;let g=h.clientX-a.current.x,b=h.clientY-a.current.y;a.current={x:h.clientX,y:h.clientY};let O=e.value;t({x:O.x+g,y:O.y+b,scale:O.scale})},[o,e,t]),y=M(()=>{if(s.current)n(e.value);s.current=!1},[n,e]),v=M((h)=>{if(o)return;if(h.touches.length!==2){c.current=0;return}h.preventDefault();let g=h.touches[0],b=h.touches[1],O=Math.hypot(b.clientX-g.clientX,b.clientY-g.clientY),F=(g.clientX+b.clientX)/2,_=(g.clientY+b.clientY)/2;if(c.current>0){let k=e.value,T=r.current?.getBoundingClientRect();if(!T)return;let P=F-T.left,Z=_-T.top,j=O/c.current,I=zb(k.scale*j),H=I/k.scale,U={x:P-H*(P-k.x),y:Z-H*(Z-k.y),scale:I};t(U),u(U)}c.current=O},[o,e,t,u]),x=M(()=>{if(l.current!==null)window.clearTimeout(l.current),l.current=null;n(e.value),c.current=0},[n,e]);return D(()=>{let h=r.current;if(!h)return;return h.addEventListener("wheel",p,{passive:!1}),h.addEventListener("pointerdown",m),h.addEventListener("pointermove",f),h.addEventListener("pointerup",y),h.addEventListener("pointercancel",y),h.addEventListener("touchmove",v,{passive:!1}),h.addEventListener("touchend",x),()=>{if(l.current!==null)window.clearTimeout(l.current);h.removeEventListener("wheel",p),h.removeEventListener("pointerdown",m),h.removeEventListener("pointermove",f),h.removeEventListener("pointerup",y),h.removeEventListener("pointercancel",y),h.removeEventListener("touchmove",v),h.removeEventListener("touchend",x)}},[p,m,f,y,v,x]),r}function aA(e){switch(e.type){case"markdown":return i(Rs,{node:e},void 0,!1,void 0,this);case"mcp-app":return i(Hn,{node:e},void 0,!1,void 0,this);case"webpage":return i(Aa,{node:e},void 0,!1,void 0,this);case"json-render":return i(Hn,{node:e},void 0,!1,void 0,this);case"graph":return i(Hn,{node:e},void 0,!1,void 0,this);case"prompt":return i(Ia,{node:e},void 0,!1,void 0,this);case"response":return i(za,{node:e},void 0,!1,void 0,this);case"status":return i(Ta,{node:e},void 0,!1,void 0,this);case"context":return i(hs,{node:e},void 0,!1,void 0,this);case"ledger":return i(Es,{node:e},void 0,!1,void 0,this);case"trace":return i(Pa,{node:e},void 0,!1,void 0,this);case"file":return i(Ts,{node:e},void 0,!1,void 0,this);case"diff":return i(gs,{node:e},void 0,!1,void 0,this);case"mermaid":return i(Fs,{node:e},void 0,!1,void 0,this);case"image":return i(Ea,{node:e},void 0,!1,void 0,this);case"html":return i(xi,{node:e},void 0,!1,void 0,this);case"group":return i(ix,{node:e},void 0,!1,void 0,this);default:return i("div",{children:"Unknown node type"},void 0,!1,void 0,this)}}function cA(e,t,n){let o=n.x-t.x,r=n.y-t.y,s=o*o+r*r;if(s===0)return Math.hypot(e.x-t.x,e.y-t.y);let a=Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*r)/s));return Math.hypot(e.x-(t.x+a*o),e.y-(t.y+a*r))}function lA(e,t,n){for(let o=e.length-1;o>=0;o--){let r=e[o];if(!r)continue;let s=n+r.width;if(t.x<r.bounds.x-s||t.x>r.bounds.x+r.bounds.width+s||t.y<r.bounds.y-s||t.y>r.bounds.y+r.bounds.height+s)continue;if(r.type==="text")return r;for(let a=1;a<r.points.length;a++){let c=r.points[a-1],l=r.points[a];if(c&&l&&cA(t,c,l)<=n+r.width/2)return r}}return null}var kd="currentColor",Nb=4,Rb=24,uA=14,$b={width:520,height:420};function dA(e){let t=e.trim();if(!t||/\s/.test(t))return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`https://${t}`;try{let o=new URL(n);if(o.protocol!=="http:"&&o.protocol!=="https:")return null;return o.toString()}catch{return null}}function Td(e){let t=e.trim();if(!t)return[];let n=t.includes(`
|
|
314
|
+
`)?t.split(/\r?\n/):t.split(/\s+/),o=new Set,r=[];for(let s of n){let a=s.trim();if(!a||a.startsWith("#"))continue;let c=dA(a);if(!c||o.has(c))continue;o.add(c),r.push(c)}return r}function pA(e){let t=Td(e.getData("text/uri-list"));if(t.length>0)return t;return Td(e.getData("text/plain"))}function fA(e){if(!e)return!1;return e.types.includes("text/uri-list")||e.types.includes("text/plain")}function Cd(e){if(!(e instanceof HTMLElement))return!1;return Boolean(e.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'))}function mA(e,t,n=new Set){let o=[],r=0;for(let s of e){if(n.has(s.id))continue;if(t&&s.id===t)continue;if(s.type==="group")o.splice(r++,0,s);else o.push(s)}return o}function Mb({onNodeContextMenu:e,onEdgeContextMenu:t,onCanvasContextMenu:n,annotationMode:o=!1,annotationTool:r=null}){let s=oe.value,a=N(!1),c=N(null),l=N(!1),u=N([]),[d,p]=L(null),[m,f]=L(null),[y,v]=L(null),x=N(null),[h,g]=L(!1),b=N(0),O=N(null),F=N(null);D(()=>{let E=null,G=Kt(()=>{oe.value;let le=F.current;if(!le)return;if(le.style.willChange="transform",E)clearTimeout(E);E=setTimeout(()=>{le.style.willChange="auto"},180)});return()=>{if(E)clearTimeout(E);G()}},[]);let _=Pb({viewport:oe,disabled:o,onViewportChange:(E)=>{if(a.current||o)return;er(),Af(E)},onViewportCommit:(E)=>{if(a.current||o)return;er(),zf(E)}}),k=M((E)=>{x.current=E,v(E)},[]),T=M(async(E,G,le)=>{if(E.length===0)return;let{width:te,height:X}=$b,ee=24,Q=Math.ceil(Math.sqrt(E.length)),W=Math.ceil(E.length/Q),se=Q*te+Math.max(0,Q-1)*ee,pt=W*X+Math.max(0,W-1)*ee;for(let St=0;St<E.length;St++){let Gt=St%Q,z=Math.floor(St/Q),de=G-se/2+Gt*(te+ee),Oe=le-pt/2+z*(X+ee);await Mt({type:"webpage",content:E[St],x:de,y:Oe,width:te,height:X})}},[]),P=M((E)=>{let G=_.current;if(!G)return;if(r==="eraser"){if((E.target instanceof Element?E.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;E.preventDefault(),E.stopPropagation();let W=G.getBoundingClientRect(),se=oe.value,pt={x:(E.clientX-W.left-se.x)/se.scale,y:(E.clientY-W.top-se.y)/se.scale},St=lA(Array.from(Go.value.values()),pt,uA/se.scale);if(St)Ef(St.id);return}if(r==="text"){if((E.target instanceof Element?E.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;E.preventDefault(),E.stopPropagation(),Ce.value=null,mt();let W=G.getBoundingClientRect(),se=oe.value;k({x:(E.clientX-W.left-se.x)/se.scale,y:(E.clientY-W.top-se.y)/se.scale,value:""});return}if(r==="pen"){if((E.target instanceof Element?E.target:null)?.closest(".tool-rail, .top-bar, .snapshot-panel, .context-menu, .command-palette"))return;E.preventDefault(),E.stopPropagation(),Ce.value=null,mt(),l.current=!0;let W=G.getBoundingClientRect(),se=oe.value,pt={x:(E.clientX-W.left-se.x)/se.scale,y:(E.clientY-W.top-se.y)/se.scale};u.current=[pt],f({id:"draft-annotation",type:"freehand",points:[pt],bounds:{x:0,y:0,width:0,height:0},color:kd,width:Nb,createdAt:""}),G.setPointerCapture(E.pointerId);return}if(E.target!==G)return;if(Ko()||E.button===1){if(!E.shiftKey&&!O.current)Ce.value=null,mt();return}E.preventDefault(),E.stopPropagation(),a.current=!0;let le=G.getBoundingClientRect(),te=E.clientX-le.left,X=E.clientY-le.top,ee={startX:te,startY:X,currentX:te,currentY:X};O.current=ee,p(ee),G.setPointerCapture(E.pointerId)},[r,_]);D(()=>Kt(()=>{let E=oe.value,G=c.current,le=_.current;if(!G||!le)return;let te=le.getBoundingClientRect();Va({x:(G.x-te.left-E.x)/E.scale,y:(G.y-te.top-E.y)/E.scale})}),[]);let Z=M((E)=>{{let te=_.current;if(te){c.current={x:E.clientX,y:E.clientY};let X=te.getBoundingClientRect(),ee=oe.value;Va({x:(E.clientX-X.left-ee.x)/ee.scale,y:(E.clientY-X.top-ee.y)/ee.scale})}}if(l.current){let te=_.current;if(!te)return;let X=te.getBoundingClientRect(),ee=oe.value,Q={x:(E.clientX-X.left-ee.x)/ee.scale,y:(E.clientY-X.top-ee.y)/ee.scale},W=u.current.at(-1);if(W&&Math.hypot(Q.x-W.x,Q.y-W.y)<2)return;u.current=[...u.current,Q],f((se)=>se?{...se,points:u.current}:null);return}if(!a.current||!O.current)return;let G=_.current?.getBoundingClientRect();if(!G)return;let le={...O.current,currentX:E.clientX-G.left,currentY:E.clientY-G.top};O.current=le,p(le)},[_]),j=M((E)=>{if(l.current){l.current=!1;let Q=u.current;if(u.current=[],f(null),Q.length>=2)nl({points:Q,color:kd,width:Nb});let W=_.current;if(W?.hasPointerCapture(E.pointerId))W.releasePointerCapture(E.pointerId);return}let G=O.current;if(!a.current||!G)return;a.current=!1,O.current=null;let le=Math.min(G.startX,G.currentX),te=Math.max(G.startX,G.currentX),X=Math.min(G.startY,G.currentY),ee=Math.max(G.startY,G.currentY);if(te-le<=5&&ee-X<=5)Ce.value=null,mt();if(te-le>5||ee-X>5){let Q=oe.value,W=(le-Q.x)/Q.scale,se=(te-Q.x)/Q.scale,pt=(X-Q.y)/Q.scale,St=(ee-Q.y)/Q.scale,Gt=[];for(let z of R.value.values()){let de=z.position.x,Oe=z.position.y;if(de+z.size.width>W&&de<se&&Oe+z.size.height>pt&&Oe<St)Gt.push(z.id)}if(Gt.length>0)vf(Gt)}p(null)},[]);D(()=>{if(o)return;if(!l.current&&!m&&!y)return;l.current=!1,u.current=[],f(null),k(null)},[o,m,k,y]);let I=M(()=>{let E=x.current;if(!E)return;let G=E.value.trim();if(k(null),!G)return;let le={x:E.x,y:E.y};nl({type:"text",points:[le],color:kd,width:Rb,text:G})},[k]);D(()=>{if(r!=="text"&&y)k(null)},[r,k,y]),D(()=>{let E=(X,ee,Q)=>{let W=null;for(let se of R.value.values()){if(se.id===Q||se.type==="group")continue;if(X>=se.position.x&&X<=se.position.x+se.size.width&&ee>=se.position.y&&ee<=se.position.y+se.size.height)W=se.id}return W};function G(X){if(!je.value)return;let ee=_.current;if(!ee)return;let Q=ee.getBoundingClientRect(),W=oe.value,se=(X.clientX-Q.left-W.x)/W.scale,pt=(X.clientY-Q.top-W.y)/W.scale;je.value={...je.value,cursorX:se,cursorY:pt,targetId:E(se,pt,je.value.fromId)}}function le(){let X=je.value;if(!X)return;je.value=null;let ee=X.targetId;if(!ee)return;if(X.withLabel){sn("Edge label","label text").then((Q)=>{ao(X.fromId,ee,"relation",Q??void 0)});return}ao(X.fromId,ee,"relation",void 0)}function te(X){let ee=je.value;if(!ee)return;if(X.key==="Escape")X.preventDefault(),je.value=null;else if(X.key==="l"||X.key==="L")X.preventDefault(),je.value={...ee,withLabel:!ee.withLabel}}return document.addEventListener("pointermove",G),document.addEventListener("pointerup",le),document.addEventListener("keydown",te),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",le),document.removeEventListener("keydown",te)}},[_]);let H=M((E)=>{if(o)return;let G=_.current;if(!G||E.target!==G)return;let le=G.getBoundingClientRect(),te=oe.value,X=(E.clientX-le.left-te.x)/te.scale,ee=(E.clientY-le.top-te.y)/te.scale,Q=520,W=360;Mt({type:"markdown",title:"New note",x:X-Q/2,y:ee-W/2,width:Q,height:W})},[o,_]),U=M((E)=>{if(o)return;if(!n)return;let G=_.current;if(!G)return;if((E.target instanceof Element?E.target:null)?.closest(".canvas-node"))return;let te=G.getBoundingClientRect(),X=oe.value,ee=(E.clientX-te.left-X.x)/X.scale,Q=(E.clientY-te.top-X.y)/X.scale;n(E,ee,Q)},[o,_,n]),B=M((E)=>{if(Cd(E.target instanceof Element?E.target:null))return;E.preventDefault()},[]),q=M((E)=>{if(E.preventDefault(),b.current++,E.dataTransfer?.types.includes("Files")||fA(E.dataTransfer))g(!0)},[]),Y=M((E)=>{if(E.preventDefault(),E.dataTransfer)E.dataTransfer.dropEffect="copy"},[]),be=M((E)=>{if(E.preventDefault(),b.current--,b.current<=0)b.current=0,g(!1)},[]),Me=M(async(E)=>{E.preventDefault(),g(!1),b.current=0;let G=_.current;if(!G||!E.dataTransfer)return;let le=G.getBoundingClientRect(),te=oe.value,X=(E.clientX-le.left-te.x)/te.scale,ee=(E.clientY-le.top-te.y)/te.scale,Q=Array.from(E.dataTransfer.files);if(Q.length===0){let W=pA(E.dataTransfer);await T(W,X,ee);return}await Na(Q,X,ee)},[_,T]);D(()=>{let E=async(G)=>{if(G.defaultPrevented)return;if(Cd(G.target instanceof Element?G.target:null))return;if(Cd(document.activeElement))return;let le=G.clipboardData?.getData("text/plain")??"",te=Td(le);if(te.length===0)return;let X=_.current;if(!X)return;G.preventDefault();let ee=X.getBoundingClientRect(),Q=oe.value,W=(ee.width/2-Q.x)/Q.scale,se=(ee.height/2-Q.y)/Q.scale;await T(te,W,se)};return document.addEventListener("paste",E),()=>{document.removeEventListener("paste",E)}},[_,T]);let Pt=mA(R.value.values(),Be.value,new Set(Qc.value.keys())),ce=ln.value,Qn=ce?R.value.get(ce.groupId):void 0,qt=ce?R.value.get(ce.nodeId):void 0,Vt=null;if(d){let E=Math.min(d.startX,d.currentX),G=Math.min(d.startY,d.currentY),le=Math.abs(d.currentX-d.startX),te=Math.abs(d.currentY-d.startY);Vt={position:"absolute",left:`${E}px`,top:`${G}px`,width:`${le}px`,height:`${te}px`,pointerEvents:"none"}}return i("div",{class:`canvas-viewport${Ko()?" pan-mode":""}`,ref:_,tabIndex:0,onPointerDown:P,onPointerMove:Z,onPointerLeave:()=>{c.current=null,Va(null)},onPointerUp:j,onContextMenu:U,onDblClick:H,onDragStart:B,onDragEnter:q,onDragOver:Y,onDragLeave:be,onDrop:Me,style:{width:"100%",height:"100%",position:"relative",overflow:"hidden",cursor:r==="eraser"?"cell":r==="text"?"text":o||je.value||a.current||vt.value==="connect"?"crosshair":Ko()?"grab":"default"},children:[i("div",{ref:F,class:"canvas-world",style:{transform:`matrix(${s.scale}, 0, 0, ${s.scale}, ${s.x}, ${s.y})`,transformOrigin:"0 0",position:"absolute",top:0,left:0},children:[i(fx,{},void 0,!1,void 0,this),i(db,{},void 0,!1,void 0,this),i(Mx,{},void 0,!1,void 0,this),i(Ux,{},void 0,!1,void 0,this),i(Yx,{},void 0,!1,void 0,this),i(Ab,{nodes:R,edges:Re,onEdgeContextMenu:t},void 0,!1,void 0,this),je.value&&i("div",{class:"edge-hint-pill","data-testid":"edge-hint",style:{left:`${je.value.cursorX+14}px`,top:`${je.value.cursorY+14}px`},children:[i("span",{class:"edge-hint-main",children:je.value.targetId?"release to connect":"drag onto a node"},void 0,!1,void 0,this),i("span",{class:"edge-hint-keys",children:["esc cancels · L labels",je.value.withLabel?" · label on":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ce&&Qn&&qt&&i("div",{class:"drop-pill","data-testid":"drop-pill",style:{left:`${qt.position.x}px`,top:`${qt.position.y+qt.size.height+10}px`},children:[i("span",{class:"drop-pill-text",children:ce.mode==="add"?`release to add to ${String(Qn.data.title??"group")}`:`release to remove from ${String(Qn.data.title??"group")}`},void 0,!1,void 0,this),i("span",{class:"drop-pill-hint",children:ce.mode==="add"?"esc keeps it out":"esc keeps it in"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(Sd,{annotations:Array.from(Go.value.values())},void 0,!1,void 0,this),m&&m.points.length>=2&&i(Sd,{annotations:[m]},void 0,!1,void 0,this),Pt.map((E)=>i(Eb,{node:E,onContextMenu:e,children:aA(E)},E.id,!1,void 0,this)),Ao.value&&i("svg",{class:"snap-guides-svg",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:Ao.value.map((E,G)=>E.axis==="x"?i("line",{x1:E.pos,y1:E.from-20,x2:E.pos,y2:E.to+20,class:"snap-guide-line"},G,!1,void 0,this):i("line",{x1:E.from-20,y1:E.pos,x2:E.to+20,y2:E.pos,class:"snap-guide-line"},G,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&i("div",{class:`annotation-capture-layer${r==="eraser"?" erasing":""}${r==="text"?" text":""}`,"aria-hidden":"true"},void 0,!1,void 0,this),y&&i("input",{class:"annotation-text-input",value:y.value,autoFocus:!0,style:{left:`${y.x*s.scale+s.x}px`,top:`${y.y*s.scale+s.y}px`,fontSize:`${Rb*s.scale}px`},onInput:(E)=>k({...y,value:E.target.value}),onBlur:I,onPointerDown:(E)=>E.stopPropagation(),onKeyDown:(E)=>{if(E.key==="Enter")E.preventDefault(),I();if(E.key==="Escape")E.preventDefault(),k(null)}},void 0,!1,void 0,this),Vt&&i("div",{class:"lasso-rect",style:Vt},void 0,!1,void 0,this),h&&i("div",{class:"drop-zone-overlay",children:i("div",{class:"drop-zone-indicator",children:[i("div",{class:"drop-zone-icon",children:"+"},void 0,!1,void 0,this),i("div",{class:"drop-zone-label",children:"Drop files or URLs to add to canvas"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ob(){let e=[...Ee.value],t=R.value,[n,o]=L(""),[r,s]=L(!1),a=Zx.value,[c,l]=L(null),u=a.length>=2,d=!u&&a.length===1&&a[0].steerable?a[0]:null,p=u?c?a.find((y)=>y.value===c&&y.steerable)??null:null:d,m=p?.value??null,f=async()=>{let y=n.trim();if(!y||r)return;s(!0);let v=await cb(y,m);if(s(!1),v)o("")};return i("div",{class:"command-bar","data-testid":"command-bar",children:[e.length>0&&i("div",{class:"command-bar-chips","aria-label":"Pinned context",children:[e.map((y)=>{let v=t.get(y),x=typeof v?.data.title==="string"&&v.data.title.trim()?v.data.title:v?.type??y;return i("span",{class:"command-bar-chip","data-node-id":y,children:[i("span",{class:"command-bar-chip-glyph","aria-hidden":"true",children:"✦"},void 0,!1,void 0,this),i("span",{class:"command-bar-chip-label",title:x,children:x},void 0,!1,void 0,this),i("button",{type:"button",class:"command-bar-chip-unpin","aria-label":`Unpin ${x}`,title:"Remove from context",onClick:()=>Rn(y),children:"×"},void 0,!1,void 0,this)]},y,!0,void 0,this)}),i("span",{class:"command-bar-chips-note",children:"in agent context"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"command-bar-composer",children:[i(wr,{size:15,class:"command-bar-icon"},void 0,!1,void 0,this),u&&i("select",{class:"command-bar-target","aria-label":"Steer which agent",title:"Connected agents — steering reaches all of them unless you address one",value:m??"",onChange:(y)=>l(y.target.value||null),children:[i("option",{value:"",children:"All agents"},void 0,!1,void 0,this),a.map((y)=>{let v=y.pendingSteers&&y.pendingSteers>0?` · ${y.pendingSteers} queued`:"",x=y.polling?" · polling":"";return i("option",{value:y.value,disabled:!y.steerable,children:y.attached?`${y.label}${x}${v}`:y.steerable?`${y.label} · writer${x}${v}`:`${y.label} · no inbox`},y.value,!1,void 0,this)})]},void 0,!0,void 0,this),i("input",{class:"command-bar-input",type:"text",value:n,placeholder:`Steer ${p?.label??"the agent"}, or ${Ze("K")} to search the board…`,"aria-label":"Steer the agent",disabled:r,onInput:(y)=>o(y.target.value),onKeyDown:(y)=>{if(y.key==="Enter")y.preventDefault(),f()}},void 0,!1,void 0,this),i("button",{type:"button",class:"command-bar-send",disabled:r||!n.trim(),onClick:()=>void f(),children:r?"Sending…":"Send"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Ed=Le(()=>{if(Tt.value==="disconnected")return"reconnecting";if(Tt.value==="connected"&&!Ut.value&&lo.value>1)return"resyncing";return null});function Lb(){let e=Ed.value;if(!e)return null;if(e==="reconnecting"){let t=uo.value,n=po.value;return i("div",{class:"connection-banner is-reconnecting",role:"status","data-testid":"connection-banner",children:[i("span",{class:"connection-banner-glyph","aria-hidden":"true",children:"↻"},void 0,!1,void 0,this),i("span",{class:"connection-banner-text",children:[i("b",{children:"Reconnecting…"},void 0,!1,void 0,this)," live updates are paused; edits still save, the board may be stale until the stream returns."]},void 0,!0,void 0,this),i("span",{class:"connection-banner-meta",children:[t>0?`retry ${t}`:"retrying",n>0?` · ${Math.max(1,Math.round(n/1000))}s`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}return i("div",{class:"connection-banner is-resyncing",role:"status","data-testid":"connection-banner",children:[i("span",{class:"connection-banner-glyph","aria-hidden":"true",children:"⟳"},void 0,!1,void 0,this),i("span",{class:"connection-banner-text",children:[i("b",{children:"Resyncing from snapshot"},void 0,!1,void 0,this)," — the event cursor went stale; the board reloads without losing local edits."]},void 0,!0,void 0,this),i("span",{class:"connection-banner-progress","aria-hidden":"true",children:i("span",{class:"connection-banner-progress-fill"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var hA={markdown:{width:520,height:360},group:{width:600,height:400},html:{width:720,height:640},image:{width:720,height:520},file:{width:720,height:600},webpage:{width:520,height:420}};async function zt(e){if(e.x!==void 0&&e.y!==void 0)return Mt(e);let t=hA[e.type]??{width:360,height:200},n=e.width??t.width,o=e.height??t.height,r=jo(),s=oe.value,a=await Mt({...e,width:n,height:o,x:Math.round((r.x-s.x)/s.scale-n/2),y:Math.round((r.y-s.y)/s.scale-o/2)});if(a.ok&&a.id)et(a.id);return a}var nc=!1,Db=!1,Io=null,Ar=null;function Ad(){return nc}function oc(){nc=!1,Db=!0,Fb()}function Fb(){if(Io&&Ar)Io.removeEventListener("change",Ar);Io=null,Ar=null}function gA(){if(typeof window>"u"||!window.location)return null;let e=new URLSearchParams(window.location.search).get("theme");if(e==="auto")return"auto";return Kr(e)?e:null}function jb(e){if(Db)return;let t=gA();if(!t)return;if(Fb(),nc=!0,t!=="auto"){e(t);return}Io=window.matchMedia("(prefers-color-scheme: light)"),Ar=()=>{if(nc&&Io)e(Io.matches?"light":"dark")},Ar(),Io.addEventListener("change",Ar)}var vA='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ir(e,t,n={}){D(()=>{if(!t)return;let o=e.current;if(!o)return;let r=document.activeElement,s=n.restoreTo,a=()=>Array.from(o.querySelectorAll(vA)),c=n.initial?.current??a()[0];if(c&&!o.contains(document.activeElement))c.focus();let l=(u)=>{if(u.key!=="Tab")return;let d=a();if(d.length===0)return;let p=d[0],m=d[d.length-1],f=document.activeElement;if(u.shiftKey&&(f===p||!o.contains(f)))u.preventDefault(),m.focus();else if(!u.shiftKey&&f===m)u.preventDefault(),p.focus()};return o.addEventListener("keydown",l),()=>{if(o.removeEventListener("keydown",l),s)requestAnimationFrame(()=>s()?.focus());else if(r&&document.contains(r)&&r!==document.body)r.focus()}},[e,t,n.initial,n.restoreTo])}function yA(e,t){let n=e.toLowerCase(),o=t.toLowerCase(),r=[],s=0,a=0,c=-1;for(let l=0;l<o.length&&s<n.length;l++)if(o[l]===n[s]){if(r.push(l),a+=c===l-1?10:1,l===0||o[l-1]===" "||o[l-1]==="-"||o[l-1]==="_")a+=5;c=l,s++}return{match:s===n.length,score:a,indices:r}}function xA(e,t){if(t.length===0)return e;let n=[],o=0;for(let r of t){if(r>o)n.push(e.slice(o,r));n.push(i("mark",{children:e[r]},r,!1,void 0,this)),o=r+1}if(o<e.length)n.push(e.slice(o));return n}var Id={md:"markdown",app:"mcp-app",web:"webpage",ui:"json-render",chart:"graph",ctx:"context",log:"ledger"};function bA(e){let t=e.toLowerCase().trim();if(t.startsWith("type:")){let n=t.slice(5).trim(),r=Object.keys(ot).find((a)=>a.startsWith(n));if(r)return{typeFilter:r,remaining:""};let s=Id[n];if(s)return{typeFilter:s,remaining:""}}if(Id[t])return{typeFilter:Id[t],remaining:""};return{typeFilter:null,remaining:e}}function Zb({onClose:e,onToggleMinimap:t}){let[n,o]=L(""),[r,s]=L(0),a=N(null),c=N(null),l=N(null);Ir(l,!0,{initial:a}),D(()=>{setTimeout(()=>a.current?.focus(),30)},[]);let u=M(()=>{let h=[];for(let b of R.value.values()){let O=b.data.title||ot[b.type],F=b.data.content||b.data.path||"",_=b.type==="group"&&Array.isArray(b.data.children)?b.data.children.length:0;h.push({id:`node:${b.id}`,kind:"node",label:O,description:b.type==="group"?`group · ${_} node${_===1?"":"s"}`:F.length>60?`${ot[b.type].toLowerCase()} · ${F.slice(0,60)}…`:F?`${ot[b.type].toLowerCase()} · ${F}`:ot[b.type].toLowerCase(),icon:yn(b.type),nodeType:b.type,action:()=>{et(b.id),e()}})}let g=[{label:"New markdown note",shortcut:"M",icon:Bn,iconTone:"accent",action:()=>{zt({type:"markdown",title:"New note",width:520,height:360}),e()}},...dt.value?[]:[{label:"Start agent session",icon:wr,iconTone:"purple",action:()=>{Gn(),e()}}],{label:"Fit view",shortcut:"F",icon:Ma,iconTone:"muted",action:()=>{tr(bt().width,bt().height),e()}},{label:"Auto-arrange (grid)",icon:So,iconTone:"muted",action:()=>{Ss(),e()}},{label:"Auto-arrange (graph-aware)",icon:So,iconTone:"muted",action:()=>{ks(),e()}},{label:"Toggle minimap",icon:Oa,iconTone:"muted",action:()=>{t(),e()}},{label:"Toggle theme (dark/light)",icon:La,iconTone:"muted",action:()=>{let b=Ge.value==="dark"?"light":"dark";oc(),document.documentElement.setAttribute("data-theme",b),gr(),Ge.value=b,is(b),e()}}];for(let b of g)h.push({id:`action:${b.label}`,kind:"action",label:b.label,...b.shortcut?{shortcut:b.shortcut}:{},icon:b.icon,...b.iconTone?{iconTone:b.iconTone}:{},action:b.action});return h},[e,t]),{typeFilter:d,remaining:p}=bA(n),m=u(),f;if(!n.trim())f=m.map((h)=>({...h,score:0,indices:[]}));else{f=[];for(let h of m){if(d){if(h.kind!=="node"||h.nodeType!==d)continue;if(!p){f.push({...h,score:0,indices:[]});continue}}let g=yA(p||n,h.label);if(g.match)f.push({...h,score:g.score,indices:g.indices})}f.sort((h,g)=>g.score-h.score)}f=[...f.filter((h)=>h.kind==="action"),...f.filter((h)=>h.kind==="node")];let y=f.findIndex((h)=>h.kind==="node");D(()=>{if(!n.trim()){Nn.value=null;return}let h=new Set;for(let g of f)if(g.kind==="node")h.add(g.id.slice(5));Nn.value=h.size>0?h:null},[n,f]),D(()=>()=>{Nn.value=null},[]);let v=Math.min(r,Math.max(0,f.length-1)),x=M((h)=>{if(h.key==="ArrowDown")h.preventDefault(),s((g)=>Math.min(g+1,f.length-1));else if(h.key==="ArrowUp")h.preventDefault(),s((g)=>Math.max(g-1,0));else if(h.key==="Enter"){if(h.preventDefault(),f[v])f[v].action()}else if(h.key==="Escape")h.preventDefault(),h.stopPropagation(),e()},[f,v,e]);return D(()=>{let h=c.current;if(!h)return;h.children[v]?.scrollIntoView({block:"nearest"})},[v]),D(()=>{s(0)},[n]),i("div",{class:"command-palette-backdrop",onMouseDown:e,children:i("div",{ref:l,class:"command-palette",role:"dialog","aria-modal":"true","aria-label":"Search and commands",onMouseDown:(h)=>h.stopPropagation(),children:[i("div",{class:"command-palette-search",children:[i("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[i("circle",{cx:"7",cy:"7",r:"4.5"},void 0,!1,void 0,this),i("line",{x1:"10.5",y1:"10.5",x2:"14.5",y2:"14.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("input",{ref:a,type:"text",class:"command-palette-input",value:n,onInput:(h)=>o(h.target.value),onKeyDown:x,placeholder:"Search nodes, run actions, jump to…","aria-label":"Search nodes, run actions, jump to"},void 0,!1,void 0,this),i("kbd",{class:"command-palette-esc",children:"esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"command-palette-results",ref:c,children:[f.length===0&&i("div",{class:"command-palette-empty",children:"No matching nodes or actions"},void 0,!1,void 0,this),f.map((h,g)=>{let b=h.icon,O=g===0&&h.kind==="action"?"Actions":g===y?"Jump to":null;return i("div",{class:"command-palette-row",children:[O&&i("div",{class:"command-palette-group",children:O},void 0,!1,void 0,this),i("button",{type:"button",class:`command-palette-item${g===v?" selected":""}`,onMouseEnter:()=>s(g),onClick:()=>h.action(),children:[i("span",{class:`command-palette-icon tone-${h.iconTone??"kind"}`,"aria-hidden":"true",children:i(b,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"command-palette-label",children:[h.indices.length>0?xA(h.label,h.indices):h.label,h.description&&i("span",{class:"command-palette-desc",children:[" — ",h.description]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h.shortcut&&i("kbd",{class:"command-palette-kbd",children:h.shortcut},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},h.id,!0,void 0,this)})]},void 0,!0,void 0,this),i("div",{class:"command-palette-hint",children:[i("span",{children:"↑↓ navigate"},void 0,!1,void 0,this),i("span",{children:"↵ open"},void 0,!1,void 0,this),i("span",{children:"esc close"},void 0,!1,void 0,this),i("span",{children:"type: filter"},void 0,!1,void 0,this),i("span",{class:"command-palette-hint-spacer"},void 0,!1,void 0,this),i("span",{children:Ze("K")},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Hb(){let[e,t]=L(null),n=M((a,c)=>{a.preventDefault(),a.stopPropagation(),t({kind:"node",x:a.clientX,y:a.clientY,nodeId:c})},[]),o=M((a,c,l)=>{a.preventDefault(),a.stopPropagation(),t({kind:"canvas",x:a.clientX,y:a.clientY,canvasX:c,canvasY:l})},[]),r=M((a,c)=>{a.preventDefault(),a.stopPropagation(),t({kind:"edge",x:a.clientX,y:a.clientY,edgeId:c})},[]),s=M(()=>t(null),[]);return D(()=>{if(!e)return;let a=()=>t(null),c=(l)=>{if(l.key==="Escape")t(null)};return document.addEventListener("click",a),document.addEventListener("keydown",c),()=>{document.removeEventListener("click",a),document.removeEventListener("keydown",c)}},[e]),{menu:e,openNodeMenu:n,openCanvasMenu:o,openEdgeMenu:r,closeMenu:s}}var wA="#4bbcFF",_A=[{label:"Blue",value:"#3b82f6"},{label:"Green",value:"#22c55e"},{label:"Yellow",value:"#eab308"},{label:"Red",value:"#ef4444"},{label:"Gray",value:"#6b7280"},{label:"Purple",value:"#a855f7"}];function Bb({menu:e,onClose:t}){let n;if(e.kind==="node"){let c=R.value.get(e.nodeId);if(!c)return null;n=AA(c)}else if(e.kind==="edge"){let c=e.edgeId,l=Re.value.get(c);n=[{label:l?.label?`Edit label “${l.label.slice(0,18)}${l.label.length>18?"…":""}”`:"Add label…",action:()=>{sn("Edge label (empty clears it)","label text",{initial:l?.label??"",allowEmpty:!0,confirm:"Save"}).then((u)=>{if(u===null)return;ls(c,{label:u})})}},{separator:!0},...["flow","depends-on","relation","references"].map((u)=>({label:`${l?.type===u?"✓":" "} ${u}`,action:()=>void ls(c,{type:u})})),{separator:!0},...["solid","dashed","dotted"].map((u)=>({label:`${(l?.style??"solid")===u?"✓":" "} ${u}`,action:()=>void ls(c,{style:u})})),{separator:!0},{label:"Delete edge",danger:!0,action:()=>void us(c)}]}else n=EA(e.canvasX,e.canvasY);let o=new Map,r=n.some((c)=>c.render)?n.length*32+168:n.length*32+8,s=Math.min(e.x,Math.max(12,window.innerWidth-240)),a=Math.min(e.y,Math.max(12,window.innerHeight-r));return i("div",{class:"context-menu",style:{position:"fixed",left:`${s}px`,top:`${a}px`,zIndex:1e4},onPointerDown:(c)=>c.stopPropagation(),onClick:(c)=>c.stopPropagation(),children:n.map((c)=>{let l=c.separator?"separator":c.render?"custom":`${c.label??"item"}:${c.shortcut??""}`,u=(o.get(l)??0)+1;o.set(l,u);let d=`${l}:${u}`;if(c.separator)return i("div",{class:"context-menu-separator"},d,!1,void 0,this);if(c.render)return i("div",{class:"context-menu-custom",children:c.render(t)},d,!1,void 0,this);return i("button",{type:"button",class:`context-menu-item${c.danger?" is-danger":""}`,onClick:()=>{c.action?.(),t()},children:[i("span",{class:"context-menu-label",children:c.label},void 0,!1,void 0,this),c.shortcut&&i("span",{class:"context-menu-shortcut",children:c.shortcut},void 0,!1,void 0,this)]},d,!0,void 0,this)})},void 0,!1,void 0,this)}function SA(e){return(typeof e.data.path==="string"?e.data.path.trim():"")||null}function rc(e){let t=e.trim().toLowerCase(),n=t.match(/^#([0-9a-f]{3})$/);if(n){let[o,r,s]=n[1].split("");return`#${o}${o}${r}${r}${s}${s}`}return t}function Ub(e){if(typeof e.data.color!=="string"||!e.data.color.trim())return null;return rc(e.data.color)}function kA(e){let t=Ub(e);return t&&/^#[0-9a-f]{6}$/.test(t)?t:rc(wA)}function zd(e,t){let n=t?rc(t):null;rt(e.id,{data:{...e.data,color:n}}),ft(e.id,{data:{color:n}})}function CA(e,t){let n=Ub(e);return i("div",{class:"context-menu-section",children:[i("div",{class:"context-menu-section-header",children:[i("span",{class:"context-menu-section-label",children:"Group color"},void 0,!1,void 0,this),i("button",{type:"button",class:"context-menu-reset",onClick:()=>{zd(e,null),t()},children:"Theme default"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"context-menu-color-grid",children:_A.map((o)=>{let r=rc(o.value);return i("button",{type:"button",class:`context-menu-color-swatch${n===r?" active":""}`,"aria-label":`Set group color to ${o.label}`,title:o.label,style:{"--swatch-color":o.value},onClick:()=>{zd(e,o.value),t()},children:[i("span",{class:"context-menu-color-dot",style:{"--swatch-color":o.value}},void 0,!1,void 0,this),i("span",{children:o.label},void 0,!1,void 0,this)]},o.value,!0,void 0,this)})},void 0,!1,void 0,this),i("label",{class:"context-menu-color-custom",children:[i("span",{children:"Custom"},void 0,!1,void 0,this),i("input",{type:"color",class:"context-menu-color-input","aria-label":"Custom group color",value:kA(e),onClick:(o)=>o.stopPropagation(),onInput:(o)=>{zd(e,o.currentTarget.value),t()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Nd(e,t,n,o){return{x:e-n/2,y:t-o/2}}function TA(e,t){return e.trim().replace(/[?#].*$/,"").split("/").filter(Boolean).at(-1)||t}async function Pd(e){let t=await sn(e.promptLabel,e.placeholder??"");if(!t)return;let n=t.trim();if(!n)return;let o=Nd(e.canvasX,e.canvasY,e.width,e.height);if(!(await Mt({type:e.type,...e.type!=="webpage"?{title:TA(n,e.titleFallback)}:{},content:n,x:o.x,y:o.y,width:e.width,height:e.height})).ok)console.error(`[canvas-menu] ${e.errorMessage}`)}function EA(e,t){return[{label:"New note",action:()=>{let r=Nd(e,t,520,360);Mt({type:"markdown",title:"New note",x:r.x,y:r.y,width:520,height:360})}},{label:"Open webpage...",action:()=>{Pd({promptLabel:"Webpage URL:",type:"webpage",canvasX:e,canvasY:t,width:520,height:420,placeholder:"https://example.com",titleFallback:"Webpage",errorMessage:"Could not create webpage node. Enter a valid http(s) URL."})}},{label:"Open file...",action:()=>{Pd({promptLabel:"Workspace path or absolute file path:",type:"file",canvasX:e,canvasY:t,width:720,height:500,placeholder:"src/server/server.ts",titleFallback:"File",errorMessage:"Could not create file node. Check the path and try again."})}},{label:"Open image...",action:()=>{Pd({promptLabel:"Image path, URL, or data URI:",type:"image",canvasX:e,canvasY:t,width:480,height:360,placeholder:"artifacts/architecture.png",titleFallback:"Image",errorMessage:"Could not create image node. Check the image source and try again."})}},{separator:!0},{label:"New group",action:()=>{let r=Nd(e,t,600,400);Zo({title:"Group",x:r.x,y:r.y,width:600,height:400})}}]}function AA(e){let t=[],n=SA(e);if(t.push({label:"Focus",action:()=>et(e.id)}),Zr.has(e.type))t.push({label:"Expand",shortcut:"⤢",action:()=>Qt(e.id)});t.push({label:e.collapsed?"Expand":"Collapse",action:()=>Yo(e.id)});let o=Ee.value.has(e.id);t.push({label:o?"Unpin from context":"Pin as context",action:()=>Rn(e.id)}),t.push({label:e.pinned?"Unlock position":"Lock position (no auto-arrange)",action:()=>{let l=!e.pinned;rt(e.id,{pinned:l}),ft(e.id,{pinned:l}),Je()}});let r=vs.value;if(r&&r.from!==e.id){let l=R.value.get(r.from),u=l?(l.data.title||l.id).slice(0,20):r.from;t.push({label:`Connect from "${u}"`,action:()=>{ao(r.from,e.id,"relation"),vs.value=null}})}t.push({label:r?"Connect from here (replace)":"Connect from here",action:()=>{vs.value={from:e.id}}});let s=Array.from(Re.value.values()).filter((l)=>l.from===e.id||l.to===e.id).length;if(s>0)t.push({label:`${s} edge${s!==1?"s":""} connected`});if(t.push({separator:!0}),(e.type==="markdown"||e.type==="file"||e.type==="image")&&n)t.push({label:"Open in browser",action:()=>{window.open(`/artifact?path=${encodeURIComponent(n)}`,"_blank","noopener")}}),t.push({label:"Copy path",action:()=>{navigator.clipboard.writeText(n)}});if(e.type==="mcp-app"||e.type==="json-render"||e.type==="graph")if(e.data.chartConfig){let l=e.data.chartConfig.title||"chart";t.push({label:"Copy chart data",action:()=>{navigator.clipboard.writeText(JSON.stringify(e.data.chartConfig,null,2))}})}else{let l=e.data.url;if(t.push({label:"Open in browser",action:()=>{if(l)window.open(l,"_blank")}}),t.push({label:"Focus in TUI",action:()=>Op("mcp-app-focus",{url:l})}),e.type==="json-render"||e.type==="graph")t.push({label:"Copy spec",action:()=>{navigator.clipboard.writeText(JSON.stringify(e.data.spec??e.data.graphConfig??{},null,2))}})}if(e.type==="webpage"){let l=typeof e.data.url==="string"?e.data.url:"";t.push({label:"Refresh webpage",action:()=>{ss(e.id)}}),t.push({label:"Open in browser",action:()=>{if(l)window.open(l,"_blank","noopener")}}),t.push({label:"Copy URL",action:()=>{if(l)navigator.clipboard.writeText(l)}})}if(e.type==="group"){let l=e.data.children??[];if(t.push({separator:!0}),t.push({render:(u)=>CA(e,u)}),l.length>0)t.push({label:`Ungroup (${l.length} node${l.length!==1?"s":""})`,action:()=>{Et(e.id),Ho(e.id)}})}let a=typeof e.data.parentGroup==="string"?e.data.parentGroup:null,c=a?R.value.get(a):void 0;if(c&&c.type==="group"){let l=typeof c.data.title==="string"&&c.data.title?c.data.title:"frame",u=Array.isArray(c.data.children)?c.data.children.filter((d)=>d!==e.id):[];t.push({label:`Remove from “${l}”`,action:()=>{cs(c.id,u)}})}return t.push({separator:!0}),t.push({label:e.type==="group"?"Delete frame (children stay)":"Delete",danger:!0,action:()=>{Et(e.id),An(e.id)}}),t}function Wb(){let e=Ee.value.size;if(e===0||Jt.value)return null;return i("div",{class:"context-pin-bar",children:[i("span",{class:"context-pin-bar-count",children:["✦"," ",e," node",e!==1?"s":""," in context"]},void 0,!0,void 0,this),i("button",{type:"button",class:"context-pin-bar-btn context-pin-bar-clear",onClick:kf,title:"Clear all context pins",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ti(e,t){console.error(`[tool-rail] ${e} failed`,t)}function wn(e){let t={image:{message:"Image URL (https://… or data:image/…)",placeholder:"https://example.com/diagram.png"},file:{message:"Workspace file path",placeholder:"src/server/server.ts"},webpage:{message:"Page URL",placeholder:"https://example.com"}};sn(t[e].message,t[e].placeholder).then((n)=>{if(!n)return;zt({type:e,content:n}).catch((o)=>Ti(`create ${e}`,o))})}function nt({label:e,shortcut:t,detail:n,ariaLabel:o,active:r,menuOpen:s,onClick:a,btnRef:c,children:l}){let[u,d]=L(null),p=(y)=>{let v=y.currentTarget.getBoundingClientRect();d({left:v.right+10,top:v.top+v.height/2})},m=()=>d(null),f=o??(t?`${e} (${t})`:n?`${e} (${n})`:e);return i(ye,{children:[i("button",{ref:c,type:"button",class:`rail-btn${r?" active":""}`,"aria-label":f,"aria-pressed":r===void 0?void 0:r,onClick:(y)=>{m(),a(y)},onPointerEnter:p,onPointerLeave:m,onFocus:p,onBlur:m,children:l},void 0,!1,void 0,this),u&&!s&&i("span",{class:"toolbar-tooltip rail-tooltip",role:"tooltip","data-testid":"rail-tooltip",style:{left:`${u.left}px`,top:`${u.top}px`},children:[i("span",{class:"toolbar-tooltip-label",children:e},void 0,!1,void 0,this),(t||n)&&i("span",{class:"toolbar-tooltip-meta",children:[t&&i("kbd",{class:"toolbar-tooltip-shortcut",children:t},void 0,!1,void 0,this),n&&i("span",{children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qb({minimapVisible:e,onToggleMinimap:t,snapshotOpen:n,onToggleSnapshot:o,snapshotBtnRef:r,onOpenPalette:s,onOpenShortcuts:a,annotationTool:c,onSetAnnotationTool:l}){let u=vt.value,d=Xo.value,p=Array.from(R.value.values()).filter((k)=>k.type==="trace").length,m=Re.value.size,[f,y]=L(null),[v,x]=L(null),h=N(null),g=(k)=>(T)=>{if(f===k){y(null);return}let P=T.currentTarget.getBoundingClientRect();x({top:P.top,bottom:P.bottom,right:P.right}),y(k)},b=(k)=>v?k?{position:"fixed",left:`${v.right+8}px`,bottom:`${window.innerHeight-v.bottom}px`,top:"auto",right:"auto"}:{position:"fixed",left:`${v.right+8}px`,top:`${v.top}px`,right:"auto"}:void 0;D(()=>{if(!f)return;let k=(P)=>{if(h.current&&P.target instanceof Node&&!h.current.contains(P.target))y(null)},T=(P)=>{if(P.key==="Escape")y(null)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",T),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",T)}},[f]);let O=(k)=>{oc(),document.documentElement.setAttribute("data-theme",k),gr(),Ge.value=k,is(k),y(null)},F=Tl(Ge.value),_=(k,T={})=>{fetch(`/api/workbench/intent?_ts=${Date.now()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:k,payload:T})}).catch((P)=>Ti("sendIntent",P))};return i("div",{class:"tool-rail",ref:h,role:"toolbar","aria-label":"Canvas tools","aria-orientation":"vertical",children:[i("span",{class:"rail-brand",title:"PMX Canvas","aria-label":"PMX Canvas",children:i(Ex,{size:22},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("div",{class:"rail-divider"},void 0,!1,void 0,this),i(nt,{label:"Select",shortcut:"V",active:u==="select",onClick:()=>vt.value="select",children:i(Ax,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Pan",shortcut:"Space",active:u==="pan",onClick:()=>vt.value="pan",children:i(Ix,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Connect",shortcut:"C",active:u==="connect",onClick:()=>vt.value="connect",children:i("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[i("circle",{cx:"4",cy:"4",r:"2"},void 0,!1,void 0,this),i("circle",{cx:"12",cy:"12",r:"2"},void 0,!1,void 0,this),i("path",{d:"M5.5 5.5 C 8 8, 8 8, 10.5 10.5"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i("div",{class:"rail-divider"},void 0,!1,void 0,this),i(nt,{label:"Markdown note",shortcut:"M",onClick:()=>void zt({type:"markdown",title:"New note",width:520,height:360}).catch((k)=>Ti("create markdown",k)),children:i(Bn,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Image",shortcut:"I",onClick:()=>wn("image"),children:i(rd,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"File",shortcut:"Shift+F",onClick:()=>wn("file"),children:i($a,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Webpage",shortcut:"W",onClick:()=>wn("webpage"),children:i(br,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"HTML surface",shortcut:"H",onClick:()=>void zt({type:"html",title:"HTML surface"}).catch((k)=>Ti("create html",k)),children:i(zx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Group",shortcut:"G",onClick:()=>void zt({type:"group",title:"Group"}).catch((k)=>Ti("create group",k)),children:i(id,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"toolbar-menu-anchor",children:[i(nt,{label:"Annotate",shortcut:"A",detail:"Draw · Text note · Eraser",active:c!==null,menuOpen:f==="annotate",onClick:g("annotate"),children:c==="eraser"?i(nd,{},void 0,!1,void 0,this):c==="text"?i(od,{},void 0,!1,void 0,this):i(td,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),f==="annotate"&&i("div",{class:"toolbar-menu",style:b(!1),role:"menu","aria-label":"Annotate",children:[i("button",{type:"button",class:`toolbar-menu-item${c==="pen"?" active":""}`,onClick:()=>{l(c==="pen"?null:"pen"),y(null)},children:[i(td,{},void 0,!1,void 0,this),i("span",{children:c==="pen"?"Stop annotating":"Draw (A)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:`toolbar-menu-item${c==="text"?" active":""}`,onClick:()=>{l(c==="text"?null:"text"),y(null)},children:[i(od,{},void 0,!1,void 0,this),i("span",{children:c==="text"?"Stop text notes":"Text note"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:`toolbar-menu-item${c==="eraser"?" active":""}`,onClick:()=>{l(c==="eraser"?null:"eraser"),y(null)},children:[i(nd,{},void 0,!1,void 0,this),i("span",{children:c==="eraser"?"Stop erasing":"Eraser"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"rail-spacer"},void 0,!1,void 0,this),i(nt,{label:"Search & commands",shortcut:Ze("K"),onClick:s,children:i(Cx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Arrange",detail:m>0?"graph-aware":"grid",onClick:()=>m>0?ks():Ss(),children:i(So,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:d?"Disable trace":"Enable trace",active:d,onClick:()=>_("trace-toggle",{enabled:!d}),children:i(Sx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),(d||p>0)&&i(nt,{label:"Clear trace",onClick:()=>_("trace-clear"),children:i(kx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:e?"Hide minimap":"Show minimap",active:e,onClick:t,children:i(Oa,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(nt,{label:"Snapshots",active:n,onClick:o,btnRef:r,children:i(_x,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"toolbar-menu-anchor",children:[i(nt,{label:"Theme",detail:sr[F].label,menuOpen:f==="theme",ariaLabel:"Choose theme",active:f==="theme",onClick:g("theme"),children:ar(F)==="dark"?i(wx,{},void 0,!1,void 0,this):i(La,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),f==="theme"&&i("div",{class:"toolbar-menu",style:b(!0),role:"menu","aria-label":"Theme",children:Cl.map((k)=>i("button",{type:"button",role:"menuitemradio","aria-checked":F===k,class:`toolbar-menu-item${F===k?" active":""}`,onClick:()=>O(k),children:[i("span",{class:"theme-swatch",style:{background:sr[k].swatchBg},children:i("span",{class:"theme-swatch-dot",style:{background:sr[k].swatchAccent}},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{children:sr[k].label},void 0,!1,void 0,this),F===k&&i("span",{class:"toolbar-menu-check","aria-hidden":"true",children:"✓"},void 0,!1,void 0,this)]},k,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(nt,{label:"Shortcuts",shortcut:"?",onClick:a,children:i(Tx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vb({onOpenPalette:e}){let t=N(null),n=()=>{zt({type:"markdown",title:"New note",width:520,height:360}).catch(()=>{})},o=async(r)=>{if(!r||r.length===0)return;let s=jo(),a=oe.value;await Na(Array.from(r),(s.x-a.x)/a.scale,(s.y-a.y)/a.scale)};return i("div",{class:"empty-state","data-testid":"empty-state",children:[i("svg",{class:"empty-state-mark",width:"52",height:"52",viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[i("rect",{x:"8",y:"8",width:"48",height:"48",rx:"7"},void 0,!1,void 0,this),i("rect",{x:"20",y:"20",width:"24",height:"24",rx:"4","stroke-dasharray":"4 4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{children:[i("div",{class:"empty-state-title",children:"Nothing on this board yet"},void 0,!1,void 0,this),i("div",{class:"empty-state-sub",children:"Drop files anywhere, paste a link, or start from a note."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"empty-state-grid",children:[i("button",{type:"button",class:"empty-state-action",onClick:n,children:[i(Bn,{size:16,class:"tone-accent"},void 0,!1,void 0,this),i("span",{class:"empty-state-action-label",children:"New markdown note"},void 0,!1,void 0,this),i("kbd",{children:"M"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"empty-state-action",onClick:()=>t.current?.click(),children:[i("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",class:"tone-warn","aria-hidden":"true",children:[i("path",{d:"M8 10 V2 M8 2 L5 5 M8 2 L11 5"},void 0,!1,void 0,this),i("path",{d:"M2 10 V13 H14 V10"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"empty-state-action-label",children:"Drop files"},void 0,!1,void 0,this),i("span",{class:"empty-state-action-hint",children:"or pick"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"empty-state-action",onClick:()=>wn("webpage"),children:[i(br,{size:16,class:"tone-ok"},void 0,!1,void 0,this),i("span",{class:"empty-state-action-label",children:"Paste a link"},void 0,!1,void 0,this),i("kbd",{children:Ze("V")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"empty-state-action is-agent",onClick:()=>void Gn(),children:[i(wr,{size:16,class:"tone-purple"},void 0,!1,void 0,this),i("span",{class:"empty-state-action-label",children:"Start agent session"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"empty-state-hint",onClick:e,children:["? shortcuts · ",Ze("K")," palette"]},void 0,!0,void 0,this),i("input",{ref:t,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:(r)=>{let s=r.currentTarget;o(s.files).finally(()=>{s.value=""})}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rd({presence:e,size:t=18}){return i("span",{class:"writer-avatar",style:{background:Fa(e.sessionId),width:`${t}px`,height:`${t}px`},"aria-hidden":"true",children:jx(e.label)},void 0,!1,void 0,this)}function Gb(){let e=pd.value;if(dt.value||e.length===0)return null;let t=e.reduce((r,s)=>r+s.opCount,0),n=e.length===1?e[0].label:`${e.length} writers`,o=ko.value;return i("button",{type:"button",class:"external-indicator","data-testid":"external-indicator","aria-expanded":o,title:`${e.length} external writer${e.length===1?"":"s"} on this board — click for activity`,onClick:()=>{ko.value=!o},children:[i("span",{class:"external-indicator-avatars",children:e.slice(0,3).map((r)=>i(Rd,{presence:r},r.sessionId,!1,void 0,this))},void 0,!1,void 0,this),i("span",{class:"external-indicator-label",children:n},void 0,!1,void 0,this),i("span",{class:"external-indicator-ops hud-collapsible-text",children:[t," op",t===1?"":"s"]},void 0,!0,void 0,this),i("span",{class:"external-indicator-dot","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function IA(e){if(e==="node.add"||e==="jsonrender.add"||e==="graph.add"||e==="group.create")return{glyph:"+",tone:"ok"};if(e==="node.remove"||e==="edge.remove"||e==="canvas.clear")return{glyph:"×",tone:"danger"};if(e==="edge.add")return{glyph:"⟶",tone:"accent"};if(e.startsWith("ax."))return{glyph:"◆",tone:"purple"};return{glyph:"✎",tone:"accent"}}function zA(e){return e.reduce((t,n)=>n.lastSeenAt>t?n.lastSeenAt:t,"")}function PA(){return[...qe.value.values()].filter((e)=>!e.auto&&e.phase==="forming")}function Xb(){let e=ko.value,t=pd.value,n=bn(e?1e4:0);if(D(()=>{if(!e)return;let c=(l)=>{if(l.key!=="Escape")return;if(Sr.value)Sr.value=!1;else ko.value=!1};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e]),!e||dt.value||t.length===0)return null;let o=dd.value,r=PA().filter((c)=>!o||(c.source??"")===o),s=Wn.value.filter((c)=>!o||c.sessionId===o),a=(c,l)=>i("button",{type:"button",class:`activity-filter${o===c?" is-active":""}`,style:c?{"--writer":Fa(c)}:void 0,"aria-pressed":o===c,onClick:()=>{dd.value=c},children:l},void 0,!1,void 0,this);return i("div",{class:"activity-feed","data-testid":"activity-feed",role:"dialog","aria-label":"External activity",children:[i("div",{class:"activity-feed-head",children:[i("span",{class:"external-indicator-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("div",{class:"activity-feed-titles",children:[i("div",{class:"activity-feed-title",children:["External activity — ",t.length," writer",t.length===1?"":"s"]},void 0,!0,void 0,this),i("div",{class:"activity-feed-sub",children:[t.reduce((c,l)=>c+l.opCount,0)," writes · last"," ",ja(zA(t),n)," · no session attached"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"activity-feed-close","aria-label":"Close activity feed",onClick:()=>{ko.value=!1},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"activity-filters",children:[a(null,"All"),t.map((c)=>a(c.sessionId,c.label))]},void 0,!0,void 0,this),i("div",{class:"activity-rows",children:[r.map((c)=>i("div",{class:"activity-row is-pending","data-testid":"activity-proposal",children:[i("span",{class:"activity-glyph tone-purple","aria-hidden":"true",children:"▢"},void 0,!1,void 0,this),i("div",{class:"activity-main",children:[i("div",{class:"activity-text",children:["Proposing: ",i("b",{children:c.label?.trim()||`${c.kind} intent`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"activity-meta",children:[c.reason?.trim()||"Intent signalled — a real veto window before the mutation",c.source?` · ${c.source}`:""]},void 0,!0,void 0,this),i("div",{class:"activity-actions",children:[i("button",{type:"button",class:"activity-veto",onClick:()=>{so(c).then((l)=>{if(l)wi(c.id)})},children:"Veto"},void 0,!1,void 0,this),i("span",{class:"activity-hint",children:"or hover ghost + Esc"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"activity-age",children:"now"},void 0,!1,void 0,this)]},c.id,!0,void 0,this)),s.length===0&&r.length===0&&i("div",{class:"activity-empty",children:"No writes yet."},void 0,!1,void 0,this),s.map((c)=>{let{glyph:l,tone:u}=IA(c.op);return i("div",{class:"activity-row","data-testid":"activity-row","data-op":c.op,children:[i("span",{class:`activity-glyph tone-${u}`,"aria-hidden":"true",children:l},void 0,!1,void 0,this),i("div",{class:"activity-main",children:[i("div",{class:"activity-text",children:c.summary},void 0,!1,void 0,this),i("div",{class:"activity-writer",style:{color:Fa(c.sessionId)},children:c.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"activity-age",children:ja(c.at,n)},void 0,!1,void 0,this)]},c.id,!0,void 0,this)})]},void 0,!0,void 0,this),i("div",{class:"activity-feed-foot",children:[i("span",{class:"activity-feed-note",children:"All writes ghost first · Esc vetoes"},void 0,!1,void 0,this),i("button",{type:"button",class:"activity-feed-link",onClick:()=>{Sr.value=!0},children:"Writers"},void 0,!1,void 0,this),i("button",{type:"button",class:"activity-feed-link is-accent",onClick:()=>{ko.value=!1,Gn()},children:"Start session ↗"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function NA(){let e=[];if(qn.value)e.push("scoped");if(To.value.length>0)e.push("gated");return e.length>0?e.join(" + "):"open"}function Kb(){let e=Sr.value,t=bn(e?1e4:0),n=N(null);if(Ir(n,e),!e)return null;let o=ut.value.filter((a)=>a.attached),r=ut.value.filter((a)=>!a.attached),s=()=>{Sr.value=!1};return i(ye,{children:[i("div",{class:"writers-scrim",onClick:s,"aria-hidden":"true"},void 0,!1,void 0,this),i("div",{ref:n,class:"writers-sheet","data-testid":"writers-sheet",role:"dialog","aria-modal":"true","aria-label":"Connected writers",children:[i("div",{class:"writers-head",children:[i("span",{class:"writers-title",children:"Connected writers"},void 0,!1,void 0,this),i("span",{class:"writers-board",children:dn.value.slice(0,12)},void 0,!1,void 0,this),i("button",{type:"button",class:"activity-feed-close","aria-label":"Close writers",onClick:s,children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"writers-body",children:[i("div",{class:"writers-section",children:"Agent sessions"},void 0,!1,void 0,this),o.length===0&&i("div",{class:"writers-empty",children:"None attached — start one from the top bar."},void 0,!1,void 0,this),o.map((a)=>i("div",{class:"writers-row",children:[i(Rd,{presence:a,size:20},void 0,!1,void 0,this),i("span",{class:"writers-name",children:a.label},void 0,!1,void 0,this),i("span",{class:"writers-config",children:NA()},void 0,!1,void 0,this)]},a.sessionId,!0,void 0,this)),i("div",{class:"writers-section",children:"External writers · MCP"},void 0,!1,void 0,this),r.length===0&&i("div",{class:"writers-empty",children:"No external writers right now."},void 0,!1,void 0,this),r.map((a)=>i("div",{class:"writers-row",children:[i(Rd,{presence:a,size:20},void 0,!1,void 0,this),i("span",{class:"writers-name is-mono",children:a.label},void 0,!1,void 0,this),i("span",{class:"writers-meta",children:[a.source!==a.label?`${a.source} · `:"","wrote"," ",ja(a.lastSeenAt,t)," ago"]},void 0,!0,void 0,this)]},a.sessionId,!0,void 0,this))]},void 0,!0,void 0,this),i("div",{class:"writers-foot",children:[i("span",{class:"writers-note",children:"Local-first: any process on this machine can connect and write. Every write ghosts first — veto is the control, not permissions."},void 0,!1,void 0,this),i("button",{type:"button",class:"writers-done",onClick:s,children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Jb(e,t){switch(e.type){case"markdown":return i(Rs,{node:e,expanded:t},void 0,!1,void 0,this);case"mcp-app":return i(Hn,{node:e,expanded:t},void 0,!1,void 0,this);case"webpage":return i(Aa,{node:e,expanded:t},void 0,!1,void 0,this);case"json-render":return i(Hn,{node:e,expanded:t},void 0,!1,void 0,this);case"graph":return i(Hn,{node:e,expanded:t},void 0,!1,void 0,this);case"prompt":return i(Ia,{node:e},void 0,!1,void 0,this);case"response":return i(za,{node:e,expanded:t},void 0,!1,void 0,this);case"status":return i(Ta,{node:e},void 0,!1,void 0,this);case"context":return i(hs,{node:e,expanded:t},void 0,!1,void 0,this);case"ledger":return i(Es,{node:e},void 0,!1,void 0,this);case"trace":return i(Pa,{node:e},void 0,!1,void 0,this);case"file":return i(Ts,{node:e,expanded:t},void 0,!1,void 0,this);case"diff":return i(gs,{node:e},void 0,!1,void 0,this);case"mermaid":return i(Fs,{node:e,expanded:t},void 0,!1,void 0,this);case"image":return i(Ea,{node:e,expanded:t},void 0,!1,void 0,this);case"html":return i(xi,{node:e,expanded:t},void 0,!1,void 0,this);default:return i("div",{children:"Unknown node type"},void 0,!1,void 0,this)}}function Yb(e){switch(e.type){case"markdown":return e.data.content||"";case"diff":return e.data.content||"";case"mermaid":return e.data.content||"";case"file":return e.data.fileContent||"";case"webpage":return e.data.content||"";case"html":return e.data.html||e.data.content||"";case"json-render":case"graph":return JSON.stringify(e.data.spec??e.data.graphConfig??{},null,2);default:return""}}function RA(e){if(!e)return 0;return e.split(/\s+/).filter(Boolean).length}function $A(e,t){return e!==null&&typeof e==="object"&&e.source===Ot&&e.type==="presentation-exit"&&e.token===t}function MA(e){return e==="ArrowRight"||e==="PageDown"||e===" "||e==="ArrowLeft"||e==="PageUp"||e==="Home"||e==="End"}function Qb(e){return e instanceof HTMLElement&&Boolean(e.closest(".html-presentation-exit"))}function ew(){let e=Be.value,t=e?R.value.get(e):void 0,[n,o]=L(!1),[r,s]=L(!1),[a,c]=L(""),l=N(null),u=N(null),d=M(()=>{s(!1),fo()},[]),p=M(()=>{c(`presentation-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),s(!0)},[]),m=M((B)=>{document.querySelector(".html-presentation-overlay iframe.html-node-frame-presentation")?.contentWindow?.postMessage({source:Ot,token:a,...B},"*")},[a]),f=M(()=>{s(!1)},[]),y=M((B)=>{if(B.key==="Escape"){B.preventDefault(),B.stopPropagation(),s(!1);return}if(B.key==="Tab"&&!Qb(B.target)){B.preventDefault(),B.stopPropagation(),u.current?.focus();return}if((B.key===" "||B.key==="Enter")&&Qb(B.target))return;if(!MA(B.key))return;B.preventDefault(),B.stopPropagation(),m({type:"presentation-key",key:B.key})},[m]),v=M((B)=>{if(B.target.classList.contains("expanded-overlay-backdrop"))fo()},[]),x=M(()=>{if(!t)return;let B=Yb(t);if(!B)return;navigator.clipboard.writeText(B).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})},[t]),h=M(()=>{if(!e)return;Rn(e)},[e]);D(()=>{s(!1)},[e]),Ui(()=>{if(!r)return;let B=()=>{let be=l.current;if(!be||be.contains(document.activeElement))return;be.focus()},q=[0,50,150].map((be)=>window.setTimeout(B,be)),Y=(be)=>{if(!$A(be.data,a))return;s(!1)};return document.addEventListener("keydown",y,!0),window.addEventListener("message",Y),()=>{q.forEach((be)=>{window.clearTimeout(be)}),document.removeEventListener("keydown",y,!0),window.removeEventListener("message",Y)}},[y,a,r]);let g=N(null),b=M(()=>e?document.querySelector(`.canvas-node[data-node-id="${CSS.escape(e)}"]`):null,[e]);if(Ir(g,t!==void 0,{restoreTo:b}),!t)return null;let O=t.data.title||t.data.path?.split("/").pop()||ot[t.type],F=Yb(t),_=RA(F),k=e?Ee.value.has(e):!1,T=F.length>0,P=Yt.value===e,Z=t.type==="mcp-app"||t.type==="webpage"||t.type==="json-render"||t.type==="graph",j=sx(t),I=yn(t.type),H=t.data.provenance&&typeof t.data.provenance==="object"?t.data.provenance:null,U=H?[H.sourceKind,H.sourceUri,H.syncedAt?`synced ${H.syncedAt.slice(11,16)}`:null].filter((B)=>typeof B==="string"&&B.length>0).join(" · "):null;return i("div",{class:"expanded-overlay-backdrop",onPointerDown:v,style:{pointerEvents:P?"none":"auto"},children:i("div",{ref:g,class:`expanded-overlay-panel${k?" is-pinned":""}`,role:"dialog","aria-modal":"true","aria-label":O,"data-testid":"expanded-node",children:[i("div",{class:"expanded-header",children:[i("span",{class:"expanded-kind-icon","aria-hidden":"true",children:i(I,{size:15},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"expanded-title",children:O},void 0,!1,void 0,this),i("span",{class:"expanded-kind-pill",children:ot[t.type]},void 0,!1,void 0,this),i("button",{type:"button",class:`expanded-pin${k?" is-on":""}`,onClick:h,title:k?"In agent context — click to unpin":"Pin as agent context","aria-pressed":k,children:"✦"},void 0,!1,void 0,this),i("span",{class:"expanded-spacer"},void 0,!1,void 0,this),i("div",{class:"expanded-actions",children:[T&&i("button",{type:"button",class:"expanded-action-btn",onClick:x,title:"Copy content to clipboard",children:n?"Copied!":"Copy"},void 0,!1,void 0,this),Ls(t)&&i("button",{type:"button",class:"expanded-action-btn",onClick:()=>void Ds(t),title:"Open as a full-page site in the system browser",children:"Open in tab ↗"},void 0,!1,void 0,this),j&&i("button",{type:"button",class:"expanded-action-btn expanded-action-primary",onClick:p,title:"Present this HTML node fullscreen",children:"Present"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("button",{type:"button",class:"expanded-close",onClick:d,title:"Close (Esc)","aria-label":"Close",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:`expanded-body${Z?" is-embedded":""}`,children:Z?i("div",{style:{flex:1,minHeight:0,display:"flex"},children:Jb(t,!0)},void 0,!1,void 0,this):Jb(t,!0)},void 0,!1,void 0,this),i("div",{style:{"--ax-dock-bleed":"0px","--ax-dock-pad":"16px"},children:i(Qa,{node:t},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("div",{class:"expanded-footer",children:[i("span",{class:"expanded-footer-meta",children:[U,_>0?`${_.toLocaleString()} word${_!==1?"s":""}`:null].filter(Boolean).join(" · ")||ot[t.type].toLowerCase()},void 0,!1,void 0,this),i("span",{class:"expanded-spacer"},void 0,!1,void 0,this),i("span",{class:`expanded-footer-hint${P?" is-saving":""}`,children:P?"Saving edits…":"esc or click outside to close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&r&&i("div",{ref:l,class:"html-presentation-overlay",role:"dialog","aria-modal":"true","aria-label":`Present ${O}`,tabIndex:-1,onKeyDownCapture:y,children:[i("button",{ref:u,type:"button",class:"html-presentation-exit",onClick:f,title:"Exit presentation (Esc)","aria-label":"Exit presentation",children:"Exit presentation"},void 0,!1,void 0,this),i("div",{class:"html-presentation-stage",children:i(xi,{node:t,expanded:!0,presentation:!0,presentationExitToken:a},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var nw=168,ow=112,ic=20;function tw(e,t,n,o){let r=Array.from(e.values()),s=0,a=0,c=1000,l=800;if(r.length>0){s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let x of r)s=Math.min(s,x.position.x),a=Math.min(a,x.position.y),c=Math.max(c,x.position.x+x.size.width),l=Math.max(l,x.position.y+x.size.height)}let u=-t.x/t.scale,d=-t.y/t.scale,p=u+n/t.scale,m=d+o/t.scale,f={minX:Math.min(s,u)-ic,minY:Math.min(a,d)-ic,maxX:Math.max(c,p)+ic,maxY:Math.max(l,m)+ic},y=f.maxX-f.minX||1,v=f.maxY-f.minY||1;return{bounds:f,scale:Math.min(nw/y,ow/v)}}function rw({viewport:e,nodes:t,onNavigate:n,containerWidth:o,containerHeight:r}){let s=N(null),a=N(!1),c=t.value,l=e.value,u=tw(c,l,o,r),{bounds:d,scale:p}=u,m=(_)=>(_-d.minX)*p,f=(_)=>(_-d.minY)*p,y=M((_)=>{let k=s.current;if(!k)return;let T=k.getBoundingClientRect(),P=(_.clientX-T.left)/T.width*nw,Z=(_.clientY-T.top)/T.height*ow,j=tw(t.value,e.value,o,r),I=e.value,H=o/I.scale,U=r/I.scale,B=P/j.scale+j.bounds.minX,q=Z/j.scale+j.bounds.minY;n(-(B-H/2)*I.scale,-(q-U/2)*I.scale)},[t,e,o,r,n]),v=M((_)=>{_.stopPropagation(),_.preventDefault(),a.current=!0,y(_);let k=(P)=>{if(a.current)y(P)},T=()=>{a.current=!1,document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",T)};document.addEventListener("pointermove",k),document.addEventListener("pointerup",T)},[y]),x=xe.value,h=qn.value,g=h?Ga(h.nodeIds.map((_)=>c.get(_)).filter((_)=>_!==void 0),h.padding):null,b=ut.value.map((_)=>({id:_.sessionId,phase:_.phase,worker:_.parentAgentId!=null,external:!_.attached,at:Za(_,(k)=>c.get(k))})).filter((_)=>_.at!==null),O=-l.x/l.scale,F=-l.y/l.scale;return i("div",{ref:s,class:"minimap","data-testid":"minimap",title:"Click to jump · drag the frame to pan",onPointerDown:v,children:[Array.from(c.values()).map((_)=>{let k=_.type==="group";return i("span",{class:`minimap-node${k?" is-group":""}${x.has(_.id)?" is-selected":""}`,"data-kind":_.type,style:{left:`${m(_.position.x)}px`,top:`${f(_.position.y)}px`,width:`${Math.max(k?6:4,_.size.width*p)}px`,height:`${Math.max(k?5:3,_.size.height*p)}px`,"--kind":Ja[_.type]}},_.id,!1,void 0,this)}),g&&i("span",{class:"minimap-fence",style:{left:`${m(g.x)}px`,top:`${f(g.y)}px`,width:`${g.width*p}px`,height:`${g.height*p}px`}},void 0,!1,void 0,this),b.map((_)=>i("span",{class:`minimap-presence phase-${_.phase}${_.worker?" is-worker":""}${_.external?" is-external":""}`,style:{left:`${m(_.at.x)-4}px`,top:`${f(_.at.y)-4}px`,"--identity-color":`hsl(${Un(_.id)} 65% 62%)`}},_.id,!1,void 0,this)),i("span",{class:"minimap-frame",style:{left:`${m(O)}px`,top:`${f(F)}px`,width:`${o/l.scale*p}px`,height:`${r/l.scale*p}px`}},void 0,!1,void 0,this),i("span",{class:"minimap-zoom",children:[Math.round(l.scale*100),"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ke({label:e,shortcut:t,body:n,align:o="center",side:r="down",tapToOpen:s=!1,children:a}){return i("span",{class:`toolbar-tooltip-anchor toolbar-tooltip-anchor-${o}${r==="up"?" toolbar-tooltip-anchor-up":""}${s?" toolbar-tooltip-anchor-tap":""}`,tabIndex:s?-1:void 0,children:[a,i("span",{class:"toolbar-tooltip",role:"tooltip",children:[i("span",{class:"toolbar-tooltip-label",children:e},void 0,!1,void 0,this),n&&i("span",{class:"toolbar-tooltip-body",children:n},void 0,!1,void 0,this),t&&i("span",{class:"toolbar-tooltip-meta",children:i("kbd",{class:"toolbar-tooltip-shortcut",children:t},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function iw(){let e=xe.value.size,t=M(()=>{let c=Array.from(xe.value);if(c.length===0)return;xs(c),mt()},[]),n=M(()=>{let c=Array.from(xe.value);if(c.length===0)return;Zo({title:"Group",childIds:c}),mt()},[]),o=M(()=>{let c=Array.from(xe.value);for(let l=0;l<c.length;l++)for(let u=l+1;u<c.length;u++)ao(c[l],c[u],"relation");mt()},[]),r=M(()=>{let c=Array.from(xe.value);for(let l of c)Et(l),An(l);mt()},[]);if(e===0)return null;let s=e>=2,a=!dt.value&&Ee.value.size>0&&!Jt.value;return i("div",{class:`selection-bar${a?" is-above-pin-bar":""}`,role:"toolbar","aria-label":"Selection",children:[i("span",{class:"selection-bar-count",children:[e," node",e!==1?"s":""," selected"]},void 0,!0,void 0,this),s&&i(ye,{children:[i("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),i(Ke,{label:"Align left",side:"up",children:i("button",{type:"button",class:"selection-bar-icon","aria-label":"Align left",onClick:()=>el("left"),children:i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[i("line",{x1:"2.5",y1:"2",x2:"2.5",y2:"14"},void 0,!1,void 0,this),i("rect",{x:"5",y:"3.5",width:"8",height:"3.5",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"5",y:"9",width:"5",height:"3.5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Align top",side:"up",children:i("button",{type:"button",class:"selection-bar-icon","aria-label":"Align top",onClick:()=>el("top"),children:i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[i("line",{x1:"2",y1:"2.5",x2:"14",y2:"2.5"},void 0,!1,void 0,this),i("rect",{x:"3.5",y:"5",width:"3.5",height:"8",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"9",y:"5",width:"3.5",height:"5",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Distribute horizontally",body:"Evens the gaps. A selection that cannot fit flows into a clean row instead of overlapping.",side:"up",children:i("button",{type:"button",class:"selection-bar-icon","aria-label":"Distribute",disabled:e<3,onClick:()=>_f(),children:i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","aria-hidden":"true",children:[i("rect",{x:"1.5",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"6.25",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this),i("rect",{x:"11",y:"5",width:"3.5",height:"6",rx:"1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Auto-arrange selection",side:"up",children:i("button",{type:"button",class:"selection-bar-icon","aria-label":"Auto-arrange",onClick:()=>Sf(),children:i(So,{size:14},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),i(Ke,{label:"Group the selection",shortcut:"G",side:"up",children:i("button",{type:"button",class:"selection-bar-action",onClick:n,children:[i("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-dasharray":"3 2.5","aria-hidden":"true",children:i("rect",{x:"1.5",y:"1.5",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"Group"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Connect every pair",side:"up",children:i("button",{type:"button",class:"selection-bar-action",onClick:o,children:"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(Ke,{label:"Pin to agent context",side:"up",children:i("button",{type:"button",class:"selection-bar-action is-pin",onClick:t,children:[i("span",{"aria-hidden":"true",children:"✦"},void 0,!1,void 0,this),"Pin as context"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i("span",{class:"selection-bar-sep"},void 0,!1,void 0,this),i(Ke,{label:"Delete selection",side:"up",children:i("button",{type:"button",class:"selection-bar-icon is-danger","aria-label":"Delete selection",onClick:r,children:i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","aria-hidden":"true",children:[i("path",{d:"M2.5 4 H13.5"},void 0,!1,void 0,this),i("path",{d:"M5.5 4 V2.5 H10.5 V4"},void 0,!1,void 0,this),i("path",{d:"M4 4 L4.8 13.5 H11.2 L12 4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Clear selection",shortcut:"Esc",side:"up",children:i("button",{type:"button",class:"selection-bar-icon",onClick:mt,"aria-label":"Clear selection",children:"×"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function sc(e,t=Date.now()){if(!e.expiresAt)return null;let n=Date.parse(e.expiresAt);if(!Number.isFinite(n))return null;return Math.max(0,n-t)}function ac(e){let t=Math.max(0,Math.ceil(e/1000)),n=Math.floor(t/60),o=t%60;return`${n}:${String(o).padStart(2,"0")}`}var OA={todo:"queued","in-progress":"running",blocked:"awaiting",done:"done",cancelled:"vetoed"},LA={todo:"queued","in-progress":"running",blocked:"awaiting",done:"done",cancelled:"cancelled"},sw=[{id:"all",label:"All",hint:"Everything below in one feed, newest first"},{id:"update",label:"Updates",hint:"Board edits agents made — nodes, edges, pins, work items"},{id:"steer",label:"Steer",hint:"Instructions sent to agents — by you from the composer, or agent-to-agent"},{id:"assistant",label:"Assistant",hint:"Messages agents posted for you to read"},{id:"event",label:"Events",hint:"Run telemetry — tool runs, approvals, failures, policy notes"},{id:"evidence",label:"Evidence",hint:"Proof agents recorded — test results, artifacts, links"}],aw=Object.fromEntries(sw.map((e)=>[e.id,e.hint])),DA={policy:"warn",prompt:"accent","assistant-message":"muted","tool-start":"accent","tool-result":"ok",failure:"danger",approval:"warn",steering:"purple",command:"accent",note:"muted",evidence:"ok",steer:"purple",update:"purple",yield:"warn"};function $d(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function FA({item:e}){let t=OA[e.status]??"queued",n=e.nodeIds[0];return i("li",{class:`session-item status-${t}`,"data-work-item-id":e.id,children:[i("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),i("div",{class:"session-item-main",children:[i("button",{type:"button",class:"session-item-title",title:n?"Focus the linked node":void 0,disabled:!n,onClick:()=>n&&et(n),children:e.title},void 0,!1,void 0,this),e.detail&&i("div",{class:"session-item-detail",children:e.detail},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"session-item-status",children:LA[e.status]??t},void 0,!1,void 0,this),i("span",{class:"session-item-time",children:$d(e.updatedAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function jA({gate:e,now:t}){let[n,o]=L(null),r=async(c)=>{o(c),await sb(e,c),o(null)},s=e.nodeIds[0],a=sc(e,t);return i("li",{class:"session-item status-awaiting session-gate","data-gate-id":e.id,children:[i("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),i("div",{class:"session-item-main",children:[i("button",{type:"button",class:"session-item-title",title:s?"Focus the linked node":void 0,disabled:!s,onClick:()=>s&&et(s),children:e.title},void 0,!1,void 0,this),e.detail&&i("div",{class:"session-item-detail",children:e.detail},void 0,!1,void 0,this),a!==null&&i("div",{class:"session-gate-ttl","data-testid":"gate-countdown",children:["auto-holds in ",ac(a)," if unanswered"]},void 0,!0,void 0,this),i("div",{class:"session-gate-actions",children:[i("button",{type:"button",class:"session-gate-approve",disabled:n!==null,onClick:()=>void r("approved"),children:n==="approved"?"Approving…":"Approve"},void 0,!1,void 0,this),i("button",{type:"button",class:"session-gate-reject",disabled:n!==null,onClick:()=>void r("rejected"),children:n==="rejected"?"Rejecting…":"Reject"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"session-item-time",children:$d(e.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ZA({gate:e}){let[t,n]=L(!1);return i("li",{class:"session-item status-vetoed session-gate-held","data-gate-id":e.id,children:[i("span",{class:"session-glyph","aria-hidden":"true"},void 0,!1,void 0,this),i("div",{class:"session-item-main",children:[i("span",{class:"session-item-title",children:e.title},void 0,!1,void 0,this),i("div",{class:"session-item-detail",children:"Auto-held — no answer in time, the action did not proceed."},void 0,!1,void 0,this),i("div",{class:"session-gate-actions",children:i("button",{type:"button",class:"session-gate-reject",disabled:t,onClick:()=>{n(!0),ab(e).finally(()=>n(!1))},children:t?"Reopening…":"Reopen"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("span",{class:"session-item-status",children:"held"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function HA(){let e=qn.value,t=xe.value.size,[n,o]=L(!1),r=(s)=>{o(!0),tb(s).finally(()=>o(!1))};return i("div",{class:`session-scope${e?" is-fenced":""}`,"data-testid":"session-scope",children:[i("span",{class:"session-scope-dot","aria-hidden":"true"},void 0,!1,void 0,this),e?i(ye,{children:[i("span",{class:"session-scope-text",children:["Scoped to ",i("strong",{children:e.nodeIds.length},void 0,!1,void 0,this)," node",e.nodeIds.length===1?"":"s"," · writes outside are blocked"]},void 0,!0,void 0,this),i("button",{type:"button",class:"session-scope-action",disabled:n,onClick:()=>r(null),children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i(ye,{children:[i("span",{class:"session-scope-text",children:"Unscoped — the agent may write anywhere"},void 0,!1,void 0,this),i("button",{type:"button",class:"session-scope-action",disabled:n||t===0,title:t===0?"Select nodes on the canvas first":"Fence the agent to the selected nodes",onClick:()=>r([...xe.value]),children:["Fence to selection",t>0?` (${t})`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function BA(e){if(e==="browser")return"you";return ut.value.find((n)=>n.sessionId===e||n.source===e)?.label??e}function UA({entry:e}){let t=ki.value.has(e.id);return i("li",{class:`session-timeline-row tone-${DA[e.kind]??"muted"}`,children:[i("span",{class:"session-timeline-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("div",{class:"session-timeline-main",children:[i("div",{class:"session-timeline-head",children:[i("span",{class:"session-timeline-label",title:aw[bd(e.kind)],children:e.label},void 0,!1,void 0,this),e.who&&i("span",{class:"session-timeline-who",style:{"--identity-color":`hsl(${Un(e.who)} 65% 62%)`},children:BA(e.who)},void 0,!1,void 0,this),i("span",{class:"session-item-time",children:$d(e.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"session-timeline-body",children:e.body},void 0,!1,void 0,this),e.undoable&&!t&&i("button",{type:"button",class:"session-timeline-undo","data-testid":"timeline-undo",onClick:()=>void wd(e),children:"↩ undo this edit"},void 0,!1,void 0,this),t&&i("div",{class:"session-timeline-undone",children:"undone · steering sent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function cw(){let[e,t]=L(!1),n=kr.value,o=Qx.value,r=To.value,s=nb.value,a=ib.value,[c,l]=L(!1),[u,d]=L(null),p=bn();if(D(()=>{Vn()},[]),e)return i("aside",{class:"session-panel is-collapsed","aria-label":"Session (collapsed)",children:[i("button",{type:"button",class:"session-collapse",onClick:()=>t(!1),title:"Expand session panel",children:"‹"},void 0,!1,void 0,this),i("span",{class:"session-collapsed-label",children:"Session"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("aside",{class:"session-panel","aria-label":"Session",children:[i("header",{class:"session-panel-header",children:[i("span",{class:"session-panel-title",children:"Session"},void 0,!1,void 0,this),n&&i("span",{class:`session-live phase-${n.phase}`,title:_r(n),children:[i("span",{class:"session-live-dot","aria-hidden":"true"},void 0,!1,void 0,this),"live"]},void 0,!0,void 0,this),i("span",{class:"top-bar-spacer"},void 0,!1,void 0,this),n&&i("button",{type:"button",class:"session-end",title:"End this session — a receipt and a snapshot of the board follow",onClick:()=>void Xa(n),children:"End"},void 0,!1,void 0,this),i("button",{type:"button",class:"session-collapse",onClick:()=>t(!0),title:"Collapse session panel",children:"›"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i(HA,{},void 0,!1,void 0,this),(()=>{let m=a.find((f)=>f.undoable&&!ki.value.has(f.id));if(!m)return null;return i("div",{class:"session-undo-row","data-testid":"session-undo-row",children:[i("span",{class:"session-undo-text",title:m.body,children:["Agent edit on top: ",m.body]},void 0,!0,void 0,this),i("button",{type:"button",class:"session-undo-btn",onClick:()=>void wd(m),children:"↩ Undo"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)})(),i("div",{class:"session-panel-body",children:[i("section",{class:"session-section",children:(()=>{let m=o.filter((b)=>b.status==="in-progress"||b.status==="todo").length,f=o.filter((b)=>b.status!=="cancelled"),y=f.filter((b)=>b.status==="done").length,v=o.length-f.length,x=r.length>0,h=c||x,g=m>0?`${m} running`:f.length>0?`${y}/${f.length} done${v>0?` · ${v} cancelled`:""}`:o.length>0?`${o.length} cancelled`:"none yet";return i(ye,{children:[i("button",{type:"button",class:"session-section-toggle","aria-expanded":h,"data-testid":"work-items-toggle",onClick:()=>l((b)=>!b),children:[i("span",{class:"session-section-title",children:"Work items"},void 0,!1,void 0,this),i("span",{class:"session-work-summary",children:[m>0&&i("span",{class:"session-work-dot","aria-hidden":"true"},void 0,!1,void 0,this),g]},void 0,!0,void 0,this),i("span",{class:`session-section-chevron${h?" is-open":""}`,"aria-hidden":"true",children:"›"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),h&&(r.length===0&&s.length===0&&o.length===0?i("div",{class:"session-empty",children:"No work items yet — the agent's tasks and gates appear here."},void 0,!1,void 0,this):i("ul",{class:"session-list","aria-live":"polite","aria-label":"Work items and gates",children:[r.map((b)=>i(jA,{gate:b,now:p},b.id,!1,void 0,this)),s.map((b)=>i(ZA,{gate:b},b.id,!1,void 0,this)),o.map((b)=>i(FA,{item:b},b.id,!1,void 0,this))]},void 0,!0,void 0,this))]},void 0,!0,void 0,this)})()},void 0,!1,void 0,this),i("section",{class:"session-section",children:[i("h3",{class:"session-section-title",children:"Timeline"},void 0,!1,void 0,this),i("div",{class:"session-timeline-filters",role:"group","aria-label":"Filter timeline",children:sw.map((m)=>i("button",{type:"button",class:`activity-filter${Eo.value===m.id?" is-active":""}`,"aria-pressed":Eo.value===m.id,title:m.hint,onMouseEnter:()=>d(m.id),onMouseLeave:()=>d((f)=>f===m.id?null:f),onFocus:()=>d(m.id),onBlur:()=>d((f)=>f===m.id?null:f),onClick:()=>{Eo.value=m.id},children:m.label},m.id,!1,void 0,this))},void 0,!1,void 0,this),i("div",{class:"session-timeline-hint","data-testid":"timeline-filter-hint",children:aw[u??Eo.value]},void 0,!1,void 0,this),a.length===0?i("div",{class:"session-empty",children:Eo.value==="all"?"Nothing recorded yet.":"Nothing of this kind yet."},void 0,!1,void 0,this):i("ul",{class:"session-list session-timeline","aria-live":"polite","aria-label":"Timeline",children:a.map((m)=>i(UA,{entry:m},m.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Md(e){if(!e||typeof e!=="object")return null;let t=e,n=(o)=>Array.isArray(o)?o.length:0;return{added:n(t.addedNodes)+n(t.addedEdges),removed:n(t.removedNodes)+n(t.removedEdges),modified:n(t.modifiedNodes)}}function lw({onOpenSnapshots:e}){let t=Ka.value,[n,o]=L(null),[r,s]=L(!1);if(!t)return null;let a=async()=>{if(!t.snapshot)return;s(!0);try{let u=await fetch(`/api/canvas/snapshots/${encodeURIComponent(t.snapshot.id)}/diff`,{headers:{"x-pmx-workbench":"1"}});if(u.ok){let d=await u.json();o(Md(d.diff)??{added:0,removed:0,modified:0})}}finally{s(!1)}},c=new Date(t.endedAt),l=Number.isNaN(c.getTime())?"":`${String(c.getHours()).padStart(2,"0")}:${String(c.getMinutes()).padStart(2,"0")}`;return i("div",{class:"session-receipt","data-testid":"session-receipt",role:"status",children:[i("div",{class:"session-receipt-head",children:[i("span",{class:"session-receipt-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("span",{class:"session-receipt-title",children:[t.endedBy==="human"?"Session ended by you":t.endedBy==="idle-timeout"?"Session ended — idle timeout":t.endedBy==="agent"?"Session ended by the agent":"Session ended",l?` · ${l}`:""]},void 0,!0,void 0,this),i("button",{type:"button",class:"session-receipt-close",onClick:ub,"aria-label":"Dismiss receipt",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"session-receipt-tiles",children:[i("div",{class:"session-receipt-tile",children:[i("span",{class:"session-receipt-tile-label",children:"Items"},void 0,!1,void 0,this),i("span",{class:"session-receipt-tile-value",children:t.counts.items},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"session-receipt-tile",children:[i("span",{class:"session-receipt-tile-label",children:"Done"},void 0,!1,void 0,this),i("span",{class:"session-receipt-tile-value tone-ok",children:t.counts.done},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.counts.cancelled>0&&i("div",{class:"session-receipt-tile",children:[i("span",{class:"session-receipt-tile-label",children:"Cancelled"},void 0,!1,void 0,this),i("span",{class:"session-receipt-tile-value tone-muted",children:t.counts.cancelled},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.counts.rejected>0&&i("div",{class:"session-receipt-tile",children:[i("span",{class:"session-receipt-tile-label",children:"Rejected"},void 0,!1,void 0,this),i("span",{class:"session-receipt-tile-value tone-danger",children:t.counts.rejected},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.counts.held>0&&i("div",{class:"session-receipt-tile",children:[i("span",{class:"session-receipt-tile-label",children:"Held"},void 0,!1,void 0,this),i("span",{class:"session-receipt-tile-value tone-warn",children:t.counts.held},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"session-receipt-note",children:t.snapshot?"A snapshot of the board from before this session is saved — restore it to undo the session.":t.unchanged?"This session changed nothing on the board — no snapshot kept.":"The board was empty when the session started — nothing to restore."},void 0,!1,void 0,this),n&&i("div",{class:"session-receipt-diff","data-testid":"session-receipt-diff",children:["This session: ",n.added," added · ",n.removed," removed · ",n.modified," modified"]},void 0,!0,void 0,this),i("div",{class:"session-receipt-actions",children:[t.snapshot&&i("button",{type:"button",class:"session-receipt-primary",disabled:r,onClick:()=>void a(),children:r?"Comparing…":"View diff"},void 0,!1,void 0,this),i("button",{type:"button",class:"session-receipt-secondary",title:"Open the History drawer — saved boards and past sessions",onClick:e,children:"History"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var WA=[{title:"Tools",shortcuts:[{keys:"V",desc:"Select tool — drag empty space to lasso"},{keys:"Space (hold)",desc:"Pan — drag anywhere moves the board"},{keys:"A",desc:"Annotate — draw on the canvas"}]},{title:"Navigation",shortcuts:[{keys:Ze("K"),desc:"Command palette — search nodes & actions"},{keys:"Tab / Shift+Tab",desc:"Cycle through nodes"},{keys:"← ↑ → ↓",desc:"Walk graph along edges (when node focused)"},{keys:"F",desc:"Fit all nodes on screen"},{keys:Ze("0"),desc:"Reset viewport to origin"},{keys:`${Ze("+")} / ${Ze("−")}`,desc:"Zoom in / out"}]},{title:"Creation",shortcuts:[{keys:"M",desc:"New markdown note"},{keys:"I / W / H",desc:"New image / webpage / HTML surface"},{keys:"Shift+F",desc:"New file node (workspace path)"},{keys:"G / Shift+G",desc:"Group the selection (new frame when empty) / ungroup"},{keys:"Double-click",desc:"Create new markdown note on canvas"},{keys:"Drag port → node",desc:"Connect two nodes (hover to reveal ports)"}]},{title:"Selection",shortcuts:[{keys:"Click",desc:"Focus node (highlights neighbors & edges)"},{keys:"Shift+Click",desc:"Toggle node in multi-selection"},{keys:"Drag empty space",desc:"Lasso select multiple nodes"},{keys:qr?"Delete / ⌫":"Delete / Backspace",desc:"Delete the selection (or the focused node)"},{keys:qr?"⌘Z / ⇧⌘Z":"Ctrl+Z / Ctrl+Y",desc:"Undo / redo — agent edits included"},{keys:"Esc",desc:"Clear selection / close overlay"}]},{title:"View",shortcuts:[{keys:"?",desc:"Toggle this shortcut overlay"},{keys:"Minimap",desc:"Click/drag to navigate (toggle in the rail)"},{keys:"Right-click",desc:"Context menu — dock, focus, connect"}]}];function uw({onClose:e}){return i("div",{class:"shortcut-overlay-backdrop",onMouseDown:e,children:i("div",{class:"shortcut-overlay",onMouseDown:(t)=>t.stopPropagation(),children:[i("div",{class:"shortcut-overlay-header",children:[i("span",{class:"shortcut-overlay-title",children:"Keyboard Shortcuts"},void 0,!1,void 0,this),i("span",{class:"shortcut-overlay-hint",children:["Press ",i("kbd",{children:"?"},void 0,!1,void 0,this)," or ",i("kbd",{children:"Esc"},void 0,!1,void 0,this)," to close"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"shortcut-overlay-body",children:WA.map((t)=>i("div",{class:"shortcut-group",children:[i("div",{class:"shortcut-group-title",children:t.title},void 0,!1,void 0,this),t.shortcuts.map((n)=>i("div",{class:"shortcut-row",children:[i("kbd",{class:"shortcut-keys",children:n.keys},void 0,!1,void 0,this),i("span",{class:"shortcut-desc",children:n.desc},void 0,!1,void 0,this)]},n.keys,!0,void 0,this))]},t.title,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var dw="Before session · ";function pw(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return"";return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function qA(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/60000);if(n<1)return"just now";if(n<60)return`${n}m ago`;let o=Math.floor(n/60);if(o<24)return`${o}h ago`;return`${Math.floor(o/24)}d ago`}function cc(e){if(!e.startsWith(dw))return null;let t=e.slice(dw.length),n=t.lastIndexOf(" · ");return n>0?t.slice(0,n):t}function fw({open:e,onClose:t,anchorRef:n}){let[o,r]=L([]),[s,a]=L(!1),[c,l]=L(!1),[u,d]=L(null),[p,m]=L(""),[f,y]=L(null),[v,x]=L({}),h=N(null),g=N(null);D(()=>{if(!e)return;a(!0),Wp().then((T)=>{r(T),a(!1)})},[e]),D(()=>{if(e)setTimeout(()=>g.current?.focus(),50)},[e]),D(()=>{if(!e)return;let T=(P)=>{let Z=h.current,j=n.current;if(Z&&!Z.contains(P.target)&&j&&!j.contains(P.target))t()};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[e,t]),D(()=>{if(!e)return;let T=(P)=>{if(P.key==="Escape")t()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,t]);let b=M(async()=>{let T=p.trim();if(!T)return;l(!0);let P=await qp(T);if(l(!1),P.ok&&P.snapshot)r((Z)=>[P.snapshot,...Z]),m("")},[p]),O=M(async(T)=>{y(null),d(T);let P=await Vp(T);if(d(null),P.ok)t()},[t]),F=M(async(T)=>{if((await Gp(T)).ok)r((Z)=>Z.filter((j)=>j.id!==T));y(null)},[]),_=M(async(T)=>{x((Z)=>({...Z,[T]:"loading"}));let P=await ve("snapshotDiff",`/api/canvas/snapshots/${encodeURIComponent(T)}/diff`,{});x((Z)=>({...Z,[T]:Md(P.diff)??{added:0,removed:0,modified:0}}))},[]);if(!e)return null;let k=(T,P)=>f?.id===T.id?i(ye,{children:[i("button",{type:"button",class:`snapshot-action-btn ${f.action==="delete"?"snapshot-action-confirm":"snapshot-action-restore"}`,onClick:()=>f.action==="delete"?F(T.id):O(T.id),title:f.action==="delete"?"Confirm delete":"Confirm restore",disabled:u!==null,children:f.action==="delete"?"Delete":u===T.id?"Restoring…":"Confirm"},void 0,!1,void 0,this),i("button",{type:"button",class:"snapshot-action-btn",onClick:()=>y(null),title:"Cancel",disabled:u!==null,children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):i(ye,{children:[i("button",{type:"button",class:"snapshot-action-btn snapshot-action-restore",onClick:()=>y({id:T.id,action:"restore"}),title:"Restore this snapshot — replaces the current canvas (undoable)",disabled:u!==null,children:u===T.id?"Restoring…":P},void 0,!1,void 0,this),i("button",{type:"button",class:"snapshot-action-btn snapshot-action-delete",onClick:()=>y({id:T.id,action:"delete"}),title:"Delete this snapshot","aria-label":"Delete snapshot",disabled:u!==null,children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return i("div",{ref:h,class:"snapshot-panel","data-testid":"history-drawer",role:"dialog","aria-label":"History",children:[i("div",{class:"snapshot-panel-header",children:[i("span",{class:"snapshot-panel-title",children:"History"},void 0,!1,void 0,this),i("span",{class:"snapshot-panel-sub",children:"snapshots + sessions"},void 0,!1,void 0,this),i("span",{class:"snapshot-panel-spacer"},void 0,!1,void 0,this),i("button",{type:"button",class:"snapshot-panel-close",onClick:t,title:"Close","aria-label":"Close history",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"snapshot-save-form",children:[i("input",{ref:g,type:"text",class:"snapshot-name-input",value:p,onInput:(T)=>m(T.target.value),onKeyDown:(T)=>{if(T.key==="Enter")b()},placeholder:"Save a snapshot as…","aria-label":"Snapshot name",maxLength:80,disabled:c},void 0,!1,void 0,this),i("button",{type:"button",class:"snapshot-save-btn",onClick:b,disabled:!p.trim()||c,children:c?"…":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"snapshot-restore-note",children:"Restoring replaces the current canvas. You can undo it if needed."},void 0,!1,void 0,this),i("div",{class:"snapshot-list",children:[s&&i("div",{class:"snapshot-empty",children:"Loading…"},void 0,!1,void 0,this),!s&&o.length===0&&i("div",{class:"snapshot-empty",children:"No history yet. Save a snapshot, or start an agent session — it snapshots for you."},void 0,!1,void 0,this),!s&&[...o.filter((T)=>cc(T.name)===null),...o.some((T)=>cc(T.name)!==null)?[{id:"__sessions-header__"}]:[],...o.filter((T)=>cc(T.name)!==null)].map((T)=>{if(T.id==="__sessions-header__")return i("div",{class:"snapshot-section-header","data-testid":"history-sessions-header",children:"Sessions"},T.id,!1,void 0,this);let P=cc(T.name),Z=v[T.id];if(P!==null)return i("div",{class:"snapshot-item is-session","data-testid":"history-session",children:[i("div",{class:"snapshot-item-head",children:[i("span",{class:"snapshot-session-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("span",{class:"snapshot-item-name",children:["Agent session — ",P]},void 0,!0,void 0,this),i("span",{class:"snapshot-item-time",children:pw(T.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"snapshot-item-meta",children:["snapshot at session start · ",T.nodeCount," node",T.nodeCount!==1?"s":"",Z&&Z!=="loading"&&i("span",{class:"snapshot-item-diff",children:[" ","· since: ",Z.added," added · ",Z.removed," removed · ",Z.modified," modified"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"snapshot-item-actions is-session",children:[i("button",{type:"button",class:"snapshot-action-btn snapshot-action-diff",disabled:Z==="loading",onClick:()=>void _(T.id),children:Z==="loading"?"Comparing…":"View diff"},void 0,!1,void 0,this),k(T,"Restore pre-state")]},void 0,!0,void 0,this)]},T.id,!0,void 0,this);return i("div",{class:"snapshot-item","data-testid":"history-snapshot",children:[i("div",{class:"snapshot-item-head",children:[i("span",{class:"snapshot-item-glyph","aria-hidden":"true",children:"◫"},void 0,!1,void 0,this),i("span",{class:"snapshot-item-name",children:T.name},void 0,!1,void 0,this),i("span",{class:"snapshot-item-time",children:pw(T.createdAt)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i("div",{class:"snapshot-item-meta",children:[T.nodeCount," node",T.nodeCount!==1?"s":"",T.edgeCount>0?` · ${T.edgeCount} edge${T.edgeCount!==1?"s":""}`:""," · ",qA(T.createdAt)]},void 0,!0,void 0,this),i("div",{class:"snapshot-item-actions",children:k(T,"Restore")},void 0,!1,void 0,this)]},T.id,!0,void 0,this)})]},void 0,!0,void 0,this),i("div",{class:"snapshot-panel-foot",children:"Every agent session start writes a snapshot automatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var mw=3,hw={"waiting-approval":0,thinking:1,tooling:2,idle:3};function VA(){let e=Hx.value;if(e.length===0)return null;let t=[...e].sort((a,c)=>(hw[a.phase]??4)-(hw[c.phase]??4)),n=t.slice(0,mw),o=t.slice(mw),r=e.reduce((a,c)=>(a[c.phase]=(a[c.phase]??0)+1,a),{}),s=[r["waiting-approval"]&&`${r["waiting-approval"]} waiting on approval`,r.thinking&&`${r.thinking} thinking`,r.tooling&&`${r.tooling} running tools`,r.idle&&`${r.idle} idle`].filter(Boolean).join(", ");return i(ye,{children:[i("span",{class:"agent-chips",children:n.map((a)=>{let c=ut.value.filter((l)=>l.parentAgentId!=null&&(l.parentAgentId===a.sessionId||l.parentAgentId===a.source)).length;return i(Ke,{label:`Agent session — ${a.label}`,tapToOpen:!0,body:"What this attached agent is doing right now: idle, thinking, running a tool, or waiting on your approval. Steer it from the composer below.",children:i("span",{class:`agent-chip phase-${a.phase}`,"data-phase":a.phase,style:{"--identity-color":`hsl(${Un(a.sessionId)} 65% 62%)`},children:[i("span",{class:"agent-chip-dot","aria-hidden":"true"},void 0,!1,void 0,this),i("span",{class:"agent-chip-label",children:_r(a)},void 0,!1,void 0,this),i("span",{class:"agent-chip-who hud-collapsible-text",children:a.label},void 0,!1,void 0,this),c>0&&i("span",{class:"agent-chip-workers",children:["+",c," worker",c===1?"":"s"]},void 0,!0,void 0,this),i("button",{type:"button",class:"agent-chip-end","aria-label":`End ${a.label} session`,title:`End ${a.label}'s session`,onClick:(l)=>{l.stopPropagation(),Xa({source:a.source,agentId:a.agentId})},children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},a.sessionId,!1,void 0,this)})},void 0,!1,void 0,this),o.length>0&&i(Ke,{label:`${e.length} agent sessions attached`,tapToOpen:!0,body:`${e.length} agents on this board — ${s}. The most active wear their own chips; the rest are here, and idle agents' cursors leave the board until they work again.`,children:i("span",{class:"agent-chip agent-chip-more","data-testid":"agent-chip-more",children:["+",o.length," · ",e.length," agents"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function GA(){let e=To.value.length,t=kr.value!==null&&e>0,n=bn(t?1000:0);if(!t)return null;let o=To.value.map((r)=>sc(r,n)).filter((r)=>r!==null).sort((r,s)=>r-s)[0];return i(Ke,{label:"Approval gates waiting on you",tapToOpen:!0,body:"The agent is blocked until you approve or reject in the session panel; unanswered gates auto-hold when the countdown runs out.",children:i("span",{class:"gate-badge",children:[e," gate",e===1?"":"s",o!==void 0&&` · ${ac(o)}`]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function XA(e){if(e>0.9)return"danger";if(e>=0.7)return"warn";return"ok"}function Ei(e){return e>=1000?`${(e/1000).toFixed(e>=1e4?0:1)}k`:String(e)}function KA(){let e=kr.value;if(!e)return null;let t=ud.value,n=e.contextUsage,o=n?n.used:t.used,r=n?n.total:t.total,s=r>0?Math.min(1,o/r):0,a=Math.round(s*100),c=n?{label:`Context window — reported by ${e.label}`,body:`${Ei(n.used)} of ${Ei(n.total)} tokens of the agent's actual context window are used. Your ✦-pinned nodes account for ≈ ${Ei(t.used)} tokens of it.`}:{label:"Pins — pinned-context size (estimate)",body:`The nodes you pinned (✦) are what the agent is asked to carry as context: ≈ ${Ei(t.used)} of a ${Ei(t.total)}-token budget. When the agent's host reports its real context window, this meter switches to showing that instead.`};return i(Ke,{label:c.label,body:c.body,tapToOpen:!0,children:i("span",{class:`context-budget tone-${XA(s)}`,"data-mode":n?"window":"pins",children:[i("span",{class:"context-budget-caption hud-collapsible-text",children:n?"Context":"Pins"},void 0,!1,void 0,this),i("span",{class:"context-budget-track","aria-hidden":"true",children:i("span",{class:"context-budget-fill",style:{width:`${a}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"context-budget-label","data-testid":"budget-label",children:[o>0&&a===0?"<1":a,"%"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function JA(){let[e,t]=L(!1);if(kr.value)return null;return i(Ke,{label:"Start an agent session",body:"Attaches a session to this board: the next agent that writes here is adopted into it, and you get the panel, composer, and receipt.",children:i("button",{type:"button",class:"start-session-btn",disabled:e,onClick:()=>{t(!0),Gn().finally(()=>t(!1))},children:[i("span",{class:"start-session-dot","aria-hidden":"true"},void 0,!1,void 0,this),"Start agent session",i("span",{class:"beta-tag",children:"beta"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function gw(){let e=Tt.value,t=Ut.value,n=oe.value,o=R.value.size,r=Re.value.size,s=Xo.value,a=Array.from(R.value.values()).filter((f)=>f.type==="trace").length,[c,l]=L("");D(()=>{let f=!1;return fetch("/health").then((y)=>y.ok?y.json():null).then((y)=>{if(f||typeof y?.workspace!=="string"||!y.workspace)return;let v=y.workspace.replace(/[\\/]+$/,"").split(/[\\/]/).pop();if(v)l(v)}).catch(()=>{}),()=>{f=!0}},[]);let u=Ed.value,d=u??(e==="connected"&&!t?"syncing":e),p=t?[`${o} node${o!==1?"s":""}`,...r>0?[`${r} edge${r!==1?"s":""}`]:[],...a>0?[`${a} trace${a!==1?"s":""}`]:s?["trace armed"]:[]].join(" · "):"Syncing canvas…",m=()=>{let f=bt();tr(f.width,f.height)};return i("div",{class:"top-bar",children:[i(Ke,{label:`Canvas status: ${d}`,tapToOpen:!0,body:"Live updates stream in over SSE; amber means reconnecting.",align:"start",children:i("span",{class:`connection-dot ${u??e}`,"aria-label":`Canvas status: ${d}`},void 0,!1,void 0,this)},void 0,!1,void 0,this),i("span",{class:"top-bar-title",title:c||"PMX Canvas",children:c||"PMX Canvas"},void 0,!1,void 0,this),i("span",{class:"top-bar-meta hud-collapsible-text",children:dn.value?dn.value.slice(0,12):"…"},void 0,!1,void 0,this),i("span",{class:"top-bar-meta hud-collapsible-text",children:p},void 0,!1,void 0,this),i("span",{class:"top-bar-spacer"},void 0,!1,void 0,this),i(VA,{},void 0,!1,void 0,this),i(GA,{},void 0,!1,void 0,this),i(KA,{},void 0,!1,void 0,this),i(Gb,{},void 0,!1,void 0,this),i(JA,{},void 0,!1,void 0,this),i("div",{class:"top-bar-sep"},void 0,!1,void 0,this),i(Ke,{label:"Zoom out",shortcut:Ze("−"),children:i("button",{type:"button",class:"top-bar-btn",onClick:()=>Qo(0.8),"aria-label":"Zoom out",children:i(bx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Reset zoom",shortcut:Ze("0"),children:i("button",{type:"button",class:"top-bar-zoom-label",onClick:()=>$n({x:0,y:0,scale:1},250),"aria-label":"Reset view",children:[Math.round(n.scale*100),"%"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Zoom in",shortcut:Ze("+"),children:i("button",{type:"button",class:"top-bar-btn",onClick:()=>Qo(1.25),"aria-label":"Zoom in",children:i(xx,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),i(Ke,{label:"Fit all",shortcut:"F",align:"end",children:i("button",{type:"button",class:"top-bar-btn",onClick:m,"aria-label":"Fit canvas",children:i(Ma,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function vw(e,t,n,o,r){return e.x<o.position.x+o.size.width+r&&e.x+t+r>o.position.x&&e.y<o.position.y+o.size.height+r&&e.y+n+r>o.position.y}function YA(e,t,n,o,r){return o.some((s)=>vw(e,t,n,s,r))}function QA(e,t,n,o,r){return o.find((s)=>vw(e,t,n,s,r))}function lc(e,t,n,o=24){if(e.length===0)return{x:40,y:80};let r=e[e.length-1],s={x:r.position.x+r.size.width+o,y:r.position.y};if(!YA(s,t,n,e,o))return s;let a=40,c=80,l=3000,u=c;for(let p=0;p<20;p++){let m=a;while(m+t<l){let v=QA({x:m,y:u},t,n,e,o);if(!v)return{x:m,y:u};m=v.position.x+v.size.width+o}u=e.filter((v)=>v.position.y<=u+n+o&&v.position.y+v.size.height+o>u).reduce((v,x)=>Math.max(v,x.position.y+x.size.height),u)+o}let d=e.reduce((p,m)=>Math.max(p,m.position.y+m.size.height),0);return{x:a,y:d+o}}var Xn={status:{x:40,y:80,w:300,h:120},markdown:{x:380,y:80,w:720,h:600},context:{x:1130,y:80,w:320,h:400},"mcp-app":{x:380,y:720,w:960,h:600},webpage:{x:380,y:80,w:520,h:420},"json-render":{x:380,y:720,w:840,h:620},graph:{x:380,y:720,w:760,h:520},ledger:{x:1130,y:520,w:320,h:280},trace:{x:40,y:900,w:200,h:56},file:{x:380,y:80,w:720,h:600},diff:{x:380,y:80,w:640,h:420},mermaid:{x:380,y:80,w:640,h:460},image:{x:380,y:80,w:720,h:520},html:{x:380,y:80,w:720,h:640},group:{x:220,y:60,w:840,h:560},prompt:{x:380,y:1260,w:520,h:400},response:{x:380,y:1480,w:720,h:400}};function Ai(e,t,n,o={}){let r=Xn[t];return{id:e,type:t,position:o.position??{x:r.x,y:r.y},size:o.size??{width:r.w,height:r.h},zIndex:t==="status"?0:1,collapsed:!1,pinned:!1,data:n}}var zo=null,pc=null,uc=0,Kn=null,eI=3000,tI=2000,yw=5000,Ii=!1,_n=null,zr=null,Yn=0,Jn=null;function nI(){if(typeof location>"u"||typeof window>"u")return null;let e=new URLSearchParams(location.search).get("transport");if(e==="poll"||e==="sse")return e;if(window.__PMX_AMP_ORB===!0)return"poll";return null}var Pr=new Map;function zi(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t).toString(36)}function fc(e){if(!pc)return e;let t=pc.get(e.id);if(!t)return e;return{...e,position:t.position??e.position,size:t.size??e.size,collapsed:t.collapsed??e.collapsed,pinned:t.pinned??e.pinned}}function Pi(e,t,n){return fc(Ai(e,t,n))}function oI(){return lc([...R.value.values()],Xn.markdown.w,Xn.markdown.h)}function Nr(){if(!R.value.has("status-main"))pn(Pi("status-main","status",{phase:"idle",message:"",elapsed:0}))}function rI(e,t){let n=`md-${zi(e)}`;if(R.value.get(n))re(n,{path:e,title:t}),Ce.value=n;else{let r=oI(),s=Pi(n,"markdown",{path:e,title:t,content:"",rendered:""});s.position=r,pn(s),et(n)}}function iI(e){if(R.value.get("context-main"))re("context-main",{cards:e});else if(e.length>0){let o=Pi("context-main","context",{cards:e});pn(o)}}function sI(e){let t=e.url,n=`mcp-${zi(t)}`;if(R.value.get(n))re(n,e);else pn(Pi(n,"mcp-app",e)),et(n)}function aI(e){let t=e.toolCallId,o=(typeof e.nodeId==="string"&&e.nodeId.length>0?e.nodeId:null)??(t.startsWith("ext-app-")?t:`ext-app-${t}`);if(R.value.get(o)){re(o,e);return}let{serverName:s,toolName:a}=e;if(s&&a){for(let[x,h]of R.value.entries())if(h.type==="mcp-app"&&h.data.mode==="ext-app"&&h.data.serverName===s&&h.data.toolName===a&&!h.data.toolResult){re(x,{...e});return}}let{_x:c,_y:l,_width:u,_height:d}=e,p=Xn["mcp-app"],m=u??p.w,f=d??p.h,y=c===void 0||l===void 0?lc([...R.value.values()],m,f):null,v=fc(Ai(o,"mcp-app",{mode:"ext-app",...e},{position:{x:c??y?.x??p.x,y:l??y?.y??p.y},size:{width:m,height:f}}));pn(v),et(o,{recordHistory:!1})}function cI(e){let t=e.startsWith("ext-app-")?e:`ext-app-${e}`;if(R.value.has(t))return t;let n=`ext-app-${e}`;if(n!==t&&R.value.has(n))return n;for(let[o,r]of R.value.entries())if(r.type==="mcp-app"&&r.data.mode==="ext-app"&&r.data.toolCallId===e)return o;return null}function Sw(e){let t=typeof e.nodeId==="string"&&e.nodeId.length>0?e.nodeId:null;if(t&&R.value.has(t))return t;if(typeof e.toolCallId!=="string"||!e.toolCallId)return null;return cI(e.toolCallId)}function kw(e,t){if(typeof e!=="string"||!e)return null;if(typeof t!=="string"||!t)return null;let n=null;for(let[o,r]of R.value.entries())if(r.type==="mcp-app"&&r.data.mode==="ext-app"&&r.data.serverName===e&&r.data.toolName===t&&!r.data.toolResult){if(n)return null;n=o}return n}function Cw(e){if(R.value.get("ledger-main"))re("ledger-main",e);else{let o=Pi("ledger-main","ledger",e);o.collapsed=!0,pn(o)}}function Od(e){if(!Kr(e))return;if(document.documentElement.setAttribute("data-theme",e),gr(),Ge.value!==e)Ge.value=e}function lI(e){return e==="markdown"||e==="mcp-app"||e==="webpage"||e==="json-render"||e==="graph"||e==="prompt"||e==="response"||e==="status"||e==="context"||e==="ledger"||e==="trace"||e==="file"||e==="diff"||e==="mermaid"||e==="image"||e==="html"||e==="group"}function uI(e){return e==="relation"||e==="depends-on"||e==="flow"||e==="references"}function Ld(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.x!=="number"||typeof t.y!=="number")return null;return{x:t.x,y:t.y}}function Tw(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.width!=="number"||typeof t.height!=="number")return null;return{width:t.width,height:t.height}}function dI(e){let t=Ld(e),n=Tw(e);return t&&n?{...t,...n}:null}function pI(e){if(typeof e.id!=="string"||!e.id)return null;if(!lI(e.type))return null;let t=Ld(e.position),n=Tw(e.size);if(!t||!n)return null;let o=e.data&&typeof e.data==="object"?Object.fromEntries(Object.entries(e.data)):{};return{id:e.id,type:e.type,position:t,size:n,zIndex:typeof e.zIndex==="number"?e.zIndex:1,collapsed:e.collapsed===!0,pinned:e.pinned===!0,data:o}}function fI(e){if(typeof e.id!=="string"||!e.id)return null;if(typeof e.from!=="string"||!e.from)return null;if(typeof e.to!=="string"||!e.to)return null;if(!uI(e.type))return null;return{id:e.id,from:e.from,to:e.to,type:e.type,...typeof e.label==="string"?{label:e.label}:{},...e.style==="solid"||e.style==="dashed"||e.style==="dotted"?{style:e.style}:{},...e.animated===!0?{animated:!0}:{}}}function mI(e){if(typeof e.id!=="string"||!e.id)return null;if(e.type!=="freehand"&&e.type!=="text")return null;if(!Array.isArray(e.points))return null;let t=e.points.map((o)=>Ld(o)).filter((o)=>o!==null),n=dI(e.bounds);if(t.length<(e.type==="text"?1:2)||!n)return null;return{id:e.id,type:e.type,points:t,bounds:n,color:typeof e.color==="string"?e.color:"#f97316",width:typeof e.width==="number"?e.width:4,...typeof e.text==="string"?{text:e.text}:{},...typeof e.label==="string"?{label:e.label}:{},createdAt:typeof e.createdAt==="string"?e.createdAt:""}}var xw="pmx-canvas-version-reload";function hI(e,t){if(typeof window>"u")return;let n=window,o=(s,a)=>typeof s==="string"&&s!==""&&s!=="unknown"&&typeof a==="string"&&a!==""&&a!=="unknown"&&s!==a;if(!o(e,n.__PMX_BOOT_SERVER_VERSION)&&!o(t,n.__PMX_BOOT_BUNDLE_STAMP))return;let r=`${String(e)}::${String(t)}`;try{if(window.sessionStorage.getItem(xw)===r)return;window.sessionStorage.setItem(xw,r)}catch{return}window.location.reload()}function gI(e){let t=Wn.value[0]?.id;if(fd(e),dt.value&&Wn.value[0]?.id!==t)Vn()}function vI(e){lb(e)}var bw=null;function yI(e){gd(e)}function xI(e){if(dn.value=e.sessionId||"",Tt.value="connected",lo.value+=1,hI(e.version,e.bundleStamp),jr(),Zp().then(fd),bw?.(),!os)bw=Jx();if(ve("fetchHumanPresence","/api/canvas/human-presence",null).then(gd),Dc().then((t)=>{if(Wt.value=t,dt.value)Vn()}),typeof e.theme==="string"&&!Ad())Od(e.theme);if(e.ledgerSummary)Cw(e.ledgerSummary)}function bI(e){if(typeof e.path!=="string"||!e.path)return;let t=e.path,n=(typeof e.title==="string"?e.title:"")||t.split("/").pop()||"Untitled";if(rI(t,n),e.ledgerSummary)Cw(e.ledgerSummary)}function wI(e){Nr(),re("status-main",{message:typeof e.message==="string"?e.message:String(e.message??""),level:e.level??"ok",source:e.source})}function _I(e){Nr(),re("status-main",{phase:e.phase,detail:e.detail})}function SI(e){let t=e.cards??[];iI(t)}function kI(e){if(typeof e.url==="string"&&e.url)sI({url:e.url,sourceServer:e.sourceServer,sourceTool:e.sourceTool,inferredType:e.inferredType,trustedDomain:e.trustedDomain,hostMode:e.hostMode??"hosted"})}function CI(e){let t=e.sessions??[];for(let n of t){let o=n.url;if(!o)continue;let r=`mcp-${zi(o)}`;if(R.value.has(r))re(r,{sessionState:n.state,lastSeenAt:n.lastSeenAt})}}function TI(e){if(typeof e.url==="string"&&e.url){let t=`mcp-${zi(e.url)}`;if(R.value.has(t))re(t,{hostMode:"fallback",fallbackReason:e.reasonCode})}}function EI(e){let n=R.value.get("context-main");if(!n)return;let o=(n.data.auxTabs??[]).concat(e);re("context-main",{auxTabs:o})}function AI(e){if(R.value.has("context-main"))if(e.mode==="all")re("context-main",{auxTabs:[]});else{let o=R.value.get("context-main");if(!o)return;let r=(o.data.auxTabs??[]).filter((s)=>s.id!==e.id);re("context-main",{auxTabs:r})}}function II(e){Nr(),re("status-main",{phase:"idle",lastCompletion:{tokenCount:e.tokenCount,artifactCount:e.artifactCount}})}function zI(e){Nr(),re("status-main",{phase:"tooling",detail:`${e.name}`,activeTool:e.name})}function PI(e){Nr(),re("status-main",{activeTool:null})}function NI(e){if(e.state==="active"&&e.path){let n=`md-${zi(e.path)}`;if(R.value.has(n))re(n,{reviewActive:!0})}}function RI(e){if(typeof e.toolCallId!=="string"||!e.toolCallId)return;aI({toolCallId:e.toolCallId,...typeof e.nodeId==="string"&&e.nodeId.length>0?{nodeId:e.nodeId}:{},title:e.title,html:e.html,toolInput:e.toolInput,serverName:e.serverName,toolName:e.toolName,appSessionId:e.appSessionId,resourceUri:e.resourceUri,toolDefinition:e.toolDefinition,resourceMeta:e.resourceMeta,hostMode:"hosted",trustedDomain:!0,...e.chartConfig?{chartConfig:e.chartConfig}:{},...typeof e.x==="number"&&{_x:e.x},...typeof e.y==="number"&&{_y:e.y},...typeof e.width==="number"&&{_width:e.width},...typeof e.height==="number"&&{_height:e.height}})}function $I(e){if(typeof e.toolCallId!=="string"||!e.toolCallId)return;let t=Sw(e)??kw(e.serverName,e.toolName);if(!t)return;if(R.value.has(t))re(t,{html:e.html})}function MI(e){if(typeof e.toolCallId!=="string"||!e.toolCallId)return;let t=Sw(e)??kw(e.serverName,e.toolName);if(!t)return;if(R.value.has(t)){if(e.success===!1){Et(t);return}re(t,{toolResult:Uu({result:e.result,success:typeof e.success==="boolean"?e.success:void 0,error:typeof e.error==="string"?e.error:void 0,content:typeof e.content==="string"?e.content:void 0,detailedContent:typeof e.detailedContent==="string"?e.detailedContent:void 0})})}}function OI(e){Nr(),re("status-main",{subagent:{state:e.state,name:e.agentDisplayName??e.agentName}})}function LI(e){let t=e.nodeId;if(!t)return;let n=e.text||"",{position:o,parentNodeId:r,contextNodeIds:s}=e;if(e.threadNodeId&&R.value.has(e.threadNodeId)){let a=e.threadNodeId,c=R.value.get(a);if(!c)return;let l=Array.isArray(c.data.turns)?[...c.data.turns]:[],u=l[l.length-1];if(!u||u.role!=="user"||u.text!==n)l.push({role:"user",text:n,status:"pending"});re(a,{turns:l,threadStatus:"pending"});return}if(!R.value.has(t)){let a=o??Xn.prompt;pn(fc(Ai(t,"prompt",{text:n,turns:n?[{role:"user",text:n,status:"pending"}]:[],threadStatus:n?"pending":"draft",status:n?"pending":"draft",parentNodeId:r,contextNodeIds:s},{position:{x:a.x,y:a.y}}))),et(t)}if(r&&R.value.has(r))_s({id:`edge-${r}-${t}`,from:r,to:t,type:"flow",style:"dashed"})}function DI(e){let{nodeId:t,status:n}=e;if(t&&R.value.has(t))re(t,{status:n})}function FI(e){let{responseNodeId:t,promptNodeId:n}=e;if(!t)return;let o=n?R.value.get(n):void 0;if(o&&Array.isArray(o.data.turns)){Pr.set(t,n);let s=[...o.data.turns];s.push({role:"assistant",text:"",status:"streaming"}),re(n,{turns:s,threadStatus:"streaming",_activeResponseId:t}),et(n);return}let r=o?{x:o.position.x,y:o.position.y+o.size.height+24}:{x:Xn.response.x,y:Xn.response.y};if(!R.value.has(t))pn(fc(Ai(t,"response",{content:"",status:"streaming",promptNodeId:n},{position:r})));if(n)_s({id:`edge-${n}-${t}`,from:n,to:t,type:"flow",animated:!0});et(t)}function jI(e){let t=e.responseNodeId;if(!t)return;let n=Pr.get(t);if(n){let o=R.value.get(n);if(o&&Array.isArray(o.data.turns)){let r=[...o.data.turns],s=r[r.length-1];if(s&&s.role==="assistant")s.text=e.content,s.status="streaming";re(n,{turns:r,threadStatus:"streaming"})}return}if(!R.value.has(t))return;re(t,{content:e.content,status:"streaming"})}function ZI(e){let t=e.responseNodeId;if(!t)return;let n=Pr.get(t);if(n){let s=R.value.get(n);if(s&&Array.isArray(s.data.turns)){let a=[...s.data.turns],c=a[a.length-1];if(c&&c.role==="assistant")c.text=e.content,c.status="complete";re(n,{turns:a,threadStatus:"answered",_activeResponseId:void 0})}Pr.delete(t);return}if(!R.value.has(t))return;re(t,{content:e.content,status:"complete"});let r=R.value.get(t)?.data.promptNodeId;if(r){let s=`edge-${r}-${t}`,a=Re.value.get(s);if(a)Tf(s),_s({...a,animated:!1})}}function HI(e){let t=e.layout;if(!t?.nodes)return;let n=!Ut.value;Ut.value=!0;let o=t.nodes.map(pI).filter((c)=>c!==null),r=Array.isArray(t.edges)?t.edges.map(fI).filter((c)=>c!==null):Array.from(Re.value.values()),s=Array.isArray(t.annotations)?t.annotations.map(mI).filter((c)=>c!==null):void 0,a=t.viewport?{x:typeof t.viewport.x==="number"?t.viewport.x:0,y:typeof t.viewport.y==="number"?t.viewport.y:0,scale:typeof t.viewport.scale==="number"?t.viewport.scale:1}:void 0;er(),Nf({...a?{viewport:a}:{},nodes:o,edges:r,...s?{annotations:s}:{}},{applyViewport:n}),Vc({event:"canvas-layout-update",data:e})}function BI(e){if(e<=1)return 500;if(e===2)return 1000;return Math.min(2500,1500+(e-3)*500)}function UI(e){let t=e.nodeId;if(t&&R.value.has(t)){if(e.noPan===!0){fn(t);return}et(t)}}function WI(e){let t=e.viewport;if(!t)return;let n=typeof t.x==="number"?t.x:0,o=typeof t.y==="number"?t.y:0,r=typeof t.scale==="number"?t.scale:1;er(),If({x:n,y:o,scale:r})}function qI(e){if(R.value.get("context-main"))re("context-main",{currentTokens:e.currentTokens,tokenLimit:e.tokenLimit,messagesLength:e.messagesLength,utilization:e.utilization,nearLimit:e.nearLimit})}function VI(e){Xo.value=e.enabled===!0}function GI(e){if(typeof e.theme==="string"&&!Ad())Od(e.theme)}function XI(e){let t=Array.isArray(e.nodeIds)?e.nodeIds.filter((n)=>typeof n==="string"):[];Cf(t),Vc({event:"context-pins-changed",data:e})}var dc=null;function ww(){if(dc)clearTimeout(dc);dc=setTimeout(()=>{if(dc=null,Dc().then((e)=>{Wt.value=e}),dt.value)Vn()},150)}function KI(e){let t=e.intent;if(!t||typeof t.id!=="string"||typeof t.kind!=="string"||typeof t.expiresAt!=="number")return;hx(t)}function JI(e){let t=typeof e.id==="string"?e.id:"";if(!t)return;if(e.settled===!0)vx(t,typeof e.nodeId==="string"?e.nodeId:void 0);else Qu(t)}var Ew={connected:xI,"workbench-open":bI,"canvas-status":wI,"execution-phase":_I,"context-cards":SI,"mcp-app-candidate":kI,"mcp-app-host-snapshot":CI,"mcp-app-host-fallback":TI,"aux-open":EI,"aux-close":AI,"assistant-complete":II,"tool-start":zI,"tool-complete":PI,"review-state":NI,"subagent-status":OI,"ext-app-open":RI,"ext-app-update":$I,"ext-app-result":MI,"context-pins-changed":XI,"canvas-layout-update":HI,"canvas-focus-node":UI,"canvas-viewport-update":WI,"context-usage":qI,"trace-state":VI,"theme-changed":GI,"canvas-prompt-created":LI,"canvas-prompt-status":DI,"canvas-response-start":FI,"canvas-response-delta":jI,"canvas-response-complete":ZI,"ax-state-changed":ww,"ax-event-created":ww,"ax-intent":KI,"ax-intent-clear":JI,"agent-presence":gI,"human-presence":yI,"agent-session-ended":vI};function Aw(e,t){let n=Ew[e];if(!n)return;let o=n;try{o(t)}catch(r){console.warn(`[sse-bridge] Handler for "${e}" failed:`,r)}}function _w(){Ii=!0,Yn+=1;let e=Yn;Tt.value="connecting";let t=null,n=!1,o=async()=>{if(e!==Yn)return;try{let r=new URLSearchParams;if(zr!==null)r.set("since",String(zr));let s=dn.value;if(s)r.set("session",s);let a=r.toString(),c=await fetch(`/api/workbench/poll${a?`?${a}`:""}`);if(e!==Yn)return;if(!c.ok)throw Error(`poll failed with HTTP ${c.status}`);let l=await c.json();if(e!==Yn)return;if(!l.ok)throw Error("poll returned ok: false");let u=t;if(t=l.sessionId??null,u!==null&&l.sessionId&&u!==l.sessionId&&!l.snapshot){zr=null,_n=setTimeout(()=>void o(),0);return}if(l.snapshot&&n)pc=ol(),Ut.value=!1,qc(),ed(),Pr.clear();for(let d of l.events)Aw(d.event,d.payload);n=!0,zr=l.seq,uo.value=0,po.value=0,Tt.value="connected",_n=setTimeout(()=>void o(),tI)}catch(r){if(e!==Yn)return;console.warn("[sse-bridge] poll transport error:",r),Tt.value="disconnected",uo.value+=1,po.value=yw,_n=setTimeout(()=>void o(),yw)}};return o(),()=>{if(Yn+=1,Ii=!1,zr=null,_n)clearTimeout(_n),_n=null}}function Dd(){if(jb(Od),pc=ol(),Ut.value=!1,qc(),ed(),Pr.clear(),Kn)clearTimeout(Kn),Kn=null;let e=nI();if(e==="poll"||Ii)return _w();let t=dn.value,n=t?`/api/workbench/events?session=${t}`:"/api/workbench/events";Tt.value="connecting";let o=new EventSource(n);zo=o;let r=!1;if(Jn)clearTimeout(Jn);if(Jn=null,e!=="sse")Jn=setTimeout(()=>{if(Jn=null,r||zo!==o)return;console.warn("[sse-bridge] No SSE event within watchdog window — switching to polling transport."),window.dispatchEvent(new Event("pmx-canvas-boot-extend")),o.close(),zo=null,_w()},eI);for(let[s]of Object.entries(Ew))o.addEventListener(s,(a)=>{r=!0;try{Aw(s,JSON.parse(a.data))}catch(c){console.warn(`[sse-bridge] Failed to parse "${s}" event:`,c)}});return o.onopen=()=>{if(zo!==o)return;uc=0,uo.value=0,po.value=0,Tt.value="connected"},o.onerror=()=>{if(zo!==o)return;Tt.value="disconnected",o.close(),zo=null,uc+=1;let s=BI(uc);uo.value=uc,po.value=s,Kn=setTimeout(()=>{Kn=null,Dd()},s)},()=>{if(Kn)clearTimeout(Kn),Kn=null;if(Jn)clearTimeout(Jn),Jn=null;if(Ii){if(Yn+=1,Ii=!1,zr=null,_n)clearTimeout(_n),_n=null}o.close(),zo=null}}function Po(e,t){console.error(`[app] ${e} failed`,t)}function Iw(){let[e,t]=L(!0),[n,o]=L(!1),[r,s]=L(!1),[a,c]=L(!1),[l,u]=L(null),d=N(null),{menu:p,openNodeMenu:m,openCanvasMenu:f,openEdgeMenu:y,closeMenu:v}=Hb(),x=Ut.value,h=dt.value,g=M(()=>t((P)=>!P),[]),b=M(()=>o((P)=>!P),[]),O=M(()=>o(!1),[]),F=M((P)=>u(P),[]),_=M((P,Z)=>{$n({x:P,y:Z,scale:oe.value.scale},200)},[]);D(()=>Dd(),[]),D(()=>{let P=null,Z=()=>{if(P!==null)window.clearTimeout(P);P=window.setTimeout(()=>{P=null,jr()},400)};return window.addEventListener("resize",Z),()=>{if(P!==null)window.clearTimeout(P);window.removeEventListener("resize",Z)}},[]),D(()=>{let P=(I)=>{let H=(I.metaKey||I.ctrlKey)&&!I.altKey;if(H&&I.key==="k"){I.preventDefault(),s((q)=>!q);return}if(I.key==="Escape"&&l){I.preventDefault(),u(null);return}if(I.key==="Escape"&&Be.value&&!Yt.value){I.preventDefault(),fo();return}if(I.key==="Escape"&&r){I.preventDefault(),s(!1);return}if(I.key==="Escape"&&a){I.preventDefault(),c(!1);return}let U=I.target,B=U?.tagName;if(B==="INPUT"||B==="TEXTAREA"||U?.isContentEditable)return;if(I.key===" "&&!I.repeat&&!H){I.preventDefault(),Wr.value=!0;return}if(I.key==="?"||I.key==="/"&&I.shiftKey){I.preventDefault(),c((q)=>!q);return}if(H&&(I.key==="z"||I.key==="Z"))I.preventDefault(),_d(I.shiftKey);else if(H&&(I.key==="y"||I.key==="Y"))I.preventDefault(),_d(!0);else if(H&&I.key==="0")I.preventDefault(),$n({x:0,y:0,scale:1},250);else if(H&&(I.key==="="||I.key==="+"))I.preventDefault(),Qo(1.25);else if(H&&I.key==="-")I.preventDefault(),Qo(0.8);else if(I.key==="Escape"){if(xe.value.size>0||un.value!==null){mt();return}Ce.value=null,v()}else if(I.key==="Tab")I.preventDefault(),$f(I.shiftKey?-1:1);else if(I.key==="Delete"||I.key==="Backspace"){if(un.value!==null){let Y=un.value;I.preventDefault(),un.value=null,us(Y).catch((be)=>Po("delete-edge",be));return}let q=xe.value.size>0?[...xe.value]:Ce.value?[Ce.value]:[];if(q.length===0)return;I.preventDefault();for(let Y of q)Et(Y),An(Y).catch((be)=>Po("delete",be));mt(),Ce.value=null}else if(Ce.value&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(I.key)){I.preventDefault();let q=I.key.replace("Arrow","").toLowerCase();Mf(q)}else if(!H&&!I.altKey){let q=I.key.toLowerCase();if(q==="v"&&!I.shiftKey)vt.value="select";else if(q==="c"&&!I.shiftKey&&!H)I.preventDefault(),vt.value=vt.value==="connect"?"select":"connect";else if(q==="m"&&!I.shiftKey)I.preventDefault(),zt({type:"markdown",title:"New note",width:520,height:360}).catch((Y)=>Po("create markdown",Y));else if(q==="a"&&!I.shiftKey)I.preventDefault(),u((Y)=>Y==="pen"?null:"pen");else if(q==="g"&&!I.shiftKey){I.preventDefault();let Y=Array.from(xe.value);if(Y.length>=2)Zo({title:"Group",childIds:Y}).catch((be)=>Po("group selection",be)),mt();else zt({type:"group",title:"Group"}).catch((be)=>Po("create group",be))}else if(q==="g"&&I.shiftKey){I.preventDefault();for(let Y of wf())Et(Y),Ho(Y).catch((be)=>Po("ungroup",be));mt()}else if(q==="i"&&!I.shiftKey)I.preventDefault(),wn("image");else if(q==="w"&&!I.shiftKey)I.preventDefault(),wn("webpage");else if(q==="h"&&!I.shiftKey)I.preventDefault(),zt({type:"html",title:"HTML surface"}).catch((Y)=>Po("create html",Y));else if(q==="f"&&I.shiftKey)I.preventDefault(),wn("file");else if(q==="f"&&!I.shiftKey){I.preventDefault();let Y=bt();tr(Y.width,Y.height)}}},Z=(I)=>{if(I.key===" ")Wr.value=!1},j=()=>{Wr.value=!1};return document.addEventListener("keydown",P),document.addEventListener("keyup",Z),window.addEventListener("blur",j),()=>{document.removeEventListener("keydown",P),document.removeEventListener("keyup",Z),window.removeEventListener("blur",j)}},[l,v,r,a]),D(()=>{let P=window.setTimeout(()=>void jr(),250);return()=>window.clearTimeout(P)},[h]),D(()=>{if(!x)return;let P=window.__pmxCanvasBootstrapReady;if(typeof P==="function")P()},[x]);let k=Array.from(R.value.values()),T=bt();return i("div",{class:"app-shell","data-session-active":h?"true":"false",children:[i(qb,{minimapVisible:e,onToggleMinimap:g,snapshotOpen:n,onToggleSnapshot:b,snapshotBtnRef:d,onOpenPalette:()=>s(!0),onOpenShortcuts:()=>c((P)=>!P),annotationTool:l,onSetAnnotationTool:F},void 0,!1,void 0,this),i("div",{class:"app-main",children:[i(gw,{},void 0,!1,void 0,this),i(Lb,{},void 0,!1,void 0,this),i("div",{class:"canvas-region",ref:(P)=>Rp(P),children:[i(Mb,{onNodeContextMenu:m,onCanvasContextMenu:f,onEdgeContextMenu:y,annotationMode:l!==null,annotationTool:l},void 0,!1,void 0,this),i(Np,{},void 0,!1,void 0,this),i(Pp,{},void 0,!1,void 0,this),i(Xb,{},void 0,!1,void 0,this),i(Kb,{},void 0,!1,void 0,this),x&&k.length===0&&qe.value.size===0&&i(Vb,{onOpenPalette:()=>s(!0)},void 0,!1,void 0,this),xe.value.size>0&&i(iw,{},void 0,!1,void 0,this),h?i(Ob,{},void 0,!1,void 0,this):Ee.value.size>0&&i(Wb,{},void 0,!1,void 0,this),i(lw,{onOpenSnapshots:()=>o(!0)},void 0,!1,void 0,this),i(Mp,{},void 0,!1,void 0,this),Be.value&&i(ew,{},void 0,!1,void 0,this),i(fw,{open:n,onClose:O,anchorRef:d},void 0,!1,void 0,this),e&&i(rw,{viewport:oe,nodes:R,edges:Re,onNavigate:_,containerWidth:T.width,containerHeight:T.height},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),h&&i(cw,{},void 0,!1,void 0,this),p&&i(Bb,{menu:p,onClose:v},void 0,!1,void 0,this),r&&i(Zb,{onClose:()=>s(!1),onToggleMinimap:g},void 0,!1,void 0,this),a&&i(uw,{onClose:()=>c(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}Df();var zw=document.getElementById("app");if(zw)sp(i(Iw,{},void 0,!1,void 0,this),zw);
|