diff --git a/src/conductor/engine/workflow.py b/src/conductor/engine/workflow.py index cf9a896..b8a57b0 100644 --- a/src/conductor/engine/workflow.py +++ b/src/conductor/engine/workflow.py @@ -1618,6 +1618,16 @@ async def _execute_loop(self, current_agent_name: str) -> dict[str, Any]: for a in self.config.agents for r in a.routes ] + + [ + { + "from": a.name, + "to": o.route, + "when": f"selection == '{o.value}'", + } + for a in self.config.agents + if a.type == "human_gate" and a.options + for o in a.options + ] + [ { "from": p.name, diff --git a/src/conductor/web/frontend/src/components/graph/graph-layout.ts b/src/conductor/web/frontend/src/components/graph/graph-layout.ts index b72a386..3e3a7d5 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.ts @@ -230,13 +230,83 @@ export function buildGraphElements( }); } + // Classify edges as forward or back-edges using a DFS from $start. + // Back-edges are loop-back routes (e.g. plan_reviewer → planner when + // approved=false). Feeding them to Dagre as-is causes it to greedily + // reverse arbitrary edges to break cycles, which scrambles the ranking + // and produces disjointed layouts. Pre-classifying lets us pass each + // back-edge to Dagre in REVERSED direction so the layout reflects the + // true forward DAG, while we still render the edge in its original + // direction. + const backEdgeIds = findBackEdges(flowNodes, flowEdges, '$start'); + // Apply dagre layout to top-level nodes only (non-children) - applyDagreLayout(flowNodes, flowEdges); + applyDagreLayout(flowNodes, flowEdges, backEdgeIds); return { nodes: flowNodes, edges: flowEdges }; } -function applyDagreLayout(flowNodes: Node[], flowEdges: Edge[]): void { +/** + * Identify back-edges via DFS from the entry node. An edge u→v is a back-edge + * iff v is an ancestor of u in the DFS tree (i.e. v is currently on the DFS + * stack when we visit u→v). Operates on top-level node IDs only, since edges + * have already been remapped from group children to group parents. + * + * Traversal order is deterministic: outgoing edges are visited in sorted + * target-ID order, and unreachable subgraphs are entered in sorted source-ID + * order, so layout is stable across renders. + */ +function findBackEdges( + flowNodes: Node[], + flowEdges: Edge[], + startId: string, +): Set { + const topLevelIds = new Set(flowNodes.filter((n) => !n.parentId).map((n) => n.id)); + + // Build adjacency from top-level edges. Sort targets for stability. + const adj = new Map(); + for (const e of flowEdges) { + if (!topLevelIds.has(e.source) || !topLevelIds.has(e.target)) continue; + if (!adj.has(e.source)) adj.set(e.source, []); + adj.get(e.source)!.push({ target: e.target, edgeId: e.id }); + } + for (const list of adj.values()) { + list.sort((a, b) => (a.target < b.target ? -1 : a.target > b.target ? 1 : 0)); + } + + const backEdges = new Set(); + const onStack = new Set(); + const visited = new Set(); + + const dfs = (node: string): void => { + visited.add(node); + onStack.add(node); + for (const { target, edgeId } of adj.get(node) ?? []) { + if (onStack.has(target)) { + backEdges.add(edgeId); + } else if (!visited.has(target)) { + dfs(target); + } + } + onStack.delete(node); + }; + + if (topLevelIds.has(startId)) dfs(startId); + + // Also DFS from any unvisited nodes that have outgoing edges, so back-edges + // in unreachable subgraphs are still classified deterministically. + for (const id of [...adj.keys()].sort()) { + if (!visited.has(id)) dfs(id); + } + + return backEdges; +} + +function applyDagreLayout( + flowNodes: Node[], + flowEdges: Edge[], + backEdgeIds: Set, +): void { // Use a NON-compound dagre graph — compound mode causes crashes // when edges cross compound boundaries const g = new dagre.graphlib.Graph(); @@ -253,10 +323,14 @@ function applyDagreLayout(flowNodes: Node[], flowEdges: Edge[]): g.setNode(node.id, { width: w, height: h }); } - // Add edges (dagre needs valid source/target nodes) + // Add edges (dagre needs valid source/target nodes). Back-edges are passed + // in REVERSED direction so dagre ranks the underlying DAG correctly; the + // visible flowEdges entries keep their original direction. for (const edge of flowEdges) { - // Only add edge if both source and target are in dagre graph - if (g.hasNode(edge.source) && g.hasNode(edge.target)) { + if (!g.hasNode(edge.source) || !g.hasNode(edge.target)) continue; + if (backEdgeIds.has(edge.id)) { + g.setEdge(edge.target, edge.source); + } else { g.setEdge(edge.source, edge.target); } } diff --git a/src/conductor/web/static/assets/index-Ds4Y-3QH.js b/src/conductor/web/static/assets/index-FW07qRxR.js similarity index 77% rename from src/conductor/web/static/assets/index-Ds4Y-3QH.js rename to src/conductor/web/static/assets/index-FW07qRxR.js index 0603bc6..39f2532 100644 --- a/src/conductor/web/static/assets/index-Ds4Y-3QH.js +++ b/src/conductor/web/static/assets/index-FW07qRxR.js @@ -14,7 +14,7 @@ var $E=Object.defineProperty;var GE=(e,t,r)=>t in e?$E(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Gy;function QE(){if(Gy)return je;Gy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),x=Symbol.iterator;function b(q){return q===null||typeof q!="object"?null:(q=x&&q[x]||q["@@iterator"],typeof q=="function"?q:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,_={};function S(q,Y,N){this.props=q,this.context=Y,this.refs=_,this.updater=N||w}S.prototype.isReactComponent={},S.prototype.setState=function(q,Y){if(typeof q!="object"&&typeof q!="function"&&q!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,q,Y,"setState")},S.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function C(){}C.prototype=S.prototype;function E(q,Y,N){this.props=q,this.context=Y,this.refs=_,this.updater=N||w}var A=E.prototype=new C;A.constructor=E,k(A,S.prototype),A.isPureReactComponent=!0;var M=Array.isArray;function j(){}var L={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function P(q,Y,N){var $=N.ref;return{$$typeof:e,type:q,key:Y,ref:$!==void 0?$:null,props:N}}function H(q,Y){return P(q.type,Y,q.props)}function B(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function U(q){var Y={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(N){return Y[N]})}var ee=/\/+/g;function I(q,Y){return typeof q=="object"&&q!==null&&q.key!=null?U(""+q.key):Y.toString(36)}function F(q){switch(q.status){case"fulfilled":return q.value;case"rejected":throw q.reason;default:switch(typeof q.status=="string"?q.then(j,j):(q.status="pending",q.then(function(Y){q.status==="pending"&&(q.status="fulfilled",q.value=Y)},function(Y){q.status==="pending"&&(q.status="rejected",q.reason=Y)})),q.status){case"fulfilled":return q.value;case"rejected":throw q.reason}}throw q}function z(q,Y,N,$,X){var J=typeof q;(J==="undefined"||J==="boolean")&&(q=null);var ne=!1;if(q===null)ne=!0;else switch(J){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(q.$$typeof){case e:case t:ne=!0;break;case m:return ne=q._init,z(ne(q._payload),Y,N,$,X)}}if(ne)return X=X(q),ne=$===""?"."+I(q,0):$,M(X)?(N="",ne!=null&&(N=ne.replace(ee,"$&/")+"/"),z(X,Y,N,"",function(xe){return xe})):X!=null&&(B(X)&&(X=H(X,N+(X.key==null||q&&q.key===X.key?"":(""+X.key).replace(ee,"$&/")+"/")+ne)),Y.push(X)),1;ne=0;var re=$===""?".":$+":";if(M(q))for(var se=0;set in e?$E(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Yy;function KE(){return Yy||(Yy=1,(function(e){function t(z,G){var Q=z.length;z.push(G);e:for(;0>>1,D=z[K];if(0>>1;Ka(N,Q))$a(X,N)?(z[K]=X,z[$]=Q,K=$):(z[K]=N,z[Y]=Q,K=Y);else if($a(X,Q))z[K]=X,z[$]=Q,K=$;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],m=1,p=null,x=3,b=!1,w=!1,k=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,C=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function A(z){for(var G=r(h);G!==null;){if(G.callback===null)l(h);else if(G.startTime<=z)l(h),G.sortIndex=G.expirationTime,t(d,G);else break;G=r(h)}}function M(z){if(k=!1,A(z),!w)if(r(d)!==null)w=!0,j||(j=!0,U());else{var G=r(h);G!==null&&F(M,G.startTime-z)}}var j=!1,L=-1,O=5,P=-1;function H(){return _?!0:!(e.unstable_now()-Pz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,x=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,A(z),G=!0;break t}p===r(d)&&l(d),A(z)}else l(d);p=r(d)}if(p!==null)G=!0;else{var q=r(h);q!==null&&F(M,q.startTime-z),G=!1}}break e}finally{p=null,x=Q,b=!1}G=void 0}}finally{G?U():j=!1}}}var U;if(typeof E=="function")U=function(){E(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,I=ee.port2;ee.port1.onmessage=B,U=function(){I.postMessage(null)}}else U=function(){S(B,0)};function F(z,G){L=S(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(h,z),r(d)===null&&z===r(h)&&(k?(C(L),L=-1):k=!0,F(M,Q-K))):(z.sortIndex=D,t(d,z),w||b||(w=!0,j||(j=!0,U()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=x;return function(){var Q=x;x=G;try{return z.apply(this,arguments)}finally{x=Q}}}})(uh)),uh}var Xy;function JE(){return Xy||(Xy=1,sh.exports=KE()),sh.exports}var ch={exports:{}},Ft={};/** + */var Yy;function KE(){return Yy||(Yy=1,(function(e){function t(z,G){var Q=z.length;z.push(G);e:for(;0>>1,D=z[K];if(0>>1;Ka(C,Q))$a(X,C)?(z[K]=X,z[$]=Q,K=$):(z[K]=C,z[Y]=Q,K=Y);else if($a(X,Q))z[K]=X,z[$]=Q,K=$;else break e}}return G}function a(z,G){var Q=z.sortIndex-G.sortIndex;return Q!==0?Q:z.id-G.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],m=1,p=null,x=3,b=!1,w=!1,E=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function A(z){for(var G=r(h);G!==null;){if(G.callback===null)l(h);else if(G.startTime<=z)l(h),G.sortIndex=G.expirationTime,t(d,G);else break;G=r(h)}}function M(z){if(E=!1,A(z),!w)if(r(d)!==null)w=!0,j||(j=!0,U());else{var G=r(h);G!==null&&F(M,G.startTime-z)}}var j=!1,L=-1,R=5,V=-1;function H(){return _?!0:!(e.unstable_now()-Vz&&H());){var K=p.callback;if(typeof K=="function"){p.callback=null,x=p.priorityLevel;var D=K(p.expirationTime<=z);if(z=e.unstable_now(),typeof D=="function"){p.callback=D,A(z),G=!0;break t}p===r(d)&&l(d),A(z)}else l(d);p=r(d)}if(p!==null)G=!0;else{var q=r(h);q!==null&&F(M,q.startTime-z),G=!1}}break e}finally{p=null,x=Q,b=!1}G=void 0}}finally{G?U():j=!1}}}var U;if(typeof k=="function")U=function(){k(B)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,I=ee.port2;ee.port1.onmessage=B,U=function(){I.postMessage(null)}}else U=function(){S(B,0)};function F(z,G){L=S(function(){z(e.unstable_now())},G)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_forceFrameRate=function(z){0>z||125K?(z.sortIndex=Q,t(h,z),r(d)===null&&z===r(h)&&(E?(N(L),L=-1):E=!0,F(M,Q-K))):(z.sortIndex=D,t(d,z),w||b||(w=!0,j||(j=!0,U()))),z},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(z){var G=x;return function(){var Q=x;x=G;try{return z.apply(this,arguments)}finally{x=Q}}}})(uh)),uh}var Xy;function JE(){return Xy||(Xy=1,sh.exports=KE()),sh.exports}var ch={exports:{}},Ft={};/** * @license React * react-dom.production.js * @@ -38,15 +38,15 @@ var $E=Object.defineProperty;var GE=(e,t,r)=>t in e?$E(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ky;function eN(){if(Ky)return go;Ky=1;var e=JE(),t=Zo(),r=dw();function l(n){var i="https://react.dev/errors/"+n;if(1D||(n.current=K[D],K[D]=null,D--)}function N(n,i){D++,K[D]=n.current,n.current=i}var $=q(null),X=q(null),J=q(null),ne=q(null);function re(n,i){switch(N(J,i),N(X,n),N($,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?dy(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=dy(i),n=hy(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y($),N($,n)}function se(){Y($),Y(X),Y(J)}function xe(n){n.memoizedState!==null&&N(ne,n);var i=$.current,s=hy(i,n.type);i!==s&&(N(X,n),N($,s))}function be(n){X.current===n&&(Y($),Y(X)),ne.current===n&&(Y(ne),co._currentValue=Q)}var ye,pe;function _e(n){if(ye===void 0)try{throw Error()}catch(s){var i=s.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1D||(n.current=K[D],K[D]=null,D--)}function C(n,i){D++,K[D]=n.current,n.current=i}var $=q(null),X=q(null),J=q(null),ne=q(null);function re(n,i){switch(C(J,i),C(X,n),C($,null),i.nodeType){case 9:case 11:n=(n=i.documentElement)&&(n=n.namespaceURI)?dy(n):0;break;default:if(n=i.tagName,i=i.namespaceURI)i=dy(i),n=hy(i,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}Y($),C($,n)}function se(){Y($),Y(X),Y(J)}function xe(n){n.memoizedState!==null&&C(ne,n);var i=$.current,s=hy(i,n.type);i!==s&&(C(X,n),C($,s))}function be(n){X.current===n&&(Y($),Y(X)),ne.current===n&&(Y(ne),co._currentValue=Q)}var ye,pe;function _e(n){if(ye===void 0)try{throw Error()}catch(s){var i=s.stack.trim().match(/\n( *(at )?)/);ye=i&&i[1]||"",pe=-1)":-1g||Z[f]!==le[g]){var ce=` `+Z[f].replace(" at new "," at ");return n.displayName&&ce.includes("")&&(ce=ce.replace("",n.displayName)),ce}while(1<=f&&0<=g);break}}}finally{ze=!1,Error.prepareStackTrace=s}return(s=n?n.displayName||n.name:"")?_e(s):""}function ut(n,i){switch(n.tag){case 26:case 27:case 5:return _e(n.type);case 16:return _e("Lazy");case 13:return n.child!==i&&i!==null?_e("Suspense Fallback"):_e("Suspense");case 19:return _e("SuspenseList");case 0:case 15:return Te(n.type,!1);case 11:return Te(n.type.render,!1);case 1:return Te(n.type,!0);case 31:return _e("Activity");default:return""}}function nt(n){try{var i="",s=null;do i+=ut(n,s),s=n,n=n.return;while(n);return i}catch(f){return` Error generating stack: `+f.message+` -`+f.stack}}var zt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Ht=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Mt=e.unstable_now,Hr=e.unstable_getCurrentPriorityLevel,ue=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Oe=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Qt=e.log,On=e.unstable_setDisableYieldValue,Bt=null,vt=null;function $t(n){if(typeof Qt=="function"&&On(n),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(Bt,n)}catch{}}var We=Math.clz32?Math.clz32:Fc,Qn=Math.log,fn=Math.LN2;function Fc(n){return n>>>=0,n===0?32:31-(Qn(n)/fn|0)|0}var cl=256,fl=262144,dl=4194304;function sr(n){var i=n&42;if(i!==0)return i;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,i,s){var f=n.pendingLanes;if(f===0)return 0;var g=0,v=n.suspendedLanes,T=n.pingedLanes;n=n.warmLanes;var R=f&134217727;return R!==0?(f=R&~v,f!==0?g=sr(f):(T&=R,T!==0?g=sr(T):s||(s=R&~n,s!==0&&(g=sr(s))))):(R=f&~v,R!==0?g=sr(R):T!==0?g=sr(T):s||(s=f&~n,s!==0&&(g=sr(s)))),g===0?0:i!==0&&i!==g&&(i&v)===0&&(v=g&-g,s=i&-i,v>=s||v===32&&(s&4194048)!==0)?i:g}function bi(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function Yc(n,i){switch(n){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ss(){var n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function wa(n){for(var i=[],s=0;31>s;s++)i.push(n);return i}function wi(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Xc(n,i,s,f,g,v){var T=n.pendingLanes;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=s,n.entangledLanes&=s,n.errorRecoveryDisabledLanes&=s,n.shellSuspendCounter=0;var R=n.entanglements,Z=n.expirationTimes,le=n.hiddenUpdates;for(s=T&~s;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var Wc=/[\n"\\]/g;function en(n){return n.replace(Wc,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function ki(n,i,s,f,g,v,T,R){n.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?n.type=T:n.removeAttribute("type"),i!=null?T==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+Wt(i)):n.value!==""+Wt(i)&&(n.value=""+Wt(i)):T!=="submit"&&T!=="reset"||n.removeAttribute("value"),i!=null?Na(n,T,Wt(i)):s!=null?Na(n,T,Wt(s)):f!=null&&n.removeAttribute("value"),g==null&&v!=null&&(n.defaultChecked=!!v),g!=null&&(n.checked=g&&typeof g!="function"&&typeof g!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?n.name=""+Wt(R):n.removeAttribute("name")}function ws(n,i,s,f,g,v,T,R){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),i!=null||s!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Pr(n);return}s=s!=null?""+Wt(s):"",i=i!=null?""+Wt(i):s,R||i===n.value||(n.value=i),n.defaultValue=i}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,n.checked=R?n.checked:!!f,n.defaultChecked=!!f,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(n.name=T),Pr(n)}function Na(n,i,s){i==="number"&&_i(n.ownerDocument)===n||n.defaultValue===""+s||(n.defaultValue=""+s)}function fr(n,i,s,f){if(n=n.options,i){i={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lf=!1;if(hr)try{var Ta={};Object.defineProperty(Ta,"passive",{get:function(){lf=!0}}),window.addEventListener("test",Ta,Ta),window.removeEventListener("test",Ta,Ta)}catch{lf=!1}var $r=null,af=null,_s=null;function hg(){if(_s)return _s;var n,i=af,s=i.length,f,g="value"in $r?$r.value:$r.textContent,v=g.length;for(n=0;n=za),vg=" ",bg=!1;function wg(n,i){switch(n){case"keyup":return d2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var bl=!1;function p2(n,i){switch(n){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(bg=!0,vg);case"textInput":return n=i.data,n===vg&&bg?null:n;default:return null}}function m2(n,i){if(bl)return n==="compositionend"||!ff&&wg(n,i)?(n=hg(),_s=af=$r=null,bl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:s,offset:i-n};n=f}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Ag(s)}}function Mg(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Mg(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Dg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=_i(n.document);i instanceof n.HTMLIFrameElement;){try{var s=typeof i.contentWindow.location.href=="string"}catch{s=!1}if(s)n=i.contentWindow;else break;i=_i(n.document)}return i}function pf(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var _2=hr&&"documentMode"in document&&11>=document.documentMode,wl=null,mf=null,Oa=null,gf=!1;function Rg(n,i,s){var f=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;gf||wl==null||wl!==_i(f)||(f=wl,"selectionStart"in f&&pf(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Oa&&Ra(Oa,f)||(Oa=f,f=gu(mf,"onSelect"),0>=T,g-=T,Kn=1<<32-We(i)+g|s<Me?(Pe=Se,Se=null):Pe=Se.sibling;var Ke=ae(te,Se,ie[Me],de);if(Ke===null){Se===null&&(Se=Pe);break}n&&Se&&Ke.alternate===null&&i(te,Se),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,Se=Pe}if(Me===ie.length)return s(te,Se),$e&&mr(te,Me),ke;if(Se===null){for(;MeMe?(Pe=Se,Se=null):Pe=Se.sibling;var di=ae(te,Se,Ke.value,de);if(di===null){Se===null&&(Se=Pe);break}n&&Se&&di.alternate===null&&i(te,Se),W=v(di,W,Me),Ze===null?ke=di:Ze.sibling=di,Ze=di,Se=Pe}if(Ke.done)return s(te,Se),$e&&mr(te,Me),ke;if(Se===null){for(;!Ke.done;Me++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return $e&&mr(te,Me),ke}for(Se=f(Se);!Ke.done;Me++,Ke=ie.next())Ke=oe(Se,te,Me,Ke.value,de),Ke!==null&&(n&&Ke.alternate!==null&&Se.delete(Ke.key===null?Me:Ke.key),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return n&&Se.forEach(function(PE){return i(te,PE)}),$e&&mr(te,Me),ke}function lt(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===k&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===k){if(W.tag===7){s(te,W.sibling),de=g(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===O&&Ri(ke)===W.type){s(te,W.sibling),de=g(W,ie.props),Ua(de,ie),de.return=te,te=de;break e}s(te,W);break}else i(te,W);W=W.sibling}ie.type===k?(de=ji(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Ds(ie.type,ie.key,ie.props,null,te.mode,de),Ua(de,ie),de.return=te,te=de)}return T(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){s(te,W.sibling),de=g(W,ie.children||[]),de.return=te,te=de;break e}else{s(te,W);break}else i(te,W);W=W.sibling}de=_f(ie,te.mode,de),de.return=te,te=de}return T(te);case O:return ie=Ri(ie),lt(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if(U(ie)){if(ke=U(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return lt(te,W,qs(ie),de);if(ie.$$typeof===E)return lt(te,W,Ls(te,ie),de);Us(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(s(te,W.sibling),de=g(W,ie),de.return=te,te=de):(s(te,W),de=Sf(ie,te.mode,de),de.return=te,te=de),T(te)):s(te,W)}return function(te,W,ie,de){try{qa=0;var ke=lt(te,W,ie,de);return Ml=null,ke}catch(Se){if(Se===zl||Se===Bs)throw Se;var Ze=hn(29,Se,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var Li=rx(!0),ix=rx(!1),Qr=!1;function Of(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Lf(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Zr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Kr(n,i,s){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?i.next=i:(i.next=g.next,g.next=i),f.pending=i,i=Ms(n),Ug(n,null,s),i}return zs(n,f,i,s),Ms(n)}function Va(n,i,s){if(i=i.updateQueue,i!==null&&(i=i.shared,(s&4194048)!==0)){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}function Hf(n,i){var s=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,s===f)){var g=null,v=null;if(s=s.firstBaseUpdate,s!==null){do{var T={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};v===null?g=v=T:v=v.next=T,s=s.next}while(s!==null);v===null?g=v=i:v=v.next=i}else g=v=i;s={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},n.updateQueue=s;return}n=s.lastBaseUpdate,n===null?s.firstBaseUpdate=i:n.next=i,s.lastBaseUpdate=i}var Bf=!1;function Pa(){if(Bf){var n=Al;if(n!==null)throw n}}function $a(n,i,s,f){Bf=!1;var g=n.updateQueue;Qr=!1;var v=g.firstBaseUpdate,T=g.lastBaseUpdate,R=g.shared.pending;if(R!==null){g.shared.pending=null;var Z=R,le=Z.next;Z.next=null,T===null?v=le:T.next=le,T=Z;var ce=n.alternate;ce!==null&&(ce=ce.updateQueue,R=ce.lastBaseUpdate,R!==T&&(R===null?ce.firstBaseUpdate=le:R.next=le,ce.lastBaseUpdate=Z))}if(v!==null){var he=g.baseState;T=0,ce=le=Z=null,R=v;do{var ae=R.lane&-536870913,oe=ae!==R.lane;if(oe?(Ve&ae)===ae:(f&ae)===ae){ae!==0&&ae===jl&&(Bf=!0),ce!==null&&(ce=ce.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=n,Ce=R;ae=i;var lt=s;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(lt,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(lt,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Qr=!0}}ae=R.callback,ae!==null&&(n.flags|=64,oe&&(n.flags|=8192),oe=g.callbacks,oe===null?g.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:R.tag,payload:R.payload,callback:R.callback,next:null},ce===null?(le=ce=oe,Z=he):ce=ce.next=oe,T|=ae;if(R=R.next,R===null){if(R=g.shared.pending,R===null)break;oe=R,R=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);ce===null&&(Z=he),g.baseState=Z,g.firstBaseUpdate=le,g.lastBaseUpdate=ce,v===null&&(g.shared.lanes=0),ni|=T,n.lanes=T,n.memoizedState=he}}function lx(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function ax(n,i){var s=n.callbacks;if(s!==null)for(n.callbacks=null,n=0;nv?v:8;var T=z.T,R={};z.T=R,rd(n,!1,i,s);try{var Z=g(),le=z.S;if(le!==null&&le(R,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var ce=M2(Z,f);Ya(n,i,ce,yn(n))}else Ya(n,i,f,yn(n))}catch(he){Ya(n,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,T!==null&&R.types!==null&&(T.types=R.types),z.T=T}}function B2(){}function td(n,i,s,f){if(n.tag!==5)throw Error(l(476));var g=Bx(n).queue;Hx(n,g,i,Q,s===null?B2:function(){return Ix(n),s(f)})}function Bx(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:Q},next:null};var s={};return i.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:s},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function Ix(n){var i=Bx(n);i.next===null&&(i=n.alternate.memoizedState),Ya(n,i.next.queue,{},yn())}function nd(){return qt(co)}function qx(){return wt().memoizedState}function Ux(){return wt().memoizedState}function I2(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var s=yn();n=Zr(s);var f=Kr(i,n,s);f!==null&&(on(f,i,s),Va(f,i,s)),i={cache:zf()},n.payload=i;return}i=i.return}}function q2(n,i,s){var f=yn();s={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ks(n)?Px(i,s):(s=bf(n,i,s,f),s!==null&&(on(s,n,f),$x(s,i,f)))}function Vx(n,i,s){var f=yn();Ya(n,i,s,f)}function Ya(n,i,s,f){var g={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ks(n))Px(i,g);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var T=i.lastRenderedState,R=v(T,s);if(g.hasEagerState=!0,g.eagerState=R,dn(R,T))return zs(n,i,g,0),at===null&&As(),!1}catch{}finally{}if(s=bf(n,i,g,f),s!==null)return on(s,n,f),$x(s,i,f),!0}return!1}function rd(n,i,s,f){if(f={lane:2,revertLane:Od(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ks(n)){if(i)throw Error(l(479))}else i=bf(n,s,f,2),i!==null&&on(i,n,2)}function Ks(n){var i=n.alternate;return n===Ae||i!==null&&i===Ae}function Px(n,i){Rl=$s=!0;var s=n.pending;s===null?i.next=i:(i.next=s.next,s.next=i),n.pending=i}function $x(n,i,s){if((s&4194048)!==0){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}var Xa={readContext:qt,use:Ys,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};Xa.useEffectEvent=gt;var Gx={readContext:qt,use:Ys,useCallback:function(n,i){return Zt().memoizedState=[n,i===void 0?null:i],n},useContext:qt,useEffect:Tx,useImperativeHandle:function(n,i,s){s=s!=null?s.concat([n]):null,Qs(4194308,4,Mx.bind(null,i,n),s)},useLayoutEffect:function(n,i){return Qs(4194308,4,n,i)},useInsertionEffect:function(n,i){Qs(4,2,n,i)},useMemo:function(n,i){var s=Zt();i=i===void 0?null:i;var f=n();if(Hi){$t(!0);try{n()}finally{$t(!1)}}return s.memoizedState=[f,i],f},useReducer:function(n,i,s){var f=Zt();if(s!==void 0){var g=s(i);if(Hi){$t(!0);try{s(i)}finally{$t(!1)}}}else g=i;return f.memoizedState=f.baseState=g,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:g},f.queue=n,n=n.dispatch=q2.bind(null,Ae,n),[f.memoizedState,n]},useRef:function(n){var i=Zt();return n={current:n},i.memoizedState=n},useState:function(n){n=Zf(n);var i=n.queue,s=Vx.bind(null,Ae,i);return i.dispatch=s,[n.memoizedState,s]},useDebugValue:Wf,useDeferredValue:function(n,i){var s=Zt();return ed(s,n,i)},useTransition:function(){var n=Zf(!1);return n=Hx.bind(null,Ae,n.queue,!0,!1),Zt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,s){var f=Ae,g=Zt();if($e){if(s===void 0)throw Error(l(407));s=s()}else{if(s=i(),at===null)throw Error(l(349));(Ve&127)!==0||dx(f,i,s)}g.memoizedState=s;var v={value:s,getSnapshot:i};return g.queue=v,Tx(px.bind(null,f,v,n),[n]),f.flags|=2048,Ll(9,{destroy:void 0},hx.bind(null,f,v,s,i),null),s},useId:function(){var n=Zt(),i=at.identifierPrefix;if($e){var s=Jn,f=Kn;s=(f&~(1<<32-We(f)-1)).toString(32)+s,i="_"+i+"R_"+s,s=Gs++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?T.createElement("select",{is:f.is}):T.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?T.createElement(g,{is:f.is}):T.createElement(g)}}v[Dt]=i,v[Gt]=f;e:for(T=i.child;T!==null;){if(T.tag===5||T.tag===6)v.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===i)break e;for(;T.sibling===null;){if(T.return===null||T.return===i)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}i.stateNode=v;e:switch(Vt(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&wr(i)}}return ft(i),xd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,s),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==f&&wr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(l(166));if(n=J.current,Cl(i)){if(n=i.stateNode,s=i.memoizedProps,f=null,g=It,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}n[Dt]=i,n=!!(n.nodeValue===s||f!==null&&f.suppressHydrationWarning===!0||cy(n.nodeValue,s)),n||Yr(i,!0)}else n=xu(n).createTextNode(f),n[Dt]=i,i.stateNode=n}return ft(i),null;case 31:if(s=i.memoizedState,n===null||n.memoizedState!==null){if(f=Cl(i),s!==null){if(n===null){if(!f)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),n=!1}else s=Cf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=s),n=!0;if(!n)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return ft(i),null;case 13:if(f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(g=Cl(i),f!==null&&f.dehydrated!==null){if(n===null){if(!g)throw Error(l(318));if(g=i.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(l(317));g[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),g=!1}else g=Cf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=g),g=!0;if(!g)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=s,i):(s=f!==null,n=n!==null&&n.memoizedState!==null,s&&(f=i.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),s!==n&&s&&(i.child.flags|=8192),nu(i,i.updateQueue),ft(i),null);case 4:return se(),n===null&&Id(i.stateNode.containerInfo),ft(i),null;case 10:return xr(i.type),ft(i),null;case 19:if(Y(bt),f=i.memoizedState,f===null)return ft(i),null;if(g=(i.flags&128)!==0,v=f.rendering,v===null)if(g)Za(f,!1);else{if(xt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(v=Ps(n),v!==null){for(i.flags|=128,Za(f,!1),n=v.updateQueue,i.updateQueue=n,nu(i,n),i.subtreeFlags=0,n=s,s=i.child;s!==null;)Vg(s,n),s=s.sibling;return N(bt,bt.current&1|2),$e&&mr(i,f.treeForkCount),i.child}n=n.sibling}f.tail!==null&&Mt()>ou&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304)}else{if(!g)if(n=Ps(v),n!==null){if(i.flags|=128,g=!0,n=n.updateQueue,i.updateQueue=n,nu(i,n),Za(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!$e)return ft(i),null}else 2*Mt()-f.renderingStartTime>ou&&s!==536870912&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304);f.isBackwards?(v.sibling=i.child,i.child=v):(n=f.last,n!==null?n.sibling=v:i.child=v,f.last=v)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Mt(),n.sibling=null,s=bt.current,N(bt,g?s&1|2:s&1),$e&&mr(i,f.treeForkCount),n):(ft(i),null);case 22:case 23:return mn(i),qf(),f=i.memoizedState!==null,n!==null?n.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(s&536870912)!==0&&(i.flags&128)===0&&(ft(i),i.subtreeFlags&6&&(i.flags|=8192)):ft(i),s=i.updateQueue,s!==null&&nu(i,s.retryQueue),s=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==s&&(i.flags|=2048),n!==null&&Y(Di),null;case 24:return s=null,n!==null&&(s=n.memoizedState.cache),i.memoizedState.cache!==s&&(i.flags|=2048),xr(_t),ft(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function G2(n,i){switch(Ef(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return xr(_t),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(mn(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Y(bt),null;case 4:return se(),null;case 10:return xr(i.type),null;case 22:case 23:return mn(i),qf(),n!==null&&Y(Di),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return xr(_t),null;case 25:return null;default:return null}}function m0(n,i){switch(Ef(i),i.tag){case 3:xr(_t),se();break;case 26:case 27:case 5:be(i);break;case 4:se();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(bt);break;case 10:xr(i.type);break;case 22:case 23:mn(i),qf(),n!==null&&Y(Di);break;case 24:xr(_t)}}function Ka(n,i){try{var s=i.updateQueue,f=s!==null?s.lastEffect:null;if(f!==null){var g=f.next;s=g;do{if((s.tag&n)===n){f=void 0;var v=s.create,T=s.inst;f=v(),T.destroy=f}s=s.next}while(s!==g)}}catch(R){tt(i,i.return,R)}}function ei(n,i,s){try{var f=i.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&n)===n){var T=f.inst,R=T.destroy;if(R!==void 0){T.destroy=void 0,g=i;var Z=s,le=R;try{le()}catch(ce){tt(g,Z,ce)}}}f=f.next}while(f!==v)}}catch(ce){tt(i,i.return,ce)}}function g0(n){var i=n.updateQueue;if(i!==null){var s=n.stateNode;try{ax(i,s)}catch(f){tt(n,n.return,f)}}}function x0(n,i,s){s.props=Bi(n.type,n.memoizedProps),s.state=n.memoizedState;try{s.componentWillUnmount()}catch(f){tt(n,i,f)}}function Ja(n,i){try{var s=n.ref;if(s!==null){switch(n.tag){case 26:case 27:case 5:var f=n.stateNode;break;case 30:f=n.stateNode;break;default:f=n.stateNode}typeof s=="function"?n.refCleanup=s(f):s.current=f}}catch(g){tt(n,i,g)}}function Wn(n,i){var s=n.ref,f=n.refCleanup;if(s!==null)if(typeof f=="function")try{f()}catch(g){tt(n,i,g)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(g){tt(n,i,g)}else s.current=null}function y0(n){var i=n.type,s=n.memoizedProps,f=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":s.autoFocus&&f.focus();break e;case"img":s.src?f.src=s.src:s.srcSet&&(f.srcset=s.srcSet)}}catch(g){tt(n,n.return,g)}}function yd(n,i,s){try{var f=n.stateNode;hE(f,n.type,s,i),f[Gt]=i}catch(g){tt(n,n.return,g)}}function v0(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&oi(n.type)||n.tag===4}function vd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||v0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&oi(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function bd(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(n,i):(i=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.appendChild(n),s=s._reactRootContainer,s!=null||i.onclick!==null||(i.onclick=dr));else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode,i=null),n=n.child,n!==null))for(bd(n,i,s),n=n.sibling;n!==null;)bd(n,i,s),n=n.sibling}function ru(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?s.insertBefore(n,i):s.appendChild(n);else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode),n=n.child,n!==null))for(ru(n,i,s),n=n.sibling;n!==null;)ru(n,i,s),n=n.sibling}function b0(n){var i=n.stateNode,s=n.memoizedProps;try{for(var f=n.type,g=i.attributes;g.length;)i.removeAttributeNode(g[0]);Vt(i,f,s),i[Dt]=n,i[Gt]=s}catch(v){tt(n,n.return,v)}}var Sr=!1,Nt=!1,wd=!1,w0=typeof WeakSet=="function"?WeakSet:Set,Ot=null;function F2(n,i){if(n=n.containerInfo,Vd=ku,n=Dg(n),pf(n)){if("selectionStart"in n)var s={start:n.selectionStart,end:n.selectionEnd};else e:{s=(s=n.ownerDocument)&&s.defaultView||window;var f=s.getSelection&&s.getSelection();if(f&&f.rangeCount!==0){s=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{s.nodeType,v.nodeType}catch{s=null;break e}var T=0,R=-1,Z=-1,le=0,ce=0,he=n,ae=null;t:for(;;){for(var oe;he!==s||g!==0&&he.nodeType!==3||(R=T+g),he!==v||f!==0&&he.nodeType!==3||(Z=T+f),he.nodeType===3&&(T+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===n)break t;if(ae===s&&++le===g&&(R=T),ae===v&&++ce===f&&(Z=T),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}s=R===-1||Z===-1?null:{start:R,end:Z}}else s=null}s=s||{start:0,end:0}}else s=null;for(Pd={focusedElem:n,selectionRange:s},ku=!1,Ot=i;Ot!==null;)if(i=Ot,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ot=n;else for(;Ot!==null;){switch(i=Ot,v=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(s=0;s title"))),Vt(v,f,s),v[Dt]=n,St(v),f=v;break e;case"link":var T=Cy("link","href",g).get(f+(s.href||""));if(T){for(var R=0;Rlt&&(T=lt,lt=Ce,Ce=T);var te=zg(R,Ce),W=zg(R,lt);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>lt?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=R;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;Rs?32:s,z.T=null,s=Td,Td=null;var v=ii,T=Cr;if(Rt=0,Ul=ii=null,Cr=0,(Je&6)!==0)throw Error(l(331));var R=Je;if(Je|=4,M0(v.current),j0(v,v.current,T,s),Je=R,io(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(Bt,v)}catch{}return!0}finally{G.p=g,z.T=f,Z0(n,i)}}function J0(n,i,s){i=Nn(s,i),i=od(n.stateNode,i,2),n=Kr(n,i,2),n!==null&&(wi(n,2),er(n))}function tt(n,i,s){if(n.tag===3)J0(n,n,s);else for(;i!==null;){if(i.tag===3){J0(i,n,s);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ri===null||!ri.has(f))){n=Nn(s,n),s=Wx(2),f=Kr(i,s,2),f!==null&&(e0(s,f,i,n),wi(f,2),er(f));break}}i=i.return}}function Md(n,i,s){var f=n.pingCache;if(f===null){f=n.pingCache=new Q2;var g=new Set;f.set(i,g)}else g=f.get(i),g===void 0&&(g=new Set,f.set(i,g));g.has(s)||(kd=!0,g.add(s),n=eE.bind(null,n,i,s),i.then(n,n))}function eE(n,i,s){var f=n.pingCache;f!==null&&f.delete(i),n.pingedLanes|=n.suspendedLanes&s,n.warmLanes&=~s,at===n&&(Ve&s)===s&&(xt===4||xt===3&&(Ve&62914560)===Ve&&300>Mt()-au?(Je&2)===0&&Vl(n,0):Ed|=s,ql===Ve&&(ql=0)),er(n)}function W0(n,i){i===0&&(i=ss()),n=Ti(n,i),n!==null&&(wi(n,i),er(n))}function tE(n){var i=n.memoizedState,s=0;i!==null&&(s=i.retryLane),W0(n,s)}function nE(n,i){var s=0;switch(n.tag){case 31:case 13:var f=n.stateNode,g=n.memoizedState;g!==null&&(s=g.retryLane);break;case 19:f=n.stateNode;break;case 22:f=n.stateNode._retryCache;break;default:throw Error(l(314))}f!==null&&f.delete(i),W0(n,s)}function rE(n,i){return Pt(n,i)}var hu=null,$l=null,Dd=!1,pu=!1,Rd=!1,ai=0;function er(n){n!==$l&&n.next===null&&($l===null?hu=$l=n:$l=$l.next=n),pu=!0,Dd||(Dd=!0,lE())}function io(n,i){if(!Rd&&pu){Rd=!0;do for(var s=!1,f=hu;f!==null;){if(n!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var T=f.suspendedLanes,R=f.pingedLanes;v=(1<<31-We(42|n)+1)-1,v&=g&~(T&~R),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(s=!0,ry(f,v))}else v=Ve,v=hl(f,f===at?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||bi(f,v)||(s=!0,ry(f,v));f=f.next}while(s);Rd=!1}}function iE(){ey()}function ey(){pu=Dd=!1;var n=0;ai!==0&&mE()&&(n=ai);for(var i=Mt(),s=null,f=hu;f!==null;){var g=f.next,v=ty(f,i);v===0?(f.next=null,s===null?hu=g:s.next=g,g===null&&($l=s)):(s=f,(n!==0||(v&3)!==0)&&(pu=!0)),f=g}Rt!==0&&Rt!==5||io(n),ai!==0&&(ai=0)}function ty(n,i){for(var s=n.suspendedLanes,f=n.pingedLanes,g=n.expirationTimes,v=n.pendingLanes&-62914561;0R)break;var ce=Z.transferSize,he=Z.initiatorType;ce&&fy(he)&&(Z=Z.responseEnd,T+=ce*(Z"u"?null:document;function _y(n,i,s){var f=Gl;if(f&&typeof i=="string"&&i){var g=en(i);g='link[rel="'+n+'"][href="'+g+'"]',typeof s=="string"&&(g+='[crossorigin="'+s+'"]'),Sy.has(g)||(Sy.add(g),n={rel:n,crossOrigin:s,href:i},f.querySelector(g)===null&&(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function kE(n){Tr.D(n),_y("dns-prefetch",n,null)}function EE(n,i){Tr.C(n,i),_y("preconnect",n,i)}function NE(n,i,s){Tr.L(n,i,s);var f=Gl;if(f&&n&&i){var g='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&s&&s.imageSrcSet?(g+='[imagesrcset="'+en(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(g+='[imagesizes="'+en(s.imageSizes)+'"]')):g+='[href="'+en(n)+'"]';var v=g;switch(i){case"style":v=Fl(n);break;case"script":v=Yl(n)}Mn.has(v)||(n=p({rel:"preload",href:i==="image"&&s&&s.imageSrcSet?void 0:n,as:i},s),Mn.set(v,n),f.querySelector(g)!==null||i==="style"&&f.querySelector(so(v))||i==="script"&&f.querySelector(uo(v))||(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function CE(n,i){Tr.m(n,i);var s=Gl;if(s&&n){var f=i&&typeof i.as=="string"?i.as:"script",g='link[rel="modulepreload"][as="'+en(f)+'"][href="'+en(n)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Yl(n)}if(!Mn.has(v)&&(n=p({rel:"modulepreload",href:n},i),Mn.set(v,n),s.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(uo(v)))return}f=s.createElement("link"),Vt(f,"link",n),St(f),s.head.appendChild(f)}}}function TE(n,i,s){Tr.S(n,i,s);var f=Gl;if(f&&n){var g=Ur(f).hoistableStyles,v=Fl(n);i=i||"default";var T=g.get(v);if(!T){var R={loading:0,preload:null};if(T=f.querySelector(so(v)))R.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":i},s),(s=Mn.get(v))&&Zd(n,s);var Z=T=f.createElement("link");St(Z),Vt(Z,"link",n),Z._p=new Promise(function(le,ce){Z.onload=le,Z.onerror=ce}),Z.addEventListener("load",function(){R.loading|=1}),Z.addEventListener("error",function(){R.loading|=2}),R.loading|=4,vu(T,i,f)}T={type:"stylesheet",instance:T,count:1,state:R},g.set(v,T)}}}function jE(n,i){Tr.X(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0},i),(i=Mn.get(g))&&Kd(n,i),v=s.createElement("script"),St(v),Vt(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function AE(n,i){Tr.M(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0,type:"module"},i),(i=Mn.get(g))&&Kd(n,i),v=s.createElement("script"),St(v),Vt(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function ky(n,i,s,f){var g=(g=J.current)?yu(g):null;if(!g)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(i=Fl(s.href),s=Ur(g).hoistableStyles,f=s.get(i),f||(f={type:"style",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){n=Fl(s.href);var v=Ur(g).hoistableStyles,T=v.get(n);if(T||(g=g.ownerDocument||g,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,T),(v=g.querySelector(so(n)))&&!v._p&&(T.instance=v,T.state.loading=5),Mn.has(n)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Mn.set(n,s),v||zE(g,n,s,T.state))),i&&f===null)throw Error(l(528,""));return T}if(i&&f!==null)throw Error(l(529,""));return null;case"script":return i=s.async,s=s.src,typeof s=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Yl(s),s=Ur(g).hoistableScripts,f=s.get(i),f||(f={type:"script",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function Fl(n){return'href="'+en(n)+'"'}function so(n){return'link[rel="stylesheet"]['+n+"]"}function Ey(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function zE(n,i,s,f){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=n.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),Vt(i,"link",s),St(i),n.head.appendChild(i))}function Yl(n){return'[src="'+en(n)+'"]'}function uo(n){return"script[async]"+n}function Ny(n,i,s){if(i.count++,i.instance===null)switch(i.type){case"style":var f=n.querySelector('style[data-href~="'+en(s.href)+'"]');if(f)return i.instance=f,St(f),f;var g=p({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return f=(n.ownerDocument||n).createElement("style"),St(f),Vt(f,"style",g),vu(f,s.precedence,n),i.instance=f;case"stylesheet":g=Fl(s.href);var v=n.querySelector(so(g));if(v)return i.state.loading|=4,i.instance=v,St(v),v;f=Ey(s),(g=Mn.get(g))&&Zd(f,g),v=(n.ownerDocument||n).createElement("link"),St(v);var T=v;return T._p=new Promise(function(R,Z){T.onload=R,T.onerror=Z}),Vt(v,"link",f),i.state.loading|=4,vu(v,s.precedence,n),i.instance=v;case"script":return v=Yl(s.src),(g=n.querySelector(uo(v)))?(i.instance=g,St(g),g):(f=s,(g=Mn.get(v))&&(f=p({},s),Kd(f,g)),n=n.ownerDocument||n,g=n.createElement("script"),St(g),Vt(g,"link",f),n.head.appendChild(g),i.instance=g);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,vu(f,s.precedence,n));return i.instance}function vu(n,i,s){for(var f=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,T=0;T title"):null)}function ME(n,i,s){if(s===1||i.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return n=i.disabled,typeof i.precedence=="string"&&n==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function jy(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function DE(n,i,s,f){if(s.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var g=Fl(f.href),v=i.querySelector(so(g));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=wu.bind(n),i.then(n,n)),s.state.loading|=4,s.instance=v,St(v);return}v=i.ownerDocument||i,f=Ey(f),(g=Mn.get(g))&&Zd(f,g),v=v.createElement("link"),St(v);var T=v;T._p=new Promise(function(R,Z){T.onload=R,T.onerror=Z}),Vt(v,"link",f),s.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(s,i),(i=s.state.preload)&&(s.state.loading&3)===0&&(n.count++,s=wu.bind(n),i.addEventListener("load",s),i.addEventListener("error",s))}}var Jd=0;function RE(n,i){return n.stylesheets&&n.count===0&&_u(n,n.stylesheets),0Jd?50:800)+i);return n.unsuspend=s,function(){n.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function wu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_u(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Su=null;function _u(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Su=new Map,i.forEach(OE,n),Su=null,wu.call(n))}function OE(n,i){if(!(i.state.loading&4)){var s=Su.get(n);if(s)var f=s.get(null);else{s=new Map,Su.set(n,s);for(var g=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),oh.exports=eN(),oh.exports}var nN=tN();/** +`+f.stack}}var zt=Object.prototype.hasOwnProperty,Pt=e.unstable_scheduleCallback,Ht=e.unstable_cancelCallback,kn=e.unstable_shouldYield,Rn=e.unstable_requestPaint,Mt=e.unstable_now,Hr=e.unstable_getCurrentPriorityLevel,ue=e.unstable_ImmediatePriority,ge=e.unstable_UserBlockingPriority,Ne=e.unstable_NormalPriority,Oe=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Qt=e.log,On=e.unstable_setDisableYieldValue,Bt=null,vt=null;function $t(n){if(typeof Qt=="function"&&On(n),vt&&typeof vt.setStrictMode=="function")try{vt.setStrictMode(Bt,n)}catch{}}var We=Math.clz32?Math.clz32:Fc,Qn=Math.log,fn=Math.LN2;function Fc(n){return n>>>=0,n===0?32:31-(Qn(n)/fn|0)|0}var cl=256,fl=262144,dl=4194304;function sr(n){var i=n&42;if(i!==0)return i;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function hl(n,i,s){var f=n.pendingLanes;if(f===0)return 0;var g=0,v=n.suspendedLanes,T=n.pingedLanes;n=n.warmLanes;var O=f&134217727;return O!==0?(f=O&~v,f!==0?g=sr(f):(T&=O,T!==0?g=sr(T):s||(s=O&~n,s!==0&&(g=sr(s))))):(O=f&~v,O!==0?g=sr(O):T!==0?g=sr(T):s||(s=f&~n,s!==0&&(g=sr(s)))),g===0?0:i!==0&&i!==g&&(i&v)===0&&(v=g&-g,s=i&-i,v>=s||v===32&&(s&4194048)!==0)?i:g}function bi(n,i){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&i)===0}function Yc(n,i){switch(n){case 1:case 2:case 4:case 8:case 64:return i+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ss(){var n=dl;return dl<<=1,(dl&62914560)===0&&(dl=4194304),n}function wa(n){for(var i=[],s=0;31>s;s++)i.push(n);return i}function wi(n,i){n.pendingLanes|=i,i!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Xc(n,i,s,f,g,v){var T=n.pendingLanes;n.pendingLanes=s,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=s,n.entangledLanes&=s,n.errorRecoveryDisabledLanes&=s,n.shellSuspendCounter=0;var O=n.entanglements,Z=n.expirationTimes,le=n.hiddenUpdates;for(s=T&~s;0"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var Wc=/[\n"\\]/g;function en(n){return n.replace(Wc,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function ki(n,i,s,f,g,v,T,O){n.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?n.type=T:n.removeAttribute("type"),i!=null?T==="number"?(i===0&&n.value===""||n.value!=i)&&(n.value=""+Wt(i)):n.value!==""+Wt(i)&&(n.value=""+Wt(i)):T!=="submit"&&T!=="reset"||n.removeAttribute("value"),i!=null?Na(n,T,Wt(i)):s!=null?Na(n,T,Wt(s)):f!=null&&n.removeAttribute("value"),g==null&&v!=null&&(n.defaultChecked=!!v),g!=null&&(n.checked=g&&typeof g!="function"&&typeof g!="symbol"),O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"?n.name=""+Wt(O):n.removeAttribute("name")}function ws(n,i,s,f,g,v,T,O){if(v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(n.type=v),i!=null||s!=null){if(!(v!=="submit"&&v!=="reset"||i!=null)){Pr(n);return}s=s!=null?""+Wt(s):"",i=i!=null?""+Wt(i):s,O||i===n.value||(n.value=i),n.defaultValue=i}f=f??g,f=typeof f!="function"&&typeof f!="symbol"&&!!f,n.checked=O?n.checked:!!f,n.defaultChecked=!!f,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(n.name=T),Pr(n)}function Na(n,i,s){i==="number"&&_i(n.ownerDocument)===n||n.defaultValue===""+s||(n.defaultValue=""+s)}function fr(n,i,s,f){if(n=n.options,i){i={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lf=!1;if(hr)try{var Ta={};Object.defineProperty(Ta,"passive",{get:function(){lf=!0}}),window.addEventListener("test",Ta,Ta),window.removeEventListener("test",Ta,Ta)}catch{lf=!1}var $r=null,af=null,_s=null;function hg(){if(_s)return _s;var n,i=af,s=i.length,f,g="value"in $r?$r.value:$r.textContent,v=g.length;for(n=0;n=za),vg=" ",bg=!1;function wg(n,i){switch(n){case"keyup":return d2.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sg(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var bl=!1;function p2(n,i){switch(n){case"compositionend":return Sg(i);case"keypress":return i.which!==32?null:(bg=!0,vg);case"textInput":return n=i.data,n===vg&&bg?null:n;default:return null}}function m2(n,i){if(bl)return n==="compositionend"||!ff&&wg(n,i)?(n=hg(),_s=af=$r=null,bl=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1=i)return{node:s,offset:i-n};n=f}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Ag(s)}}function Mg(n,i){return n&&i?n===i?!0:n&&n.nodeType===3?!1:i&&i.nodeType===3?Mg(n,i.parentNode):"contains"in n?n.contains(i):n.compareDocumentPosition?!!(n.compareDocumentPosition(i)&16):!1:!1}function Dg(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var i=_i(n.document);i instanceof n.HTMLIFrameElement;){try{var s=typeof i.contentWindow.location.href=="string"}catch{s=!1}if(s)n=i.contentWindow;else break;i=_i(n.document)}return i}function pf(n){var i=n&&n.nodeName&&n.nodeName.toLowerCase();return i&&(i==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||i==="textarea"||n.contentEditable==="true")}var _2=hr&&"documentMode"in document&&11>=document.documentMode,wl=null,mf=null,Oa=null,gf=!1;function Rg(n,i,s){var f=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;gf||wl==null||wl!==_i(f)||(f=wl,"selectionStart"in f&&pf(f)?f={start:f.selectionStart,end:f.selectionEnd}:(f=(f.ownerDocument&&f.ownerDocument.defaultView||window).getSelection(),f={anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset}),Oa&&Ra(Oa,f)||(Oa=f,f=gu(mf,"onSelect"),0>=T,g-=T,Kn=1<<32-We(i)+g|s<Me?(Pe=Se,Se=null):Pe=Se.sibling;var Ke=ae(te,Se,ie[Me],de);if(Ke===null){Se===null&&(Se=Pe);break}n&&Se&&Ke.alternate===null&&i(te,Se),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke,Se=Pe}if(Me===ie.length)return s(te,Se),$e&&mr(te,Me),ke;if(Se===null){for(;MeMe?(Pe=Se,Se=null):Pe=Se.sibling;var di=ae(te,Se,Ke.value,de);if(di===null){Se===null&&(Se=Pe);break}n&&Se&&di.alternate===null&&i(te,Se),W=v(di,W,Me),Ze===null?ke=di:Ze.sibling=di,Ze=di,Se=Pe}if(Ke.done)return s(te,Se),$e&&mr(te,Me),ke;if(Se===null){for(;!Ke.done;Me++,Ke=ie.next())Ke=he(te,Ke.value,de),Ke!==null&&(W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return $e&&mr(te,Me),ke}for(Se=f(Se);!Ke.done;Me++,Ke=ie.next())Ke=oe(Se,te,Me,Ke.value,de),Ke!==null&&(n&&Ke.alternate!==null&&Se.delete(Ke.key===null?Me:Ke.key),W=v(Ke,W,Me),Ze===null?ke=Ke:Ze.sibling=Ke,Ze=Ke);return n&&Se.forEach(function(PE){return i(te,PE)}),$e&&mr(te,Me),ke}function lt(te,W,ie,de){if(typeof ie=="object"&&ie!==null&&ie.type===E&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case b:e:{for(var ke=ie.key;W!==null;){if(W.key===ke){if(ke=ie.type,ke===E){if(W.tag===7){s(te,W.sibling),de=g(W,ie.props.children),de.return=te,te=de;break e}}else if(W.elementType===ke||typeof ke=="object"&&ke!==null&&ke.$$typeof===R&&Ri(ke)===W.type){s(te,W.sibling),de=g(W,ie.props),Ua(de,ie),de.return=te,te=de;break e}s(te,W);break}else i(te,W);W=W.sibling}ie.type===E?(de=ji(ie.props.children,te.mode,de,ie.key),de.return=te,te=de):(de=Ds(ie.type,ie.key,ie.props,null,te.mode,de),Ua(de,ie),de.return=te,te=de)}return T(te);case w:e:{for(ke=ie.key;W!==null;){if(W.key===ke)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){s(te,W.sibling),de=g(W,ie.children||[]),de.return=te,te=de;break e}else{s(te,W);break}else i(te,W);W=W.sibling}de=_f(ie,te.mode,de),de.return=te,te=de}return T(te);case R:return ie=Ri(ie),lt(te,W,ie,de)}if(F(ie))return we(te,W,ie,de);if(U(ie)){if(ke=U(ie),typeof ke!="function")throw Error(l(150));return ie=ke.call(ie),Ce(te,W,ie,de)}if(typeof ie.then=="function")return lt(te,W,qs(ie),de);if(ie.$$typeof===k)return lt(te,W,Ls(te,ie),de);Us(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(s(te,W.sibling),de=g(W,ie),de.return=te,te=de):(s(te,W),de=Sf(ie,te.mode,de),de.return=te,te=de),T(te)):s(te,W)}return function(te,W,ie,de){try{qa=0;var ke=lt(te,W,ie,de);return Ml=null,ke}catch(Se){if(Se===zl||Se===Bs)throw Se;var Ze=hn(29,Se,null,te.mode);return Ze.lanes=de,Ze.return=te,Ze}finally{}}}var Li=rx(!0),ix=rx(!1),Qr=!1;function Of(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Lf(n,i){n=n.updateQueue,i.updateQueue===n&&(i.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function Zr(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function Kr(n,i,s){var f=n.updateQueue;if(f===null)return null;if(f=f.shared,(Je&2)!==0){var g=f.pending;return g===null?i.next=i:(i.next=g.next,g.next=i),f.pending=i,i=Ms(n),Ug(n,null,s),i}return zs(n,f,i,s),Ms(n)}function Va(n,i,s){if(i=i.updateQueue,i!==null&&(i=i.shared,(s&4194048)!==0)){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}function Hf(n,i){var s=n.updateQueue,f=n.alternate;if(f!==null&&(f=f.updateQueue,s===f)){var g=null,v=null;if(s=s.firstBaseUpdate,s!==null){do{var T={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};v===null?g=v=T:v=v.next=T,s=s.next}while(s!==null);v===null?g=v=i:v=v.next=i}else g=v=i;s={baseState:f.baseState,firstBaseUpdate:g,lastBaseUpdate:v,shared:f.shared,callbacks:f.callbacks},n.updateQueue=s;return}n=s.lastBaseUpdate,n===null?s.firstBaseUpdate=i:n.next=i,s.lastBaseUpdate=i}var Bf=!1;function Pa(){if(Bf){var n=Al;if(n!==null)throw n}}function $a(n,i,s,f){Bf=!1;var g=n.updateQueue;Qr=!1;var v=g.firstBaseUpdate,T=g.lastBaseUpdate,O=g.shared.pending;if(O!==null){g.shared.pending=null;var Z=O,le=Z.next;Z.next=null,T===null?v=le:T.next=le,T=Z;var ce=n.alternate;ce!==null&&(ce=ce.updateQueue,O=ce.lastBaseUpdate,O!==T&&(O===null?ce.firstBaseUpdate=le:O.next=le,ce.lastBaseUpdate=Z))}if(v!==null){var he=g.baseState;T=0,ce=le=Z=null,O=v;do{var ae=O.lane&-536870913,oe=ae!==O.lane;if(oe?(Ve&ae)===ae:(f&ae)===ae){ae!==0&&ae===jl&&(Bf=!0),ce!==null&&(ce=ce.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=n,Ce=O;ae=i;var lt=s;switch(Ce.tag){case 1:if(we=Ce.payload,typeof we=="function"){he=we.call(lt,he,ae);break e}he=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ce.payload,ae=typeof we=="function"?we.call(lt,he,ae):we,ae==null)break e;he=p({},he,ae);break e;case 2:Qr=!0}}ae=O.callback,ae!==null&&(n.flags|=64,oe&&(n.flags|=8192),oe=g.callbacks,oe===null?g.callbacks=[ae]:oe.push(ae))}else oe={lane:ae,tag:O.tag,payload:O.payload,callback:O.callback,next:null},ce===null?(le=ce=oe,Z=he):ce=ce.next=oe,T|=ae;if(O=O.next,O===null){if(O=g.shared.pending,O===null)break;oe=O,O=oe.next,oe.next=null,g.lastBaseUpdate=oe,g.shared.pending=null}}while(!0);ce===null&&(Z=he),g.baseState=Z,g.firstBaseUpdate=le,g.lastBaseUpdate=ce,v===null&&(g.shared.lanes=0),ni|=T,n.lanes=T,n.memoizedState=he}}function lx(n,i){if(typeof n!="function")throw Error(l(191,n));n.call(i)}function ax(n,i){var s=n.callbacks;if(s!==null)for(n.callbacks=null,n=0;nv?v:8;var T=z.T,O={};z.T=O,rd(n,!1,i,s);try{var Z=g(),le=z.S;if(le!==null&&le(O,Z),Z!==null&&typeof Z=="object"&&typeof Z.then=="function"){var ce=M2(Z,f);Ya(n,i,ce,yn(n))}else Ya(n,i,f,yn(n))}catch(he){Ya(n,i,{then:function(){},status:"rejected",reason:he},yn())}finally{G.p=v,T!==null&&O.types!==null&&(T.types=O.types),z.T=T}}function B2(){}function td(n,i,s,f){if(n.tag!==5)throw Error(l(476));var g=Bx(n).queue;Hx(n,g,i,Q,s===null?B2:function(){return Ix(n),s(f)})}function Bx(n){var i=n.memoizedState;if(i!==null)return i;i={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:Q},next:null};var s={};return i.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:s},next:null},n.memoizedState=i,n=n.alternate,n!==null&&(n.memoizedState=i),i}function Ix(n){var i=Bx(n);i.next===null&&(i=n.alternate.memoizedState),Ya(n,i.next.queue,{},yn())}function nd(){return qt(co)}function qx(){return wt().memoizedState}function Ux(){return wt().memoizedState}function I2(n){for(var i=n.return;i!==null;){switch(i.tag){case 24:case 3:var s=yn();n=Zr(s);var f=Kr(i,n,s);f!==null&&(on(f,i,s),Va(f,i,s)),i={cache:zf()},n.payload=i;return}i=i.return}}function q2(n,i,s){var f=yn();s={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Ks(n)?Px(i,s):(s=bf(n,i,s,f),s!==null&&(on(s,n,f),$x(s,i,f)))}function Vx(n,i,s){var f=yn();Ya(n,i,s,f)}function Ya(n,i,s,f){var g={lane:f,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(Ks(n))Px(i,g);else{var v=n.alternate;if(n.lanes===0&&(v===null||v.lanes===0)&&(v=i.lastRenderedReducer,v!==null))try{var T=i.lastRenderedState,O=v(T,s);if(g.hasEagerState=!0,g.eagerState=O,dn(O,T))return zs(n,i,g,0),at===null&&As(),!1}catch{}finally{}if(s=bf(n,i,g,f),s!==null)return on(s,n,f),$x(s,i,f),!0}return!1}function rd(n,i,s,f){if(f={lane:2,revertLane:Od(),gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},Ks(n)){if(i)throw Error(l(479))}else i=bf(n,s,f,2),i!==null&&on(i,n,2)}function Ks(n){var i=n.alternate;return n===Ae||i!==null&&i===Ae}function Px(n,i){Rl=$s=!0;var s=n.pending;s===null?i.next=i:(i.next=s.next,s.next=i),n.pending=i}function $x(n,i,s){if((s&4194048)!==0){var f=i.lanes;f&=n.pendingLanes,s|=f,i.lanes=s,cs(n,s)}}var Xa={readContext:qt,use:Ys,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};Xa.useEffectEvent=gt;var Gx={readContext:qt,use:Ys,useCallback:function(n,i){return Zt().memoizedState=[n,i===void 0?null:i],n},useContext:qt,useEffect:Tx,useImperativeHandle:function(n,i,s){s=s!=null?s.concat([n]):null,Qs(4194308,4,Mx.bind(null,i,n),s)},useLayoutEffect:function(n,i){return Qs(4194308,4,n,i)},useInsertionEffect:function(n,i){Qs(4,2,n,i)},useMemo:function(n,i){var s=Zt();i=i===void 0?null:i;var f=n();if(Hi){$t(!0);try{n()}finally{$t(!1)}}return s.memoizedState=[f,i],f},useReducer:function(n,i,s){var f=Zt();if(s!==void 0){var g=s(i);if(Hi){$t(!0);try{s(i)}finally{$t(!1)}}}else g=i;return f.memoizedState=f.baseState=g,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:g},f.queue=n,n=n.dispatch=q2.bind(null,Ae,n),[f.memoizedState,n]},useRef:function(n){var i=Zt();return n={current:n},i.memoizedState=n},useState:function(n){n=Zf(n);var i=n.queue,s=Vx.bind(null,Ae,i);return i.dispatch=s,[n.memoizedState,s]},useDebugValue:Wf,useDeferredValue:function(n,i){var s=Zt();return ed(s,n,i)},useTransition:function(){var n=Zf(!1);return n=Hx.bind(null,Ae,n.queue,!0,!1),Zt().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,i,s){var f=Ae,g=Zt();if($e){if(s===void 0)throw Error(l(407));s=s()}else{if(s=i(),at===null)throw Error(l(349));(Ve&127)!==0||dx(f,i,s)}g.memoizedState=s;var v={value:s,getSnapshot:i};return g.queue=v,Tx(px.bind(null,f,v,n),[n]),f.flags|=2048,Ll(9,{destroy:void 0},hx.bind(null,f,v,s,i),null),s},useId:function(){var n=Zt(),i=at.identifierPrefix;if($e){var s=Jn,f=Kn;s=(f&~(1<<32-We(f)-1)).toString(32)+s,i="_"+i+"R_"+s,s=Gs++,0<\/script>",v=v.removeChild(v.firstChild);break;case"select":v=typeof f.is=="string"?T.createElement("select",{is:f.is}):T.createElement("select"),f.multiple?v.multiple=!0:f.size&&(v.size=f.size);break;default:v=typeof f.is=="string"?T.createElement(g,{is:f.is}):T.createElement(g)}}v[Dt]=i,v[Gt]=f;e:for(T=i.child;T!==null;){if(T.tag===5||T.tag===6)v.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===i)break e;for(;T.sibling===null;){if(T.return===null||T.return===i)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}i.stateNode=v;e:switch(Vt(v,g,f),g){case"button":case"input":case"select":case"textarea":f=!!f.autoFocus;break e;case"img":f=!0;break e;default:f=!1}f&&wr(i)}}return ft(i),xd(i,i.type,n===null?null:n.memoizedProps,i.pendingProps,s),null;case 6:if(n&&i.stateNode!=null)n.memoizedProps!==f&&wr(i);else{if(typeof f!="string"&&i.stateNode===null)throw Error(l(166));if(n=J.current,Cl(i)){if(n=i.stateNode,s=i.memoizedProps,f=null,g=It,g!==null)switch(g.tag){case 27:case 5:f=g.memoizedProps}n[Dt]=i,n=!!(n.nodeValue===s||f!==null&&f.suppressHydrationWarning===!0||cy(n.nodeValue,s)),n||Yr(i,!0)}else n=xu(n).createTextNode(f),n[Dt]=i,i.stateNode=n}return ft(i),null;case 31:if(s=i.memoizedState,n===null||n.memoizedState!==null){if(f=Cl(i),s!==null){if(n===null){if(!f)throw Error(l(318));if(n=i.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(l(557));n[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),n=!1}else s=Cf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=s),n=!0;if(!n)return i.flags&256?(mn(i),i):(mn(i),null);if((i.flags&128)!==0)throw Error(l(558))}return ft(i),null;case 13:if(f=i.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(g=Cl(i),f!==null&&f.dehydrated!==null){if(n===null){if(!g)throw Error(l(318));if(g=i.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(l(317));g[Dt]=i}else Ai(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;ft(i),g=!1}else g=Cf(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=g),g=!0;if(!g)return i.flags&256?(mn(i),i):(mn(i),null)}return mn(i),(i.flags&128)!==0?(i.lanes=s,i):(s=f!==null,n=n!==null&&n.memoizedState!==null,s&&(f=i.child,g=null,f.alternate!==null&&f.alternate.memoizedState!==null&&f.alternate.memoizedState.cachePool!==null&&(g=f.alternate.memoizedState.cachePool.pool),v=null,f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(v=f.memoizedState.cachePool.pool),v!==g&&(f.flags|=2048)),s!==n&&s&&(i.child.flags|=8192),nu(i,i.updateQueue),ft(i),null);case 4:return se(),n===null&&Id(i.stateNode.containerInfo),ft(i),null;case 10:return xr(i.type),ft(i),null;case 19:if(Y(bt),f=i.memoizedState,f===null)return ft(i),null;if(g=(i.flags&128)!==0,v=f.rendering,v===null)if(g)Za(f,!1);else{if(xt!==0||n!==null&&(n.flags&128)!==0)for(n=i.child;n!==null;){if(v=Ps(n),v!==null){for(i.flags|=128,Za(f,!1),n=v.updateQueue,i.updateQueue=n,nu(i,n),i.subtreeFlags=0,n=s,s=i.child;s!==null;)Vg(s,n),s=s.sibling;return C(bt,bt.current&1|2),$e&&mr(i,f.treeForkCount),i.child}n=n.sibling}f.tail!==null&&Mt()>ou&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304)}else{if(!g)if(n=Ps(v),n!==null){if(i.flags|=128,g=!0,n=n.updateQueue,i.updateQueue=n,nu(i,n),Za(f,!0),f.tail===null&&f.tailMode==="hidden"&&!v.alternate&&!$e)return ft(i),null}else 2*Mt()-f.renderingStartTime>ou&&s!==536870912&&(i.flags|=128,g=!0,Za(f,!1),i.lanes=4194304);f.isBackwards?(v.sibling=i.child,i.child=v):(n=f.last,n!==null?n.sibling=v:i.child=v,f.last=v)}return f.tail!==null?(n=f.tail,f.rendering=n,f.tail=n.sibling,f.renderingStartTime=Mt(),n.sibling=null,s=bt.current,C(bt,g?s&1|2:s&1),$e&&mr(i,f.treeForkCount),n):(ft(i),null);case 22:case 23:return mn(i),qf(),f=i.memoizedState!==null,n!==null?n.memoizedState!==null!==f&&(i.flags|=8192):f&&(i.flags|=8192),f?(s&536870912)!==0&&(i.flags&128)===0&&(ft(i),i.subtreeFlags&6&&(i.flags|=8192)):ft(i),s=i.updateQueue,s!==null&&nu(i,s.retryQueue),s=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),f=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),f!==s&&(i.flags|=2048),n!==null&&Y(Di),null;case 24:return s=null,n!==null&&(s=n.memoizedState.cache),i.memoizedState.cache!==s&&(i.flags|=2048),xr(_t),ft(i),null;case 25:return null;case 30:return null}throw Error(l(156,i.tag))}function G2(n,i){switch(Ef(i),i.tag){case 1:return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 3:return xr(_t),se(),n=i.flags,(n&65536)!==0&&(n&128)===0?(i.flags=n&-65537|128,i):null;case 26:case 27:case 5:return be(i),null;case 31:if(i.memoizedState!==null){if(mn(i),i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 13:if(mn(i),n=i.memoizedState,n!==null&&n.dehydrated!==null){if(i.alternate===null)throw Error(l(340));Ai()}return n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 19:return Y(bt),null;case 4:return se(),null;case 10:return xr(i.type),null;case 22:case 23:return mn(i),qf(),n!==null&&Y(Di),n=i.flags,n&65536?(i.flags=n&-65537|128,i):null;case 24:return xr(_t),null;case 25:return null;default:return null}}function m0(n,i){switch(Ef(i),i.tag){case 3:xr(_t),se();break;case 26:case 27:case 5:be(i);break;case 4:se();break;case 31:i.memoizedState!==null&&mn(i);break;case 13:mn(i);break;case 19:Y(bt);break;case 10:xr(i.type);break;case 22:case 23:mn(i),qf(),n!==null&&Y(Di);break;case 24:xr(_t)}}function Ka(n,i){try{var s=i.updateQueue,f=s!==null?s.lastEffect:null;if(f!==null){var g=f.next;s=g;do{if((s.tag&n)===n){f=void 0;var v=s.create,T=s.inst;f=v(),T.destroy=f}s=s.next}while(s!==g)}}catch(O){tt(i,i.return,O)}}function ei(n,i,s){try{var f=i.updateQueue,g=f!==null?f.lastEffect:null;if(g!==null){var v=g.next;f=v;do{if((f.tag&n)===n){var T=f.inst,O=T.destroy;if(O!==void 0){T.destroy=void 0,g=i;var Z=s,le=O;try{le()}catch(ce){tt(g,Z,ce)}}}f=f.next}while(f!==v)}}catch(ce){tt(i,i.return,ce)}}function g0(n){var i=n.updateQueue;if(i!==null){var s=n.stateNode;try{ax(i,s)}catch(f){tt(n,n.return,f)}}}function x0(n,i,s){s.props=Bi(n.type,n.memoizedProps),s.state=n.memoizedState;try{s.componentWillUnmount()}catch(f){tt(n,i,f)}}function Ja(n,i){try{var s=n.ref;if(s!==null){switch(n.tag){case 26:case 27:case 5:var f=n.stateNode;break;case 30:f=n.stateNode;break;default:f=n.stateNode}typeof s=="function"?n.refCleanup=s(f):s.current=f}}catch(g){tt(n,i,g)}}function Wn(n,i){var s=n.ref,f=n.refCleanup;if(s!==null)if(typeof f=="function")try{f()}catch(g){tt(n,i,g)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(g){tt(n,i,g)}else s.current=null}function y0(n){var i=n.type,s=n.memoizedProps,f=n.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":s.autoFocus&&f.focus();break e;case"img":s.src?f.src=s.src:s.srcSet&&(f.srcset=s.srcSet)}}catch(g){tt(n,n.return,g)}}function yd(n,i,s){try{var f=n.stateNode;hE(f,n.type,s,i),f[Gt]=i}catch(g){tt(n,n.return,g)}}function v0(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&oi(n.type)||n.tag===4}function vd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||v0(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&oi(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function bd(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(n,i):(i=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,i.appendChild(n),s=s._reactRootContainer,s!=null||i.onclick!==null||(i.onclick=dr));else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode,i=null),n=n.child,n!==null))for(bd(n,i,s),n=n.sibling;n!==null;)bd(n,i,s),n=n.sibling}function ru(n,i,s){var f=n.tag;if(f===5||f===6)n=n.stateNode,i?s.insertBefore(n,i):s.appendChild(n);else if(f!==4&&(f===27&&oi(n.type)&&(s=n.stateNode),n=n.child,n!==null))for(ru(n,i,s),n=n.sibling;n!==null;)ru(n,i,s),n=n.sibling}function b0(n){var i=n.stateNode,s=n.memoizedProps;try{for(var f=n.type,g=i.attributes;g.length;)i.removeAttributeNode(g[0]);Vt(i,f,s),i[Dt]=n,i[Gt]=s}catch(v){tt(n,n.return,v)}}var Sr=!1,Nt=!1,wd=!1,w0=typeof WeakSet=="function"?WeakSet:Set,Ot=null;function F2(n,i){if(n=n.containerInfo,Vd=ku,n=Dg(n),pf(n)){if("selectionStart"in n)var s={start:n.selectionStart,end:n.selectionEnd};else e:{s=(s=n.ownerDocument)&&s.defaultView||window;var f=s.getSelection&&s.getSelection();if(f&&f.rangeCount!==0){s=f.anchorNode;var g=f.anchorOffset,v=f.focusNode;f=f.focusOffset;try{s.nodeType,v.nodeType}catch{s=null;break e}var T=0,O=-1,Z=-1,le=0,ce=0,he=n,ae=null;t:for(;;){for(var oe;he!==s||g!==0&&he.nodeType!==3||(O=T+g),he!==v||f!==0&&he.nodeType!==3||(Z=T+f),he.nodeType===3&&(T+=he.nodeValue.length),(oe=he.firstChild)!==null;)ae=he,he=oe;for(;;){if(he===n)break t;if(ae===s&&++le===g&&(O=T),ae===v&&++ce===f&&(Z=T),(oe=he.nextSibling)!==null)break;he=ae,ae=he.parentNode}he=oe}s=O===-1||Z===-1?null:{start:O,end:Z}}else s=null}s=s||{start:0,end:0}}else s=null;for(Pd={focusedElem:n,selectionRange:s},ku=!1,Ot=i;Ot!==null;)if(i=Ot,n=i.child,(i.subtreeFlags&1028)!==0&&n!==null)n.return=i,Ot=n;else for(;Ot!==null;){switch(i=Ot,v=i.alternate,n=i.flags,i.tag){case 0:if((n&4)!==0&&(n=i.updateQueue,n=n!==null?n.events:null,n!==null))for(s=0;s title"))),Vt(v,f,s),v[Dt]=n,St(v),f=v;break e;case"link":var T=Cy("link","href",g).get(f+(s.href||""));if(T){for(var O=0;Olt&&(T=lt,lt=Ce,Ce=T);var te=zg(O,Ce),W=zg(O,lt);if(te&&W&&(oe.rangeCount!==1||oe.anchorNode!==te.node||oe.anchorOffset!==te.offset||oe.focusNode!==W.node||oe.focusOffset!==W.offset)){var ie=he.createRange();ie.setStart(te.node,te.offset),oe.removeAllRanges(),Ce>lt?(oe.addRange(ie),oe.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),oe.addRange(ie))}}}}for(he=[],oe=O;oe=oe.parentNode;)oe.nodeType===1&&he.push({element:oe,left:oe.scrollLeft,top:oe.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Os?32:s,z.T=null,s=Td,Td=null;var v=ii,T=Cr;if(Rt=0,Ul=ii=null,Cr=0,(Je&6)!==0)throw Error(l(331));var O=Je;if(Je|=4,M0(v.current),j0(v,v.current,T,s),Je=O,io(0,!1),vt&&typeof vt.onPostCommitFiberRoot=="function")try{vt.onPostCommitFiberRoot(Bt,v)}catch{}return!0}finally{G.p=g,z.T=f,Z0(n,i)}}function J0(n,i,s){i=Nn(s,i),i=od(n.stateNode,i,2),n=Kr(n,i,2),n!==null&&(wi(n,2),er(n))}function tt(n,i,s){if(n.tag===3)J0(n,n,s);else for(;i!==null;){if(i.tag===3){J0(i,n,s);break}else if(i.tag===1){var f=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof f.componentDidCatch=="function"&&(ri===null||!ri.has(f))){n=Nn(s,n),s=Wx(2),f=Kr(i,s,2),f!==null&&(e0(s,f,i,n),wi(f,2),er(f));break}}i=i.return}}function Md(n,i,s){var f=n.pingCache;if(f===null){f=n.pingCache=new Q2;var g=new Set;f.set(i,g)}else g=f.get(i),g===void 0&&(g=new Set,f.set(i,g));g.has(s)||(kd=!0,g.add(s),n=eE.bind(null,n,i,s),i.then(n,n))}function eE(n,i,s){var f=n.pingCache;f!==null&&f.delete(i),n.pingedLanes|=n.suspendedLanes&s,n.warmLanes&=~s,at===n&&(Ve&s)===s&&(xt===4||xt===3&&(Ve&62914560)===Ve&&300>Mt()-au?(Je&2)===0&&Vl(n,0):Ed|=s,ql===Ve&&(ql=0)),er(n)}function W0(n,i){i===0&&(i=ss()),n=Ti(n,i),n!==null&&(wi(n,i),er(n))}function tE(n){var i=n.memoizedState,s=0;i!==null&&(s=i.retryLane),W0(n,s)}function nE(n,i){var s=0;switch(n.tag){case 31:case 13:var f=n.stateNode,g=n.memoizedState;g!==null&&(s=g.retryLane);break;case 19:f=n.stateNode;break;case 22:f=n.stateNode._retryCache;break;default:throw Error(l(314))}f!==null&&f.delete(i),W0(n,s)}function rE(n,i){return Pt(n,i)}var hu=null,$l=null,Dd=!1,pu=!1,Rd=!1,ai=0;function er(n){n!==$l&&n.next===null&&($l===null?hu=$l=n:$l=$l.next=n),pu=!0,Dd||(Dd=!0,lE())}function io(n,i){if(!Rd&&pu){Rd=!0;do for(var s=!1,f=hu;f!==null;){if(n!==0){var g=f.pendingLanes;if(g===0)var v=0;else{var T=f.suspendedLanes,O=f.pingedLanes;v=(1<<31-We(42|n)+1)-1,v&=g&~(T&~O),v=v&201326741?v&201326741|1:v?v|2:0}v!==0&&(s=!0,ry(f,v))}else v=Ve,v=hl(f,f===at?v:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),(v&3)===0||bi(f,v)||(s=!0,ry(f,v));f=f.next}while(s);Rd=!1}}function iE(){ey()}function ey(){pu=Dd=!1;var n=0;ai!==0&&mE()&&(n=ai);for(var i=Mt(),s=null,f=hu;f!==null;){var g=f.next,v=ty(f,i);v===0?(f.next=null,s===null?hu=g:s.next=g,g===null&&($l=s)):(s=f,(n!==0||(v&3)!==0)&&(pu=!0)),f=g}Rt!==0&&Rt!==5||io(n),ai!==0&&(ai=0)}function ty(n,i){for(var s=n.suspendedLanes,f=n.pingedLanes,g=n.expirationTimes,v=n.pendingLanes&-62914561;0O)break;var ce=Z.transferSize,he=Z.initiatorType;ce&&fy(he)&&(Z=Z.responseEnd,T+=ce*(Z"u"?null:document;function _y(n,i,s){var f=Gl;if(f&&typeof i=="string"&&i){var g=en(i);g='link[rel="'+n+'"][href="'+g+'"]',typeof s=="string"&&(g+='[crossorigin="'+s+'"]'),Sy.has(g)||(Sy.add(g),n={rel:n,crossOrigin:s,href:i},f.querySelector(g)===null&&(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function kE(n){Tr.D(n),_y("dns-prefetch",n,null)}function EE(n,i){Tr.C(n,i),_y("preconnect",n,i)}function NE(n,i,s){Tr.L(n,i,s);var f=Gl;if(f&&n&&i){var g='link[rel="preload"][as="'+en(i)+'"]';i==="image"&&s&&s.imageSrcSet?(g+='[imagesrcset="'+en(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(g+='[imagesizes="'+en(s.imageSizes)+'"]')):g+='[href="'+en(n)+'"]';var v=g;switch(i){case"style":v=Fl(n);break;case"script":v=Yl(n)}Mn.has(v)||(n=p({rel:"preload",href:i==="image"&&s&&s.imageSrcSet?void 0:n,as:i},s),Mn.set(v,n),f.querySelector(g)!==null||i==="style"&&f.querySelector(so(v))||i==="script"&&f.querySelector(uo(v))||(i=f.createElement("link"),Vt(i,"link",n),St(i),f.head.appendChild(i)))}}function CE(n,i){Tr.m(n,i);var s=Gl;if(s&&n){var f=i&&typeof i.as=="string"?i.as:"script",g='link[rel="modulepreload"][as="'+en(f)+'"][href="'+en(n)+'"]',v=g;switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":v=Yl(n)}if(!Mn.has(v)&&(n=p({rel:"modulepreload",href:n},i),Mn.set(v,n),s.querySelector(g)===null)){switch(f){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(uo(v)))return}f=s.createElement("link"),Vt(f,"link",n),St(f),s.head.appendChild(f)}}}function TE(n,i,s){Tr.S(n,i,s);var f=Gl;if(f&&n){var g=Ur(f).hoistableStyles,v=Fl(n);i=i||"default";var T=g.get(v);if(!T){var O={loading:0,preload:null};if(T=f.querySelector(so(v)))O.loading=5;else{n=p({rel:"stylesheet",href:n,"data-precedence":i},s),(s=Mn.get(v))&&Zd(n,s);var Z=T=f.createElement("link");St(Z),Vt(Z,"link",n),Z._p=new Promise(function(le,ce){Z.onload=le,Z.onerror=ce}),Z.addEventListener("load",function(){O.loading|=1}),Z.addEventListener("error",function(){O.loading|=2}),O.loading|=4,vu(T,i,f)}T={type:"stylesheet",instance:T,count:1,state:O},g.set(v,T)}}}function jE(n,i){Tr.X(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0},i),(i=Mn.get(g))&&Kd(n,i),v=s.createElement("script"),St(v),Vt(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function AE(n,i){Tr.M(n,i);var s=Gl;if(s&&n){var f=Ur(s).hoistableScripts,g=Yl(n),v=f.get(g);v||(v=s.querySelector(uo(g)),v||(n=p({src:n,async:!0,type:"module"},i),(i=Mn.get(g))&&Kd(n,i),v=s.createElement("script"),St(v),Vt(v,"link",n),s.head.appendChild(v)),v={type:"script",instance:v,count:1,state:null},f.set(g,v))}}function ky(n,i,s,f){var g=(g=J.current)?yu(g):null;if(!g)throw Error(l(446));switch(n){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(i=Fl(s.href),s=Ur(g).hoistableStyles,f=s.get(i),f||(f={type:"style",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){n=Fl(s.href);var v=Ur(g).hoistableStyles,T=v.get(n);if(T||(g=g.ownerDocument||g,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},v.set(n,T),(v=g.querySelector(so(n)))&&!v._p&&(T.instance=v,T.state.loading=5),Mn.has(n)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Mn.set(n,s),v||zE(g,n,s,T.state))),i&&f===null)throw Error(l(528,""));return T}if(i&&f!==null)throw Error(l(529,""));return null;case"script":return i=s.async,s=s.src,typeof s=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=Yl(s),s=Ur(g).hoistableScripts,f=s.get(i),f||(f={type:"script",instance:null,count:0,state:null},s.set(i,f)),f):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,n))}}function Fl(n){return'href="'+en(n)+'"'}function so(n){return'link[rel="stylesheet"]['+n+"]"}function Ey(n){return p({},n,{"data-precedence":n.precedence,precedence:null})}function zE(n,i,s,f){n.querySelector('link[rel="preload"][as="style"]['+i+"]")?f.loading=1:(i=n.createElement("link"),f.preload=i,i.addEventListener("load",function(){return f.loading|=1}),i.addEventListener("error",function(){return f.loading|=2}),Vt(i,"link",s),St(i),n.head.appendChild(i))}function Yl(n){return'[src="'+en(n)+'"]'}function uo(n){return"script[async]"+n}function Ny(n,i,s){if(i.count++,i.instance===null)switch(i.type){case"style":var f=n.querySelector('style[data-href~="'+en(s.href)+'"]');if(f)return i.instance=f,St(f),f;var g=p({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return f=(n.ownerDocument||n).createElement("style"),St(f),Vt(f,"style",g),vu(f,s.precedence,n),i.instance=f;case"stylesheet":g=Fl(s.href);var v=n.querySelector(so(g));if(v)return i.state.loading|=4,i.instance=v,St(v),v;f=Ey(s),(g=Mn.get(g))&&Zd(f,g),v=(n.ownerDocument||n).createElement("link"),St(v);var T=v;return T._p=new Promise(function(O,Z){T.onload=O,T.onerror=Z}),Vt(v,"link",f),i.state.loading|=4,vu(v,s.precedence,n),i.instance=v;case"script":return v=Yl(s.src),(g=n.querySelector(uo(v)))?(i.instance=g,St(g),g):(f=s,(g=Mn.get(v))&&(f=p({},s),Kd(f,g)),n=n.ownerDocument||n,g=n.createElement("script"),St(g),Vt(g,"link",f),n.head.appendChild(g),i.instance=g);case"void":return null;default:throw Error(l(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(f=i.instance,i.state.loading|=4,vu(f,s.precedence,n));return i.instance}function vu(n,i,s){for(var f=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=f.length?f[f.length-1]:null,v=g,T=0;T title"):null)}function ME(n,i,s){if(s===1||i.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return n=i.disabled,typeof i.precedence=="string"&&n==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function jy(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function DE(n,i,s,f){if(s.type==="stylesheet"&&(typeof f.media!="string"||matchMedia(f.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var g=Fl(f.href),v=i.querySelector(so(g));if(v){i=v._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(n.count++,n=wu.bind(n),i.then(n,n)),s.state.loading|=4,s.instance=v,St(v);return}v=i.ownerDocument||i,f=Ey(f),(g=Mn.get(g))&&Zd(f,g),v=v.createElement("link"),St(v);var T=v;T._p=new Promise(function(O,Z){T.onload=O,T.onerror=Z}),Vt(v,"link",f),s.instance=v}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(s,i),(i=s.state.preload)&&(s.state.loading&3)===0&&(n.count++,s=wu.bind(n),i.addEventListener("load",s),i.addEventListener("error",s))}}var Jd=0;function RE(n,i){return n.stylesheets&&n.count===0&&_u(n,n.stylesheets),0Jd?50:800)+i);return n.unsuspend=s,function(){n.unsuspend=null,clearTimeout(f),clearTimeout(g)}}:null}function wu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_u(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Su=null;function _u(n,i){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Su=new Map,i.forEach(OE,n),Su=null,wu.call(n))}function OE(n,i){if(!(i.state.loading&4)){var s=Su.get(n);if(s)var f=s.get(null);else{s=new Map,Su.set(n,s);for(var g=n.querySelectorAll("link[data-precedence],style[data-precedence]"),v=0;v"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),oh.exports=eN(),oh.exports}var nN=tN();/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. @@ -61,12 +61,12 @@ Error generating stack: `+f.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const lN=V.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:u,...c},d)=>V.createElement("svg",{ref:d,...iN,width:t,height:t,stroke:e,strokeWidth:l?Number(r)*24/Number(t):r,className:hw("lucide",a),...c},[...u.map(([h,m])=>V.createElement(h,m)),...Array.isArray(o)?o:[o]]));/** + */const lN=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:a="",children:o,iconNode:u,...c},d)=>P.createElement("svg",{ref:d,...iN,width:t,height:t,stroke:e,strokeWidth:l?Number(r)*24/Number(t):r,className:hw("lucide",a),...c},[...u.map(([h,m])=>P.createElement(h,m)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Ue=(e,t)=>{const r=V.forwardRef(({className:l,...a},o)=>V.createElement(lN,{ref:o,iconNode:t,className:hw(`lucide-${rN(e)}`,l),...a}));return r.displayName=`${e}`,r};/** + */const Ue=(e,t)=>{const r=P.forwardRef(({className:l,...a},o)=>P.createElement(lN,{ref:o,iconNode:t,className:hw(`lucide-${rN(e)}`,l),...a}));return r.displayName=`${e}`,r};/** * @license lucide-react v0.469.0 - ISC * * This source code is licensed under the ISC license. @@ -251,8 +251,8 @@ Error generating stack: `+f.message+` * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const EN=Ue("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ev=e=>{let t;const r=new Set,l=(h,m)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(b=>b(t,x))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>d,subscribe:h=>(r.add(h),()=>r.delete(h))},d=t=e(l,a,c);return c},NN=(e=>e?ev(e):ev),CN=e=>e;function TN(e,t=CN){const r=ta.useSyncExternalStore(e.subscribe,ta.useCallback(()=>t(e.getState()),[e,t]),ta.useCallback(()=>t(e.getInitialState()),[e,t]));return ta.useDebugValue(r),r}const tv=e=>{const t=NN(e),r=l=>TN(t,l);return Object.assign(r,t),r},jN=(e=>e?tv(e):tv);function Ge(e,t,r="agent"){return e[t]||(e[t]={name:t,status:"pending",type:r,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function zu(e,t,r){Ge(e,t).activity.push(r)}function Le(e,t){e[t]&&(e[t]={...e[t]})}function xo(e,t,r,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(u=>u.key===r);o&&o.activity.push(l)}function AN(e,t,r,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:r,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function tr(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){u=c;break}if(u===-1)return null;r.push(u),a=l[u],l=a.children}return{indexPath:r,ctx:a}}function zN(e,t){for(let r=e.length-1;r>=0;r--){const l=e[r];if(l.slotKey===t)return{ctx:l,index:r}}return null}const fe=jN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:r=>{e({_wsSend:r})},sendGateResponse:(r,l,a)=>{const o=fe.getState()._wsSend;o&&o({type:"gate_response",agent_name:r,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(r,l,a)=>{const o=fe.getState()._wsSend;o&&o({type:"dialog_message",agent_name:r,dialog_id:l,content:a})},sendDialogDecline:(r,l)=>{const a=fe.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:r,dialog_id:l})},processEvent:r=>{const l=Mu[r.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:r.timestamp};l&&l(o,r.data,r.timestamp);const u=Du(r);u&&o.eventLog.push(u);const c=Ru(r);return c&&o.activityLog.push(c),o})},replayState:r=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},selectNode:r=>{e({selectedNode:r})},setReplayMode:r=>{e(l=>{const a={...l,replayMode:!0,replayEvents:r,replayTotalEvents:r.length,replayPosition:r.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},setReplayPosition:r=>{e(l=>{const a=l.replayEvents.slice(0,r),o={...l,replayPosition:r,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const u of a){const c=Mu[u.type];c&&c(o,u.data,u.timestamp);const d=Du(u);d&&o.eventLog.push(d);const h=Ru(u);h&&o.activityLog.push(h),o.lastEventTime=u.timestamp}return o})},setReplayPlaying:r=>{e({replayPlaying:r})},setReplaySpeed:r=>{e({replaySpeed:r})},setWsStatus:r=>{e({wsStatus:r})},setEdgeHighlight:(r,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(u=>!(u.from===r&&u.to===l)),{from:r,to:l,state:a}]}))},clearEdgeHighlight:(r,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===r&&o.to===l))}))},navigateToContext:r=>{e({viewContextPath:r,selectedNode:null})},navigateUp:()=>{e(r=>({viewContextPath:r.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:r=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=tr(l.subworkflowContexts,a);if(!c)return;o=c.children}const u=zN(o,r);u&&e({viewContextPath:[...a,u.index],selectedNode:null})},getViewedContext:()=>{const r=t();if(r.viewContextPath.length===0)return{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts};const l=tr(r.subworkflowContexts,r.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts}},getBreadcrumbs:()=>{const r=t(),l=[{label:r.workflowName||"Root",path:[]}];let a=r.subworkflowContexts;for(let o=0;o0&&(r=((a=Pi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),r){const o=r;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:u=>{o.totalCost+=u,e.totalCost+=u},addTokens:u=>{o.totalTokens+=u,e.totalTokens+=u},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Mu={workflow_started:(e,t,r)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=r??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],Ge(e.nodes,"$start","start"),e.nodes.$start.status="running",Le(e.nodes,"$start");const o=new Set,u=new Set;for(const c of e.parallelGroups){for(const d of c.agents)o.add(d);u.add(c.name),Ge(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const d of c.agents)Ge(e.nodes,d,"agent")}for(const c of e.forEachGroups)u.add(c.name),Ge(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!u.has(c.name)&&!o.has(c.name)){const d=c.type||"agent";Ge(e.nodes,c.name,d),c.model&&(e.nodes[c.name].model=c.model),u.add(c.name)}e.agentsTotal=u.size}else{const o=t.subworkflow_path,u=Array.isArray(o)&&o.length>0?((a=Pi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:tr(e.subworkflowContexts,e.activeContextPath);if(u){u.workflowName=l.name||"",u.status="running",u.entryPoint=l.entry_point||null,u.agents=l.agents||[],u.routes=l.routes||[],u.parallelGroups=l.parallel_groups||[],u.forEachGroups=l.for_each_groups||[],Ge(u.nodes,"$start","start"),u.nodes.$start.status="running";const c=new Set,d=new Set;for(const h of u.parallelGroups){for(const m of h.agents)c.add(m);d.add(h.name),Ge(u.nodes,h.name,"parallel_group"),u.groupProgress[h.name]={total:h.agents.length,completed:0,failed:0};for(const m of h.agents)Ge(u.nodes,m,"agent")}for(const h of u.forEachGroups)d.add(h.name),Ge(u.nodes,h.name,"for_each_group"),u.groupProgress[h.name]={total:0,completed:0,failed:0};for(const h of u.agents)if(!d.has(h.name)&&!c.has(h.name)){const m=h.type||"agent";Ge(u.nodes,h.name,m),h.model&&(u.nodes[h.name].model=h.model),d.add(h.name)}u.agentsTotal=d.size}}e.wfDepth++},agent_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ge(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=r??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,Le(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.input_tokens=r.input_tokens,a.output_tokens=r.output_tokens,a.cost_usd=r.cost_usd,a.output=r.output,a.output_keys=r.output_keys,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Le(l.nodes,r.agent_name)},agent_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message;for(const o of l.routes)o.to===r.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});Le(l.nodes,r.agent_name)},agent_prompt_rendered:(e,t)=>{var u;const r=t,l=t.item_key,a=ht(e,t),o=Ge(a.nodes,r.agent_name);if(o.prompt=r.rendered_prompt,o.context_keys=r.context_keys,l){xo(a.nodes,r.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((u=r.rendered_prompt)==null?void 0:u.slice(0,500))||null});const c=a.nodes[r.agent_name];if(c!=null&&c.for_each_items){const d=c.for_each_items.find(h=>h.key===l);d&&(d.prompt=r.rendered_prompt)}}Le(a.nodes,r.agent_name)},agent_reasoning:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:r.content};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_tool_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:r.tool_name,detail:r.arguments||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_tool_complete:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:r.tool_name||"done",detail:r.result||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_turn_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${r.turn??"?"}`};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_message:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.latest_message=r.content,Le(l.nodes,r.agent_name)},script_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ge(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,Le(a.nodes,l.agent_name)},script_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.stdout=r.stdout,a.stderr=r.stderr,a.exit_code=r.exit_code,Le(l.nodes,r.agent_name)},script_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Le(l.nodes,r.agent_name)},gate_presented:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="waiting",a.options=r.options,a.option_details=r.option_details,a.prompt=r.prompt,Le(l.nodes,r.agent_name)},gate_resolved:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=r.selected_option,a.route=r.route,a.additional_input=r.additional_input,Le(l.nodes,r.agent_name)},route_taken:(e,t)=>{const r=t;ht(e,t).highlightedEdges.push({from:r.from_agent,to:r.to_agent,state:"taken"})},parallel_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"parallel_group");a.status="running",l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.agents.length,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Le(l.nodes,r.group_name)},parallel_agent_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ge(l.nodes,r.agent_name);a.status="completed",a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.cost_usd=r.cost_usd,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Le(l.nodes,r.agent_name),Le(l.nodes,r.group_name)},parallel_agent_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Le(l.nodes,r.agent_name),Le(l.nodes,r.group_name)},parallel_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ge(l.nodes,r.group_name,"parallel_group");a.status=r.failure_count===0?"completed":"failed",Le(l.nodes,r.group_name)},for_each_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.item_count,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Le(l.nodes,r.group_name)},for_each_item_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:r.item_key??String(r.index),index:r.index,status:"running",activity:[]}),Le(l.nodes,r.group_name)},for_each_item_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ge(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="completed",u.elapsed=r.elapsed,u.tokens=r.tokens,u.cost_usd=r.cost_usd,u.output=r.output)}Le(l.nodes,r.group_name)},for_each_item_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ge(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message)}Le(l.nodes,r.group_name)},for_each_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ge(l.nodes,r.group_name,"for_each_group");a.status=(r.failure_count??0)===0?"completed":"failed",a.elapsed=r.elapsed,a.success_count=r.success_count,a.failure_count=r.failure_count,Le(l.nodes,r.group_name)},workflow_completed:(e,t)=>{var r;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.workflowOutput=l.output??null,e.nodes.$end&&(e.nodes.$end.status="completed",Le(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",Le(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(r=Pi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:r.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const r=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.workflowFailedAgent=r.agent_name||null,r.agent_name&&e.nodes[r.agent_name]){e.nodes[r.agent_name].status="failed",Le(e.nodes,r.agent_name);for(const a of e.routes)a.to===r.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:r.error_type,message:r.message,elapsed_seconds:r.elapsed_seconds,timeout_seconds:r.timeout_seconds,current_agent:r.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",Le(e.nodes,"$start"))}else{const a=r.subworkflow_path?(l=Pi(e.subworkflowContexts,r.subworkflow_path))==null?void 0:l.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:r.error_type,message:r.message})}},subworkflow_started:(e,t)=>{const r=t,l=r.slot_key??(r.item_key!=null?`${r.agent_name}[${r.item_key}]`:r.agent_name),a=AN(r.agent_name,r.iteration??1,r.workflow,l);let o;if(r.parent_path!==void 0){const c=Pi(e.subworkflowContexts,r.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let u;if(o.length===0)e.subworkflowContexts.push(a),u=[e.subworkflowContexts.length-1];else{const c=tr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),u=[...o,c.children.length-1]}if(e.activeContextPath=u,o.length===0){const c=e.nodes[r.agent_name];c&&(c.status="running",Le(e.nodes,r.agent_name))}else{const c=tr(e.subworkflowContexts,o);if(c){const d=c.nodes[r.agent_name];d&&(d.status="running",Le(c.nodes,r.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Pi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];if(u){if(r.item_key==null)if(u.status="completed",u.elapsed=r.elapsed,l.length===0)e.agentsCompleted++;else{const c=tr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Le(a,r.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Pi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];u&&r.item_key==null&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message,Le(a,r.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const r=t;r.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:r.path})},agent_paused:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),Le(e.nodes,r.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Le(e.nodes,r.agent_name),e.isPaused=!1},dialog_started:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_id=r.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:r.agent_name,dialogId:r.dialog_id},e.dialogEngaged=!1,Le(e.nodes,r.agent_name)},dialog_message:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:r.role,content:r.content}),r.role==="user"?l.dialog_awaiting_response=!0:r.role==="agent"&&(l.dialog_awaiting_response=!1),Le(e.nodes,r.agent_name)},dialog_completed:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Le(e.nodes,r.agent_name)}};function Du(e){var l,a;const t=e.timestamp,r=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${r.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Agent completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}${r.cost_usd!=null?` · $${r.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Agent failed: ${r.message||r.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Script completed (exit ${r.exit_code??"?"})${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Script failed: ${r.message||r.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Gate resolved → ${r.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${r.from_agent} → ${r.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`Parallel group started (${((l=r.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:r.failure_count===0?"success":"error",source:String(r.group_name),message:`Parallel group completed${r.failure_count>0?` with ${r.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`For-each started (${r.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(r.failure_count??0)===0?"success":"error",source:String(r.group_name),message:`For-each completed · ${r.success_count} succeeded${r.failure_count>0?` · ${r.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${r.message||r.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=r.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Agent resumed — re-executing"};case"dialog_started":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Dialog completed (${r.turn_count||0} messages)`};default:return null}}function Qu(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Ru(e){const t=e.timestamp,r=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(r.agent_name),type:"prompt",message:"Prompt rendered",detail:yo(String(r.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(r.agent_name),type:"reasoning",message:String(r.content||"")};case"agent_tool_start":return{timestamp:t,source:String(r.agent_name),type:"tool-start",message:`→ ${r.tool_name}`,detail:r.arguments?yo(String(r.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`← ${r.tool_name||"done"}`,detail:r.result?yo(String(r.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Turn ${r.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(r.agent_name),type:"message",message:yo(String(r.content||""),500)};case"agent_completed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Failed: ${r.message||r.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Script completed (exit ${r.exit_code??"?"})`,detail:r.stdout?yo(String(r.stdout),300):null};case"script_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Script failed: ${r.message||r.error_type||"unknown"}`};default:return null}}function yo(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function nv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function MN(e){const t=new Map;for(let r=0;ra)o=u;else break}o>r&&t.set(r,o)}return t}function DN(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,u,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:u}),rv(c??"")]})}const r=e.match(/^(\s*)(- )(.*)/);if(r){const[,l,a,o]=r;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),rv(o??"")]})}return y.jsx("span",{children:e})}function rv(e){if(!e)return"";const t=e.indexOf(" #"),r=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=r;return/^(true|false|null|yes|no)$/i.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^\d+(\.\d+)?$/.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^["'].*["']$/.test(r.trim())?a=y.jsx("span",{className:"text-green-400",children:r}):(r.includes("|")||r.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:r})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function RN({yaml:e,onClose:t}){const[r,l]=V.useState(new Set);V.useEffect(()=>{const d=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t]);const a=V.useMemo(()=>e.split(` -`),[e]),o=V.useMemo(()=>MN(a),[a]),u=V.useCallback(d=>{l(h=>{const m=new Set(h);return m.has(d)?m.delete(d):m.add(d),m})},[]),c=V.useMemo(()=>{const d=[];let h=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>u(d),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Rr,{className:"w-3 h-3"}):y.jsx(il,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[DN(h),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>u(d),children:"···"})]})]},d))})})]})]})}function ON(){const e=fe(S=>S.workflowName),t=fe(S=>S.workflowStatus),r=fe(S=>S.isPaused),l=fe(S=>S.workflowYaml),a=fe(S=>S.conductorVersion),[o,u]=V.useState(!1),[c,d]=V.useState(!1),[h,m]=V.useState(!1),[p,x]=V.useState(!1),b=t==="running"||t==="pending";V.useEffect(()=>{r||(u(!1),d(!1),m(!1))},[r]);const w=async()=>{u(!0);try{await fetch("/api/stop",{method:"POST"})}catch(S){console.error("Failed to stop agent:",S),u(!1)}},k=async()=>{d(!0);try{await fetch("/api/resume",{method:"POST"})}catch(S){console.error("Failed to resume agent:",S),d(!1)}},_=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(S){console.error("Failed to kill workflow:",S),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(pw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[r?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:k,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded + */const EN=Ue("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ev=e=>{let t;const r=new Set,l=(h,m)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(b=>b(t,x))}},a=()=>t,c={setState:l,getState:a,getInitialState:()=>d,subscribe:h=>(r.add(h),()=>r.delete(h))},d=t=e(l,a,c);return c},NN=(e=>e?ev(e):ev),CN=e=>e;function TN(e,t=CN){const r=ta.useSyncExternalStore(e.subscribe,ta.useCallback(()=>t(e.getState()),[e,t]),ta.useCallback(()=>t(e.getInitialState()),[e,t]));return ta.useDebugValue(r),r}const tv=e=>{const t=NN(e),r=l=>TN(t,l);return Object.assign(r,t),r},jN=(e=>e?tv(e):tv);function Ge(e,t,r="agent"){return e[t]||(e[t]={name:t,status:"pending",type:r,activity:[]}),e[t].activity||(e[t].activity=[]),e[t]}function zu(e,t,r){Ge(e,t).activity.push(r)}function Le(e,t){e[t]&&(e[t]={...e[t]})}function xo(e,t,r,l){const a=e[t];if(!(a!=null&&a.for_each_items))return;const o=a.for_each_items.find(u=>u.key===r);o&&o.activity.push(l)}function AN(e,t,r,l){return{parentAgent:e,iteration:t,slotKey:l??e,workflowFile:r,workflowName:"",status:"pending",agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],entryPoint:null,children:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,eventLog:[],activityLog:[],workflowOutput:null,workflowFailure:null}}function tr(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;l=0;c--)if(l[c].slotKey===o){u=c;break}if(u===-1)return null;r.push(u),a=l[u],l=a.children}return{indexPath:r,ctx:a}}function zN(e,t){for(let r=e.length-1;r>=0;r--){const l=e[r];if(l.slotKey===t)return{ctx:l,index:r}}return null}const fe=jN((e,t)=>({workflowName:"",workflowStatus:"pending",workflowStartTime:null,workflowFailure:null,workflowFailedAgent:null,workflowYaml:null,conductorVersion:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],nodes:{},groupProgress:{},highlightedEdges:[],agentsCompleted:0,agentsTotal:0,totalCost:0,totalTokens:0,selectedNode:null,wsStatus:"connecting",eventLog:[],activityLog:[],workflowOutput:null,lastEventTime:null,isPaused:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[],replayMode:!1,replayEvents:[],replayPosition:0,replayTotalEvents:0,replayPlaying:!1,replaySpeed:1,_wsSend:null,setWsSend:r=>{e({_wsSend:r})},sendGateResponse:(r,l,a)=>{const o=fe.getState()._wsSend;o&&o({type:"gate_response",agent_name:r,selected_value:l,additional_input:a||{}})},activeDialog:null,dialogEngaged:!1,engageDialog:()=>{e({dialogEngaged:!0})},sendDialogMessage:(r,l,a)=>{const o=fe.getState()._wsSend;o&&o({type:"dialog_message",agent_name:r,dialog_id:l,content:a})},sendDialogDecline:(r,l)=>{const a=fe.getState()._wsSend;a&&a({type:"dialog_decline",agent_name:r,dialog_id:l})},processEvent:r=>{const l=Mu[r.type];e(a=>{const o={...a,nodes:{...a.nodes},groupProgress:{...a.groupProgress},eventLog:[...a.eventLog],activityLog:[...a.activityLog],lastEventTime:r.timestamp};l&&l(o,r.data,r.timestamp);const u=Du(r);u&&o.eventLog.push(u);const c=Ru(r);return c&&o.activityLog.push(c),o})},replayState:r=>{e(l=>{const a={...l,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},selectNode:r=>{e({selectedNode:r})},setReplayMode:r=>{e(l=>{const a={...l,replayMode:!0,replayEvents:r,replayTotalEvents:r.length,replayPosition:r.length,replayPlaying:!1,replaySpeed:1,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const o of r){const u=Mu[o.type];u&&u(a,o.data,o.timestamp);const c=Du(o);c&&a.eventLog.push(c);const d=Ru(o);d&&a.activityLog.push(d),a.lastEventTime=o.timestamp}return a})},setReplayPosition:r=>{e(l=>{const a=l.replayEvents.slice(0,r),o={...l,replayPosition:r,agentsCompleted:0,totalCost:0,totalTokens:0,nodes:{},groupProgress:{},highlightedEdges:[],eventLog:[],activityLog:[],workflowOutput:null,workflowFailedAgent:null,workflowStatus:"pending",workflowStartTime:null,workflowName:"",workflowFailure:null,entryPoint:null,agents:[],routes:[],parallelGroups:[],forEachGroups:[],isPaused:!1,lastEventTime:null,activeDialog:null,dialogEngaged:!1,wfDepth:0,subworkflowContexts:[],activeContextPath:[],viewContextPath:[]};for(const u of a){const c=Mu[u.type];c&&c(o,u.data,u.timestamp);const d=Du(u);d&&o.eventLog.push(d);const h=Ru(u);h&&o.activityLog.push(h),o.lastEventTime=u.timestamp}return o})},setReplayPlaying:r=>{e({replayPlaying:r})},setReplaySpeed:r=>{e({replaySpeed:r})},setWsStatus:r=>{e({wsStatus:r})},setEdgeHighlight:(r,l,a)=>{e(o=>({highlightedEdges:[...o.highlightedEdges.filter(u=>!(u.from===r&&u.to===l)),{from:r,to:l,state:a}]}))},clearEdgeHighlight:(r,l)=>{e(a=>({highlightedEdges:a.highlightedEdges.filter(o=>!(o.from===r&&o.to===l))}))},navigateToContext:r=>{e({viewContextPath:r,selectedNode:null})},navigateUp:()=>{e(r=>({viewContextPath:r.viewContextPath.slice(0,-1),selectedNode:null}))},navigateIntoSubworkflow:r=>{const l=t(),a=l.viewContextPath;let o;if(a.length===0)o=l.subworkflowContexts;else{const c=tr(l.subworkflowContexts,a);if(!c)return;o=c.children}const u=zN(o,r);u&&e({viewContextPath:[...a,u.index],selectedNode:null})},getViewedContext:()=>{const r=t();if(r.viewContextPath.length===0)return{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts};const l=tr(r.subworkflowContexts,r.viewContextPath);return l?{workflowName:l.workflowName,agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,highlightedEdges:l.highlightedEdges,entryPoint:l.entryPoint,subworkflowContexts:l.children}:{workflowName:r.workflowName,agents:r.agents,routes:r.routes,parallelGroups:r.parallelGroups,forEachGroups:r.forEachGroups,nodes:r.nodes,groupProgress:r.groupProgress,highlightedEdges:r.highlightedEdges,entryPoint:r.entryPoint,subworkflowContexts:r.subworkflowContexts}},getBreadcrumbs:()=>{const r=t(),l=[{label:r.workflowName||"Root",path:[]}];let a=r.subworkflowContexts;for(let o=0;o0&&(r=((a=Pi(e.subworkflowContexts,l))==null?void 0:a.ctx)??null),r){const o=r;return{nodes:o.nodes,groupProgress:o.groupProgress,routes:o.routes,highlightedEdges:o.highlightedEdges,addCost:u=>{o.totalCost+=u,e.totalCost+=u},addTokens:u=>{o.totalTokens+=u,e.totalTokens+=u},incrCompleted:()=>{o.agentsCompleted++,e.agentsCompleted++}}}return{nodes:e.nodes,groupProgress:e.groupProgress,routes:e.routes,highlightedEdges:e.highlightedEdges,addCost:o=>{e.totalCost+=o},addTokens:o=>{e.totalTokens+=o},incrCompleted:()=>{e.agentsCompleted++}}}const Mu={workflow_started:(e,t,r)=>{var a;const l=t;if(e.wfDepth===0){e.workflowStatus="running",e.workflowStartTime=r??Date.now()/1e3,e.workflowName=l.name||"",e.workflowYaml=t.yaml_source??null,e.conductorVersion=t.version??null,e.entryPoint=l.entry_point||null,e.agents=l.agents||[],e.routes=l.routes||[],e.parallelGroups=l.parallel_groups||[],e.forEachGroups=l.for_each_groups||[],Ge(e.nodes,"$start","start"),e.nodes.$start.status="running",Le(e.nodes,"$start");const o=new Set,u=new Set;for(const c of e.parallelGroups){for(const d of c.agents)o.add(d);u.add(c.name),Ge(e.nodes,c.name,"parallel_group"),e.groupProgress[c.name]={total:c.agents.length,completed:0,failed:0};for(const d of c.agents)Ge(e.nodes,d,"agent")}for(const c of e.forEachGroups)u.add(c.name),Ge(e.nodes,c.name,"for_each_group"),e.groupProgress[c.name]={total:0,completed:0,failed:0};for(const c of e.agents)if(!u.has(c.name)&&!o.has(c.name)){const d=c.type||"agent";Ge(e.nodes,c.name,d),c.model&&(e.nodes[c.name].model=c.model),u.add(c.name)}e.agentsTotal=u.size}else{const o=t.subworkflow_path,u=Array.isArray(o)&&o.length>0?((a=Pi(e.subworkflowContexts,o))==null?void 0:a.ctx)??null:tr(e.subworkflowContexts,e.activeContextPath);if(u){u.workflowName=l.name||"",u.status="running",u.entryPoint=l.entry_point||null,u.agents=l.agents||[],u.routes=l.routes||[],u.parallelGroups=l.parallel_groups||[],u.forEachGroups=l.for_each_groups||[],Ge(u.nodes,"$start","start"),u.nodes.$start.status="running";const c=new Set,d=new Set;for(const h of u.parallelGroups){for(const m of h.agents)c.add(m);d.add(h.name),Ge(u.nodes,h.name,"parallel_group"),u.groupProgress[h.name]={total:h.agents.length,completed:0,failed:0};for(const m of h.agents)Ge(u.nodes,m,"agent")}for(const h of u.forEachGroups)d.add(h.name),Ge(u.nodes,h.name,"for_each_group"),u.groupProgress[h.name]={total:0,completed:0,failed:0};for(const h of u.agents)if(!d.has(h.name)&&!c.has(h.name)){const m=h.type||"agent";Ge(u.nodes,h.name,m),h.model&&(u.nodes[h.name].model=h.model),d.add(h.name)}u.agentsTotal=d.size}}e.wfDepth++},agent_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ge(a.nodes,l.agent_name);o.iteration!=null&&(o.output!=null||o.error_type!=null)&&(o.iterationHistory||(o.iterationHistory=[]),o.iterationHistory.push({iteration:o.iteration,prompt:o.prompt,output:o.output,elapsed:o.elapsed,model:o.model,tokens:o.tokens,input_tokens:o.input_tokens,output_tokens:o.output_tokens,cost_usd:o.cost_usd,activity:o.activity,error_type:o.error_type,error_message:o.error_message})),o.status="running",o.iteration=l.iteration,o.startedAt=r??Date.now()/1e3,o.activity=[],l.context_window_max!=null&&(o.context_window_max=l.context_window_max),o.prompt=void 0,o.output=void 0,o.error_type=void 0,o.error_message=void 0,Le(a.nodes,l.agent_name)},agent_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.input_tokens=r.input_tokens,a.output_tokens=r.output_tokens,a.cost_usd=r.cost_usd,a.output=r.output,a.output_keys=r.output_keys,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Le(l.nodes,r.agent_name)},agent_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message;for(const o of l.routes)o.to===r.agent_name&&l.highlightedEdges.push({from:o.from,to:o.to,state:"failed"});Le(l.nodes,r.agent_name)},agent_prompt_rendered:(e,t)=>{var u;const r=t,l=t.item_key,a=ht(e,t),o=Ge(a.nodes,r.agent_name);if(o.prompt=r.rendered_prompt,o.context_keys=r.context_keys,l){xo(a.nodes,r.agent_name,l,{type:"prompt",icon:"📝",label:"prompt",text:"Prompt rendered",detail:((u=r.rendered_prompt)==null?void 0:u.slice(0,500))||null});const c=a.nodes[r.agent_name];if(c!=null&&c.for_each_items){const d=c.for_each_items.find(h=>h.key===l);d&&(d.prompt=r.rendered_prompt)}}Le(a.nodes,r.agent_name)},agent_reasoning:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"reasoning",icon:"💭",label:"thinking",text:r.content};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_tool_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-start",icon:"🔧",label:"tool",text:r.tool_name,detail:r.arguments||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_tool_complete:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"tool-complete",icon:"✓",label:"result",text:r.tool_name||"done",detail:r.result||null};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_turn_start:(e,t)=>{const r=t,l=t.item_key,a=ht(e,t),o={type:"turn",icon:"⏳",label:"turn",text:`Turn ${r.turn??"?"}`};zu(a.nodes,r.agent_name,o),l&&xo(a.nodes,r.agent_name,l,o),Le(a.nodes,r.agent_name)},agent_message:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.latest_message=r.content,Le(l.nodes,r.agent_name)},script_started:(e,t,r)=>{const l=t,a=ht(e,t),o=Ge(a.nodes,l.agent_name);o.status="running",o.startedAt=r??Date.now()/1e3,Le(a.nodes,l.agent_name)},script_completed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.elapsed=r.elapsed,a.stdout=r.stdout,a.stderr=r.stderr,a.exit_code=r.exit_code,Le(l.nodes,r.agent_name)},script_failed:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Le(l.nodes,r.agent_name)},gate_presented:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="waiting",a.options=r.options,a.option_details=r.option_details,a.prompt=r.prompt,Le(l.nodes,r.agent_name)},gate_resolved:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.agent_name);a.status="completed",l.incrCompleted(),a.selected_option=r.selected_option,a.route=r.route,a.additional_input=r.additional_input,Le(l.nodes,r.agent_name)},route_taken:(e,t)=>{const r=t;ht(e,t).highlightedEdges.push({from:r.from_agent,to:r.to_agent,state:"taken"})},parallel_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"parallel_group");a.status="running",l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.agents.length,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Le(l.nodes,r.group_name)},parallel_agent_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ge(l.nodes,r.agent_name);a.status="completed",a.elapsed=r.elapsed,a.model=r.model,a.tokens=r.tokens,a.cost_usd=r.cost_usd,a.context_window_used=r.context_window_used,a.context_window_max=r.context_window_max,r.context_window_used!=null&&r.context_window_max!=null&&r.context_window_max>0&&(a.context_pct=Math.round(r.context_window_used/r.context_window_max*100)),r.cost_usd&&l.addCost(r.cost_usd),r.tokens&&l.addTokens(r.tokens),Le(l.nodes,r.agent_name),Le(l.nodes,r.group_name)},parallel_agent_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ge(l.nodes,r.agent_name);a.status="failed",a.elapsed=r.elapsed,a.error_type=r.error_type,a.error_message=r.message,Le(l.nodes,r.agent_name),Le(l.nodes,r.group_name)},parallel_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ge(l.nodes,r.group_name,"parallel_group");a.status=r.failure_count===0?"completed":"failed",Le(l.nodes,r.group_name)},for_each_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"for_each_group");a.status="running",a.for_each_items=[],l.groupProgress[r.group_name]&&(l.groupProgress[r.group_name].total=r.item_count,l.groupProgress[r.group_name].completed=0,l.groupProgress[r.group_name].failed=0),Le(l.nodes,r.group_name)},for_each_item_started:(e,t)=>{const r=t,l=ht(e,t),a=Ge(l.nodes,r.group_name,"for_each_group");a.for_each_items||(a.for_each_items=[]),a.for_each_items.push({key:r.item_key??String(r.index),index:r.index,status:"running",activity:[]}),Le(l.nodes,r.group_name)},for_each_item_completed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].completed++;const a=Ge(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="completed",u.elapsed=r.elapsed,u.tokens=r.tokens,u.cost_usd=r.cost_usd,u.output=r.output)}Le(l.nodes,r.group_name)},for_each_item_failed:(e,t)=>{const r=t,l=ht(e,t);l.groupProgress[r.group_name]&&l.groupProgress[r.group_name].failed++;const a=Ge(l.nodes,r.group_name,"for_each_group");if(a.for_each_items){const o=r.item_key??String(r.index),u=a.for_each_items.find(c=>c.key===o);u&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message)}Le(l.nodes,r.group_name)},for_each_completed:(e,t)=>{const r=t,l=ht(e,t);l.incrCompleted();const a=Ge(l.nodes,r.group_name,"for_each_group");a.status=(r.failure_count??0)===0?"completed":"failed",a.elapsed=r.elapsed,a.success_count=r.success_count,a.failure_count=r.failure_count,Le(l.nodes,r.group_name)},workflow_completed:(e,t)=>{var r;if(e.wfDepth=Math.max(0,e.wfDepth-1),e.wfDepth===0){const l=t;e.workflowStatus="completed",e.isPaused=!1,e.workflowOutput=l.output??null,e.nodes.$end&&(e.nodes.$end.status="completed",Le(e.nodes,"$end")),e.nodes.$start&&(e.nodes.$start.status="completed",Le(e.nodes,"$start")),e.highlightedEdges=[]}else{const l=t,a=l.subworkflow_path?(r=Pi(e.subworkflowContexts,l.subworkflow_path))==null?void 0:r.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="completed",a.workflowOutput=l.output??null,a.nodes.$end&&(a.nodes.$end.status="completed"),a.nodes.$start&&(a.nodes.$start.status="completed"),a.highlightedEdges=[])}},workflow_failed:(e,t)=>{var l;e.wfDepth=Math.max(0,e.wfDepth-1);const r=t;if(e.wfDepth===0){if(e.workflowStatus="failed",e.isPaused=!1,e.workflowFailedAgent=r.agent_name||null,r.agent_name&&e.nodes[r.agent_name]){e.nodes[r.agent_name].status="failed",Le(e.nodes,r.agent_name);for(const a of e.routes)a.to===r.agent_name&&e.highlightedEdges.push({from:a.from,to:a.to,state:"failed"})}e.workflowFailure={error_type:r.error_type,message:r.message,elapsed_seconds:r.elapsed_seconds,timeout_seconds:r.timeout_seconds,current_agent:r.current_agent},e.nodes.$start&&(e.nodes.$start.status="completed",Le(e.nodes,"$start"))}else{const a=r.subworkflow_path?(l=Pi(e.subworkflowContexts,r.subworkflow_path))==null?void 0:l.ctx:tr(e.subworkflowContexts,e.activeContextPath);a&&(a.status="failed",a.workflowFailure={error_type:r.error_type,message:r.message})}},subworkflow_started:(e,t)=>{const r=t,l=r.slot_key??(r.item_key!=null?`${r.agent_name}[${r.item_key}]`:r.agent_name),a=AN(r.agent_name,r.iteration??1,r.workflow,l);let o;if(r.parent_path!==void 0){const c=Pi(e.subworkflowContexts,r.parent_path);if(!c)return;o=c.indexPath}else o=e.activeContextPath;let u;if(o.length===0)e.subworkflowContexts.push(a),u=[e.subworkflowContexts.length-1];else{const c=tr(e.subworkflowContexts,o);if(!c)return;c.children.push(a),u=[...o,c.children.length-1]}if(e.activeContextPath=u,o.length===0){const c=e.nodes[r.agent_name];c&&(c.status="running",Le(e.nodes,r.agent_name))}else{const c=tr(e.subworkflowContexts,o);if(c){const d=c.nodes[r.agent_name];d&&(d.status="running",Le(c.nodes,r.agent_name))}}},subworkflow_completed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Pi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];if(u){if(r.item_key==null)if(u.status="completed",u.elapsed=r.elapsed,l.length===0)e.agentsCompleted++;else{const c=tr(e.subworkflowContexts,l);c&&c.agentsCompleted++}Le(a,r.agent_name)}}e.activeContextPath=l},subworkflow_failed:(e,t)=>{var o;const r=t;let l;if(r.parent_path!==void 0){const u=Pi(e.subworkflowContexts,r.parent_path);if(!u)return;l=u.indexPath}else l=e.activeContextPath;const a=l.length===0?e.nodes:(o=tr(e.subworkflowContexts,l))==null?void 0:o.nodes;if(a){const u=a[r.agent_name];u&&r.item_key==null&&(u.status="failed",u.elapsed=r.elapsed,u.error_type=r.error_type,u.error_message=r.message,Le(a,r.agent_name))}e.activeContextPath=l},checkpoint_saved:(e,t)=>{const r=t;r.path&&e.workflowFailure&&(e.workflowFailure={...e.workflowFailure,checkpoint_path:r.path})},agent_paused:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.status="waiting",l.activity.push({type:"agent_paused",icon:"⏸",label:"Paused",text:"Agent paused — click Resume to re-execute"}),Le(e.nodes,r.agent_name),e.isPaused=!0},agent_resumed:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.status="running",l.activity.push({type:"agent_resumed",icon:"▶",label:"Resumed",text:"Agent resumed — re-executing"}),Le(e.nodes,r.agent_name),e.isPaused=!1},dialog_started:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_id=r.dialog_id,l.dialog_messages=[],l.dialog_active=!0,l.dialog_awaiting_response=!1,e.activeDialog={agentName:r.agent_name,dialogId:r.dialog_id},e.dialogEngaged=!1,Le(e.nodes,r.agent_name)},dialog_message:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_messages||(l.dialog_messages=[]),l.dialog_messages.push({role:r.role,content:r.content}),r.role==="user"?l.dialog_awaiting_response=!0:r.role==="agent"&&(l.dialog_awaiting_response=!1),Le(e.nodes,r.agent_name)},dialog_completed:(e,t)=>{const r=t,l=Ge(e.nodes,r.agent_name);l.dialog_active=!1,l.dialog_awaiting_response=!1,e.activeDialog=null,e.dialogEngaged=!1,Le(e.nodes,r.agent_name)}};function Du(e){var l,a;const t=e.timestamp,r=e.data;switch(e.type){case"workflow_started":return{timestamp:t,level:"info",source:"workflow",message:`Workflow "${r.name||""}" started`};case"agent_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Agent completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}${r.cost_usd!=null?` · $${r.cost_usd.toFixed(4)}`:""}`};case"agent_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Agent failed: ${r.message||r.error_type||"unknown error"}`};case"script_started":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Script started"};case"script_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Script completed (exit ${r.exit_code??"?"})${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"script_failed":return{timestamp:t,level:"error",source:String(r.agent_name),message:`Script failed: ${r.message||r.error_type||"unknown error"}`};case"gate_presented":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Waiting for human input…"};case"gate_resolved":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Gate resolved → ${r.selected_option||"continue"}`};case"route_taken":return{timestamp:t,level:"debug",source:"router",message:`${r.from_agent} → ${r.to_agent}`};case"parallel_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`Parallel group started (${((l=r.agents)==null?void 0:l.length)||"?"} agents)`};case"parallel_completed":return{timestamp:t,level:r.failure_count===0?"success":"error",source:String(r.group_name),message:`Parallel group completed${r.failure_count>0?` with ${r.failure_count} failure(s)`:""}`};case"for_each_started":return{timestamp:t,level:"info",source:String(r.group_name),message:`For-each started (${r.item_count} items)`};case"for_each_completed":return{timestamp:t,level:(r.failure_count??0)===0?"success":"error",source:String(r.group_name),message:`For-each completed · ${r.success_count} succeeded${r.failure_count>0?` · ${r.failure_count} failed`:""}`};case"workflow_completed":return{timestamp:t,level:"success",source:"workflow",message:`Workflow completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}`};case"workflow_failed":return{timestamp:t,level:"error",source:"workflow",message:`Workflow failed: ${r.message||r.error_type||"unknown error"}`};case"checkpoint_saved":return{timestamp:t,level:"info",source:"workflow",message:`Checkpoint saved: ${((a=r.path)==null?void 0:a.split("/").pop())||"unknown"}`};case"agent_paused":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Agent paused — waiting for resume"};case"agent_resumed":return{timestamp:t,level:"info",source:String(r.agent_name),message:"Agent resumed — re-executing"};case"dialog_started":return{timestamp:t,level:"warning",source:String(r.agent_name),message:"Dialog started — waiting for user…"};case"dialog_completed":return{timestamp:t,level:"success",source:String(r.agent_name),message:`Dialog completed (${r.turn_count||0} messages)`};default:return null}}function Qu(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Ru(e){const t=e.timestamp,r=e.data;switch(e.type){case"agent_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Agent started${r.iteration!=null?` (iteration ${r.iteration})`:""}`};case"agent_prompt_rendered":return{timestamp:t,source:String(r.agent_name),type:"prompt",message:"Prompt rendered",detail:yo(String(r.rendered_prompt||""),500)};case"agent_reasoning":return{timestamp:t,source:String(r.agent_name),type:"reasoning",message:String(r.content||"")};case"agent_tool_start":return{timestamp:t,source:String(r.agent_name),type:"tool-start",message:`→ ${r.tool_name}`,detail:r.arguments?yo(String(r.arguments),300):null};case"agent_tool_complete":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`← ${r.tool_name||"done"}`,detail:r.result?yo(String(r.result),300):null};case"agent_turn_start":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Turn ${r.turn??"?"}`};case"agent_message":return{timestamp:t,source:String(r.agent_name),type:"message",message:yo(String(r.content||""),500)};case"agent_completed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Completed${r.elapsed!=null?` in ${Qu(r.elapsed)}`:""}${r.tokens!=null?` · ${r.tokens.toLocaleString()} tokens`:""}`};case"agent_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Failed: ${r.message||r.error_type||"unknown"}`};case"script_started":return{timestamp:t,source:String(r.agent_name),type:"turn",message:"Script started"};case"script_completed":return{timestamp:t,source:String(r.agent_name),type:"tool-complete",message:`Script completed (exit ${r.exit_code??"?"})`,detail:r.stdout?yo(String(r.stdout),300):null};case"script_failed":return{timestamp:t,source:String(r.agent_name),type:"turn",message:`Script failed: ${r.message||r.error_type||"unknown"}`};default:return null}}function yo(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function nv(e){const t=e.match(/^(\s*)/);return t?t[1].length:0}function MN(e){const t=new Map;for(let r=0;ra)o=u;else break}o>r&&t.set(r,o)}return t}function DN(e){if(/^\s*#/.test(e))return y.jsx("span",{className:"text-emerald-500/70",children:e});const t=e.match(/^(\s*)(- )?([a-zA-Z_][\w.-]*)(:\s*)(.*)/);if(t){const[,l,a,o,u,c]=t;return y.jsxs("span",{children:[l,a??"",y.jsx("span",{className:"text-sky-400",children:o}),y.jsx("span",{className:"text-[var(--text-muted)]",children:u}),rv(c??"")]})}const r=e.match(/^(\s*)(- )(.*)/);if(r){const[,l,a,o]=r;return y.jsxs("span",{children:[l,y.jsx("span",{className:"text-[var(--text-muted)]",children:a}),rv(o??"")]})}return y.jsx("span",{children:e})}function rv(e){if(!e)return"";const t=e.indexOf(" #"),r=t>=0?e.slice(0,t):e,l=t>=0?e.slice(t):"";let a=r;return/^(true|false|null|yes|no)$/i.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^\d+(\.\d+)?$/.test(r.trim())?a=y.jsx("span",{className:"text-amber-400",children:r}):/^["'].*["']$/.test(r.trim())?a=y.jsx("span",{className:"text-green-400",children:r}):(r.includes("|")||r.includes(">"))&&(a=y.jsx("span",{className:"text-[var(--text-secondary)]",children:r})),y.jsxs(y.Fragment,{children:[a,l&&y.jsx("span",{className:"text-emerald-500/70",children:l})]})}function RN({yaml:e,onClose:t}){const[r,l]=P.useState(new Set);P.useEffect(()=>{const d=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t]);const a=P.useMemo(()=>e.split(` +`),[e]),o=P.useMemo(()=>MN(a),[a]),u=P.useCallback(d=>{l(h=>{const m=new Set(h);return m.has(d)?m.delete(d):m.add(d),m})},[]),c=P.useMemo(()=>{const d=[];let h=-1;for(let m=0;my.jsxs("div",{className:"flex",children:[y.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",style:{width:"1.25rem"},children:m?y.jsx("button",{onClick:()=>u(d),className:"text-[var(--text-muted)] hover:text-[var(--text)] p-0 leading-none",style:{background:"none",border:"none",cursor:"pointer"},children:p?y.jsx(Rr,{className:"w-3 h-3"}):y.jsx(il,{className:"w-3 h-3"})}):null}),y.jsxs("span",{className:"flex-1",children:[DN(h),p&&y.jsx("span",{className:"text-[var(--text-muted)] text-[11px] ml-2 px-1.5 py-0.5 rounded bg-[var(--surface-hover)] cursor-pointer",onClick:()=>u(d),children:"···"})]})]},d))})})]})]})}function ON(){const e=fe(S=>S.workflowName),t=fe(S=>S.workflowStatus),r=fe(S=>S.isPaused),l=fe(S=>S.workflowYaml),a=fe(S=>S.conductorVersion),[o,u]=P.useState(!1),[c,d]=P.useState(!1),[h,m]=P.useState(!1),[p,x]=P.useState(!1),b=t==="running"||t==="pending";P.useEffect(()=>{r||(u(!1),d(!1),m(!1))},[r]);const w=async()=>{u(!0);try{await fetch("/api/stop",{method:"POST"})}catch(S){console.error("Failed to stop agent:",S),u(!1)}},E=async()=>{d(!0);try{await fetch("/api/resume",{method:"POST"})}catch(S){console.error("Failed to resume agent:",S),d(!1)}},_=async()=>{m(!0);try{await fetch("/api/kill",{method:"POST"})}catch(S){console.error("Failed to kill workflow:",S),m(!1)}};return y.jsxs("header",{className:"flex items-center justify-between px-4 py-2 bg-[var(--surface)] border-b border-[var(--border)] flex-shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(pw,{className:"w-4 h-4 text-[var(--running)]"}),y.jsx("h1",{className:"text-sm font-semibold text-[var(--text)]",children:"Conductor"}),e&&y.jsxs("span",{className:"text-sm text-[var(--text-muted)] font-normal",children:["— ",e]})]}),y.jsxs("div",{className:"flex items-center gap-3",children:[r?y.jsxs(y.Fragment,{children:[y.jsxs("button",{onClick:E,disabled:c,className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/20 hover:border-emerald-500/30 disabled:opacity-50 disabled:cursor-not-allowed @@ -270,7 +270,7 @@ Error generating stack: `+f.message+` transition-colors`,title:"View workflow YAML configuration",children:[y.jsx(pN,{className:"w-3 h-3"}),"YAML"]}),y.jsxs("a",{href:"/api/logs",download:"conductor-logs.json",className:`flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded bg-[var(--surface-hover)] text-[var(--text-secondary)] border border-[var(--border)] hover:text-[var(--text)] hover:bg-[var(--surface)] - transition-colors`,title:"Download full event log as JSON",children:[y.jsx(dN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(RN,{yaml:l,onClose:()=>x(!1)})]})}function LN(){const e=fe(o=>o.getBreadcrumbs),t=fe(o=>o.navigateToContext),r=fe(o=>o.viewContextPath);if(fe(o=>o.subworkflowContexts).length===0&&r.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(Sc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,u)=>{const c=u===a.length-1,d=JSON.stringify(o.path)===JSON.stringify(r);return y.jsxs("span",{className:"flex items-center gap-1",children:[u>0&&y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${d?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},u)})]})}function He(...e){return e.filter(Boolean).join(" ")}function Jt(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function $n(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function yi(e){return e==null?"":`$${e.toFixed(4)}`}function Sw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function HN(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const r=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${r(e)} / ${r(t)} (${l}%)`}function _w(){const e=fe(c=>c.workflowStatus),t=fe(c=>c.workflowStartTime),r=fe(c=>c.replayMode),l=fe(c=>c.lastEventTime),[a,o]=V.useState("—"),u=V.useRef(null);return V.useEffect(()=>{if(t!=null){if(r){u.current&&(clearInterval(u.current),u.current=null),o(Jt((l??t)-t));return}if(e==="running"){const c=()=>{const d=Date.now()/1e3-t;o(Jt(d))};return c(),u.current=setInterval(c,500),()=>{u.current&&clearInterval(u.current)}}else(e==="completed"||e==="failed")&&u.current&&(clearInterval(u.current),u.current=null)}},[e,t,r,l]),a}function BN(){const e=fe(k=>k.workflowStatus),t=fe(k=>k.agentsCompleted),r=fe(k=>k.agentsTotal),l=fe(k=>k.totalCost),a=fe(k=>k.totalTokens),o=fe(k=>k.wsStatus),u=fe(k=>k.workflowFailure),c=fe(k=>k.lastEventTime),d=_w(),[h,m]=V.useState(null);V.useEffect(()=>{if(e!=="running"||c==null){m(null);return}const k=()=>{m(Math.floor(Date.now()/1e3-c))};k();const _=setInterval(k,1e3);return()=>clearInterval(_)},[e,c]);const p=e==="failed",x=(()=>{switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!u)return"Failed";const k=u.error_type||"";return k==="MaxIterationsError"?"Failed: exceeded maximum iterations":k==="TimeoutError"?"Failed: workflow timed out":u.message?`Failed: ${u.message.length>60?u.message.slice(0,57)+"...":u.message}`:`Failed: ${k}`}}})(),b={pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],w=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(kN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(_N,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:He("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",p?"bg-red-950/50 border-red-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:He("w-2 h-2 rounded-full flex-shrink-0",b)}),y.jsx("span",{className:He(p?"text-red-300":"text-[var(--text)]"),children:x}),r>0&&y.jsxs("span",{className:He(p?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",r," agents"]}),e!=="pending"&&y.jsx("span",{className:He("font-mono",p?"text-red-400/60":"text-[var(--text-muted)]"),children:d}),a>0&&y.jsxs("span",{className:He("flex items-center gap-1",p?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:He("flex items-center gap-1",p?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(mw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),h!=null&&h>=5&&y.jsxs("span",{className:He("flex items-center gap-1 font-mono",h>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(fN,{className:"w-3 h-3"}),y.jsx("span",{children:h>=60?`${Math.floor(h/60)}m ${h%60}s idle`:`${h}s idle`})]}),y.jsx("span",{className:"flex-1"}),w]})}const IN=[1,5,10,20,50];function qN(e,t){if(t===0||e.length===0)return"+0.0s";const r=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-r;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),u=a%60;return`+${o}m${u.toFixed(0)}s`}function UN(){const e=fe(p=>p.replayPosition),t=fe(p=>p.replayTotalEvents),r=fe(p=>p.replayPlaying),l=fe(p=>p.replaySpeed),a=fe(p=>p.replayEvents),o=fe(p=>p.setReplayPosition),u=fe(p=>p.setReplayPlaying),c=fe(p=>p.setReplaySpeed),d=p=>{const x=parseInt(p.target.value,10);o(x),r&&u(!1)},h=()=>{!r&&e>=t&&o(0),u(!r)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:h,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:r?"Pause":"Play",children:r?y.jsx(yN,{className:"w-3.5 h-3.5"}):y.jsx(xm,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:d,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` + transition-colors`,title:"Download full event log as JSON",children:[y.jsx(dN,{className:"w-3 h-3"}),"Logs"]}),y.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["v",a??"—"]})]}),p&&l&&y.jsx(RN,{yaml:l,onClose:()=>x(!1)})]})}function LN(){const e=fe(o=>o.getBreadcrumbs),t=fe(o=>o.navigateToContext),r=fe(o=>o.viewContextPath);if(fe(o=>o.subworkflowContexts).length===0&&r.length===0)return null;const a=e();return y.jsxs("div",{className:"flex items-center gap-1 px-4 py-1.5 bg-[var(--surface)] border-b border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx(Sc,{className:"w-3 h-3 text-[var(--text-muted)] mr-1"}),a.map((o,u)=>{const c=u===a.length-1,d=JSON.stringify(o.path)===JSON.stringify(r);return y.jsxs("span",{className:"flex items-center gap-1",children:[u>0&&y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)]"}),c?y.jsx("span",{className:"font-semibold text-[var(--text)]",children:o.label}):y.jsx("button",{onClick:()=>t(o.path),className:`hover:text-[var(--running)] transition-colors ${d?"text-[var(--text)] font-medium":"text-[var(--text-muted)]"}`,children:o.label})]},u)})]})}function He(...e){return e.filter(Boolean).join(" ")}function Jt(e){if(e==null)return"";if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function $n(e){return e==null?"":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:`${e}`}function yi(e){return e==null?"":`$${e.toFixed(4)}`}function Sw(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)}function HN(e,t){if(t<=0)return`${e.toLocaleString()} tokens (limit unknown)`;const r=a=>a.toLocaleString(),l=(e/t*100).toFixed(1);return`${r(e)} / ${r(t)} (${l}%)`}function _w(){const e=fe(c=>c.workflowStatus),t=fe(c=>c.workflowStartTime),r=fe(c=>c.replayMode),l=fe(c=>c.lastEventTime),[a,o]=P.useState("—"),u=P.useRef(null);return P.useEffect(()=>{if(t!=null){if(r){u.current&&(clearInterval(u.current),u.current=null),o(Jt((l??t)-t));return}if(e==="running"){const c=()=>{const d=Date.now()/1e3-t;o(Jt(d))};return c(),u.current=setInterval(c,500),()=>{u.current&&clearInterval(u.current)}}else(e==="completed"||e==="failed")&&u.current&&(clearInterval(u.current),u.current=null)}},[e,t,r,l]),a}function BN(){const e=fe(E=>E.workflowStatus),t=fe(E=>E.agentsCompleted),r=fe(E=>E.agentsTotal),l=fe(E=>E.totalCost),a=fe(E=>E.totalTokens),o=fe(E=>E.wsStatus),u=fe(E=>E.workflowFailure),c=fe(E=>E.lastEventTime),d=_w(),[h,m]=P.useState(null);P.useEffect(()=>{if(e!=="running"||c==null){m(null);return}const E=()=>{m(Math.floor(Date.now()/1e3-c))};E();const _=setInterval(E,1e3);return()=>clearInterval(_)},[e,c]);const p=e==="failed",x=(()=>{switch(e){case"pending":return"Waiting for workflow…";case"running":return"Running";case"completed":return"Completed";case"failed":{if(!u)return"Failed";const E=u.error_type||"";return E==="MaxIterationsError"?"Failed: exceeded maximum iterations":E==="TimeoutError"?"Failed: workflow timed out":u.message?`Failed: ${u.message.length>60?u.message.slice(0,57)+"...":u.message}`:`Failed: ${E}`}}})(),b={pending:"bg-[var(--pending)]",running:"bg-[var(--running)] animate-pulse",completed:"bg-[var(--completed)]",failed:"bg-[var(--failed)]"}[e],w=(()=>{switch(o){case"connected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--completed)]",children:[y.jsx(kN,{className:"w-3 h-3"}),y.jsx("span",{children:"Connected"})]});case"disconnected":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--failed)]",children:[y.jsx(_N,{className:"w-3 h-3"}),y.jsx("span",{children:"Disconnected"})]});case"reconnecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--waiting)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Reconnecting\\u2026"})]});case"connecting":return y.jsxs("span",{className:"flex items-center gap-1 text-[var(--text-muted)]",children:[y.jsx(ca,{className:"w-3 h-3 animate-spin"}),y.jsx("span",{children:"Connecting\\u2026"})]})}})();return y.jsxs("footer",{className:He("flex items-center gap-4 px-4 py-1.5 border-t text-xs flex-shrink-0 transition-colors duration-300",p?"bg-red-950/50 border-red-500/30":"bg-[var(--surface)] border-[var(--border)]"),children:[y.jsx("span",{className:He("w-2 h-2 rounded-full flex-shrink-0",b)}),y.jsx("span",{className:He(p?"text-red-300":"text-[var(--text)]"),children:x}),r>0&&y.jsxs("span",{className:He(p?"text-red-400/60":"text-[var(--text-muted)]"),children:[t,"/",r," agents"]}),e!=="pending"&&y.jsx("span",{className:He("font-mono",p?"text-red-400/60":"text-[var(--text-muted)]"),children:d}),a>0&&y.jsxs("span",{className:He("flex items-center gap-1",p?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total tokens used",children:[y.jsx(yw,{className:"w-3 h-3"}),y.jsx("span",{className:"font-mono",children:a.toLocaleString()})]}),l>0&&y.jsxs("span",{className:He("flex items-center gap-1",p?"text-red-400/60":"text-[var(--text-muted)]"),title:"Total cost",children:[y.jsx(mw,{className:"w-3 h-3"}),y.jsxs("span",{className:"font-mono",children:["$",l.toFixed(4)]})]}),h!=null&&h>=5&&y.jsxs("span",{className:He("flex items-center gap-1 font-mono",h>=60?"text-amber-400":"text-[var(--text-muted)]"),title:"Time since last event from the provider",children:[y.jsx(fN,{className:"w-3 h-3"}),y.jsx("span",{children:h>=60?`${Math.floor(h/60)}m ${h%60}s idle`:`${h}s idle`})]}),y.jsx("span",{className:"flex-1"}),w]})}const IN=[1,5,10,20,50];function qN(e,t){if(t===0||e.length===0)return"+0.0s";const r=e[0].timestamp,a=e[Math.min(t,e.length)-1].timestamp-r;if(a<60)return`+${a.toFixed(1)}s`;const o=Math.floor(a/60),u=a%60;return`+${o}m${u.toFixed(0)}s`}function UN(){const e=fe(p=>p.replayPosition),t=fe(p=>p.replayTotalEvents),r=fe(p=>p.replayPlaying),l=fe(p=>p.replaySpeed),a=fe(p=>p.replayEvents),o=fe(p=>p.setReplayPosition),u=fe(p=>p.setReplayPlaying),c=fe(p=>p.setReplaySpeed),d=p=>{const x=parseInt(p.target.value,10);o(x),r&&u(!1)},h=()=>{!r&&e>=t&&o(0),u(!r)},m=t>0?e/t*100:0;return y.jsxs("footer",{className:"flex items-center gap-3 px-4 py-1.5 border-t bg-[var(--surface)] border-[var(--border)] text-xs flex-shrink-0",children:[y.jsx("button",{onClick:h,className:"flex items-center justify-center w-6 h-6 rounded hover:bg-[var(--surface-hover)] text-[var(--text-secondary)] hover:text-[var(--text)] transition-colors",title:r?"Pause":"Play",children:r?y.jsx(yN,{className:"w-3.5 h-3.5"}):y.jsx(xm,{className:"w-3.5 h-3.5"})}),y.jsxs("div",{className:"flex-1 relative flex items-center",children:[y.jsx("input",{type:"range",min:0,max:t,value:e,onChange:d,className:"w-full h-1 appearance-none rounded-full cursor-pointer",style:{background:`linear-gradient(to right, var(--accent) 0%, var(--accent) ${m}%, var(--border) ${m}%, var(--border) 100%)`,WebkitAppearance:"none"}}),y.jsx("style",{children:` footer input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; @@ -290,7 +290,7 @@ Error generating stack: `+f.message+` cursor: pointer; box-shadow: 0 0 4px rgba(99, 102, 241, 0.4); } - `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:qN(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:IN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:He("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const _c=V.createContext(null);_c.displayName="PanelGroupContext";const yt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ym=10,Xi=V.useLayoutEffect,iv=ZE.useId,VN=typeof iv=="function"?iv:()=>null;let PN=0;function vm(e=null){const t=VN(),r=V.useRef(e||t||null);return r.current===null&&(r.current=""+PN++),e??r.current}function kw({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:a,forwardedRef:o,id:u,maxSize:c,minSize:d,onCollapse:h,onExpand:m,onResize:p,order:x,style:b,tagName:w="div",...k}){const _=V.useContext(_c);if(_===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:C,getPanelSize:E,getPanelStyle:A,groupId:M,isPanelCollapsed:j,reevaluatePanelConstraints:L,registerPanel:O,resizePanel:P,unregisterPanel:H}=_,B=vm(u),U=V.useRef({callbacks:{onCollapse:h,onExpand:m,onResize:p},constraints:{collapsedSize:r,collapsible:l,defaultSize:a,maxSize:c,minSize:d},id:B,idIsFromProps:u!==void 0,order:x});V.useRef({didLogMissingDefaultSizeWarning:!1}),Xi(()=>{const{callbacks:I,constraints:F}=U.current,z={...F};U.current.id=B,U.current.idIsFromProps=u!==void 0,U.current.order=x,I.onCollapse=h,I.onExpand=m,I.onResize=p,F.collapsedSize=r,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=d,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L(U.current,z)}),Xi(()=>{const I=U.current;return O(I),()=>{H(I)}},[x,B,O,H]),V.useImperativeHandle(o,()=>({collapse:()=>{S(U.current)},expand:I=>{C(U.current,I)},getId(){return B},getSize(){return E(U.current)},isCollapsed(){return j(U.current)},isExpanded(){return!j(U.current)},resize:I=>{P(U.current,I)}}),[S,C,E,j,B,P]);const ee=A(U.current,a);return V.createElement(w,{...k,children:e,className:t,id:B,style:{...ee,...b},[yt.groupId]:M,[yt.panel]:"",[yt.panelCollapsible]:l||void 0,[yt.panelId]:B,[yt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Eo=V.forwardRef((e,t)=>V.createElement(kw,{...e,forwardedRef:t}));kw.displayName="Panel";Eo.displayName="forwardRef(Panel)";let Up=null,Zu=-1,gi=null;function $N(e,t){if(t){const r=(t&jw)!==0,l=(t&Aw)!==0,a=(t&zw)!==0,o=(t&Mw)!==0;if(r)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function GN(){gi!==null&&(document.head.removeChild(gi),Up=null,gi=null,Zu=-1)}function fh(e,t){var r,l;const a=$N(e,t);if(Up!==a){if(Up=a,gi===null&&(gi=document.createElement("style"),document.head.appendChild(gi)),Zu>=0){var o;(o=gi.sheet)===null||o===void 0||o.removeRule(Zu)}Zu=(r=(l=gi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&r!==void 0?r:-1}}function Ew(e){return e.type==="keydown"}function Nw(e){return e.type.startsWith("pointer")}function Cw(e){return e.type.startsWith("mouse")}function kc(e){if(Nw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Cw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function FN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function YN(e,t,r){return e.xt.x&&e.yt.y}function XN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:ov(e),b:ov(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;Re(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:av(lv(r.a)),b:av(lv(r.b))};if(a.a===a.b){const o=l.childNodes,u={a:r.a.at(-1),b:r.b.at(-1)};let c=o.length;for(;c--;){const d=o[c];if(d===u.a)return 1;if(d===u.b)return-1}}return Math.sign(a.a-a.b)}const QN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ZN(e){var t;const r=getComputedStyle((t=Tw(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="inline-flex"}function KN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ZN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||QN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lv(e){let t=e.length;for(;t--;){const r=e[t];if(Re(r,"Missing node"),KN(r))return r}return null}function av(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ov(e){const t=[];for(;e;)t.push(e),e=Tw(e);return t}function Tw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const jw=1,Aw=2,zw=4,Mw=8,JN=FN()==="coarse";let Gn=[],aa=!1,Gi=new Map,Ec=new Map;const Lo=new Set;function WN(e,t,r,l,a){var o;const{ownerDocument:u}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:a},d=(o=Gi.get(u))!==null&&o!==void 0?o:0;return Gi.set(u,d+1),Lo.add(c),ic(),function(){var m;Ec.delete(e),Lo.delete(c);const p=(m=Gi.get(u))!==null&&m!==void 0?m:1;if(Gi.set(u,p-1),ic(),p===1&&Gi.delete(u),Gn.includes(c)){const x=Gn.indexOf(c);x>=0&&Gn.splice(x,1),wm(),a("up",!0,null)}}}function eC(e){const{target:t}=e,{x:r,y:l}=kc(e);aa=!0,bm({target:t,x:r,y:l}),ic(),Gn.length>0&&(lc("down",e),e.preventDefault(),Dw(t)||e.stopImmediatePropagation())}function dh(e){const{x:t,y:r}=kc(e);if(aa&&e.buttons===0&&(aa=!1,lc("up",e)),!aa){const{target:l}=e;bm({target:l,x:t,y:r})}lc("move",e),wm(),Gn.length>0&&e.preventDefault()}function hh(e){const{target:t}=e,{x:r,y:l}=kc(e);Ec.clear(),aa=!1,Gn.length>0&&(e.preventDefault(),Dw(t)||e.stopImmediatePropagation()),lc("up",e),bm({target:t,x:r,y:l}),wm(),ic()}function Dw(e){let t=e;for(;t;){if(t.hasAttribute(yt.resizeHandle))return!0;t=t.parentElement}return!1}function bm({target:e,x:t,y:r}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Lo.forEach(a=>{const{element:o,hitAreaMargins:u}=a,c=o.getBoundingClientRect(),{bottom:d,left:h,right:m,top:p}=c,x=JN?u.coarse:u.fine;if(t>=h-x&&t<=m+x&&r>=p-x&&r<=d+x){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&XN(l,o)>0){let w=l,k=!1;for(;w&&!w.contains(o);){if(YN(w.getBoundingClientRect(),c)){k=!0;break}w=w.parentElement}if(k)return}Gn.push(a)}})}function ph(e,t){Ec.set(e,t)}function wm(){let e=!1,t=!1;Gn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let r=0;Ec.forEach(l=>{r|=l}),e&&t?fh("intersection",r):e?fh("horizontal",r):t?fh("vertical",r):GN()}let mh=new AbortController;function ic(){mh.abort(),mh=new AbortController;const e={capture:!0,signal:mh.signal};Lo.size&&(aa?(Gn.length>0&&Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("contextmenu",hh,e),l.addEventListener("pointerleave",dh,e),l.addEventListener("pointermove",dh,e))}),window.addEventListener("pointerup",hh,e),window.addEventListener("pointercancel",hh,e)):Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("pointerdown",eC,e),l.addEventListener("pointermove",dh,e))}))}function lc(e,t){Lo.forEach(r=>{const{setResizeHandlerState:l}=r,a=Gn.includes(r);l(e,a,t)})}function tC(){const[e,t]=V.useState(0);return V.useCallback(()=>t(r=>r+1),[])}function Re(e,t){if(!e)throw console.error(t),Error(t)}function Ki(e,t,r=ym){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function Ar(e,t,r=ym){return Ki(e,t,r)===0}function bn(e,t,r){return Ki(e,t,r)===0}function nC(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-S:S)}}}{const p=e<0?c:d,x=r[p];Re(x,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:k=0}=x;if(w){const _=t[p];if(Re(_!=null,`Previous layout not found for panel index ${p}`),bn(_,k)){const S=_-b;Ki(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const p=e<0?1:-1;let x=e<0?d:c,b=0;for(;;){const k=t[x];Re(k!=null,`Previous layout not found for panel index ${x}`);const S=na({panelConstraints:r,panelIndex:x,size:100})-k;if(b+=S,x+=p,x<0||x>=r.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let x=e<0?c:d;for(;x>=0&&x=0))break;e<0?x--:x++}}if(nC(a,u))return a;{const p=e<0?d:c,x=t[p];Re(x!=null,`Previous layout not found for panel index ${p}`);const b=x+h,w=na({panelConstraints:r,panelIndex:p,size:b});if(u[p]=w,!bn(w,b)){let k=b-w,S=e<0?d:c;for(;S>=0&&S0?S--:S++}}}const m=u.reduce((p,x)=>x+p,0);return bn(m,100)?u:a}function rC({layout:e,panelsArray:t,pivotIndices:r}){let l=0,a=100,o=0,u=0;const c=r[0];Re(c!=null,"No pivot index found"),t.forEach((p,x)=>{const{constraints:b}=p,{maxSize:w=100,minSize:k=0}=b;x===c?(l=k,a=w):(o+=k,u+=w)});const d=Math.min(a,100-o),h=Math.max(l,100-u),m=e[c];return{valueMax:d,valueMin:h,valueNow:m}}function Ho(e,t=document){return Array.from(t.querySelectorAll(`[${yt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Rw(e,t,r=document){const a=Ho(e,r).findIndex(o=>o.getAttribute(yt.resizeHandleId)===t);return a??null}function Ow(e,t,r){const l=Rw(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Lw(e,t=document){var r;if(t instanceof HTMLElement&&(t==null||(r=t.dataset)===null||r===void 0?void 0:r.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function Nc(e,t=document){const r=t.querySelector(`[${yt.resizeHandleId}="${e}"]`);return r||null}function iC(e,t,r,l=document){var a,o,u,c;const d=Nc(t,l),h=Ho(e,l),m=d?h.indexOf(d):-1,p=(a=(o=r[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,x=(u=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&u!==void 0?u:null;return[p,x]}function lC({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:u}){V.useRef({didWarnAboutMissingResizeHandle:!1}),Xi(()=>{if(!o)return;const c=Ho(r,o);for(let d=0;d{c.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[r,l,a,o]),V.useEffect(()=>{if(!o)return;const c=t.current;Re(c,"Eager values not found");const{panelDataArray:d}=c,h=Lw(r,o);Re(h!=null,`No group found for id "${r}"`);const m=Ho(r,o);Re(m,`No resize handles found for group id "${r}"`);const p=m.map(x=>{const b=x.getAttribute(yt.resizeHandleId);Re(b,"Resize handle element has no handle id attribute");const[w,k]=iC(r,b,d,o);if(w==null||k==null)return()=>{};const _=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const C=d.findIndex(E=>E.id===w);if(C>=0){const E=d[C];Re(E,`No panel data found for index ${C}`);const A=l[C],{collapsedSize:M=0,collapsible:j,minSize:L=0}=E.constraints;if(A!=null&&j){const O=No({delta:bn(A,M)?L-M:M-A,initialLayout:l,panelConstraints:d.map(P=>P.constraints),pivotIndices:Ow(r,b,o),prevLayout:l,trigger:"keyboard"});l!==O&&u(O)}}break}}};return x.addEventListener("keydown",_),()=>{x.removeEventListener("keydown",_)}});return()=>{p.forEach(x=>x())}},[o,e,t,r,l,a,u])}function sv(e,t){if(e.length!==t.length)return!1;for(let r=0;ro.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];Re(o,`Panel data not found for index ${a}`);const{callbacks:u,constraints:c,id:d}=o,{collapsedSize:h=0,collapsible:m}=c,p=r[d];if(p==null||l!==p){r[d]=l;const{onCollapse:x,onExpand:b,onResize:w}=u;w&&w(l,p),m&&(x||b)&&(b&&(p==null||Ar(p,h))&&!Ar(l,h)&&b(),x&&(p==null||!Ar(p,h))&&Ar(l,h)&&x())}})}function Ou(e,t){if(e.length!==t.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...a)},t)}}function uv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Bw(e){return`react-resizable-panels:${e}`}function Iw(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function qw(e,t){try{const r=Bw(e),l=t.getItem(r);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function fC(e,t,r){var l,a;const o=(l=qw(e,r))!==null&&l!==void 0?l:{},u=Iw(t);return(a=o[u])!==null&&a!==void 0?a:null}function dC(e,t,r,l,a){var o;const u=Bw(e),c=Iw(t),d=(o=qw(e,a))!==null&&o!==void 0?o:{};d[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{a.setItem(u,JSON.stringify(d))}catch(h){console.error(h)}}function cv({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((o,u)=>o+u,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&r.length>0)for(let o=0;o(uv(Co),Co.getItem(e)),setItem:(e,t)=>{uv(Co),Co.setItem(e,t)}},fv={};function Uw({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:a,id:o=null,onLayout:u=null,keyboardResizeBy:c=null,storage:d=Co,style:h,tagName:m="div",...p}){const x=vm(o),b=V.useRef(null),[w,k]=V.useState(null),[_,S]=V.useState([]),C=tC(),E=V.useRef({}),A=V.useRef(new Map),M=V.useRef(0),j=V.useRef({autoSaveId:e,direction:l,dragState:w,id:x,keyboardResizeBy:c,onLayout:u,storage:d}),L=V.useRef({layout:_,panelDataArray:[],panelDataArrayChanged:!1});V.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),V.useImperativeHandle(a,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:N}=L.current;return N},setLayout:N=>{const{onLayout:$}=j.current,{layout:X,panelDataArray:J}=L.current,ne=cv({layout:N,panelConstraints:J.map(re=>re.constraints)});sv(X,ne)||(S(ne),L.current.layout=ne,$&&$(ne),Ql(J,ne,E.current))}}),[]),Xi(()=>{j.current.autoSaveId=e,j.current.direction=l,j.current.dragState=w,j.current.id=x,j.current.onLayout=u,j.current.storage=d}),lC({committedValuesRef:j,eagerValuesRef:L,groupId:x,layout:_,panelDataArray:L.current.panelDataArray,setLayout:S,panelGroupElement:b.current}),V.useEffect(()=>{const{panelDataArray:N}=L.current;if(e){if(_.length===0||_.length!==N.length)return;let $=fv[e];$==null&&($=cC(dC,hC),fv[e]=$);const X=[...N],J=new Map(A.current);$(e,X,J,_,d)}},[e,_,d]),V.useEffect(()=>{});const O=V.useCallback(N=>{const{onLayout:$}=j.current,{layout:X,panelDataArray:J}=L.current;if(N.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:xe}=Ui(J,N,X);if(Re(se!=null,`Panel size not found for panel "${N.id}"`),!Ar(se,re)){A.current.set(N.id,se);const ye=Wl(J,N)===J.length-1?se-re:re-se,pe=No({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Ou(X,pe)||(S(pe),L.current.layout=pe,$&&$(pe),Ql(J,pe,E.current))}}},[]),P=V.useCallback((N,$)=>{const{onLayout:X}=j.current,{layout:J,panelDataArray:ne}=L.current;if(N.constraints.collapsible){const re=ne.map(_e=>_e.constraints),{collapsedSize:se=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Ui(ne,N,J),pe=$??be;if(Ar(xe,se)){const _e=A.current.get(N.id),ze=_e!=null&&_e>=pe?_e:pe,ut=Wl(ne,N)===ne.length-1?xe-ze:ze-xe,nt=No({delta:ut,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Ou(J,nt)||(S(nt),L.current.layout=nt,X&&X(nt),Ql(ne,nt,E.current))}}},[]),H=V.useCallback(N=>{const{layout:$,panelDataArray:X}=L.current,{panelSize:J}=Ui(X,N,$);return Re(J!=null,`Panel size not found for panel "${N.id}"`),J},[]),B=V.useCallback((N,$)=>{const{panelDataArray:X}=L.current,J=Wl(X,N);return uC({defaultSize:$,dragState:w,layout:_,panelData:X,panelIndex:J})},[w,_]),U=V.useCallback(N=>{const{layout:$,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,N,$);return Re(re!=null,`Panel size not found for panel "${N.id}"`),ne===!0&&Ar(re,J)},[]),ee=V.useCallback(N=>{const{layout:$,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,N,$);return Re(re!=null,`Panel size not found for panel "${N.id}"`),!ne||Ki(re,J)>0},[]),I=V.useCallback(N=>{const{panelDataArray:$}=L.current;$.push(N),$.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,C()},[C]);Xi(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:N,onLayout:$,storage:X}=j.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(N){const xe=fC(N,ne,X);xe&&(A.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=sC({panelDataArray:ne}));const se=cv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});sv(J,se)||(S(se),L.current.layout=se,$&&$(se),Ql(ne,se,E.current))}}),Xi(()=>{const N=L.current;return()=>{N.layout=[]}},[]);const F=V.useCallback(N=>{let $=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&($=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:se,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=j.current,{layout:_e,panelDataArray:ze}=L.current,{initialLayout:Te}=xe??{},ut=Ow(be,N,re);let nt=oC(ne,N,se,xe,ye,re);const zt=se==="horizontal";zt&&$&&(nt=-nt);const Pt=ze.map(Rn=>Rn.constraints),Ht=No({delta:nt,initialLayout:Te??_e,panelConstraints:Pt,pivotIndices:ut,prevLayout:_e,trigger:Ew(ne)?"keyboard":"mouse-or-touch"}),kn=!Ou(_e,Ht);(Nw(ne)||Cw(ne))&&M.current!=nt&&(M.current=nt,!kn&&nt!==0?zt?ph(N,nt<0?jw:Aw):ph(N,nt<0?zw:Mw):ph(N,0)),kn&&(S(Ht),L.current.layout=Ht,pe&&pe(Ht),Ql(ze,Ht,E.current))}},[]),z=V.useCallback((N,$)=>{const{onLayout:X}=j.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(_e=>_e.constraints),{panelSize:se,pivotIndices:xe}=Ui(ne,N,J);Re(se!=null,`Panel size not found for panel "${N.id}"`);const ye=Wl(ne,N)===ne.length-1?se-$:$-se,pe=No({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Ou(J,pe)||(S(pe),L.current.layout=pe,X&&X(pe),Ql(ne,pe,E.current))},[]),G=V.useCallback((N,$)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=$,{collapsedSize:se=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=N.constraints,{panelSize:pe}=Ui(J,N,X);pe!=null&&(re&&xe&&Ar(pe,ne)?Ar(ne,se)||z(N,se):pebe&&z(N,be))},[z]),Q=V.useCallback((N,$)=>{const{direction:X}=j.current,{layout:J}=L.current;if(!b.current)return;const ne=Nc(N,b.current);Re(ne,`Drag handle element not found for id "${N}"`);const re=Hw(X,$);k({dragHandleId:N,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=V.useCallback(()=>{k(null)},[]),D=V.useCallback(N=>{const{panelDataArray:$}=L.current,X=Wl($,N);X>=0&&($.splice(X,1),delete E.current[N.id],L.current.panelDataArrayChanged=!0,C())},[C]),q=V.useMemo(()=>({collapsePanel:O,direction:l,dragState:w,expandPanel:P,getPanelSize:H,getPanelStyle:B,groupId:x,isPanelCollapsed:U,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:I,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[O,w,l,P,H,B,x,U,ee,G,I,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return V.createElement(_c.Provider,{value:q},V.createElement(m,{...p,children:t,className:r,id:o,ref:b,style:{...Y,...h},[yt.group]:"",[yt.groupDirection]:l,[yt.groupId]:x}))}const Vp=V.forwardRef((e,t)=>V.createElement(Uw,{...e,forwardedRef:t}));Uw.displayName="PanelGroup";Vp.displayName="forwardRef(PanelGroup)";function Wl(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function Ui(e,t,r){const l=Wl(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],u=r[l];return{...t.constraints,panelSize:u,pivotIndices:o}}function pC({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){V.useEffect(()=>{if(e||r==null||l==null)return;const a=Nc(t,l);if(a==null)return;const o=u=>{if(!u.defaultPrevented)switch(u.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{u.preventDefault(),r(u);break}case"F6":{u.preventDefault();const c=a.getAttribute(yt.groupId);Re(c,`No group element found for id "${c}"`);const d=Ho(c,l),h=Rw(c,t,l);Re(h!==null,`No resize element found for id "${t}"`);const m=u.shiftKey?h>0?h-1:d.length-1:h+1{a.removeEventListener("keydown",o)}},[l,e,t,r])}function Pp({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:u,onDragging:c,onFocus:d,onPointerDown:h,onPointerUp:m,style:p={},tabIndex:x=0,tagName:b="div",...w}){var k,_;const S=V.useRef(null),C=V.useRef({onClick:u,onDragging:c,onPointerDown:h,onPointerUp:m});V.useEffect(()=>{C.current.onClick=u,C.current.onDragging=c,C.current.onPointerDown=h,C.current.onPointerUp=m});const E=V.useContext(_c);if(E===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:M,registerResizeHandle:j,startDragging:L,stopDragging:O,panelGroupElement:P}=E,H=vm(a),[B,U]=V.useState("inactive"),[ee,I]=V.useState(!1),[F,z]=V.useState(null),G=V.useRef({state:B});Xi(()=>{G.current.state=B}),V.useEffect(()=>{if(r)z(null);else{const q=j(H);z(()=>q)}},[r,H,j]);const Q=(k=l==null?void 0:l.coarse)!==null&&k!==void 0?k:15,K=(_=l==null?void 0:l.fine)!==null&&_!==void 0?_:5;V.useEffect(()=>{if(r||F==null)return;const q=S.current;Re(q,"Element ref not attached");let Y=!1;return WN(H,q,A,{coarse:Q,fine:K},($,X,J)=>{if(!X){U("inactive");return}switch($){case"down":{U("drag"),Y=!1,Re(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=C.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&U("hover"),Re(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{U("hover"),O();const{onClick:ne,onDragging:re,onPointerUp:se}=C.current;re==null||re(!1),se==null||se(),Y||ne==null||ne();break}}})},[Q,A,r,K,j,H,F,L,O]),pC({disabled:r,handleId:H,resizeHandler:F,panelGroupElement:P});const D={touchAction:"none",userSelect:"none"};return V.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{I(!1),o==null||o()},onFocus:()=>{I(!0),d==null||d()},ref:S,role:"separator",style:{...D,...p},tabIndex:x,[yt.groupDirection]:A,[yt.groupId]:M,[yt.resizeHandle]:"",[yt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[yt.resizeHandleEnabled]:!r,[yt.resizeHandleId]:H,[yt.resizeHandleState]:B})}Pp.displayName="PanelResizeHandle";function At(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,l;r{}};function Cc(){for(var e=0,t=arguments.length,r={},l;e=0&&(l=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:l}})}Ku.prototype=Cc.prototype={constructor:Ku,on:function(e,t){var r=this._,l=gC(e+"",r),a,o=-1,u=l.length;if(arguments.length<2){for(;++o0)for(var r=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),hv.hasOwnProperty(t)?{space:hv[t],local:e}:e}function yC(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===$p&&t.documentElement.namespaceURI===$p?t.createElement(e):t.createElementNS(r,e)}}function vC(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vw(e){var t=Tc(e);return(t.local?vC:yC)(t)}function bC(){}function Sm(e){return e==null?bC:function(){return this.querySelector(e)}}function wC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,r=t.length,l=new Array(r),a=0;a=E&&(E=C+1);!(M=_[E])&&++E=0;)(u=l[a])&&(o&&u.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(u,o),o=u);return this}function FC(e){e||(e=YC);function t(p,x){return p&&x?e(p.__data__,x.__data__):!p-!x}for(var r=this._groups,l=r.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function XC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function QC(){return Array.from(this)}function ZC(){for(var e=this._groups,t=0,r=e.length;t1?this.each((t==null?o3:typeof t=="function"?u3:s3)(e,t,r??"")):fa(this.node(),e)}function fa(e,t){return e.style.getPropertyValue(t)||Yw(e).getComputedStyle(e,null).getPropertyValue(t)}function f3(e){return function(){delete this[e]}}function d3(e,t){return function(){this[e]=t}}function h3(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function p3(e,t){return arguments.length>1?this.each((t==null?f3:typeof t=="function"?h3:d3)(e,t)):this.node()[e]}function Xw(e){return e.trim().split(/^|\s+/)}function _m(e){return e.classList||new Qw(e)}function Qw(e){this._node=e,this._names=Xw(e.getAttribute("class")||"")}Qw.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Zw(e,t){for(var r=_m(e),l=-1,a=t.length;++l=0&&(r=t.slice(l+1),t=t.slice(0,l)),{type:t,name:r}})}function V3(e){return function(){var t=this.__on;if(t){for(var r=0,l=-1,a=t.length,o;r()=>e;function Gp(e,{sourceEvent:t,subject:r,target:l,identifier:a,active:o,x:u,y:c,dx:d,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}Gp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function J3(e){return!e.ctrlKey&&!e.button}function W3(){return this.parentNode}function eT(e,t){return t??{x:e.x,y:e.y}}function tT(){return navigator.maxTouchPoints||"ontouchstart"in this}function nS(){var e=J3,t=W3,r=eT,l=tT,a={},o=Cc("start","drag","end"),u=0,c,d,h,m,p=0;function x(A){A.on("mousedown.drag",b).filter(l).on("touchstart.drag",_).on("touchmove.drag",S,K3).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(A,M){if(!(m||!e.call(this,A,M))){var j=E(this,t.call(this,A,M),A,M,"mouse");j&&(wn(A.view).on("mousemove.drag",w,Bo).on("mouseup.drag",k,Bo),eS(A.view),gh(A),h=!1,c=A.clientX,d=A.clientY,j("start",A))}}function w(A){if(oa(A),!h){var M=A.clientX-c,j=A.clientY-d;h=M*M+j*j>p}a.mouse("drag",A)}function k(A){wn(A.view).on("mousemove.drag mouseup.drag",null),tS(A.view,h),oa(A),a.mouse("end",A)}function _(A,M){if(e.call(this,A,M)){var j=A.changedTouches,L=t.call(this,A,M),O=j.length,P,H;for(P=0;P>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Hu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Hu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=rT.exec(e))?new un(t[1],t[2],t[3],1):(t=iT.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lT.exec(e))?Hu(t[1],t[2],t[3],t[4]):(t=aT.exec(e))?Hu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=oT.exec(e))?bv(t[1],t[2]/100,t[3]/100,1):(t=sT.exec(e))?bv(t[1],t[2]/100,t[3]/100,t[4]):pv.hasOwnProperty(e)?xv(pv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function xv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Hu(e,t,r,l){return l<=0&&(e=t=r=NaN),new un(e,t,r,l)}function fT(e){return e instanceof Jo||(e=Ji(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Fp(e,t,r,l){return arguments.length===1?fT(e):new un(e,t,r,l??1)}function un(e,t,r,l){this.r=+e,this.g=+t,this.b=+r,this.opacity=+l}km(un,Fp,rS(Jo,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Qi(this.r),Qi(this.g),Qi(this.b),sc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:yv,formatHex:yv,formatHex8:dT,formatRgb:vv,toString:vv}));function yv(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}`}function dT(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}${Fi((isNaN(this.opacity)?1:this.opacity)*255)}`}function vv(){const e=sc(this.opacity);return`${e===1?"rgb(":"rgba("}${Qi(this.r)}, ${Qi(this.g)}, ${Qi(this.b)}${e===1?")":`, ${e})`}`}function sc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fi(e){return e=Qi(e),(e<16?"0":"")+e.toString(16)}function bv(e,t,r,l){return l<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,r,l)}function iS(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Ji(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,r=e.g/255,l=e.b/255,a=Math.min(t,r,l),o=Math.max(t,r,l),u=NaN,c=o-a,d=(o+a)/2;return c?(t===o?u=(r-l)/c+(r0&&d<1?0:u,new Un(u,c,d,e.opacity)}function hT(e,t,r,l){return arguments.length===1?iS(e):new Un(e,t,r,l??1)}function Un(e,t,r,l){this.h=+e,this.s=+t,this.l=+r,this.opacity=+l}km(Un,hT,rS(Jo,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new Un(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,l=r+(r<.5?r:1-r)*t,a=2*r-l;return new un(xh(e>=240?e-240:e+120,a,l),xh(e,a,l),xh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new Un(wv(this.h),Bu(this.s),Bu(this.l),sc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=sc(this.opacity);return`${e===1?"hsl(":"hsla("}${wv(this.h)}, ${Bu(this.s)*100}%, ${Bu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function wv(e){return e=(e||0)%360,e<0?e+360:e}function Bu(e){return Math.max(0,Math.min(1,e||0))}function xh(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Em=e=>()=>e;function pT(e,t){return function(r){return e+r*t}}function mT(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(l){return Math.pow(e+l*t,r)}}function gT(e){return(e=+e)==1?lS:function(t,r){return r-t?mT(t,r,e):Em(isNaN(t)?r:t)}}function lS(e,t){var r=t-e;return r?pT(e,r):Em(isNaN(e)?t:e)}const uc=(function e(t){var r=gT(t);function l(a,o){var u=r((a=Fp(a)).r,(o=Fp(o)).r),c=r(a.g,o.g),d=r(a.b,o.b),h=lS(a.opacity,o.opacity);return function(m){return a.r=u(m),a.g=c(m),a.b=d(m),a.opacity=h(m),a+""}}return l.gamma=e,l})(1);function xT(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;ar&&(o=t.slice(r,o),c[u]?c[u]+=o:c[++u]=o),(l=l[0])===(a=a[0])?c[u]?c[u]+=a:c[++u]=a:(c[++u]=null,d.push({i:u,x:rr(l,a)})),r=yh.lastIndex;return r180?m+=360:m-h>180&&(h+=360),x.push({i:p.push(a(p)+"rotate(",null,l)-2,x:rr(h,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(h,m,p,x){h!==m?x.push({i:p.push(a(p)+"skewX(",null,l)-2,x:rr(h,m)}):m&&p.push(a(p)+"skewX("+m+l)}function d(h,m,p,x,b,w){if(h!==p||m!==x){var k=b.push(a(b)+"scale(",null,",",null,")");w.push({i:k-4,x:rr(h,p)},{i:k-2,x:rr(m,x)})}else(p!==1||x!==1)&&b.push(a(b)+"scale("+p+","+x+")")}return function(h,m){var p=[],x=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,p,x),u(h.rotate,m.rotate,p,x),c(h.skewX,m.skewX,p,x),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,p,x),h=m=null,function(b){for(var w=-1,k=x.length,_;++w=0&&e._call.call(void 0,t),e=e._next;--da}function kv(){Wi=(fc=Uo.now())+jc,da=To=0;try{MT()}finally{da=0,RT(),Wi=0}}function DT(){var e=Uo.now(),t=e-fc;t>uS&&(jc-=t,fc=e)}function RT(){for(var e,t=cc,r,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:cc=r);jo=e,Qp(l)}function Qp(e){if(!da){To&&(To=clearTimeout(To));var t=e-Wi;t>24?(e<1/0&&(To=setTimeout(kv,e-Uo.now()-jc)),vo&&(vo=clearInterval(vo))):(vo||(fc=Uo.now(),vo=setInterval(DT,uS)),da=1,cS(kv))}}function Ev(e,t,r){var l=new dc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,r),l}var OT=Cc("start","end","cancel","interrupt"),LT=[],dS=0,Nv=1,Zp=2,Wu=3,Cv=4,Kp=5,ec=6;function Ac(e,t,r,l,a,o){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;HT(e,r,{name:t,index:l,group:a,on:OT,tween:LT,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:dS})}function Cm(e,t){var r=Xn(e,t);if(r.state>dS)throw new Error("too late; already scheduled");return r}function ar(e,t){var r=Xn(e,t);if(r.state>Wu)throw new Error("too late; already running");return r}function Xn(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function HT(e,t,r){var l=e.__transition,a;l[t]=r,r.timer=fS(o,0,r.time);function o(h){r.state=Nv,r.timer.restart(u,r.delay,r.time),r.delay<=h&&u(h-r.delay)}function u(h){var m,p,x,b;if(r.state!==Nv)return d();for(m in l)if(b=l[m],b.name===r.name){if(b.state===Wu)return Ev(u);b.state===Cv?(b.state=ec,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mZp&&l.state=0&&(t=t.slice(0,r)),!t||t==="start"})}function hj(e,t,r){var l,a,o=dj(t)?Cm:ar;return function(){var u=o(this,e),c=u.on;c!==l&&(a=(l=c).copy()).on(t,r),u.on=a}}function pj(e,t){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(hj(r,e,t))}function mj(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function gj(){return this.on("end.remove",mj(this._id))}function xj(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),u=0;u()=>e;function Vj(e,{sourceEvent:t,target:r,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function zr(e,t,r){this.k=e,this.x=t,this.y=r}zr.prototype={constructor:zr,scale:function(e){return e===1?this:new zr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var zc=new zr(1,0,0);gS.prototype=zr.prototype;function gS(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zc;return e.__zoom}function vh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function Pj(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $j(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Tv(){return this.__zoom||zc}function Gj(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fj(){return navigator.maxTouchPoints||"ontouchstart"in this}function Yj(e,t,r){var l=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],u=e.invertY(t[1][1])-r[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),u>o?(o+u)/2:Math.min(0,o)||Math.max(0,u))}function xS(){var e=Pj,t=$j,r=Yj,l=Gj,a=Fj,o=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,d=Ju,h=Cc("start","zoom","end"),m,p,x,b=500,w=150,k=0,_=10;function S(I){I.property("__zoom",Tv).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(I,F,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",Tv),I!==Q?M(I,F,z,G):Q.interrupt().each(function(){j(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},S.scaleBy=function(I,F,z,G){S.scaleTo(I,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},S.scaleTo=function(I,F,z,G){S.transform(I,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?A(Q):typeof z=="function"?z.apply(this,arguments):z,q=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return r(E(C(K,Y),D,q),Q,u)},z,G)},S.translateBy=function(I,F,z,G){S.transform(I,function(){return r(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),u)},null,G)},S.translateTo=function(I,F,z,G,Q){S.transform(I,function(){var K=t.apply(this,arguments),D=this.__zoom,q=G==null?A(K):typeof G=="function"?G.apply(this,arguments):G;return r(zc.translate(q[0],q[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,u)},G,Q)};function C(I,F){return F=Math.max(o[0],Math.min(o[1],F)),F===I.k?I:new zr(F,I.x,I.y)}function E(I,F,z){var G=F[0]-z[0]*I.k,Q=F[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new zr(I.k,G,Q)}function A(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function M(I,F,z,G){I.on("start.zoom",function(){j(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=j(Q,K).event(G),q=t.apply(Q,K),Y=z==null?A(q):typeof z=="function"?z.apply(Q,K):z,N=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),$=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=d($.invert(Y).concat(N/$.k),X.invert(Y).concat(N/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),se=N/re[2];ne=new zr(se,Y[0]-re[0]*se,Y[1]-re[1]*se)}D.zoom(null,ne)}})}function j(I,F,z){return!z&&I.__zooming||new L(I,F)}function L(I,F){this.that=I,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,F),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,F){return this.mouse&&I!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var F=wn(this.that).datum();h.call(I,this.that,new Vj(I,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:h}),F)}};function O(I,...F){if(!e.apply(this,arguments))return;var z=j(this,F).event(I),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(I);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],tc(this),z.start()}bo(I),z.wheel=setTimeout(D,w),z.zoom("mouse",r(E(C(G,Q),z.mouse[0],z.mouse[1]),z.extent,u));function D(){z.wheel=null,z.end()}}function P(I,...F){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=j(this,F,!0).event(I),Q=wn(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",N,!0),K=qn(I,z),D=I.clientX,q=I.clientY;eS(I.view),vh(I),G.mouse=[K,this.__zoom.invert(K)],tc(this),G.start();function Y($){if(bo($),!G.moved){var X=$.clientX-D,J=$.clientY-q;G.moved=X*X+J*J>k}G.event($).zoom("mouse",r(E(G.that.__zoom,G.mouse[0]=qn($,z),G.mouse[1]),G.extent,u))}function N($){Q.on("mousemove.zoom mouseup.zoom",null),tS($.view,G.moved),bo($),G.event($).end()}}function H(I,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),K=z.k*(I.shiftKey?.5:2),D=r(E(C(z,K),G,Q),t.apply(this,F),u);bo(I),c>0?wn(this).transition().duration(c).call(M,D,G,I):wn(this).call(S.transform,D,G,I)}}function B(I,...F){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=j(this,F,I.changedTouches.length===G).event(I),K,D,q,Y;for(vh(I),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:r,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r:l}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Vo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],yS=["Enter"," ","Escape"],vS={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ha;(function(e){e.Strict="strict",e.Loose="loose"})(ha||(ha={}));var Zi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zi||(Zi={}));var Po;(function(e){e.Partial="partial",e.Full="full"})(Po||(Po={}));const bS={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var xi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(xi||(xi={}));var hc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(hc||(hc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const jv={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function wS(e){return e===null?null:e?"valid":"invalid"}const SS=e=>"id"in e&&"source"in e&&"target"in e,Xj=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),jm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wo=(e,t=[0,0])=>{const{width:r,height:l}=Or(e),a=e.origin??t,o=r*a[0],u=l*a[1];return{x:e.position.x-o,y:e.position.y-u}},Qj=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((l,a)=>{const o=typeof a=="string";let u=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(u=o?t.nodeLookup.get(a):jm(a)?a:t.nodeLookup.get(a.id));const c=u?pc(u,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Mc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Dc(r)},es=(e,t={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(r=Mc(r,pc(a)),l=!0)}),l?Dc(r):{x:0,y:0,width:0,height:0}},Am=(e,t,[r,l,a]=[0,0,1],o=!1,u=!1)=>{const c={...ns(t,[r,l,a]),width:t.width/a,height:t.height/a},d=[];for(const h of e.values()){const{measured:m,selectable:p=!0,hidden:x=!1}=h;if(u&&!p||x)continue;const b=m.width??h.width??h.initialWidth??null,w=m.height??h.height??h.initialHeight??null,k=$o(c,ma(h)),_=(b??0)*(w??0),S=o&&k>0;(!h.internals.handleBounds||S||k>=_||h.dragging)&&d.push(h)}return d},Zj=(e,t)=>{const r=new Set;return e.forEach(l=>{r.add(l.id)}),t.filter(l=>r.has(l.source)||r.has(l.target))};function Kj(e,t){const r=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&r.set(a.id,a)}),r}async function Jj({nodes:e,width:t,height:r,panZoom:l,minZoom:a,maxZoom:o},u){if(e.size===0)return Promise.resolve(!0);const c=Kj(e,u),d=es(c),h=zm(d,t,r,(u==null?void 0:u.minZoom)??a,(u==null?void 0:u.maxZoom)??o,(u==null?void 0:u.padding)??.1);return await l.setViewport(h,{duration:u==null?void 0:u.duration,ease:u==null?void 0:u.ease,interpolate:u==null?void 0:u.interpolate}),Promise.resolve(!0)}function _S({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const u=r.get(e),c=u.parentId?r.get(u.parentId):void 0,{x:d,y:h}=c?c.internals.positionAbsolute:{x:0,y:0},m=u.origin??l;let p=u.extent||a;if(u.extent==="parent"&&!u.expandParent)if(!c)o==null||o("005",lr.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[d,h],[d+b,h+w]])}else c&&ga(u.extent)&&(p=[[u.extent[0][0]+d,u.extent[0][1]+h],[u.extent[1][0]+d,u.extent[1][1]+h]]);const x=ga(p)?el(t,p,u.measured):t;return(u.measured.width===void 0||u.measured.height===void 0)&&(o==null||o("015",lr.error015())),{position:{x:x.x-d+(u.measured.width??0)*m[0],y:x.y-h+(u.measured.height??0)*m[1]},positionAbsolute:x}}async function Wj({nodesToRemove:e=[],edgesToRemove:t=[],nodes:r,edges:l,onBeforeDelete:a}){const o=new Set(e.map(x=>x.id)),u=[];for(const x of r){if(x.deletable===!1)continue;const b=o.has(x.id),w=!b&&x.parentId&&u.find(k=>k.id===x.parentId);(b||w)&&u.push(x)}const c=new Set(t.map(x=>x.id)),d=l.filter(x=>x.deletable!==!1),m=Zj(u,d);for(const x of d)c.has(x.id)&&!m.find(w=>w.id===x.id)&&m.push(x);if(!a)return{edges:m,nodes:u};const p=await a({nodes:u,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:u}:{edges:[],nodes:[]}:p}const pa=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),el=(e={x:0,y:0},t,r)=>({x:pa(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:pa(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function kS(e,t,r){const{width:l,height:a}=Or(r),{x:o,y:u}=r.internals.positionAbsolute;return el(e,[[o,u],[o+l,u+a]],t)}const Av=(e,t,r)=>er?-pa(Math.abs(e-r),1,t)/t:0,ES=(e,t,r=15,l=40)=>{const a=Av(e.x,l,t.width-l)*r,o=Av(e.y,l,t.height-l)*r;return[a,o]},Mc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Jp=({x:e,y:t,width:r,height:l})=>({x:e,y:t,x2:e+r,y2:t+l}),Dc=({x:e,y:t,x2:r,y2:l})=>({x:e,y:t,width:r-e,height:l-t}),ma=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=jm(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},pc=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=jm(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,x2:r+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},NS=(e,t)=>Dc(Mc(Jp(e),Jp(t))),$o=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*l)},zv=e=>Vn(e.width)&&Vn(e.height)&&Vn(e.x)&&Vn(e.y),Vn=e=>!isNaN(e)&&isFinite(e),eA=(e,t)=>{},ts=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ns=({x:e,y:t},[r,l,a],o=!1,u=[1,1])=>{const c={x:(e-r)/a,y:(t-l)/a};return o?ts(c,u):c},mc=({x:e,y:t},[r,l,a])=>({x:e*a+r,y:t*a+l});function Zl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function tA(e,t,r){if(typeof e=="string"||typeof e=="number"){const l=Zl(e,r),a=Zl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Zl(e.top??e.y??0,r),a=Zl(e.bottom??e.y??0,r),o=Zl(e.left??e.x??0,t),u=Zl(e.right??e.x??0,t);return{top:l,right:u,bottom:a,left:o,x:o+u,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function nA(e,t,r,l,a,o){const{x:u,y:c}=mc(e,[t,r,l]),{x:d,y:h}=mc({x:e.x+e.width,y:e.y+e.height},[t,r,l]),m=a-d,p=o-h;return{left:Math.floor(u),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const zm=(e,t,r,l,a,o)=>{const u=tA(o,t,r),c=(t-u.x)/e.width,d=(r-u.y)/e.height,h=Math.min(c,d),m=pa(h,l,a),p=e.x+e.width/2,x=e.y+e.height/2,b=t/2-p*m,w=r/2-x*m,k=nA(e,b,w,m,t,r),_={left:Math.min(k.left-u.left,0),top:Math.min(k.top-u.top,0),right:Math.min(k.right-u.right,0),bottom:Math.min(k.bottom-u.bottom,0)};return{x:b-_.left+_.right,y:w-_.top+_.bottom,zoom:m}},Go=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ga(e){return e!=null&&e!=="parent"}function Or(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function CS(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function TS(e,t={width:0,height:0},r,l,a){const o={...e},u=l.get(r);if(u){const c=u.origin||a;o.x+=u.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=u.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Mv(e,t){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}function rA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function iA(e){return{...vS,...e||{}}}function Mo(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:l,containerBounds:a}){const{x:o,y:u}=Pn(e),c=ns({x:o-((a==null?void 0:a.left)??0),y:u-((a==null?void 0:a.top)??0)},l),{x:d,y:h}=r?ts(c,t):c;return{xSnapped:d,ySnapped:h,...c}}const Mm=e=>({width:e.offsetWidth,height:e.offsetHeight}),jS=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},lA=["INPUT","SELECT","TEXTAREA"];function AS(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:lA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const zS=e=>"clientX"in e,Pn=(e,t)=>{var o,u;const r=zS(e),l=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Dv=(e,t,r,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(u=>{const c=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:a,position:u.getAttribute("data-handlepos"),x:(c.left-r.left)/l,y:(c.top-r.top)/l,...Mm(u)}})};function MS({sourceX:e,sourceY:t,targetX:r,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:u,targetControlY:c}){const d=e*.125+a*.375+u*.375+r*.125,h=t*.125+o*.375+c*.375+l*.125,m=Math.abs(d-e),p=Math.abs(h-t);return[d,h,m,p]}function Uu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Rv({pos:e,x1:t,y1:r,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Uu(t-l,o),r];case ve.Right:return[t+Uu(l-t,o),r];case ve.Top:return[t,r-Uu(r-a,o)];case ve.Bottom:return[t,r+Uu(a-r,o)]}}function Dm({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:u=.25}){const[c,d]=Rv({pos:r,x1:e,y1:t,x2:l,y2:a,c:u}),[h,m]=Rv({pos:o,x1:l,y1:a,x2:e,y2:t,c:u}),[p,x,b,w]=MS({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:m});return[`M${e},${t} C${c},${d} ${h},${m} ${l},${a}`,p,x,b,w]}function DS({sourceX:e,sourceY:t,targetX:r,targetY:l}){const a=Math.abs(r-e)/2,o=r0}const sA=({source:e,sourceHandle:t,target:r,targetHandle:l})=>`xy-edge__${e}${t||""}-${r}${l||""}`,uA=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),cA=(e,t,r={})=>{if(!e.source||!e.target)return t;const l=r.getEdgeId||sA;let a;return SS(e)?a={...e}:a={...e,id:l(e)},uA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function RS({sourceX:e,sourceY:t,targetX:r,targetY:l}){const[a,o,u,c]=DS({sourceX:e,sourceY:t,targetX:r,targetY:l});return[`M ${e},${t}L ${r},${l}`,a,o,u,c]}const Ov={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},fA=({source:e,sourcePosition:t=ve.Bottom,target:r})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dA({source:e,sourcePosition:t=ve.Bottom,target:r,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:u}){const c=Ov[t],d=Ov[l],h={x:e.x+c.x*o,y:e.y+c.y*o},m={x:r.x+d.x*o,y:r.y+d.y*o},p=fA({source:h,sourcePosition:t,target:m}),x=p.x!==0?"x":"y",b=p[x];let w=[],k,_;const S={x:0,y:0},C={x:0,y:0},[,,E,A]=DS({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*d[x]===-1){x==="x"?(k=a.x??h.x+(m.x-h.x)*u,_=a.y??(h.y+m.y)/2):(k=a.x??(h.x+m.x)/2,_=a.y??h.y+(m.y-h.y)*u);const j=[{x:k,y:h.y},{x:k,y:m.y}],L=[{x:h.x,y:_},{x:m.x,y:_}];c[x]===b?w=x==="x"?j:L:w=x==="x"?L:j}else{const j=[{x:h.x,y:m.y}],L=[{x:m.x,y:h.y}];if(x==="x"?w=c.x===b?L:j:w=c.y===b?j:L,t===l){const U=Math.abs(e[x]-r[x]);if(U<=o){const ee=Math.min(o-1,o-U);c[x]===b?S[x]=(h[x]>e[x]?-1:1)*ee:C[x]=(m[x]>r[x]?-1:1)*ee}}if(t!==l){const U=x==="x"?"y":"x",ee=c[x]===d[U],I=h[U]>m[U],F=h[U]=B?(k=(O.x+P.x)/2,_=w[0].y):(k=w[0].x,_=(O.y+P.y)/2)}return[[e,{x:h.x+S.x,y:h.y+S.y},...w,{x:m.x+C.x,y:m.y+C.y},r],k,_,E,A]}function hA(e,t,r,l){const a=Math.min(Lv(e,t)/2,Lv(t,r)/2,l),{x:o,y:u}=t;if(e.x===o&&o===r.x||e.y===u&&u===r.y)return`L${o} ${u}`;if(e.y===u){const h=e.x{let A="";return E>0&&Er.id===t):e[0])||null}function em(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function mA(e,{id:t,defaultColor:r,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((u,c)=>([c.markerStart||l,c.markerEnd||a].forEach(d=>{if(d&&typeof d=="object"){const h=em(d,t);o.has(h)||(u.push({id:h,color:d.color||r,...d}),o.add(h))}}),u),[]).sort((u,c)=>u.id.localeCompare(c.id))}const OS=1e3,gA=10,Rm={nodeOrigin:[0,0],nodeExtent:Vo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xA={...Rm,checkEquality:!0};function Om(e,t){const r={...e};for(const l in t)t[l]!==void 0&&(r[l]=t[l]);return r}function yA(e,t,r){const l=Om(Rm,r);for(const a of e.values())if(a.parentId)Hm(a,e,t,l);else{const o=Wo(a,l.nodeOrigin),u=ga(a.extent)?a.extent:l.nodeExtent,c=el(o,u,Or(a));a.internals.positionAbsolute=c}}function vA(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const r=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?r.push(o):a.type==="target"&&l.push(o)}return{source:r,target:l}}function Lm(e){return e==="manual"}function tm(e,t,r,l={}){var h,m;const a=Om(xA,l),o={i:0},u=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Lm(a.zIndexMode)?OS:0;let d=e.length>0;t.clear(),r.clear();for(const p of e){let x=u.get(p.id);if(a.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=Wo(p,a.nodeOrigin),w=ga(p.extent)?p.extent:a.nodeExtent,k=el(b,w,Or(p));x={...a.defaults,...p,measured:{width:(h=p.measured)==null?void 0:h.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:k,handleBounds:vA(p,x),z:LS(p,c,a.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),p.parentId&&Hm(x,t,r,l,o)}return d}function bA(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hm(e,t,r,l,a){const{elevateNodesOnSelect:o,nodeOrigin:u,nodeExtent:c,zIndexMode:d}=Om(Rm,l),h=e.parentId,m=t.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}bA(e,r),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*gA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Lm(d)?OS:0,{x,y:b,z:w}=wA(e,m,u,c,p,d),{positionAbsolute:k}=e.internals,_=x!==k.x||b!==k.y;(_||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:_?{x,y:b}:k,z:w}})}function LS(e,t,r){const l=Vn(e.zIndex)?e.zIndex:0;return Lm(r)?l:l+(e.selected?t:0)}function wA(e,t,r,l,a,o){const{x:u,y:c}=t.internals.positionAbsolute,d=Or(e),h=Wo(e,r),m=ga(e.extent)?el(h,e.extent,d):h;let p=el({x:u+m.x,y:c+m.y},l,d);e.extent==="parent"&&(p=kS(p,d,t));const x=LS(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=x?b+1:x}}function Bm(e,t,r,l=[0,0]){var u;const a=[],o=new Map;for(const c of e){const d=t.get(c.parentId);if(!d)continue;const h=((u=o.get(c.parentId))==null?void 0:u.expandedRect)??ma(d),m=NS(h,c.rect);o.set(c.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:c,parent:d},h)=>{var E;const m=d.internals.positionAbsolute,p=Or(d),x=d.origin??l,b=c.x0||w>0||S||C)&&(a.push({id:h,type:"position",position:{x:d.position.x-b+S,y:d.position.y-w+C}}),(E=r.get(h))==null||E.forEach(A=>{e.some(M=>M.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+b,y:A.position.y+w}})})),(p.width0){const b=Bm(x,t,r,a);h.push(...b)}return{changes:h,updatedInternals:d}}async function _A({delta:e,panZoom:t,transform:r,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const u=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],l),c=!!u&&(u.x!==r[0]||u.y!==r[1]||u.k!==r[2]);return Promise.resolve(c)}function qv(e,t,r,l,a,o){let u=a;const c=l.get(u)||new Map;l.set(u,c.set(r,t)),u=`${a}-${e}`;const d=l.get(u)||new Map;if(l.set(u,d.set(r,t)),o){u=`${a}-${e}-${o}`;const h=l.get(u)||new Map;l.set(u,h.set(r,t))}}function HS(e,t,r){e.clear(),t.clear();for(const l of r){const{source:a,target:o,sourceHandle:u=null,targetHandle:c=null}=l,d={edgeId:l.id,source:a,target:o,sourceHandle:u,targetHandle:c},h=`${a}-${u}--${o}-${c}`,m=`${o}-${c}--${a}-${u}`;qv("source",d,m,e,a,u),qv("target",d,h,e,o,c),t.set(l.id,l)}}function BS(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:BS(r,t):!1}function Uv(e,t,r){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===r)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function kA(e,t,r,l){const a=new Map;for(const[o,u]of e)if((u.selected||u.id===l)&&(!u.parentId||!BS(u,e))&&(u.draggable||t&&typeof u.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:r.x-c.internals.positionAbsolute.x,y:r.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function bh({nodeId:e,dragItems:t,nodeLookup:r,dragging:l=!0}){var u,c,d;const a=[];for(const[h,m]of t){const p=(u=r.get(h))==null?void 0:u.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=r.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:l}:a[0],a]}function EA({dragItems:e,snapGrid:t,x:r,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:l-a.distance.y},u=ts(o,t);return{x:u.x-o.x,y:u.y-o.y}}function NA({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,onDrag:l,onDragStop:a}){let o={x:null,y:null},u=0,c=new Map,d=!1,h={x:0,y:0},m=null,p=!1,x=null,b=!1,w=!1,k=null;function _({noDragClassName:C,handleSelector:E,domNode:A,isSelectable:M,nodeId:j,nodeClickDistance:L=0}){x=wn(A);function O({x:U,y:ee}){const{nodeLookup:I,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:q,updateNodePositions:Y}=t();o={x:U,y:ee};let N=!1;const $=c.size>1,X=$&&F?Jp(es(c)):null,J=$&&G?EA({dragItems:c,snapGrid:z,x:U,y:ee}):null;for(const[ne,re]of c){if(!I.has(ne))continue;let se={x:U-re.distance.x,y:ee-re.distance.y};G&&(se=J?{x:Math.round(se.x+J.x),y:Math.round(se.y+J.y)}:ts(se,z));let xe=null;if($&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,_e=pe.x-X.x+F[0][0],ze=pe.x+re.measured.width-X.x2+F[1][0],Te=pe.y-X.y+F[0][1],ut=pe.y+re.measured.height-X.y2+F[1][1];xe=[[_e,Te],[ze,ut]]}const{position:be,positionAbsolute:ye}=_S({nodeId:ne,nextPosition:se,nodeLookup:I,nodeExtent:xe||F,nodeOrigin:Q,onError:q});N=N||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||N,!!N&&(Y(c,!0),k&&(l||K||!j&&D))){const[ne,re]=bh({nodeId:j,dragItems:c,nodeLookup:I});l==null||l(k,c,ne,re),K==null||K(k,ne,re),j||D==null||D(k,re)}}async function P(){if(!m)return;const{transform:U,panBy:ee,autoPanSpeed:I,autoPanOnNodeDrag:F}=t();if(!F){d=!1,cancelAnimationFrame(u);return}const[z,G]=ES(h,m,I);(z!==0||G!==0)&&(o.x=(o.x??0)-z/U[2],o.y=(o.y??0)-G/U[2],await ee({x:z,y:G})&&O(o)),u=requestAnimationFrame(P)}function H(U){var $;const{nodeLookup:ee,multiSelectionActive:I,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!I&&j&&(($=ee.get(j))!=null&&$.selected||Y()),M&&K&&j&&(e==null||e(j));const N=Mo(U.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=N,c=kA(ee,F,N,j),c.size>0&&(r||D||!j&&q)){const[X,J]=bh({nodeId:j,dragItems:c,nodeLookup:ee});r==null||r(U.sourceEvent,c,X,J),D==null||D(U.sourceEvent,X,J),j||q==null||q(U.sourceEvent,J)}}const B=nS().clickDistance(L).on("start",U=>{const{domNode:ee,nodeDragThreshold:I,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,k=U.sourceEvent,I===0&&H(U),o=Mo(U.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),h=Pn(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:ee,transform:I,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Mo(U.sourceEvent,{transform:I,snapGrid:F,snapToGrid:z,containerBounds:m});if(k=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||j&&!Q.has(j))&&(b=!0),!b){if(!d&&ee&&p&&(d=!0,P()),!p){const D=Pn(U.sourceEvent,m),q=D.x-h.x,Y=D.y-h.y;Math.sqrt(q*q+Y*Y)>G&&H(U)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(h=Pn(U.sourceEvent,m),O(K))}}).on("end",U=>{if(!(!p||b)&&(d=!1,p=!1,cancelAnimationFrame(u),c.size>0)){const{nodeLookup:ee,updateNodePositions:I,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(I(c,!1),w=!1),a||F||!j&&z){const[G,Q]=bh({nodeId:j,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a(U.sourceEvent,c,G,Q),F==null||F(U.sourceEvent,G,Q),j||z==null||z(U.sourceEvent,Q)}}}).filter(U=>{const ee=U.target;return!U.button&&(!C||!Uv(ee,`.${C}`,A))&&(!E||Uv(ee,E,A))});x.call(B)}function S(){x==null||x.on(".drag",null)}return{update:_,destroy:S}}function CA(e,t,r){const l=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())$o(a,ma(o))>0&&l.push(o);return l}const TA=250;function jA(e,t,r,l){var c,d;let a=[],o=1/0;const u=CA(e,r,t+TA);for(const h of u){const m=[...((c=h.internals.handleBounds)==null?void 0:c.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x,y:b}=tl(h,p,p.position,!0),w=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const h=l.type==="source"?"target":"source";return a.find(m=>m.type===h)??a[0]}return a[0]}function IS(e,t,r,l,a,o=!1){var h,m,p;const u=l.get(e);if(!u)return null;const c=a==="strict"?(h=u.internals.handleBounds)==null?void 0:h[t]:[...((m=u.internals.handleBounds)==null?void 0:m.source)??[],...((p=u.internals.handleBounds)==null?void 0:p.target)??[]],d=(r?c==null?void 0:c.find(x=>x.id===r):c==null?void 0:c[0])??null;return d&&o?{...d,...tl(u,d,d.position,!0)}:d}function qS(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function AA(e,t){let r=null;return t?r=!0:e&&!t&&(r=!1),r}const US=()=>!0;function zA(e,{connectionMode:t,connectionRadius:r,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:u,domNode:c,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:p,panBy:x,cancelConnection:b,onConnectStart:w,onConnect:k,onConnectEnd:_,isValidConnection:S=US,onReconnectEnd:C,updateConnection:E,getTransform:A,getFromHandle:M,autoPanSpeed:j,dragThreshold:L=1,handleDomNode:O}){const P=jS(e.target);let H=0,B;const{x:U,y:ee}=Pn(e),I=qS(o,O),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!I)return;const G=IS(a,I,l,d,t);if(!G)return;let Q=Pn(e,F),K=!1,D=null,q=!1,Y=null;function N(){if(!m||!F)return;const[be,ye]=ES(Q,F,j);x({x:be,y:ye}),H=requestAnimationFrame(N)}const $={...G,nodeId:a,type:I,position:G.position},X=d.get(a);let ne={inProgress:!0,isValid:null,from:tl(X,$,ve.Left,!0),fromHandle:$,fromPosition:$.position,fromNode:X,to:Q,toHandle:null,toPosition:jv[$.position],toNode:null,pointer:Q};function re(){z=!0,E(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:I})}L===0&&re();function se(be){if(!z){const{x:ut,y:nt}=Pn(be),zt=ut-U,Pt=nt-ee;if(!(zt*zt+Pt*Pt>L*L))return;re()}if(!M()||!$){xe(be);return}const ye=A();Q=Pn(be,F),B=jA(ns(Q,ye,!1,[1,1]),r,d,$),K||(N(),K=!0);const pe=VS(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:u?"target":"source",isValidConnection:S,doc:P,lib:h,flowId:p,nodeLookup:d});Y=pe.handleDomNode,D=pe.connection,q=AA(!!B,pe.isValid);const _e=d.get(a),ze=_e?tl(_e,$,ve.Left,!0):ne.from,Te={...ne,from:ze,isValid:q,to:pe.toHandle&&q?mc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:q&&pe.toHandle?pe.toHandle.position:jv[$.position],toNode:pe.toHandle?d.get(pe.toHandle.nodeId):null,pointer:Q};E(Te),ne=Te}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&q&&(k==null||k(D));const{inProgress:ye,...pe}=ne,_e={...pe,toPosition:ne.toHandle?ne.toPosition:null};_==null||_(be,_e),o&&(C==null||C(be,_e))}b(),cancelAnimationFrame(H),K=!1,q=!1,D=null,Y=null,P.removeEventListener("mousemove",se),P.removeEventListener("mouseup",xe),P.removeEventListener("touchmove",se),P.removeEventListener("touchend",xe)}}P.addEventListener("mousemove",se),P.addEventListener("mouseup",xe),P.addEventListener("touchmove",se),P.addEventListener("touchend",xe)}function VS(e,{handle:t,connectionMode:r,fromNodeId:l,fromHandleId:a,fromType:o,doc:u,lib:c,flowId:d,isValidConnection:h=US,nodeLookup:m}){const p=o==="target",x=t?u.querySelector(`.${c}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Pn(e),k=u.elementFromPoint(b,w),_=k!=null&&k.classList.contains(`${c}-flow__handle`)?k:x,S={handleDomNode:_,isValid:!1,connection:null,toHandle:null};if(_){const C=qS(void 0,_),E=_.getAttribute("data-nodeid"),A=_.getAttribute("data-handleid"),M=_.classList.contains("connectable"),j=_.classList.contains("connectableend");if(!E||!C)return S;const L={source:p?E:l,sourceHandle:p?A:a,target:p?l:E,targetHandle:p?a:A};S.connection=L;const P=M&&j&&(r===ha.Strict?p&&C==="source"||!p&&C==="target":E!==l||A!==a);S.isValid=P&&h(L),S.toHandle=IS(E,C,A,m,r,!0)}return S}const nm={onPointerDown:zA,isValid:VS};function MA({domNode:e,panZoom:t,getTransform:r,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:d,height:h,zoomStep:m=1,pannable:p=!0,zoomable:x=!0,inversePan:b=!1}){const w=E=>{if(E.sourceEvent.type!=="wheel"||!t)return;const A=r(),M=E.sourceEvent.ctrlKey&&Go()?10:1,j=-E.sourceEvent.deltaY*(E.sourceEvent.deltaMode===1?.05:E.sourceEvent.deltaMode?1:.002)*m,L=A[2]*Math.pow(2,j*M);t.scaleTo(L)};let k=[0,0];const _=E=>{(E.sourceEvent.type==="mousedown"||E.sourceEvent.type==="touchstart")&&(k=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY])},S=E=>{const A=r();if(E.sourceEvent.type!=="mousemove"&&E.sourceEvent.type!=="touchmove"||!t)return;const M=[E.sourceEvent.clientX??E.sourceEvent.touches[0].clientX,E.sourceEvent.clientY??E.sourceEvent.touches[0].clientY],j=[M[0]-k[0],M[1]-k[1]];k=M;const L=l()*Math.max(A[2],Math.log(A[2]))*(b?-1:1),O={x:A[0]-j[0]*L,y:A[1]-j[1]*L},P=[[0,0],[d,h]];t.setViewportConstrained({x:O.x,y:O.y,zoom:A[2]},P,c)},C=xS().on("start",_).on("zoom",p?S:null).on("zoom.wheel",x?w:null);a.call(C,{})}function u(){a.on("zoom",null)}return{update:o,destroy:u,pointer:qn}}const Rc=e=>({x:e.x,y:e.y,zoom:e.k}),wh=({x:e,y:t,zoom:r})=>zc.translate(e,t).scale(r),ra=(e,t)=>e.target.closest(`.${t}`),PS=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),DA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Sh=(e,t=0,r=DA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(r).on("end",l):e},$S=e=>{const t=e.ctrlKey&&Go()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function RA({zoomPanValues:e,noWheelClassName:t,d3Selection:r,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:u,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(ra(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=r.property("__zoom").k||1;if(m.ctrlKey&&u){const _=qn(m),S=$S(m),C=p*Math.pow(2,S);l.scaleTo(r,C,_,m);return}const x=m.deltaMode===1?20:1;let b=a===Zi.Vertical?0:m.deltaX*x,w=a===Zi.Horizontal?0:m.deltaY*x;!Go()&&m.shiftKey&&a!==Zi.Vertical&&(b=m.deltaY*x,w=0),l.translateBy(r,-(b/p)*o,-(w/p)*o,{internal:!0});const k=Rc(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(m,k),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,k),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,k))}}function OA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){return function(l,a){const o=l.type==="wheel",u=!t&&o&&!l.ctrlKey,c=ra(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),u||c)return null;l.preventDefault(),r.call(this,l,a)}}function LA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){return l=>{var o,u,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Rc(l.transform);e.mouseButton=((u=l.sourceEvent)==null?void 0:u.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),r&&(r==null||r(l.sourceEvent,a))}}function HA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:l,onPanZoom:a}){return o=>{var u,c;e.usedRightMouseButton=!!(r&&PS(t,e.mouseButton??0)),(u=o.sourceEvent)!=null&&u.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Rc(o.transform)))}}function BA({zoomPanValues:e,panOnDrag:t,panOnScroll:r,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return u=>{var c;if(!((c=u.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&PS(t,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&o(u.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const d=Rc(u.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(u.sourceEvent,d)},r?150:0)}}}function IA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:u,noWheelClassName:c,noPanClassName:d,lib:h,connectionInProgress:m}){return p=>{var _;const x=e||t,b=r&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ra(p,`${h}-flow__node`)||ra(p,`${h}-flow__edge`)))return!0;if(!l&&!x&&!a&&!o&&!r||u||m&&!w||ra(p,c)&&w||ra(p,d)&&(!w||a&&w&&!e)||!r&&p.ctrlKey&&w)return!1;if(!r&&p.type==="touchstart"&&((_=p.touches)==null?void 0:_.length)>1)return p.preventDefault(),!1;if(!x&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const k=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&k}}function qA({domNode:e,minZoom:t,maxZoom:r,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:u,onPanZoomEnd:c,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=xS().scaleExtent([t,r]).translateExtent(l),x=wn(e).call(p);C({x:a.x,y:a.y,zoom:pa(a.zoom,t,r)},[[0,0],[m.width,m.height]],l);const b=x.on("wheel.zoom"),w=x.on("dblclick.zoom");p.wheelDelta($S);function k(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).transform(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function _({noWheelClassName:B,noPanClassName:U,onPaneContextMenu:ee,userSelectionActive:I,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:q,zoomOnDoubleClick:Y,zoomActivationKeyPressed:N,lib:$,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){I&&!h.isZoomingOrPanning&&S();const se=F&&!N&&!I;p.clickDistance(re?1/0:!Vn(ne)||ne<0?0:ne);const xe=se?RA({zoomPanValues:h,noWheelClassName:B,d3Selection:x,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:u,onPanZoom:o,onPanZoomEnd:c}):OA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(x.on("wheel.zoom",xe,{passive:!1}),!I){const ye=LA({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:u});p.on("start",ye);const pe=HA({zoomPanValues:h,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const _e=BA({zoomPanValues:h,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:d});p.on("end",_e)}const be=IA({zoomActivationKeyPressed:N,panOnDrag:z,zoomOnScroll:q,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:I,noPanClassName:U,noWheelClassName:B,lib:$,connectionInProgress:J});p.filter(be),Y?x.on("dblclick.zoom",w):x.on("dblclick.zoom",null)}function S(){p.on("zoom",null)}async function C(B,U,ee){const I=wh(B),F=p==null?void 0:p.constrain()(I,U,ee);return F&&await k(F),new Promise(z=>z(F))}async function E(B,U){const ee=wh(B);return await k(ee,U),new Promise(I=>I(ee))}function A(B){if(x){const U=wh(B),ee=x.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(x,U,null,{sync:!0}))}}function M(){const B=x?gS(x.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function j(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleTo(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleBy(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function O(B){p==null||p.scaleExtent(B)}function P(B){p==null||p.translateExtent(B)}function H(B){const U=!Vn(B)||B<0?0:B;p==null||p.clickDistance(U)}return{update:_,destroy:S,setViewport:E,setViewportConstrained:C,getViewport:M,scaleTo:j,scaleBy:L,setScaleExtent:O,setTranslateExtent:P,syncViewport:A,setClickDistance:H}}var xa;(function(e){e.Line="line",e.Handle="handle"})(xa||(xa={}));function UA({width:e,prevWidth:t,height:r,prevHeight:l,affectsX:a,affectsY:o}){const u=e-t,c=r-l,d=[u>0?1:u<0?-1:0,c>0?1:c<0?-1:0];return u&&a&&(d[0]=d[0]*-1),c&&o&&(d[1]=d[1]*-1),d}function Vv(e){const t=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:l,affectsY:a}}function hi(e,t){return Math.max(0,t-e)}function pi(e,t){return Math.max(0,e-t)}function Vu(e,t,r){return Math.max(0,t-e,e-r)}function Pv(e,t){return e?!t:t}function VA(e,t,r,l,a,o,u,c){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:p}=t,x=m&&p,{xSnapped:b,ySnapped:w}=r,{minWidth:k,maxWidth:_,minHeight:S,maxHeight:C}=l,{x:E,y:A,width:M,height:j,aspectRatio:L}=e;let O=Math.floor(m?b-e.pointerX:0),P=Math.floor(p?w-e.pointerY:0);const H=M+(d?-O:O),B=j+(h?-P:P),U=-o[0]*M,ee=-o[1]*j;let I=Vu(H,k,_),F=Vu(B,S,C);if(u){let Q=0,K=0;d&&O<0?Q=hi(E+O+U,u[0][0]):!d&&O>0&&(Q=pi(E+H+U,u[1][0])),h&&P<0?K=hi(A+P+ee,u[0][1]):!h&&P>0&&(K=pi(A+B+ee,u[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;d&&O>0?Q=pi(E+O,c[0][0]):!d&&O<0&&(Q=hi(E+H,c[1][0])),h&&P>0?K=pi(A+P,c[0][1]):!h&&P<0&&(K=hi(A+B,c[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(a){if(m){const Q=Vu(H/L,S,C)*L;if(I=Math.max(I,Q),u){let K=0;!d&&!h||d&&!h&&x?K=pi(A+ee+H/L,u[1][1])*L:K=hi(A+ee+(d?O:-O)/L,u[0][1])*L,I=Math.max(I,K)}if(c){let K=0;!d&&!h||d&&!h&&x?K=hi(A+H/L,c[1][1])*L:K=pi(A+(d?O:-O)/L,c[0][1])*L,I=Math.max(I,K)}}if(p){const Q=Vu(B*L,k,_)/L;if(F=Math.max(F,Q),u){let K=0;!d&&!h||h&&!d&&x?K=pi(E+B*L+U,u[1][0])/L:K=hi(E+(h?P:-P)*L+U,u[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!d&&!h||h&&!d&&x?K=hi(E+B*L,c[1][0])/L:K=pi(E+(h?P:-P)*L,c[0][0])/L,F=Math.max(F,K)}}}P=P+(P<0?F:-F),O=O+(O<0?I:-I),a&&(x?H>B*L?P=(Pv(d,h)?-O:O)/L:O=(Pv(d,h)?-P:P)*L:m?(P=O/L,h=d):(O=P*L,d=h));const z=d?E+O:E,G=h?A+P:A;return{width:M+(d?-O:O),height:j+(h?-P:P),x:o[0]*O*(d?-1:1)+z,y:o[1]*P*(h?-1:1)+G}}const GS={width:0,height:0,x:0,y:0},PA={...GS,pointerX:0,pointerY:0,aspectRatio:1};function $A(e){return[[0,0],[e.measured.width,e.measured.height]]}function GA(e,t,r){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,u=e.measured.height??0,c=r[0]*o,d=r[1]*u;return[[l-c,a-d],[l+o-c,a+u-d]]}function FA({domNode:e,nodeId:t,getStoreItems:r,onChange:l,onEnd:a}){const o=wn(e);let u={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:h,boundaries:m,keepAspectRatio:p,resizeDirection:x,onResizeStart:b,onResize:w,onResizeEnd:k,shouldResize:_}){let S={...GS},C={...PA};u={boundaries:m,resizeDirection:x,keepAspectRatio:p,controlDirection:Vv(h)};let E,A=null,M=[],j,L,O,P=!1;const H=nS().on("start",B=>{const{nodeLookup:U,transform:ee,snapGrid:I,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=r();if(E=U.get(t),!E)return;A=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Mo(B.sourceEvent,{transform:ee,snapGrid:I,snapToGrid:F,containerBounds:A});S={width:E.measured.width??0,height:E.measured.height??0,x:E.position.x??0,y:E.position.y??0},C={...S,pointerX:Q,pointerY:K,aspectRatio:S.width/S.height},j=void 0,E.parentId&&(E.extent==="parent"||E.expandParent)&&(j=U.get(E.parentId),L=j&&E.extent==="parent"?$A(j):void 0),M=[],O=void 0;for(const[D,q]of U)if(q.parentId===t&&(M.push({id:D,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=GA(q,E,q.origin??z);O?O=[[Math.min(Y[0][0],O[0][0]),Math.min(Y[0][1],O[0][1])],[Math.max(Y[1][0],O[1][0]),Math.max(Y[1][1],O[1][1])]]:O=Y}b==null||b(B,{...S})}).on("drag",B=>{const{transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F}=r(),z=Mo(B.sourceEvent,{transform:U,snapGrid:ee,snapToGrid:I,containerBounds:A}),G=[];if(!E)return;const{x:Q,y:K,width:D,height:q}=S,Y={},N=E.origin??F,{width:$,height:X,x:J,y:ne}=VA(C,u.controlDirection,z,u.boundaries,u.keepAspectRatio,N,L,O),re=$!==D,se=X!==q,xe=J!==Q&&re,be=ne!==K&&se;if(!xe&&!be&&!re&&!se)return;if((xe||be||N[0]===1||N[1]===1)&&(Y.x=xe?J:S.x,Y.y=be?ne:S.y,S.x=Y.x,S.y=Y.y,M.length>0)){const ze=J-Q,Te=ne-K;for(const ut of M)ut.position={x:ut.position.x-ze+N[0]*($-D),y:ut.position.y-Te+N[1]*(X-q)},G.push(ut)}if((re||se)&&(Y.width=re&&(!u.resizeDirection||u.resizeDirection==="horizontal")?$:S.width,Y.height=se&&(!u.resizeDirection||u.resizeDirection==="vertical")?X:S.height,S.width=Y.width,S.height=Y.height),j&&E.expandParent){const ze=N[0]*(Y.width??0);Y.x&&Y.x{P&&(k==null||k(B,{...S}),a==null||a({...S}),P=!1)});o.call(H)}function d(){o.on(".drag",null)}return{update:c,destroy:d}}var _h={exports:{}},kh={},Eh={exports:{}},Nh={};/** + `})]}),y.jsx("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:qN(a,e)}),y.jsxs("span",{className:"text-[var(--text-muted)] font-mono whitespace-nowrap",children:["Event ",e,"/",t]}),y.jsx("div",{className:"flex items-center gap-0.5",children:IN.map(p=>y.jsxs("button",{onClick:()=>c(p),className:He("px-1.5 py-0.5 rounded text-xs font-mono transition-colors",l===p?"bg-[var(--accent)] text-white":"text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--surface-hover)]"),children:[p,"×"]},p))})]})}const _c=P.createContext(null);_c.displayName="PanelGroupContext";const yt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ym=10,Xi=P.useLayoutEffect,iv=ZE.useId,VN=typeof iv=="function"?iv:()=>null;let PN=0;function vm(e=null){const t=VN(),r=P.useRef(e||t||null);return r.current===null&&(r.current=""+PN++),e??r.current}function kw({children:e,className:t="",collapsedSize:r,collapsible:l,defaultSize:a,forwardedRef:o,id:u,maxSize:c,minSize:d,onCollapse:h,onExpand:m,onResize:p,order:x,style:b,tagName:w="div",...E}){const _=P.useContext(_c);if(_===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:N,getPanelSize:k,getPanelStyle:A,groupId:M,isPanelCollapsed:j,reevaluatePanelConstraints:L,registerPanel:R,resizePanel:V,unregisterPanel:H}=_,B=vm(u),U=P.useRef({callbacks:{onCollapse:h,onExpand:m,onResize:p},constraints:{collapsedSize:r,collapsible:l,defaultSize:a,maxSize:c,minSize:d},id:B,idIsFromProps:u!==void 0,order:x});P.useRef({didLogMissingDefaultSizeWarning:!1}),Xi(()=>{const{callbacks:I,constraints:F}=U.current,z={...F};U.current.id=B,U.current.idIsFromProps=u!==void 0,U.current.order=x,I.onCollapse=h,I.onExpand=m,I.onResize=p,F.collapsedSize=r,F.collapsible=l,F.defaultSize=a,F.maxSize=c,F.minSize=d,(z.collapsedSize!==F.collapsedSize||z.collapsible!==F.collapsible||z.maxSize!==F.maxSize||z.minSize!==F.minSize)&&L(U.current,z)}),Xi(()=>{const I=U.current;return R(I),()=>{H(I)}},[x,B,R,H]),P.useImperativeHandle(o,()=>({collapse:()=>{S(U.current)},expand:I=>{N(U.current,I)},getId(){return B},getSize(){return k(U.current)},isCollapsed(){return j(U.current)},isExpanded(){return!j(U.current)},resize:I=>{V(U.current,I)}}),[S,N,k,j,B,V]);const ee=A(U.current,a);return P.createElement(w,{...E,children:e,className:t,id:B,style:{...ee,...b},[yt.groupId]:M,[yt.panel]:"",[yt.panelCollapsible]:l||void 0,[yt.panelId]:B,[yt.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const Eo=P.forwardRef((e,t)=>P.createElement(kw,{...e,forwardedRef:t}));kw.displayName="Panel";Eo.displayName="forwardRef(Panel)";let Up=null,Zu=-1,gi=null;function $N(e,t){if(t){const r=(t&jw)!==0,l=(t&Aw)!==0,a=(t&zw)!==0,o=(t&Mw)!==0;if(r)return a?"se-resize":o?"ne-resize":"e-resize";if(l)return a?"sw-resize":o?"nw-resize":"w-resize";if(a)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function GN(){gi!==null&&(document.head.removeChild(gi),Up=null,gi=null,Zu=-1)}function fh(e,t){var r,l;const a=$N(e,t);if(Up!==a){if(Up=a,gi===null&&(gi=document.createElement("style"),document.head.appendChild(gi)),Zu>=0){var o;(o=gi.sheet)===null||o===void 0||o.removeRule(Zu)}Zu=(r=(l=gi.sheet)===null||l===void 0?void 0:l.insertRule(`*{cursor: ${a} !important;}`))!==null&&r!==void 0?r:-1}}function Ew(e){return e.type==="keydown"}function Nw(e){return e.type.startsWith("pointer")}function Cw(e){return e.type.startsWith("mouse")}function kc(e){if(Nw(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Cw(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function FN(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function YN(e,t,r){return e.xt.x&&e.yt.y}function XN(e,t){if(e===t)throw new Error("Cannot compare node with itself");const r={a:ov(e),b:ov(t)};let l;for(;r.a.at(-1)===r.b.at(-1);)e=r.a.pop(),t=r.b.pop(),l=e;Re(l,"Stacking order can only be calculated for elements with a common ancestor");const a={a:av(lv(r.a)),b:av(lv(r.b))};if(a.a===a.b){const o=l.childNodes,u={a:r.a.at(-1),b:r.b.at(-1)};let c=o.length;for(;c--;){const d=o[c];if(d===u.a)return 1;if(d===u.b)return-1}}return Math.sign(a.a-a.b)}const QN=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ZN(e){var t;const r=getComputedStyle((t=Tw(e))!==null&&t!==void 0?t:e).display;return r==="flex"||r==="inline-flex"}function KN(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||ZN(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||QN.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lv(e){let t=e.length;for(;t--;){const r=e[t];if(Re(r,"Missing node"),KN(r))return r}return null}function av(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ov(e){const t=[];for(;e;)t.push(e),e=Tw(e);return t}function Tw(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const jw=1,Aw=2,zw=4,Mw=8,JN=FN()==="coarse";let Gn=[],aa=!1,Gi=new Map,Ec=new Map;const Lo=new Set;function WN(e,t,r,l,a){var o;const{ownerDocument:u}=t,c={direction:r,element:t,hitAreaMargins:l,setResizeHandlerState:a},d=(o=Gi.get(u))!==null&&o!==void 0?o:0;return Gi.set(u,d+1),Lo.add(c),ic(),function(){var m;Ec.delete(e),Lo.delete(c);const p=(m=Gi.get(u))!==null&&m!==void 0?m:1;if(Gi.set(u,p-1),ic(),p===1&&Gi.delete(u),Gn.includes(c)){const x=Gn.indexOf(c);x>=0&&Gn.splice(x,1),wm(),a("up",!0,null)}}}function eC(e){const{target:t}=e,{x:r,y:l}=kc(e);aa=!0,bm({target:t,x:r,y:l}),ic(),Gn.length>0&&(lc("down",e),e.preventDefault(),Dw(t)||e.stopImmediatePropagation())}function dh(e){const{x:t,y:r}=kc(e);if(aa&&e.buttons===0&&(aa=!1,lc("up",e)),!aa){const{target:l}=e;bm({target:l,x:t,y:r})}lc("move",e),wm(),Gn.length>0&&e.preventDefault()}function hh(e){const{target:t}=e,{x:r,y:l}=kc(e);Ec.clear(),aa=!1,Gn.length>0&&(e.preventDefault(),Dw(t)||e.stopImmediatePropagation()),lc("up",e),bm({target:t,x:r,y:l}),wm(),ic()}function Dw(e){let t=e;for(;t;){if(t.hasAttribute(yt.resizeHandle))return!0;t=t.parentElement}return!1}function bm({target:e,x:t,y:r}){Gn.splice(0);let l=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(l=e),Lo.forEach(a=>{const{element:o,hitAreaMargins:u}=a,c=o.getBoundingClientRect(),{bottom:d,left:h,right:m,top:p}=c,x=JN?u.coarse:u.fine;if(t>=h-x&&t<=m+x&&r>=p-x&&r<=d+x){if(l!==null&&document.contains(l)&&o!==l&&!o.contains(l)&&!l.contains(o)&&XN(l,o)>0){let w=l,E=!1;for(;w&&!w.contains(o);){if(YN(w.getBoundingClientRect(),c)){E=!0;break}w=w.parentElement}if(E)return}Gn.push(a)}})}function ph(e,t){Ec.set(e,t)}function wm(){let e=!1,t=!1;Gn.forEach(l=>{const{direction:a}=l;a==="horizontal"?e=!0:t=!0});let r=0;Ec.forEach(l=>{r|=l}),e&&t?fh("intersection",r):e?fh("horizontal",r):t?fh("vertical",r):GN()}let mh=new AbortController;function ic(){mh.abort(),mh=new AbortController;const e={capture:!0,signal:mh.signal};Lo.size&&(aa?(Gn.length>0&&Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("contextmenu",hh,e),l.addEventListener("pointerleave",dh,e),l.addEventListener("pointermove",dh,e))}),window.addEventListener("pointerup",hh,e),window.addEventListener("pointercancel",hh,e)):Gi.forEach((t,r)=>{const{body:l}=r;t>0&&(l.addEventListener("pointerdown",eC,e),l.addEventListener("pointermove",dh,e))}))}function lc(e,t){Lo.forEach(r=>{const{setResizeHandlerState:l}=r,a=Gn.includes(r);l(e,a,t)})}function tC(){const[e,t]=P.useState(0);return P.useCallback(()=>t(r=>r+1),[])}function Re(e,t){if(!e)throw console.error(t),Error(t)}function Ki(e,t,r=ym){return e.toFixed(r)===t.toFixed(r)?0:e>t?1:-1}function Ar(e,t,r=ym){return Ki(e,t,r)===0}function bn(e,t,r){return Ki(e,t,r)===0}function nC(e,t,r){if(e.length!==t.length)return!1;for(let l=0;l0&&(e=e<0?0-S:S)}}}{const p=e<0?c:d,x=r[p];Re(x,`No panel constraints found for index ${p}`);const{collapsedSize:b=0,collapsible:w,minSize:E=0}=x;if(w){const _=t[p];if(Re(_!=null,`Previous layout not found for panel index ${p}`),bn(_,E)){const S=_-b;Ki(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const p=e<0?1:-1;let x=e<0?d:c,b=0;for(;;){const E=t[x];Re(E!=null,`Previous layout not found for panel index ${x}`);const S=na({panelConstraints:r,panelIndex:x,size:100})-E;if(b+=S,x+=p,x<0||x>=r.length)break}const w=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-w:w}{let x=e<0?c:d;for(;x>=0&&x=0))break;e<0?x--:x++}}if(nC(a,u))return a;{const p=e<0?d:c,x=t[p];Re(x!=null,`Previous layout not found for panel index ${p}`);const b=x+h,w=na({panelConstraints:r,panelIndex:p,size:b});if(u[p]=w,!bn(w,b)){let E=b-w,S=e<0?d:c;for(;S>=0&&S0?S--:S++}}}const m=u.reduce((p,x)=>x+p,0);return bn(m,100)?u:a}function rC({layout:e,panelsArray:t,pivotIndices:r}){let l=0,a=100,o=0,u=0;const c=r[0];Re(c!=null,"No pivot index found"),t.forEach((p,x)=>{const{constraints:b}=p,{maxSize:w=100,minSize:E=0}=b;x===c?(l=E,a=w):(o+=E,u+=w)});const d=Math.min(a,100-o),h=Math.max(l,100-u),m=e[c];return{valueMax:d,valueMin:h,valueNow:m}}function Ho(e,t=document){return Array.from(t.querySelectorAll(`[${yt.resizeHandleId}][data-panel-group-id="${e}"]`))}function Rw(e,t,r=document){const a=Ho(e,r).findIndex(o=>o.getAttribute(yt.resizeHandleId)===t);return a??null}function Ow(e,t,r){const l=Rw(e,t,r);return l!=null?[l,l+1]:[-1,-1]}function Lw(e,t=document){var r;if(t instanceof HTMLElement&&(t==null||(r=t.dataset)===null||r===void 0?void 0:r.panelGroupId)==e)return t;const l=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return l||null}function Nc(e,t=document){const r=t.querySelector(`[${yt.resizeHandleId}="${e}"]`);return r||null}function iC(e,t,r,l=document){var a,o,u,c;const d=Nc(t,l),h=Ho(e,l),m=d?h.indexOf(d):-1,p=(a=(o=r[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,x=(u=(c=r[m+1])===null||c===void 0?void 0:c.id)!==null&&u!==void 0?u:null;return[p,x]}function lC({committedValuesRef:e,eagerValuesRef:t,groupId:r,layout:l,panelDataArray:a,panelGroupElement:o,setLayout:u}){P.useRef({didWarnAboutMissingResizeHandle:!1}),Xi(()=>{if(!o)return;const c=Ho(r,o);for(let d=0;d{c.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[r,l,a,o]),P.useEffect(()=>{if(!o)return;const c=t.current;Re(c,"Eager values not found");const{panelDataArray:d}=c,h=Lw(r,o);Re(h!=null,`No group found for id "${r}"`);const m=Ho(r,o);Re(m,`No resize handles found for group id "${r}"`);const p=m.map(x=>{const b=x.getAttribute(yt.resizeHandleId);Re(b,"Resize handle element has no handle id attribute");const[w,E]=iC(r,b,d,o);if(w==null||E==null)return()=>{};const _=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const N=d.findIndex(k=>k.id===w);if(N>=0){const k=d[N];Re(k,`No panel data found for index ${N}`);const A=l[N],{collapsedSize:M=0,collapsible:j,minSize:L=0}=k.constraints;if(A!=null&&j){const R=No({delta:bn(A,M)?L-M:M-A,initialLayout:l,panelConstraints:d.map(V=>V.constraints),pivotIndices:Ow(r,b,o),prevLayout:l,trigger:"keyboard"});l!==R&&u(R)}}break}}};return x.addEventListener("keydown",_),()=>{x.removeEventListener("keydown",_)}});return()=>{p.forEach(x=>x())}},[o,e,t,r,l,a,u])}function sv(e,t){if(e.length!==t.length)return!1;for(let r=0;ro.constraints);let l=0,a=100;for(let o=0;o{const o=e[a];Re(o,`Panel data not found for index ${a}`);const{callbacks:u,constraints:c,id:d}=o,{collapsedSize:h=0,collapsible:m}=c,p=r[d];if(p==null||l!==p){r[d]=l;const{onCollapse:x,onExpand:b,onResize:w}=u;w&&w(l,p),m&&(x||b)&&(b&&(p==null||Ar(p,h))&&!Ar(l,h)&&b(),x&&(p==null||!Ar(p,h))&&Ar(l,h)&&x())}})}function Ou(e,t){if(e.length!==t.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{e(...a)},t)}}function uv(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,r)=>{localStorage.setItem(t,r)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Bw(e){return`react-resizable-panels:${e}`}function Iw(e){return e.map(t=>{const{constraints:r,id:l,idIsFromProps:a,order:o}=t;return a?l:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((t,r)=>t.localeCompare(r)).join(",")}function qw(e,t){try{const r=Bw(e),l=t.getItem(r);if(l){const a=JSON.parse(l);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function fC(e,t,r){var l,a;const o=(l=qw(e,r))!==null&&l!==void 0?l:{},u=Iw(t);return(a=o[u])!==null&&a!==void 0?a:null}function dC(e,t,r,l,a){var o;const u=Bw(e),c=Iw(t),d=(o=qw(e,a))!==null&&o!==void 0?o:{};d[c]={expandToSizes:Object.fromEntries(r.entries()),layout:l};try{a.setItem(u,JSON.stringify(d))}catch(h){console.error(h)}}function cv({layout:e,panelConstraints:t}){const r=[...e],l=r.reduce((o,u)=>o+u,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!bn(l,100)&&r.length>0)for(let o=0;o(uv(Co),Co.getItem(e)),setItem:(e,t)=>{uv(Co),Co.setItem(e,t)}},fv={};function Uw({autoSaveId:e=null,children:t,className:r="",direction:l,forwardedRef:a,id:o=null,onLayout:u=null,keyboardResizeBy:c=null,storage:d=Co,style:h,tagName:m="div",...p}){const x=vm(o),b=P.useRef(null),[w,E]=P.useState(null),[_,S]=P.useState([]),N=tC(),k=P.useRef({}),A=P.useRef(new Map),M=P.useRef(0),j=P.useRef({autoSaveId:e,direction:l,dragState:w,id:x,keyboardResizeBy:c,onLayout:u,storage:d}),L=P.useRef({layout:_,panelDataArray:[],panelDataArrayChanged:!1});P.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),P.useImperativeHandle(a,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:C}=L.current;return C},setLayout:C=>{const{onLayout:$}=j.current,{layout:X,panelDataArray:J}=L.current,ne=cv({layout:C,panelConstraints:J.map(re=>re.constraints)});sv(X,ne)||(S(ne),L.current.layout=ne,$&&$(ne),Ql(J,ne,k.current))}}),[]),Xi(()=>{j.current.autoSaveId=e,j.current.direction=l,j.current.dragState=w,j.current.id=x,j.current.onLayout=u,j.current.storage=d}),lC({committedValuesRef:j,eagerValuesRef:L,groupId:x,layout:_,panelDataArray:L.current.panelDataArray,setLayout:S,panelGroupElement:b.current}),P.useEffect(()=>{const{panelDataArray:C}=L.current;if(e){if(_.length===0||_.length!==C.length)return;let $=fv[e];$==null&&($=cC(dC,hC),fv[e]=$);const X=[...C],J=new Map(A.current);$(e,X,J,_,d)}},[e,_,d]),P.useEffect(()=>{});const R=P.useCallback(C=>{const{onLayout:$}=j.current,{layout:X,panelDataArray:J}=L.current;if(C.constraints.collapsible){const ne=J.map(be=>be.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:xe}=Ui(J,C,X);if(Re(se!=null,`Panel size not found for panel "${C.id}"`),!Ar(se,re)){A.current.set(C.id,se);const ye=Wl(J,C)===J.length-1?se-re:re-se,pe=No({delta:ye,initialLayout:X,panelConstraints:ne,pivotIndices:xe,prevLayout:X,trigger:"imperative-api"});Ou(X,pe)||(S(pe),L.current.layout=pe,$&&$(pe),Ql(J,pe,k.current))}}},[]),V=P.useCallback((C,$)=>{const{onLayout:X}=j.current,{layout:J,panelDataArray:ne}=L.current;if(C.constraints.collapsible){const re=ne.map(_e=>_e.constraints),{collapsedSize:se=0,panelSize:xe=0,minSize:be=0,pivotIndices:ye}=Ui(ne,C,J),pe=$??be;if(Ar(xe,se)){const _e=A.current.get(C.id),ze=_e!=null&&_e>=pe?_e:pe,ut=Wl(ne,C)===ne.length-1?xe-ze:ze-xe,nt=No({delta:ut,initialLayout:J,panelConstraints:re,pivotIndices:ye,prevLayout:J,trigger:"imperative-api"});Ou(J,nt)||(S(nt),L.current.layout=nt,X&&X(nt),Ql(ne,nt,k.current))}}},[]),H=P.useCallback(C=>{const{layout:$,panelDataArray:X}=L.current,{panelSize:J}=Ui(X,C,$);return Re(J!=null,`Panel size not found for panel "${C.id}"`),J},[]),B=P.useCallback((C,$)=>{const{panelDataArray:X}=L.current,J=Wl(X,C);return uC({defaultSize:$,dragState:w,layout:_,panelData:X,panelIndex:J})},[w,_]),U=P.useCallback(C=>{const{layout:$,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,C,$);return Re(re!=null,`Panel size not found for panel "${C.id}"`),ne===!0&&Ar(re,J)},[]),ee=P.useCallback(C=>{const{layout:$,panelDataArray:X}=L.current,{collapsedSize:J=0,collapsible:ne,panelSize:re}=Ui(X,C,$);return Re(re!=null,`Panel size not found for panel "${C.id}"`),!ne||Ki(re,J)>0},[]),I=P.useCallback(C=>{const{panelDataArray:$}=L.current;$.push(C),$.sort((X,J)=>{const ne=X.order,re=J.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),L.current.panelDataArrayChanged=!0,N()},[N]);Xi(()=>{if(L.current.panelDataArrayChanged){L.current.panelDataArrayChanged=!1;const{autoSaveId:C,onLayout:$,storage:X}=j.current,{layout:J,panelDataArray:ne}=L.current;let re=null;if(C){const xe=fC(C,ne,X);xe&&(A.current=new Map(Object.entries(xe.expandToSizes)),re=xe.layout)}re==null&&(re=sC({panelDataArray:ne}));const se=cv({layout:re,panelConstraints:ne.map(xe=>xe.constraints)});sv(J,se)||(S(se),L.current.layout=se,$&&$(se),Ql(ne,se,k.current))}}),Xi(()=>{const C=L.current;return()=>{C.layout=[]}},[]);const F=P.useCallback(C=>{let $=!1;const X=b.current;return X&&window.getComputedStyle(X,null).getPropertyValue("direction")==="rtl"&&($=!0),function(ne){ne.preventDefault();const re=b.current;if(!re)return()=>null;const{direction:se,dragState:xe,id:be,keyboardResizeBy:ye,onLayout:pe}=j.current,{layout:_e,panelDataArray:ze}=L.current,{initialLayout:Te}=xe??{},ut=Ow(be,C,re);let nt=oC(ne,C,se,xe,ye,re);const zt=se==="horizontal";zt&&$&&(nt=-nt);const Pt=ze.map(Rn=>Rn.constraints),Ht=No({delta:nt,initialLayout:Te??_e,panelConstraints:Pt,pivotIndices:ut,prevLayout:_e,trigger:Ew(ne)?"keyboard":"mouse-or-touch"}),kn=!Ou(_e,Ht);(Nw(ne)||Cw(ne))&&M.current!=nt&&(M.current=nt,!kn&&nt!==0?zt?ph(C,nt<0?jw:Aw):ph(C,nt<0?zw:Mw):ph(C,0)),kn&&(S(Ht),L.current.layout=Ht,pe&&pe(Ht),Ql(ze,Ht,k.current))}},[]),z=P.useCallback((C,$)=>{const{onLayout:X}=j.current,{layout:J,panelDataArray:ne}=L.current,re=ne.map(_e=>_e.constraints),{panelSize:se,pivotIndices:xe}=Ui(ne,C,J);Re(se!=null,`Panel size not found for panel "${C.id}"`);const ye=Wl(ne,C)===ne.length-1?se-$:$-se,pe=No({delta:ye,initialLayout:J,panelConstraints:re,pivotIndices:xe,prevLayout:J,trigger:"imperative-api"});Ou(J,pe)||(S(pe),L.current.layout=pe,X&&X(pe),Ql(ne,pe,k.current))},[]),G=P.useCallback((C,$)=>{const{layout:X,panelDataArray:J}=L.current,{collapsedSize:ne=0,collapsible:re}=$,{collapsedSize:se=0,collapsible:xe,maxSize:be=100,minSize:ye=0}=C.constraints,{panelSize:pe}=Ui(J,C,X);pe!=null&&(re&&xe&&Ar(pe,ne)?Ar(ne,se)||z(C,se):pebe&&z(C,be))},[z]),Q=P.useCallback((C,$)=>{const{direction:X}=j.current,{layout:J}=L.current;if(!b.current)return;const ne=Nc(C,b.current);Re(ne,`Drag handle element not found for id "${C}"`);const re=Hw(X,$);E({dragHandleId:C,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:J})},[]),K=P.useCallback(()=>{E(null)},[]),D=P.useCallback(C=>{const{panelDataArray:$}=L.current,X=Wl($,C);X>=0&&($.splice(X,1),delete k.current[C.id],L.current.panelDataArrayChanged=!0,N())},[N]),q=P.useMemo(()=>({collapsePanel:R,direction:l,dragState:w,expandPanel:V,getPanelSize:H,getPanelStyle:B,groupId:x,isPanelCollapsed:U,isPanelExpanded:ee,reevaluatePanelConstraints:G,registerPanel:I,registerResizeHandle:F,resizePanel:z,startDragging:Q,stopDragging:K,unregisterPanel:D,panelGroupElement:b.current}),[R,w,l,V,H,B,x,U,ee,G,I,F,z,Q,K,D]),Y={display:"flex",flexDirection:l==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return P.createElement(_c.Provider,{value:q},P.createElement(m,{...p,children:t,className:r,id:o,ref:b,style:{...Y,...h},[yt.group]:"",[yt.groupDirection]:l,[yt.groupId]:x}))}const Vp=P.forwardRef((e,t)=>P.createElement(Uw,{...e,forwardedRef:t}));Uw.displayName="PanelGroup";Vp.displayName="forwardRef(PanelGroup)";function Wl(e,t){return e.findIndex(r=>r===t||r.id===t.id)}function Ui(e,t,r){const l=Wl(e,t),o=l===e.length-1?[l-1,l]:[l,l+1],u=r[l];return{...t.constraints,panelSize:u,pivotIndices:o}}function pC({disabled:e,handleId:t,resizeHandler:r,panelGroupElement:l}){P.useEffect(()=>{if(e||r==null||l==null)return;const a=Nc(t,l);if(a==null)return;const o=u=>{if(!u.defaultPrevented)switch(u.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{u.preventDefault(),r(u);break}case"F6":{u.preventDefault();const c=a.getAttribute(yt.groupId);Re(c,`No group element found for id "${c}"`);const d=Ho(c,l),h=Rw(c,t,l);Re(h!==null,`No resize element found for id "${t}"`);const m=u.shiftKey?h>0?h-1:d.length-1:h+1{a.removeEventListener("keydown",o)}},[l,e,t,r])}function Pp({children:e=null,className:t="",disabled:r=!1,hitAreaMargins:l,id:a,onBlur:o,onClick:u,onDragging:c,onFocus:d,onPointerDown:h,onPointerUp:m,style:p={},tabIndex:x=0,tagName:b="div",...w}){var E,_;const S=P.useRef(null),N=P.useRef({onClick:u,onDragging:c,onPointerDown:h,onPointerUp:m});P.useEffect(()=>{N.current.onClick=u,N.current.onDragging=c,N.current.onPointerDown=h,N.current.onPointerUp=m});const k=P.useContext(_c);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:A,groupId:M,registerResizeHandle:j,startDragging:L,stopDragging:R,panelGroupElement:V}=k,H=vm(a),[B,U]=P.useState("inactive"),[ee,I]=P.useState(!1),[F,z]=P.useState(null),G=P.useRef({state:B});Xi(()=>{G.current.state=B}),P.useEffect(()=>{if(r)z(null);else{const q=j(H);z(()=>q)}},[r,H,j]);const Q=(E=l==null?void 0:l.coarse)!==null&&E!==void 0?E:15,K=(_=l==null?void 0:l.fine)!==null&&_!==void 0?_:5;P.useEffect(()=>{if(r||F==null)return;const q=S.current;Re(q,"Element ref not attached");let Y=!1;return WN(H,q,A,{coarse:Q,fine:K},($,X,J)=>{if(!X){U("inactive");return}switch($){case"down":{U("drag"),Y=!1,Re(J,'Expected event to be defined for "down" action'),L(H,J);const{onDragging:ne,onPointerDown:re}=N.current;ne==null||ne(!0),re==null||re();break}case"move":{const{state:ne}=G.current;Y=!0,ne!=="drag"&&U("hover"),Re(J,'Expected event to be defined for "move" action'),F(J);break}case"up":{U("hover"),R();const{onClick:ne,onDragging:re,onPointerUp:se}=N.current;re==null||re(!1),se==null||se(),Y||ne==null||ne();break}}})},[Q,A,r,K,j,H,F,L,R]),pC({disabled:r,handleId:H,resizeHandler:F,panelGroupElement:V});const D={touchAction:"none",userSelect:"none"};return P.createElement(b,{...w,children:e,className:t,id:a,onBlur:()=>{I(!1),o==null||o()},onFocus:()=>{I(!0),d==null||d()},ref:S,role:"separator",style:{...D,...p},tabIndex:x,[yt.groupDirection]:A,[yt.groupId]:M,[yt.resizeHandle]:"",[yt.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[yt.resizeHandleEnabled]:!r,[yt.resizeHandleId]:H,[yt.resizeHandleState]:B})}Pp.displayName="PanelResizeHandle";function At(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let r=0,l;r{}};function Cc(){for(var e=0,t=arguments.length,r={},l;e=0&&(l=r.slice(a+1),r=r.slice(0,a)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:l}})}Ku.prototype=Cc.prototype={constructor:Ku,on:function(e,t){var r=this._,l=gC(e+"",r),a,o=-1,u=l.length;if(arguments.length<2){for(;++o0)for(var r=new Array(a),l=0,a,o;l=0&&(t=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),hv.hasOwnProperty(t)?{space:hv[t],local:e}:e}function yC(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===$p&&t.documentElement.namespaceURI===$p?t.createElement(e):t.createElementNS(r,e)}}function vC(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Vw(e){var t=Tc(e);return(t.local?vC:yC)(t)}function bC(){}function Sm(e){return e==null?bC:function(){return this.querySelector(e)}}function wC(e){typeof e!="function"&&(e=Sm(e));for(var t=this._groups,r=t.length,l=new Array(r),a=0;a=k&&(k=N+1);!(M=_[k])&&++k=0;)(u=l[a])&&(o&&u.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(u,o),o=u);return this}function FC(e){e||(e=YC);function t(p,x){return p&&x?e(p.__data__,x.__data__):!p-!x}for(var r=this._groups,l=r.length,a=new Array(l),o=0;ot?1:e>=t?0:NaN}function XC(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function QC(){return Array.from(this)}function ZC(){for(var e=this._groups,t=0,r=e.length;t1?this.each((t==null?o3:typeof t=="function"?u3:s3)(e,t,r??"")):fa(this.node(),e)}function fa(e,t){return e.style.getPropertyValue(t)||Yw(e).getComputedStyle(e,null).getPropertyValue(t)}function f3(e){return function(){delete this[e]}}function d3(e,t){return function(){this[e]=t}}function h3(e,t){return function(){var r=t.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function p3(e,t){return arguments.length>1?this.each((t==null?f3:typeof t=="function"?h3:d3)(e,t)):this.node()[e]}function Xw(e){return e.trim().split(/^|\s+/)}function _m(e){return e.classList||new Qw(e)}function Qw(e){this._node=e,this._names=Xw(e.getAttribute("class")||"")}Qw.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Zw(e,t){for(var r=_m(e),l=-1,a=t.length;++l=0&&(r=t.slice(l+1),t=t.slice(0,l)),{type:t,name:r}})}function V3(e){return function(){var t=this.__on;if(t){for(var r=0,l=-1,a=t.length,o;r()=>e;function Gp(e,{sourceEvent:t,subject:r,target:l,identifier:a,active:o,x:u,y:c,dx:d,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}Gp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function J3(e){return!e.ctrlKey&&!e.button}function W3(){return this.parentNode}function eT(e,t){return t??{x:e.x,y:e.y}}function tT(){return navigator.maxTouchPoints||"ontouchstart"in this}function nS(){var e=J3,t=W3,r=eT,l=tT,a={},o=Cc("start","drag","end"),u=0,c,d,h,m,p=0;function x(A){A.on("mousedown.drag",b).filter(l).on("touchstart.drag",_).on("touchmove.drag",S,K3).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function b(A,M){if(!(m||!e.call(this,A,M))){var j=k(this,t.call(this,A,M),A,M,"mouse");j&&(wn(A.view).on("mousemove.drag",w,Bo).on("mouseup.drag",E,Bo),eS(A.view),gh(A),h=!1,c=A.clientX,d=A.clientY,j("start",A))}}function w(A){if(oa(A),!h){var M=A.clientX-c,j=A.clientY-d;h=M*M+j*j>p}a.mouse("drag",A)}function E(A){wn(A.view).on("mousemove.drag mouseup.drag",null),tS(A.view,h),oa(A),a.mouse("end",A)}function _(A,M){if(e.call(this,A,M)){var j=A.changedTouches,L=t.call(this,A,M),R=j.length,V,H;for(V=0;V>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Hu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Hu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=rT.exec(e))?new un(t[1],t[2],t[3],1):(t=iT.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lT.exec(e))?Hu(t[1],t[2],t[3],t[4]):(t=aT.exec(e))?Hu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=oT.exec(e))?bv(t[1],t[2]/100,t[3]/100,1):(t=sT.exec(e))?bv(t[1],t[2]/100,t[3]/100,t[4]):pv.hasOwnProperty(e)?xv(pv[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function xv(e){return new un(e>>16&255,e>>8&255,e&255,1)}function Hu(e,t,r,l){return l<=0&&(e=t=r=NaN),new un(e,t,r,l)}function fT(e){return e instanceof Jo||(e=Ji(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function Fp(e,t,r,l){return arguments.length===1?fT(e):new un(e,t,r,l??1)}function un(e,t,r,l){this.r=+e,this.g=+t,this.b=+r,this.opacity=+l}km(un,Fp,rS(Jo,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Qi(this.r),Qi(this.g),Qi(this.b),sc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:yv,formatHex:yv,formatHex8:dT,formatRgb:vv,toString:vv}));function yv(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}`}function dT(){return`#${Fi(this.r)}${Fi(this.g)}${Fi(this.b)}${Fi((isNaN(this.opacity)?1:this.opacity)*255)}`}function vv(){const e=sc(this.opacity);return`${e===1?"rgb(":"rgba("}${Qi(this.r)}, ${Qi(this.g)}, ${Qi(this.b)}${e===1?")":`, ${e})`}`}function sc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Fi(e){return e=Qi(e),(e<16?"0":"")+e.toString(16)}function bv(e,t,r,l){return l<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Un(e,t,r,l)}function iS(e){if(e instanceof Un)return new Un(e.h,e.s,e.l,e.opacity);if(e instanceof Jo||(e=Ji(e)),!e)return new Un;if(e instanceof Un)return e;e=e.rgb();var t=e.r/255,r=e.g/255,l=e.b/255,a=Math.min(t,r,l),o=Math.max(t,r,l),u=NaN,c=o-a,d=(o+a)/2;return c?(t===o?u=(r-l)/c+(r0&&d<1?0:u,new Un(u,c,d,e.opacity)}function hT(e,t,r,l){return arguments.length===1?iS(e):new Un(e,t,r,l??1)}function Un(e,t,r,l){this.h=+e,this.s=+t,this.l=+r,this.opacity=+l}km(Un,hT,rS(Jo,{brighter(e){return e=e==null?oc:Math.pow(oc,e),new Un(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Io:Math.pow(Io,e),new Un(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,l=r+(r<.5?r:1-r)*t,a=2*r-l;return new un(xh(e>=240?e-240:e+120,a,l),xh(e,a,l),xh(e<120?e+240:e-120,a,l),this.opacity)},clamp(){return new Un(wv(this.h),Bu(this.s),Bu(this.l),sc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=sc(this.opacity);return`${e===1?"hsl(":"hsla("}${wv(this.h)}, ${Bu(this.s)*100}%, ${Bu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function wv(e){return e=(e||0)%360,e<0?e+360:e}function Bu(e){return Math.max(0,Math.min(1,e||0))}function xh(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const Em=e=>()=>e;function pT(e,t){return function(r){return e+r*t}}function mT(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(l){return Math.pow(e+l*t,r)}}function gT(e){return(e=+e)==1?lS:function(t,r){return r-t?mT(t,r,e):Em(isNaN(t)?r:t)}}function lS(e,t){var r=t-e;return r?pT(e,r):Em(isNaN(e)?t:e)}const uc=(function e(t){var r=gT(t);function l(a,o){var u=r((a=Fp(a)).r,(o=Fp(o)).r),c=r(a.g,o.g),d=r(a.b,o.b),h=lS(a.opacity,o.opacity);return function(m){return a.r=u(m),a.g=c(m),a.b=d(m),a.opacity=h(m),a+""}}return l.gamma=e,l})(1);function xT(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,l=t.slice(),a;return function(o){for(a=0;ar&&(o=t.slice(r,o),c[u]?c[u]+=o:c[++u]=o),(l=l[0])===(a=a[0])?c[u]?c[u]+=a:c[++u]=a:(c[++u]=null,d.push({i:u,x:rr(l,a)})),r=yh.lastIndex;return r180?m+=360:m-h>180&&(h+=360),x.push({i:p.push(a(p)+"rotate(",null,l)-2,x:rr(h,m)})):m&&p.push(a(p)+"rotate("+m+l)}function c(h,m,p,x){h!==m?x.push({i:p.push(a(p)+"skewX(",null,l)-2,x:rr(h,m)}):m&&p.push(a(p)+"skewX("+m+l)}function d(h,m,p,x,b,w){if(h!==p||m!==x){var E=b.push(a(b)+"scale(",null,",",null,")");w.push({i:E-4,x:rr(h,p)},{i:E-2,x:rr(m,x)})}else(p!==1||x!==1)&&b.push(a(b)+"scale("+p+","+x+")")}return function(h,m){var p=[],x=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,p,x),u(h.rotate,m.rotate,p,x),c(h.skewX,m.skewX,p,x),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,p,x),h=m=null,function(b){for(var w=-1,E=x.length,_;++w=0&&e._call.call(void 0,t),e=e._next;--da}function kv(){Wi=(fc=Uo.now())+jc,da=To=0;try{MT()}finally{da=0,RT(),Wi=0}}function DT(){var e=Uo.now(),t=e-fc;t>uS&&(jc-=t,fc=e)}function RT(){for(var e,t=cc,r,l=1/0;t;)t._call?(l>t._time&&(l=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:cc=r);jo=e,Qp(l)}function Qp(e){if(!da){To&&(To=clearTimeout(To));var t=e-Wi;t>24?(e<1/0&&(To=setTimeout(kv,e-Uo.now()-jc)),vo&&(vo=clearInterval(vo))):(vo||(fc=Uo.now(),vo=setInterval(DT,uS)),da=1,cS(kv))}}function Ev(e,t,r){var l=new dc;return t=t==null?0:+t,l.restart(a=>{l.stop(),e(a+t)},t,r),l}var OT=Cc("start","end","cancel","interrupt"),LT=[],dS=0,Nv=1,Zp=2,Wu=3,Cv=4,Kp=5,ec=6;function Ac(e,t,r,l,a,o){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;HT(e,r,{name:t,index:l,group:a,on:OT,tween:LT,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:dS})}function Cm(e,t){var r=Xn(e,t);if(r.state>dS)throw new Error("too late; already scheduled");return r}function ar(e,t){var r=Xn(e,t);if(r.state>Wu)throw new Error("too late; already running");return r}function Xn(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw new Error("transition not found");return r}function HT(e,t,r){var l=e.__transition,a;l[t]=r,r.timer=fS(o,0,r.time);function o(h){r.state=Nv,r.timer.restart(u,r.delay,r.time),r.delay<=h&&u(h-r.delay)}function u(h){var m,p,x,b;if(r.state!==Nv)return d();for(m in l)if(b=l[m],b.name===r.name){if(b.state===Wu)return Ev(u);b.state===Cv?(b.state=ec,b.timer.stop(),b.on.call("interrupt",e,e.__data__,b.index,b.group),delete l[m]):+mZp&&l.state=0&&(t=t.slice(0,r)),!t||t==="start"})}function hj(e,t,r){var l,a,o=dj(t)?Cm:ar;return function(){var u=o(this,e),c=u.on;c!==l&&(a=(l=c).copy()).on(t,r),u.on=a}}function pj(e,t){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(hj(r,e,t))}function mj(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;t&&t.removeChild(this)}}function gj(){return this.on("end.remove",mj(this._id))}function xj(e){var t=this._name,r=this._id;typeof e!="function"&&(e=Sm(e));for(var l=this._groups,a=l.length,o=new Array(a),u=0;u()=>e;function Vj(e,{sourceEvent:t,target:r,transform:l,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:a}})}function zr(e,t,r){this.k=e,this.x=t,this.y=r}zr.prototype={constructor:zr,scale:function(e){return e===1?this:new zr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new zr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var zc=new zr(1,0,0);gS.prototype=zr.prototype;function gS(e){for(;!e.__zoom;)if(!(e=e.parentNode))return zc;return e.__zoom}function vh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function Pj(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function $j(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Tv(){return this.__zoom||zc}function Gj(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Fj(){return navigator.maxTouchPoints||"ontouchstart"in this}function Yj(e,t,r){var l=e.invertX(t[0][0])-r[0][0],a=e.invertX(t[1][0])-r[1][0],o=e.invertY(t[0][1])-r[0][1],u=e.invertY(t[1][1])-r[1][1];return e.translate(a>l?(l+a)/2:Math.min(0,l)||Math.max(0,a),u>o?(o+u)/2:Math.min(0,o)||Math.max(0,u))}function xS(){var e=Pj,t=$j,r=Yj,l=Gj,a=Fj,o=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,d=Ju,h=Cc("start","zoom","end"),m,p,x,b=500,w=150,E=0,_=10;function S(I){I.property("__zoom",Tv).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",H).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(I,F,z,G){var Q=I.selection?I.selection():I;Q.property("__zoom",Tv),I!==Q?M(I,F,z,G):Q.interrupt().each(function(){j(this,arguments).event(G).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},S.scaleBy=function(I,F,z,G){S.scaleTo(I,function(){var Q=this.__zoom.k,K=typeof F=="function"?F.apply(this,arguments):F;return Q*K},z,G)},S.scaleTo=function(I,F,z,G){S.transform(I,function(){var Q=t.apply(this,arguments),K=this.__zoom,D=z==null?A(Q):typeof z=="function"?z.apply(this,arguments):z,q=K.invert(D),Y=typeof F=="function"?F.apply(this,arguments):F;return r(k(N(K,Y),D,q),Q,u)},z,G)},S.translateBy=function(I,F,z,G){S.transform(I,function(){return r(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),u)},null,G)},S.translateTo=function(I,F,z,G,Q){S.transform(I,function(){var K=t.apply(this,arguments),D=this.__zoom,q=G==null?A(K):typeof G=="function"?G.apply(this,arguments):G;return r(zc.translate(q[0],q[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof z=="function"?-z.apply(this,arguments):-z),K,u)},G,Q)};function N(I,F){return F=Math.max(o[0],Math.min(o[1],F)),F===I.k?I:new zr(F,I.x,I.y)}function k(I,F,z){var G=F[0]-z[0]*I.k,Q=F[1]-z[1]*I.k;return G===I.x&&Q===I.y?I:new zr(I.k,G,Q)}function A(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function M(I,F,z,G){I.on("start.zoom",function(){j(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(G).end()}).tween("zoom",function(){var Q=this,K=arguments,D=j(Q,K).event(G),q=t.apply(Q,K),Y=z==null?A(q):typeof z=="function"?z.apply(Q,K):z,C=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),$=Q.__zoom,X=typeof F=="function"?F.apply(Q,K):F,J=d($.invert(Y).concat(C/$.k),X.invert(Y).concat(C/X.k));return function(ne){if(ne===1)ne=X;else{var re=J(ne),se=C/re[2];ne=new zr(se,Y[0]-re[0]*se,Y[1]-re[1]*se)}D.zoom(null,ne)}})}function j(I,F,z){return!z&&I.__zooming||new L(I,F)}function L(I,F){this.that=I,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,F),this.taps=0}L.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,F){return this.mouse&&I!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var F=wn(this.that).datum();h.call(I,this.that,new Vj(I,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:h}),F)}};function R(I,...F){if(!e.apply(this,arguments))return;var z=j(this,F).event(I),G=this.__zoom,Q=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,l.apply(this,arguments)))),K=qn(I);if(z.wheel)(z.mouse[0][0]!==K[0]||z.mouse[0][1]!==K[1])&&(z.mouse[1]=G.invert(z.mouse[0]=K)),clearTimeout(z.wheel);else{if(G.k===Q)return;z.mouse=[K,G.invert(K)],tc(this),z.start()}bo(I),z.wheel=setTimeout(D,w),z.zoom("mouse",r(k(N(G,Q),z.mouse[0],z.mouse[1]),z.extent,u));function D(){z.wheel=null,z.end()}}function V(I,...F){if(x||!e.apply(this,arguments))return;var z=I.currentTarget,G=j(this,F,!0).event(I),Q=wn(I.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",C,!0),K=qn(I,z),D=I.clientX,q=I.clientY;eS(I.view),vh(I),G.mouse=[K,this.__zoom.invert(K)],tc(this),G.start();function Y($){if(bo($),!G.moved){var X=$.clientX-D,J=$.clientY-q;G.moved=X*X+J*J>E}G.event($).zoom("mouse",r(k(G.that.__zoom,G.mouse[0]=qn($,z),G.mouse[1]),G.extent,u))}function C($){Q.on("mousemove.zoom mouseup.zoom",null),tS($.view,G.moved),bo($),G.event($).end()}}function H(I,...F){if(e.apply(this,arguments)){var z=this.__zoom,G=qn(I.changedTouches?I.changedTouches[0]:I,this),Q=z.invert(G),K=z.k*(I.shiftKey?.5:2),D=r(k(N(z,K),G,Q),t.apply(this,F),u);bo(I),c>0?wn(this).transition().duration(c).call(M,D,G,I):wn(this).call(S.transform,D,G,I)}}function B(I,...F){if(e.apply(this,arguments)){var z=I.touches,G=z.length,Q=j(this,F,I.changedTouches.length===G).event(I),K,D,q,Y;for(vh(I),D=0;D"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:r,targetHandle:l})=>`Couldn't create edge for ${e} handle id: "${e==="source"?r:l}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Vo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],yS=["Enter"," ","Escape"],vS={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:r})=>`Moved selected node ${e}. New position, x: ${t}, y: ${r}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var ha;(function(e){e.Strict="strict",e.Loose="loose"})(ha||(ha={}));var Zi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zi||(Zi={}));var Po;(function(e){e.Partial="partial",e.Full="full"})(Po||(Po={}));const bS={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var xi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(xi||(xi={}));var hc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(hc||(hc={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const jv={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function wS(e){return e===null?null:e?"valid":"invalid"}const SS=e=>"id"in e&&"source"in e&&"target"in e,Xj=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),jm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wo=(e,t=[0,0])=>{const{width:r,height:l}=Or(e),a=e.origin??t,o=r*a[0],u=l*a[1];return{x:e.position.x-o,y:e.position.y-u}},Qj=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((l,a)=>{const o=typeof a=="string";let u=!t.nodeLookup&&!o?a:void 0;t.nodeLookup&&(u=o?t.nodeLookup.get(a):jm(a)?a:t.nodeLookup.get(a.id));const c=u?pc(u,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Mc(l,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Dc(r)},es=(e,t={})=>{let r={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return e.forEach(a=>{(t.filter===void 0||t.filter(a))&&(r=Mc(r,pc(a)),l=!0)}),l?Dc(r):{x:0,y:0,width:0,height:0}},Am=(e,t,[r,l,a]=[0,0,1],o=!1,u=!1)=>{const c={...ns(t,[r,l,a]),width:t.width/a,height:t.height/a},d=[];for(const h of e.values()){const{measured:m,selectable:p=!0,hidden:x=!1}=h;if(u&&!p||x)continue;const b=m.width??h.width??h.initialWidth??null,w=m.height??h.height??h.initialHeight??null,E=$o(c,ma(h)),_=(b??0)*(w??0),S=o&&E>0;(!h.internals.handleBounds||S||E>=_||h.dragging)&&d.push(h)}return d},Zj=(e,t)=>{const r=new Set;return e.forEach(l=>{r.add(l.id)}),t.filter(l=>r.has(l.source)||r.has(l.target))};function Kj(e,t){const r=new Map,l=t!=null&&t.nodes?new Set(t.nodes.map(a=>a.id)):null;return e.forEach(a=>{a.measured.width&&a.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!a.hidden)&&(!l||l.has(a.id))&&r.set(a.id,a)}),r}async function Jj({nodes:e,width:t,height:r,panZoom:l,minZoom:a,maxZoom:o},u){if(e.size===0)return Promise.resolve(!0);const c=Kj(e,u),d=es(c),h=zm(d,t,r,(u==null?void 0:u.minZoom)??a,(u==null?void 0:u.maxZoom)??o,(u==null?void 0:u.padding)??.1);return await l.setViewport(h,{duration:u==null?void 0:u.duration,ease:u==null?void 0:u.ease,interpolate:u==null?void 0:u.interpolate}),Promise.resolve(!0)}function _S({nodeId:e,nextPosition:t,nodeLookup:r,nodeOrigin:l=[0,0],nodeExtent:a,onError:o}){const u=r.get(e),c=u.parentId?r.get(u.parentId):void 0,{x:d,y:h}=c?c.internals.positionAbsolute:{x:0,y:0},m=u.origin??l;let p=u.extent||a;if(u.extent==="parent"&&!u.expandParent)if(!c)o==null||o("005",lr.error005());else{const b=c.measured.width,w=c.measured.height;b&&w&&(p=[[d,h],[d+b,h+w]])}else c&&ga(u.extent)&&(p=[[u.extent[0][0]+d,u.extent[0][1]+h],[u.extent[1][0]+d,u.extent[1][1]+h]]);const x=ga(p)?el(t,p,u.measured):t;return(u.measured.width===void 0||u.measured.height===void 0)&&(o==null||o("015",lr.error015())),{position:{x:x.x-d+(u.measured.width??0)*m[0],y:x.y-h+(u.measured.height??0)*m[1]},positionAbsolute:x}}async function Wj({nodesToRemove:e=[],edgesToRemove:t=[],nodes:r,edges:l,onBeforeDelete:a}){const o=new Set(e.map(x=>x.id)),u=[];for(const x of r){if(x.deletable===!1)continue;const b=o.has(x.id),w=!b&&x.parentId&&u.find(E=>E.id===x.parentId);(b||w)&&u.push(x)}const c=new Set(t.map(x=>x.id)),d=l.filter(x=>x.deletable!==!1),m=Zj(u,d);for(const x of d)c.has(x.id)&&!m.find(w=>w.id===x.id)&&m.push(x);if(!a)return{edges:m,nodes:u};const p=await a({nodes:u,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:u}:{edges:[],nodes:[]}:p}const pa=(e,t=0,r=1)=>Math.min(Math.max(e,t),r),el=(e={x:0,y:0},t,r)=>({x:pa(e.x,t[0][0],t[1][0]-((r==null?void 0:r.width)??0)),y:pa(e.y,t[0][1],t[1][1]-((r==null?void 0:r.height)??0))});function kS(e,t,r){const{width:l,height:a}=Or(r),{x:o,y:u}=r.internals.positionAbsolute;return el(e,[[o,u],[o+l,u+a]],t)}const Av=(e,t,r)=>er?-pa(Math.abs(e-r),1,t)/t:0,ES=(e,t,r=15,l=40)=>{const a=Av(e.x,l,t.width-l)*r,o=Av(e.y,l,t.height-l)*r;return[a,o]},Mc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Jp=({x:e,y:t,width:r,height:l})=>({x:e,y:t,x2:e+r,y2:t+l}),Dc=({x:e,y:t,x2:r,y2:l})=>({x:e,y:t,width:r-e,height:l-t}),ma=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=jm(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},pc=(e,t=[0,0])=>{var a,o;const{x:r,y:l}=jm(e)?e.internals.positionAbsolute:Wo(e,t);return{x:r,y:l,x2:r+(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0),y2:l+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},NS=(e,t)=>Dc(Mc(Jp(e),Jp(t))),$o=(e,t)=>{const r=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),l=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(r*l)},zv=e=>Vn(e.width)&&Vn(e.height)&&Vn(e.x)&&Vn(e.y),Vn=e=>!isNaN(e)&&isFinite(e),eA=(e,t)=>{},ts=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ns=({x:e,y:t},[r,l,a],o=!1,u=[1,1])=>{const c={x:(e-r)/a,y:(t-l)/a};return o?ts(c,u):c},mc=({x:e,y:t},[r,l,a])=>({x:e*a+r,y:t*a+l});function Zl(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(r)}if(typeof e=="string"&&e.endsWith("%")){const r=parseFloat(e);if(!Number.isNaN(r))return Math.floor(t*r*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function tA(e,t,r){if(typeof e=="string"||typeof e=="number"){const l=Zl(e,r),a=Zl(e,t);return{top:l,right:a,bottom:l,left:a,x:a*2,y:l*2}}if(typeof e=="object"){const l=Zl(e.top??e.y??0,r),a=Zl(e.bottom??e.y??0,r),o=Zl(e.left??e.x??0,t),u=Zl(e.right??e.x??0,t);return{top:l,right:u,bottom:a,left:o,x:o+u,y:l+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function nA(e,t,r,l,a,o){const{x:u,y:c}=mc(e,[t,r,l]),{x:d,y:h}=mc({x:e.x+e.width,y:e.y+e.height},[t,r,l]),m=a-d,p=o-h;return{left:Math.floor(u),top:Math.floor(c),right:Math.floor(m),bottom:Math.floor(p)}}const zm=(e,t,r,l,a,o)=>{const u=tA(o,t,r),c=(t-u.x)/e.width,d=(r-u.y)/e.height,h=Math.min(c,d),m=pa(h,l,a),p=e.x+e.width/2,x=e.y+e.height/2,b=t/2-p*m,w=r/2-x*m,E=nA(e,b,w,m,t,r),_={left:Math.min(E.left-u.left,0),top:Math.min(E.top-u.top,0),right:Math.min(E.right-u.right,0),bottom:Math.min(E.bottom-u.bottom,0)};return{x:b-_.left+_.right,y:w-_.top+_.bottom,zoom:m}},Go=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function ga(e){return e!=null&&e!=="parent"}function Or(e){var t,r;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}}function CS(e){var t,r;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight)!==void 0}function TS(e,t={width:0,height:0},r,l,a){const o={...e},u=l.get(r);if(u){const c=u.origin||a;o.x+=u.internals.positionAbsolute.x-(t.width??0)*c[0],o.y+=u.internals.positionAbsolute.y-(t.height??0)*c[1]}return o}function Mv(e,t){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}function rA(){let e,t;return{promise:new Promise((l,a)=>{e=l,t=a}),resolve:e,reject:t}}function iA(e){return{...vS,...e||{}}}function Mo(e,{snapGrid:t=[0,0],snapToGrid:r=!1,transform:l,containerBounds:a}){const{x:o,y:u}=Pn(e),c=ns({x:o-((a==null?void 0:a.left)??0),y:u-((a==null?void 0:a.top)??0)},l),{x:d,y:h}=r?ts(c,t):c;return{xSnapped:d,ySnapped:h,...c}}const Mm=e=>({width:e.offsetWidth,height:e.offsetHeight}),jS=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},lA=["INPUT","SELECT","TEXTAREA"];function AS(e){var l,a;const t=((a=(l=e.composedPath)==null?void 0:l.call(e))==null?void 0:a[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:lA.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const zS=e=>"clientX"in e,Pn=(e,t)=>{var o,u;const r=zS(e),l=r?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:l-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},Dv=(e,t,r,l,a)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(u=>{const c=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:a,position:u.getAttribute("data-handlepos"),x:(c.left-r.left)/l,y:(c.top-r.top)/l,...Mm(u)}})};function MS({sourceX:e,sourceY:t,targetX:r,targetY:l,sourceControlX:a,sourceControlY:o,targetControlX:u,targetControlY:c}){const d=e*.125+a*.375+u*.375+r*.125,h=t*.125+o*.375+c*.375+l*.125,m=Math.abs(d-e),p=Math.abs(h-t);return[d,h,m,p]}function Uu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Rv({pos:e,x1:t,y1:r,x2:l,y2:a,c:o}){switch(e){case ve.Left:return[t-Uu(t-l,o),r];case ve.Right:return[t+Uu(l-t,o),r];case ve.Top:return[t,r-Uu(r-a,o)];case ve.Bottom:return[t,r+Uu(a-r,o)]}}function Dm({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top,curvature:u=.25}){const[c,d]=Rv({pos:r,x1:e,y1:t,x2:l,y2:a,c:u}),[h,m]=Rv({pos:o,x1:l,y1:a,x2:e,y2:t,c:u}),[p,x,b,w]=MS({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:m});return[`M${e},${t} C${c},${d} ${h},${m} ${l},${a}`,p,x,b,w]}function DS({sourceX:e,sourceY:t,targetX:r,targetY:l}){const a=Math.abs(r-e)/2,o=r0}const sA=({source:e,sourceHandle:t,target:r,targetHandle:l})=>`xy-edge__${e}${t||""}-${r}${l||""}`,uA=(e,t)=>t.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),cA=(e,t,r={})=>{if(!e.source||!e.target)return t;const l=r.getEdgeId||sA;let a;return SS(e)?a={...e}:a={...e,id:l(e)},uA(a,t)?t:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,t.concat(a))};function RS({sourceX:e,sourceY:t,targetX:r,targetY:l}){const[a,o,u,c]=DS({sourceX:e,sourceY:t,targetX:r,targetY:l});return[`M ${e},${t}L ${r},${l}`,a,o,u,c]}const Ov={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},fA=({source:e,sourcePosition:t=ve.Bottom,target:r})=>t===ve.Left||t===ve.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function dA({source:e,sourcePosition:t=ve.Bottom,target:r,targetPosition:l=ve.Top,center:a,offset:o,stepPosition:u}){const c=Ov[t],d=Ov[l],h={x:e.x+c.x*o,y:e.y+c.y*o},m={x:r.x+d.x*o,y:r.y+d.y*o},p=fA({source:h,sourcePosition:t,target:m}),x=p.x!==0?"x":"y",b=p[x];let w=[],E,_;const S={x:0,y:0},N={x:0,y:0},[,,k,A]=DS({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(c[x]*d[x]===-1){x==="x"?(E=a.x??h.x+(m.x-h.x)*u,_=a.y??(h.y+m.y)/2):(E=a.x??(h.x+m.x)/2,_=a.y??h.y+(m.y-h.y)*u);const j=[{x:E,y:h.y},{x:E,y:m.y}],L=[{x:h.x,y:_},{x:m.x,y:_}];c[x]===b?w=x==="x"?j:L:w=x==="x"?L:j}else{const j=[{x:h.x,y:m.y}],L=[{x:m.x,y:h.y}];if(x==="x"?w=c.x===b?L:j:w=c.y===b?j:L,t===l){const U=Math.abs(e[x]-r[x]);if(U<=o){const ee=Math.min(o-1,o-U);c[x]===b?S[x]=(h[x]>e[x]?-1:1)*ee:N[x]=(m[x]>r[x]?-1:1)*ee}}if(t!==l){const U=x==="x"?"y":"x",ee=c[x]===d[U],I=h[U]>m[U],F=h[U]=B?(E=(R.x+V.x)/2,_=w[0].y):(E=w[0].x,_=(R.y+V.y)/2)}return[[e,{x:h.x+S.x,y:h.y+S.y},...w,{x:m.x+N.x,y:m.y+N.y},r],E,_,k,A]}function hA(e,t,r,l){const a=Math.min(Lv(e,t)/2,Lv(t,r)/2,l),{x:o,y:u}=t;if(e.x===o&&o===r.x||e.y===u&&u===r.y)return`L${o} ${u}`;if(e.y===u){const h=e.x{let A="";return k>0&&kr.id===t):e[0])||null}function em(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(l=>`${l}=${e[l]}`).join("&")}`:""}function mA(e,{id:t,defaultColor:r,defaultMarkerStart:l,defaultMarkerEnd:a}){const o=new Set;return e.reduce((u,c)=>([c.markerStart||l,c.markerEnd||a].forEach(d=>{if(d&&typeof d=="object"){const h=em(d,t);o.has(h)||(u.push({id:h,color:d.color||r,...d}),o.add(h))}}),u),[]).sort((u,c)=>u.id.localeCompare(c.id))}const OS=1e3,gA=10,Rm={nodeOrigin:[0,0],nodeExtent:Vo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xA={...Rm,checkEquality:!0};function Om(e,t){const r={...e};for(const l in t)t[l]!==void 0&&(r[l]=t[l]);return r}function yA(e,t,r){const l=Om(Rm,r);for(const a of e.values())if(a.parentId)Hm(a,e,t,l);else{const o=Wo(a,l.nodeOrigin),u=ga(a.extent)?a.extent:l.nodeExtent,c=el(o,u,Or(a));a.internals.positionAbsolute=c}}function vA(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const r=[],l=[];for(const a of e.handles){const o={id:a.id,width:a.width??1,height:a.height??1,nodeId:e.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?r.push(o):a.type==="target"&&l.push(o)}return{source:r,target:l}}function Lm(e){return e==="manual"}function tm(e,t,r,l={}){var h,m;const a=Om(xA,l),o={i:0},u=new Map(t),c=a!=null&&a.elevateNodesOnSelect&&!Lm(a.zIndexMode)?OS:0;let d=e.length>0;t.clear(),r.clear();for(const p of e){let x=u.get(p.id);if(a.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=Wo(p,a.nodeOrigin),w=ga(p.extent)?p.extent:a.nodeExtent,E=el(b,w,Or(p));x={...a.defaults,...p,measured:{width:(h=p.measured)==null?void 0:h.width,height:(m=p.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:vA(p,x),z:LS(p,c,a.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),p.parentId&&Hm(x,t,r,l,o)}return d}function bA(e,t){if(!e.parentId)return;const r=t.get(e.parentId);r?r.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hm(e,t,r,l,a){const{elevateNodesOnSelect:o,nodeOrigin:u,nodeExtent:c,zIndexMode:d}=Om(Rm,l),h=e.parentId,m=t.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}bA(e,r),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*gA),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const p=o&&!Lm(d)?OS:0,{x,y:b,z:w}=wA(e,m,u,c,p,d),{positionAbsolute:E}=e.internals,_=x!==E.x||b!==E.y;(_||w!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:_?{x,y:b}:E,z:w}})}function LS(e,t,r){const l=Vn(e.zIndex)?e.zIndex:0;return Lm(r)?l:l+(e.selected?t:0)}function wA(e,t,r,l,a,o){const{x:u,y:c}=t.internals.positionAbsolute,d=Or(e),h=Wo(e,r),m=ga(e.extent)?el(h,e.extent,d):h;let p=el({x:u+m.x,y:c+m.y},l,d);e.extent==="parent"&&(p=kS(p,d,t));const x=LS(e,a,o),b=t.internals.z??0;return{x:p.x,y:p.y,z:b>=x?b+1:x}}function Bm(e,t,r,l=[0,0]){var u;const a=[],o=new Map;for(const c of e){const d=t.get(c.parentId);if(!d)continue;const h=((u=o.get(c.parentId))==null?void 0:u.expandedRect)??ma(d),m=NS(h,c.rect);o.set(c.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:c,parent:d},h)=>{var k;const m=d.internals.positionAbsolute,p=Or(d),x=d.origin??l,b=c.x0||w>0||S||N)&&(a.push({id:h,type:"position",position:{x:d.position.x-b+S,y:d.position.y-w+N}}),(k=r.get(h))==null||k.forEach(A=>{e.some(M=>M.id===A.id)||a.push({id:A.id,type:"position",position:{x:A.position.x+b,y:A.position.y+w}})})),(p.width0){const b=Bm(x,t,r,a);h.push(...b)}return{changes:h,updatedInternals:d}}async function _A({delta:e,panZoom:t,transform:r,translateExtent:l,width:a,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const u=await t.setViewportConstrained({x:r[0]+e.x,y:r[1]+e.y,zoom:r[2]},[[0,0],[a,o]],l),c=!!u&&(u.x!==r[0]||u.y!==r[1]||u.k!==r[2]);return Promise.resolve(c)}function qv(e,t,r,l,a,o){let u=a;const c=l.get(u)||new Map;l.set(u,c.set(r,t)),u=`${a}-${e}`;const d=l.get(u)||new Map;if(l.set(u,d.set(r,t)),o){u=`${a}-${e}-${o}`;const h=l.get(u)||new Map;l.set(u,h.set(r,t))}}function HS(e,t,r){e.clear(),t.clear();for(const l of r){const{source:a,target:o,sourceHandle:u=null,targetHandle:c=null}=l,d={edgeId:l.id,source:a,target:o,sourceHandle:u,targetHandle:c},h=`${a}-${u}--${o}-${c}`,m=`${o}-${c}--${a}-${u}`;qv("source",d,m,e,a,u),qv("target",d,h,e,o,c),t.set(l.id,l)}}function BS(e,t){if(!e.parentId)return!1;const r=t.get(e.parentId);return r?r.selected?!0:BS(r,t):!1}function Uv(e,t,r){var a;let l=e;do{if((a=l==null?void 0:l.matches)!=null&&a.call(l,t))return!0;if(l===r)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function kA(e,t,r,l){const a=new Map;for(const[o,u]of e)if((u.selected||u.id===l)&&(!u.parentId||!BS(u,e))&&(u.draggable||t&&typeof u.draggable>"u")){const c=e.get(o);c&&a.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:r.x-c.internals.positionAbsolute.x,y:r.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return a}function bh({nodeId:e,dragItems:t,nodeLookup:r,dragging:l=!0}){var u,c,d;const a=[];for(const[h,m]of t){const p=(u=r.get(h))==null?void 0:u.internals.userNode;p&&a.push({...p,position:m.position,dragging:l})}if(!e)return[a[0],a];const o=(c=r.get(e))==null?void 0:c.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:l}:a[0],a]}function EA({dragItems:e,snapGrid:t,x:r,y:l}){const a=e.values().next().value;if(!a)return null;const o={x:r-a.distance.x,y:l-a.distance.y},u=ts(o,t);return{x:u.x-o.x,y:u.y-o.y}}function NA({onNodeMouseDown:e,getStoreItems:t,onDragStart:r,onDrag:l,onDragStop:a}){let o={x:null,y:null},u=0,c=new Map,d=!1,h={x:0,y:0},m=null,p=!1,x=null,b=!1,w=!1,E=null;function _({noDragClassName:N,handleSelector:k,domNode:A,isSelectable:M,nodeId:j,nodeClickDistance:L=0}){x=wn(A);function R({x:U,y:ee}){const{nodeLookup:I,nodeExtent:F,snapGrid:z,snapToGrid:G,nodeOrigin:Q,onNodeDrag:K,onSelectionDrag:D,onError:q,updateNodePositions:Y}=t();o={x:U,y:ee};let C=!1;const $=c.size>1,X=$&&F?Jp(es(c)):null,J=$&&G?EA({dragItems:c,snapGrid:z,x:U,y:ee}):null;for(const[ne,re]of c){if(!I.has(ne))continue;let se={x:U-re.distance.x,y:ee-re.distance.y};G&&(se=J?{x:Math.round(se.x+J.x),y:Math.round(se.y+J.y)}:ts(se,z));let xe=null;if($&&F&&!re.extent&&X){const{positionAbsolute:pe}=re.internals,_e=pe.x-X.x+F[0][0],ze=pe.x+re.measured.width-X.x2+F[1][0],Te=pe.y-X.y+F[0][1],ut=pe.y+re.measured.height-X.y2+F[1][1];xe=[[_e,Te],[ze,ut]]}const{position:be,positionAbsolute:ye}=_S({nodeId:ne,nextPosition:se,nodeLookup:I,nodeExtent:xe||F,nodeOrigin:Q,onError:q});C=C||re.position.x!==be.x||re.position.y!==be.y,re.position=be,re.internals.positionAbsolute=ye}if(w=w||C,!!C&&(Y(c,!0),E&&(l||K||!j&&D))){const[ne,re]=bh({nodeId:j,dragItems:c,nodeLookup:I});l==null||l(E,c,ne,re),K==null||K(E,ne,re),j||D==null||D(E,re)}}async function V(){if(!m)return;const{transform:U,panBy:ee,autoPanSpeed:I,autoPanOnNodeDrag:F}=t();if(!F){d=!1,cancelAnimationFrame(u);return}const[z,G]=ES(h,m,I);(z!==0||G!==0)&&(o.x=(o.x??0)-z/U[2],o.y=(o.y??0)-G/U[2],await ee({x:z,y:G})&&R(o)),u=requestAnimationFrame(V)}function H(U){var $;const{nodeLookup:ee,multiSelectionActive:I,nodesDraggable:F,transform:z,snapGrid:G,snapToGrid:Q,selectNodesOnDrag:K,onNodeDragStart:D,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();p=!0,(!K||!M)&&!I&&j&&(($=ee.get(j))!=null&&$.selected||Y()),M&&K&&j&&(e==null||e(j));const C=Mo(U.sourceEvent,{transform:z,snapGrid:G,snapToGrid:Q,containerBounds:m});if(o=C,c=kA(ee,F,C,j),c.size>0&&(r||D||!j&&q)){const[X,J]=bh({nodeId:j,dragItems:c,nodeLookup:ee});r==null||r(U.sourceEvent,c,X,J),D==null||D(U.sourceEvent,X,J),j||q==null||q(U.sourceEvent,J)}}const B=nS().clickDistance(L).on("start",U=>{const{domNode:ee,nodeDragThreshold:I,transform:F,snapGrid:z,snapToGrid:G}=t();m=(ee==null?void 0:ee.getBoundingClientRect())||null,b=!1,w=!1,E=U.sourceEvent,I===0&&H(U),o=Mo(U.sourceEvent,{transform:F,snapGrid:z,snapToGrid:G,containerBounds:m}),h=Pn(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:ee,transform:I,snapGrid:F,snapToGrid:z,nodeDragThreshold:G,nodeLookup:Q}=t(),K=Mo(U.sourceEvent,{transform:I,snapGrid:F,snapToGrid:z,containerBounds:m});if(E=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||j&&!Q.has(j))&&(b=!0),!b){if(!d&&ee&&p&&(d=!0,V()),!p){const D=Pn(U.sourceEvent,m),q=D.x-h.x,Y=D.y-h.y;Math.sqrt(q*q+Y*Y)>G&&H(U)}(o.x!==K.xSnapped||o.y!==K.ySnapped)&&c&&p&&(h=Pn(U.sourceEvent,m),R(K))}}).on("end",U=>{if(!(!p||b)&&(d=!1,p=!1,cancelAnimationFrame(u),c.size>0)){const{nodeLookup:ee,updateNodePositions:I,onNodeDragStop:F,onSelectionDragStop:z}=t();if(w&&(I(c,!1),w=!1),a||F||!j&&z){const[G,Q]=bh({nodeId:j,dragItems:c,nodeLookup:ee,dragging:!1});a==null||a(U.sourceEvent,c,G,Q),F==null||F(U.sourceEvent,G,Q),j||z==null||z(U.sourceEvent,Q)}}}).filter(U=>{const ee=U.target;return!U.button&&(!N||!Uv(ee,`.${N}`,A))&&(!k||Uv(ee,k,A))});x.call(B)}function S(){x==null||x.on(".drag",null)}return{update:_,destroy:S}}function CA(e,t,r){const l=[],a={x:e.x-r,y:e.y-r,width:r*2,height:r*2};for(const o of t.values())$o(a,ma(o))>0&&l.push(o);return l}const TA=250;function jA(e,t,r,l){var c,d;let a=[],o=1/0;const u=CA(e,r,t+TA);for(const h of u){const m=[...((c=h.internals.handleBounds)==null?void 0:c.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of m){if(l.nodeId===p.nodeId&&l.type===p.type&&l.id===p.id)continue;const{x,y:b}=tl(h,p,p.position,!0),w=Math.sqrt(Math.pow(x-e.x,2)+Math.pow(b-e.y,2));w>t||(w1){const h=l.type==="source"?"target":"source";return a.find(m=>m.type===h)??a[0]}return a[0]}function IS(e,t,r,l,a,o=!1){var h,m,p;const u=l.get(e);if(!u)return null;const c=a==="strict"?(h=u.internals.handleBounds)==null?void 0:h[t]:[...((m=u.internals.handleBounds)==null?void 0:m.source)??[],...((p=u.internals.handleBounds)==null?void 0:p.target)??[]],d=(r?c==null?void 0:c.find(x=>x.id===r):c==null?void 0:c[0])??null;return d&&o?{...d,...tl(u,d,d.position,!0)}:d}function qS(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function AA(e,t){let r=null;return t?r=!0:e&&!t&&(r=!1),r}const US=()=>!0;function zA(e,{connectionMode:t,connectionRadius:r,handleId:l,nodeId:a,edgeUpdaterType:o,isTarget:u,domNode:c,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:p,panBy:x,cancelConnection:b,onConnectStart:w,onConnect:E,onConnectEnd:_,isValidConnection:S=US,onReconnectEnd:N,updateConnection:k,getTransform:A,getFromHandle:M,autoPanSpeed:j,dragThreshold:L=1,handleDomNode:R}){const V=jS(e.target);let H=0,B;const{x:U,y:ee}=Pn(e),I=qS(o,R),F=c==null?void 0:c.getBoundingClientRect();let z=!1;if(!F||!I)return;const G=IS(a,I,l,d,t);if(!G)return;let Q=Pn(e,F),K=!1,D=null,q=!1,Y=null;function C(){if(!m||!F)return;const[be,ye]=ES(Q,F,j);x({x:be,y:ye}),H=requestAnimationFrame(C)}const $={...G,nodeId:a,type:I,position:G.position},X=d.get(a);let ne={inProgress:!0,isValid:null,from:tl(X,$,ve.Left,!0),fromHandle:$,fromPosition:$.position,fromNode:X,to:Q,toHandle:null,toPosition:jv[$.position],toNode:null,pointer:Q};function re(){z=!0,k(ne),w==null||w(e,{nodeId:a,handleId:l,handleType:I})}L===0&&re();function se(be){if(!z){const{x:ut,y:nt}=Pn(be),zt=ut-U,Pt=nt-ee;if(!(zt*zt+Pt*Pt>L*L))return;re()}if(!M()||!$){xe(be);return}const ye=A();Q=Pn(be,F),B=jA(ns(Q,ye,!1,[1,1]),r,d,$),K||(C(),K=!0);const pe=VS(be,{handle:B,connectionMode:t,fromNodeId:a,fromHandleId:l,fromType:u?"target":"source",isValidConnection:S,doc:V,lib:h,flowId:p,nodeLookup:d});Y=pe.handleDomNode,D=pe.connection,q=AA(!!B,pe.isValid);const _e=d.get(a),ze=_e?tl(_e,$,ve.Left,!0):ne.from,Te={...ne,from:ze,isValid:q,to:pe.toHandle&&q?mc({x:pe.toHandle.x,y:pe.toHandle.y},ye):Q,toHandle:pe.toHandle,toPosition:q&&pe.toHandle?pe.toHandle.position:jv[$.position],toNode:pe.toHandle?d.get(pe.toHandle.nodeId):null,pointer:Q};k(Te),ne=Te}function xe(be){if(!("touches"in be&&be.touches.length>0)){if(z){(B||Y)&&D&&q&&(E==null||E(D));const{inProgress:ye,...pe}=ne,_e={...pe,toPosition:ne.toHandle?ne.toPosition:null};_==null||_(be,_e),o&&(N==null||N(be,_e))}b(),cancelAnimationFrame(H),K=!1,q=!1,D=null,Y=null,V.removeEventListener("mousemove",se),V.removeEventListener("mouseup",xe),V.removeEventListener("touchmove",se),V.removeEventListener("touchend",xe)}}V.addEventListener("mousemove",se),V.addEventListener("mouseup",xe),V.addEventListener("touchmove",se),V.addEventListener("touchend",xe)}function VS(e,{handle:t,connectionMode:r,fromNodeId:l,fromHandleId:a,fromType:o,doc:u,lib:c,flowId:d,isValidConnection:h=US,nodeLookup:m}){const p=o==="target",x=t?u.querySelector(`.${c}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:b,y:w}=Pn(e),E=u.elementFromPoint(b,w),_=E!=null&&E.classList.contains(`${c}-flow__handle`)?E:x,S={handleDomNode:_,isValid:!1,connection:null,toHandle:null};if(_){const N=qS(void 0,_),k=_.getAttribute("data-nodeid"),A=_.getAttribute("data-handleid"),M=_.classList.contains("connectable"),j=_.classList.contains("connectableend");if(!k||!N)return S;const L={source:p?k:l,sourceHandle:p?A:a,target:p?l:k,targetHandle:p?a:A};S.connection=L;const V=M&&j&&(r===ha.Strict?p&&N==="source"||!p&&N==="target":k!==l||A!==a);S.isValid=V&&h(L),S.toHandle=IS(k,N,A,m,r,!0)}return S}const nm={onPointerDown:zA,isValid:VS};function MA({domNode:e,panZoom:t,getTransform:r,getViewScale:l}){const a=wn(e);function o({translateExtent:c,width:d,height:h,zoomStep:m=1,pannable:p=!0,zoomable:x=!0,inversePan:b=!1}){const w=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const A=r(),M=k.sourceEvent.ctrlKey&&Go()?10:1,j=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,L=A[2]*Math.pow(2,j*M);t.scaleTo(L)};let E=[0,0];const _=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},S=k=>{const A=r();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],j=[M[0]-E[0],M[1]-E[1]];E=M;const L=l()*Math.max(A[2],Math.log(A[2]))*(b?-1:1),R={x:A[0]-j[0]*L,y:A[1]-j[1]*L},V=[[0,0],[d,h]];t.setViewportConstrained({x:R.x,y:R.y,zoom:A[2]},V,c)},N=xS().on("start",_).on("zoom",p?S:null).on("zoom.wheel",x?w:null);a.call(N,{})}function u(){a.on("zoom",null)}return{update:o,destroy:u,pointer:qn}}const Rc=e=>({x:e.x,y:e.y,zoom:e.k}),wh=({x:e,y:t,zoom:r})=>zc.translate(e,t).scale(r),ra=(e,t)=>e.target.closest(`.${t}`),PS=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),DA=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Sh=(e,t=0,r=DA,l=()=>{})=>{const a=typeof t=="number"&&t>0;return a||l(),a?e.transition().duration(t).ease(r).on("end",l):e},$S=e=>{const t=e.ctrlKey&&Go()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function RA({zoomPanValues:e,noWheelClassName:t,d3Selection:r,d3Zoom:l,panOnScrollMode:a,panOnScrollSpeed:o,zoomOnPinch:u,onPanZoomStart:c,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(ra(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=r.property("__zoom").k||1;if(m.ctrlKey&&u){const _=qn(m),S=$S(m),N=p*Math.pow(2,S);l.scaleTo(r,N,_,m);return}const x=m.deltaMode===1?20:1;let b=a===Zi.Vertical?0:m.deltaX*x,w=a===Zi.Horizontal?0:m.deltaY*x;!Go()&&m.shiftKey&&a!==Zi.Vertical&&(b=m.deltaY*x,w=0),l.translateBy(r,-(b/p)*o,-(w/p)*o,{internal:!0});const E=Rc(r.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(m,E),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(m,E))}}function OA({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:r}){return function(l,a){const o=l.type==="wheel",u=!t&&o&&!l.ctrlKey,c=ra(l,e);if(l.ctrlKey&&o&&c&&l.preventDefault(),u||c)return null;l.preventDefault(),r.call(this,l,a)}}function LA({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:r}){return l=>{var o,u,c;if((o=l.sourceEvent)!=null&&o.internal)return;const a=Rc(l.transform);e.mouseButton=((u=l.sourceEvent)==null?void 0:u.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=a,((c=l.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),r&&(r==null||r(l.sourceEvent,a))}}function HA({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:r,onTransformChange:l,onPanZoom:a}){return o=>{var u,c;e.usedRightMouseButton=!!(r&&PS(t,e.mouseButton??0)),(u=o.sourceEvent)!=null&&u.sync||l([o.transform.x,o.transform.y,o.transform.k]),a&&!((c=o.sourceEvent)!=null&&c.internal)&&(a==null||a(o.sourceEvent,Rc(o.transform)))}}function BA({zoomPanValues:e,panOnDrag:t,panOnScroll:r,onDraggingChange:l,onPanZoomEnd:a,onPaneContextMenu:o}){return u=>{var c;if(!((c=u.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,o&&PS(t,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&o(u.sourceEvent),e.usedRightMouseButton=!1,l(!1),a)){const d=Rc(u.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{a==null||a(u.sourceEvent,d)},r?150:0)}}}function IA({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:r,panOnDrag:l,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:u,noWheelClassName:c,noPanClassName:d,lib:h,connectionInProgress:m}){return p=>{var _;const x=e||t,b=r&&p.ctrlKey,w=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(ra(p,`${h}-flow__node`)||ra(p,`${h}-flow__edge`)))return!0;if(!l&&!x&&!a&&!o&&!r||u||m&&!w||ra(p,c)&&w||ra(p,d)&&(!w||a&&w&&!e)||!r&&p.ctrlKey&&w)return!1;if(!r&&p.type==="touchstart"&&((_=p.touches)==null?void 0:_.length)>1)return p.preventDefault(),!1;if(!x&&!a&&!b&&w||!l&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(l)&&!l.includes(p.button)&&p.type==="mousedown")return!1;const E=Array.isArray(l)&&l.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||w)&&E}}function qA({domNode:e,minZoom:t,maxZoom:r,translateExtent:l,viewport:a,onPanZoom:o,onPanZoomStart:u,onPanZoomEnd:c,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect(),p=xS().scaleExtent([t,r]).translateExtent(l),x=wn(e).call(p);N({x:a.x,y:a.y,zoom:pa(a.zoom,t,r)},[[0,0],[m.width,m.height]],l);const b=x.on("wheel.zoom"),w=x.on("dblclick.zoom");p.wheelDelta($S);function E(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).transform(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function _({noWheelClassName:B,noPanClassName:U,onPaneContextMenu:ee,userSelectionActive:I,panOnScroll:F,panOnDrag:z,panOnScrollMode:G,panOnScrollSpeed:Q,preventScrolling:K,zoomOnPinch:D,zoomOnScroll:q,zoomOnDoubleClick:Y,zoomActivationKeyPressed:C,lib:$,onTransformChange:X,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:re}){I&&!h.isZoomingOrPanning&&S();const se=F&&!C&&!I;p.clickDistance(re?1/0:!Vn(ne)||ne<0?0:ne);const xe=se?RA({zoomPanValues:h,noWheelClassName:B,d3Selection:x,d3Zoom:p,panOnScrollMode:G,panOnScrollSpeed:Q,zoomOnPinch:D,onPanZoomStart:u,onPanZoom:o,onPanZoomEnd:c}):OA({noWheelClassName:B,preventScrolling:K,d3ZoomHandler:b});if(x.on("wheel.zoom",xe,{passive:!1}),!I){const ye=LA({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:u});p.on("start",ye);const pe=HA({zoomPanValues:h,panOnDrag:z,onPaneContextMenu:!!ee,onPanZoom:o,onTransformChange:X});p.on("zoom",pe);const _e=BA({zoomPanValues:h,panOnDrag:z,panOnScroll:F,onPaneContextMenu:ee,onPanZoomEnd:c,onDraggingChange:d});p.on("end",_e)}const be=IA({zoomActivationKeyPressed:C,panOnDrag:z,zoomOnScroll:q,panOnScroll:F,zoomOnDoubleClick:Y,zoomOnPinch:D,userSelectionActive:I,noPanClassName:U,noWheelClassName:B,lib:$,connectionInProgress:J});p.filter(be),Y?x.on("dblclick.zoom",w):x.on("dblclick.zoom",null)}function S(){p.on("zoom",null)}async function N(B,U,ee){const I=wh(B),F=p==null?void 0:p.constrain()(I,U,ee);return F&&await E(F),new Promise(z=>z(F))}async function k(B,U){const ee=wh(B);return await E(ee,U),new Promise(I=>I(ee))}function A(B){if(x){const U=wh(B),ee=x.property("__zoom");(ee.k!==B.zoom||ee.x!==B.x||ee.y!==B.y)&&(p==null||p.transform(x,U,null,{sync:!0}))}}function M(){const B=x?gS(x.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function j(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleTo(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function L(B,U){return x?new Promise(ee=>{p==null||p.interpolate((U==null?void 0:U.interpolate)==="linear"?zo:Ju).scaleBy(Sh(x,U==null?void 0:U.duration,U==null?void 0:U.ease,()=>ee(!0)),B)}):Promise.resolve(!1)}function R(B){p==null||p.scaleExtent(B)}function V(B){p==null||p.translateExtent(B)}function H(B){const U=!Vn(B)||B<0?0:B;p==null||p.clickDistance(U)}return{update:_,destroy:S,setViewport:k,setViewportConstrained:N,getViewport:M,scaleTo:j,scaleBy:L,setScaleExtent:R,setTranslateExtent:V,syncViewport:A,setClickDistance:H}}var xa;(function(e){e.Line="line",e.Handle="handle"})(xa||(xa={}));function UA({width:e,prevWidth:t,height:r,prevHeight:l,affectsX:a,affectsY:o}){const u=e-t,c=r-l,d=[u>0?1:u<0?-1:0,c>0?1:c<0?-1:0];return u&&a&&(d[0]=d[0]*-1),c&&o&&(d[1]=d[1]*-1),d}function Vv(e){const t=e.includes("right")||e.includes("left"),r=e.includes("bottom")||e.includes("top"),l=e.includes("left"),a=e.includes("top");return{isHorizontal:t,isVertical:r,affectsX:l,affectsY:a}}function hi(e,t){return Math.max(0,t-e)}function pi(e,t){return Math.max(0,e-t)}function Vu(e,t,r){return Math.max(0,t-e,e-r)}function Pv(e,t){return e?!t:t}function VA(e,t,r,l,a,o,u,c){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:p}=t,x=m&&p,{xSnapped:b,ySnapped:w}=r,{minWidth:E,maxWidth:_,minHeight:S,maxHeight:N}=l,{x:k,y:A,width:M,height:j,aspectRatio:L}=e;let R=Math.floor(m?b-e.pointerX:0),V=Math.floor(p?w-e.pointerY:0);const H=M+(d?-R:R),B=j+(h?-V:V),U=-o[0]*M,ee=-o[1]*j;let I=Vu(H,E,_),F=Vu(B,S,N);if(u){let Q=0,K=0;d&&R<0?Q=hi(k+R+U,u[0][0]):!d&&R>0&&(Q=pi(k+H+U,u[1][0])),h&&V<0?K=hi(A+V+ee,u[0][1]):!h&&V>0&&(K=pi(A+B+ee,u[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(c){let Q=0,K=0;d&&R>0?Q=pi(k+R,c[0][0]):!d&&R<0&&(Q=hi(k+H,c[1][0])),h&&V>0?K=pi(A+V,c[0][1]):!h&&V<0&&(K=hi(A+B,c[1][1])),I=Math.max(I,Q),F=Math.max(F,K)}if(a){if(m){const Q=Vu(H/L,S,N)*L;if(I=Math.max(I,Q),u){let K=0;!d&&!h||d&&!h&&x?K=pi(A+ee+H/L,u[1][1])*L:K=hi(A+ee+(d?R:-R)/L,u[0][1])*L,I=Math.max(I,K)}if(c){let K=0;!d&&!h||d&&!h&&x?K=hi(A+H/L,c[1][1])*L:K=pi(A+(d?R:-R)/L,c[0][1])*L,I=Math.max(I,K)}}if(p){const Q=Vu(B*L,E,_)/L;if(F=Math.max(F,Q),u){let K=0;!d&&!h||h&&!d&&x?K=pi(k+B*L+U,u[1][0])/L:K=hi(k+(h?V:-V)*L+U,u[0][0])/L,F=Math.max(F,K)}if(c){let K=0;!d&&!h||h&&!d&&x?K=hi(k+B*L,c[1][0])/L:K=pi(k+(h?V:-V)*L,c[0][0])/L,F=Math.max(F,K)}}}V=V+(V<0?F:-F),R=R+(R<0?I:-I),a&&(x?H>B*L?V=(Pv(d,h)?-R:R)/L:R=(Pv(d,h)?-V:V)*L:m?(V=R/L,h=d):(R=V*L,d=h));const z=d?k+R:k,G=h?A+V:A;return{width:M+(d?-R:R),height:j+(h?-V:V),x:o[0]*R*(d?-1:1)+z,y:o[1]*V*(h?-1:1)+G}}const GS={width:0,height:0,x:0,y:0},PA={...GS,pointerX:0,pointerY:0,aspectRatio:1};function $A(e){return[[0,0],[e.measured.width,e.measured.height]]}function GA(e,t,r){const l=t.position.x+e.position.x,a=t.position.y+e.position.y,o=e.measured.width??0,u=e.measured.height??0,c=r[0]*o,d=r[1]*u;return[[l-c,a-d],[l+o-c,a+u-d]]}function FA({domNode:e,nodeId:t,getStoreItems:r,onChange:l,onEnd:a}){const o=wn(e);let u={controlDirection:Vv("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:h,boundaries:m,keepAspectRatio:p,resizeDirection:x,onResizeStart:b,onResize:w,onResizeEnd:E,shouldResize:_}){let S={...GS},N={...PA};u={boundaries:m,resizeDirection:x,keepAspectRatio:p,controlDirection:Vv(h)};let k,A=null,M=[],j,L,R,V=!1;const H=nS().on("start",B=>{const{nodeLookup:U,transform:ee,snapGrid:I,snapToGrid:F,nodeOrigin:z,paneDomNode:G}=r();if(k=U.get(t),!k)return;A=(G==null?void 0:G.getBoundingClientRect())??null;const{xSnapped:Q,ySnapped:K}=Mo(B.sourceEvent,{transform:ee,snapGrid:I,snapToGrid:F,containerBounds:A});S={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},N={...S,pointerX:Q,pointerY:K,aspectRatio:S.width/S.height},j=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(j=U.get(k.parentId),L=j&&k.extent==="parent"?$A(j):void 0),M=[],R=void 0;for(const[D,q]of U)if(q.parentId===t&&(M.push({id:D,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=GA(q,k,q.origin??z);R?R=[[Math.min(Y[0][0],R[0][0]),Math.min(Y[0][1],R[0][1])],[Math.max(Y[1][0],R[1][0]),Math.max(Y[1][1],R[1][1])]]:R=Y}b==null||b(B,{...S})}).on("drag",B=>{const{transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F}=r(),z=Mo(B.sourceEvent,{transform:U,snapGrid:ee,snapToGrid:I,containerBounds:A}),G=[];if(!k)return;const{x:Q,y:K,width:D,height:q}=S,Y={},C=k.origin??F,{width:$,height:X,x:J,y:ne}=VA(N,u.controlDirection,z,u.boundaries,u.keepAspectRatio,C,L,R),re=$!==D,se=X!==q,xe=J!==Q&&re,be=ne!==K&&se;if(!xe&&!be&&!re&&!se)return;if((xe||be||C[0]===1||C[1]===1)&&(Y.x=xe?J:S.x,Y.y=be?ne:S.y,S.x=Y.x,S.y=Y.y,M.length>0)){const ze=J-Q,Te=ne-K;for(const ut of M)ut.position={x:ut.position.x-ze+C[0]*($-D),y:ut.position.y-Te+C[1]*(X-q)},G.push(ut)}if((re||se)&&(Y.width=re&&(!u.resizeDirection||u.resizeDirection==="horizontal")?$:S.width,Y.height=se&&(!u.resizeDirection||u.resizeDirection==="vertical")?X:S.height,S.width=Y.width,S.height=Y.height),j&&k.expandParent){const ze=C[0]*(Y.width??0);Y.x&&Y.x{V&&(E==null||E(B,{...S}),a==null||a({...S}),V=!1)});o.call(H)}function d(){o.on(".drag",null)}return{update:c,destroy:d}}var _h={exports:{}},kh={},Eh={exports:{}},Nh={};/** * @license React * use-sync-external-store-shim.production.js * @@ -298,7 +298,7 @@ Error generating stack: `+f.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var $v;function YA(){if($v)return Nh;$v=1;var e=Zo();function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}var r=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,u=e.useDebugValue;function c(p,x){var b=x(),w=l({inst:{value:b,getSnapshot:x}}),k=w[0].inst,_=w[1];return o(function(){k.value=b,k.getSnapshot=x,d(k)&&_({inst:k})},[p,b,x]),a(function(){return d(k)&&_({inst:k}),p(function(){d(k)&&_({inst:k})})},[p]),u(b),b}function d(p){var x=p.getSnapshot;p=p.value;try{var b=x();return!r(p,b)}catch{return!0}}function h(p,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Nh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Nh}var Gv;function XA(){return Gv||(Gv=1,Eh.exports=YA()),Eh.exports}/** + */var $v;function YA(){if($v)return Nh;$v=1;var e=Zo();function t(p,x){return p===x&&(p!==0||1/p===1/x)||p!==p&&x!==x}var r=typeof Object.is=="function"?Object.is:t,l=e.useState,a=e.useEffect,o=e.useLayoutEffect,u=e.useDebugValue;function c(p,x){var b=x(),w=l({inst:{value:b,getSnapshot:x}}),E=w[0].inst,_=w[1];return o(function(){E.value=b,E.getSnapshot=x,d(E)&&_({inst:E})},[p,b,x]),a(function(){return d(E)&&_({inst:E}),p(function(){d(E)&&_({inst:E})})},[p]),u(b),b}function d(p){var x=p.getSnapshot;p=p.value;try{var b=x();return!r(p,b)}catch{return!0}}function h(p,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Nh.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Nh}var Gv;function XA(){return Gv||(Gv=1,Eh.exports=YA()),Eh.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -306,41 +306,41 @@ Error generating stack: `+f.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Fv;function QA(){if(Fv)return kh;Fv=1;var e=Zo(),t=XA();function r(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var l=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,u=e.useEffect,c=e.useMemo,d=e.useDebugValue;return kh.useSyncExternalStoreWithSelector=function(h,m,p,x,b){var w=o(null);if(w.current===null){var k={hasValue:!1,value:null};w.current=k}else k=w.current;w=c(function(){function S(j){if(!C){if(C=!0,E=j,j=x(j),b!==void 0&&k.hasValue){var L=k.value;if(b(L,j))return A=L}return A=j}if(L=A,l(E,j))return L;var O=x(j);return b!==void 0&&b(L,O)?(E=j,L):(E=j,A=O)}var C=!1,E,A,M=p===void 0?null:p;return[function(){return S(m())},M===null?void 0:function(){return S(M())}]},[m,p,x,b]);var _=a(h,w[0],w[1]);return u(function(){k.hasValue=!0,k.value=_},[_]),d(_),_},kh}var Yv;function ZA(){return Yv||(Yv=1,_h.exports=QA()),_h.exports}var KA=ZA();const JA=Qo(KA),WA={},Xv=e=>{let t;const r=new Set,l=(m,p)=>{const x=typeof m=="function"?m(t):m;if(!Object.is(x,t)){const b=t;t=p??(typeof x!="object"||x===null)?x:Object.assign({},t,x),r.forEach(w=>w(t,b))}},a=()=>t,d={setState:l,getState:a,getInitialState:()=>h,subscribe:m=>(r.add(m),()=>r.delete(m)),destroy:()=>{(WA?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},h=t=e(l,a,d);return d},ez=e=>e?Xv(e):Xv,{useDebugValue:tz}=ta,{useSyncExternalStoreWithSelector:nz}=JA,rz=e=>e;function FS(e,t=rz,r){const l=nz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return tz(l),l}const Qv=(e,t)=>{const r=ez(e),l=(a,o=t)=>FS(r,a,o);return Object.assign(l,r),l},iz=(e,t)=>e?Qv(e,t):Qv;function pt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var lz=dw();const Oc=V.createContext(null),az=Oc.Provider,YS=lr.error001();function Ye(e,t){const r=V.useContext(Oc);if(r===null)throw new Error(YS);return FS(r,e,t)}function mt(){const e=V.useContext(Oc);if(e===null)throw new Error(YS);return V.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Zv={display:"none"},oz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},XS="react-flow__node-desc",QS="react-flow__edge-desc",sz="react-flow__aria-live",uz=e=>e.ariaLiveMessage,cz=e=>e.ariaLabelConfig;function fz({rfId:e}){const t=Ye(uz);return y.jsx("div",{id:`${sz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:oz,children:t})}function dz({rfId:e,disableKeyboardA11y:t}){const r=Ye(cz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${XS}-${e}`,style:Zv,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${QS}-${e}`,style:Zv,children:r["edge.a11yDescription.default"]}),!t&&y.jsx(fz,{rfId:e})]})}const Lc=V.forwardRef(({position:e="top-left",children:t,className:r,style:l,...a},o)=>{const u=`${e}`.split("-");return y.jsx("div",{className:At(["react-flow__panel",r,...u]),style:l,ref:o,...a,children:t})});Lc.displayName="Panel";function hz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Lc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const pz=e=>{const t=[],r=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&r.push(l);return{selectedNodes:t,selectedEdges:r}},Pu=e=>e.id;function mz(e,t){return pt(e.selectedNodes.map(Pu),t.selectedNodes.map(Pu))&&pt(e.selectedEdges.map(Pu),t.selectedEdges.map(Pu))}function gz({onSelectionChange:e}){const t=mt(),{selectedNodes:r,selectedEdges:l}=Ye(pz,mz);return V.useEffect(()=>{const a={nodes:r,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,l,e]),null}const xz=e=>!!e.onSelectionChangeHandlers;function yz({onSelectionChange:e}){const t=Ye(xz);return e||t?y.jsx(gz,{onSelectionChange:e}):null}const ZS=[0,0],vz={x:0,y:0,zoom:1},bz=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Kv=[...bz,"rfId"],wz=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Jv={translateExtent:Vo,nodeOrigin:ZS,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Sz(e){const{setNodes:t,setEdges:r,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:u,reset:c,setDefaultNodesAndEdges:d}=Ye(wz,pt),h=mt();V.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=Jv,c()}),[]);const m=V.useRef(Jv);return V.useEffect(()=>{for(const p of Kv){const x=e[p],b=m.current[p];x!==b&&(typeof e[p]>"u"||(p==="nodes"?t(x):p==="edges"?r(x):p==="minZoom"?l(x):p==="maxZoom"?a(x):p==="translateExtent"?o(x):p==="nodeExtent"?u(x):p==="ariaLabelConfig"?h.setState({ariaLabelConfig:iA(x)}):p==="fitView"?h.setState({fitViewQueued:x}):p==="fitViewOptions"?h.setState({fitViewOptions:x}):h.setState({[p]:x})))}m.current=e},Kv.map(p=>e[p])),null}function Wv(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function _z(e){var l;const[t,r]=V.useState(e==="system"?null:e);return V.useEffect(()=>{if(e!=="system"){r(e);return}const a=Wv(),o=()=>r(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=Wv())!=null&&l.matches?"dark":"light"}const eb=typeof document<"u"?document:null;function Fo(e=null,t={target:eb,actInsideInputWithModifier:!0}){const[r,l]=V.useState(!1),a=V.useRef(!1),o=V.useRef(new Set([])),[u,c]=V.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` + */var Fv;function QA(){if(Fv)return kh;Fv=1;var e=Zo(),t=XA();function r(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var l=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,o=e.useRef,u=e.useEffect,c=e.useMemo,d=e.useDebugValue;return kh.useSyncExternalStoreWithSelector=function(h,m,p,x,b){var w=o(null);if(w.current===null){var E={hasValue:!1,value:null};w.current=E}else E=w.current;w=c(function(){function S(j){if(!N){if(N=!0,k=j,j=x(j),b!==void 0&&E.hasValue){var L=E.value;if(b(L,j))return A=L}return A=j}if(L=A,l(k,j))return L;var R=x(j);return b!==void 0&&b(L,R)?(k=j,L):(k=j,A=R)}var N=!1,k,A,M=p===void 0?null:p;return[function(){return S(m())},M===null?void 0:function(){return S(M())}]},[m,p,x,b]);var _=a(h,w[0],w[1]);return u(function(){E.hasValue=!0,E.value=_},[_]),d(_),_},kh}var Yv;function ZA(){return Yv||(Yv=1,_h.exports=QA()),_h.exports}var KA=ZA();const JA=Qo(KA),WA={},Xv=e=>{let t;const r=new Set,l=(m,p)=>{const x=typeof m=="function"?m(t):m;if(!Object.is(x,t)){const b=t;t=p??(typeof x!="object"||x===null)?x:Object.assign({},t,x),r.forEach(w=>w(t,b))}},a=()=>t,d={setState:l,getState:a,getInitialState:()=>h,subscribe:m=>(r.add(m),()=>r.delete(m)),destroy:()=>{(WA?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},h=t=e(l,a,d);return d},ez=e=>e?Xv(e):Xv,{useDebugValue:tz}=ta,{useSyncExternalStoreWithSelector:nz}=JA,rz=e=>e;function FS(e,t=rz,r){const l=nz(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return tz(l),l}const Qv=(e,t)=>{const r=ez(e),l=(a,o=t)=>FS(r,a,o);return Object.assign(l,r),l},iz=(e,t)=>e?Qv(e,t):Qv;function pt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[l,a]of e)if(!Object.is(a,t.get(l)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const l of e)if(!t.has(l))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(t,l)||!Object.is(e[l],t[l]))return!1;return!0}var lz=dw();const Oc=P.createContext(null),az=Oc.Provider,YS=lr.error001();function Ye(e,t){const r=P.useContext(Oc);if(r===null)throw new Error(YS);return FS(r,e,t)}function mt(){const e=P.useContext(Oc);if(e===null)throw new Error(YS);return P.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Zv={display:"none"},oz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},XS="react-flow__node-desc",QS="react-flow__edge-desc",sz="react-flow__aria-live",uz=e=>e.ariaLiveMessage,cz=e=>e.ariaLabelConfig;function fz({rfId:e}){const t=Ye(uz);return y.jsx("div",{id:`${sz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:oz,children:t})}function dz({rfId:e,disableKeyboardA11y:t}){const r=Ye(cz);return y.jsxs(y.Fragment,{children:[y.jsx("div",{id:`${XS}-${e}`,style:Zv,children:t?r["node.a11yDescription.default"]:r["node.a11yDescription.keyboardDisabled"]}),y.jsx("div",{id:`${QS}-${e}`,style:Zv,children:r["edge.a11yDescription.default"]}),!t&&y.jsx(fz,{rfId:e})]})}const Lc=P.forwardRef(({position:e="top-left",children:t,className:r,style:l,...a},o)=>{const u=`${e}`.split("-");return y.jsx("div",{className:At(["react-flow__panel",r,...u]),style:l,ref:o,...a,children:t})});Lc.displayName="Panel";function hz({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:y.jsx(Lc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:y.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const pz=e=>{const t=[],r=[];for(const[,l]of e.nodeLookup)l.selected&&t.push(l.internals.userNode);for(const[,l]of e.edgeLookup)l.selected&&r.push(l);return{selectedNodes:t,selectedEdges:r}},Pu=e=>e.id;function mz(e,t){return pt(e.selectedNodes.map(Pu),t.selectedNodes.map(Pu))&&pt(e.selectedEdges.map(Pu),t.selectedEdges.map(Pu))}function gz({onSelectionChange:e}){const t=mt(),{selectedNodes:r,selectedEdges:l}=Ye(pz,mz);return P.useEffect(()=>{const a={nodes:r,edges:l};e==null||e(a),t.getState().onSelectionChangeHandlers.forEach(o=>o(a))},[r,l,e]),null}const xz=e=>!!e.onSelectionChangeHandlers;function yz({onSelectionChange:e}){const t=Ye(xz);return e||t?y.jsx(gz,{onSelectionChange:e}):null}const ZS=[0,0],vz={x:0,y:0,zoom:1},bz=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Kv=[...bz,"rfId"],wz=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Jv={translateExtent:Vo,nodeOrigin:ZS,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Sz(e){const{setNodes:t,setEdges:r,setMinZoom:l,setMaxZoom:a,setTranslateExtent:o,setNodeExtent:u,reset:c,setDefaultNodesAndEdges:d}=Ye(wz,pt),h=mt();P.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=Jv,c()}),[]);const m=P.useRef(Jv);return P.useEffect(()=>{for(const p of Kv){const x=e[p],b=m.current[p];x!==b&&(typeof e[p]>"u"||(p==="nodes"?t(x):p==="edges"?r(x):p==="minZoom"?l(x):p==="maxZoom"?a(x):p==="translateExtent"?o(x):p==="nodeExtent"?u(x):p==="ariaLabelConfig"?h.setState({ariaLabelConfig:iA(x)}):p==="fitView"?h.setState({fitViewQueued:x}):p==="fitViewOptions"?h.setState({fitViewOptions:x}):h.setState({[p]:x})))}m.current=e},Kv.map(p=>e[p])),null}function Wv(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function _z(e){var l;const[t,r]=P.useState(e==="system"?null:e);return P.useEffect(()=>{if(e!=="system"){r(e);return}const a=Wv(),o=()=>r(a!=null&&a.matches?"dark":"light");return o(),a==null||a.addEventListener("change",o),()=>{a==null||a.removeEventListener("change",o)}},[e]),t!==null?t:(l=Wv())!=null&&l.matches?"dark":"light"}const eb=typeof document<"u"?document:null;function Fo(e=null,t={target:eb,actInsideInputWithModifier:!0}){const[r,l]=P.useState(!1),a=P.useRef(!1),o=P.useRef(new Set([])),[u,c]=P.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",` `).replace(` `,` +`).split(` -`)),m=h.reduce((p,x)=>p.concat(...x),[]);return[h,m]}return[[],[]]},[e]);return V.useEffect(()=>{const d=(t==null?void 0:t.target)??eb,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var _,S;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!h)&&AS(b))return!1;const k=nb(b.code,c);if(o.current.add(b[k]),tb(u,o.current,!1)){const C=((S=(_=b.composedPath)==null?void 0:_.call(b))==null?void 0:S[0])||b.target,E=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";t.preventDefault!==!1&&(a.current||!E)&&b.preventDefault(),l(!0)}},p=b=>{const w=nb(b.code,c);tb(u,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},x=()=>{o.current.clear(),l(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,l]),r}function tb(e,t,r){return e.filter(l=>r||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function nb(e,t){return t.includes(e)?"code":"key"}const kz=()=>{const e=mt();return V.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{const{transform:[l,a,o],panZoom:u}=e.getState();return u?(await u.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,l]=e.getState().transform;return{x:t,y:r,zoom:l}},setCenter:async(t,r,l)=>e.getState().setCenter(t,r,l),fitBounds:async(t,r)=>{const{width:l,height:a,minZoom:o,maxZoom:u,panZoom:c}=e.getState(),d=zm(t,l,a,o,u,(r==null?void 0:r.padding)??.1);return c?(await c.setViewport(d,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:u}=e.getState();if(!u)return t;const{x:c,y:d}=u.getBoundingClientRect(),h={x:t.x-c,y:t.y-d},m=r.snapGrid??a,p=r.snapToGrid??o;return ns(h,l,p,m)},flowToScreenPosition:t=>{const{transform:r,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),u=mc(t,r);return{x:u.x+a,y:u.y+o}}}),[])};function KS(e,t){const r=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const u=l.get(o.id);u?u.push(o):l.set(o.id,[o])}for(const o of t){const u=l.get(o.id);if(!u){r.push(o);continue}if(u[0].type==="remove")continue;if(u[0].type==="replace"){r.push({...u[0].item});continue}const c={...o};for(const d of u)Ez(d,c);r.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}function Ez(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function JS(e,t){return KS(e,t)}function WS(e,t){return KS(e,t)}function $i(e,t){return{id:e,type:"select",selected:t}}function ia(e,t=new Set,r=!1){const l=[];for(const[a,o]of e){const u=t.has(a);!(o.selected===void 0&&!u)&&o.selected!==u&&(r&&(o.selected=u),l.push($i(o.id,u)))}return l}function rb({items:e=[],lookup:t}){var a;const r=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,u]of e.entries()){const c=t.get(u.id),d=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;d!==void 0&&d!==u&&r.push({id:u.id,item:u,type:"replace"}),d===void 0&&r.push({item:u,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function ib(e){return{id:e.id,type:"remove"}}const lb=e=>Xj(e),Nz=e=>SS(e);function e_(e){return V.forwardRef(e)}const Cz=typeof window<"u"?V.useLayoutEffect:V.useEffect;function ab(e){const[t,r]=V.useState(BigInt(0)),[l]=V.useState(()=>Tz(()=>r(a=>a+BigInt(1))));return Cz(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function Tz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:r=>{t.push(r),e()}}}const t_=V.createContext(null);function jz({children:e}){const t=mt(),r=V.useCallback(c=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:p,nodeLookup:x,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let k=d;for(const S of c)k=typeof S=="function"?S(k):S;let _=rb({items:k,lookup:x});for(const S of w.values())_=S(_);m&&h(k),_.length>0?p==null||p(_):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:S,nodes:C,setNodes:E}=t.getState();S&&E(C)})},[]),l=ab(r),a=V.useCallback(c=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:x}=t.getState();let b=d;for(const w of c)b=typeof w=="function"?w(b):w;m?h(b):p&&p(rb({items:b,lookup:x}))},[]),o=ab(a),u=V.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(t_.Provider,{value:u,children:e})}function Az(){const e=V.useContext(t_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const zz=e=>!!e.panZoom;function al(){const e=kz(),t=mt(),r=Az(),l=Ye(zz),a=V.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),u=p=>{r.nodeQueue.push(p)},c=p=>{r.edgeQueue.push(p)},d=p=>{var S,C;const{nodeLookup:x,nodeOrigin:b}=t.getState(),w=lb(p)?p:x.get(p.id),k=w.parentId?TS(w.position,w.measured,w.parentId,x,b):w.position,_={...w,position:k,width:((S=w.measured)==null?void 0:S.width)??w.width,height:((C=w.measured)==null?void 0:C.height)??w.height};return ma(_)},h=(p,x,b={replace:!1})=>{u(w=>w.map(k=>{if(k.id===p){const _=typeof x=="function"?x(k):x;return b.replace&&lb(_)?_:{...k,..._}}return k}))},m=(p,x,b={replace:!1})=>{c(w=>w.map(k=>{if(k.id===p){const _=typeof x=="function"?x(k):x;return b.replace&&Nz(_)?_:{...k,..._}}return k}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var x;return(x=o(p))==null?void 0:x.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:u,setEdges:c,addNodes:p=>{const x=Array.isArray(p)?p:[p];r.nodeQueue.push(b=>[...b,...x])},addEdges:p=>{const x=Array.isArray(p)?p:[p];r.edgeQueue.push(b=>[...b,...x])},toObject:()=>{const{nodes:p=[],edges:x=[],transform:b}=t.getState(),[w,k,_]=b;return{nodes:p.map(S=>({...S})),edges:x.map(S=>({...S})),viewport:{x:w,y:k,zoom:_}}},deleteElements:async({nodes:p=[],edges:x=[]})=>{const{nodes:b,edges:w,onNodesDelete:k,onEdgesDelete:_,triggerNodeChanges:S,triggerEdgeChanges:C,onDelete:E,onBeforeDelete:A}=t.getState(),{nodes:M,edges:j}=await Wj({nodesToRemove:p,edgesToRemove:x,nodes:b,edges:w,onBeforeDelete:A}),L=j.length>0,O=M.length>0;if(L){const P=j.map(ib);_==null||_(j),C(P)}if(O){const P=M.map(ib);k==null||k(M),S(P)}return(O||L)&&(E==null||E({nodes:M,edges:j})),{deletedNodes:M,deletedEdges:j}},getIntersectingNodes:(p,x=!0,b)=>{const w=zv(p),k=w?p:d(p),_=b!==void 0;return k?(b||t.getState().nodes).filter(S=>{const C=t.getState().nodeLookup.get(S.id);if(C&&!w&&(S.id===p.id||!C.internals.positionAbsolute))return!1;const E=ma(_?S:C),A=$o(E,k);return x&&A>0||A>=E.width*E.height||A>=k.width*k.height}):[]},isNodeIntersecting:(p,x,b=!0)=>{const k=zv(p)?p:d(p);if(!k)return!1;const _=$o(k,x);return b&&_>0||_>=x.width*x.height||_>=k.width*k.height},updateNode:h,updateNodeData:(p,x,b={replace:!1})=>{h(p,w=>{const k=typeof x=="function"?x(w):x;return b.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},b)},updateEdge:m,updateEdgeData:(p,x,b={replace:!1})=>{m(p,w=>{const k=typeof x=="function"?x(w):x;return b.replace?{...w,data:k}:{...w,data:{...w.data,...k}}},b)},getNodesBounds:p=>{const{nodeLookup:x,nodeOrigin:b}=t.getState();return Qj(p,{nodeLookup:x,nodeOrigin:b})},getHandleConnections:({type:p,id:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${x?`-${x}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?x?`-${p}-${x}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const x=t.getState().fitViewResolver??rA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:x}),r.nodeQueue.push(b=>[...b]),x.promise}}},[]);return V.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const ob=e=>e.selected,Mz=typeof window<"u"?window:void 0;function Dz({deleteKeyCode:e,multiSelectionKeyCode:t}){const r=mt(),{deleteElements:l}=al(),a=Fo(e,{actInsideInputWithModifier:!1}),o=Fo(t,{target:Mz});V.useEffect(()=>{if(a){const{edges:u,nodes:c}=r.getState();l({nodes:c.filter(ob),edges:u.filter(ob)}),r.setState({nodesSelectionActive:!1})}},[a]),V.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function Rz(e){const t=mt();V.useEffect(()=>{const r=()=>{var a,o,u,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Mm(e.current);(l.height===0||l.width===0)&&((c=(u=t.getState()).onError)==null||c.call(u,"004",lr.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){r(),window.addEventListener("resize",r);const l=new ResizeObserver(()=>r());return l.observe(e.current),()=>{window.removeEventListener("resize",r),l&&e.current&&l.unobserve(e.current)}}},[])}const Hc={position:"absolute",width:"100%",height:"100%",top:0,left:0},Oz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Lz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=Zi.Free,zoomOnDoubleClick:u=!0,panOnDrag:c=!0,defaultViewport:d,translateExtent:h,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:w,noWheelClassName:k,noPanClassName:_,onViewportChange:S,isControlledViewport:C,paneClickDistance:E,selectionOnDrag:A}){const M=mt(),j=V.useRef(null),{userSelectionActive:L,lib:O,connectionInProgress:P}=Ye(Oz,pt),H=Fo(x),B=V.useRef();Rz(j);const U=V.useCallback(ee=>{S==null||S({x:ee[0],y:ee[1],zoom:ee[2]}),C||M.setState({transform:ee})},[S,C]);return V.useEffect(()=>{if(j.current){B.current=qA({domNode:j.current,minZoom:m,maxZoom:p,translateExtent:h,viewport:d,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:I,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,I,F],domNode:j.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),V.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:u,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:_,userSelectionActive:L,noWheelClassName:k,lib:O,onTransformChange:U,connectionInProgress:P,selectionOnDrag:A,paneClickDistance:E})},[e,t,r,l,a,o,u,c,H,b,_,L,k,O,U,P,A,E]),y.jsx("div",{className:"react-flow__renderer",ref:j,style:Hc,children:w})}const Hz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Bz(){const{userSelectionActive:e,userSelectionRect:t}=Ye(Hz,pt);return e&&t?y.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Ch=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},Iz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function qz({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Po.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:u,onSelectionEnd:c,onPaneClick:d,onPaneContextMenu:h,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:w}){const k=mt(),{userSelectionActive:_,elementsSelectable:S,dragging:C,connectionInProgress:E}=Ye(Iz,pt),A=S&&(e||_),M=V.useRef(null),j=V.useRef(),L=V.useRef(new Set),O=V.useRef(new Set),P=V.useRef(!1),H=Q=>{if(P.current||E){P.current=!1;return}d==null||d(Q),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}h==null||h(Q)},U=m?Q=>m(Q):void 0,ee=Q=>{P.current&&(Q.stopPropagation(),P.current=!1)},I=Q=>{var X,J;const{domNode:K}=k.getState();if(j.current=K==null?void 0:K.getBoundingClientRect(),!j.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),P.current=!1;const{x:N,y:$}=Pn(Q.nativeEvent,j.current);k.setState({userSelectionRect:{width:0,height:0,startX:N,startY:$,x:N,y:$}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:q,edgeLookup:Y,connectionLookup:N,triggerNodeChanges:$,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=k.getState();if(!j.current||!K)return;const{x:re,y:se}=Pn(Q.nativeEvent,j.current),{startX:xe,startY:be}=K;if(!P.current){const Te=t?0:a;if(Math.hypot(re-xe,se-be)<=Te)return;ne(),u==null||u(Q)}P.current=!0;const ye={startX:xe,startY:be,x:reTe.id)),O.current=new Set;const ze=(J==null?void 0:J.selectable)??!0;for(const Te of L.current){const ut=N.get(Te);if(ut)for(const{edgeId:nt}of ut.values()){const zt=Y.get(nt);zt&&(zt.selectable??ze)&&O.current.add(nt)}}if(!Mv(pe,L.current)){const Te=ia(q,L.current,!0);$(Te)}if(!Mv(_e,O.current)){const Te=ia(Y,O.current);X(Te)}k.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!_&&Q.target===M.current&&k.getState().userSelectionRect&&(H==null||H(Q)),k.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(Q),k.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:At(["react-flow__pane",{draggable:G,dragging:C,selection:e}]),onClick:A?void 0:Ch(H,M),onContextMenu:Ch(B,M),onWheel:Ch(U,M),onPointerEnter:A?void 0:p,onPointerMove:A?F:x,onPointerUp:A?z:void 0,onPointerDownCapture:A?I:void 0,onClickCapture:A?ee:void 0,onPointerLeave:b,ref:M,style:Hc,children:[w,y.jsx(Bz,{})]})}function rm({id:e,store:t,unselect:r=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:u,nodeLookup:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",lr.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&u)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function n_({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:u}){const c=mt(),[d,h]=V.useState(!1),m=V.useRef();return V.useEffect(()=>{m.current=NA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{rm({id:p,store:c,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),V.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:r,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:u}),()=>{var p;(p=m.current)==null||p.destroy()}},[r,l,t,o,e,a,u]),d}const Uz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function r_(){const e=mt();return V.useCallback(r=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:u,onError:c,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),p=new Map,x=Uz(u),b=a?o[0]:5,w=a?o[1]:5,k=r.direction.x*b*r.factor,_=r.direction.y*w*r.factor;for(const[,S]of h){if(!x(S))continue;let C={x:S.internals.positionAbsolute.x+k,y:S.internals.positionAbsolute.y+_};a&&(C=ts(C,o));const{position:E,positionAbsolute:A}=_S({nodeId:S.id,nextPosition:C,nodeLookup:h,nodeExtent:l,nodeOrigin:m,onError:c});S.position=E,S.internals.positionAbsolute=A,p.set(S.id,S)}d(p)},[])}const Im=V.createContext(null),Vz=Im.Provider;Im.Consumer;const i_=()=>V.useContext(Im),Pz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),$z=(e,t,r)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:u}=l,{fromHandle:c,toHandle:d,isValid:h}=u,m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===r;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===r,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===ha.Strict?(c==null?void 0:c.type)!==r:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&h}};function Gz({type:e="source",position:t=ve.Top,isValidConnection:r,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:u,onConnect:c,children:d,className:h,onMouseDown:m,onTouchStart:p,...x},b){var F,z;const w=u||null,k=e==="target",_=mt(),S=i_(),{connectOnClick:C,noPanClassName:E,rfId:A}=Ye(Pz,pt),{connectingFrom:M,connectingTo:j,clickConnecting:L,isPossibleEndHandle:O,connectionInProcess:P,clickConnectionInProcess:H,valid:B}=Ye($z(S,w,e),pt);S||(z=(F=_.getState()).onError)==null||z.call(F,"010",lr.error010());const U=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=_.getState(),q={...Q,...G};if(D){const{edges:Y,setEdges:N}=_.getState();N(cA(q,Y))}K==null||K(q),c==null||c(q)},ee=G=>{if(!S)return;const Q=zS(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=_.getState();nm.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:k,handleId:w,nodeId:S,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var q,Y;return(Y=(q=_.getState()).onConnectEnd)==null?void 0:Y.call(q,...D)},updateConnection:K.updateConnection,onConnect:U,isValidConnection:r||((...D)=>{var q,Y;return((Y=(q=_.getState()).isValidConnection)==null?void 0:Y.call(q,...D))??!0}),getTransform:()=>_.getState().transform,getFromHandle:()=>_.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:q,isValidConnection:Y,lib:N,rfId:$,nodeLookup:X,connection:J}=_.getState();if(!S||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:S,handleId:w,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:S,type:e,id:w}});return}const ne=jS(G.target),re=r||Y,{connection:se,isValid:xe}=nm.isValid(G.nativeEvent,{handle:{nodeId:S,id:w,type:e},connectionMode:q,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:$,doc:ne,lib:N,nodeLookup:X});xe&&se&&U(se);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),_.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":S,"data-handlepos":t,"data-id":`${A}-${S}-${w}-${e}`,className:At(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,h,{source:!k,target:k,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:j,valid:B,connectionindicator:l&&(!P||O)&&(P||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:C?I:void 0,ref:b,...x,children:d})}const Lt=V.memo(e_(Gz));function Fz({data:e,isConnectable:t,sourcePosition:r=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:r,isConnectable:t})]})}function Yz({data:e,isConnectable:t,targetPosition:r=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:l,isConnectable:t})]})}function Xz(){return null}function Qz({data:e,isConnectable:t,targetPosition:r=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label]})}const gc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},sb={input:Fz,default:Yz,output:Qz,group:Xz};function Zz(e){var t,r,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((r=e.style)==null?void 0:r.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const Kz=e=>{const{width:t,height:r,x:l,y:a}=es(e.nodeLookup,{filter:o=>!!o.selected});return{width:Vn(t)?t:null,height:Vn(r)?r:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function Jz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const l=mt(),{width:a,height:o,transformString:u,userSelectionActive:c}=Ye(Kz,pt),d=r_(),h=V.useRef(null);V.useEffect(()=>{var b;r||(b=h.current)==null||b.focus({preventScroll:!0})},[r]);const m=!c&&a!==null&&o!==null;if(n_({nodeRef:h,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(k=>k.selected);e(b,w)}:void 0,x=b=>{Object.prototype.hasOwnProperty.call(gc,b.key)&&(b.preventDefault(),d({direction:gc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:At(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u},children:y.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:a,height:o}})})}const ub=typeof window<"u"?window:void 0,Wz=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function l_({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,paneClickDistance:c,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:p,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:k,zoomActivationKeyCode:_,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:E,panOnScroll:A,panOnScrollSpeed:M,panOnScrollMode:j,zoomOnDoubleClick:L,panOnDrag:O,defaultViewport:P,translateExtent:H,minZoom:B,maxZoom:U,preventScrolling:ee,onSelectionContextMenu:I,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:q}=Ye(Wz,pt),Y=Fo(h,{target:ub}),N=Fo(k,{target:ub}),$=N||O,X=N||A,J=m&&$!==!0,ne=Y||q||J;return Dz({deleteKeyCode:d,multiSelectionKeyCode:w}),y.jsx(Lz,{onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:E,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:j,zoomOnDoubleClick:L,panOnDrag:!Y&&$,defaultViewport:P,translateExtent:H,minZoom:B,maxZoom:U,zoomActivationKeyCode:_,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs(qz,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,panOnDrag:$,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(Jz,{onSelectionContextMenu:I,noPanClassName:z,disableKeyboardA11y:G})]})})}l_.displayName="FlowRenderer";const eM=V.memo(l_),tM=e=>t=>e?Am(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function nM(e){return Ye(V.useCallback(tM(e),[e]),pt)}const rM=e=>e.updateNodeInternals;function iM(){const e=Ye(rM),[t]=V.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const l=new Map;r.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return V.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function lM({node:e,nodeType:t,hasDimensions:r,resizeObserver:l}){const a=mt(),o=V.useRef(null),u=V.useRef(null),c=V.useRef(e.sourcePosition),d=V.useRef(e.targetPosition),h=V.useRef(t),m=r&&!!e.internals.handleBounds;return V.useEffect(()=>{o.current&&!e.hidden&&(!m||u.current!==o.current)&&(u.current&&(l==null||l.unobserve(u.current)),l==null||l.observe(o.current),u.current=o.current)},[m,e.hidden]),V.useEffect(()=>()=>{u.current&&(l==null||l.unobserve(u.current),u.current=null)},[]),V.useEffect(()=>{if(o.current){const p=h.current!==t,x=c.current!==e.sourcePosition,b=d.current!==e.targetPosition;(p||x||b)&&(h.current=t,c.current=e.sourcePosition,d.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function aM({id:e,onClick:t,onMouseEnter:r,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:u,nodesDraggable:c,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:p,noDragClassName:x,noPanClassName:b,disableKeyboardA11y:w,rfId:k,nodeTypes:_,nodeClickDistance:S,onError:C}){const{node:E,internals:A,isParent:M}=Ye(re=>{const se=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},pt);let j=E.type||"default",L=(_==null?void 0:_[j])||sb[j];L===void 0&&(C==null||C("003",lr.error003(j)),j="default",L=(_==null?void 0:_.default)||sb.default);const O=!!(E.draggable||c&&typeof E.draggable>"u"),P=!!(E.selectable||d&&typeof E.selectable>"u"),H=!!(E.connectable||h&&typeof E.connectable>"u"),B=!!(E.focusable||m&&typeof E.focusable>"u"),U=mt(),ee=CS(E),I=lM({node:E,nodeType:j,hasDimensions:ee,resizeObserver:p}),F=n_({nodeRef:I,disabled:E.hidden||!O,noDragClassName:x,handleSelector:E.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:S}),z=r_();if(E.hidden)return null;const G=Or(E),Q=Zz(E),K=P||O||t||r||l||a,D=r?re=>r(re,{...A.userNode}):void 0,q=l?re=>l(re,{...A.userNode}):void 0,Y=a?re=>a(re,{...A.userNode}):void 0,N=o?re=>o(re,{...A.userNode}):void 0,$=u?re=>u(re,{...A.userNode}):void 0,X=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=U.getState();P&&(!se||!O||xe>0)&&rm({id:e,store:U,nodeRef:I}),t&&t(re,{...A.userNode})},J=re=>{if(!(AS(re.nativeEvent)||w)){if(yS.includes(re.key)&&P){const se=re.key==="Escape";rm({id:e,store:U,unselect:se,nodeRef:I})}else if(O&&E.selected&&Object.prototype.hasOwnProperty.call(gc,re.key)){re.preventDefault();const{ariaLabelConfig:se}=U.getState();U.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),z({direction:gc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var _e;if(w||!((_e=I.current)!=null&&_e.matches(":focus-visible")))return;const{transform:re,width:se,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=U.getState();if(!be)return;Am(new Map([[e,E]]),{x:0,y:0,width:se,height:xe},re,!0).length>0||ye(E.position.x+G.width/2,E.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:At(["react-flow__node",`react-flow__node-${j}`,{[b]:O},E.className,{selected:E.selected,selectable:P,parent:M,draggable:O,dragging:F}]),ref:I,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...E.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:q,onMouseLeave:Y,onContextMenu:N,onClick:X,onDoubleClick:$,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:E.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${XS}-${k}`,"aria-label":E.ariaLabel,...E.domAttributes,children:y.jsx(Vz,{value:e,children:y.jsx(L,{id:e,data:E.data,type:j,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:E.selected??!1,selectable:P,draggable:O,deletable:E.deletable??!0,isConnectable:H,sourcePosition:E.sourcePosition,targetPosition:E.targetPosition,dragging:F,dragHandle:E.dragHandle,zIndex:A.z,parentId:E.parentId,...G})})})}var oM=V.memo(aM);const sM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function a_(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(sM,pt),u=nM(e.onlyRenderVisibleElements),c=iM();return y.jsx("div",{className:"react-flow__nodes",style:Hc,children:u.map(d=>y.jsx(oM,{id:d,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},d))})}a_.displayName="NodeRenderer";const uM=V.memo(a_);function cM(e){return Ye(V.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const l=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),u=r.nodeLookup.get(a.target);o&&u&&oA({sourceNode:o,targetNode:u,width:r.width,height:r.height,transform:r.transform})&&l.push(a.id)}return l},[e]),pt)}const fM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},dM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},cb={[hc.Arrow]:fM,[hc.ArrowClosed]:dM};function hM(e){const t=mt();return V.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(cb,e)?cb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",lr.error009(e)),null)},[e])}const pM=({id:e,type:t,color:r,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const d=hM(t);return d?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(d,{color:r,strokeWidth:u})}):null},o_=({defaultColor:e,rfId:t})=>{const r=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=V.useMemo(()=>mA(r,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[r,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(pM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};o_.displayName="MarkerDefinitions";var mM=V.memo(o_);function s_({x:e,y:t,label:r,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...m}){const[p,x]=V.useState({x:1,y:0,width:0,height:0}),b=At(["react-flow__edge-textwrapper",h]),w=V.useRef(null);return V.useEffect(()=>{if(w.current){const k=w.current.getBBox();x({x:k.x,y:k.y,width:k.width,height:k.height})}},[r]),r?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*u[0],x:-u[0],y:-u[1],height:p.height+2*u[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:r}),d]}):null}s_.displayName="EdgeText";const gM=V.memo(s_);function rs({path:e,labelX:t,labelY:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:At(["react-flow__edge-path",m.className])}),h?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,l&&Vn(t)&&Vn(r)?y.jsx(gM,{x:t,y:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d}):null]})}function fb({pos:e,x1:t,y1:r,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),r]:[t,.5*(r+a)]}function u_({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[u,c]=fb({pos:r,x1:e,y1:t,x2:l,y2:a}),[d,h]=fb({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,x,b]=MS({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:u,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${u},${c} ${d},${h} ${l},${a}`,m,p,x,b]}function c_(e){return V.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:_,interactionWidth:S})=>{const[C,E,A]=u_({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(rs,{id:M,path:C,labelX:E,labelY:A,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:_,interactionWidth:S})})}const xM=c_({isInternal:!1}),f_=c_({isInternal:!0});xM.displayName="SimpleBezierEdge";f_.displayName="SimpleBezierEdgeInternal";function d_(e){return V.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:k,markerStart:_,pathOptions:S,interactionWidth:C})=>{const[E,A,M]=Wp({sourceX:r,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:S==null?void 0:S.borderRadius,offset:S==null?void 0:S.offset,stepPosition:S==null?void 0:S.stepPosition}),j=e.isInternal?void 0:t;return y.jsx(rs,{id:j,path:E,labelX:A,labelY:M,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:k,markerStart:_,interactionWidth:C})})}const h_=d_({isInternal:!1}),p_=d_({isInternal:!0});h_.displayName="SmoothStepEdge";p_.displayName="SmoothStepEdgeInternal";function m_(e){return V.memo(({id:t,...r})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(h_,{...r,id:l,pathOptions:V.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const yM=m_({isInternal:!1}),g_=m_({isInternal:!0});yM.displayName="StepEdge";g_.displayName="StepEdgeInternal";function x_(e){return V.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:k})=>{const[_,S,C]=RS({sourceX:r,sourceY:l,targetX:a,targetY:o}),E=e.isInternal?void 0:t;return y.jsx(rs,{id:E,path:_,labelX:S,labelY:C,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:k})})}const vM=x_({isInternal:!1}),y_=x_({isInternal:!0});vM.displayName="StraightEdge";y_.displayName="StraightEdgeInternal";function v_(e){return V.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u=ve.Bottom,targetPosition:c=ve.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:_,pathOptions:S,interactionWidth:C})=>{const[E,A,M]=Dm({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c,curvature:S==null?void 0:S.curvature}),j=e.isInternal?void 0:t;return y.jsx(rs,{id:j,path:E,labelX:A,labelY:M,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:k,markerStart:_,interactionWidth:C})})}const bM=v_({isInternal:!1}),b_=v_({isInternal:!0});bM.displayName="BezierEdge";b_.displayName="BezierEdgeInternal";const db={default:b_,straight:y_,step:g_,smoothstep:p_,simplebezier:f_},hb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},wM=(e,t,r)=>r===ve.Left?e-t:r===ve.Right?e+t:e,SM=(e,t,r)=>r===ve.Top?e-t:r===ve.Bottom?e+t:e,pb="react-flow__edgeupdater";function mb({position:e,centerX:t,centerY:r,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:u,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:u,className:At([pb,`${pb}-${c}`]),cx:wM(t,l,e),cy:SM(r,l,e),r:l,stroke:"transparent",fill:"transparent"})}function _M({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:l,sourceY:a,targetX:o,targetY:u,sourcePosition:c,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:p,setReconnecting:x,setUpdateHover:b}){const w=mt(),k=(A,M)=>{if(A.button!==0)return;const{autoPanOnConnect:j,domNode:L,connectionMode:O,connectionRadius:P,lib:H,onConnectStart:B,cancelConnection:U,nodeLookup:ee,rfId:I,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=(q,Y)=>{x(!1),p==null||p(q,r,M.type,Y)},K=q=>h==null?void 0:h(r,q),D=(q,Y)=>{x(!0),m==null||m(A,r,M.type),B==null||B(q,Y)};nm.onPointerDown(A.nativeEvent,{autoPanOnConnect:j,connectionMode:O,connectionRadius:P,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:I,cancelConnection:U,panBy:F,isValidConnection:(...q)=>{var Y,N;return((N=(Y=w.getState()).isValidConnection)==null?void 0:N.call(Y,...q))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...q)=>{var Y,N;return(N=(Y=w.getState()).onConnectEnd)==null?void 0:N.call(Y,...q)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},_=A=>k(A,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),S=A=>k(A,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),C=()=>b(!0),E=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(mb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:_,onMouseEnter:C,onMouseOut:E,type:"source"}),(e===!0||e==="target")&&y.jsx(mb,{position:d,centerX:o,centerY:u,radius:t,onMouseDown:S,onMouseEnter:C,onMouseOut:E,type:"target"})]})}function kM({id:e,edgesFocusable:t,edgesReconnectable:r,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,rfId:w,edgeTypes:k,noPanClassName:_,onError:S,disableKeyboardA11y:C}){let E=Ye(ye=>ye.edgeLookup.get(e));const A=Ye(ye=>ye.defaultEdgeOptions);E=A?{...A,...E}:E;let M=E.type||"default",j=(k==null?void 0:k[M])||db[M];j===void 0&&(S==null||S("011",lr.error011(M)),M="default",j=(k==null?void 0:k.default)||db.default);const L=!!(E.focusable||t&&typeof E.focusable>"u"),O=typeof p<"u"&&(E.reconnectable||r&&typeof E.reconnectable>"u"),P=!!(E.selectable||l&&typeof E.selectable>"u"),H=V.useRef(null),[B,U]=V.useState(!1),[ee,I]=V.useState(!1),F=mt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y}=Ye(V.useCallback(ye=>{const pe=ye.nodeLookup.get(E.source),_e=ye.nodeLookup.get(E.target);if(!pe||!_e)return{zIndex:E.zIndex,...hb};const ze=pA({id:e,sourceNode:pe,targetNode:_e,sourceHandle:E.sourceHandle||null,targetHandle:E.targetHandle||null,connectionMode:ye.connectionMode,onError:S});return{zIndex:aA({selected:E.selected,zIndex:E.zIndex,sourceNode:pe,targetNode:_e,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...ze||hb}},[E.source,E.target,E.sourceHandle,E.targetHandle,E.selected,E.zIndex]),pt),N=V.useMemo(()=>E.markerStart?`url('#${em(E.markerStart,w)}')`:void 0,[E.markerStart,w]),$=V.useMemo(()=>E.markerEnd?`url('#${em(E.markerEnd,w)}')`:void 0,[E.markerEnd,w]);if(E.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var Te;const{addSelectedEdges:pe,unselectNodesAndEdges:_e,multiSelectionActive:ze}=F.getState();P&&(F.setState({nodesSelectionActive:!1}),E.selected&&ze?(_e({nodes:[],edges:[E]}),(Te=H.current)==null||Te.blur()):pe([e])),a&&a(ye,E)},J=o?ye=>{o(ye,{...E})}:void 0,ne=u?ye=>{u(ye,{...E})}:void 0,re=c?ye=>{c(ye,{...E})}:void 0,se=d?ye=>{d(ye,{...E})}:void 0,xe=h?ye=>{h(ye,{...E})}:void 0,be=ye=>{var pe;if(!C&&yS.includes(ye.key)&&P){const{unselectNodesAndEdges:_e,addSelectedEdges:ze}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),_e({edges:[E]})):ze([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:At(["react-flow__edge",`react-flow__edge-${M}`,E.className,_,{selected:E.selected,animated:E.animated,inactive:!P&&!a,updating:B,selectable:P}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:se,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:E.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":E.ariaLabel===null?void 0:E.ariaLabel||`Edge from ${E.source} to ${E.target}`,"aria-describedby":L?`${QS}-${w}`:void 0,ref:H,...E.domAttributes,children:[!ee&&y.jsx(j,{id:e,source:E.source,target:E.target,type:E.type,selected:E.selected,animated:E.animated,selectable:P,deletable:E.deletable??!0,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,data:E.data,style:E.style,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerStart:N,markerEnd:$,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth}),O&&y.jsx(_M,{edge:E,isReconnectable:O,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,setUpdateHover:U,setReconnecting:I})]})})}var EM=V.memo(kM);const NM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function w_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:k}){const{edgesFocusable:_,edgesReconnectable:S,elementsSelectable:C,onError:E}=Ye(NM,pt),A=cM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(mM,{defaultColor:e,rfId:r}),A.map(M=>y.jsx(EM,{id:M,edgesFocusable:_,edgesReconnectable:S,elementsSelectable:C,noPanClassName:a,onReconnect:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:p,onDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,rfId:r,onError:E,edgeTypes:l,disableKeyboardA11y:k},M))]})}w_.displayName="EdgeRenderer";const CM=V.memo(w_),TM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function jM({children:e}){const t=Ye(TM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function AM(e){const t=al(),r=V.useRef(!1);V.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const zM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function MM(e){const t=Ye(zM),r=mt();return V.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function DM(e){return e.connection.inProgress?{...e.connection,to:ns(e.connection.to,e.transform)}:{...e.connection}}function RM(e){return DM}function OM(e){const t=RM();return Ye(t,pt)}const LM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function HM({containerStyle:e,style:t,type:r,component:l}){const{nodesConnectable:a,width:o,height:u,isValid:c,inProgress:d}=Ye(LM,pt);return!(o&&a&&d)?null:y.jsx("svg",{style:e,width:o,height:u,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:At(["react-flow__connection",wS(c)]),children:y.jsx(S_,{style:t,type:r,CustomComponent:l,isValid:c})})})}const S_=({style:e,type:t=xi.Bezier,CustomComponent:r,isValid:l})=>{const{inProgress:a,from:o,fromNode:u,fromHandle:c,fromPosition:d,to:h,toNode:m,toHandle:p,toPosition:x,pointer:b}=OM();if(!a)return;if(r)return y.jsx(r,{connectionLineType:t,connectionLineStyle:e,fromNode:u,fromHandle:c,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:x,connectionStatus:wS(l),toNode:m,toHandle:p,pointer:b});let w="";const k={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:x};switch(t){case xi.Bezier:[w]=Dm(k);break;case xi.SimpleBezier:[w]=u_(k);break;case xi.Step:[w]=Wp({...k,borderRadius:0});break;case xi.SmoothStep:[w]=Wp(k);break;default:[w]=RS(k)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};S_.displayName="ConnectionLine";const BM={};function gb(e=BM){V.useRef(e),mt(),V.useEffect(()=>{},[e])}function IM(){mt(),V.useRef(!1),V.useEffect(()=>{},[])}function __({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:x,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:k,connectionLineComponent:_,connectionLineContainerStyle:S,selectionKeyCode:C,selectionOnDrag:E,selectionMode:A,multiSelectionKeyCode:M,panActivationKeyCode:j,zoomActivationKeyCode:L,deleteKeyCode:O,onlyRenderVisibleElements:P,elementsSelectable:H,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:N,onPaneClick:$,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:_e,onEdgeMouseLeave:ze,reconnectRadius:Te,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,noDragClassName:Pt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr,viewport:ue,onViewportChange:ge}){return gb(e),gb(t),IM(),AM(r),MM(ue),y.jsx(eM,{onPaneClick:$,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:O,selectionKeyCode:C,selectionOnDrag:E,selectionMode:A,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:j,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,panOnDrag:N,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Pt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,onViewportChange:ge,isControlledViewport:!!ue,children:y.jsxs(jM,{children:[y.jsx(CM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:u,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,onlyRenderVisibleElements:P,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:_e,onEdgeMouseLeave:ze,reconnectRadius:Te,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:Hr}),y.jsx(HM,{style:k,type:w,component:_,containerStyle:S}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(uM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:P,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}__.displayName="GraphView";const qM=V.memo(__),xb=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:p,zIndexMode:x="basic"}={})=>{const b=new Map,w=new Map,k=new Map,_=new Map,S=l??t??[],C=r??e??[],E=m??[0,0],A=p??Vo;HS(k,_,S);const M=tm(C,b,w,{nodeOrigin:E,nodeExtent:A,zIndexMode:x});let j=[0,0,1];if(u&&a&&o){const L=es(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:O,y:P,zoom:H}=zm(L,a,o,d,h,(c==null?void 0:c.padding)??.1);j=[O,P,H]}return{rfId:"1",width:a??0,height:o??0,transform:j,nodes:C,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:S,edgeLookup:_,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:Vo,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ha.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:E,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:u??!1,fitViewOptions:c,fitViewResolver:null,connection:{...bS},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:eA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:vS,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},UM=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x})=>iz((b,w)=>{async function k(){const{nodeLookup:_,panZoom:S,fitViewOptions:C,fitViewResolver:E,width:A,height:M,minZoom:j,maxZoom:L}=w();S&&(await Jj({nodes:_,width:A,height:M,panZoom:S,minZoom:j,maxZoom:L},C),E==null||E.resolve(!0),b({fitViewResolver:null}))}return{...xb({nodes:e,edges:t,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,defaultNodes:r,defaultEdges:l,zIndexMode:x}),setNodes:_=>{const{nodeLookup:S,parentLookup:C,nodeOrigin:E,elevateNodesOnSelect:A,fitViewQueued:M,zIndexMode:j}=w(),L=tm(_,S,C,{nodeOrigin:E,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:j});M&&L?(k(),b({nodes:_,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:_,nodesInitialized:L})},setEdges:_=>{const{connectionLookup:S,edgeLookup:C}=w();HS(S,C,_),b({edges:_})},setDefaultNodesAndEdges:(_,S)=>{if(_){const{setNodes:C}=w();C(_),b({hasDefaultNodes:!0})}if(S){const{setEdges:C}=w();C(S),b({hasDefaultEdges:!0})}},updateNodeInternals:_=>{const{triggerNodeChanges:S,nodeLookup:C,parentLookup:E,domNode:A,nodeOrigin:M,nodeExtent:j,debug:L,fitViewQueued:O,zIndexMode:P}=w(),{changes:H,updatedInternals:B}=SA(_,C,E,A,M,j,P);B&&(yA(C,E,{nodeOrigin:M,nodeExtent:j,zIndexMode:P}),O?(k(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),S==null||S(H)))},updateNodePositions:(_,S=!1)=>{const C=[];let E=[];const{nodeLookup:A,triggerNodeChanges:M,connection:j,updateConnection:L,onNodesChangeMiddlewareMap:O}=w();for(const[P,H]of _){const B=A.get(P),U=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:P,type:"position",position:U?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:S};if(B&&j.inProgress&&j.fromNode.id===B.id){const I=tl(B,j.fromHandle,ve.Left,!0);L({...j,from:I})}U&&B.parentId&&C.push({id:P,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),E.push(ee)}if(C.length>0){const{parentLookup:P,nodeOrigin:H}=w(),B=Bm(C,A,P,H);E.push(...B)}for(const P of O.values())E=P(E);M(E)},triggerNodeChanges:_=>{const{onNodesChange:S,setNodes:C,nodes:E,hasDefaultNodes:A,debug:M}=w();if(_!=null&&_.length){if(A){const j=JS(_,E);C(j)}M&&console.log("React Flow: trigger node changes",_),S==null||S(_)}},triggerEdgeChanges:_=>{const{onEdgesChange:S,setEdges:C,edges:E,hasDefaultEdges:A,debug:M}=w();if(_!=null&&_.length){if(A){const j=WS(_,E);C(j)}M&&console.log("React Flow: trigger edge changes",_),S==null||S(_)}},addSelectedNodes:_=>{const{multiSelectionActive:S,edgeLookup:C,nodeLookup:E,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(S){const j=_.map(L=>$i(L,!0));A(j);return}A(ia(E,new Set([..._]),!0)),M(ia(C))},addSelectedEdges:_=>{const{multiSelectionActive:S,edgeLookup:C,nodeLookup:E,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(S){const j=_.map(L=>$i(L,!0));M(j);return}M(ia(C,new Set([..._]))),A(ia(E,new Set,!0))},unselectNodesAndEdges:({nodes:_,edges:S}={})=>{const{edges:C,nodes:E,nodeLookup:A,triggerNodeChanges:M,triggerEdgeChanges:j}=w(),L=_||E,O=S||C,P=[];for(const B of L){if(!B.selected)continue;const U=A.get(B.id);U&&(U.selected=!1),P.push($i(B.id,!1))}const H=[];for(const B of O)B.selected&&H.push($i(B.id,!1));M(P),j(H)},setMinZoom:_=>{const{panZoom:S,maxZoom:C}=w();S==null||S.setScaleExtent([_,C]),b({minZoom:_})},setMaxZoom:_=>{const{panZoom:S,minZoom:C}=w();S==null||S.setScaleExtent([C,_]),b({maxZoom:_})},setTranslateExtent:_=>{var S;(S=w().panZoom)==null||S.setTranslateExtent(_),b({translateExtent:_})},resetSelectedElements:()=>{const{edges:_,nodes:S,triggerNodeChanges:C,triggerEdgeChanges:E,elementsSelectable:A}=w();if(!A)return;const M=S.reduce((L,O)=>O.selected?[...L,$i(O.id,!1)]:L,[]),j=_.reduce((L,O)=>O.selected?[...L,$i(O.id,!1)]:L,[]);C(M),E(j)},setNodeExtent:_=>{const{nodes:S,nodeLookup:C,parentLookup:E,nodeOrigin:A,elevateNodesOnSelect:M,nodeExtent:j,zIndexMode:L}=w();_[0][0]===j[0][0]&&_[0][1]===j[0][1]&&_[1][0]===j[1][0]&&_[1][1]===j[1][1]||(tm(S,C,E,{nodeOrigin:A,nodeExtent:_,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:_}))},panBy:_=>{const{transform:S,width:C,height:E,panZoom:A,translateExtent:M}=w();return _A({delta:_,panZoom:A,transform:S,translateExtent:M,width:C,height:E})},setCenter:async(_,S,C)=>{const{width:E,height:A,maxZoom:M,panZoom:j}=w();if(!j)return Promise.resolve(!1);const L=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:M;return await j.setViewport({x:E/2-_*L,y:A/2-S*L,zoom:L},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...bS}})},updateConnection:_=>{b({connection:_})},reset:()=>b({...xb()})}},Object.is);function VM({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:u,initialMaxZoom:c,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x,children:b}){const[w]=V.useState(()=>UM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:h,minZoom:u,maxZoom:c,fitViewOptions:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x}));return y.jsx(az,{value:w,children:y.jsx(jz,{children:b})})}function PM({children:e,nodes:t,edges:r,defaultNodes:l,defaultEdges:a,width:o,height:u,fitView:c,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b}){return V.useContext(Oc)?y.jsx(y.Fragment,{children:e}):y.jsx(VM,{initialNodes:t,initialEdges:r,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:u,fitView:c,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b,children:e})}const $M={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function GM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:u,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:p,onMoveEnd:x,onConnect:b,onConnectStart:w,onConnectEnd:k,onClickConnectStart:_,onClickConnectEnd:S,onNodeMouseEnter:C,onNodeMouseMove:E,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:j,onNodeDragStart:L,onNodeDrag:O,onNodeDragStop:P,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onSelectionChange:ee,onSelectionDragStart:I,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:q,connectionLineType:Y=xi.Bezier,connectionLineStyle:N,connectionLineComponent:$,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Po.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Go()?"Meta":"Control",zoomActivationKeyCode:ye=Go()?"Meta":"Control",snapToGrid:pe,snapGrid:_e,onlyRenderVisibleElements:ze=!1,selectNodesOnDrag:Te,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Pt,nodeOrigin:Ht=ZS,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt=!0,defaultViewport:Hr=vz,minZoom:ue=.5,maxZoom:ge=2,translateExtent:Ne=Vo,preventScrolling:Oe=!0,nodeExtent:Xe,defaultMarkerColor:Qt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:Bt=!0,panOnScroll:vt=!1,panOnScrollSpeed:$t=.5,panOnScrollMode:We=Zi.Free,zoomOnDoubleClick:Qn=!0,panOnDrag:fn=!0,onPaneClick:Fc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi=1,nodeClickDistance:Yc=0,children:ss,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Xc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:Sa,onEdgeMouseLeave:_a,reconnectRadius:ds=10,onNodesChange:hs,onEdgesChange:Zn,noDragClassName:Dt="nodrag",noWheelClassName:Gt="nowheel",noPanClassName:ur="nopan",fitView:pl,fitViewOptions:ps,connectOnClick:Qc,attributionPosition:ms,proOptions:Si,defaultEdgeOptions:ka,elevateNodesOnSelect:Br=!0,elevateEdgesOnSelect:Ir=!1,disableKeyboardA11y:qr=!1,autoPanOnConnect:Ur,autoPanOnNodeDrag:St,autoPanSpeed:gs,connectionRadius:xs,isValidConnection:cr,onError:Vr,style:Zc,id:Ea,nodeDragThreshold:ys,connectionDragThreshold:Kc,viewport:ml,onViewportChange:gl,width:Ln,height:Wt,colorMode:vs="light",debug:Jc,onScroll:Pr,ariaLabelConfig:bs,zIndexMode:_i="basic",...Wc},en){const ki=Ea||"1",ws=_z(vs),Na=V.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pr==null||Pr(fr)},[Pr]);return y.jsx("div",{"data-testid":"rf__wrapper",...Wc,onScroll:Na,style:{...Zc,...$M},ref:en,className:At(["react-flow",a,ws]),id:Ea,role:"application",children:y.jsxs(PM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:pl,fitViewOptions:ps,minZoom:ue,maxZoom:ge,nodeOrigin:Ht,nodeExtent:Xe,zIndexMode:_i,children:[y.jsx(qM,{onInit:h,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:C,onNodeMouseMove:E,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:j,nodeTypes:o,edgeTypes:u,connectionLineType:Y,connectionLineStyle:N,connectionLineComponent:$,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:ze,defaultViewport:Hr,translateExtent:Ne,minZoom:ue,maxZoom:ge,preventScrolling:Oe,zoomOnScroll:On,zoomOnPinch:Bt,zoomOnDoubleClick:Qn,panOnScroll:vt,panOnScrollSpeed:$t,panOnScrollMode:We,panOnDrag:fn,onPaneClick:Fc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi,nodeClickDistance:Yc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Xc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:Sa,onEdgeMouseLeave:_a,reconnectRadius:ds,defaultMarkerColor:Qt,noDragClassName:Dt,noWheelClassName:Gt,noPanClassName:ur,rfId:ki,disableKeyboardA11y:qr,nodeExtent:Xe,viewport:ml,onViewportChange:gl}),y.jsx(Sz,{nodes:e,edges:t,defaultNodes:r,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:k,onClickConnectStart:_,onClickConnectEnd:S,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt,elevateNodesOnSelect:Br,elevateEdgesOnSelect:Ir,minZoom:ue,maxZoom:ge,nodeExtent:Xe,onNodesChange:hs,onEdgesChange:Zn,snapToGrid:pe,snapGrid:_e,connectionMode:q,translateExtent:Ne,connectOnClick:Qc,defaultEdgeOptions:ka,fitView:pl,fitViewOptions:ps,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onNodeDragStart:L,onNodeDrag:O,onNodeDragStop:P,onSelectionDrag:F,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:x,noPanClassName:ur,nodeOrigin:Ht,rfId:ki,autoPanOnConnect:Ur,autoPanOnNodeDrag:St,autoPanSpeed:gs,onError:Vr,connectionRadius:xs,isValidConnection:cr,selectNodesOnDrag:Te,nodeDragThreshold:ys,connectionDragThreshold:Kc,onBeforeDelete:D,debug:Jc,ariaLabelConfig:bs,zIndexMode:_i}),y.jsx(yz,{onSelectionChange:ee}),ss,y.jsx(hz,{proOptions:Si,position:ms}),y.jsx(dz,{rfId:ki,disableKeyboardA11y:qr})]})})}var FM=e_(GM);const YM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function XM({children:e}){const t=Ye(YM);return t?lz.createPortal(e,t):null}function QM(e){const[t,r]=V.useState(e),l=V.useCallback(a=>r(o=>JS(a,o)),[]);return[t,r,l]}function ZM(e){const[t,r]=V.useState(e),l=V.useCallback(a=>r(o=>WS(a,o)),[]);return[t,r,l]}function KM({dimensions:e,lineWidth:t,variant:r,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:At(["react-flow__background-pattern",r,l])})}function JM({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:At(["react-flow__background-pattern","dots",t])})}var Mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Mr||(Mr={}));const WM={[Mr.Dots]:1,[Mr.Lines]:1,[Mr.Cross]:6},e5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function k_({id:e,variant:t=Mr.Dots,gap:r=20,size:l,lineWidth:a=1,offset:o=0,color:u,bgColor:c,style:d,className:h,patternClassName:m}){const p=V.useRef(null),{transform:x,patternId:b}=Ye(e5,pt),w=l||WM[t],k=t===Mr.Dots,_=t===Mr.Cross,S=Array.isArray(r)?r:[r,r],C=[S[0]*x[2]||1,S[1]*x[2]||1],E=w*x[2],A=Array.isArray(o)?o:[o,o],M=_?[E,E]:C,j=[A[0]*x[2]||1+M[0]/2,A[1]*x[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:At(["react-flow__background",h]),style:{...d,...Hc,"--xy-background-color-props":c,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:x[0]%C[0],y:x[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:k?y.jsx(JM,{radius:E/2,className:m}):y.jsx(KM,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}k_.displayName="Background";const t5=V.memo(k_);function n5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function r5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function i5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function l5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function $u({children:e,className:t,...r}){return y.jsx("button",{type:"button",className:At(["react-flow__controls-button",t]),...r,children:e})}const o5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function E_({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:u,onFitView:c,onInteractiveChange:d,className:h,children:m,position:p="bottom-left",orientation:x="vertical","aria-label":b}){const w=mt(),{isInteractive:k,minZoomReached:_,maxZoomReached:S,ariaLabelConfig:C}=Ye(o5,pt),{zoomIn:E,zoomOut:A,fitView:M}=al(),j=()=>{E(),o==null||o()},L=()=>{A(),u==null||u()},O=()=>{M(a),c==null||c()},P=()=>{w.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d==null||d(!k)},H=x==="horizontal"?"horizontal":"vertical";return y.jsxs(Lc,{className:At(["react-flow__controls",H,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??C["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx($u,{onClick:j,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:S,children:y.jsx(n5,{})}),y.jsx($u,{onClick:L,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:_,children:y.jsx(r5,{})})]}),r&&y.jsx($u,{className:"react-flow__controls-fitview",onClick:O,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:y.jsx(i5,{})}),l&&y.jsx($u,{className:"react-flow__controls-interactive",onClick:P,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:k?y.jsx(a5,{}):y.jsx(l5,{})}),m]})}E_.displayName="Controls";const s5=V.memo(E_);function u5({id:e,x:t,y:r,width:l,height:a,style:o,color:u,strokeColor:c,strokeWidth:d,className:h,borderRadius:m,shapeRendering:p,selected:x,onClick:b}){const{background:w,backgroundColor:k}=o||{},_=u||w||k;return y.jsx("rect",{className:At(["react-flow__minimap-node",{selected:x},h]),x:t,y:r,rx:m,ry:m,width:l,height:a,style:{fill:_,stroke:c,strokeWidth:d},shapeRendering:p,onClick:b?S=>b(S,e):void 0})}const c5=V.memo(u5),f5=e=>e.nodes.map(t=>t.id),Th=e=>e instanceof Function?e:()=>e;function d5({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=c5,onClick:u}){const c=Ye(f5,pt),d=Th(t),h=Th(e),m=Th(r),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(x=>y.jsx(p5,{id:x,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:u,shapeRendering:p},x))})}function h5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:r,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:u,NodeComponent:c,onClick:d}){const{node:h,x:m,y:p,width:x,height:b}=Ye(w=>{const k=w.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const _=k.internals.userNode,{x:S,y:C}=k.internals.positionAbsolute,{width:E,height:A}=Or(_);return{node:_,x:S,y:C,width:E,height:A}},pt);return!h||h.hidden||!CS(h)?null:y.jsx(c,{x:m,y:p,width:x,height:b,style:h.style,selected:!!h.selected,className:l(h),color:t(h),borderRadius:a,strokeColor:r(h),strokeWidth:o,shapeRendering:u,onClick:d,id:h.id})}const p5=V.memo(h5);var m5=V.memo(d5);const g5=200,x5=150,y5=e=>!e.hidden,v5=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?NS(es(e.nodeLookup,{filter:y5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},b5="react-flow__minimap-desc";function N_({style:e,className:t,nodeStrokeColor:r,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:u,nodeComponent:c,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:p,position:x="bottom-right",onClick:b,onNodeClick:w,pannable:k=!1,zoomable:_=!1,ariaLabel:S,inversePan:C,zoomStep:E=1,offsetScale:A=5}){const M=mt(),j=V.useRef(null),{boundingRect:L,viewBB:O,rfId:P,panZoom:H,translateExtent:B,flowWidth:U,flowHeight:ee,ariaLabelConfig:I}=Ye(v5,pt),F=(e==null?void 0:e.width)??g5,z=(e==null?void 0:e.height)??x5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,q=K*z,Y=A*K,N=L.x-(D-L.width)/2-Y,$=L.y-(q-L.height)/2-Y,X=D+Y*2,J=q+Y*2,ne=`${b5}-${P}`,re=V.useRef(0),se=V.useRef();re.current=K,V.useEffect(()=>{if(j.current&&H)return se.current=MA({domNode:j.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[H]),V.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:B,width:U,height:ee,inversePan:C,pannable:k,zoomStep:E,zoomable:_})},[k,_,C,E,B,U,ee]);const xe=b?pe=>{var Te;const[_e,ze]=((Te=se.current)==null?void 0:Te.pointer(pe))||[0,0];b(pe,{x:_e,y:ze})}:void 0,be=w?V.useCallback((pe,_e)=>{const ze=M.getState().nodeLookup.get(_e).internals.userNode;w(pe,ze)},[]):void 0,ye=S??I["minimap.ariaLabel"];return y.jsx(Lc,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof u=="number"?u:void 0},className:At(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${N} ${$} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:j,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(m5,{onClick:be,nodeColor:l,nodeStrokeColor:r,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:u,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${N-Y},${$-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z - M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}N_.displayName="MiniMap";const w5=V.memo(N_),S5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_5={[xa.Line]:"right",[xa.Handle]:"bottom-right"};function k5({nodeId:e,position:t,variant:r=xa.Handle,className:l,style:a=void 0,children:o,color:u,minWidth:c=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:x,autoScale:b=!0,shouldResize:w,onResizeStart:k,onResize:_,onResizeEnd:S}){const C=i_(),E=typeof e=="string"?e:C,A=mt(),M=V.useRef(null),j=r===xa.Handle,L=Ye(V.useCallback(S5(j&&b),[j,b]),pt),O=V.useRef(null),P=t??_5[r];V.useEffect(()=>{if(!(!M.current||!E))return O.current||(O.current=FA({domNode:M.current,nodeId:E,getStoreItems:()=>{const{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,domNode:z}=A.getState();return{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,paneDomNode:z}},onChange:(B,U)=>{const{triggerNodeChanges:ee,nodeLookup:I,parentLookup:F,nodeOrigin:z}=A.getState(),G=[],Q={x:B.x,y:B.y},K=I.get(E);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,q=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,N={id:K.id,parentId:K.parentId,rect:{width:q,height:Y,...TS({x:B.x??K.position.x,y:B.y??K.position.y},{width:q,height:Y},K.parentId,I,D)}},$=Bm([N],I,F,z);G.push(...$),Q.x=B.x?Math.max(D[0]*q,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:E,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const q={id:E,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push(q)}for(const D of U){const q={...D,type:"position"};G.push(q)}ee(G)},onEnd:({width:B,height:U})=>{const ee={id:E,type:"dimensions",resizing:!1,dimensions:{width:B,height:U}};A.getState().triggerNodeChanges([ee])}})),O.current.update({controlPosition:P,boundaries:{minWidth:c,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:p,resizeDirection:x,onResizeStart:k,onResize:_,onResizeEnd:S,shouldResize:w}),()=>{var B;(B=O.current)==null||B.destroy()}},[P,c,d,h,m,p,k,_,S,w]);const H=P.split("-");return y.jsx("div",{className:At(["react-flow__resize-control","nodrag",...H,r,l]),ref:M,style:{...a,scale:L,...u&&{[j?"backgroundColor":"borderColor"]:u}},children:o})}V.memo(k5);function is(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;ll.viewContextPath),t=fe(l=>l.nodes),r=fe(l=>l.subworkflowContexts);return V.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.nodes)??t},[e,t,r])}function E5(){const e=fe(l=>l.viewContextPath),t=fe(l=>l.groupProgress),r=fe(l=>l.subworkflowContexts);return V.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.groupProgress)??t},[e,t,r])}function N5(){const e=fe(l=>l.viewContextPath),t=fe(l=>l.highlightedEdges),r=fe(l=>l.subworkflowContexts);return V.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.highlightedEdges)??t},[e,t,r])}function qm(){const e=fe(r=>r.viewContextPath),t=fe(r=>r.subworkflowContexts);return V.useMemo(()=>{var r;return e.length===0?t:((r=is(t,e))==null?void 0:r.children)??[]},[e,t])}function C5(){const e=fe(h=>h.viewContextPath),t=fe(h=>h.agents),r=fe(h=>h.routes),l=fe(h=>h.parallelGroups),a=fe(h=>h.forEachGroups),o=fe(h=>h.nodes),u=fe(h=>h.groupProgress),c=fe(h=>h.entryPoint),d=fe(h=>h.subworkflowContexts);return V.useMemo(()=>{if(e.length===0)return{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null};const h=is(d,e);return h?{agents:h.agents,routes:h.routes,parallelGroups:h.parallelGroups,forEachGroups:h.forEachGroups,nodes:h.nodes,groupProgress:h.groupProgress,entryPoint:h.entryPoint,subworkflowContexts:h.children,parentAgent:h.parentAgent}:{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null}},[e,t,r,l,a,o,u,c,d])}function T5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function yb(e,t){const r=[];let l=e;for(const a of t){let o=-1;for(let u=l.length-1;u>=0;u--)if(l[u].slotKey===a){o=u;break}if(o===-1){for(let u=l.length-1;u>=0;u--)if(l[u].parentAgent===a){o=u;break}}if(o===-1)return{path:r,failedSegment:a};r.push(o),l=l[o].children}return{path:r,failedSegment:null}}function im(e,t,r=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:u,ctx:o}),o.children.length>0&&l.push(...im(o.children,t,u))}return l}function j5(e){return e.length===0?null:[...e].sort((t,r)=>{const l=t.ctx.status==="running"?1:0,a=r.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==r.path.length)return r.path.length-t.path.length;for(let o=0;o{if(r.current||!u)return;let c=null,d=null,h=null;const m=()=>{if(r.current)return;r.current=!0,c&&clearTimeout(c),d&&clearTimeout(d),h&&h();const b=fe.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const k=a.split("/").filter(Boolean),_=yb(b.subworkflowContexts,k);if(_.failedSegment){const S=k.slice(0,_.path.length).join("/");t({message:`Subworkflow "${_.failedSegment}" not found${S?` (resolved: ${S})`:""}. It may not have started yet.`});return}w=_.path}if(o){if((w.length===0?b.agents:(()=>{let _,S=b.subworkflowContexts;for(const C of w){if(_=S[C],!_)break;S=_.children}return(_==null?void 0:_.agents)??[]})()).some(_=>_.name===o))fe.setState({viewContextPath:w,selectedNode:o});else{const _=im(b.subworkflowContexts,o);if(_.length===0){const C=a||"root workflow";fe.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${C}.`});return}if(a){const C=_.slice(0,5).map(A=>A5(b.subworkflowContexts,A.path)).join(", "),E=_.length>5?`, and ${_.length-5} more`:"";fe.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${C}${E}`});return}const S=j5(_);fe.setState({viewContextPath:S.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&fe.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=fe.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:k}=yb(b.subworkflowContexts,w);if(k)return!1}return!(o&&!a&&!b.agents.some(k=>k.name===o)&&im(b.subworkflowContexts,o).length===0)},x=()=>{c&&clearTimeout(c),c=setTimeout(()=>{r.current||p()&&m()},200)};return h=fe.subscribe(x),d=setTimeout(()=>{r.current||m()},5e3),x(),()=>{c&&clearTimeout(c),d&&clearTimeout(d),h&&h()}},[u,a,o,l]),e}var jh,vb;function Um(){if(vb)return jh;vb=1;var e="\0",t="\0",r="";class l{constructor(m){Ct(this,"_isDirected",!0);Ct(this,"_isMultigraph",!1);Ct(this,"_isCompound",!1);Ct(this,"_label");Ct(this,"_defaultNodeLabelFn",()=>{});Ct(this,"_defaultEdgeLabelFn",()=>{});Ct(this,"_nodes",{});Ct(this,"_in",{});Ct(this,"_preds",{});Ct(this,"_out",{});Ct(this,"_sucs",{});Ct(this,"_edgeObjs",{});Ct(this,"_edgeLabels",{});Ct(this,"_nodeCount",0);Ct(this,"_edgeCount",0);Ct(this,"_parent");Ct(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var x=arguments,b=this;return m.forEach(function(w){x.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var x=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(x),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(x),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var x=p;x!==void 0;x=this.parent(x))if(x===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var x of this.successors(m))b.add(x);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var x=this;Object.entries(this._nodes).forEach(function([k,_]){m(k)&&p.setNode(k,_)}),Object.values(this._edgeObjs).forEach(function(k){p.hasNode(k.v)&&p.hasNode(k.w)&&p.setEdge(k,x.edge(k))});var b={};function w(k){var _=x.parent(k);return _===void 0||p.hasNode(_)?(b[k]=_,_):_ in b?b[_]:w(_)}return this._isCompound&&p.nodes().forEach(k=>p.setParent(k,w(k))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var x=this,b=arguments;return m.reduce(function(w,k){return b.length>1?x.setEdge(w,k,p):x.setEdge(w,k),k}),this}setEdge(){var m,p,x,b,w=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(m=k.v,p=k.w,x=k.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=k,p=arguments[1],x=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,x!==void 0&&(x=""+x);var _=u(this._isDirected,m,p,x);if(Object.hasOwn(this._edgeLabels,_))return w&&(this._edgeLabels[_]=b),this;if(x!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[_]=w?b:this._defaultEdgeLabelFn(m,p,x);var S=c(this._isDirected,m,p,x);return m=S.v,p=S.w,Object.freeze(S),this._edgeObjs[_]=S,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][_]=S,this._out[m][_]=S,this._edgeCount++,this}edge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var x=this._in[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var x=this._out[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var x=this.inEdges(m,p);if(x)return x.concat(this.outEdges(m,p))}}function a(h,m){h[m]?h[m]++:h[m]=1}function o(h,m){--h[m]||delete h[m]}function u(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var k=b;b=w,w=k}return b+r+w+r+(x===void 0?e:x)}function c(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var k=b;b=w,w=k}var _={v:b,w};return x&&(_.name=x),_}function d(h,m){return u(h,m.v,m.w,m.name)}return jh=l,jh}var Ah,bb;function M5(){return bb||(bb=1,Ah="2.2.4"),Ah}var zh,wb;function D5(){return wb||(wb=1,zh={Graph:Um(),version:M5()}),zh}var Mh,Sb;function R5(){if(Sb)return Mh;Sb=1;var e=Um();Mh={write:t,read:a};function t(o){var u={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:l(o)};return o.graph()!==void 0&&(u.value=structuredClone(o.graph())),u}function r(o){return o.nodes().map(function(u){var c=o.node(u),d=o.parent(u),h={v:u};return c!==void 0&&(h.value=c),d!==void 0&&(h.parent=d),h})}function l(o){return o.edges().map(function(u){var c=o.edge(u),d={v:u.v,w:u.w};return u.name!==void 0&&(d.name=u.name),c!==void 0&&(d.value=c),d})}function a(o){var u=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){u.setNode(c.v,c.value),c.parent&&u.setParent(c.v,c.parent)}),o.edges.forEach(function(c){u.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),u}return Mh}var Dh,_b;function O5(){if(_b)return Dh;_b=1,Dh=e;function e(t){var r={},l=[],a;function o(u){Object.hasOwn(r,u)||(r[u]=!0,a.push(u),t.successors(u).forEach(o),t.predecessors(u).forEach(o))}return t.nodes().forEach(function(u){a=[],o(u),a.length&&l.push(a)}),l}return Dh}var Rh,kb;function C_(){if(kb)return Rh;kb=1;class e{constructor(){Ct(this,"_arr",[]);Ct(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(r){return r.key})}has(r){return Object.hasOwn(this._keyIndices,r)}priority(r){var l=this._keyIndices[r];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(r,l){var a=this._keyIndices;if(r=String(r),!Object.hasOwn(a,r)){var o=this._arr,u=o.length;return a[r]=u,o.push({key:r,priority:l}),this._decrease(u),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key}decrease(r,l){var a=this._keyIndices[r];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(r){var l=this._arr,a=2*r,o=a+1,u=r;a>1,!(l[o].priority1;function r(a,o,u,c){return l(a,String(o),u||t,c||function(d){return a.outEdges(d)})}function l(a,o,u,c){var d={},h=new e,m,p,x=function(b){var w=b.v!==m?b.v:b.w,k=d[w],_=u(b),S=p.distance+_;if(_<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+_);S0&&(m=h.removeMin(),p=d[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(x);return d}return Oh}var Lh,Nb;function L5(){if(Nb)return Lh;Nb=1;var e=T_();Lh=t;function t(r,l,a){return r.nodes().reduce(function(o,u){return o[u]=e(r,u,l,a),o},{})}return Lh}var Hh,Cb;function j_(){if(Cb)return Hh;Cb=1,Hh=e;function e(t){var r=0,l=[],a={},o=[];function u(c){var d=a[c]={onStack:!0,lowlink:r,index:r++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(d.lowlink=Math.min(d.lowlink,a[p].index)):(u(p),d.lowlink=Math.min(d.lowlink,a[p].lowlink))}),d.lowlink===d.index){var h=[],m;do m=l.pop(),a[m].onStack=!1,h.push(m);while(c!==m);o.push(h)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||u(c)}),o}return Hh}var Bh,Tb;function H5(){if(Tb)return Bh;Tb=1;var e=j_();Bh=t;function t(r){return e(r).filter(function(l){return l.length>1||l.length===1&&r.hasEdge(l[0],l[0])})}return Bh}var Ih,jb;function B5(){if(jb)return Ih;jb=1,Ih=t;var e=()=>1;function t(l,a,o){return r(l,a||e,o||function(u){return l.outEdges(u)})}function r(l,a,o){var u={},c=l.nodes();return c.forEach(function(d){u[d]={},u[d][d]={distance:0},c.forEach(function(h){d!==h&&(u[d][h]={distance:Number.POSITIVE_INFINITY})}),o(d).forEach(function(h){var m=h.v===d?h.w:h.v,p=a(h);u[d][m]={distance:p,predecessor:d}})}),c.forEach(function(d){var h=u[d];c.forEach(function(m){var p=u[m];c.forEach(function(x){var b=p[d],w=h[x],k=p[x],_=b.distance+w.distance;_a.successors(p):p=>a.neighbors(p),d=u==="post"?t:r,h=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);d(p,c,m,h)}),h}function t(a,o,u,c){for(var d=[[a,!1]];d.length>0;){var h=d.pop();h[1]?c.push(h[0]):Object.hasOwn(u,h[0])||(u[h[0]]=!0,d.push([h[0],!0]),l(o(h[0]),m=>d.push([m,!1])))}}function r(a,o,u,c){for(var d=[a];d.length>0;){var h=d.pop();Object.hasOwn(u,h)||(u[h]=!0,c.push(h),l(o(h),m=>d.push(m)))}}function l(a,o){for(var u=a.length;u--;)o(a[u],u,a);return a}return Vh}var Ph,Db;function q5(){if(Db)return Ph;Db=1;var e=z_();Ph=t;function t(r,l){return e(r,l,"post")}return Ph}var $h,Rb;function U5(){if(Rb)return $h;Rb=1;var e=z_();$h=t;function t(r,l){return e(r,l,"pre")}return $h}var Gh,Ob;function V5(){if(Ob)return Gh;Ob=1;var e=Um(),t=C_();Gh=r;function r(l,a){var o=new e,u={},c=new t,d;function h(p){var x=p.v===d?p.w:p.v,b=c.priority(x);if(b!==void 0){var w=a(p);w0;){if(d=c.removeMin(),Object.hasOwn(u,d))o.setEdge(d,u[d]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(d).forEach(h)}return o}return Gh}var Fh,Lb;function P5(){return Lb||(Lb=1,Fh={components:O5(),dijkstra:T_(),dijkstraAll:L5(),findCycles:H5(),floydWarshall:B5(),isAcyclic:I5(),postorder:q5(),preorder:U5(),prim:V5(),tarjan:j_(),topsort:A_()}),Fh}var Yh,Hb;function Yn(){if(Hb)return Yh;Hb=1;var e=D5();return Yh={Graph:e.Graph,json:R5(),alg:P5(),version:e.version},Yh}var Xh,Bb;function $5(){if(Bb)return Xh;Bb=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,u=o._prev;for(;u!==o;)a.push(JSON.stringify(u,r)),u=u._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function r(l,a){if(l!=="_next"&&l!=="_prev")return a}return Xh=e,Xh}var Qh,Ib;function G5(){if(Ib)return Qh;Ib=1;let e=Yn().Graph,t=$5();Qh=l;let r=()=>1;function l(h,m){if(h.nodeCount()<=1)return[];let p=u(h,m||r);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>h.outEdges(b.v,b.w))}function a(h,m,p){let x=[],b=m[m.length-1],w=m[0],k;for(;h.nodeCount();){for(;k=w.dequeue();)o(h,m,p,k);for(;k=b.dequeue();)o(h,m,p,k);if(h.nodeCount()){for(let _=m.length-2;_>0;--_)if(k=m[_].dequeue(),k){x=x.concat(o(h,m,p,k,!0));break}}}return x}function o(h,m,p,x,b){let w=b?[]:void 0;return h.inEdges(x.v).forEach(k=>{let _=h.edge(k),S=h.node(k.v);b&&w.push({v:k.v,w:k.w}),S.out-=_,c(m,p,S)}),h.outEdges(x.v).forEach(k=>{let _=h.edge(k),S=k.w,C=h.node(S);C.in-=_,c(m,p,C)}),h.removeNode(x.v),w}function u(h,m){let p=new e,x=0,b=0;h.nodes().forEach(_=>{p.setNode(_,{v:_,in:0,out:0})}),h.edges().forEach(_=>{let S=p.edge(_.v,_.w)||0,C=m(_),E=S+C;p.setEdge(_.v,_.w,E),b=Math.max(b,p.node(_.v).out+=C),x=Math.max(x,p.node(_.w).in+=C)});let w=d(b+x+3).map(()=>new t),k=x+1;return p.nodes().forEach(_=>{c(w,k,p.node(_))}),{graph:p,buckets:w,zeroIdx:k}}function c(h,m,p){p.out?p.in?h[p.out-p.in+m].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}function d(h){const m=[];for(let p=0;pP.setNode(H,O.node(H))),O.edges().forEach(H=>{let B=P.edge(H.v,H.w)||{weight:0,minlen:1},U=O.edge(H);P.setEdge(H.v,H.w,{weight:B.weight+U.weight,minlen:Math.max(B.minlen,U.minlen)})}),P}function l(O){let P=new e({multigraph:O.isMultigraph()}).setGraph(O.graph());return O.nodes().forEach(H=>{O.children(H).length||P.setNode(H,O.node(H))}),O.edges().forEach(H=>{P.setEdge(H,O.edge(H))}),P}function a(O){let P=O.nodes().map(H=>{let B={};return O.outEdges(H).forEach(U=>{B[U.w]=(B[U.w]||0)+O.edge(U).weight}),B});return L(O.nodes(),P)}function o(O){let P=O.nodes().map(H=>{let B={};return O.inEdges(H).forEach(U=>{B[U.v]=(B[U.v]||0)+O.edge(U).weight}),B});return L(O.nodes(),P)}function u(O,P){let H=O.x,B=O.y,U=P.x-H,ee=P.y-B,I=O.width/2,F=O.height/2;if(!U&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*I>Math.abs(U)*F?(ee<0&&(F=-F),z=F*U/ee,G=F):(U<0&&(I=-I),z=I,G=I*ee/U),{x:H+z,y:B+G}}function c(O){let P=A(w(O)+1).map(()=>[]);return O.nodes().forEach(H=>{let B=O.node(H),U=B.rank;U!==void 0&&(P[U][B.order]=H)}),P}function d(O){let P=O.nodes().map(B=>{let U=O.node(B).rank;return U===void 0?Number.MAX_VALUE:U}),H=b(Math.min,P);O.nodes().forEach(B=>{let U=O.node(B);Object.hasOwn(U,"rank")&&(U.rank-=H)})}function h(O){let P=O.nodes().map(I=>O.node(I).rank),H=b(Math.min,P),B=[];O.nodes().forEach(I=>{let F=O.node(I).rank-H;B[F]||(B[F]=[]),B[F].push(I)});let U=0,ee=O.graph().nodeRankFactor;Array.from(B).forEach((I,F)=>{I===void 0&&F%ee!==0?--U:I!==void 0&&U&&I.forEach(z=>O.node(z).rank+=U)})}function m(O,P,H,B){let U={width:0,height:0};return arguments.length>=4&&(U.rank=H,U.order=B),t(O,"border",U,P)}function p(O,P=x){const H=[];for(let B=0;Bx){const H=p(P);return O.apply(null,H.map(B=>O.apply(null,B)))}else return O.apply(null,P)}function w(O){const H=O.nodes().map(B=>{let U=O.node(B).rank;return U===void 0?Number.MIN_VALUE:U});return b(Math.max,H)}function k(O,P){let H={lhs:[],rhs:[]};return O.forEach(B=>{P(B)?H.lhs.push(B):H.rhs.push(B)}),H}function _(O,P){let H=Date.now();try{return P()}finally{console.log(O+" time: "+(Date.now()-H)+"ms")}}function S(O,P){return P()}let C=0;function E(O){var P=++C;return O+(""+P)}function A(O,P,H=1){P==null&&(P=O,O=0);let B=ee=>eePB[P]),Object.entries(O).reduce((B,[U,ee])=>(B[U]=H(ee,U),B),{})}function L(O,P){return O.reduce((H,B,U)=>(H[B]=P[U],H),{})}return Zh}var Kh,Ub;function F5(){if(Ub)return Kh;Ub=1;let e=G5(),t=jt().uniqueId;Kh={run:r,undo:a};function r(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(d=>{let h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,t("rev"))});function c(d){return h=>d.edge(h).weight}}function l(o){let u=[],c={},d={};function h(m){Object.hasOwn(d,m)||(d[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?u.push(p):h(p.w)}),delete c[m])}return o.nodes().forEach(h),u}function a(o){o.edges().forEach(u=>{let c=o.edge(u);if(c.reversed){o.removeEdge(u);let d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(u.w,u.v,c,d)}})}return Kh}var Jh,Vb;function Y5(){if(Vb)return Jh;Vb=1;let e=jt();Jh={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>r(a,o))}function r(a,o){let u=o.v,c=a.node(u).rank,d=o.w,h=a.node(d).rank,m=o.name,p=a.edge(o),x=p.labelRank;if(h===c+1)return;a.removeEdge(o);let b,w,k;for(k=0,++c;c{let u=a.node(o),c=u.edgeLabel,d;for(a.setEdge(u.edgeObj,c);u.dummy;)d=a.successors(o)[0],a.removeNode(o),c.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(c.x=u.x,c.y=u.y,c.width=u.width,c.height=u.height),o=d,u=a.node(o)})}return Jh}var Wh,Pb;function xc(){if(Pb)return Wh;Pb=1;const{applyWithChunking:e}=jt();Wh={longestPath:t,slack:r};function t(l){var a={};function o(u){var c=l.node(u);if(Object.hasOwn(a,u))return c.rank;a[u]=!0;let d=l.outEdges(u).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var h=e(Math.min,d);return h===Number.POSITIVE_INFINITY&&(h=0),c.rank=h}l.sources().forEach(o)}function r(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return Wh}var ep,$b;function M_(){if($b)return ep;$b=1;var e=Yn().Graph,t=xc().slack;ep=r;function r(u){var c=new e({directed:!1}),d=u.nodes()[0],h=u.nodeCount();c.setNode(d,{});for(var m,p;l(c,u){var p=m.v,x=h===p?m.w:p;!u.hasNode(x)&&!t(c,m)&&(u.setNode(x,{}),u.setEdge(h,x,{}),d(x))})}return u.nodes().forEach(d),u.nodeCount()}function a(u,c){return c.edges().reduce((h,m)=>{let p=Number.POSITIVE_INFINITY;return u.hasNode(m.v)!==u.hasNode(m.w)&&(p=t(c,m)),pc.node(h).rank+=d)}return ep}var tp,Gb;function X5(){if(Gb)return tp;Gb=1;var e=M_(),t=xc().slack,r=xc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=jt().simplify;tp=u,u.initLowLimValues=m,u.initCutValues=c,u.calcCutValue=h,u.leaveEdge=x,u.enterEdge=b,u.exchangeEdges=w;function u(C){C=o(C),r(C);var E=e(C);m(E),c(E,C);for(var A,M;A=x(E);)M=b(E,C,A),w(E,C,A,M)}function c(C,E){var A=a(C,C.nodes());A=A.slice(0,A.length-1),A.forEach(M=>d(C,E,M))}function d(C,E,A){var M=C.node(A),j=M.parent;C.edge(A,j).cutvalue=h(C,E,A)}function h(C,E,A){var M=C.node(A),j=M.parent,L=!0,O=E.edge(A,j),P=0;return O||(L=!1,O=E.edge(j,A)),P=O.weight,E.nodeEdges(A).forEach(H=>{var B=H.v===A,U=B?H.w:H.v;if(U!==j){var ee=B===L,I=E.edge(H).weight;if(P+=ee?I:-I,_(C,A,U)){var F=C.edge(A,U).cutvalue;P+=ee?-F:F}}}),P}function m(C,E){arguments.length<2&&(E=C.nodes()[0]),p(C,{},1,E)}function p(C,E,A,M,j){var L=A,O=C.node(M);return E[M]=!0,C.neighbors(M).forEach(P=>{Object.hasOwn(E,P)||(A=p(C,E,A,P,M))}),O.low=L,O.lim=A++,j?O.parent=j:delete O.parent,A}function x(C){return C.edges().find(E=>C.edge(E).cutvalue<0)}function b(C,E,A){var M=A.v,j=A.w;E.hasEdge(M,j)||(M=A.w,j=A.v);var L=C.node(M),O=C.node(j),P=L,H=!1;L.lim>O.lim&&(P=O,H=!0);var B=E.edges().filter(U=>H===S(C,C.node(U.v),P)&&H!==S(C,C.node(U.w),P));return B.reduce((U,ee)=>t(E,ee)!E.node(j).parent),M=l(C,A);M=M.slice(1),M.forEach(j=>{var L=C.node(j).parent,O=E.edge(j,L),P=!1;O||(O=E.edge(L,j),P=!0),E.node(j).rank=E.node(L).rank+(P?O.minlen:-O.minlen)})}function _(C,E,A){return C.hasEdge(E,A)}function S(C,E,A){return A.low<=E.lim&&E.lim<=A.lim}return tp}var np,Fb;function Q5(){if(Fb)return np;Fb=1;var e=xc(),t=e.longestPath,r=M_(),l=X5();np=a;function a(d){var h=d.graph().ranker;if(h instanceof Function)return h(d);switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":u(d);break;case"longest-path":o(d);break;case"none":break;default:c(d)}}var o=t;function u(d){t(d),r(d)}function c(d){l(d)}return np}var rp,Yb;function Z5(){if(Yb)return rp;Yb=1,rp=e;function e(l){let a=r(l);l.graph().dummyChains.forEach(o=>{let u=l.node(o),c=u.edgeObj,d=t(l,a,c.v,c.w),h=d.path,m=d.lca,p=0,x=h[p],b=!0;for(;o!==c.w;){if(u=l.node(o),b){for(;(x=h[p])!==m&&l.node(x).maxRankh||m>a[p].lim));for(x=p,p=u;(p=l.parent(p))!==x;)d.push(p);return{path:c.concat(d.reverse()),lca:x}}function r(l){let a={},o=0;function u(c){let d=o;l.children(c).forEach(u),a[c]={low:d,lim:o++}}return l.children().forEach(u),a}return rp}var ip,Xb;function K5(){if(Xb)return ip;Xb=1;let e=jt();ip={run:t,cleanup:o};function t(u){let c=e.addDummyNode(u,"root",{},"_root"),d=l(u),h=Object.values(d),m=e.applyWithChunking(Math.max,h)-1,p=2*m+1;u.graph().nestingRoot=c,u.edges().forEach(b=>u.edge(b).minlen*=p);let x=a(u)+1;u.children().forEach(b=>r(u,c,p,x,m,d,b)),u.graph().nodeRankFactor=p}function r(u,c,d,h,m,p,x){let b=u.children(x);if(!b.length){x!==c&&u.setEdge(c,x,{weight:0,minlen:d});return}let w=e.addBorderNode(u,"_bt"),k=e.addBorderNode(u,"_bb"),_=u.node(x);u.setParent(w,x),_.borderTop=w,u.setParent(k,x),_.borderBottom=k,b.forEach(S=>{r(u,c,d,h,m,p,S);let C=u.node(S),E=C.borderTop?C.borderTop:S,A=C.borderBottom?C.borderBottom:S,M=C.borderTop?h:2*h,j=E!==A?1:m-p[x]+1;u.setEdge(w,E,{weight:M,minlen:j,nestingEdge:!0}),u.setEdge(A,k,{weight:M,minlen:j,nestingEdge:!0})}),u.parent(x)||u.setEdge(c,w,{weight:0,minlen:m+p[x]})}function l(u){var c={};function d(h,m){var p=u.children(h);p&&p.length&&p.forEach(x=>d(x,m+1)),c[h]=m}return u.children().forEach(h=>d(h,1)),c}function a(u){return u.edges().reduce((c,d)=>c+u.edge(d).weight,0)}function o(u){var c=u.graph();u.removeNode(c.nestingRoot),delete c.nestingRoot,u.edges().forEach(d=>{var h=u.edge(d);h.nestingEdge&&u.removeEdge(d)})}return ip}var lp,Qb;function J5(){if(Qb)return lp;Qb=1;let e=jt();lp=t;function t(l){function a(o){let u=l.children(o),c=l.node(o);if(u.length&&u.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let d=c.minRank,h=c.maxRank+1;dl(d.node(h))),d.edges().forEach(h=>l(d.edge(h)))}function l(d){let h=d.width;d.width=d.height,d.height=h}function a(d){d.nodes().forEach(h=>o(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(d){d.y=-d.y}function u(d){d.nodes().forEach(h=>c(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(d){let h=d.x;d.x=d.y,d.y=h}return ap}var op,Kb;function e4(){if(Kb)return op;Kb=1;let e=jt();op=t;function t(r){let l={},a=r.nodes().filter(m=>!r.children(m).length),o=a.map(m=>r.node(m).rank),u=e.applyWithChunking(Math.max,o),c=e.range(u+1).map(()=>[]);function d(m){if(l[m])return;l[m]=!0;let p=r.node(m);c[p.rank].push(m),r.successors(m).forEach(d)}return a.sort((m,p)=>r.node(m).rank-r.node(p).rank).forEach(d),c}return op}var sp,Jb;function t4(){if(Jb)return sp;Jb=1;let e=jt().zipObject;sp=t;function t(l,a){let o=0;for(let u=1;ub)),c=a.flatMap(x=>l.outEdges(x).map(b=>({pos:u[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),d=1;for(;d{let b=x.pos+d;m[b]+=x.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=x.weight;p+=x.weight*w}),p}return sp}var up,Wb;function n4(){if(Wb)return up;Wb=1,up=e;function e(t,r=[]){return r.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((u,c)=>{let d=t.edge(c),h=t.node(c.v);return{sum:u.sum+d.weight*h.order,weight:u.weight+d.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return up}var cp,e1;function r4(){if(e1)return cp;e1=1;let e=jt();cp=t;function t(a,o){let u={};a.forEach((d,h)=>{let m=u[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};d.barycenter!==void 0&&(m.barycenter=d.barycenter,m.weight=d.weight)}),o.edges().forEach(d=>{let h=u[d.v],m=u[d.w];h!==void 0&&m!==void 0&&(m.indegree++,h.out.push(u[d.w]))});let c=Object.values(u).filter(d=>!d.indegree);return r(c)}function r(a){let o=[];function u(d){return h=>{h.merged||(h.barycenter===void 0||d.barycenter===void 0||h.barycenter>=d.barycenter)&&l(d,h)}}function c(d){return h=>{h.in.push(d),--h.indegree===0&&a.push(h)}}for(;a.length;){let d=a.pop();o.push(d),d.in.reverse().forEach(u(d)),d.out.forEach(c(d))}return o.filter(d=>!d.merged).map(d=>e.pick(d,["vs","i","barycenter","weight"]))}function l(a,o){let u=0,c=0;a.weight&&(u+=a.barycenter*a.weight,c+=a.weight),o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=u/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return cp}var fp,t1;function i4(){if(t1)return fp;t1=1;let e=jt();fp=t;function t(a,o){let u=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=u.lhs,d=u.rhs.sort((w,k)=>k.i-w.i),h=[],m=0,p=0,x=0;c.sort(l(!!o)),x=r(h,d,x),c.forEach(w=>{x+=w.vs.length,h.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,x=r(h,d,x)});let b={vs:h.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function r(a,o,u){let c;for(;o.length&&(c=o[o.length-1]).i<=u;)o.pop(),a.push(c.vs),u++;return u}function l(a){return(o,u)=>o.barycenteru.barycenter?1:a?u.i-o.i:o.i-u.i}return fp}var dp,n1;function l4(){if(n1)return dp;n1=1;let e=n4(),t=r4(),r=i4();dp=l;function l(u,c,d,h){let m=u.children(c),p=u.node(c),x=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};x&&(m=m.filter(C=>C!==x&&C!==b));let k=e(u,m);k.forEach(C=>{if(u.children(C.v).length){let E=l(u,C.v,d,h);w[C.v]=E,Object.hasOwn(E,"barycenter")&&o(C,E)}});let _=t(k,d);a(_,w);let S=r(_,h);if(x&&(S.vs=[x,S.vs,b].flat(!0),u.predecessors(x).length)){let C=u.node(u.predecessors(x)[0]),E=u.node(u.predecessors(b)[0]);Object.hasOwn(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+C.order+E.order)/(S.weight+2),S.weight+=2}return S}function a(u,c){u.forEach(d=>{d.vs=d.vs.flatMap(h=>c[h]?c[h].vs:h)})}function o(u,c){u.barycenter!==void 0?(u.barycenter=(u.barycenter*u.weight+c.barycenter*c.weight)/(u.weight+c.weight),u.weight+=c.weight):(u.barycenter=c.barycenter,u.weight=c.weight)}return dp}var hp,r1;function a4(){if(r1)return hp;r1=1;let e=Yn().Graph,t=jt();hp=r;function r(a,o,u,c){c||(c=a.nodes());let d=l(a),h=new e({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),x=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(h.setNode(m),h.setParent(m,x||d),a[u](m).forEach(b=>{let w=b.v===m?b.w:b.v,k=h.edge(w,m),_=k!==void 0?k.weight:0;h.setEdge(w,m,{weight:a.edge(b).weight+_})}),Object.hasOwn(p,"minRank")&&h.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),h}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return hp}var pp,i1;function o4(){if(i1)return pp;i1=1,pp=e;function e(t,r,l){let a={},o;l.forEach(u=>{let c=t.parent(u),d,h;for(;c;){if(d=t.parent(c),d?(h=a[d],a[d]=c):(h=o,o=c),h&&h!==c){r.setEdge(h,c);return}c=d}})}return pp}var mp,l1;function s4(){if(l1)return mp;l1=1;let e=e4(),t=t4(),r=l4(),l=a4(),a=o4(),o=Yn().Graph,u=jt();mp=c;function c(p,x){if(x&&typeof x.customOrder=="function"){x.customOrder(p,c);return}let b=u.maxRank(p),w=d(p,u.range(1,b+1),"inEdges"),k=d(p,u.range(b-1,-1,-1),"outEdges"),_=e(p);if(m(p,_),x&&x.disableOptimalOrderHeuristic)return;let S=Number.POSITIVE_INFINITY,C;for(let E=0,A=0;A<4;++E,++A){h(E%2?w:k,E%4>=2),_=u.buildLayerMatrix(p);let M=t(p,_);M{w.has(_)||w.set(_,[]),w.get(_).push(S)};for(const _ of p.nodes()){const S=p.node(_);if(typeof S.rank=="number"&&k(S.rank,_),typeof S.minRank=="number"&&typeof S.maxRank=="number")for(let C=S.minRank;C<=S.maxRank;C++)C!==S.rank&&k(C,_)}return x.map(function(_){return l(p,_,b,w.get(_)||[])})}function h(p,x){let b=new o;p.forEach(function(w){let k=w.graph().root,_=r(w,k,b,x);_.vs.forEach((S,C)=>w.node(S).order=C),a(w,b,_.vs)})}function m(p,x){Object.values(x).forEach(b=>b.forEach((w,k)=>p.node(w).order=k))}return mp}var gp,a1;function u4(){if(a1)return gp;a1=1;let e=Yn().Graph,t=jt();gp={positionX:b,findType1Conflicts:r,findType2Conflicts:l,addConflict:o,hasConflict:u,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:p,findSmallestWidthAlignment:m,balance:x};function r(_,S){let C={};function E(A,M){let j=0,L=0,O=A.length,P=M[M.length-1];return M.forEach((H,B)=>{let U=a(_,H),ee=U?_.node(U).order:O;(U||H===P)&&(M.slice(L,B+1).forEach(I=>{_.predecessors(I).forEach(F=>{let z=_.node(F),G=z.order;(G{H=M[B],_.node(H).dummy&&_.predecessors(H).forEach(U=>{let ee=_.node(U);ee.dummy&&(ee.orderP)&&o(C,U,H)})})}function A(M,j){let L=-1,O,P=0;return j.forEach((H,B)=>{if(_.node(H).dummy==="border"){let U=_.predecessors(H);U.length&&(O=_.node(U[0]).order,E(j,P,B,L,O),P=B,L=O)}E(j,P,j.length,O,M.length)}),j}return S.length&&S.reduce(A),C}function a(_,S){if(_.node(S).dummy)return _.predecessors(S).find(C=>_.node(C).dummy)}function o(_,S,C){if(S>C){let A=S;S=C,C=A}let E=_[S];E||(_[S]=E={}),E[C]=!0}function u(_,S,C){if(S>C){let E=S;S=C,C=E}return!!_[S]&&Object.hasOwn(_[S],C)}function c(_,S,C,E){let A={},M={},j={};return S.forEach(L=>{L.forEach((O,P)=>{A[O]=O,M[O]=O,j[O]=P})}),S.forEach(L=>{let O=-1;L.forEach(P=>{let H=E(P);if(H.length){H=H.sort((U,ee)=>j[U]-j[ee]);let B=(H.length-1)/2;for(let U=Math.floor(B),ee=Math.ceil(B);U<=ee;++U){let I=H[U];M[P]===P&&OMath.max(U,M[ee.v]+j.edge(ee)),0)}function H(B){let U=j.outEdges(B).reduce((I,F)=>Math.min(I,M[F.w]-j.edge(F)),Number.POSITIVE_INFINITY),ee=_.node(B);U!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],U))}return O(P,j.predecessors.bind(j)),O(H,j.successors.bind(j)),Object.keys(E).forEach(B=>M[B]=M[C[B]]),M}function h(_,S,C,E){let A=new e,M=_.graph(),j=w(M.nodesep,M.edgesep,E);return S.forEach(L=>{let O;L.forEach(P=>{let H=C[P];if(A.setNode(H),O){var B=C[O],U=A.edge(B,H);A.setEdge(B,H,Math.max(j(_,P,O),U||0))}O=P})}),A}function m(_,S){return Object.values(S).reduce((C,E)=>{let A=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(E).forEach(([L,O])=>{let P=k(_,L)/2;A=Math.max(O+P,A),M=Math.min(O-P,M)});const j=A-M;return j{["l","r"].forEach(j=>{let L=M+j,O=_[L];if(O===S)return;let P=Object.values(O),H=E-t.applyWithChunking(Math.min,P);j!=="l"&&(H=A-t.applyWithChunking(Math.max,P)),H&&(_[L]=t.mapValues(O,B=>B+H))})})}function x(_,S){return t.mapValues(_.ul,(C,E)=>{if(S)return _[S.toLowerCase()][E];{let A=Object.values(_).map(M=>M[E]).sort((M,j)=>M-j);return(A[1]+A[2])/2}})}function b(_){let S=t.buildLayerMatrix(_),C=Object.assign(r(_,S),l(_,S)),E={},A;["u","d"].forEach(j=>{A=j==="u"?S:Object.values(S).reverse(),["l","r"].forEach(L=>{L==="r"&&(A=A.map(B=>Object.values(B).reverse()));let O=(j==="u"?_.predecessors:_.successors).bind(_),P=c(_,A,C,O),H=d(_,A,P.root,P.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),E[j+L]=H})});let M=m(_,E);return p(E,M),x(E,_.graph().align)}function w(_,S,C){return(E,A,M)=>{let j=E.node(A),L=E.node(M),O=0,P;if(O+=j.width/2,Object.hasOwn(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":P=-j.width/2;break;case"r":P=j.width/2;break}if(P&&(O+=C?P:-P),P=0,O+=(j.dummy?S:_)/2,O+=(L.dummy?S:_)/2,O+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":P=L.width/2;break;case"r":P=-L.width/2;break}return P&&(O+=C?P:-P),P=0,O}}function k(_,S){return _.node(S).width}return gp}var xp,o1;function c4(){if(o1)return xp;o1=1;let e=jt(),t=u4().positionX;xp=r;function r(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,u])=>a.node(o).x=u)}function l(a){let o=e.buildLayerMatrix(a),u=a.graph().ranksep,c=0;o.forEach(d=>{const h=d.reduce((m,p)=>{const x=a.node(p).height;return m>x?m:x},0);d.forEach(m=>a.node(m).y=c+h/2),c+=h+u})}return xp}var yp,s1;function f4(){if(s1)return yp;s1=1;let e=F5(),t=Y5(),r=Q5(),l=jt().normalizeRanks,a=Z5(),o=jt().removeEmptyRanks,u=K5(),c=J5(),d=W5(),h=s4(),m=c4(),p=jt(),x=Yn().Graph;yp=b;function b(N,$){let X=$&&$.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>O(N));X(" runLayout",()=>w(J,X,$)),X(" updateInputGraph",()=>k(N,J))})}function w(N,$,X){$(" makeSpaceForEdgeLabels",()=>P(N)),$(" removeSelfEdges",()=>Q(N)),$(" acyclic",()=>e.run(N)),$(" nestingGraph.run",()=>u.run(N)),$(" rank",()=>r(p.asNonCompoundGraph(N))),$(" injectEdgeLabelProxies",()=>H(N)),$(" removeEmptyRanks",()=>o(N)),$(" nestingGraph.cleanup",()=>u.cleanup(N)),$(" normalizeRanks",()=>l(N)),$(" assignRankMinMax",()=>B(N)),$(" removeEdgeLabelProxies",()=>U(N)),$(" normalize.run",()=>t.run(N)),$(" parentDummyChains",()=>a(N)),$(" addBorderSegments",()=>c(N)),$(" order",()=>h(N,X)),$(" insertSelfEdges",()=>K(N)),$(" adjustCoordinateSystem",()=>d.adjust(N)),$(" position",()=>m(N)),$(" positionSelfEdges",()=>D(N)),$(" removeBorderNodes",()=>G(N)),$(" normalize.undo",()=>t.undo(N)),$(" fixupEdgeLabelCoords",()=>F(N)),$(" undoCoordinateSystem",()=>d.undo(N)),$(" translateGraph",()=>ee(N)),$(" assignNodeIntersects",()=>I(N)),$(" reversePoints",()=>z(N)),$(" acyclic.undo",()=>e.undo(N))}function k(N,$){N.nodes().forEach(X=>{let J=N.node(X),ne=$.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,$.children(X).length&&(J.width=ne.width,J.height=ne.height))}),N.edges().forEach(X=>{let J=N.edge(X),ne=$.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),N.graph().width=$.graph().width,N.graph().height=$.graph().height}let _=["nodesep","edgesep","ranksep","marginx","marginy"],S={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},C=["acyclicer","ranker","rankdir","align"],E=["width","height","rank"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function O(N){let $=new x({multigraph:!0,compound:!0}),X=Y(N.graph());return $.setGraph(Object.assign({},S,q(X,_),p.pick(X,C))),N.nodes().forEach(J=>{let ne=Y(N.node(J));const re=q(ne,E);Object.keys(A).forEach(se=>{re[se]===void 0&&(re[se]=A[se])}),$.setNode(J,re),$.setParent(J,N.parent(J))}),N.edges().forEach(J=>{let ne=Y(N.edge(J));$.setEdge(J,Object.assign({},j,q(ne,M),p.pick(ne,L)))}),$}function P(N){let $=N.graph();$.ranksep/=2,N.edges().forEach(X=>{let J=N.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&($.rankdir==="TB"||$.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(N){N.edges().forEach($=>{let X=N.edge($);if(X.width&&X.height){let J=N.node($.v),re={rank:(N.node($.w).rank-J.rank)/2+J.rank,e:$};p.addDummyNode(N,"edge-proxy",re,"_ep")}})}function B(N){let $=0;N.nodes().forEach(X=>{let J=N.node(X);J.borderTop&&(J.minRank=N.node(J.borderTop).rank,J.maxRank=N.node(J.borderBottom).rank,$=Math.max($,J.maxRank))}),N.graph().maxRank=$}function U(N){N.nodes().forEach($=>{let X=N.node($);X.dummy==="edge-proxy"&&(N.edge(X.e).labelRank=X.rank,N.removeNode($))})}function ee(N){let $=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=N.graph(),se=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,_e=ye.y,ze=ye.width,Te=ye.height;$=Math.min($,pe-ze/2),X=Math.max(X,pe+ze/2),J=Math.min(J,_e-Te/2),ne=Math.max(ne,_e+Te/2)}N.nodes().forEach(ye=>be(N.node(ye))),N.edges().forEach(ye=>{let pe=N.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),$-=se,J-=xe,N.nodes().forEach(ye=>{let pe=N.node(ye);pe.x-=$,pe.y-=J}),N.edges().forEach(ye=>{let pe=N.edge(ye);pe.points.forEach(_e=>{_e.x-=$,_e.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=$),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-$+se,re.height=ne-J+xe}function I(N){N.edges().forEach($=>{let X=N.edge($),J=N.node($.v),ne=N.node($.w),re,se;X.points?(re=X.points[0],se=X.points[X.points.length-1]):(X.points=[],re=ne,se=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,se))})}function F(N){N.edges().forEach($=>{let X=N.edge($);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(N){N.edges().forEach($=>{let X=N.edge($);X.reversed&&X.points.reverse()})}function G(N){N.nodes().forEach($=>{if(N.children($).length){let X=N.node($),J=N.node(X.borderTop),ne=N.node(X.borderBottom),re=N.node(X.borderLeft[X.borderLeft.length-1]),se=N.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(se.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),N.nodes().forEach($=>{N.node($).dummy==="border"&&N.removeNode($)})}function Q(N){N.edges().forEach($=>{if($.v===$.w){var X=N.node($.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:$,label:N.edge($)}),N.removeEdge($)}})}function K(N){var $=p.buildLayerMatrix(N);$.forEach(X=>{var J=0;X.forEach((ne,re)=>{var se=N.node(ne);se.order=re+J,(se.selfEdges||[]).forEach(xe=>{p.addDummyNode(N,"selfedge",{width:xe.label.width,height:xe.label.height,rank:se.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete se.selfEdges})})}function D(N){N.nodes().forEach($=>{var X=N.node($);if(X.dummy==="selfedge"){var J=N.node(X.e.v),ne=J.x+J.width/2,re=J.y,se=X.x-ne,xe=J.height/2;N.setEdge(X.e,X.label),N.removeNode($),X.label.points=[{x:ne+2*se/3,y:re-xe},{x:ne+5*se/6,y:re-xe},{x:ne+se,y:re},{x:ne+5*se/6,y:re+xe},{x:ne+2*se/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function q(N,$){return p.mapValues(p.pick(N,$),Number)}function Y(N){var $={};return N&&Object.entries(N).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),$[X]=J}),$}return yp}var vp,u1;function d4(){if(u1)return vp;u1=1;let e=jt(),t=Yn().Graph;vp={debugOrdering:r};function r(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(u=>{o.setNode(u,{label:u}),o.setParent(u,"layer"+l.node(u).rank)}),l.edges().forEach(u=>o.setEdge(u.v,u.w,{},u.name)),a.forEach((u,c)=>{let d="layer"+c;o.setNode(d,{rank:"same"}),u.reduce((h,m)=>(o.setEdge(h,m,{style:"invis"}),m))}),o}return vp}var bp,c1;function h4(){return c1||(c1=1,bp="1.1.8"),bp}var wp,f1;function p4(){return f1||(f1=1,wp={graphlib:Yn(),layout:f4(),debug:d4(),util:{time:jt().time,notime:jt().notime},version:h4()}),wp}var m4=p4();const d1=Qo(m4),Ao=200,la=56,h1=20,p1=40,g4=20,m1=12;function x4(e,t,r,l,a,o,u,c){const d=[],h=[],m=new Set,p=new Set,x=new Map;for(const S of r)for(const C of S.agents)p.add(C),x.set(C,S.name);for(const S of r){const C=a[S.name],E=S.agents.length,A=Ao+h1*2,M=p1+E*la+(E-1)*m1+g4;d.push({id:S.name,type:"groupNode",position:{x:0,y:0},data:{label:S.name,type:"parallel_group",status:(C==null?void 0:C.status)||"pending",groupName:S.name,progress:o[S.name]},style:{width:A,height:M}});for(let j=0;j$entryPoint",source:"$start",target:u,type:"animatedEdge",data:{},animated:!1})}const w=new Set(d.map(S=>S.id)),k=new Map;for(const S of d)S.parentId&&k.set(S.id,S.parentId);const _=new Map;for(const S of t){const C=k.get(S.from)??S.from,E=k.get(S.to)??S.to;if(!w.has(C)||!w.has(E)||C===E)continue;const A=`${C}->${E}`,M=_.get(A);if(M){M.when!==S.when&&(h[M.idx].data={when:void 0});continue}const j=h.length;_.set(A,{when:S.when,idx:j});const L=`${A}${S.when?`[${S.when}]`:""}`;h.push({id:L,source:C,target:E,type:"animatedEdge",data:{when:S.when},animated:!1})}return y4(d,h),{nodes:d,edges:h}}function y4(e,t){var l,a,o,u;const r=new d1.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const c of e){if(c.parentId)continue;const d=c.type==="groupNode",h=d&&((l=c.style)==null?void 0:l.width)||Ao,m=d&&((a=c.style)==null?void 0:a.height)||la;r.setNode(c.id,{width:h,height:m})}for(const c of t)r.hasNode(c.source)&&r.hasNode(c.target)&&r.setEdge(c.source,c.target);d1.layout(r);for(const c of e){if(c.parentId)continue;const d=r.node(c.id);if(!d)continue;const h=c.type==="groupNode",m=h&&((o=c.style)==null?void 0:o.width)||Ao,p=h&&((u=c.style)==null?void 0:u.height)||la;c.position={x:d.x-m/2,y:d.y-p/2}}}const Fe={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},v4=70,g1=90;function Bc({data:e,children:t}){const[r,l]=V.useState(!1),a=V.useRef(null),o=V.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),u=V.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=Fe[e.status]||Fe.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:u,children:[t,r&&y.jsxs("div",{className:He("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:Jt(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[$n(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",$n(e.inputTokens),"↑ ",$n(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:yi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:He("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const b4=V.memo(function({data:t,id:r,selected:l}){var L;const a=t,o=ol(),c=((L=o[r])==null?void 0:L.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.model,x=h==null?void 0:h.tokens,b=h==null?void 0:h.input_tokens,w=h==null?void 0:h.output_tokens,k=h==null?void 0:h.cost_usd,_=h==null?void 0:h.iteration,S=h==null?void 0:h.error_type,C=h==null?void 0:h.error_message,E=h==null?void 0:h.context_pct,A=w4(r,c),M=S4(c),j=(()=>{if(c==="failed"&&C)return{text:C.length>40?C.slice(0,37)+"...":C,className:"text-red-400"};if(c==="running")return{text:A,className:"text-[var(--text-muted)]"};if(c==="completed"){const O=[];return m!=null&&O.push(Jt(m)),x!=null&&O.push(`${$n(x)} tok`),k!=null&&O.push(yi(k)),{text:O.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,elapsed:m,model:p,tokens:x,inputTokens:b,outputTokens:w,costUsd:k,iteration:_,errorType:S,errorMessage:C},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(sN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_!=null&&_>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${d}25`,color:d},children:["x",_]})]}),j.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",j.className),children:j.text})]}),E!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:He("h-full transition-all duration-500",E>=g1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(E,100)}%`,backgroundColor:E>=g1?"#ef4444":E>=v4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function w4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=fe(h=>h.replayMode),a=fe(h=>h.lastEventTime),[o,u]=V.useState("0.0s"),c=V.useRef(null);return V.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function S4(e){const t=V.useRef(e),[r,l]=V.useState("");return V.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const _4=V.memo(function({data:t,id:r,selected:l}){var S;const a=t,o=ol(),c=((S=o[r])==null?void 0:S.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.exit_code,x=h==null?void 0:h.error_type,b=h==null?void 0:h.error_message,w=k4(r,c),k=E4(c),_=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const C=[];return m!=null&&C.push(Jt(m)),p!=null&&C.push(`exit ${p}`),{text:C.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,elapsed:m,exitCode:p,errorType:x,errorMessage:b},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",k),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(SN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",_.className),children:_.text})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function k4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=fe(h=>h.replayMode),a=fe(h=>h.lastEventTime),[o,u]=V.useState("0.0s"),c=V.useRef(null);return V.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function E4(e){const t=V.useRef(e),[r,l]=V.useState("");return V.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const N4=V.memo(function({data:t,id:r,selected:l}){var p,x;const a=t,o=ol(),c=((p=o[r])==null?void 0:p.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=(x=o[r])==null?void 0:x.selected_option,m=C4(c);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,selectedOption:h},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(wN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&h&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:h})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function C4(e){const t=V.useRef(e),[r,l]=V.useState("");return V.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const T4=V.memo(function({data:t,id:r,selected:l}){var _;const a=t,u=a.type==="for_each_group"?vN:gN,c=a.progress,m=((_=ol()[r])==null?void 0:_.status)||a.status||"pending",p=Fe[m]||Fe.pending,x=j4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,k=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:He("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",x),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(u,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:k?"var(--failed)":"var(--completed)"}})})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function j4(e){const t=V.useRef(e),[r,l]=V.useState("");return V.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const A4=V.memo(function({data:t,id:r,selected:l}){const a=t,u=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.status})||a.status||"pending",c=Fe[u]||Fe.pending,d=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.elapsed}),h=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.error_message}),m=fe(_=>_.navigateIntoSubworkflow),p=qm(),x=p.some(_=>_.parentAgent===r),b=p.find(_=>_.parentAgent===r),w=b==null?void 0:b.workflowName,k=(()=>{if(u==="failed"&&h)return{text:h.length>35?h.slice(0,32)+"...":h,className:"text-red-400"};if(u==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(u==="completed"){const _=[];return w&&_.push(w),d!=null&&_.push(`${d.toFixed(1)}s`),{text:_.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:u,elapsed:d,errorType:void 0,errorMessage:h,iteration:void 0},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:_=>{x&&(_.stopPropagation(),m(r))},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",u==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(Sc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),k.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",k.className),children:k.text})]}),x&&y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),z4=V.memo(function({data:t,selected:r}){const a=t.status||"pending",o=a==="completed",u=a==="failed",c=!o&&!u,d=o?Fe.completed:u?Fe.failed:Fe.pending;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:d},children:o?y.jsx(Yi,{className:"w-5 h-5 text-white",strokeWidth:3}):u?y.jsx(bw,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Yi,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?Fe.pending:d}})})]})}),M4=V.memo(function({data:t,selected:r}){const a=t.status||"pending",o=Fe[a]||Fe.pending,u=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",u?"bg-[var(--completed)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(xm,{className:"w-4 h-4 ml-0.5",style:{color:u?"white":o}})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),x1="#a78bfa",D4=V.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",u=o?x1:Fe[a]||x1,c=l.parentAgent,d=fe(h=>h.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:u},onDoubleClick:h=>{h.stopPropagation(),d()},children:y.jsx(aN,{className:"w-4 h-4",style:{color:o?"white":u}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",R4=V.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="completed",u=a==="failed",c=o?y1:u?Fe.failed:y1,d=l.parentAgent,h=fe(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),h()},children:y.jsx(oN,{className:"w-4 h-4",style:{color:o||u?"white":c}})}),d&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:d})]})]})]})}),O4=V.memo(function({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,source:d,target:h,data:m}){const p=N5(),x=V.useMemo(()=>p.find(P=>P.from===d&&P.to===h),[p,d,h]),[b,w,k]=Dm({sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c}),_=m==null?void 0:m.when,S=!!_,C=(x==null?void 0:x.state)==="taken",E=(x==null?void 0:x.state)==="highlighted",A=(x==null?void 0:x.state)==="failed";let M="var(--edge-color)",j=2,L;A?(M="var(--failed)",j=3):C?(M="var(--edge-taken)",j=3):E&&(M="var(--edge-active)",j=3),S&&!C&&!E&&!A&&(L="6 3");const O=A?"failed":C?"taken":E?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(rs,{id:t,path:b,style:{stroke:M,strokeWidth:j,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${O})`}),S&&y.jsx(XM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${k}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:A?"var(--failed)":C?"var(--edge-taken)":"var(--surface)",color:A||C?"var(--bg)":"var(--text-muted)",border:`1px solid ${A?"var(--failed)":C?"var(--edge-taken)":"var(--border)"}`},title:_,children:_})})}),C&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),A&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function L4(){const e=fe(u=>u.workflowStatus),t=fe(u=>u.workflowFailure),r=fe(u=>u.workflowFailedAgent),l=fe(u=>u.selectNode);if(e!=="failed"||!t)return null;const a=t.message||t.error_type||"Unknown error",o=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(ww,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:"Workflow Failed"}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:a}),o&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),r&&y.jsxs("button",{onClick:()=>l(r),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(hN,{className:"w-3 h-3"}),"View"]})]})})}function H4(){const[e,t]=V.useState(!1),r=fe(d=>d.workflowStatus),l=fe(d=>d.totalCost),a=fe(d=>d.totalTokens),o=fe(d=>d.agentsCompleted),u=fe(d=>d.agentsTotal),c=_w();return r!=="completed"||e?null:y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm"),children:[y.jsx(cN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-green-300",children:"Completed"}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono",children:[y.jsx("span",{children:c}),u>0&&y.jsxs("span",{children:[o,"/",u," agents"]}),a>0&&y.jsxs("span",{children:[$n(a)," tok"]}),l>0&&y.jsx("span",{children:yi(l)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(ll,{className:"w-3.5 h-3.5"})})]})})}const B4={agentNode:b4,scriptNode:_4,gateNode:N4,groupNode:T4,workflowNode:A4,endNode:z4,startNode:M4,ingressNode:D4,egressNode:R4},I4={animatedEdge:O4},q4={type:"animatedEdge"};function U4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function V4(){const e=C5(),t=fe(z=>z.viewContextPath),r=fe(z=>z.selectNode),l=fe(z=>z.selectedNode),a=fe(z=>z.workflowStatus),o=fe(z=>z.wsStatus),u=fe(z=>z.workflowFailedAgent),c=fe(z=>z.navigateIntoSubworkflow),{agents:d,routes:h,parallelGroups:m,forEachGroups:p,nodes:x,groupProgress:b,entryPoint:w,subworkflowContexts:k,parentAgent:_}=e,[S,C,E]=QM([]),[A,M,j]=ZM([]),L=V.useRef(!1),O=V.useRef(""),P=JSON.stringify(t);V.useEffect(()=>{if(d.length===0){O.current!==P&&(L.current=!1,O.current=P,C([]),M([]));return}if(O.current!==P&&(L.current=!1,O.current=P),L.current)return;L.current=!0;const{nodes:z,edges:G}=x4(d,h,m,p,x,b,w,_);C(z),M(G)},[d,h,m,p,x,b,w,C,M,P,_]),V.useEffect(()=>{L.current&&C(z=>z.map(G=>{const Q=x[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const q={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&(q.progress=b[G.data.groupName]),{...G,data:q}}if(G.data.groupName&&b[G.data.groupName]){const q=G.data.progress,Y=b[G.data.groupName];if(Y&&(!q||q.completed!==Y.completed||q.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[x,b,C]);const H=V.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||r(G.id)},[r]),B=V.useCallback((z,G)=>{k.some(K=>K.parentAgent===G.id)&&c(G.id)},[k,c]),U=V.useCallback(()=>{r(null)},[r]),ee=V.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return Fe[G]??Fe.pending??"#6b7280"},[]);V.useEffect(()=>{C(z=>z.map(G=>({...G,selected:G.id===l})))},[l,C]),V.useEffect(()=>{a==="failed"&&u&&r(u)},[a,u,r]);const I=a==="pending"&&d.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(U4,{}),y.jsx(L4,{}),y.jsx(H4,{}),I&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(EN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(ca,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(FM,{nodes:S,edges:A,onNodesChange:E,onEdgesChange:j,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:U,nodeTypes:B4,edgeTypes:I4,defaultEdgeOptions:q4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(t5,{variant:Mr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(w5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(s5,{showInteractive:!1,children:y.jsx(P4,{})}),y.jsx($4,{}),y.jsx(G4,{viewPathKey:P}),y.jsx(F4,{})]})]})}function P4(){const{fitView:e}=al(),t=V.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(xN,{className:"w-3.5 h-3.5"})})}function $4(){const{fitView:e}=al();return V.useEffect(()=>{const t=r=>{var a;const l=(a=r.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||r.key==="f"&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function G4({viewPathKey:e}){const{fitView:t}=al(),r=V.useRef(e);return V.useEffect(()=>{r.current!==e&&(r.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function F4(){const e=z5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function sl({items:e}){const t=e.filter(r=>r.value!=null&&r.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:r,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:r}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},r))})}function D_(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:Jt(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.tokens!=null&&t.push({label:"Tokens",value:$n(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${$n(e.input_tokens)} / ${$n(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:yi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:HN(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function nl({output:e,title:t="Output",defaultExpanded:r=!0,maxHeight:l="300px"}){const[a,o]=V.useState(r),[u,c]=V.useState(!1),d=Sw(e);if(!d)return null;const h=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:u?y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(gw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:h?y.jsx(Y4,{text:d}):d})]})}function Y4({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[r,l]=V.useState(t),a=V.useRef(null);return V.useEffect(()=>{a.current&&r&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,r]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!r),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[r?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),r&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,u)=>y.jsx(X4,{entry:o},u))})]})}function X4({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:He("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:He("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function v1({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(b1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(sl,{items:D_(e)}),e.prompt&&y.jsx(nl,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(nl,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(b1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function b1({label:e,defaultExpanded:t,snapshot:r,status:l}){const[a,o]=V.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(il,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),r.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:Q4(r.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(sl,{items:D_(r)}),r.prompt&&y.jsx(nl,{output:r.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:r.activity,defaultExpanded:t&&l!=="completed"}),r.output!=null&&y.jsx(nl,{output:r.output,title:"Output",defaultExpanded:!0}),r.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:r.error_type}),r.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",r.error_message]})]})]})]})}function Q4(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function Z4({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:Jt(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` +`)),m=h.reduce((p,x)=>p.concat(...x),[]);return[h,m]}return[[],[]]},[e]);return P.useEffect(()=>{const d=(t==null?void 0:t.target)??eb,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var _,S;if(a.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!a.current||a.current&&!h)&&AS(b))return!1;const E=nb(b.code,c);if(o.current.add(b[E]),tb(u,o.current,!1)){const N=((S=(_=b.composedPath)==null?void 0:_.call(b))==null?void 0:S[0])||b.target,k=(N==null?void 0:N.nodeName)==="BUTTON"||(N==null?void 0:N.nodeName)==="A";t.preventDefault!==!1&&(a.current||!k)&&b.preventDefault(),l(!0)}},p=b=>{const w=nb(b.code,c);tb(u,o.current,!0)?(l(!1),o.current.clear()):o.current.delete(b[w]),b.key==="Meta"&&o.current.clear(),a.current=!1},x=()=>{o.current.clear(),l(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",x),window.addEventListener("contextmenu",x),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",x),window.removeEventListener("contextmenu",x)}}},[e,l]),r}function tb(e,t,r){return e.filter(l=>r||l.length===t.size).some(l=>l.every(a=>t.has(a)))}function nb(e,t){return t.includes(e)?"code":"key"}const kz=()=>{const e=mt();return P.useMemo(()=>({zoomIn:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:r}=e.getState();return r?r.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,r)=>{const{panZoom:l}=e.getState();return l?l.scaleTo(t,{duration:r==null?void 0:r.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,r)=>{const{transform:[l,a,o],panZoom:u}=e.getState();return u?(await u.setViewport({x:t.x??l,y:t.y??a,zoom:t.zoom??o},r),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,r,l]=e.getState().transform;return{x:t,y:r,zoom:l}},setCenter:async(t,r,l)=>e.getState().setCenter(t,r,l),fitBounds:async(t,r)=>{const{width:l,height:a,minZoom:o,maxZoom:u,panZoom:c}=e.getState(),d=zm(t,l,a,o,u,(r==null?void 0:r.padding)??.1);return c?(await c.setViewport(d,{duration:r==null?void 0:r.duration,ease:r==null?void 0:r.ease,interpolate:r==null?void 0:r.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,r={})=>{const{transform:l,snapGrid:a,snapToGrid:o,domNode:u}=e.getState();if(!u)return t;const{x:c,y:d}=u.getBoundingClientRect(),h={x:t.x-c,y:t.y-d},m=r.snapGrid??a,p=r.snapToGrid??o;return ns(h,l,p,m)},flowToScreenPosition:t=>{const{transform:r,domNode:l}=e.getState();if(!l)return t;const{x:a,y:o}=l.getBoundingClientRect(),u=mc(t,r);return{x:u.x+a,y:u.y+o}}}),[])};function KS(e,t){const r=[],l=new Map,a=[];for(const o of e)if(o.type==="add"){a.push(o);continue}else if(o.type==="remove"||o.type==="replace")l.set(o.id,[o]);else{const u=l.get(o.id);u?u.push(o):l.set(o.id,[o])}for(const o of t){const u=l.get(o.id);if(!u){r.push(o);continue}if(u[0].type==="remove")continue;if(u[0].type==="replace"){r.push({...u[0].item});continue}const c={...o};for(const d of u)Ez(d,c);r.push(c)}return a.length&&a.forEach(o=>{o.index!==void 0?r.splice(o.index,0,{...o.item}):r.push({...o.item})}),r}function Ez(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function JS(e,t){return KS(e,t)}function WS(e,t){return KS(e,t)}function $i(e,t){return{id:e,type:"select",selected:t}}function ia(e,t=new Set,r=!1){const l=[];for(const[a,o]of e){const u=t.has(a);!(o.selected===void 0&&!u)&&o.selected!==u&&(r&&(o.selected=u),l.push($i(o.id,u)))}return l}function rb({items:e=[],lookup:t}){var a;const r=[],l=new Map(e.map(o=>[o.id,o]));for(const[o,u]of e.entries()){const c=t.get(u.id),d=((a=c==null?void 0:c.internals)==null?void 0:a.userNode)??c;d!==void 0&&d!==u&&r.push({id:u.id,item:u,type:"replace"}),d===void 0&&r.push({item:u,type:"add",index:o})}for(const[o]of t)l.get(o)===void 0&&r.push({id:o,type:"remove"});return r}function ib(e){return{id:e.id,type:"remove"}}const lb=e=>Xj(e),Nz=e=>SS(e);function e_(e){return P.forwardRef(e)}const Cz=typeof window<"u"?P.useLayoutEffect:P.useEffect;function ab(e){const[t,r]=P.useState(BigInt(0)),[l]=P.useState(()=>Tz(()=>r(a=>a+BigInt(1))));return Cz(()=>{const a=l.get();a.length&&(e(a),l.reset())},[t]),l}function Tz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:r=>{t.push(r),e()}}}const t_=P.createContext(null);function jz({children:e}){const t=mt(),r=P.useCallback(c=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:p,nodeLookup:x,fitViewQueued:b,onNodesChangeMiddlewareMap:w}=t.getState();let E=d;for(const S of c)E=typeof S=="function"?S(E):S;let _=rb({items:E,lookup:x});for(const S of w.values())_=S(_);m&&h(E),_.length>0?p==null||p(_):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:S,nodes:N,setNodes:k}=t.getState();S&&k(N)})},[]),l=ab(r),a=P.useCallback(c=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:x}=t.getState();let b=d;for(const w of c)b=typeof w=="function"?w(b):w;m?h(b):p&&p(rb({items:b,lookup:x}))},[]),o=ab(a),u=P.useMemo(()=>({nodeQueue:l,edgeQueue:o}),[]);return y.jsx(t_.Provider,{value:u,children:e})}function Az(){const e=P.useContext(t_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const zz=e=>!!e.panZoom;function al(){const e=kz(),t=mt(),r=Az(),l=Ye(zz),a=P.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),u=p=>{r.nodeQueue.push(p)},c=p=>{r.edgeQueue.push(p)},d=p=>{var S,N;const{nodeLookup:x,nodeOrigin:b}=t.getState(),w=lb(p)?p:x.get(p.id),E=w.parentId?TS(w.position,w.measured,w.parentId,x,b):w.position,_={...w,position:E,width:((S=w.measured)==null?void 0:S.width)??w.width,height:((N=w.measured)==null?void 0:N.height)??w.height};return ma(_)},h=(p,x,b={replace:!1})=>{u(w=>w.map(E=>{if(E.id===p){const _=typeof x=="function"?x(E):x;return b.replace&&lb(_)?_:{...E,..._}}return E}))},m=(p,x,b={replace:!1})=>{c(w=>w.map(E=>{if(E.id===p){const _=typeof x=="function"?x(E):x;return b.replace&&Nz(_)?_:{...E,..._}}return E}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var x;return(x=o(p))==null?void 0:x.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(x=>({...x}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:u,setEdges:c,addNodes:p=>{const x=Array.isArray(p)?p:[p];r.nodeQueue.push(b=>[...b,...x])},addEdges:p=>{const x=Array.isArray(p)?p:[p];r.edgeQueue.push(b=>[...b,...x])},toObject:()=>{const{nodes:p=[],edges:x=[],transform:b}=t.getState(),[w,E,_]=b;return{nodes:p.map(S=>({...S})),edges:x.map(S=>({...S})),viewport:{x:w,y:E,zoom:_}}},deleteElements:async({nodes:p=[],edges:x=[]})=>{const{nodes:b,edges:w,onNodesDelete:E,onEdgesDelete:_,triggerNodeChanges:S,triggerEdgeChanges:N,onDelete:k,onBeforeDelete:A}=t.getState(),{nodes:M,edges:j}=await Wj({nodesToRemove:p,edgesToRemove:x,nodes:b,edges:w,onBeforeDelete:A}),L=j.length>0,R=M.length>0;if(L){const V=j.map(ib);_==null||_(j),N(V)}if(R){const V=M.map(ib);E==null||E(M),S(V)}return(R||L)&&(k==null||k({nodes:M,edges:j})),{deletedNodes:M,deletedEdges:j}},getIntersectingNodes:(p,x=!0,b)=>{const w=zv(p),E=w?p:d(p),_=b!==void 0;return E?(b||t.getState().nodes).filter(S=>{const N=t.getState().nodeLookup.get(S.id);if(N&&!w&&(S.id===p.id||!N.internals.positionAbsolute))return!1;const k=ma(_?S:N),A=$o(k,E);return x&&A>0||A>=k.width*k.height||A>=E.width*E.height}):[]},isNodeIntersecting:(p,x,b=!0)=>{const E=zv(p)?p:d(p);if(!E)return!1;const _=$o(E,x);return b&&_>0||_>=x.width*x.height||_>=E.width*E.height},updateNode:h,updateNodeData:(p,x,b={replace:!1})=>{h(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},updateEdge:m,updateEdgeData:(p,x,b={replace:!1})=>{m(p,w=>{const E=typeof x=="function"?x(w):x;return b.replace?{...w,data:E}:{...w,data:{...w.data,...E}}},b)},getNodesBounds:p=>{const{nodeLookup:x,nodeOrigin:b}=t.getState();return Qj(p,{nodeLookup:x,nodeOrigin:b})},getHandleConnections:({type:p,id:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}-${p}${x?`-${x}`:""}`))==null?void 0:w.values())??[])},getNodeConnections:({type:p,handleId:x,nodeId:b})=>{var w;return Array.from(((w=t.getState().connectionLookup.get(`${b}${p?x?`-${p}-${x}`:`-${p}`:""}`))==null?void 0:w.values())??[])},fitView:async p=>{const x=t.getState().fitViewResolver??rA();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:x}),r.nodeQueue.push(b=>[...b]),x.promise}}},[]);return P.useMemo(()=>({...a,...e,viewportInitialized:l}),[l])}const ob=e=>e.selected,Mz=typeof window<"u"?window:void 0;function Dz({deleteKeyCode:e,multiSelectionKeyCode:t}){const r=mt(),{deleteElements:l}=al(),a=Fo(e,{actInsideInputWithModifier:!1}),o=Fo(t,{target:Mz});P.useEffect(()=>{if(a){const{edges:u,nodes:c}=r.getState();l({nodes:c.filter(ob),edges:u.filter(ob)}),r.setState({nodesSelectionActive:!1})}},[a]),P.useEffect(()=>{r.setState({multiSelectionActive:o})},[o])}function Rz(e){const t=mt();P.useEffect(()=>{const r=()=>{var a,o,u,c;if(!e.current||!(((o=(a=e.current).checkVisibility)==null?void 0:o.call(a))??!0))return!1;const l=Mm(e.current);(l.height===0||l.width===0)&&((c=(u=t.getState()).onError)==null||c.call(u,"004",lr.error004())),t.setState({width:l.width||500,height:l.height||500})};if(e.current){r(),window.addEventListener("resize",r);const l=new ResizeObserver(()=>r());return l.observe(e.current),()=>{window.removeEventListener("resize",r),l&&e.current&&l.unobserve(e.current)}}},[])}const Hc={position:"absolute",width:"100%",height:"100%",top:0,left:0},Oz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Lz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:r=!0,panOnScroll:l=!1,panOnScrollSpeed:a=.5,panOnScrollMode:o=Zi.Free,zoomOnDoubleClick:u=!0,panOnDrag:c=!0,defaultViewport:d,translateExtent:h,minZoom:m,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:w,noWheelClassName:E,noPanClassName:_,onViewportChange:S,isControlledViewport:N,paneClickDistance:k,selectionOnDrag:A}){const M=mt(),j=P.useRef(null),{userSelectionActive:L,lib:R,connectionInProgress:V}=Ye(Oz,pt),H=Fo(x),B=P.useRef();Rz(j);const U=P.useCallback(ee=>{S==null||S({x:ee[0],y:ee[1],zoom:ee[2]}),N||M.setState({transform:ee})},[S,N]);return P.useEffect(()=>{if(j.current){B.current=qA({domNode:j.current,minZoom:m,maxZoom:p,translateExtent:h,viewport:d,onDraggingChange:z=>M.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:Q,onMoveStart:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoom:(z,G)=>{const{onViewportChange:Q,onMove:K}=M.getState();K==null||K(z,G),Q==null||Q(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:Q,onMoveEnd:K}=M.getState();K==null||K(z,G),Q==null||Q(G)}});const{x:ee,y:I,zoom:F}=B.current.getViewport();return M.setState({panZoom:B.current,transform:[ee,I,F],domNode:j.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),P.useEffect(()=>{var ee;(ee=B.current)==null||ee.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:r,panOnScroll:l,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:u,panOnDrag:c,zoomActivationKeyPressed:H,preventScrolling:b,noPanClassName:_,userSelectionActive:L,noWheelClassName:E,lib:R,onTransformChange:U,connectionInProgress:V,selectionOnDrag:A,paneClickDistance:k})},[e,t,r,l,a,o,u,c,H,b,_,L,E,R,U,V,A,k]),y.jsx("div",{className:"react-flow__renderer",ref:j,style:Hc,children:w})}const Hz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Bz(){const{userSelectionActive:e,userSelectionRect:t}=Ye(Hz,pt);return e&&t?y.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Ch=(e,t)=>r=>{r.target===t.current&&(e==null||e(r))},Iz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function qz({isSelecting:e,selectionKeyPressed:t,selectionMode:r=Po.Full,panOnDrag:l,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:u,onSelectionEnd:c,onPaneClick:d,onPaneContextMenu:h,onPaneScroll:m,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:w}){const E=mt(),{userSelectionActive:_,elementsSelectable:S,dragging:N,connectionInProgress:k}=Ye(Iz,pt),A=S&&(e||_),M=P.useRef(null),j=P.useRef(),L=P.useRef(new Set),R=P.useRef(new Set),V=P.useRef(!1),H=Q=>{if(V.current||k){V.current=!1;return}d==null||d(Q),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},B=Q=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){Q.preventDefault();return}h==null||h(Q)},U=m?Q=>m(Q):void 0,ee=Q=>{V.current&&(Q.stopPropagation(),V.current=!1)},I=Q=>{var X,J;const{domNode:K}=E.getState();if(j.current=K==null?void 0:K.getBoundingClientRect(),!j.current)return;const D=Q.target===M.current;if(!D&&!!Q.target.closest(".nokey")||!e||!(o&&D||t)||Q.button!==0||!Q.isPrimary)return;(J=(X=Q.target)==null?void 0:X.setPointerCapture)==null||J.call(X,Q.pointerId),V.current=!1;const{x:C,y:$}=Pn(Q.nativeEvent,j.current);E.setState({userSelectionRect:{width:0,height:0,startX:C,startY:$,x:C,y:$}}),D||(Q.stopPropagation(),Q.preventDefault())},F=Q=>{const{userSelectionRect:K,transform:D,nodeLookup:q,edgeLookup:Y,connectionLookup:C,triggerNodeChanges:$,triggerEdgeChanges:X,defaultEdgeOptions:J,resetSelectedElements:ne}=E.getState();if(!j.current||!K)return;const{x:re,y:se}=Pn(Q.nativeEvent,j.current),{startX:xe,startY:be}=K;if(!V.current){const Te=t?0:a;if(Math.hypot(re-xe,se-be)<=Te)return;ne(),u==null||u(Q)}V.current=!0;const ye={startX:xe,startY:be,x:reTe.id)),R.current=new Set;const ze=(J==null?void 0:J.selectable)??!0;for(const Te of L.current){const ut=C.get(Te);if(ut)for(const{edgeId:nt}of ut.values()){const zt=Y.get(nt);zt&&(zt.selectable??ze)&&R.current.add(nt)}}if(!Mv(pe,L.current)){const Te=ia(q,L.current,!0);$(Te)}if(!Mv(_e,R.current)){const Te=ia(Y,R.current);X(Te)}E.setState({userSelectionRect:ye,userSelectionActive:!0,nodesSelectionActive:!1})},z=Q=>{var K,D;Q.button===0&&((D=(K=Q.target)==null?void 0:K.releasePointerCapture)==null||D.call(K,Q.pointerId),!_&&Q.target===M.current&&E.getState().userSelectionRect&&(H==null||H(Q)),E.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(Q),E.setState({nodesSelectionActive:L.current.size>0})))},G=l===!0||Array.isArray(l)&&l.includes(0);return y.jsxs("div",{className:At(["react-flow__pane",{draggable:G,dragging:N,selection:e}]),onClick:A?void 0:Ch(H,M),onContextMenu:Ch(B,M),onWheel:Ch(U,M),onPointerEnter:A?void 0:p,onPointerMove:A?F:x,onPointerUp:A?z:void 0,onPointerDownCapture:A?I:void 0,onClickCapture:A?ee:void 0,onPointerLeave:b,ref:M,style:Hc,children:[w,y.jsx(Bz,{})]})}function rm({id:e,store:t,unselect:r=!1,nodeRef:l}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:u,nodeLookup:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",lr.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&u)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=l==null?void 0:l.current)==null?void 0:m.blur()})):a([e])}function n_({nodeRef:e,disabled:t=!1,noDragClassName:r,handleSelector:l,nodeId:a,isSelectable:o,nodeClickDistance:u}){const c=mt(),[d,h]=P.useState(!1),m=P.useRef();return P.useEffect(()=>{m.current=NA({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{rm({id:p,store:c,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),P.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:r,handleSelector:l,domNode:e.current,isSelectable:o,nodeId:a,nodeClickDistance:u}),()=>{var p;(p=m.current)==null||p.destroy()}},[r,l,t,o,e,a,u]),d}const Uz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function r_(){const e=mt();return P.useCallback(r=>{const{nodeExtent:l,snapToGrid:a,snapGrid:o,nodesDraggable:u,onError:c,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),p=new Map,x=Uz(u),b=a?o[0]:5,w=a?o[1]:5,E=r.direction.x*b*r.factor,_=r.direction.y*w*r.factor;for(const[,S]of h){if(!x(S))continue;let N={x:S.internals.positionAbsolute.x+E,y:S.internals.positionAbsolute.y+_};a&&(N=ts(N,o));const{position:k,positionAbsolute:A}=_S({nodeId:S.id,nextPosition:N,nodeLookup:h,nodeExtent:l,nodeOrigin:m,onError:c});S.position=k,S.internals.positionAbsolute=A,p.set(S.id,S)}d(p)},[])}const Im=P.createContext(null),Vz=Im.Provider;Im.Consumer;const i_=()=>P.useContext(Im),Pz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),$z=(e,t,r)=>l=>{const{connectionClickStartHandle:a,connectionMode:o,connection:u}=l,{fromHandle:c,toHandle:d,isValid:h}=u,m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===r;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===r,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===r,isPossibleEndHandle:o===ha.Strict?(c==null?void 0:c.type)!==r:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!a,valid:m&&h}};function Gz({type:e="source",position:t=ve.Top,isValidConnection:r,isConnectable:l=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:u,onConnect:c,children:d,className:h,onMouseDown:m,onTouchStart:p,...x},b){var F,z;const w=u||null,E=e==="target",_=mt(),S=i_(),{connectOnClick:N,noPanClassName:k,rfId:A}=Ye(Pz,pt),{connectingFrom:M,connectingTo:j,clickConnecting:L,isPossibleEndHandle:R,connectionInProcess:V,clickConnectionInProcess:H,valid:B}=Ye($z(S,w,e),pt);S||(z=(F=_.getState()).onError)==null||z.call(F,"010",lr.error010());const U=G=>{const{defaultEdgeOptions:Q,onConnect:K,hasDefaultEdges:D}=_.getState(),q={...Q,...G};if(D){const{edges:Y,setEdges:C}=_.getState();C(cA(q,Y))}K==null||K(q),c==null||c(q)},ee=G=>{if(!S)return;const Q=zS(G.nativeEvent);if(a&&(Q&&G.button===0||!Q)){const K=_.getState();nm.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:E,handleId:w,nodeId:S,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...D)=>{var q,Y;return(Y=(q=_.getState()).onConnectEnd)==null?void 0:Y.call(q,...D)},updateConnection:K.updateConnection,onConnect:U,isValidConnection:r||((...D)=>{var q,Y;return((Y=(q=_.getState()).isValidConnection)==null?void 0:Y.call(q,...D))??!0}),getTransform:()=>_.getState().transform,getFromHandle:()=>_.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}Q?m==null||m(G):p==null||p(G)},I=G=>{const{onClickConnectStart:Q,onClickConnectEnd:K,connectionClickStartHandle:D,connectionMode:q,isValidConnection:Y,lib:C,rfId:$,nodeLookup:X,connection:J}=_.getState();if(!S||!D&&!a)return;if(!D){Q==null||Q(G.nativeEvent,{nodeId:S,handleId:w,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:S,type:e,id:w}});return}const ne=jS(G.target),re=r||Y,{connection:se,isValid:xe}=nm.isValid(G.nativeEvent,{handle:{nodeId:S,id:w,type:e},connectionMode:q,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:re,flowId:$,doc:ne,lib:C,nodeLookup:X});xe&&se&&U(se);const be=structuredClone(J);delete be.inProgress,be.toPosition=be.toHandle?be.toHandle.position:null,K==null||K(G,be),_.setState({connectionClickStartHandle:null})};return y.jsx("div",{"data-handleid":w,"data-nodeid":S,"data-handlepos":t,"data-id":`${A}-${S}-${w}-${e}`,className:At(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,h,{source:!E,target:E,connectable:l,connectablestart:a,connectableend:o,clickconnecting:L,connectingfrom:M,connectingto:j,valid:B,connectionindicator:l&&(!V||R)&&(V||H?o:a)}]),onMouseDown:ee,onTouchStart:ee,onClick:N?I:void 0,ref:b,...x,children:d})}const Lt=P.memo(e_(Gz));function Fz({data:e,isConnectable:t,sourcePosition:r=ve.Bottom}){return y.jsxs(y.Fragment,{children:[e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:r,isConnectable:t})]})}function Yz({data:e,isConnectable:t,targetPosition:r=ve.Top,sourcePosition:l=ve.Bottom}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label,y.jsx(Lt,{type:"source",position:l,isConnectable:t})]})}function Xz(){return null}function Qz({data:e,isConnectable:t,targetPosition:r=ve.Top}){return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:r,isConnectable:t}),e==null?void 0:e.label]})}const gc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},sb={input:Fz,default:Yz,output:Qz,group:Xz};function Zz(e){var t,r,l,a;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((r=e.style)==null?void 0:r.height)}:{width:e.width??((l=e.style)==null?void 0:l.width),height:e.height??((a=e.style)==null?void 0:a.height)}}const Kz=e=>{const{width:t,height:r,x:l,y:a}=es(e.nodeLookup,{filter:o=>!!o.selected});return{width:Vn(t)?t:null,height:Vn(r)?r:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${l}px,${a}px)`}};function Jz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:r}){const l=mt(),{width:a,height:o,transformString:u,userSelectionActive:c}=Ye(Kz,pt),d=r_(),h=P.useRef(null);P.useEffect(()=>{var b;r||(b=h.current)==null||b.focus({preventScroll:!0})},[r]);const m=!c&&a!==null&&o!==null;if(n_({nodeRef:h,disabled:!m}),!m)return null;const p=e?b=>{const w=l.getState().nodes.filter(E=>E.selected);e(b,w)}:void 0,x=b=>{Object.prototype.hasOwnProperty.call(gc,b.key)&&(b.preventDefault(),d({direction:gc[b.key],factor:b.shiftKey?4:1}))};return y.jsx("div",{className:At(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u},children:y.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:a,height:o}})})}const ub=typeof window<"u"?window:void 0,Wz=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function l_({children:e,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,paneClickDistance:c,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:p,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:w,panActivationKeyCode:E,zoomActivationKeyCode:_,elementsSelectable:S,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:A,panOnScrollSpeed:M,panOnScrollMode:j,zoomOnDoubleClick:L,panOnDrag:R,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,preventScrolling:ee,onSelectionContextMenu:I,noWheelClassName:F,noPanClassName:z,disableKeyboardA11y:G,onViewportChange:Q,isControlledViewport:K}){const{nodesSelectionActive:D,userSelectionActive:q}=Ye(Wz,pt),Y=Fo(h,{target:ub}),C=Fo(E,{target:ub}),$=C||R,X=C||A,J=m&&$!==!0,ne=Y||q||J;return Dz({deleteKeyCode:d,multiSelectionKeyCode:w}),y.jsx(Lz,{onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:N,zoomOnPinch:k,panOnScroll:X,panOnScrollSpeed:M,panOnScrollMode:j,zoomOnDoubleClick:L,panOnDrag:!Y&&$,defaultViewport:V,translateExtent:H,minZoom:B,maxZoom:U,zoomActivationKeyCode:_,preventScrolling:ee,noWheelClassName:F,noPanClassName:z,onViewportChange:Q,isControlledViewport:K,paneClickDistance:c,selectionOnDrag:J,children:y.jsxs(qz,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:r,onPaneMouseMove:l,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:u,panOnDrag:$,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Y,paneClickDistance:c,selectionOnDrag:J,children:[e,D&&y.jsx(Jz,{onSelectionContextMenu:I,noPanClassName:z,disableKeyboardA11y:G})]})})}l_.displayName="FlowRenderer";const eM=P.memo(l_),tM=e=>t=>e?Am(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(r=>r.id):Array.from(t.nodeLookup.keys());function nM(e){return Ye(P.useCallback(tM(e),[e]),pt)}const rM=e=>e.updateNodeInternals;function iM(){const e=Ye(rM),[t]=P.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(r=>{const l=new Map;r.forEach(a=>{const o=a.target.getAttribute("data-id");l.set(o,{id:o,nodeElement:a.target,force:!0})}),e(l)}));return P.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function lM({node:e,nodeType:t,hasDimensions:r,resizeObserver:l}){const a=mt(),o=P.useRef(null),u=P.useRef(null),c=P.useRef(e.sourcePosition),d=P.useRef(e.targetPosition),h=P.useRef(t),m=r&&!!e.internals.handleBounds;return P.useEffect(()=>{o.current&&!e.hidden&&(!m||u.current!==o.current)&&(u.current&&(l==null||l.unobserve(u.current)),l==null||l.observe(o.current),u.current=o.current)},[m,e.hidden]),P.useEffect(()=>()=>{u.current&&(l==null||l.unobserve(u.current),u.current=null)},[]),P.useEffect(()=>{if(o.current){const p=h.current!==t,x=c.current!==e.sourcePosition,b=d.current!==e.targetPosition;(p||x||b)&&(h.current=t,c.current=e.sourcePosition,d.current=e.targetPosition,a.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function aM({id:e,onClick:t,onMouseEnter:r,onMouseMove:l,onMouseLeave:a,onContextMenu:o,onDoubleClick:u,nodesDraggable:c,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:p,noDragClassName:x,noPanClassName:b,disableKeyboardA11y:w,rfId:E,nodeTypes:_,nodeClickDistance:S,onError:N}){const{node:k,internals:A,isParent:M}=Ye(re=>{const se=re.nodeLookup.get(e),xe=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:xe}},pt);let j=k.type||"default",L=(_==null?void 0:_[j])||sb[j];L===void 0&&(N==null||N("003",lr.error003(j)),j="default",L=(_==null?void 0:_.default)||sb.default);const R=!!(k.draggable||c&&typeof k.draggable>"u"),V=!!(k.selectable||d&&typeof k.selectable>"u"),H=!!(k.connectable||h&&typeof k.connectable>"u"),B=!!(k.focusable||m&&typeof k.focusable>"u"),U=mt(),ee=CS(k),I=lM({node:k,nodeType:j,hasDimensions:ee,resizeObserver:p}),F=n_({nodeRef:I,disabled:k.hidden||!R,noDragClassName:x,handleSelector:k.dragHandle,nodeId:e,isSelectable:V,nodeClickDistance:S}),z=r_();if(k.hidden)return null;const G=Or(k),Q=Zz(k),K=V||R||t||r||l||a,D=r?re=>r(re,{...A.userNode}):void 0,q=l?re=>l(re,{...A.userNode}):void 0,Y=a?re=>a(re,{...A.userNode}):void 0,C=o?re=>o(re,{...A.userNode}):void 0,$=u?re=>u(re,{...A.userNode}):void 0,X=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:xe}=U.getState();V&&(!se||!R||xe>0)&&rm({id:e,store:U,nodeRef:I}),t&&t(re,{...A.userNode})},J=re=>{if(!(AS(re.nativeEvent)||w)){if(yS.includes(re.key)&&V){const se=re.key==="Escape";rm({id:e,store:U,unselect:se,nodeRef:I})}else if(R&&k.selected&&Object.prototype.hasOwnProperty.call(gc,re.key)){re.preventDefault();const{ariaLabelConfig:se}=U.getState();U.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),z({direction:gc[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var _e;if(w||!((_e=I.current)!=null&&_e.matches(":focus-visible")))return;const{transform:re,width:se,height:xe,autoPanOnNodeFocus:be,setCenter:ye}=U.getState();if(!be)return;Am(new Map([[e,k]]),{x:0,y:0,width:se,height:xe},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return y.jsx("div",{className:At(["react-flow__node",`react-flow__node-${j}`,{[b]:R},k.className,{selected:k.selected,selectable:V,parent:M,draggable:R,dragging:F}]),ref:I,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:ee?"visible":"hidden",...k.style,...Q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:q,onMouseLeave:Y,onContextMenu:C,onClick:X,onDoubleClick:$,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:k.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":w?void 0:`${XS}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:y.jsx(Vz,{value:e,children:y.jsx(L,{id:e,data:k.data,type:j,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:k.selected??!1,selectable:V,draggable:R,deletable:k.deletable??!0,isConnectable:H,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:F,dragHandle:k.dragHandle,zIndex:A.z,parentId:k.parentId,...G})})})}var oM=P.memo(aM);const sM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function a_(e){const{nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,onError:o}=Ye(sM,pt),u=nM(e.onlyRenderVisibleElements),c=iM();return y.jsx("div",{className:"react-flow__nodes",style:Hc,children:u.map(d=>y.jsx(oM,{id:d,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:r,nodesFocusable:l,elementsSelectable:a,nodeClickDistance:e.nodeClickDistance,onError:o},d))})}a_.displayName="NodeRenderer";const uM=P.memo(a_);function cM(e){return Ye(P.useCallback(r=>{if(!e)return r.edges.map(a=>a.id);const l=[];if(r.width&&r.height)for(const a of r.edges){const o=r.nodeLookup.get(a.source),u=r.nodeLookup.get(a.target);o&&u&&oA({sourceNode:o,targetNode:u,width:r.width,height:r.height,transform:r.transform})&&l.push(a.id)}return l},[e]),pt)}const fM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e}};return y.jsx("polyline",{className:"arrow",style:r,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},dM=({color:e="none",strokeWidth:t=1})=>{const r={strokeWidth:t,...e&&{stroke:e,fill:e}};return y.jsx("polyline",{className:"arrowclosed",style:r,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},cb={[hc.Arrow]:fM,[hc.ArrowClosed]:dM};function hM(e){const t=mt();return P.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(cb,e)?cb[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",lr.error009(e)),null)},[e])}const pM=({id:e,type:t,color:r,width:l=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const d=hM(t);return d?y.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${l}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0",children:y.jsx(d,{color:r,strokeWidth:u})}):null},o_=({defaultColor:e,rfId:t})=>{const r=Ye(o=>o.edges),l=Ye(o=>o.defaultEdgeOptions),a=P.useMemo(()=>mA(r,{id:t,defaultColor:e,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[r,l,t,e]);return a.length?y.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:y.jsx("defs",{children:a.map(o=>y.jsx(pM,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};o_.displayName="MarkerDefinitions";var mM=P.memo(o_);function s_({x:e,y:t,label:r,labelStyle:l,labelShowBg:a=!0,labelBgStyle:o,labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...m}){const[p,x]=P.useState({x:1,y:0,width:0,height:0}),b=At(["react-flow__edge-textwrapper",h]),w=P.useRef(null);return P.useEffect(()=>{if(w.current){const E=w.current.getBBox();x({x:E.x,y:E.y,width:E.width,height:E.height})}},[r]),r?y.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[a&&y.jsx("rect",{width:p.width+2*u[0],x:-u[0],y:-u[1],height:p.height+2*u[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),y.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:w,style:l,children:r}),d]}):null}s_.displayName="EdgeText";const gM=P.memo(s_);function rs({path:e,labelX:t,labelY:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return y.jsxs(y.Fragment,{children:[y.jsx("path",{...m,d:e,fill:"none",className:At(["react-flow__edge-path",m.className])}),h?y.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,l&&Vn(t)&&Vn(r)?y.jsx(gM,{x:t,y:r,label:l,labelStyle:a,labelShowBg:o,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d}):null]})}function fb({pos:e,x1:t,y1:r,x2:l,y2:a}){return e===ve.Left||e===ve.Right?[.5*(t+l),r]:[t,.5*(r+a)]}function u_({sourceX:e,sourceY:t,sourcePosition:r=ve.Bottom,targetX:l,targetY:a,targetPosition:o=ve.Top}){const[u,c]=fb({pos:r,x1:e,y1:t,x2:l,y2:a}),[d,h]=fb({pos:o,x1:l,y1:a,x2:e,y2:t}),[m,p,x,b]=MS({sourceX:e,sourceY:t,targetX:l,targetY:a,sourceControlX:u,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${u},${c} ${d},${h} ${l},${a}`,m,p,x,b]}function c_(e){return P.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:_,interactionWidth:S})=>{const[N,k,A]=u_({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c}),M=e.isInternal?void 0:t;return y.jsx(rs,{id:M,path:N,labelX:k,labelY:A,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:_,interactionWidth:S})})}const xM=c_({isInternal:!1}),f_=c_({isInternal:!0});xM.displayName="SimpleBezierEdge";f_.displayName="SimpleBezierEdgeInternal";function d_(e){return P.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,sourcePosition:b=ve.Bottom,targetPosition:w=ve.Top,markerEnd:E,markerStart:_,pathOptions:S,interactionWidth:N})=>{const[k,A,M]=Wp({sourceX:r,sourceY:l,sourcePosition:b,targetX:a,targetY:o,targetPosition:w,borderRadius:S==null?void 0:S.borderRadius,offset:S==null?void 0:S.offset,stepPosition:S==null?void 0:S.stepPosition}),j=e.isInternal?void 0:t;return y.jsx(rs,{id:j,path:k,labelX:A,labelY:M,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:E,markerStart:_,interactionWidth:N})})}const h_=d_({isInternal:!1}),p_=d_({isInternal:!0});h_.displayName="SmoothStepEdge";p_.displayName="SmoothStepEdgeInternal";function m_(e){return P.memo(({id:t,...r})=>{var a;const l=e.isInternal?void 0:t;return y.jsx(h_,{...r,id:l,pathOptions:P.useMemo(()=>{var o;return{borderRadius:0,offset:(o=r.pathOptions)==null?void 0:o.offset}},[(a=r.pathOptions)==null?void 0:a.offset])})})}const yM=m_({isInternal:!1}),g_=m_({isInternal:!0});yM.displayName="StepEdge";g_.displayName="StepEdgeInternal";function x_(e){return P.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})=>{const[_,S,N]=RS({sourceX:r,sourceY:l,targetX:a,targetY:o}),k=e.isInternal?void 0:t;return y.jsx(rs,{id:k,path:_,labelX:S,labelY:N,label:u,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:w,interactionWidth:E})})}const vM=x_({isInternal:!1}),y_=x_({isInternal:!0});vM.displayName="StraightEdge";y_.displayName="StraightEdgeInternal";function v_(e){return P.memo(({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u=ve.Bottom,targetPosition:c=ve.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:_,pathOptions:S,interactionWidth:N})=>{const[k,A,M]=Dm({sourceX:r,sourceY:l,sourcePosition:u,targetX:a,targetY:o,targetPosition:c,curvature:S==null?void 0:S.curvature}),j=e.isInternal?void 0:t;return y.jsx(rs,{id:j,path:k,labelX:A,labelY:M,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:x,labelBgBorderRadius:b,style:w,markerEnd:E,markerStart:_,interactionWidth:N})})}const bM=v_({isInternal:!1}),b_=v_({isInternal:!0});bM.displayName="BezierEdge";b_.displayName="BezierEdgeInternal";const db={default:b_,straight:y_,step:g_,smoothstep:p_,simplebezier:f_},hb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},wM=(e,t,r)=>r===ve.Left?e-t:r===ve.Right?e+t:e,SM=(e,t,r)=>r===ve.Top?e-t:r===ve.Bottom?e+t:e,pb="react-flow__edgeupdater";function mb({position:e,centerX:t,centerY:r,radius:l=10,onMouseDown:a,onMouseEnter:o,onMouseOut:u,type:c}){return y.jsx("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:u,className:At([pb,`${pb}-${c}`]),cx:wM(t,l,e),cy:SM(r,l,e),r:l,stroke:"transparent",fill:"transparent"})}function _M({isReconnectable:e,reconnectRadius:t,edge:r,sourceX:l,sourceY:a,targetX:o,targetY:u,sourcePosition:c,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:p,setReconnecting:x,setUpdateHover:b}){const w=mt(),E=(A,M)=>{if(A.button!==0)return;const{autoPanOnConnect:j,domNode:L,connectionMode:R,connectionRadius:V,lib:H,onConnectStart:B,cancelConnection:U,nodeLookup:ee,rfId:I,panBy:F,updateConnection:z}=w.getState(),G=M.type==="target",Q=(q,Y)=>{x(!1),p==null||p(q,r,M.type,Y)},K=q=>h==null?void 0:h(r,q),D=(q,Y)=>{x(!0),m==null||m(A,r,M.type),B==null||B(q,Y)};nm.onPointerDown(A.nativeEvent,{autoPanOnConnect:j,connectionMode:R,connectionRadius:V,domNode:L,handleId:M.id,nodeId:M.nodeId,nodeLookup:ee,isTarget:G,edgeUpdaterType:M.type,lib:H,flowId:I,cancelConnection:U,panBy:F,isValidConnection:(...q)=>{var Y,C;return((C=(Y=w.getState()).isValidConnection)==null?void 0:C.call(Y,...q))??!0},onConnect:K,onConnectStart:D,onConnectEnd:(...q)=>{var Y,C;return(C=(Y=w.getState()).onConnectEnd)==null?void 0:C.call(Y,...q)},onReconnectEnd:Q,updateConnection:z,getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,dragThreshold:w.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},_=A=>E(A,{nodeId:r.target,id:r.targetHandle??null,type:"target"}),S=A=>E(A,{nodeId:r.source,id:r.sourceHandle??null,type:"source"}),N=()=>b(!0),k=()=>b(!1);return y.jsxs(y.Fragment,{children:[(e===!0||e==="source")&&y.jsx(mb,{position:c,centerX:l,centerY:a,radius:t,onMouseDown:_,onMouseEnter:N,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&y.jsx(mb,{position:d,centerX:o,centerY:u,radius:t,onMouseDown:S,onMouseEnter:N,onMouseOut:k,type:"target"})]})}function kM({id:e,edgesFocusable:t,edgesReconnectable:r,elementsSelectable:l,onClick:a,onDoubleClick:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,rfId:w,edgeTypes:E,noPanClassName:_,onError:S,disableKeyboardA11y:N}){let k=Ye(ye=>ye.edgeLookup.get(e));const A=Ye(ye=>ye.defaultEdgeOptions);k=A?{...A,...k}:k;let M=k.type||"default",j=(E==null?void 0:E[M])||db[M];j===void 0&&(S==null||S("011",lr.error011(M)),M="default",j=(E==null?void 0:E.default)||db.default);const L=!!(k.focusable||t&&typeof k.focusable>"u"),R=typeof p<"u"&&(k.reconnectable||r&&typeof k.reconnectable>"u"),V=!!(k.selectable||l&&typeof k.selectable>"u"),H=P.useRef(null),[B,U]=P.useState(!1),[ee,I]=P.useState(!1),F=mt(),{zIndex:z,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y}=Ye(P.useCallback(ye=>{const pe=ye.nodeLookup.get(k.source),_e=ye.nodeLookup.get(k.target);if(!pe||!_e)return{zIndex:k.zIndex,...hb};const ze=pA({id:e,sourceNode:pe,targetNode:_e,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:S});return{zIndex:aA({selected:k.selected,zIndex:k.zIndex,sourceNode:pe,targetNode:_e,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode}),...ze||hb}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),pt),C=P.useMemo(()=>k.markerStart?`url('#${em(k.markerStart,w)}')`:void 0,[k.markerStart,w]),$=P.useMemo(()=>k.markerEnd?`url('#${em(k.markerEnd,w)}')`:void 0,[k.markerEnd,w]);if(k.hidden||G===null||Q===null||K===null||D===null)return null;const X=ye=>{var Te;const{addSelectedEdges:pe,unselectNodesAndEdges:_e,multiSelectionActive:ze}=F.getState();V&&(F.setState({nodesSelectionActive:!1}),k.selected&&ze?(_e({nodes:[],edges:[k]}),(Te=H.current)==null||Te.blur()):pe([e])),a&&a(ye,k)},J=o?ye=>{o(ye,{...k})}:void 0,ne=u?ye=>{u(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,se=d?ye=>{d(ye,{...k})}:void 0,xe=h?ye=>{h(ye,{...k})}:void 0,be=ye=>{var pe;if(!N&&yS.includes(ye.key)&&V){const{unselectNodesAndEdges:_e,addSelectedEdges:ze}=F.getState();ye.key==="Escape"?((pe=H.current)==null||pe.blur(),_e({edges:[k]})):ze([e])}};return y.jsx("svg",{style:{zIndex:z},children:y.jsxs("g",{className:At(["react-flow__edge",`react-flow__edge-${M}`,k.className,_,{selected:k.selected,animated:k.animated,inactive:!V&&!a,updating:B,selectable:V}]),onClick:X,onDoubleClick:J,onContextMenu:ne,onMouseEnter:re,onMouseMove:se,onMouseLeave:xe,onKeyDown:L?be:void 0,tabIndex:L?0:void 0,role:k.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":L?`${QS}-${w}`:void 0,ref:H,...k.domAttributes,children:[!ee&&y.jsx(j,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:V,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:C,markerEnd:$,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),R&&y.jsx(_M,{edge:k,isReconnectable:R,reconnectRadius:m,onReconnect:p,onReconnectStart:x,onReconnectEnd:b,sourceX:G,sourceY:Q,targetX:K,targetY:D,sourcePosition:q,targetPosition:Y,setUpdateHover:U,setReconnecting:I})]})})}var EM=P.memo(kM);const NM=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function w_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:r,edgeTypes:l,noPanClassName:a,onReconnect:o,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,disableKeyboardA11y:E}){const{edgesFocusable:_,edgesReconnectable:S,elementsSelectable:N,onError:k}=Ye(NM,pt),A=cM(t);return y.jsxs("div",{className:"react-flow__edges",children:[y.jsx(mM,{defaultColor:e,rfId:r}),A.map(M=>y.jsx(EM,{id:M,edgesFocusable:_,edgesReconnectable:S,elementsSelectable:N,noPanClassName:a,onReconnect:o,onContextMenu:u,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:p,onDoubleClick:x,onReconnectStart:b,onReconnectEnd:w,rfId:r,onError:k,edgeTypes:l,disableKeyboardA11y:E},M))]})}w_.displayName="EdgeRenderer";const CM=P.memo(w_),TM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function jM({children:e}){const t=Ye(TM);return y.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function AM(e){const t=al(),r=P.useRef(!1);P.useEffect(()=>{!r.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),r.current=!0)},[e,t.viewportInitialized])}const zM=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function MM(e){const t=Ye(zM),r=mt();return P.useEffect(()=>{e&&(t==null||t(e),r.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function DM(e){return e.connection.inProgress?{...e.connection,to:ns(e.connection.to,e.transform)}:{...e.connection}}function RM(e){return DM}function OM(e){const t=RM();return Ye(t,pt)}const LM=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function HM({containerStyle:e,style:t,type:r,component:l}){const{nodesConnectable:a,width:o,height:u,isValid:c,inProgress:d}=Ye(LM,pt);return!(o&&a&&d)?null:y.jsx("svg",{style:e,width:o,height:u,className:"react-flow__connectionline react-flow__container",children:y.jsx("g",{className:At(["react-flow__connection",wS(c)]),children:y.jsx(S_,{style:t,type:r,CustomComponent:l,isValid:c})})})}const S_=({style:e,type:t=xi.Bezier,CustomComponent:r,isValid:l})=>{const{inProgress:a,from:o,fromNode:u,fromHandle:c,fromPosition:d,to:h,toNode:m,toHandle:p,toPosition:x,pointer:b}=OM();if(!a)return;if(r)return y.jsx(r,{connectionLineType:t,connectionLineStyle:e,fromNode:u,fromHandle:c,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:x,connectionStatus:wS(l),toNode:m,toHandle:p,pointer:b});let w="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:x};switch(t){case xi.Bezier:[w]=Dm(E);break;case xi.SimpleBezier:[w]=u_(E);break;case xi.Step:[w]=Wp({...E,borderRadius:0});break;case xi.SmoothStep:[w]=Wp(E);break;default:[w]=RS(E)}return y.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:e})};S_.displayName="ConnectionLine";const BM={};function gb(e=BM){P.useRef(e),mt(),P.useEffect(()=>{},[e])}function IM(){mt(),P.useRef(!1),P.useEffect(()=>{},[])}function __({nodeTypes:e,edgeTypes:t,onInit:r,onNodeClick:l,onEdgeClick:a,onNodeDoubleClick:o,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:x,onSelectionEnd:b,connectionLineType:w,connectionLineStyle:E,connectionLineComponent:_,connectionLineContainerStyle:S,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,multiSelectionKeyCode:M,panActivationKeyCode:j,zoomActivationKeyCode:L,deleteKeyCode:R,onlyRenderVisibleElements:V,elementsSelectable:H,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,preventScrolling:F,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:Q,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:C,onPaneClick:$,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:xe,nodeClickDistance:be,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:_e,onEdgeMouseLeave:ze,reconnectRadius:Te,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,noDragClassName:Pt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr,viewport:ue,onViewportChange:ge}){return gb(e),gb(t),IM(),AM(r),MM(ue),y.jsx(eM,{onPaneClick:$,onPaneMouseEnter:X,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:xe,deleteKeyCode:R,selectionKeyCode:N,selectionOnDrag:k,selectionMode:A,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:M,panActivationKeyCode:j,zoomActivationKeyCode:L,elementsSelectable:H,zoomOnScroll:G,zoomOnPinch:Q,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:D,panOnScrollMode:q,panOnDrag:C,defaultViewport:B,translateExtent:U,minZoom:ee,maxZoom:I,onSelectionContextMenu:p,preventScrolling:F,noDragClassName:Pt,noWheelClassName:Ht,noPanClassName:kn,disableKeyboardA11y:Rn,onViewportChange:ge,isControlledViewport:!!ue,children:y.jsxs(jM,{children:[y.jsx(CM,{edgeTypes:t,onEdgeClick:a,onEdgeDoubleClick:u,onReconnect:ut,onReconnectStart:nt,onReconnectEnd:zt,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:pe,onEdgeMouseMove:_e,onEdgeMouseLeave:ze,reconnectRadius:Te,defaultMarkerColor:z,noPanClassName:kn,disableKeyboardA11y:Rn,rfId:Hr}),y.jsx(HM,{style:E,type:w,component:_,containerStyle:S}),y.jsx("div",{className:"react-flow__edgelabel-renderer"}),y.jsx(uM,{nodeTypes:e,onNodeClick:l,onNodeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:be,onlyRenderVisibleElements:V,noPanClassName:kn,noDragClassName:Pt,disableKeyboardA11y:Rn,nodeExtent:Mt,rfId:Hr}),y.jsx("div",{className:"react-flow__viewport-portal"})]})})}__.displayName="GraphView";const qM=P.memo(__),xb=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:p,zIndexMode:x="basic"}={})=>{const b=new Map,w=new Map,E=new Map,_=new Map,S=l??t??[],N=r??e??[],k=m??[0,0],A=p??Vo;HS(E,_,S);const M=tm(N,b,w,{nodeOrigin:k,nodeExtent:A,zIndexMode:x});let j=[0,0,1];if(u&&a&&o){const L=es(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:R,y:V,zoom:H}=zm(L,a,o,d,h,(c==null?void 0:c.padding)??.1);j=[R,V,H]}return{rfId:"1",width:a??0,height:o??0,transform:j,nodes:N,nodesInitialized:M,nodeLookup:b,parentLookup:w,edges:S,edgeLookup:_,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:r!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:Vo,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ha.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:u??!1,fitViewOptions:c,fitViewResolver:null,connection:{...bS},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:eA,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:vS,zIndexMode:x,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},UM=({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x})=>iz((b,w)=>{async function E(){const{nodeLookup:_,panZoom:S,fitViewOptions:N,fitViewResolver:k,width:A,height:M,minZoom:j,maxZoom:L}=w();S&&(await Jj({nodes:_,width:A,height:M,panZoom:S,minZoom:j,maxZoom:L},N),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...xb({nodes:e,edges:t,width:a,height:o,fitView:u,fitViewOptions:c,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,defaultNodes:r,defaultEdges:l,zIndexMode:x}),setNodes:_=>{const{nodeLookup:S,parentLookup:N,nodeOrigin:k,elevateNodesOnSelect:A,fitViewQueued:M,zIndexMode:j}=w(),L=tm(_,S,N,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:j});M&&L?(E(),b({nodes:_,nodesInitialized:L,fitViewQueued:!1,fitViewOptions:void 0})):b({nodes:_,nodesInitialized:L})},setEdges:_=>{const{connectionLookup:S,edgeLookup:N}=w();HS(S,N,_),b({edges:_})},setDefaultNodesAndEdges:(_,S)=>{if(_){const{setNodes:N}=w();N(_),b({hasDefaultNodes:!0})}if(S){const{setEdges:N}=w();N(S),b({hasDefaultEdges:!0})}},updateNodeInternals:_=>{const{triggerNodeChanges:S,nodeLookup:N,parentLookup:k,domNode:A,nodeOrigin:M,nodeExtent:j,debug:L,fitViewQueued:R,zIndexMode:V}=w(),{changes:H,updatedInternals:B}=SA(_,N,k,A,M,j,V);B&&(yA(N,k,{nodeOrigin:M,nodeExtent:j,zIndexMode:V}),R?(E(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(H==null?void 0:H.length)>0&&(L&&console.log("React Flow: trigger node changes",H),S==null||S(H)))},updateNodePositions:(_,S=!1)=>{const N=[];let k=[];const{nodeLookup:A,triggerNodeChanges:M,connection:j,updateConnection:L,onNodesChangeMiddlewareMap:R}=w();for(const[V,H]of _){const B=A.get(V),U=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),ee={id:V,type:"position",position:U?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:S};if(B&&j.inProgress&&j.fromNode.id===B.id){const I=tl(B,j.fromHandle,ve.Left,!0);L({...j,from:I})}U&&B.parentId&&N.push({id:V,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),k.push(ee)}if(N.length>0){const{parentLookup:V,nodeOrigin:H}=w(),B=Bm(N,A,V,H);k.push(...B)}for(const V of R.values())k=V(k);M(k)},triggerNodeChanges:_=>{const{onNodesChange:S,setNodes:N,nodes:k,hasDefaultNodes:A,debug:M}=w();if(_!=null&&_.length){if(A){const j=JS(_,k);N(j)}M&&console.log("React Flow: trigger node changes",_),S==null||S(_)}},triggerEdgeChanges:_=>{const{onEdgesChange:S,setEdges:N,edges:k,hasDefaultEdges:A,debug:M}=w();if(_!=null&&_.length){if(A){const j=WS(_,k);N(j)}M&&console.log("React Flow: trigger edge changes",_),S==null||S(_)}},addSelectedNodes:_=>{const{multiSelectionActive:S,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(S){const j=_.map(L=>$i(L,!0));A(j);return}A(ia(k,new Set([..._]),!0)),M(ia(N))},addSelectedEdges:_=>{const{multiSelectionActive:S,edgeLookup:N,nodeLookup:k,triggerNodeChanges:A,triggerEdgeChanges:M}=w();if(S){const j=_.map(L=>$i(L,!0));M(j);return}M(ia(N,new Set([..._]))),A(ia(k,new Set,!0))},unselectNodesAndEdges:({nodes:_,edges:S}={})=>{const{edges:N,nodes:k,nodeLookup:A,triggerNodeChanges:M,triggerEdgeChanges:j}=w(),L=_||k,R=S||N,V=[];for(const B of L){if(!B.selected)continue;const U=A.get(B.id);U&&(U.selected=!1),V.push($i(B.id,!1))}const H=[];for(const B of R)B.selected&&H.push($i(B.id,!1));M(V),j(H)},setMinZoom:_=>{const{panZoom:S,maxZoom:N}=w();S==null||S.setScaleExtent([_,N]),b({minZoom:_})},setMaxZoom:_=>{const{panZoom:S,minZoom:N}=w();S==null||S.setScaleExtent([N,_]),b({maxZoom:_})},setTranslateExtent:_=>{var S;(S=w().panZoom)==null||S.setTranslateExtent(_),b({translateExtent:_})},resetSelectedElements:()=>{const{edges:_,nodes:S,triggerNodeChanges:N,triggerEdgeChanges:k,elementsSelectable:A}=w();if(!A)return;const M=S.reduce((L,R)=>R.selected?[...L,$i(R.id,!1)]:L,[]),j=_.reduce((L,R)=>R.selected?[...L,$i(R.id,!1)]:L,[]);N(M),k(j)},setNodeExtent:_=>{const{nodes:S,nodeLookup:N,parentLookup:k,nodeOrigin:A,elevateNodesOnSelect:M,nodeExtent:j,zIndexMode:L}=w();_[0][0]===j[0][0]&&_[0][1]===j[0][1]&&_[1][0]===j[1][0]&&_[1][1]===j[1][1]||(tm(S,N,k,{nodeOrigin:A,nodeExtent:_,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:L}),b({nodeExtent:_}))},panBy:_=>{const{transform:S,width:N,height:k,panZoom:A,translateExtent:M}=w();return _A({delta:_,panZoom:A,transform:S,translateExtent:M,width:N,height:k})},setCenter:async(_,S,N)=>{const{width:k,height:A,maxZoom:M,panZoom:j}=w();if(!j)return Promise.resolve(!1);const L=typeof(N==null?void 0:N.zoom)<"u"?N.zoom:M;return await j.setViewport({x:k/2-_*L,y:A/2-S*L,zoom:L},{duration:N==null?void 0:N.duration,ease:N==null?void 0:N.ease,interpolate:N==null?void 0:N.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{b({connection:{...bS}})},updateConnection:_=>{b({connection:_})},reset:()=>b({...xb()})}},Object.is);function VM({initialNodes:e,initialEdges:t,defaultNodes:r,defaultEdges:l,initialWidth:a,initialHeight:o,initialMinZoom:u,initialMaxZoom:c,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:p,zIndexMode:x,children:b}){const[w]=P.useState(()=>UM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,width:a,height:o,fitView:h,minZoom:u,maxZoom:c,fitViewOptions:d,nodeOrigin:m,nodeExtent:p,zIndexMode:x}));return y.jsx(az,{value:w,children:y.jsx(jz,{children:b})})}function PM({children:e,nodes:t,edges:r,defaultNodes:l,defaultEdges:a,width:o,height:u,fitView:c,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b}){return P.useContext(Oc)?y.jsx(y.Fragment,{children:e}):y.jsx(VM,{initialNodes:t,initialEdges:r,defaultNodes:l,defaultEdges:a,initialWidth:o,initialHeight:u,fitView:c,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:p,nodeExtent:x,zIndexMode:b,children:e})}const $M={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function GM({nodes:e,edges:t,defaultNodes:r,defaultEdges:l,className:a,nodeTypes:o,edgeTypes:u,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:p,onMoveEnd:x,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:_,onClickConnectEnd:S,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:j,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onSelectionChange:ee,onSelectionDragStart:I,onSelectionDrag:F,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onBeforeDelete:D,connectionMode:q,connectionLineType:Y=xi.Bezier,connectionLineStyle:C,connectionLineComponent:$,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Po.Full,panActivationKeyCode:xe="Space",multiSelectionKeyCode:be=Go()?"Meta":"Control",zoomActivationKeyCode:ye=Go()?"Meta":"Control",snapToGrid:pe,snapGrid:_e,onlyRenderVisibleElements:ze=!1,selectNodesOnDrag:Te,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Pt,nodeOrigin:Ht=ZS,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt=!0,defaultViewport:Hr=vz,minZoom:ue=.5,maxZoom:ge=2,translateExtent:Ne=Vo,preventScrolling:Oe=!0,nodeExtent:Xe,defaultMarkerColor:Qt="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:Bt=!0,panOnScroll:vt=!1,panOnScrollSpeed:$t=.5,panOnScrollMode:We=Zi.Free,zoomOnDoubleClick:Qn=!0,panOnDrag:fn=!0,onPaneClick:Fc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi=1,nodeClickDistance:Yc=0,children:ss,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Xc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:Sa,onEdgeMouseLeave:_a,reconnectRadius:ds=10,onNodesChange:hs,onEdgesChange:Zn,noDragClassName:Dt="nodrag",noWheelClassName:Gt="nowheel",noPanClassName:ur="nopan",fitView:pl,fitViewOptions:ps,connectOnClick:Qc,attributionPosition:ms,proOptions:Si,defaultEdgeOptions:ka,elevateNodesOnSelect:Br=!0,elevateEdgesOnSelect:Ir=!1,disableKeyboardA11y:qr=!1,autoPanOnConnect:Ur,autoPanOnNodeDrag:St,autoPanSpeed:gs,connectionRadius:xs,isValidConnection:cr,onError:Vr,style:Zc,id:Ea,nodeDragThreshold:ys,connectionDragThreshold:Kc,viewport:ml,onViewportChange:gl,width:Ln,height:Wt,colorMode:vs="light",debug:Jc,onScroll:Pr,ariaLabelConfig:bs,zIndexMode:_i="basic",...Wc},en){const ki=Ea||"1",ws=_z(vs),Na=P.useCallback(fr=>{fr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Pr==null||Pr(fr)},[Pr]);return y.jsx("div",{"data-testid":"rf__wrapper",...Wc,onScroll:Na,style:{...Zc,...$M},ref:en,className:At(["react-flow",a,ws]),id:Ea,role:"application",children:y.jsxs(PM,{nodes:e,edges:t,width:Ln,height:Wt,fitView:pl,fitViewOptions:ps,minZoom:ue,maxZoom:ge,nodeOrigin:Ht,nodeExtent:Xe,zIndexMode:_i,children:[y.jsx(qM,{onInit:h,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:k,onNodeMouseLeave:A,onNodeContextMenu:M,onNodeDoubleClick:j,nodeTypes:o,edgeTypes:u,connectionLineType:Y,connectionLineStyle:C,connectionLineComponent:$,connectionLineContainerStyle:X,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:J,multiSelectionKeyCode:be,panActivationKeyCode:xe,zoomActivationKeyCode:ye,onlyRenderVisibleElements:ze,defaultViewport:Hr,translateExtent:Ne,minZoom:ue,maxZoom:ge,preventScrolling:Oe,zoomOnScroll:On,zoomOnPinch:Bt,zoomOnDoubleClick:Qn,panOnScroll:vt,panOnScrollSpeed:$t,panOnScrollMode:We,panOnDrag:fn,onPaneClick:Fc,onPaneMouseEnter:cl,onPaneMouseMove:fl,onPaneMouseLeave:dl,onPaneScroll:sr,onPaneContextMenu:hl,paneClickDistance:bi,nodeClickDistance:Yc,onSelectionContextMenu:G,onSelectionStart:Q,onSelectionEnd:K,onReconnect:wa,onReconnectStart:wi,onReconnectEnd:Xc,onEdgeContextMenu:us,onEdgeDoubleClick:cs,onEdgeMouseEnter:fs,onEdgeMouseMove:Sa,onEdgeMouseLeave:_a,reconnectRadius:ds,defaultMarkerColor:Qt,noDragClassName:Dt,noWheelClassName:Gt,noPanClassName:ur,rfId:ki,disableKeyboardA11y:qr,nodeExtent:Xe,viewport:ml,onViewportChange:gl}),y.jsx(Sz,{nodes:e,edges:t,defaultNodes:r,defaultEdges:l,onConnect:b,onConnectStart:w,onConnectEnd:E,onClickConnectStart:_,onClickConnectEnd:S,nodesDraggable:ut,autoPanOnNodeFocus:nt,nodesConnectable:zt,nodesFocusable:Pt,edgesFocusable:kn,edgesReconnectable:Rn,elementsSelectable:Mt,elevateNodesOnSelect:Br,elevateEdgesOnSelect:Ir,minZoom:ue,maxZoom:ge,nodeExtent:Xe,onNodesChange:hs,onEdgesChange:Zn,snapToGrid:pe,snapGrid:_e,connectionMode:q,translateExtent:Ne,connectOnClick:Qc,defaultEdgeOptions:ka,fitView:pl,fitViewOptions:ps,onNodesDelete:H,onEdgesDelete:B,onDelete:U,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:V,onSelectionDrag:F,onSelectionDragStart:I,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:x,noPanClassName:ur,nodeOrigin:Ht,rfId:ki,autoPanOnConnect:Ur,autoPanOnNodeDrag:St,autoPanSpeed:gs,onError:Vr,connectionRadius:xs,isValidConnection:cr,selectNodesOnDrag:Te,nodeDragThreshold:ys,connectionDragThreshold:Kc,onBeforeDelete:D,debug:Jc,ariaLabelConfig:bs,zIndexMode:_i}),y.jsx(yz,{onSelectionChange:ee}),ss,y.jsx(hz,{proOptions:Si,position:ms}),y.jsx(dz,{rfId:ki,disableKeyboardA11y:qr})]})})}var FM=e_(GM);const YM=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function XM({children:e}){const t=Ye(YM);return t?lz.createPortal(e,t):null}function QM(e){const[t,r]=P.useState(e),l=P.useCallback(a=>r(o=>JS(a,o)),[]);return[t,r,l]}function ZM(e){const[t,r]=P.useState(e),l=P.useCallback(a=>r(o=>WS(a,o)),[]);return[t,r,l]}function KM({dimensions:e,lineWidth:t,variant:r,className:l}){return y.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:At(["react-flow__background-pattern",r,l])})}function JM({radius:e,className:t}){return y.jsx("circle",{cx:e,cy:e,r:e,className:At(["react-flow__background-pattern","dots",t])})}var Mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Mr||(Mr={}));const WM={[Mr.Dots]:1,[Mr.Lines]:1,[Mr.Cross]:6},e5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function k_({id:e,variant:t=Mr.Dots,gap:r=20,size:l,lineWidth:a=1,offset:o=0,color:u,bgColor:c,style:d,className:h,patternClassName:m}){const p=P.useRef(null),{transform:x,patternId:b}=Ye(e5,pt),w=l||WM[t],E=t===Mr.Dots,_=t===Mr.Cross,S=Array.isArray(r)?r:[r,r],N=[S[0]*x[2]||1,S[1]*x[2]||1],k=w*x[2],A=Array.isArray(o)?o:[o,o],M=_?[k,k]:N,j=[A[0]*x[2]||1+M[0]/2,A[1]*x[2]||1+M[1]/2],L=`${b}${e||""}`;return y.jsxs("svg",{className:At(["react-flow__background",h]),style:{...d,...Hc,"--xy-background-color-props":c,"--xy-background-pattern-color-props":u},ref:p,"data-testid":"rf__background",children:[y.jsx("pattern",{id:L,x:x[0]%N[0],y:x[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:E?y.jsx(JM,{radius:k/2,className:m}):y.jsx(KM,{dimensions:M,lineWidth:a,variant:t,className:m})}),y.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}k_.displayName="Background";const t5=P.memo(k_);function n5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:y.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function r5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:y.jsx("path",{d:"M0 0h32v4.2H0z"})})}function i5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:y.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function l5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function a5(){return y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:y.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function $u({children:e,className:t,...r}){return y.jsx("button",{type:"button",className:At(["react-flow__controls-button",t]),...r,children:e})}const o5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function E_({style:e,showZoom:t=!0,showFitView:r=!0,showInteractive:l=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:u,onFitView:c,onInteractiveChange:d,className:h,children:m,position:p="bottom-left",orientation:x="vertical","aria-label":b}){const w=mt(),{isInteractive:E,minZoomReached:_,maxZoomReached:S,ariaLabelConfig:N}=Ye(o5,pt),{zoomIn:k,zoomOut:A,fitView:M}=al(),j=()=>{k(),o==null||o()},L=()=>{A(),u==null||u()},R=()=>{M(a),c==null||c()},V=()=>{w.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),d==null||d(!E)},H=x==="horizontal"?"horizontal":"vertical";return y.jsxs(Lc,{className:At(["react-flow__controls",H,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??N["controls.ariaLabel"],children:[t&&y.jsxs(y.Fragment,{children:[y.jsx($u,{onClick:j,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:S,children:y.jsx(n5,{})}),y.jsx($u,{onClick:L,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:_,children:y.jsx(r5,{})})]}),r&&y.jsx($u,{className:"react-flow__controls-fitview",onClick:R,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:y.jsx(i5,{})}),l&&y.jsx($u,{className:"react-flow__controls-interactive",onClick:V,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:E?y.jsx(a5,{}):y.jsx(l5,{})}),m]})}E_.displayName="Controls";const s5=P.memo(E_);function u5({id:e,x:t,y:r,width:l,height:a,style:o,color:u,strokeColor:c,strokeWidth:d,className:h,borderRadius:m,shapeRendering:p,selected:x,onClick:b}){const{background:w,backgroundColor:E}=o||{},_=u||w||E;return y.jsx("rect",{className:At(["react-flow__minimap-node",{selected:x},h]),x:t,y:r,rx:m,ry:m,width:l,height:a,style:{fill:_,stroke:c,strokeWidth:d},shapeRendering:p,onClick:b?S=>b(S,e):void 0})}const c5=P.memo(u5),f5=e=>e.nodes.map(t=>t.id),Th=e=>e instanceof Function?e:()=>e;function d5({nodeStrokeColor:e,nodeColor:t,nodeClassName:r="",nodeBorderRadius:l=5,nodeStrokeWidth:a,nodeComponent:o=c5,onClick:u}){const c=Ye(f5,pt),d=Th(t),h=Th(e),m=Th(r),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.jsx(y.Fragment,{children:c.map(x=>y.jsx(p5,{id:x,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:l,nodeStrokeWidth:a,NodeComponent:o,onClick:u,shapeRendering:p},x))})}function h5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:r,nodeClassNameFunc:l,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:u,NodeComponent:c,onClick:d}){const{node:h,x:m,y:p,width:x,height:b}=Ye(w=>{const E=w.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const _=E.internals.userNode,{x:S,y:N}=E.internals.positionAbsolute,{width:k,height:A}=Or(_);return{node:_,x:S,y:N,width:k,height:A}},pt);return!h||h.hidden||!CS(h)?null:y.jsx(c,{x:m,y:p,width:x,height:b,style:h.style,selected:!!h.selected,className:l(h),color:t(h),borderRadius:a,strokeColor:r(h),strokeWidth:o,shapeRendering:u,onClick:d,id:h.id})}const p5=P.memo(h5);var m5=P.memo(d5);const g5=200,x5=150,y5=e=>!e.hidden,v5=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?NS(es(e.nodeLookup,{filter:y5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},b5="react-flow__minimap-desc";function N_({style:e,className:t,nodeStrokeColor:r,nodeColor:l,nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:u,nodeComponent:c,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:p,position:x="bottom-right",onClick:b,onNodeClick:w,pannable:E=!1,zoomable:_=!1,ariaLabel:S,inversePan:N,zoomStep:k=1,offsetScale:A=5}){const M=mt(),j=P.useRef(null),{boundingRect:L,viewBB:R,rfId:V,panZoom:H,translateExtent:B,flowWidth:U,flowHeight:ee,ariaLabelConfig:I}=Ye(v5,pt),F=(e==null?void 0:e.width)??g5,z=(e==null?void 0:e.height)??x5,G=L.width/F,Q=L.height/z,K=Math.max(G,Q),D=K*F,q=K*z,Y=A*K,C=L.x-(D-L.width)/2-Y,$=L.y-(q-L.height)/2-Y,X=D+Y*2,J=q+Y*2,ne=`${b5}-${V}`,re=P.useRef(0),se=P.useRef();re.current=K,P.useEffect(()=>{if(j.current&&H)return se.current=MA({domNode:j.current,panZoom:H,getTransform:()=>M.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[H]),P.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:B,width:U,height:ee,inversePan:N,pannable:E,zoomStep:k,zoomable:_})},[E,_,N,k,B,U,ee]);const xe=b?pe=>{var Te;const[_e,ze]=((Te=se.current)==null?void 0:Te.pointer(pe))||[0,0];b(pe,{x:_e,y:ze})}:void 0,be=w?P.useCallback((pe,_e)=>{const ze=M.getState().nodeLookup.get(_e).internals.userNode;w(pe,ze)},[]):void 0,ye=S??I["minimap.ariaLabel"];return y.jsx(Lc,{position:x,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*K:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-width-props":typeof u=="number"?u:void 0},className:At(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:y.jsxs("svg",{width:F,height:z,viewBox:`${C} ${$} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:j,onClick:xe,children:[ye&&y.jsx("title",{id:ne,children:ye}),y.jsx(m5,{onClick:be,nodeColor:l,nodeStrokeColor:r,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:u,nodeComponent:c}),y.jsx("path",{className:"react-flow__minimap-mask",d:`M${C-Y},${$-Y}h${X+Y*2}v${J+Y*2}h${-X-Y*2}z + M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}N_.displayName="MiniMap";const w5=P.memo(N_),S5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_5={[xa.Line]:"right",[xa.Handle]:"bottom-right"};function k5({nodeId:e,position:t,variant:r=xa.Handle,className:l,style:a=void 0,children:o,color:u,minWidth:c=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:x,autoScale:b=!0,shouldResize:w,onResizeStart:E,onResize:_,onResizeEnd:S}){const N=i_(),k=typeof e=="string"?e:N,A=mt(),M=P.useRef(null),j=r===xa.Handle,L=Ye(P.useCallback(S5(j&&b),[j,b]),pt),R=P.useRef(null),V=t??_5[r];P.useEffect(()=>{if(!(!M.current||!k))return R.current||(R.current=FA({domNode:M.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,domNode:z}=A.getState();return{nodeLookup:B,transform:U,snapGrid:ee,snapToGrid:I,nodeOrigin:F,paneDomNode:z}},onChange:(B,U)=>{const{triggerNodeChanges:ee,nodeLookup:I,parentLookup:F,nodeOrigin:z}=A.getState(),G=[],Q={x:B.x,y:B.y},K=I.get(k);if(K&&K.expandParent&&K.parentId){const D=K.origin??z,q=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,C={id:K.id,parentId:K.parentId,rect:{width:q,height:Y,...TS({x:B.x??K.position.x,y:B.y??K.position.y},{width:q,height:Y},K.parentId,I,D)}},$=Bm([C],I,F,z);G.push(...$),Q.x=B.x?Math.max(D[0]*q,B.x):void 0,Q.y=B.y?Math.max(D[1]*Y,B.y):void 0}if(Q.x!==void 0&&Q.y!==void 0){const D={id:k,type:"position",position:{...Q}};G.push(D)}if(B.width!==void 0&&B.height!==void 0){const q={id:k,type:"dimensions",resizing:!0,setAttributes:x?x==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};G.push(q)}for(const D of U){const q={...D,type:"position"};G.push(q)}ee(G)},onEnd:({width:B,height:U})=>{const ee={id:k,type:"dimensions",resizing:!1,dimensions:{width:B,height:U}};A.getState().triggerNodeChanges([ee])}})),R.current.update({controlPosition:V,boundaries:{minWidth:c,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:p,resizeDirection:x,onResizeStart:E,onResize:_,onResizeEnd:S,shouldResize:w}),()=>{var B;(B=R.current)==null||B.destroy()}},[V,c,d,h,m,p,E,_,S,w]);const H=V.split("-");return y.jsx("div",{className:At(["react-flow__resize-control","nodrag",...H,r,l]),ref:M,style:{...a,scale:L,...u&&{[j?"backgroundColor":"borderColor"]:u}},children:o})}P.memo(k5);function is(e,t){if(t.length===0)return null;let r=e[t[0]];for(let l=1;ll.viewContextPath),t=fe(l=>l.nodes),r=fe(l=>l.subworkflowContexts);return P.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.nodes)??t},[e,t,r])}function E5(){const e=fe(l=>l.viewContextPath),t=fe(l=>l.groupProgress),r=fe(l=>l.subworkflowContexts);return P.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.groupProgress)??t},[e,t,r])}function N5(){const e=fe(l=>l.viewContextPath),t=fe(l=>l.highlightedEdges),r=fe(l=>l.subworkflowContexts);return P.useMemo(()=>{var l;return e.length===0?t:((l=is(r,e))==null?void 0:l.highlightedEdges)??t},[e,t,r])}function qm(){const e=fe(r=>r.viewContextPath),t=fe(r=>r.subworkflowContexts);return P.useMemo(()=>{var r;return e.length===0?t:((r=is(t,e))==null?void 0:r.children)??[]},[e,t])}function C5(){const e=fe(h=>h.viewContextPath),t=fe(h=>h.agents),r=fe(h=>h.routes),l=fe(h=>h.parallelGroups),a=fe(h=>h.forEachGroups),o=fe(h=>h.nodes),u=fe(h=>h.groupProgress),c=fe(h=>h.entryPoint),d=fe(h=>h.subworkflowContexts);return P.useMemo(()=>{if(e.length===0)return{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null};const h=is(d,e);return h?{agents:h.agents,routes:h.routes,parallelGroups:h.parallelGroups,forEachGroups:h.forEachGroups,nodes:h.nodes,groupProgress:h.groupProgress,entryPoint:h.entryPoint,subworkflowContexts:h.children,parentAgent:h.parentAgent}:{agents:t,routes:r,parallelGroups:l,forEachGroups:a,nodes:o,groupProgress:u,entryPoint:c,subworkflowContexts:d,parentAgent:null}},[e,t,r,l,a,o,u,c,d])}function T5(){const e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get("subworkflow"),agent:e.get("agent")}}function yb(e,t){const r=[];let l=e;for(const a of t){let o=-1;for(let u=l.length-1;u>=0;u--)if(l[u].slotKey===a){o=u;break}if(o===-1){for(let u=l.length-1;u>=0;u--)if(l[u].parentAgent===a){o=u;break}}if(o===-1)return{path:r,failedSegment:a};r.push(o),l=l[o].children}return{path:r,failedSegment:null}}function im(e,t,r=[]){const l=[];for(let a=0;ac.name===t)&&l.push({path:u,ctx:o}),o.children.length>0&&l.push(...im(o.children,t,u))}return l}function j5(e){return e.length===0?null:[...e].sort((t,r)=>{const l=t.ctx.status==="running"?1:0,a=r.ctx.status==="running"?1:0;if(l!==a)return a-l;if(t.path.length!==r.path.length)return r.path.length-t.path.length;for(let o=0;o{if(r.current||!u)return;let c=null,d=null,h=null;const m=()=>{if(r.current)return;r.current=!0,c&&clearTimeout(c),d&&clearTimeout(d),h&&h();const b=fe.getState();if(b.agents.length===0){t({message:"Workflow state did not load."});return}let w=[];if(a){const E=a.split("/").filter(Boolean),_=yb(b.subworkflowContexts,E);if(_.failedSegment){const S=E.slice(0,_.path.length).join("/");t({message:`Subworkflow "${_.failedSegment}" not found${S?` (resolved: ${S})`:""}. It may not have started yet.`});return}w=_.path}if(o){if((w.length===0?b.agents:(()=>{let _,S=b.subworkflowContexts;for(const N of w){if(_=S[N],!_)break;S=_.children}return(_==null?void 0:_.agents)??[]})()).some(_=>_.name===o))fe.setState({viewContextPath:w,selectedNode:o});else{const _=im(b.subworkflowContexts,o);if(_.length===0){const N=a||"root workflow";fe.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${N}.`});return}if(a){const N=_.slice(0,5).map(A=>A5(b.subworkflowContexts,A.path)).join(", "),k=_.length>5?`, and ${_.length-5} more`:"";fe.setState({viewContextPath:w,selectedNode:null}),t({message:`Agent "${o}" not found in ${a}. Found in: ${N}${k}`});return}const S=j5(_);fe.setState({viewContextPath:S.path,selectedNode:o})}setTimeout(()=>{l({nodes:[{id:o}],padding:.5,duration:400})},200)}else a&&fe.setState({viewContextPath:w,selectedNode:null})},p=()=>{const b=fe.getState();if(b.agents.length===0)return!1;if(b.workflowStatus!=="running"&&b.workflowStatus!=="pending")return!0;if(a){const w=a.split("/").filter(Boolean),{failedSegment:E}=yb(b.subworkflowContexts,w);if(E)return!1}return!(o&&!a&&!b.agents.some(E=>E.name===o)&&im(b.subworkflowContexts,o).length===0)},x=()=>{c&&clearTimeout(c),c=setTimeout(()=>{r.current||p()&&m()},200)};return h=fe.subscribe(x),d=setTimeout(()=>{r.current||m()},5e3),x(),()=>{c&&clearTimeout(c),d&&clearTimeout(d),h&&h()}},[u,a,o,l]),e}var jh,vb;function Um(){if(vb)return jh;vb=1;var e="\0",t="\0",r="";class l{constructor(m){Ct(this,"_isDirected",!0);Ct(this,"_isMultigraph",!1);Ct(this,"_isCompound",!1);Ct(this,"_label");Ct(this,"_defaultNodeLabelFn",()=>{});Ct(this,"_defaultEdgeLabelFn",()=>{});Ct(this,"_nodes",{});Ct(this,"_in",{});Ct(this,"_preds",{});Ct(this,"_out",{});Ct(this,"_sucs",{});Ct(this,"_edgeObjs",{});Ct(this,"_edgeLabels",{});Ct(this,"_nodeCount",0);Ct(this,"_edgeCount",0);Ct(this,"_parent");Ct(this,"_children");m&&(this._isDirected=Object.hasOwn(m,"directed")?m.directed:!0,this._isMultigraph=Object.hasOwn(m,"multigraph")?m.multigraph:!1,this._isCompound=Object.hasOwn(m,"compound")?m.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(m){return this._label=m,this}graph(){return this._label}setDefaultNodeLabel(m){return this._defaultNodeLabelFn=m,typeof m!="function"&&(this._defaultNodeLabelFn=()=>m),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var m=this;return this.nodes().filter(p=>Object.keys(m._in[p]).length===0)}sinks(){var m=this;return this.nodes().filter(p=>Object.keys(m._out[p]).length===0)}setNodes(m,p){var x=arguments,b=this;return m.forEach(function(w){x.length>1?b.setNode(w,p):b.setNode(w)}),this}setNode(m,p){return Object.hasOwn(this._nodes,m)?(arguments.length>1&&(this._nodes[m]=p),this):(this._nodes[m]=arguments.length>1?p:this._defaultNodeLabelFn(m),this._isCompound&&(this._parent[m]=t,this._children[m]={},this._children[t][m]=!0),this._in[m]={},this._preds[m]={},this._out[m]={},this._sucs[m]={},++this._nodeCount,this)}node(m){return this._nodes[m]}hasNode(m){return Object.hasOwn(this._nodes,m)}removeNode(m){var p=this;if(Object.hasOwn(this._nodes,m)){var x=b=>p.removeEdge(p._edgeObjs[b]);delete this._nodes[m],this._isCompound&&(this._removeFromParentsChildList(m),delete this._parent[m],this.children(m).forEach(function(b){p.setParent(b)}),delete this._children[m]),Object.keys(this._in[m]).forEach(x),delete this._in[m],delete this._preds[m],Object.keys(this._out[m]).forEach(x),delete this._out[m],delete this._sucs[m],--this._nodeCount}return this}setParent(m,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(p===void 0)p=t;else{p+="";for(var x=p;x!==void 0;x=this.parent(x))if(x===m)throw new Error("Setting "+p+" as parent of "+m+" would create a cycle");this.setNode(p)}return this.setNode(m),this._removeFromParentsChildList(m),this._parent[m]=p,this._children[p][m]=!0,this}_removeFromParentsChildList(m){delete this._children[this._parent[m]][m]}parent(m){if(this._isCompound){var p=this._parent[m];if(p!==t)return p}}children(m=t){if(this._isCompound){var p=this._children[m];if(p)return Object.keys(p)}else{if(m===t)return this.nodes();if(this.hasNode(m))return[]}}predecessors(m){var p=this._preds[m];if(p)return Object.keys(p)}successors(m){var p=this._sucs[m];if(p)return Object.keys(p)}neighbors(m){var p=this.predecessors(m);if(p){const b=new Set(p);for(var x of this.successors(m))b.add(x);return Array.from(b.values())}}isLeaf(m){var p;return this.isDirected()?p=this.successors(m):p=this.neighbors(m),p.length===0}filterNodes(m){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var x=this;Object.entries(this._nodes).forEach(function([E,_]){m(E)&&p.setNode(E,_)}),Object.values(this._edgeObjs).forEach(function(E){p.hasNode(E.v)&&p.hasNode(E.w)&&p.setEdge(E,x.edge(E))});var b={};function w(E){var _=x.parent(E);return _===void 0||p.hasNode(_)?(b[E]=_,_):_ in b?b[_]:w(_)}return this._isCompound&&p.nodes().forEach(E=>p.setParent(E,w(E))),p}setDefaultEdgeLabel(m){return this._defaultEdgeLabelFn=m,typeof m!="function"&&(this._defaultEdgeLabelFn=()=>m),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(m,p){var x=this,b=arguments;return m.reduce(function(w,E){return b.length>1?x.setEdge(w,E,p):x.setEdge(w,E),E}),this}setEdge(){var m,p,x,b,w=!1,E=arguments[0];typeof E=="object"&&E!==null&&"v"in E?(m=E.v,p=E.w,x=E.name,arguments.length===2&&(b=arguments[1],w=!0)):(m=E,p=arguments[1],x=arguments[3],arguments.length>2&&(b=arguments[2],w=!0)),m=""+m,p=""+p,x!==void 0&&(x=""+x);var _=u(this._isDirected,m,p,x);if(Object.hasOwn(this._edgeLabels,_))return w&&(this._edgeLabels[_]=b),this;if(x!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(m),this.setNode(p),this._edgeLabels[_]=w?b:this._defaultEdgeLabelFn(m,p,x);var S=c(this._isDirected,m,p,x);return m=S.v,p=S.w,Object.freeze(S),this._edgeObjs[_]=S,a(this._preds[p],m),a(this._sucs[m],p),this._in[p][_]=S,this._out[m][_]=S,this._edgeCount++,this}edge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return this._edgeLabels[b]}edgeAsObj(){const m=this.edge(...arguments);return typeof m!="object"?{label:m}:m}hasEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x);return Object.hasOwn(this._edgeLabels,b)}removeEdge(m,p,x){var b=arguments.length===1?d(this._isDirected,arguments[0]):u(this._isDirected,m,p,x),w=this._edgeObjs[b];return w&&(m=w.v,p=w.w,delete this._edgeLabels[b],delete this._edgeObjs[b],o(this._preds[p],m),o(this._sucs[m],p),delete this._in[p][b],delete this._out[m][b],this._edgeCount--),this}inEdges(m,p){var x=this._in[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.v===p):b}}outEdges(m,p){var x=this._out[m];if(x){var b=Object.values(x);return p?b.filter(w=>w.w===p):b}}nodeEdges(m,p){var x=this.inEdges(m,p);if(x)return x.concat(this.outEdges(m,p))}}function a(h,m){h[m]?h[m]++:h[m]=1}function o(h,m){--h[m]||delete h[m]}function u(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var E=b;b=w,w=E}return b+r+w+r+(x===void 0?e:x)}function c(h,m,p,x){var b=""+m,w=""+p;if(!h&&b>w){var E=b;b=w,w=E}var _={v:b,w};return x&&(_.name=x),_}function d(h,m){return u(h,m.v,m.w,m.name)}return jh=l,jh}var Ah,bb;function M5(){return bb||(bb=1,Ah="2.2.4"),Ah}var zh,wb;function D5(){return wb||(wb=1,zh={Graph:Um(),version:M5()}),zh}var Mh,Sb;function R5(){if(Sb)return Mh;Sb=1;var e=Um();Mh={write:t,read:a};function t(o){var u={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:l(o)};return o.graph()!==void 0&&(u.value=structuredClone(o.graph())),u}function r(o){return o.nodes().map(function(u){var c=o.node(u),d=o.parent(u),h={v:u};return c!==void 0&&(h.value=c),d!==void 0&&(h.parent=d),h})}function l(o){return o.edges().map(function(u){var c=o.edge(u),d={v:u.v,w:u.w};return u.name!==void 0&&(d.name=u.name),c!==void 0&&(d.value=c),d})}function a(o){var u=new e(o.options).setGraph(o.value);return o.nodes.forEach(function(c){u.setNode(c.v,c.value),c.parent&&u.setParent(c.v,c.parent)}),o.edges.forEach(function(c){u.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),u}return Mh}var Dh,_b;function O5(){if(_b)return Dh;_b=1,Dh=e;function e(t){var r={},l=[],a;function o(u){Object.hasOwn(r,u)||(r[u]=!0,a.push(u),t.successors(u).forEach(o),t.predecessors(u).forEach(o))}return t.nodes().forEach(function(u){a=[],o(u),a.length&&l.push(a)}),l}return Dh}var Rh,kb;function C_(){if(kb)return Rh;kb=1;class e{constructor(){Ct(this,"_arr",[]);Ct(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(r){return r.key})}has(r){return Object.hasOwn(this._keyIndices,r)}priority(r){var l=this._keyIndices[r];if(l!==void 0)return this._arr[l].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(r,l){var a=this._keyIndices;if(r=String(r),!Object.hasOwn(a,r)){var o=this._arr,u=o.length;return a[r]=u,o.push({key:r,priority:l}),this._decrease(u),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key}decrease(r,l){var a=this._keyIndices[r];if(l>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+l);this._arr[a].priority=l,this._decrease(a)}_heapify(r){var l=this._arr,a=2*r,o=a+1,u=r;a>1,!(l[o].priority1;function r(a,o,u,c){return l(a,String(o),u||t,c||function(d){return a.outEdges(d)})}function l(a,o,u,c){var d={},h=new e,m,p,x=function(b){var w=b.v!==m?b.v:b.w,E=d[w],_=u(b),S=p.distance+_;if(_<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+_);S0&&(m=h.removeMin(),p=d[m],p.distance!==Number.POSITIVE_INFINITY);)c(m).forEach(x);return d}return Oh}var Lh,Nb;function L5(){if(Nb)return Lh;Nb=1;var e=T_();Lh=t;function t(r,l,a){return r.nodes().reduce(function(o,u){return o[u]=e(r,u,l,a),o},{})}return Lh}var Hh,Cb;function j_(){if(Cb)return Hh;Cb=1,Hh=e;function e(t){var r=0,l=[],a={},o=[];function u(c){var d=a[c]={onStack:!0,lowlink:r,index:r++};if(l.push(c),t.successors(c).forEach(function(p){Object.hasOwn(a,p)?a[p].onStack&&(d.lowlink=Math.min(d.lowlink,a[p].index)):(u(p),d.lowlink=Math.min(d.lowlink,a[p].lowlink))}),d.lowlink===d.index){var h=[],m;do m=l.pop(),a[m].onStack=!1,h.push(m);while(c!==m);o.push(h)}}return t.nodes().forEach(function(c){Object.hasOwn(a,c)||u(c)}),o}return Hh}var Bh,Tb;function H5(){if(Tb)return Bh;Tb=1;var e=j_();Bh=t;function t(r){return e(r).filter(function(l){return l.length>1||l.length===1&&r.hasEdge(l[0],l[0])})}return Bh}var Ih,jb;function B5(){if(jb)return Ih;jb=1,Ih=t;var e=()=>1;function t(l,a,o){return r(l,a||e,o||function(u){return l.outEdges(u)})}function r(l,a,o){var u={},c=l.nodes();return c.forEach(function(d){u[d]={},u[d][d]={distance:0},c.forEach(function(h){d!==h&&(u[d][h]={distance:Number.POSITIVE_INFINITY})}),o(d).forEach(function(h){var m=h.v===d?h.w:h.v,p=a(h);u[d][m]={distance:p,predecessor:d}})}),c.forEach(function(d){var h=u[d];c.forEach(function(m){var p=u[m];c.forEach(function(x){var b=p[d],w=h[x],E=p[x],_=b.distance+w.distance;_a.successors(p):p=>a.neighbors(p),d=u==="post"?t:r,h=[],m={};return o.forEach(p=>{if(!a.hasNode(p))throw new Error("Graph does not have node: "+p);d(p,c,m,h)}),h}function t(a,o,u,c){for(var d=[[a,!1]];d.length>0;){var h=d.pop();h[1]?c.push(h[0]):Object.hasOwn(u,h[0])||(u[h[0]]=!0,d.push([h[0],!0]),l(o(h[0]),m=>d.push([m,!1])))}}function r(a,o,u,c){for(var d=[a];d.length>0;){var h=d.pop();Object.hasOwn(u,h)||(u[h]=!0,c.push(h),l(o(h),m=>d.push(m)))}}function l(a,o){for(var u=a.length;u--;)o(a[u],u,a);return a}return Vh}var Ph,Db;function q5(){if(Db)return Ph;Db=1;var e=z_();Ph=t;function t(r,l){return e(r,l,"post")}return Ph}var $h,Rb;function U5(){if(Rb)return $h;Rb=1;var e=z_();$h=t;function t(r,l){return e(r,l,"pre")}return $h}var Gh,Ob;function V5(){if(Ob)return Gh;Ob=1;var e=Um(),t=C_();Gh=r;function r(l,a){var o=new e,u={},c=new t,d;function h(p){var x=p.v===d?p.w:p.v,b=c.priority(x);if(b!==void 0){var w=a(p);w0;){if(d=c.removeMin(),Object.hasOwn(u,d))o.setEdge(d,u[d]);else{if(m)throw new Error("Input graph is not connected: "+l);m=!0}l.nodeEdges(d).forEach(h)}return o}return Gh}var Fh,Lb;function P5(){return Lb||(Lb=1,Fh={components:O5(),dijkstra:T_(),dijkstraAll:L5(),findCycles:H5(),floydWarshall:B5(),isAcyclic:I5(),postorder:q5(),preorder:U5(),prim:V5(),tarjan:j_(),topsort:A_()}),Fh}var Yh,Hb;function Yn(){if(Hb)return Yh;Hb=1;var e=D5();return Yh={Graph:e.Graph,json:R5(),alg:P5(),version:e.version},Yh}var Xh,Bb;function $5(){if(Bb)return Xh;Bb=1;class e{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,o=a._prev;if(o!==a)return t(o),o}enqueue(a){let o=this._sentinel;a._prev&&a._next&&t(a),a._next=o._next,o._next._prev=a,o._next=a,a._prev=o}toString(){let a=[],o=this._sentinel,u=o._prev;for(;u!==o;)a.push(JSON.stringify(u,r)),u=u._prev;return"["+a.join(", ")+"]"}}function t(l){l._prev._next=l._next,l._next._prev=l._prev,delete l._next,delete l._prev}function r(l,a){if(l!=="_next"&&l!=="_prev")return a}return Xh=e,Xh}var Qh,Ib;function G5(){if(Ib)return Qh;Ib=1;let e=Yn().Graph,t=$5();Qh=l;let r=()=>1;function l(h,m){if(h.nodeCount()<=1)return[];let p=u(h,m||r);return a(p.graph,p.buckets,p.zeroIdx).flatMap(b=>h.outEdges(b.v,b.w))}function a(h,m,p){let x=[],b=m[m.length-1],w=m[0],E;for(;h.nodeCount();){for(;E=w.dequeue();)o(h,m,p,E);for(;E=b.dequeue();)o(h,m,p,E);if(h.nodeCount()){for(let _=m.length-2;_>0;--_)if(E=m[_].dequeue(),E){x=x.concat(o(h,m,p,E,!0));break}}}return x}function o(h,m,p,x,b){let w=b?[]:void 0;return h.inEdges(x.v).forEach(E=>{let _=h.edge(E),S=h.node(E.v);b&&w.push({v:E.v,w:E.w}),S.out-=_,c(m,p,S)}),h.outEdges(x.v).forEach(E=>{let _=h.edge(E),S=E.w,N=h.node(S);N.in-=_,c(m,p,N)}),h.removeNode(x.v),w}function u(h,m){let p=new e,x=0,b=0;h.nodes().forEach(_=>{p.setNode(_,{v:_,in:0,out:0})}),h.edges().forEach(_=>{let S=p.edge(_.v,_.w)||0,N=m(_),k=S+N;p.setEdge(_.v,_.w,k),b=Math.max(b,p.node(_.v).out+=N),x=Math.max(x,p.node(_.w).in+=N)});let w=d(b+x+3).map(()=>new t),E=x+1;return p.nodes().forEach(_=>{c(w,E,p.node(_))}),{graph:p,buckets:w,zeroIdx:E}}function c(h,m,p){p.out?p.in?h[p.out-p.in+m].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}function d(h){const m=[];for(let p=0;pV.setNode(H,R.node(H))),R.edges().forEach(H=>{let B=V.edge(H.v,H.w)||{weight:0,minlen:1},U=R.edge(H);V.setEdge(H.v,H.w,{weight:B.weight+U.weight,minlen:Math.max(B.minlen,U.minlen)})}),V}function l(R){let V=new e({multigraph:R.isMultigraph()}).setGraph(R.graph());return R.nodes().forEach(H=>{R.children(H).length||V.setNode(H,R.node(H))}),R.edges().forEach(H=>{V.setEdge(H,R.edge(H))}),V}function a(R){let V=R.nodes().map(H=>{let B={};return R.outEdges(H).forEach(U=>{B[U.w]=(B[U.w]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function o(R){let V=R.nodes().map(H=>{let B={};return R.inEdges(H).forEach(U=>{B[U.v]=(B[U.v]||0)+R.edge(U).weight}),B});return L(R.nodes(),V)}function u(R,V){let H=R.x,B=R.y,U=V.x-H,ee=V.y-B,I=R.width/2,F=R.height/2;if(!U&&!ee)throw new Error("Not possible to find intersection inside of the rectangle");let z,G;return Math.abs(ee)*I>Math.abs(U)*F?(ee<0&&(F=-F),z=F*U/ee,G=F):(U<0&&(I=-I),z=I,G=I*ee/U),{x:H+z,y:B+G}}function c(R){let V=A(w(R)+1).map(()=>[]);return R.nodes().forEach(H=>{let B=R.node(H),U=B.rank;U!==void 0&&(V[U][B.order]=H)}),V}function d(R){let V=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MAX_VALUE:U}),H=b(Math.min,V);R.nodes().forEach(B=>{let U=R.node(B);Object.hasOwn(U,"rank")&&(U.rank-=H)})}function h(R){let V=R.nodes().map(I=>R.node(I).rank),H=b(Math.min,V),B=[];R.nodes().forEach(I=>{let F=R.node(I).rank-H;B[F]||(B[F]=[]),B[F].push(I)});let U=0,ee=R.graph().nodeRankFactor;Array.from(B).forEach((I,F)=>{I===void 0&&F%ee!==0?--U:I!==void 0&&U&&I.forEach(z=>R.node(z).rank+=U)})}function m(R,V,H,B){let U={width:0,height:0};return arguments.length>=4&&(U.rank=H,U.order=B),t(R,"border",U,V)}function p(R,V=x){const H=[];for(let B=0;Bx){const H=p(V);return R.apply(null,H.map(B=>R.apply(null,B)))}else return R.apply(null,V)}function w(R){const H=R.nodes().map(B=>{let U=R.node(B).rank;return U===void 0?Number.MIN_VALUE:U});return b(Math.max,H)}function E(R,V){let H={lhs:[],rhs:[]};return R.forEach(B=>{V(B)?H.lhs.push(B):H.rhs.push(B)}),H}function _(R,V){let H=Date.now();try{return V()}finally{console.log(R+" time: "+(Date.now()-H)+"ms")}}function S(R,V){return V()}let N=0;function k(R){var V=++N;return R+(""+V)}function A(R,V,H=1){V==null&&(V=R,R=0);let B=ee=>eeVB[V]),Object.entries(R).reduce((B,[U,ee])=>(B[U]=H(ee,U),B),{})}function L(R,V){return R.reduce((H,B,U)=>(H[B]=V[U],H),{})}return Zh}var Kh,Ub;function F5(){if(Ub)return Kh;Ub=1;let e=G5(),t=jt().uniqueId;Kh={run:r,undo:a};function r(o){(o.graph().acyclicer==="greedy"?e(o,c(o)):l(o)).forEach(d=>{let h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,t("rev"))});function c(d){return h=>d.edge(h).weight}}function l(o){let u=[],c={},d={};function h(m){Object.hasOwn(d,m)||(d[m]=!0,c[m]=!0,o.outEdges(m).forEach(p=>{Object.hasOwn(c,p.w)?u.push(p):h(p.w)}),delete c[m])}return o.nodes().forEach(h),u}function a(o){o.edges().forEach(u=>{let c=o.edge(u);if(c.reversed){o.removeEdge(u);let d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(u.w,u.v,c,d)}})}return Kh}var Jh,Vb;function Y5(){if(Vb)return Jh;Vb=1;let e=jt();Jh={run:t,undo:l};function t(a){a.graph().dummyChains=[],a.edges().forEach(o=>r(a,o))}function r(a,o){let u=o.v,c=a.node(u).rank,d=o.w,h=a.node(d).rank,m=o.name,p=a.edge(o),x=p.labelRank;if(h===c+1)return;a.removeEdge(o);let b,w,E;for(E=0,++c;c{let u=a.node(o),c=u.edgeLabel,d;for(a.setEdge(u.edgeObj,c);u.dummy;)d=a.successors(o)[0],a.removeNode(o),c.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(c.x=u.x,c.y=u.y,c.width=u.width,c.height=u.height),o=d,u=a.node(o)})}return Jh}var Wh,Pb;function xc(){if(Pb)return Wh;Pb=1;const{applyWithChunking:e}=jt();Wh={longestPath:t,slack:r};function t(l){var a={};function o(u){var c=l.node(u);if(Object.hasOwn(a,u))return c.rank;a[u]=!0;let d=l.outEdges(u).map(m=>m==null?Number.POSITIVE_INFINITY:o(m.w)-l.edge(m).minlen);var h=e(Math.min,d);return h===Number.POSITIVE_INFINITY&&(h=0),c.rank=h}l.sources().forEach(o)}function r(l,a){return l.node(a.w).rank-l.node(a.v).rank-l.edge(a).minlen}return Wh}var ep,$b;function M_(){if($b)return ep;$b=1;var e=Yn().Graph,t=xc().slack;ep=r;function r(u){var c=new e({directed:!1}),d=u.nodes()[0],h=u.nodeCount();c.setNode(d,{});for(var m,p;l(c,u){var p=m.v,x=h===p?m.w:p;!u.hasNode(x)&&!t(c,m)&&(u.setNode(x,{}),u.setEdge(h,x,{}),d(x))})}return u.nodes().forEach(d),u.nodeCount()}function a(u,c){return c.edges().reduce((h,m)=>{let p=Number.POSITIVE_INFINITY;return u.hasNode(m.v)!==u.hasNode(m.w)&&(p=t(c,m)),pc.node(h).rank+=d)}return ep}var tp,Gb;function X5(){if(Gb)return tp;Gb=1;var e=M_(),t=xc().slack,r=xc().longestPath,l=Yn().alg.preorder,a=Yn().alg.postorder,o=jt().simplify;tp=u,u.initLowLimValues=m,u.initCutValues=c,u.calcCutValue=h,u.leaveEdge=x,u.enterEdge=b,u.exchangeEdges=w;function u(N){N=o(N),r(N);var k=e(N);m(k),c(k,N);for(var A,M;A=x(k);)M=b(k,N,A),w(k,N,A,M)}function c(N,k){var A=a(N,N.nodes());A=A.slice(0,A.length-1),A.forEach(M=>d(N,k,M))}function d(N,k,A){var M=N.node(A),j=M.parent;N.edge(A,j).cutvalue=h(N,k,A)}function h(N,k,A){var M=N.node(A),j=M.parent,L=!0,R=k.edge(A,j),V=0;return R||(L=!1,R=k.edge(j,A)),V=R.weight,k.nodeEdges(A).forEach(H=>{var B=H.v===A,U=B?H.w:H.v;if(U!==j){var ee=B===L,I=k.edge(H).weight;if(V+=ee?I:-I,_(N,A,U)){var F=N.edge(A,U).cutvalue;V+=ee?-F:F}}}),V}function m(N,k){arguments.length<2&&(k=N.nodes()[0]),p(N,{},1,k)}function p(N,k,A,M,j){var L=A,R=N.node(M);return k[M]=!0,N.neighbors(M).forEach(V=>{Object.hasOwn(k,V)||(A=p(N,k,A,V,M))}),R.low=L,R.lim=A++,j?R.parent=j:delete R.parent,A}function x(N){return N.edges().find(k=>N.edge(k).cutvalue<0)}function b(N,k,A){var M=A.v,j=A.w;k.hasEdge(M,j)||(M=A.w,j=A.v);var L=N.node(M),R=N.node(j),V=L,H=!1;L.lim>R.lim&&(V=R,H=!0);var B=k.edges().filter(U=>H===S(N,N.node(U.v),V)&&H!==S(N,N.node(U.w),V));return B.reduce((U,ee)=>t(k,ee)!k.node(j).parent),M=l(N,A);M=M.slice(1),M.forEach(j=>{var L=N.node(j).parent,R=k.edge(j,L),V=!1;R||(R=k.edge(L,j),V=!0),k.node(j).rank=k.node(L).rank+(V?R.minlen:-R.minlen)})}function _(N,k,A){return N.hasEdge(k,A)}function S(N,k,A){return A.low<=k.lim&&k.lim<=A.lim}return tp}var np,Fb;function Q5(){if(Fb)return np;Fb=1;var e=xc(),t=e.longestPath,r=M_(),l=X5();np=a;function a(d){var h=d.graph().ranker;if(h instanceof Function)return h(d);switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":u(d);break;case"longest-path":o(d);break;case"none":break;default:c(d)}}var o=t;function u(d){t(d),r(d)}function c(d){l(d)}return np}var rp,Yb;function Z5(){if(Yb)return rp;Yb=1,rp=e;function e(l){let a=r(l);l.graph().dummyChains.forEach(o=>{let u=l.node(o),c=u.edgeObj,d=t(l,a,c.v,c.w),h=d.path,m=d.lca,p=0,x=h[p],b=!0;for(;o!==c.w;){if(u=l.node(o),b){for(;(x=h[p])!==m&&l.node(x).maxRankh||m>a[p].lim));for(x=p,p=u;(p=l.parent(p))!==x;)d.push(p);return{path:c.concat(d.reverse()),lca:x}}function r(l){let a={},o=0;function u(c){let d=o;l.children(c).forEach(u),a[c]={low:d,lim:o++}}return l.children().forEach(u),a}return rp}var ip,Xb;function K5(){if(Xb)return ip;Xb=1;let e=jt();ip={run:t,cleanup:o};function t(u){let c=e.addDummyNode(u,"root",{},"_root"),d=l(u),h=Object.values(d),m=e.applyWithChunking(Math.max,h)-1,p=2*m+1;u.graph().nestingRoot=c,u.edges().forEach(b=>u.edge(b).minlen*=p);let x=a(u)+1;u.children().forEach(b=>r(u,c,p,x,m,d,b)),u.graph().nodeRankFactor=p}function r(u,c,d,h,m,p,x){let b=u.children(x);if(!b.length){x!==c&&u.setEdge(c,x,{weight:0,minlen:d});return}let w=e.addBorderNode(u,"_bt"),E=e.addBorderNode(u,"_bb"),_=u.node(x);u.setParent(w,x),_.borderTop=w,u.setParent(E,x),_.borderBottom=E,b.forEach(S=>{r(u,c,d,h,m,p,S);let N=u.node(S),k=N.borderTop?N.borderTop:S,A=N.borderBottom?N.borderBottom:S,M=N.borderTop?h:2*h,j=k!==A?1:m-p[x]+1;u.setEdge(w,k,{weight:M,minlen:j,nestingEdge:!0}),u.setEdge(A,E,{weight:M,minlen:j,nestingEdge:!0})}),u.parent(x)||u.setEdge(c,w,{weight:0,minlen:m+p[x]})}function l(u){var c={};function d(h,m){var p=u.children(h);p&&p.length&&p.forEach(x=>d(x,m+1)),c[h]=m}return u.children().forEach(h=>d(h,1)),c}function a(u){return u.edges().reduce((c,d)=>c+u.edge(d).weight,0)}function o(u){var c=u.graph();u.removeNode(c.nestingRoot),delete c.nestingRoot,u.edges().forEach(d=>{var h=u.edge(d);h.nestingEdge&&u.removeEdge(d)})}return ip}var lp,Qb;function J5(){if(Qb)return lp;Qb=1;let e=jt();lp=t;function t(l){function a(o){let u=l.children(o),c=l.node(o);if(u.length&&u.forEach(a),Object.hasOwn(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(let d=c.minRank,h=c.maxRank+1;dl(d.node(h))),d.edges().forEach(h=>l(d.edge(h)))}function l(d){let h=d.width;d.width=d.height,d.height=h}function a(d){d.nodes().forEach(h=>o(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(o),Object.hasOwn(m,"y")&&o(m)})}function o(d){d.y=-d.y}function u(d){d.nodes().forEach(h=>c(d.node(h))),d.edges().forEach(h=>{let m=d.edge(h);m.points.forEach(c),Object.hasOwn(m,"x")&&c(m)})}function c(d){let h=d.x;d.x=d.y,d.y=h}return ap}var op,Kb;function e4(){if(Kb)return op;Kb=1;let e=jt();op=t;function t(r){let l={},a=r.nodes().filter(m=>!r.children(m).length),o=a.map(m=>r.node(m).rank),u=e.applyWithChunking(Math.max,o),c=e.range(u+1).map(()=>[]);function d(m){if(l[m])return;l[m]=!0;let p=r.node(m);c[p.rank].push(m),r.successors(m).forEach(d)}return a.sort((m,p)=>r.node(m).rank-r.node(p).rank).forEach(d),c}return op}var sp,Jb;function t4(){if(Jb)return sp;Jb=1;let e=jt().zipObject;sp=t;function t(l,a){let o=0;for(let u=1;ub)),c=a.flatMap(x=>l.outEdges(x).map(b=>({pos:u[b.w],weight:l.edge(b).weight})).sort((b,w)=>b.pos-w.pos)),d=1;for(;d{let b=x.pos+d;m[b]+=x.weight;let w=0;for(;b>0;)b%2&&(w+=m[b+1]),b=b-1>>1,m[b]+=x.weight;p+=x.weight*w}),p}return sp}var up,Wb;function n4(){if(Wb)return up;Wb=1,up=e;function e(t,r=[]){return r.map(l=>{let a=t.inEdges(l);if(a.length){let o=a.reduce((u,c)=>{let d=t.edge(c),h=t.node(c.v);return{sum:u.sum+d.weight*h.order,weight:u.weight+d.weight}},{sum:0,weight:0});return{v:l,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:l}})}return up}var cp,e1;function r4(){if(e1)return cp;e1=1;let e=jt();cp=t;function t(a,o){let u={};a.forEach((d,h)=>{let m=u[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};d.barycenter!==void 0&&(m.barycenter=d.barycenter,m.weight=d.weight)}),o.edges().forEach(d=>{let h=u[d.v],m=u[d.w];h!==void 0&&m!==void 0&&(m.indegree++,h.out.push(u[d.w]))});let c=Object.values(u).filter(d=>!d.indegree);return r(c)}function r(a){let o=[];function u(d){return h=>{h.merged||(h.barycenter===void 0||d.barycenter===void 0||h.barycenter>=d.barycenter)&&l(d,h)}}function c(d){return h=>{h.in.push(d),--h.indegree===0&&a.push(h)}}for(;a.length;){let d=a.pop();o.push(d),d.in.reverse().forEach(u(d)),d.out.forEach(c(d))}return o.filter(d=>!d.merged).map(d=>e.pick(d,["vs","i","barycenter","weight"]))}function l(a,o){let u=0,c=0;a.weight&&(u+=a.barycenter*a.weight,c+=a.weight),o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=u/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return cp}var fp,t1;function i4(){if(t1)return fp;t1=1;let e=jt();fp=t;function t(a,o){let u=e.partition(a,w=>Object.hasOwn(w,"barycenter")),c=u.lhs,d=u.rhs.sort((w,E)=>E.i-w.i),h=[],m=0,p=0,x=0;c.sort(l(!!o)),x=r(h,d,x),c.forEach(w=>{x+=w.vs.length,h.push(w.vs),m+=w.barycenter*w.weight,p+=w.weight,x=r(h,d,x)});let b={vs:h.flat(!0)};return p&&(b.barycenter=m/p,b.weight=p),b}function r(a,o,u){let c;for(;o.length&&(c=o[o.length-1]).i<=u;)o.pop(),a.push(c.vs),u++;return u}function l(a){return(o,u)=>o.barycenteru.barycenter?1:a?u.i-o.i:o.i-u.i}return fp}var dp,n1;function l4(){if(n1)return dp;n1=1;let e=n4(),t=r4(),r=i4();dp=l;function l(u,c,d,h){let m=u.children(c),p=u.node(c),x=p?p.borderLeft:void 0,b=p?p.borderRight:void 0,w={};x&&(m=m.filter(N=>N!==x&&N!==b));let E=e(u,m);E.forEach(N=>{if(u.children(N.v).length){let k=l(u,N.v,d,h);w[N.v]=k,Object.hasOwn(k,"barycenter")&&o(N,k)}});let _=t(E,d);a(_,w);let S=r(_,h);if(x&&(S.vs=[x,S.vs,b].flat(!0),u.predecessors(x).length)){let N=u.node(u.predecessors(x)[0]),k=u.node(u.predecessors(b)[0]);Object.hasOwn(S,"barycenter")||(S.barycenter=0,S.weight=0),S.barycenter=(S.barycenter*S.weight+N.order+k.order)/(S.weight+2),S.weight+=2}return S}function a(u,c){u.forEach(d=>{d.vs=d.vs.flatMap(h=>c[h]?c[h].vs:h)})}function o(u,c){u.barycenter!==void 0?(u.barycenter=(u.barycenter*u.weight+c.barycenter*c.weight)/(u.weight+c.weight),u.weight+=c.weight):(u.barycenter=c.barycenter,u.weight=c.weight)}return dp}var hp,r1;function a4(){if(r1)return hp;r1=1;let e=Yn().Graph,t=jt();hp=r;function r(a,o,u,c){c||(c=a.nodes());let d=l(a),h=new e({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(m=>a.node(m));return c.forEach(m=>{let p=a.node(m),x=a.parent(m);(p.rank===o||p.minRank<=o&&o<=p.maxRank)&&(h.setNode(m),h.setParent(m,x||d),a[u](m).forEach(b=>{let w=b.v===m?b.w:b.v,E=h.edge(w,m),_=E!==void 0?E.weight:0;h.setEdge(w,m,{weight:a.edge(b).weight+_})}),Object.hasOwn(p,"minRank")&&h.setNode(m,{borderLeft:p.borderLeft[o],borderRight:p.borderRight[o]}))}),h}function l(a){for(var o;a.hasNode(o=t.uniqueId("_root")););return o}return hp}var pp,i1;function o4(){if(i1)return pp;i1=1,pp=e;function e(t,r,l){let a={},o;l.forEach(u=>{let c=t.parent(u),d,h;for(;c;){if(d=t.parent(c),d?(h=a[d],a[d]=c):(h=o,o=c),h&&h!==c){r.setEdge(h,c);return}c=d}})}return pp}var mp,l1;function s4(){if(l1)return mp;l1=1;let e=e4(),t=t4(),r=l4(),l=a4(),a=o4(),o=Yn().Graph,u=jt();mp=c;function c(p,x){if(x&&typeof x.customOrder=="function"){x.customOrder(p,c);return}let b=u.maxRank(p),w=d(p,u.range(1,b+1),"inEdges"),E=d(p,u.range(b-1,-1,-1),"outEdges"),_=e(p);if(m(p,_),x&&x.disableOptimalOrderHeuristic)return;let S=Number.POSITIVE_INFINITY,N;for(let k=0,A=0;A<4;++k,++A){h(k%2?w:E,k%4>=2),_=u.buildLayerMatrix(p);let M=t(p,_);M{w.has(_)||w.set(_,[]),w.get(_).push(S)};for(const _ of p.nodes()){const S=p.node(_);if(typeof S.rank=="number"&&E(S.rank,_),typeof S.minRank=="number"&&typeof S.maxRank=="number")for(let N=S.minRank;N<=S.maxRank;N++)N!==S.rank&&E(N,_)}return x.map(function(_){return l(p,_,b,w.get(_)||[])})}function h(p,x){let b=new o;p.forEach(function(w){let E=w.graph().root,_=r(w,E,b,x);_.vs.forEach((S,N)=>w.node(S).order=N),a(w,b,_.vs)})}function m(p,x){Object.values(x).forEach(b=>b.forEach((w,E)=>p.node(w).order=E))}return mp}var gp,a1;function u4(){if(a1)return gp;a1=1;let e=Yn().Graph,t=jt();gp={positionX:b,findType1Conflicts:r,findType2Conflicts:l,addConflict:o,hasConflict:u,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:p,findSmallestWidthAlignment:m,balance:x};function r(_,S){let N={};function k(A,M){let j=0,L=0,R=A.length,V=M[M.length-1];return M.forEach((H,B)=>{let U=a(_,H),ee=U?_.node(U).order:R;(U||H===V)&&(M.slice(L,B+1).forEach(I=>{_.predecessors(I).forEach(F=>{let z=_.node(F),G=z.order;(G{H=M[B],_.node(H).dummy&&_.predecessors(H).forEach(U=>{let ee=_.node(U);ee.dummy&&(ee.orderV)&&o(N,U,H)})})}function A(M,j){let L=-1,R,V=0;return j.forEach((H,B)=>{if(_.node(H).dummy==="border"){let U=_.predecessors(H);U.length&&(R=_.node(U[0]).order,k(j,V,B,L,R),V=B,L=R)}k(j,V,j.length,R,M.length)}),j}return S.length&&S.reduce(A),N}function a(_,S){if(_.node(S).dummy)return _.predecessors(S).find(N=>_.node(N).dummy)}function o(_,S,N){if(S>N){let A=S;S=N,N=A}let k=_[S];k||(_[S]=k={}),k[N]=!0}function u(_,S,N){if(S>N){let k=S;S=N,N=k}return!!_[S]&&Object.hasOwn(_[S],N)}function c(_,S,N,k){let A={},M={},j={};return S.forEach(L=>{L.forEach((R,V)=>{A[R]=R,M[R]=R,j[R]=V})}),S.forEach(L=>{let R=-1;L.forEach(V=>{let H=k(V);if(H.length){H=H.sort((U,ee)=>j[U]-j[ee]);let B=(H.length-1)/2;for(let U=Math.floor(B),ee=Math.ceil(B);U<=ee;++U){let I=H[U];M[V]===V&&RMath.max(U,M[ee.v]+j.edge(ee)),0)}function H(B){let U=j.outEdges(B).reduce((I,F)=>Math.min(I,M[F.w]-j.edge(F)),Number.POSITIVE_INFINITY),ee=_.node(B);U!==Number.POSITIVE_INFINITY&&ee.borderType!==L&&(M[B]=Math.max(M[B],U))}return R(V,j.predecessors.bind(j)),R(H,j.successors.bind(j)),Object.keys(k).forEach(B=>M[B]=M[N[B]]),M}function h(_,S,N,k){let A=new e,M=_.graph(),j=w(M.nodesep,M.edgesep,k);return S.forEach(L=>{let R;L.forEach(V=>{let H=N[V];if(A.setNode(H),R){var B=N[R],U=A.edge(B,H);A.setEdge(B,H,Math.max(j(_,V,R),U||0))}R=V})}),A}function m(_,S){return Object.values(S).reduce((N,k)=>{let A=Number.NEGATIVE_INFINITY,M=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([L,R])=>{let V=E(_,L)/2;A=Math.max(R+V,A),M=Math.min(R-V,M)});const j=A-M;return j{["l","r"].forEach(j=>{let L=M+j,R=_[L];if(R===S)return;let V=Object.values(R),H=k-t.applyWithChunking(Math.min,V);j!=="l"&&(H=A-t.applyWithChunking(Math.max,V)),H&&(_[L]=t.mapValues(R,B=>B+H))})})}function x(_,S){return t.mapValues(_.ul,(N,k)=>{if(S)return _[S.toLowerCase()][k];{let A=Object.values(_).map(M=>M[k]).sort((M,j)=>M-j);return(A[1]+A[2])/2}})}function b(_){let S=t.buildLayerMatrix(_),N=Object.assign(r(_,S),l(_,S)),k={},A;["u","d"].forEach(j=>{A=j==="u"?S:Object.values(S).reverse(),["l","r"].forEach(L=>{L==="r"&&(A=A.map(B=>Object.values(B).reverse()));let R=(j==="u"?_.predecessors:_.successors).bind(_),V=c(_,A,N,R),H=d(_,A,V.root,V.align,L==="r");L==="r"&&(H=t.mapValues(H,B=>-B)),k[j+L]=H})});let M=m(_,k);return p(k,M),x(k,_.graph().align)}function w(_,S,N){return(k,A,M)=>{let j=k.node(A),L=k.node(M),R=0,V;if(R+=j.width/2,Object.hasOwn(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":V=-j.width/2;break;case"r":V=j.width/2;break}if(V&&(R+=N?V:-V),V=0,R+=(j.dummy?S:_)/2,R+=(L.dummy?S:_)/2,R+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":V=L.width/2;break;case"r":V=-L.width/2;break}return V&&(R+=N?V:-V),V=0,R}}function E(_,S){return _.node(S).width}return gp}var xp,o1;function c4(){if(o1)return xp;o1=1;let e=jt(),t=u4().positionX;xp=r;function r(a){a=e.asNonCompoundGraph(a),l(a),Object.entries(t(a)).forEach(([o,u])=>a.node(o).x=u)}function l(a){let o=e.buildLayerMatrix(a),u=a.graph().ranksep,c=0;o.forEach(d=>{const h=d.reduce((m,p)=>{const x=a.node(p).height;return m>x?m:x},0);d.forEach(m=>a.node(m).y=c+h/2),c+=h+u})}return xp}var yp,s1;function f4(){if(s1)return yp;s1=1;let e=F5(),t=Y5(),r=Q5(),l=jt().normalizeRanks,a=Z5(),o=jt().removeEmptyRanks,u=K5(),c=J5(),d=W5(),h=s4(),m=c4(),p=jt(),x=Yn().Graph;yp=b;function b(C,$){let X=$&&$.debugTiming?p.time:p.notime;X("layout",()=>{let J=X(" buildLayoutGraph",()=>R(C));X(" runLayout",()=>w(J,X,$)),X(" updateInputGraph",()=>E(C,J))})}function w(C,$,X){$(" makeSpaceForEdgeLabels",()=>V(C)),$(" removeSelfEdges",()=>Q(C)),$(" acyclic",()=>e.run(C)),$(" nestingGraph.run",()=>u.run(C)),$(" rank",()=>r(p.asNonCompoundGraph(C))),$(" injectEdgeLabelProxies",()=>H(C)),$(" removeEmptyRanks",()=>o(C)),$(" nestingGraph.cleanup",()=>u.cleanup(C)),$(" normalizeRanks",()=>l(C)),$(" assignRankMinMax",()=>B(C)),$(" removeEdgeLabelProxies",()=>U(C)),$(" normalize.run",()=>t.run(C)),$(" parentDummyChains",()=>a(C)),$(" addBorderSegments",()=>c(C)),$(" order",()=>h(C,X)),$(" insertSelfEdges",()=>K(C)),$(" adjustCoordinateSystem",()=>d.adjust(C)),$(" position",()=>m(C)),$(" positionSelfEdges",()=>D(C)),$(" removeBorderNodes",()=>G(C)),$(" normalize.undo",()=>t.undo(C)),$(" fixupEdgeLabelCoords",()=>F(C)),$(" undoCoordinateSystem",()=>d.undo(C)),$(" translateGraph",()=>ee(C)),$(" assignNodeIntersects",()=>I(C)),$(" reversePoints",()=>z(C)),$(" acyclic.undo",()=>e.undo(C))}function E(C,$){C.nodes().forEach(X=>{let J=C.node(X),ne=$.node(X);J&&(J.x=ne.x,J.y=ne.y,J.rank=ne.rank,$.children(X).length&&(J.width=ne.width,J.height=ne.height))}),C.edges().forEach(X=>{let J=C.edge(X),ne=$.edge(X);J.points=ne.points,Object.hasOwn(ne,"x")&&(J.x=ne.x,J.y=ne.y)}),C.graph().width=$.graph().width,C.graph().height=$.graph().height}let _=["nodesep","edgesep","ranksep","marginx","marginy"],S={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],A={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function R(C){let $=new x({multigraph:!0,compound:!0}),X=Y(C.graph());return $.setGraph(Object.assign({},S,q(X,_),p.pick(X,N))),C.nodes().forEach(J=>{let ne=Y(C.node(J));const re=q(ne,k);Object.keys(A).forEach(se=>{re[se]===void 0&&(re[se]=A[se])}),$.setNode(J,re),$.setParent(J,C.parent(J))}),C.edges().forEach(J=>{let ne=Y(C.edge(J));$.setEdge(J,Object.assign({},j,q(ne,M),p.pick(ne,L)))}),$}function V(C){let $=C.graph();$.ranksep/=2,C.edges().forEach(X=>{let J=C.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&($.rankdir==="TB"||$.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function H(C){C.edges().forEach($=>{let X=C.edge($);if(X.width&&X.height){let J=C.node($.v),re={rank:(C.node($.w).rank-J.rank)/2+J.rank,e:$};p.addDummyNode(C,"edge-proxy",re,"_ep")}})}function B(C){let $=0;C.nodes().forEach(X=>{let J=C.node(X);J.borderTop&&(J.minRank=C.node(J.borderTop).rank,J.maxRank=C.node(J.borderBottom).rank,$=Math.max($,J.maxRank))}),C.graph().maxRank=$}function U(C){C.nodes().forEach($=>{let X=C.node($);X.dummy==="edge-proxy"&&(C.edge(X.e).labelRank=X.rank,C.removeNode($))})}function ee(C){let $=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,ne=0,re=C.graph(),se=re.marginx||0,xe=re.marginy||0;function be(ye){let pe=ye.x,_e=ye.y,ze=ye.width,Te=ye.height;$=Math.min($,pe-ze/2),X=Math.max(X,pe+ze/2),J=Math.min(J,_e-Te/2),ne=Math.max(ne,_e+Te/2)}C.nodes().forEach(ye=>be(C.node(ye))),C.edges().forEach(ye=>{let pe=C.edge(ye);Object.hasOwn(pe,"x")&&be(pe)}),$-=se,J-=xe,C.nodes().forEach(ye=>{let pe=C.node(ye);pe.x-=$,pe.y-=J}),C.edges().forEach(ye=>{let pe=C.edge(ye);pe.points.forEach(_e=>{_e.x-=$,_e.y-=J}),Object.hasOwn(pe,"x")&&(pe.x-=$),Object.hasOwn(pe,"y")&&(pe.y-=J)}),re.width=X-$+se,re.height=ne-J+xe}function I(C){C.edges().forEach($=>{let X=C.edge($),J=C.node($.v),ne=C.node($.w),re,se;X.points?(re=X.points[0],se=X.points[X.points.length-1]):(X.points=[],re=ne,se=J),X.points.unshift(p.intersectRect(J,re)),X.points.push(p.intersectRect(ne,se))})}function F(C){C.edges().forEach($=>{let X=C.edge($);if(Object.hasOwn(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function z(C){C.edges().forEach($=>{let X=C.edge($);X.reversed&&X.points.reverse()})}function G(C){C.nodes().forEach($=>{if(C.children($).length){let X=C.node($),J=C.node(X.borderTop),ne=C.node(X.borderBottom),re=C.node(X.borderLeft[X.borderLeft.length-1]),se=C.node(X.borderRight[X.borderRight.length-1]);X.width=Math.abs(se.x-re.x),X.height=Math.abs(ne.y-J.y),X.x=re.x+X.width/2,X.y=J.y+X.height/2}}),C.nodes().forEach($=>{C.node($).dummy==="border"&&C.removeNode($)})}function Q(C){C.edges().forEach($=>{if($.v===$.w){var X=C.node($.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:$,label:C.edge($)}),C.removeEdge($)}})}function K(C){var $=p.buildLayerMatrix(C);$.forEach(X=>{var J=0;X.forEach((ne,re)=>{var se=C.node(ne);se.order=re+J,(se.selfEdges||[]).forEach(xe=>{p.addDummyNode(C,"selfedge",{width:xe.label.width,height:xe.label.height,rank:se.rank,order:re+ ++J,e:xe.e,label:xe.label},"_se")}),delete se.selfEdges})})}function D(C){C.nodes().forEach($=>{var X=C.node($);if(X.dummy==="selfedge"){var J=C.node(X.e.v),ne=J.x+J.width/2,re=J.y,se=X.x-ne,xe=J.height/2;C.setEdge(X.e,X.label),C.removeNode($),X.label.points=[{x:ne+2*se/3,y:re-xe},{x:ne+5*se/6,y:re-xe},{x:ne+se,y:re},{x:ne+5*se/6,y:re+xe},{x:ne+2*se/3,y:re+xe}],X.label.x=X.x,X.label.y=X.y}})}function q(C,$){return p.mapValues(p.pick(C,$),Number)}function Y(C){var $={};return C&&Object.entries(C).forEach(([X,J])=>{typeof X=="string"&&(X=X.toLowerCase()),$[X]=J}),$}return yp}var vp,u1;function d4(){if(u1)return vp;u1=1;let e=jt(),t=Yn().Graph;vp={debugOrdering:r};function r(l){let a=e.buildLayerMatrix(l),o=new t({compound:!0,multigraph:!0}).setGraph({});return l.nodes().forEach(u=>{o.setNode(u,{label:u}),o.setParent(u,"layer"+l.node(u).rank)}),l.edges().forEach(u=>o.setEdge(u.v,u.w,{},u.name)),a.forEach((u,c)=>{let d="layer"+c;o.setNode(d,{rank:"same"}),u.reduce((h,m)=>(o.setEdge(h,m,{style:"invis"}),m))}),o}return vp}var bp,c1;function h4(){return c1||(c1=1,bp="1.1.8"),bp}var wp,f1;function p4(){return f1||(f1=1,wp={graphlib:Yn(),layout:f4(),debug:d4(),util:{time:jt().time,notime:jt().notime},version:h4()}),wp}var m4=p4();const d1=Qo(m4),Ao=200,la=56,h1=20,p1=40,g4=20,m1=12;function x4(e,t,r,l,a,o,u,c){const d=[],h=[],m=new Set,p=new Set,x=new Map;for(const N of r)for(const k of N.agents)p.add(k),x.set(k,N.name);for(const N of r){const k=a[N.name],A=N.agents.length,M=Ao+h1*2,j=p1+A*la+(A-1)*m1+g4;d.push({id:N.name,type:"groupNode",position:{x:0,y:0},data:{label:N.name,type:"parallel_group",status:(k==null?void 0:k.status)||"pending",groupName:N.name,progress:o[N.name]},style:{width:M,height:j}});for(let L=0;L$entryPoint",source:"$start",target:u,type:"animatedEdge",data:{},animated:!1})}const w=new Set(d.map(N=>N.id)),E=new Map;for(const N of d)N.parentId&&E.set(N.id,N.parentId);const _=new Map;for(const N of t){const k=E.get(N.from)??N.from,A=E.get(N.to)??N.to;if(!w.has(k)||!w.has(A)||k===A)continue;const M=`${k}->${A}`,j=_.get(M);if(j){j.when!==N.when&&(h[j.idx].data={when:void 0});continue}const L=h.length;_.set(M,{when:N.when,idx:L});const R=`${M}${N.when?`[${N.when}]`:""}`;h.push({id:R,source:k,target:A,type:"animatedEdge",data:{when:N.when},animated:!1})}const S=y4(d,h,"$start");return v4(d,h,S),{nodes:d,edges:h}}function y4(e,t,r){const l=new Set(e.filter(h=>!h.parentId).map(h=>h.id)),a=new Map;for(const h of t)!l.has(h.source)||!l.has(h.target)||(a.has(h.source)||a.set(h.source,[]),a.get(h.source).push({target:h.target,edgeId:h.id}));for(const h of a.values())h.sort((m,p)=>m.targetp.target?1:0);const o=new Set,u=new Set,c=new Set,d=h=>{c.add(h),u.add(h);for(const{target:m,edgeId:p}of a.get(h)??[])u.has(m)?o.add(p):c.has(m)||d(m);u.delete(h)};l.has(r)&&d(r);for(const h of[...a.keys()].sort())c.has(h)||d(h);return o}function v4(e,t,r){var a,o,u,c;const l=new d1.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:"TB",nodesep:50,ranksep:70,marginx:30,marginy:30});for(const d of e){if(d.parentId)continue;const h=d.type==="groupNode",m=h&&((a=d.style)==null?void 0:a.width)||Ao,p=h&&((o=d.style)==null?void 0:o.height)||la;l.setNode(d.id,{width:m,height:p})}for(const d of t)!l.hasNode(d.source)||!l.hasNode(d.target)||(r.has(d.id)?l.setEdge(d.target,d.source):l.setEdge(d.source,d.target));d1.layout(l);for(const d of e){if(d.parentId)continue;const h=l.node(d.id);if(!h)continue;const m=d.type==="groupNode",p=m&&((u=d.style)==null?void 0:u.width)||Ao,x=m&&((c=d.style)==null?void 0:c.height)||la;d.position={x:h.x-p/2,y:h.y-x/2}}}const Fe={pending:"#6b7280",running:"#3b82f6",completed:"#22c55e",failed:"#ef4444",paused:"#f59e0b",idle:"#6b7280",waiting:"#a855f7"},b4=70,g1=90;function Bc({data:e,children:t}){const[r,l]=P.useState(!1),a=P.useRef(null),o=P.useCallback(()=>{a.current=setTimeout(()=>l(!0),200)},[]),u=P.useCallback(()=>{a.current&&clearTimeout(a.current),l(!1)},[]),c=Fe[e.status]||Fe.pending;return y.jsxs("div",{className:"relative",onMouseEnter:o,onMouseLeave:u,children:[t,r&&y.jsxs("div",{className:He("absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2","bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg","rounded-lg px-3 py-2 max-w-[260px] pointer-events-none","animate-[tooltip-in_150ms_ease-out]"),children:[y.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]"}),y.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[y.jsxs("div",{className:"flex items-center gap-1.5",children:[y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:c}}),y.jsx("span",{className:"font-medium text-[var(--text)] capitalize",children:e.status}),e.iteration!=null&&e.iteration>1&&y.jsxs("span",{className:"text-[var(--text-muted)] ml-auto",children:["iter ",e.iteration]})]}),y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",children:[e.elapsed!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Elapsed"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:Jt(e.elapsed)})]}),e.model&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Model"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.model})]}),e.tokens!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Tokens"}),y.jsxs("span",{className:"text-[var(--text)] font-mono",children:[$n(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&y.jsxs("span",{className:"text-[var(--text-muted)]",children:[" ","(",$n(e.inputTokens),"↑ ",$n(e.outputTokens),"↓)"]})]})]}),e.costUsd!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Cost"}),y.jsx("span",{className:"text-[var(--text)] font-mono",children:yi(e.costUsd)})]}),e.exitCode!=null&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Exit code"}),y.jsx("span",{className:He("font-mono",e.exitCode===0?"text-[var(--completed)]":"text-[var(--failed)]"),children:e.exitCode})]}),e.selectedOption&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-[var(--text-muted)]",children:"Selected"}),y.jsx("span",{className:"text-[var(--text)] truncate",children:e.selectedOption})]})]}),e.errorMessage&&y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"h-px bg-[var(--border)]"}),y.jsxs("div",{className:"text-red-400 leading-tight",children:[e.errorType&&y.jsxs("span",{className:"font-medium",children:[e.errorType,": "]}),y.jsxs("span",{className:"break-words",children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?"...":""]})]})]})]})]})]})}const w4=P.memo(function({data:t,id:r,selected:l}){var L;const a=t,o=ol(),c=((L=o[r])==null?void 0:L.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.model,x=h==null?void 0:h.tokens,b=h==null?void 0:h.input_tokens,w=h==null?void 0:h.output_tokens,E=h==null?void 0:h.cost_usd,_=h==null?void 0:h.iteration,S=h==null?void 0:h.error_type,N=h==null?void 0:h.error_message,k=h==null?void 0:h.context_pct,A=S4(r,c),M=_4(c),j=(()=>{if(c==="failed"&&N)return{text:N.length>40?N.slice(0,37)+"...":N,className:"text-red-400"};if(c==="running")return{text:A,className:"text-[var(--text-muted)]"};if(c==="completed"){const R=[];return m!=null&&R.push(Jt(m)),x!=null&&R.push(`${$n(x)} tok`),E!=null&&R.push(yi(E)),{text:R.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,elapsed:m,model:p,tokens:x,inputTokens:b,outputTokens:w,costUsd:E,iteration:_,errorType:S,errorMessage:N},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",M),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(sN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_!=null&&_>1&&y.jsxs("span",{className:"flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none",style:{backgroundColor:`${d}25`,color:d},children:["x",_]})]}),j.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",j.className),children:j.text})]}),k!=null&&y.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden",style:{backgroundColor:"rgba(255,255,255,0.06)"},children:y.jsx("div",{className:He("h-full transition-all duration-500",k>=g1?"animate-[context-pulse_2s_ease-in-out_infinite]":""),style:{width:`${Math.min(k,100)}%`,backgroundColor:k>=g1?"#ef4444":k>=b4?"#f59e0b":"#22c55e"}})})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function S4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=fe(h=>h.replayMode),a=fe(h=>h.lastEventTime),[o,u]=P.useState("0.0s"),c=P.useRef(null);return P.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function _4(e){const t=P.useRef(e),[r,l]=P.useState("");return P.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const k4=P.memo(function({data:t,id:r,selected:l}){var S;const a=t,o=ol(),c=((S=o[r])==null?void 0:S.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=o[r],m=h==null?void 0:h.elapsed,p=h==null?void 0:h.exit_code,x=h==null?void 0:h.error_type,b=h==null?void 0:h.error_message,w=E4(r,c),E=N4(c),_=(()=>{if(c==="failed"&&b)return{text:b.length>40?b.slice(0,37)+"...":b,className:"text-red-400"};if(c==="running")return{text:w,className:"text-[var(--text-muted)]"};if(c==="completed"){const N=[];return m!=null&&N.push(Jt(m)),p!=null&&N.push(`exit ${p}`),{text:N.join(" · ")||null,className:"text-[var(--text-muted)]"}}return{text:null,className:""}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,elapsed:m,exitCode:p,errorType:x,errorMessage:b},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",E),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="running"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(SN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),_.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",_.className),children:_.text})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function E4(e,t){var d;const r=(d=ol()[e])==null?void 0:d.startedAt,l=fe(h=>h.replayMode),a=fe(h=>h.lastEventTime),[o,u]=P.useState("0.0s"),c=P.useRef(null);return P.useEffect(()=>{if(t==="running"){if(l){c.current&&clearInterval(c.current);const p=r??a??0;u(Jt((a??p)-p));return}const h=r!=null?r*1e3:Date.now(),m=()=>{const p=(Date.now()-h)/1e3;u(Jt(p))};return m(),c.current=setInterval(m,1e3),()=>{c.current&&clearInterval(c.current)}}else c.current&&clearInterval(c.current)},[t,r,l,a]),o}function N4(e){const t=P.useRef(e),[r,l]=P.useState("");return P.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const C4=P.memo(function({data:t,id:r,selected:l}){var p,x;const a=t,o=ol(),c=((p=o[r])==null?void 0:p.status)||a.status||"pending",d=Fe[c]||Fe.pending,h=(x=o[r])==null?void 0:x.selected_option,m=T4(c);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:c,selectedOption:h},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",c==="waiting"&&"shadow-[0_0_12px_var(--waiting-muted)]",c==="running"&&"shadow-[0_0_12px_var(--running-glow)]",m),style:{borderColor:d},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",c==="waiting"&&"animate-pulse"),style:{backgroundColor:`${d}20`},children:y.jsx(wN,{className:"w-3.5 h-3.5",style:{color:d}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label}),c==="waiting"&&y.jsx("span",{className:"text-[10px] text-[var(--waiting)] truncate leading-tight",children:"Awaiting input..."}),c==="completed"&&h&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] truncate leading-tight",children:h})]})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function T4(e){const t=P.useRef(e),[r,l]=P.useState("");return P.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"||e==="waiting"?l("node-activate"):(a==="running"||a==="waiting")&&e==="completed"&&l("node-complete");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const j4=P.memo(function({data:t,id:r,selected:l}){var _;const a=t,u=a.type==="for_each_group"?vN:gN,c=a.progress,m=((_=ol()[r])==null?void 0:_.status)||a.status||"pending",p=Fe[m]||Fe.pending,x=A4(m),b=c?`${c.completed+c.failed}/${c.total}${c.failed>0?` (${c.failed} failed)`:""}`:null,w=c&&c.total>0?(c.completed+c.failed)/c.total*100:0,E=c!=null&&c.failed>0;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:He("flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",m==="running"&&"shadow-[0_0_16px_var(--running-glow)]",x),style:{borderColor:p,minHeight:"100%"},children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(u,{className:"w-3.5 h-3.5",style:{color:p}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text-secondary)]",children:a.label})]}),b&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] font-mono",children:b}),c&&c.total>0&&m==="running"&&y.jsx("div",{className:"w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500 ease-out",style:{width:`${w}%`,backgroundColor:E?"var(--failed)":"var(--completed)"}})})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})});function A4(e){const t=P.useRef(e),[r,l]=P.useState("");return P.useEffect(()=>{const a=t.current;if(t.current=e,a===e)return;e==="running"?l("node-activate"):a==="running"&&(e==="completed"||e==="failed")&&l(e==="completed"?"node-complete":"node-fail");const o=setTimeout(()=>l(""),400);return()=>clearTimeout(o)},[e]),r}const z4=P.memo(function({data:t,id:r,selected:l}){const a=t,u=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.status})||a.status||"pending",c=Fe[u]||Fe.pending,d=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.elapsed}),h=fe(_=>{var S;return(S=_.nodes[r])==null?void 0:S.error_message}),m=fe(_=>_.navigateIntoSubworkflow),p=qm(),x=p.some(_=>_.parentAgent===r),b=p.find(_=>_.parentAgent===r),w=b==null?void 0:b.workflowName,E=(()=>{if(u==="failed"&&h)return{text:h.length>35?h.slice(0,32)+"...":h,className:"text-red-400"};if(u==="running")return{text:w||"Running subworkflow…",className:"text-[var(--text-muted)]"};if(u==="completed"){const _=[];return w&&_.push(w),d!=null&&_.push(`${d.toFixed(1)}s`),{text:_.join(" · ")||"Done",className:"text-[var(--text-muted)]"}}return{text:w||null,className:"text-[var(--text-muted)]"}})();return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx(Bc,{data:{status:u,elapsed:d,errorType:void 0,errorMessage:h,iteration:void 0},children:y.jsxs("div",{className:He("flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300 cursor-pointer",l&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u==="running"&&"shadow-[0_0_12px_var(--running-glow)]"),style:{borderColor:c,borderStyle:"dashed"},onDoubleClick:_=>{x&&(_.stopPropagation(),m(r))},children:[y.jsx("div",{className:He("flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0",u==="running"&&"animate-pulse"),style:{backgroundColor:`${c}20`},children:y.jsx(Sc,{className:"w-3.5 h-3.5",style:{color:c}})}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("div",{className:"flex items-center gap-1",children:y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:a.label})}),E.text&&y.jsx("span",{className:He("text-[10px] truncate leading-tight",E.className),children:E.text})]}),x&&y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),M4=P.memo(function({data:t,selected:r}){const a=t.status||"pending",o=a==="completed",u=a==="failed",c=!o&&!u,d=o?Fe.completed:u?Fe.failed:Fe.pending;return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",o?"bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:d},children:o?y.jsx(Yi,{className:"w-5 h-5 text-white",strokeWidth:3}):u?y.jsx(bw,{className:"w-3.5 h-3.5 text-white",fill:"white"}):y.jsx(Yi,{className:"w-5 h-5",strokeWidth:2.5,style:{color:c?Fe.pending:d}})})]})}),D4=P.memo(function({data:t,selected:r}){const a=t.status||"pending",o=Fe[a]||Fe.pending,u=a==="running"||a==="completed";return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300",u?"bg-[var(--completed)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",u&&"shadow-[0_0_12px_var(--completed-muted)]"),style:{borderColor:o},children:y.jsx(xm,{className:"w-4 h-4 ml-0.5",style:{color:u?"white":o}})}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),x1="#a78bfa",R4=P.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="running"||a==="completed",u=o?x1:Fe[a]||x1,c=l.parentAgent,d=fe(h=>h.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]",o&&"shadow-[0_0_12px_rgba(167,139,250,0.4)]"),style:{borderColor:u},onDoubleClick:h=>{h.stopPropagation(),d()},children:y.jsx(aN,{className:"w-4 h-4",style:{color:o?"white":u}})}),c&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["from ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:c})]})]}),y.jsx(Lt,{type:"source",position:ve.Bottom,className:"!bg-[var(--border)] !border-none !w-2 !h-2"})]})}),y1="#a78bfa",O4=P.memo(function({data:t,selected:r}){const l=t,a=l.status||"pending",o=a==="completed",u=a==="failed",c=o?y1:u?Fe.failed:y1,d=l.parentAgent,h=fe(m=>m.navigateUp);return y.jsxs(y.Fragment,{children:[y.jsx(Lt,{type:"target",position:ve.Top,className:"!bg-[var(--border)] !border-none !w-2 !h-2"}),y.jsxs("div",{className:"flex flex-col items-center gap-1",children:[y.jsx("div",{className:He("flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer",o?"bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]":u?"bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]":"bg-[var(--node-bg)]",r&&"ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]"),style:{borderColor:c},onDoubleClick:m=>{m.stopPropagation(),h()},children:y.jsx(oN,{className:"w-4 h-4",style:{color:o||u?"white":c}})}),d&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] whitespace-nowrap",children:["return to ",y.jsx("span",{className:"font-medium text-[var(--text)]",children:d})]})]})]})}),L4=P.memo(function({id:t,sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c,source:d,target:h,data:m}){const p=N5(),x=P.useMemo(()=>p.find(V=>V.from===d&&V.to===h),[p,d,h]),[b,w,E]=Dm({sourceX:r,sourceY:l,targetX:a,targetY:o,sourcePosition:u,targetPosition:c}),_=m==null?void 0:m.when,S=!!_,N=(x==null?void 0:x.state)==="taken",k=(x==null?void 0:x.state)==="highlighted",A=(x==null?void 0:x.state)==="failed";let M="var(--edge-color)",j=2,L;A?(M="var(--failed)",j=3):N?(M="var(--edge-taken)",j=3):k&&(M="var(--edge-active)",j=3),S&&!N&&!k&&!A&&(L="6 3");const R=A?"failed":N?"taken":k?"active":"default";return y.jsxs(y.Fragment,{children:[y.jsx(rs,{id:t,path:b,style:{stroke:M,strokeWidth:j,strokeDasharray:L,transition:"stroke 0.3s ease, stroke-width 0.3s ease"},markerEnd:`url(#arrow-${R})`}),S&&y.jsx(XM,{children:y.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w}px,${E}px)`,pointerEvents:"all"},children:y.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate",style:{backgroundColor:A?"var(--failed)":N?"var(--edge-taken)":"var(--surface)",color:A||N?"var(--bg)":"var(--text-muted)",border:`1px solid ${A?"var(--failed)":N?"var(--edge-taken)":"var(--border)"}`},title:_,children:_})})}),N&&y.jsx("circle",{r:"3",fill:"var(--edge-taken)",children:y.jsx("animateMotion",{dur:"1s",repeatCount:"indefinite",path:b})}),A&&y.jsx("circle",{r:"3",fill:"var(--failed)",opacity:"0.8",children:y.jsx("animateMotion",{dur:"1.5s",repeatCount:"indefinite",path:b})})]})});function H4(){const e=fe(u=>u.workflowStatus),t=fe(u=>u.workflowFailure),r=fe(u=>u.workflowFailedAgent),l=fe(u=>u.selectNode);if(e!=="failed"||!t)return null;const a=t.message||t.error_type||"Unknown error",o=t.error_type==="TimeoutError";return y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-2 px-4 py-2 rounded-lg","bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10","backdrop-blur-sm max-w-[560px]"),children:[y.jsx(ww,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsxs("div",{className:"flex flex-col min-w-0",children:[y.jsx("span",{className:"text-xs font-medium text-red-300",children:"Workflow Failed"}),y.jsx("span",{className:"text-[11px] text-red-400/80 truncate",children:a}),o&&t.current_agent&&y.jsxs("span",{className:"text-[10px] text-red-400/60 truncate",children:["Timed out on agent: ",t.current_agent]}),t.checkpoint_path&&y.jsxs("span",{className:"text-[10px] text-red-400/50 truncate",title:t.checkpoint_path,children:["Checkpoint: ",t.checkpoint_path.split("/").pop()]})]}),r&&y.jsxs("button",{onClick:()=>l(r),className:"flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1",children:[y.jsx(hN,{className:"w-3 h-3"}),"View"]})]})})}function B4(){const[e,t]=P.useState(!1),r=fe(d=>d.workflowStatus),l=fe(d=>d.totalCost),a=fe(d=>d.totalTokens),o=fe(d=>d.agentsCompleted),u=fe(d=>d.agentsTotal),c=_w();return r!=="completed"||e?null:y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:He("flex items-center gap-3 px-4 py-2 rounded-lg","bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10","backdrop-blur-sm"),children:[y.jsx(cN,{className:"w-4 h-4 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-green-300",children:"Completed"}),y.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-green-400/80 font-mono",children:[y.jsx("span",{children:c}),u>0&&y.jsxs("span",{children:[o,"/",u," agents"]}),a>0&&y.jsxs("span",{children:[$n(a)," tok"]}),l>0&&y.jsx("span",{children:yi(l)})]}),y.jsx("button",{onClick:()=>t(!0),className:"p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1",children:y.jsx(ll,{className:"w-3.5 h-3.5"})})]})})}const I4={agentNode:w4,scriptNode:k4,gateNode:C4,groupNode:j4,workflowNode:z4,endNode:M4,startNode:D4,ingressNode:R4,egressNode:O4},q4={animatedEdge:L4},U4={type:"animatedEdge"};function V4(){return y.jsx("svg",{style:{position:"absolute",width:0,height:0},children:y.jsxs("defs",{children:[y.jsx("marker",{id:"arrow-default",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-color)"})}),y.jsx("marker",{id:"arrow-active",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-active)"})}),y.jsx("marker",{id:"arrow-taken",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--edge-taken)"})}),y.jsx("marker",{id:"arrow-failed",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:y.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--failed)"})})]})})}function P4(){const e=C5(),t=fe(z=>z.viewContextPath),r=fe(z=>z.selectNode),l=fe(z=>z.selectedNode),a=fe(z=>z.workflowStatus),o=fe(z=>z.wsStatus),u=fe(z=>z.workflowFailedAgent),c=fe(z=>z.navigateIntoSubworkflow),{agents:d,routes:h,parallelGroups:m,forEachGroups:p,nodes:x,groupProgress:b,entryPoint:w,subworkflowContexts:E,parentAgent:_}=e,[S,N,k]=QM([]),[A,M,j]=ZM([]),L=P.useRef(!1),R=P.useRef(""),V=JSON.stringify(t);P.useEffect(()=>{if(d.length===0){R.current!==V&&(L.current=!1,R.current=V,N([]),M([]));return}if(R.current!==V&&(L.current=!1,R.current=V),L.current)return;L.current=!0;const{nodes:z,edges:G}=x4(d,h,m,p,x,b,w,_);N(z),M(G)},[d,h,m,p,x,b,w,N,M,V,_]),P.useEffect(()=>{L.current&&N(z=>z.map(G=>{const Q=x[G.id];if(!Q)return G;const K=Q.status||"pending",D=G.data.status;if(K!==D){const q={...G.data,status:K};return G.data.groupName&&b[G.data.groupName]&&(q.progress=b[G.data.groupName]),{...G,data:q}}if(G.data.groupName&&b[G.data.groupName]){const q=G.data.progress,Y=b[G.data.groupName];if(Y&&(!q||q.completed!==Y.completed||q.failed!==Y.failed))return{...G,data:{...G.data,progress:Y}}}return G}))},[x,b,N]);const H=P.useCallback((z,G)=>{G.type==="groupNode"&&G.data.type!=="for_each_group"||r(G.id)},[r]),B=P.useCallback((z,G)=>{E.some(K=>K.parentAgent===G.id)&&c(G.id)},[E,c]),U=P.useCallback(()=>{r(null)},[r]),ee=P.useCallback(z=>{var Q;const G=((Q=z.data)==null?void 0:Q.status)||"pending";return Fe[G]??Fe.pending??"#6b7280"},[]);P.useEffect(()=>{N(z=>z.map(G=>({...G,selected:G.id===l})))},[l,N]),P.useEffect(()=>{a==="failed"&&u&&r(u)},[a,u,r]);const I=a==="pending"&&d.length===0,F=(()=>{switch(o){case"connecting":return"Connecting to workflow…";case"reconnecting":return"Reconnecting…";case"disconnected":return"Connection lost. Retrying…";default:return"Waiting for workflow…"}})();return y.jsxs("div",{className:"w-full h-full relative",children:[y.jsx(V4,{}),y.jsx(H4,{}),y.jsx(B4,{}),I&&y.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none",children:[y.jsxs("div",{className:"relative mb-3",children:[y.jsx(EN,{className:"w-8 h-8 text-[var(--accent)] opacity-20"}),y.jsx(ca,{className:"w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40"})]}),y.jsx("p",{className:"text-sm text-[var(--text-muted)] animate-pulse",children:F})]}),y.jsxs(FM,{nodes:S,edges:A,onNodesChange:k,onEdgesChange:j,onNodeClick:H,onNodeDoubleClick:B,onPaneClick:U,nodeTypes:I4,edgeTypes:q4,defaultEdgeOptions:U4,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[y.jsx(t5,{variant:Mr.Dots,gap:20,size:1,color:"var(--border-subtle)"}),y.jsx(w5,{nodeColor:ee,maskColor:"var(--minimap-mask)",style:{background:"var(--minimap-bg)"},pannable:!0,zoomable:!0}),y.jsx(s5,{showInteractive:!1,children:y.jsx($4,{})}),y.jsx(G4,{}),y.jsx(F4,{viewPathKey:V}),y.jsx(Y4,{})]})]})}function $4(){const{fitView:e}=al(),t=P.useCallback(()=>{e({padding:.2,duration:300})},[e]);return y.jsx("button",{onClick:t,className:"react-flow__controls-button",title:"Fit view (F)",style:{display:"flex",alignItems:"center",justifyContent:"center"},children:y.jsx(xN,{className:"w-3.5 h-3.5"})})}function G4(){const{fitView:e}=al();return P.useEffect(()=>{const t=r=>{var a;const l=(a=r.target)==null?void 0:a.tagName;l==="INPUT"||l==="TEXTAREA"||l==="SELECT"||r.key==="f"&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&e({padding:.2,duration:300})};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e]),null}function F4({viewPathKey:e}){const{fitView:t}=al(),r=P.useRef(e);return P.useEffect(()=>{r.current!==e&&(r.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function Y4(){const e=z5();return e?y.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]",children:y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]",children:[y.jsx("span",{className:"text-xs text-amber-300",children:"⚠"}),y.jsx("span",{className:"text-[11px] text-amber-400/80",children:e.message}),y.jsx("a",{href:window.location.pathname,className:"px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1",children:"Root"})]})}):null}function sl({items:e}){const t=e.filter(r=>r.value!=null&&r.value!=="");return t.length===0?null:y.jsx("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs",children:t.map(({label:r,value:l})=>y.jsxs("div",{className:"contents",children:[y.jsx("dt",{className:"text-[var(--text-muted)] whitespace-nowrap",children:r}),y.jsx("dd",{className:"text-[var(--text)] break-words",children:typeof l=="object"?JSON.stringify(l):String(l)})]},r))})}function D_(e){const t=[];return e.elapsed!=null&&t.push({label:"Elapsed",value:Jt(e.elapsed)}),e.model&&t.push({label:"Model",value:e.model}),e.tokens!=null&&t.push({label:"Tokens",value:$n(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:"In / Out",value:`${$n(e.input_tokens)} / ${$n(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:"Cost",value:yi(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:"Context",value:HN(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:"Iteration",value:e.iteration}),e.error_type&&t.push({label:"Error",value:e.error_type}),e.error_message&&t.push({label:"Message",value:e.error_message}),t}function nl({output:e,title:t="Output",defaultExpanded:r=!0,maxHeight:l="300px"}){const[a,o]=P.useState(r),[u,c]=P.useState(!1),d=Sw(e);if(!d)return null;const h=typeof e=="object"&&e!==null,m=async()=>{await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),2e3)};return y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[a?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),t]}),a&&y.jsx("button",{onClick:m,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Copy to clipboard",children:u?y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}):y.jsx(gw,{className:"w-3 h-3"})})]}),a&&y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words",style:{maxHeight:l},children:h?y.jsx(X4,{text:d}):d})]})}function X4({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function Vm({activity:e,defaultExpanded:t=!0}){const[r,l]=P.useState(t),a=P.useRef(null);return P.useEffect(()=>{a.current&&r&&(a.current.scrollTop=a.current.scrollHeight)},[e.length,r]),e.length===0?null:y.jsxs("div",{className:"space-y-1.5",children:[y.jsxs("button",{onClick:()=>l(!r),className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold",children:[r?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Activity (",e.length,")"]}),r&&y.jsx("div",{ref:a,className:"max-h-[400px] overflow-y-auto space-y-0.5",children:e.map((o,u)=>y.jsx(Q4,{entry:o},u))})]})}function Q4({entry:e}){const t={reasoning:"text-indigo-400/70","tool-start":"text-blue-400","tool-complete":"text-green-400",turn:"text-amber-400",message:"text-[var(--text)]"};return y.jsxs("div",{className:He("py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0"),children:[y.jsxs("div",{className:"flex items-start gap-1.5",children:[y.jsx("span",{className:"w-4 text-center flex-shrink-0",children:e.icon}),y.jsx("span",{className:"text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px",children:e.label}),y.jsx("span",{className:He("break-words",t[e.type]||"text-[var(--text)]"),children:typeof e.text=="object"?JSON.stringify(e.text):e.text})]}),e.detail&&y.jsx("div",{className:"mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto",children:typeof e.detail=="object"?JSON.stringify(e.detail,null,2):e.detail})]})}function v1({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=e.iterationHistory&&e.iterationHistory.length>0;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Agent"})]}),l?y.jsx(b1,{label:`Iteration ${e.iteration??"?"} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):y.jsxs(y.Fragment,{children:[y.jsx(sl,{items:D_(e)}),e.prompt&&y.jsx(nl,{output:e.prompt,title:"Input / Prompt",defaultExpanded:!0}),y.jsx(Vm,{activity:e.activity,defaultExpanded:t!=="completed"}),e.output!=null&&y.jsx(nl,{output:e.output,title:"Output"})]}),l&&[...e.iterationHistory].reverse().map(a=>y.jsx(b1,{label:`Iteration ${a.iteration}`,defaultExpanded:!1,status:t,snapshot:a},a.iteration))]})}function b1({label:e,defaultExpanded:t,snapshot:r,status:l}){const[a,o]=P.useState(t);return y.jsxs("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:[y.jsxs("button",{onClick:()=>o(!a),className:"flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[a?y.jsx(il,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text)]",children:e}),r.elapsed!=null&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] ml-auto",children:Z4(r.elapsed)})]}),a&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[y.jsx(sl,{items:D_(r)}),r.prompt&&y.jsx(nl,{output:r.prompt,title:"Input / Prompt",defaultExpanded:!1}),y.jsx(Vm,{activity:r.activity,defaultExpanded:t&&l!=="completed"}),r.output!=null&&y.jsx(nl,{output:r.output,title:"Output",defaultExpanded:!0}),r.error_type&&y.jsxs("div",{className:"text-xs text-red-400",children:[y.jsx("span",{className:"font-semibold",children:r.error_type}),r.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",r.error_message]})]})]})]})}function Z4(e){if(e<1)return`${(e*1e3).toFixed(0)}ms`;if(e<60)return`${e.toFixed(1)}s`;const t=Math.floor(e/60),r=(e%60).toFixed(0);return`${t}m ${r}s`}function K4({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=[];e.elapsed!=null&&l.push({label:"Elapsed",value:Jt(e.elapsed)}),e.exit_code!=null&&l.push({label:"Exit Code",value:e.exit_code}),e.error_type&&l.push({label:"Error",value:e.error_type}),e.error_message&&l.push({label:"Message",value:e.error_message});let a="";return e.stdout&&(a+=e.stdout),e.stderr&&(a+=(a?` --- stderr --- -`:"")+e.stderr),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Script"})]}),y.jsx(sl,{items:l}),a&&y.jsx(nl,{output:a,title:"Output"})]})}function K4(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const J4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,W4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eD={};function w1(e,t){return(eD.jsx?W4:J4).test(e)}const tD=/[ \t\n\f\r]/g;function nD(e){return typeof e=="object"?e.type==="text"?S1(e.value):!1:S1(e)}function S1(e){return e.replace(tD,"")===""}class ls{constructor(t,r,l){this.normal=r,this.property=t,l&&(this.space=l)}}ls.prototype.normal={};ls.prototype.property={};ls.prototype.space=void 0;function R_(e,t){const r={},l={};for(const a of e)Object.assign(r,a.property),Object.assign(l,a.normal);return new ls(r,l,t)}function lm(e){return e.toLowerCase()}class cn{constructor(t,r){this.attribute=r,this.property=t}}cn.prototype.attribute="";cn.prototype.booleanish=!1;cn.prototype.boolean=!1;cn.prototype.commaOrSpaceSeparated=!1;cn.prototype.commaSeparated=!1;cn.prototype.defined=!1;cn.prototype.mustUseProperty=!1;cn.prototype.number=!1;cn.prototype.overloadedBoolean=!1;cn.prototype.property="";cn.prototype.spaceSeparated=!1;cn.prototype.space=void 0;let rD=0;const De=ul(),Tt=ul(),am=ul(),me=ul(),st=ul(),ua=ul(),vn=ul();function ul(){return 2**++rD}const om=Object.freeze(Object.defineProperty({__proto__:null,boolean:De,booleanish:Tt,commaOrSpaceSeparated:vn,commaSeparated:ua,number:me,overloadedBoolean:am,spaceSeparated:st},Symbol.toStringTag,{value:"Module"})),Sp=Object.keys(om);class Pm extends cn{constructor(t,r,l,a){let o=-1;if(super(t,r),_1(this,"space",a),typeof l=="number")for(;++o4&&r.slice(0,4)==="data"&&sD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(k1,fD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!k1.test(o)){let u=o.replace(oD,cD);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Pm}return new a(l,t)}function cD(e){return"-"+e.toLowerCase()}function fD(e){return e.charAt(1).toUpperCase()}const dD=R_([O_,iD,B_,I_,q_],"html"),$m=R_([O_,lD,B_,I_,q_],"svg");function hD(e){return e.join(" ").trim()}var Kl={},_p,E1;function pD(){if(E1)return _p;E1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=` -`,h="/",m="*",p="",x="comment",b="declaration";function w(_,S){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];S=S||{};var C=1,E=1;function A(I){var F=I.match(t);F&&(C+=F.length);var z=I.lastIndexOf(d);E=~z?I.length-z:E+I.length}function M(){var I={line:C,column:E};return function(F){return F.position=new j(I),P(),F}}function j(I){this.start=I,this.end={line:C,column:E},this.source=S.source}j.prototype.content=_;function L(I){var F=new Error(S.source+":"+C+":"+E+": "+I);if(F.reason=I,F.filename=S.source,F.line=C,F.column=E,F.source=_,!S.silent)throw F}function O(I){var F=I.exec(_);if(F){var z=F[0];return A(z),_=_.slice(z.length),F}}function P(){O(r)}function H(I){var F;for(I=I||[];F=B();)F!==!1&&I.push(F);return I}function B(){var I=M();if(!(h!=_.charAt(0)||m!=_.charAt(1))){for(var F=2;p!=_.charAt(F)&&(m!=_.charAt(F)||h!=_.charAt(F+1));)++F;if(F+=2,p===_.charAt(F-1))return L("End of comment missing");var z=_.slice(2,F-2);return E+=2,A(z),_=_.slice(F),E+=2,I({type:x,comment:z})}}function U(){var I=M(),F=O(l);if(F){if(B(),!O(a))return L("property missing ':'");var z=O(o),G=I({type:b,property:k(F[0].replace(e,p)),value:z?k(z[0].replace(e,p)):p});return O(u),G}}function ee(){var I=[];H(I);for(var F;F=U();)F!==!1&&(I.push(F),H(I));return I}return P(),ee()}function k(_){return _?_.replace(c,p):p}return _p=w,_p}var N1;function mD(){if(N1)return Kl;N1=1;var e=Kl&&Kl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.default=r;const t=e(pD());function r(l,a){let o=null;if(!l||typeof l!="string")return o;const u=(0,t.default)(l),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;c?a(h,m,d):m&&(o=o||{},o[h]=m)}),o}return Kl}var wo={},C1;function gD(){if(C1)return wo;C1=1,Object.defineProperty(wo,"__esModule",{value:!0}),wo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||r.test(h)||e.test(h)},u=function(h,m){return m.toUpperCase()},c=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,c):h=h.replace(l,c),h.replace(t,u))};return wo.camelCase=d,wo}var So,T1;function xD(){if(T1)return So;T1=1;var e=So&&So.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(mD()),r=gD();function l(a,o){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,r.camelCase)(c,o)]=d)}),u}return l.default=l,So=l,So}var yD=xD();const vD=Qo(yD),U_=V_("end"),Gm=V_("start");function V_(e){return t;function t(r){const l=r&&r.position&&r.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function bD(e){const t=Gm(e),r=U_(e);if(t&&r)return{start:t,end:r}}function Do(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?j1(e.position):"start"in e||"end"in e?j1(e):"line"in e||"column"in e?sm(e):""}function sm(e){return A1(e&&e.line)+":"+A1(e&&e.column)}function j1(e){return sm(e&&e.start)+"-"+sm(e&&e.end)}function A1(e){return e&&typeof e=="number"?e:1}class Xt extends Error{constructor(t,r,l){super(),typeof r=="string"&&(l=r,r=void 0);let a="",o={},u=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof t=="string"?a=t:!o.cause&&t&&(u=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const d=l.indexOf(":");d===-1?o.ruleId=l:(o.source=l.slice(0,d),o.ruleId=l.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Do(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=u&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Xt.prototype.file="";Xt.prototype.name="";Xt.prototype.reason="";Xt.prototype.message="";Xt.prototype.stack="";Xt.prototype.column=void 0;Xt.prototype.line=void 0;Xt.prototype.ancestors=void 0;Xt.prototype.cause=void 0;Xt.prototype.fatal=void 0;Xt.prototype.place=void 0;Xt.prototype.ruleId=void 0;Xt.prototype.source=void 0;const Fm={}.hasOwnProperty,wD=new Map,SD=/[A-Z]/g,_D=new Set(["table","tbody","thead","tfoot","tr"]),kD=new Set(["td","th"]),P_="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ED(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=DD(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=MD(r,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?$m:dD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=$_(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function $_(e,t,r){if(t.type==="element")return ND(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return CD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return jD(e,t,r);if(t.type==="mdxjsEsm")return TD(e,t);if(t.type==="root")return AD(e,t,r);if(t.type==="text")return zD(e,t)}function ND(e,t,r){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=$m,e.schema=a),e.ancestors.push(t);const o=F_(e,t.tagName,!1),u=RD(e,t);let c=Xm(e,t);return _D.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!nD(d):!0})),G_(e,u,o,t),Ym(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function CD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Yo(e,t.position)}function TD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Yo(e,t.position)}function jD(e,t,r){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=$m,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:F_(e,t.name,!0),u=OD(e,t),c=Xm(e,t);return G_(e,u,o,t),Ym(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function AD(e,t,r){const l={};return Ym(l,Xm(e,t)),e.create(t,e.Fragment,l,r)}function zD(e,t){return t.value}function G_(e,t,r,l){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=l)}function Ym(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function MD(e,t,r){return l;function l(a,o,u,c){const h=Array.isArray(u.children)?r:t;return c?h(o,u,c):h(o,u)}}function DD(e,t){return r;function r(l,a,o,u){const c=Array.isArray(o.children),d=Gm(l);return t(a,o,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function RD(e,t){const r={};let l,a;for(a in t.properties)if(a!=="children"&&Fm.call(t.properties,a)){const o=LD(e,a,t.properties[a]);if(o){const[u,c]=o;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&kD.has(t.tagName)?l=c:r[u]=c}}if(l){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return r}function OD(e,t){const r={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const u=o.expression;u.type;const c=u.properties[0];c.type,Object.assign(r,e.evaluater.evaluateExpression(c.argument))}else Yo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Yo(e,t.position);else o=l.value===null?!0:l.value;r[a]=o}return r}function Xm(e,t){const r=[];let l=-1;const a=e.passKeys?new Map:wD;for(;++la?0:a+t:t=t>a?a:t,r=r>0?r:0,l.length<1e4)u=Array.from(l),u.unshift(t,r),e.splice(...u);else for(r&&e.splice(t,r);o0?(Sn(e,e.length,0,t),e):t}const D1={}.hasOwnProperty;function X_(e){const t={};let r=-1;for(;++r13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Kt=vi(/[A-Za-z]/),Yt=vi(/[\dA-Za-z]/),GD=vi(/[#-'*+\--9=?A-Z^-~]/);function yc(e){return e!==null&&(e<32||e===127)}const um=vi(/\d/),FD=vi(/[\dA-Fa-f]/),YD=vi(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function qe(e){return e===-2||e===-1||e===32}const Ic=vi(new RegExp("\\p{P}|\\p{S}","u")),rl=vi(/\s/);function vi(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function ba(e){const t=[];let r=-1,l=0,a=0;for(;++r55295&&o<57344){const c=e.charCodeAt(r+1);o<56320&&c>56319&&c<57344?(u=String.fromCharCode(o,c),a=1):u="�"}else u=String.fromCharCode(o);u&&(t.push(e.slice(l,r),encodeURIComponent(u)),l=r+a+1,u=""),a&&(r+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,r,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return u;function u(d){return qe(d)?(e.enter(r),c(d)):t(d)}function c(d){return qe(d)&&o++u))return;const L=t.events.length;let O=L,P,H;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if(P){H=t.events[O][1].end;break}P=!0}for(S(l),j=L;jE;){const M=r[A];t.containerState=M[1],M[0].exit.call(t,e)}r.length=E}function C(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function JD(e,t,r){return Qe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ya(e){if(e===null||ot(e)||rl(e))return 1;if(Ic(e))return 2}function qc(e,t,r){const l=[];let a=-1;for(;++a1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[l][1].end},x={...e[r][1].start};O1(p,-d),O1(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},o={type:d>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[r][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[l][1].end={...u.start},e[r][1].start={...c.end},h=[],e[l][1].end.offset-e[l][1].start.offset&&(h=Dn(h,[["enter",e[l][1],t],["exit",e[l][1],t]])),h=Dn(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",o,t]]),h=Dn(h,qc(t.parser.constructs.insideSpan.null,e.slice(l+1,r),t)),h=Dn(h,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(m=2,h=Dn(h,[["enter",e[r][1],t],["exit",e[r][1],t]])):m=0,Sn(e,l-1,r-l+3,h),r=l+h.length-m-2;break}}for(r=-1;++r0&&qe(j)?Qe(e,C,"linePrefix",o+1)(j):C(j)}function C(j){return j===null||Ee(j)?e.check(L1,k,A)(j):(e.enter("codeFlowValue"),E(j))}function E(j){return j===null||Ee(j)?(e.exit("codeFlowValue"),C(j)):(e.consume(j),E)}function A(j){return e.exit("codeFenced"),t(j)}function M(j,L,O){let P=0;return H;function H(F){return j.enter("lineEnding"),j.consume(F),j.exit("lineEnding"),B}function B(F){return j.enter("codeFencedFence"),qe(F)?Qe(j,U,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):U(F)}function U(F){return F===c?(j.enter("codeFencedFenceSequence"),ee(F)):O(F)}function ee(F){return F===c?(P++,j.consume(F),ee):P>=u?(j.exit("codeFencedFenceSequence"),qe(F)?Qe(j,I,"whitespace")(F):I(F)):O(F)}function I(F){return F===null||Ee(F)?(j.exit("codeFencedFence"),L(F)):O(F)}}}function cR(e,t,r){const l=this;return a;function a(u){return u===null?r(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}const Ep={name:"codeIndented",tokenize:dR},fR={partial:!0,tokenize:hR};function dR(e,t,r){const l=this;return a;function a(h){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(h)}function o(h){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?u(h):r(h)}function u(h){return h===null?d(h):Ee(h)?e.attempt(fR,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||Ee(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function hR(e,t,r){const l=this;return a;function a(u){return l.parser.lazy[l.now().line]?r(u):Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(u)}function o(u){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Ee(u)?a(u):r(u)}}const pR={name:"codeText",previous:gR,resolve:mR,tokenize:xR};function mR(e){let t=e.length-4,r=3,l,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=r;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,r,l){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&_o(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),_o(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),_o(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(u):e.interrupt(l.parser.constructs.flow,r,t)(u)}}function ek(e,t,r,l,a,o,u,c,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(S){return S===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(S),e.exit(o),x):S===null||S===32||S===41||yc(S)?r(S):(e.enter(l),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),k(S))}function x(S){return S===62?(e.enter(o),e.consume(S),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||Ee(S)?r(S):(e.consume(S),S===92?w:b)}function w(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function k(S){return!m&&(S===null||S===41||ot(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(l),t(S)):m999||b===null||b===91||b===93&&!d||b===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?r(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),d||(d=!qe(b)),b===92?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function nk(e,t,r,l,a,o){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(l),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):r(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(l),t):(e.enter(o),h(x))}function h(x){return x===u?(e.exit(o),d(u)):x===null?r(x):Ee(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Qe(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===u||x===null||Ee(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?p:m)}function p(x){return x===u||x===92?(e.consume(x),m):m(x)}}function Ro(e,t){let r;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,l):qe(a)?Qe(e,l,r?"linePrefix":"lineSuffix")(a):t(a)}}const ER={name:"definition",tokenize:CR},NR={partial:!0,tokenize:TR};function CR(e,t,r){const l=this;let a;return o;function o(b){return e.enter("definition"),u(b)}function u(b){return tk.call(l,e,c,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Fn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):r(b)}function d(b){return ot(b)?Ro(e,h)(b):h(b)}function h(b){return ek(e,m,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(NR,p,p)(b)}function p(b){return qe(b)?Qe(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):r(b)}}function TR(e,t,r){return l;function l(c){return ot(c)?Ro(e,a)(c):r(c)}function a(c){return nk(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return qe(c)?Qe(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Ee(c)?t(c):r(c)}}const jR={name:"hardBreakEscape",tokenize:AR};function AR(e,t,r){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const zR={name:"headingAtx",resolve:MR,tokenize:DR};function MR(e,t){let r=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),r-2>l&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(l===r-1||r-4>l&&e[r-2][1].type==="whitespace")&&(r-=l+1===r?2:4),r>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[r][1].end},o={type:"chunkText",start:e[l][1].start,end:e[r][1].end,contentType:"text"},Sn(e,l,r-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function DR(e,t,r){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&l++<6?(e.consume(m),u):m===null||ot(m)?(e.exit("atxHeadingSequence"),c(m)):r(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):qe(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),c(m))}function h(m){return m===null||m===35||ot(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),h)}}const RR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],B1=["pre","script","style","textarea"],OR={concrete:!0,name:"htmlFlow",resolveTo:BR,tokenize:IR},LR={partial:!0,tokenize:UR},HR={partial:!0,tokenize:qR};function BR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function IR(e,t,r){const l=this;let a,o,u,c,d;return h;function h(N){return m(N)}function m(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),p}function p(N){return N===33?(e.consume(N),x):N===47?(e.consume(N),o=!0,k):N===63?(e.consume(N),a=3,l.interrupt?t:D):Kt(N)?(e.consume(N),u=String.fromCharCode(N),_):r(N)}function x(N){return N===45?(e.consume(N),a=2,b):N===91?(e.consume(N),a=5,c=0,w):Kt(N)?(e.consume(N),a=4,l.interrupt?t:D):r(N)}function b(N){return N===45?(e.consume(N),l.interrupt?t:D):r(N)}function w(N){const $="CDATA[";return N===$.charCodeAt(c++)?(e.consume(N),c===$.length?l.interrupt?t:U:w):r(N)}function k(N){return Kt(N)?(e.consume(N),u=String.fromCharCode(N),_):r(N)}function _(N){if(N===null||N===47||N===62||ot(N)){const $=N===47,X=u.toLowerCase();return!$&&!o&&B1.includes(X)?(a=1,l.interrupt?t(N):U(N)):RR.includes(u.toLowerCase())?(a=6,$?(e.consume(N),S):l.interrupt?t(N):U(N)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(N):o?C(N):E(N))}return N===45||Yt(N)?(e.consume(N),u+=String.fromCharCode(N),_):r(N)}function S(N){return N===62?(e.consume(N),l.interrupt?t:U):r(N)}function C(N){return qe(N)?(e.consume(N),C):H(N)}function E(N){return N===47?(e.consume(N),H):N===58||N===95||Kt(N)?(e.consume(N),A):qe(N)?(e.consume(N),E):H(N)}function A(N){return N===45||N===46||N===58||N===95||Yt(N)?(e.consume(N),A):M(N)}function M(N){return N===61?(e.consume(N),j):qe(N)?(e.consume(N),M):E(N)}function j(N){return N===null||N===60||N===61||N===62||N===96?r(N):N===34||N===39?(e.consume(N),d=N,L):qe(N)?(e.consume(N),j):O(N)}function L(N){return N===d?(e.consume(N),d=null,P):N===null||Ee(N)?r(N):(e.consume(N),L)}function O(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||ot(N)?M(N):(e.consume(N),O)}function P(N){return N===47||N===62||qe(N)?E(N):r(N)}function H(N){return N===62?(e.consume(N),B):r(N)}function B(N){return N===null||Ee(N)?U(N):qe(N)?(e.consume(N),B):r(N)}function U(N){return N===45&&a===2?(e.consume(N),z):N===60&&a===1?(e.consume(N),G):N===62&&a===4?(e.consume(N),q):N===63&&a===3?(e.consume(N),D):N===93&&a===5?(e.consume(N),K):Ee(N)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(LR,Y,ee)(N)):N===null||Ee(N)?(e.exit("htmlFlowData"),ee(N)):(e.consume(N),U)}function ee(N){return e.check(HR,I,Y)(N)}function I(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),F}function F(N){return N===null||Ee(N)?ee(N):(e.enter("htmlFlowData"),U(N))}function z(N){return N===45?(e.consume(N),D):U(N)}function G(N){return N===47?(e.consume(N),u="",Q):U(N)}function Q(N){if(N===62){const $=u.toLowerCase();return B1.includes($)?(e.consume(N),q):U(N)}return Kt(N)&&u.length<8?(e.consume(N),u+=String.fromCharCode(N),Q):U(N)}function K(N){return N===93?(e.consume(N),D):U(N)}function D(N){return N===62?(e.consume(N),q):N===45&&a===2?(e.consume(N),D):U(N)}function q(N){return N===null||Ee(N)?(e.exit("htmlFlowData"),Y(N)):(e.consume(N),q)}function Y(N){return e.exit("htmlFlow"),t(N)}}function qR(e,t,r){const l=this;return a;function a(u){return Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):r(u)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}function UR(e,t,r){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(as,t,r)}}const VR={name:"htmlText",tokenize:PR};function PR(e,t,r){const l=this;let a,o,u;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),d}function d(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),M):D===63?(e.consume(D),E):Kt(D)?(e.consume(D),O):r(D)}function h(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Kt(D)?(e.consume(D),C):r(D)}function m(D){return D===45?(e.consume(D),b):r(D)}function p(D){return D===null?r(D):D===45?(e.consume(D),x):Ee(D)?(u=p,G(D)):(e.consume(D),p)}function x(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?x(D):p(D)}function w(D){const q="CDATA[";return D===q.charCodeAt(o++)?(e.consume(D),o===q.length?k:w):r(D)}function k(D){return D===null?r(D):D===93?(e.consume(D),_):Ee(D)?(u=k,G(D)):(e.consume(D),k)}function _(D){return D===93?(e.consume(D),S):k(D)}function S(D){return D===62?z(D):D===93?(e.consume(D),S):k(D)}function C(D){return D===null||D===62?z(D):Ee(D)?(u=C,G(D)):(e.consume(D),C)}function E(D){return D===null?r(D):D===63?(e.consume(D),A):Ee(D)?(u=E,G(D)):(e.consume(D),E)}function A(D){return D===62?z(D):E(D)}function M(D){return Kt(D)?(e.consume(D),j):r(D)}function j(D){return D===45||Yt(D)?(e.consume(D),j):L(D)}function L(D){return Ee(D)?(u=L,G(D)):qe(D)?(e.consume(D),L):z(D)}function O(D){return D===45||Yt(D)?(e.consume(D),O):D===47||D===62||ot(D)?P(D):r(D)}function P(D){return D===47?(e.consume(D),z):D===58||D===95||Kt(D)?(e.consume(D),H):Ee(D)?(u=P,G(D)):qe(D)?(e.consume(D),P):z(D)}function H(D){return D===45||D===46||D===58||D===95||Yt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),U):Ee(D)?(u=B,G(D)):qe(D)?(e.consume(D),B):P(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(u=U,G(D)):qe(D)?(e.consume(D),U):(e.consume(D),I)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?r(D):Ee(D)?(u=ee,G(D)):(e.consume(D),ee)}function I(D){return D===null||D===34||D===39||D===60||D===61||D===96?r(D):D===47||D===62||ot(D)?P(D):(e.consume(D),I)}function F(D){return D===47||D===62||ot(D)?P(D):r(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):r(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return qe(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),u(D)}}const Km={name:"labelEnd",resolveAll:YR,resolveTo:XR,tokenize:QR},$R={tokenize:ZR},GR={tokenize:KR},FR={tokenize:JR};function YR(e){let t=-1;const r=[];for(;++t=3&&(h===null||Ee(h))?(e.exit("thematicBreak"),t(h)):r(h)}function d(h){return h===a?(e.consume(h),l++,d):(e.exit("thematicBreakSequence"),qe(h)?Qe(e,c,"whitespace")(h):c(h))}}const sn={continuation:{tokenize:sO},exit:cO,name:"list",tokenize:oO},lO={partial:!0,tokenize:fO},aO={partial:!0,tokenize:uO};function oO(e,t,r){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:um(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(nc,r,h)(b):h(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return r(b)}function d(b){return um(b)&&++u<10?(e.consume(b),d):(!l.interrupt||u<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):r(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(as,l.interrupt?r:m,e.attempt(lO,x,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,x(b)}function p(b){return qe(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):r(b)}function x(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function sO(e,t,r){const l=this;return l.containerState._closeFlow=void 0,e.check(as,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!qe(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,u(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(aO,t,u)(c))}function u(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,r),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function uO(e,t,r){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===l.containerState.size?t(o):r(o)}}function cO(e){e.exit(this.containerState.type)}function fO(e,t,r){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const u=l.events[l.events.length-1];return!qe(o)&&u&&u[1].type==="listItemPrefixWhitespace"?t(o):r(o)}}const I1={name:"setextUnderline",resolveTo:dO,tokenize:hO};function dO(e,t){let r=e.length,l,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){l=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const u={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",u,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=u,e.push(["exit",u,t]),e}function hO(e,t,r){const l=this;let a;return o;function o(h){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=h,u(h)):r(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),qe(h)?Qe(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||Ee(h)?(e.exit("setextHeadingLine"),t(h)):r(h)}}const pO={tokenize:mO};function mO(e){const t=this,r=e.attempt(as,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(bR,a)),"linePrefix")));return r;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const gO={resolveAll:ik()},xO=rk("string"),yO=rk("text");function rk(e){return{resolveAll:ik(e==="text"?vO:void 0),tokenize:t};function t(r){const l=this,a=this.parser.constructs[e],o=r.attempt(a,u,c);return u;function u(m){return h(m)?o(m):c(m)}function c(m){if(m===null){r.consume(m);return}return r.enter("data"),r.consume(m),d}function d(m){return h(m)?(r.exit("data"),o(m)):(r.consume(m),d)}function h(m){if(m===null)return!0;const p=a[m];let x=-1;if(p)for(;++x-1){const c=u[0];typeof c=="string"?u[0]=c.slice(l):u.shift()}o>0&&u.push(e[a].slice(0,o))}return u}function MO(e,t){let r=-1;const l=[];let a;for(;++r4&&r.slice(0,4)==="data"&&uD.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(k1,dD);l="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!k1.test(o)){let u=o.replace(sD,fD);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Pm}return new a(l,t)}function fD(e){return"-"+e.toLowerCase()}function dD(e){return e.charAt(1).toUpperCase()}const hD=R_([O_,lD,B_,I_,q_],"html"),$m=R_([O_,aD,B_,I_,q_],"svg");function pD(e){return e.join(" ").trim()}var Kl={},_p,E1;function mD(){if(E1)return _p;E1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=` +`,h="/",m="*",p="",x="comment",b="declaration";function w(_,S){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];S=S||{};var N=1,k=1;function A(I){var F=I.match(t);F&&(N+=F.length);var z=I.lastIndexOf(d);k=~z?I.length-z:k+I.length}function M(){var I={line:N,column:k};return function(F){return F.position=new j(I),V(),F}}function j(I){this.start=I,this.end={line:N,column:k},this.source=S.source}j.prototype.content=_;function L(I){var F=new Error(S.source+":"+N+":"+k+": "+I);if(F.reason=I,F.filename=S.source,F.line=N,F.column=k,F.source=_,!S.silent)throw F}function R(I){var F=I.exec(_);if(F){var z=F[0];return A(z),_=_.slice(z.length),F}}function V(){R(r)}function H(I){var F;for(I=I||[];F=B();)F!==!1&&I.push(F);return I}function B(){var I=M();if(!(h!=_.charAt(0)||m!=_.charAt(1))){for(var F=2;p!=_.charAt(F)&&(m!=_.charAt(F)||h!=_.charAt(F+1));)++F;if(F+=2,p===_.charAt(F-1))return L("End of comment missing");var z=_.slice(2,F-2);return k+=2,A(z),_=_.slice(F),k+=2,I({type:x,comment:z})}}function U(){var I=M(),F=R(l);if(F){if(B(),!R(a))return L("property missing ':'");var z=R(o),G=I({type:b,property:E(F[0].replace(e,p)),value:z?E(z[0].replace(e,p)):p});return R(u),G}}function ee(){var I=[];H(I);for(var F;F=U();)F!==!1&&(I.push(F),H(I));return I}return V(),ee()}function E(_){return _?_.replace(c,p):p}return _p=w,_p}var N1;function gD(){if(N1)return Kl;N1=1;var e=Kl&&Kl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.default=r;const t=e(mD());function r(l,a){let o=null;if(!l||typeof l!="string")return o;const u=(0,t.default)(l),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:m}=d;c?a(h,m,d):m&&(o=o||{},o[h]=m)}),o}return Kl}var wo={},C1;function xD(){if(C1)return wo;C1=1,Object.defineProperty(wo,"__esModule",{value:!0}),wo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(h){return!h||r.test(h)||e.test(h)},u=function(h,m){return m.toUpperCase()},c=function(h,m){return"".concat(m,"-")},d=function(h,m){return m===void 0&&(m={}),o(h)?h:(h=h.toLowerCase(),m.reactCompat?h=h.replace(a,c):h=h.replace(l,c),h.replace(t,u))};return wo.camelCase=d,wo}var So,T1;function yD(){if(T1)return So;T1=1;var e=So&&So.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(gD()),r=xD();function l(a,o){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,r.camelCase)(c,o)]=d)}),u}return l.default=l,So=l,So}var vD=yD();const bD=Qo(vD),U_=V_("end"),Gm=V_("start");function V_(e){return t;function t(r){const l=r&&r.position&&r.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function wD(e){const t=Gm(e),r=U_(e);if(t&&r)return{start:t,end:r}}function Do(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?j1(e.position):"start"in e||"end"in e?j1(e):"line"in e||"column"in e?sm(e):""}function sm(e){return A1(e&&e.line)+":"+A1(e&&e.column)}function j1(e){return sm(e&&e.start)+"-"+sm(e&&e.end)}function A1(e){return e&&typeof e=="number"?e:1}class Xt extends Error{constructor(t,r,l){super(),typeof r=="string"&&(l=r,r=void 0);let a="",o={},u=!1;if(r&&("line"in r&&"column"in r?o={place:r}:"start"in r&&"end"in r?o={place:r}:"type"in r?o={ancestors:[r],place:r.position}:o={...r}),typeof t=="string"?a=t:!o.cause&&t&&(u=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof l=="string"){const d=l.indexOf(":");d===-1?o.ruleId=l:(o.source=l.slice(0,d),o.ruleId=l.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Do(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=u&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Xt.prototype.file="";Xt.prototype.name="";Xt.prototype.reason="";Xt.prototype.message="";Xt.prototype.stack="";Xt.prototype.column=void 0;Xt.prototype.line=void 0;Xt.prototype.ancestors=void 0;Xt.prototype.cause=void 0;Xt.prototype.fatal=void 0;Xt.prototype.place=void 0;Xt.prototype.ruleId=void 0;Xt.prototype.source=void 0;const Fm={}.hasOwnProperty,SD=new Map,_D=/[A-Z]/g,kD=new Set(["table","tbody","thead","tfoot","tr"]),ED=new Set(["td","th"]),P_="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ND(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let l;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=RD(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=DD(r,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:l,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?$m:hD,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=$_(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function $_(e,t,r){if(t.type==="element")return CD(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return TD(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return AD(e,t,r);if(t.type==="mdxjsEsm")return jD(e,t);if(t.type==="root")return zD(e,t,r);if(t.type==="text")return MD(e,t)}function CD(e,t,r){const l=e.schema;let a=l;t.tagName.toLowerCase()==="svg"&&l.space==="html"&&(a=$m,e.schema=a),e.ancestors.push(t);const o=F_(e,t.tagName,!1),u=OD(e,t);let c=Xm(e,t);return kD.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!rD(d):!0})),G_(e,u,o,t),Ym(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function TD(e,t){if(t.data&&t.data.estree&&e.evaluater){const l=t.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}Yo(e,t.position)}function jD(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Yo(e,t.position)}function AD(e,t,r){const l=e.schema;let a=l;t.name==="svg"&&l.space==="html"&&(a=$m,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:F_(e,t.name,!0),u=LD(e,t),c=Xm(e,t);return G_(e,u,o,t),Ym(u,c),e.ancestors.pop(),e.schema=l,e.create(t,o,u,r)}function zD(e,t,r){const l={};return Ym(l,Xm(e,t)),e.create(t,e.Fragment,l,r)}function MD(e,t){return t.value}function G_(e,t,r,l){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=l)}function Ym(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function DD(e,t,r){return l;function l(a,o,u,c){const h=Array.isArray(u.children)?r:t;return c?h(o,u,c):h(o,u)}}function RD(e,t){return r;function r(l,a,o,u){const c=Array.isArray(o.children),d=Gm(l);return t(a,o,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function OD(e,t){const r={};let l,a;for(a in t.properties)if(a!=="children"&&Fm.call(t.properties,a)){const o=HD(e,a,t.properties[a]);if(o){const[u,c]=o;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&ED.has(t.tagName)?l=c:r[u]=c}}if(l){const o=r.style||(r.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return r}function LD(e,t){const r={};for(const l of t.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const o=l.data.estree.body[0];o.type;const u=o.expression;u.type;const c=u.properties[0];c.type,Object.assign(r,e.evaluater.evaluateExpression(c.argument))}else Yo(e,t.position);else{const a=l.name;let o;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const c=l.value.data.estree.body[0];c.type,o=e.evaluater.evaluateExpression(c.expression)}else Yo(e,t.position);else o=l.value===null?!0:l.value;r[a]=o}return r}function Xm(e,t){const r=[];let l=-1;const a=e.passKeys?new Map:SD;for(;++la?0:a+t:t=t>a?a:t,r=r>0?r:0,l.length<1e4)u=Array.from(l),u.unshift(t,r),e.splice(...u);else for(r&&e.splice(t,r);o0?(Sn(e,e.length,0,t),e):t}const D1={}.hasOwnProperty;function X_(e){const t={};let r=-1;for(;++r13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Fn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Kt=vi(/[A-Za-z]/),Yt=vi(/[\dA-Za-z]/),FD=vi(/[#-'*+\--9=?A-Z^-~]/);function yc(e){return e!==null&&(e<32||e===127)}const um=vi(/\d/),YD=vi(/[\dA-Fa-f]/),XD=vi(/[!-/:-@[-`{-~]/);function Ee(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function qe(e){return e===-2||e===-1||e===32}const Ic=vi(new RegExp("\\p{P}|\\p{S}","u")),rl=vi(/\s/);function vi(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function ba(e){const t=[];let r=-1,l=0,a=0;for(;++r55295&&o<57344){const c=e.charCodeAt(r+1);o<56320&&c>56319&&c<57344?(u=String.fromCharCode(o,c),a=1):u="�"}else u=String.fromCharCode(o);u&&(t.push(e.slice(l,r),encodeURIComponent(u)),l=r+a+1,u=""),a&&(r+=a,a=0)}return t.join("")+e.slice(l)}function Qe(e,t,r,l){const a=l?l-1:Number.POSITIVE_INFINITY;let o=0;return u;function u(d){return qe(d)?(e.enter(r),c(d)):t(d)}function c(d){return qe(d)&&o++u))return;const L=t.events.length;let R=L,V,H;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(V){H=t.events[R][1].end;break}V=!0}for(S(l),j=L;jk;){const M=r[A];t.containerState=M[1],M[0].exit.call(t,e)}r.length=k}function N(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function WD(e,t,r){return Qe(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ya(e){if(e===null||ot(e)||rl(e))return 1;if(Ic(e))return 2}function qc(e,t,r){const l=[];let a=-1;for(;++a1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[l][1].end},x={...e[r][1].start};O1(p,-d),O1(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[l][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},o={type:d>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[r][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[l][1].end={...u.start},e[r][1].start={...c.end},h=[],e[l][1].end.offset-e[l][1].start.offset&&(h=Dn(h,[["enter",e[l][1],t],["exit",e[l][1],t]])),h=Dn(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",o,t]]),h=Dn(h,qc(t.parser.constructs.insideSpan.null,e.slice(l+1,r),t)),h=Dn(h,[["exit",o,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[r][1].end.offset-e[r][1].start.offset?(m=2,h=Dn(h,[["enter",e[r][1],t],["exit",e[r][1],t]])):m=0,Sn(e,l-1,r-l+3,h),r=l+h.length-m-2;break}}for(r=-1;++r0&&qe(j)?Qe(e,N,"linePrefix",o+1)(j):N(j)}function N(j){return j===null||Ee(j)?e.check(L1,E,A)(j):(e.enter("codeFlowValue"),k(j))}function k(j){return j===null||Ee(j)?(e.exit("codeFlowValue"),N(j)):(e.consume(j),k)}function A(j){return e.exit("codeFenced"),t(j)}function M(j,L,R){let V=0;return H;function H(F){return j.enter("lineEnding"),j.consume(F),j.exit("lineEnding"),B}function B(F){return j.enter("codeFencedFence"),qe(F)?Qe(j,U,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):U(F)}function U(F){return F===c?(j.enter("codeFencedFenceSequence"),ee(F)):R(F)}function ee(F){return F===c?(V++,j.consume(F),ee):V>=u?(j.exit("codeFencedFenceSequence"),qe(F)?Qe(j,I,"whitespace")(F):I(F)):R(F)}function I(F){return F===null||Ee(F)?(j.exit("codeFencedFence"),L(F)):R(F)}}}function fR(e,t,r){const l=this;return a;function a(u){return u===null?r(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}const Ep={name:"codeIndented",tokenize:hR},dR={partial:!0,tokenize:pR};function hR(e,t,r){const l=this;return a;function a(h){return e.enter("codeIndented"),Qe(e,o,"linePrefix",5)(h)}function o(h){const m=l.events[l.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?u(h):r(h)}function u(h){return h===null?d(h):Ee(h)?e.attempt(dR,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||Ee(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function pR(e,t,r){const l=this;return a;function a(u){return l.parser.lazy[l.now().line]?r(u):Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Qe(e,o,"linePrefix",5)(u)}function o(u){const c=l.events[l.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Ee(u)?a(u):r(u)}}const mR={name:"codeText",previous:xR,resolve:gR,tokenize:yR};function gR(e){let t=e.length-4,r=3,l,a;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(l=r;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(t,r,l){const a=r||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return l&&_o(this.left,l),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),_o(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),_o(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(u):e.interrupt(l.parser.constructs.flow,r,t)(u)}}function ek(e,t,r,l,a,o,u,c,d){const h=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(S){return S===60?(e.enter(l),e.enter(a),e.enter(o),e.consume(S),e.exit(o),x):S===null||S===32||S===41||yc(S)?r(S):(e.enter(l),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),E(S))}function x(S){return S===62?(e.enter(o),e.consume(S),e.exit(o),e.exit(a),e.exit(l),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||Ee(S)?r(S):(e.consume(S),S===92?w:b)}function w(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function E(S){return!m&&(S===null||S===41||ot(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(l),t(S)):m999||b===null||b===91||b===93&&!d||b===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?r(b):b===93?(e.exit(o),e.enter(a),e.consume(b),e.exit(a),e.exit(l),t):Ee(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ee(b)||c++>999?(e.exit("chunkString"),m(b)):(e.consume(b),d||(d=!qe(b)),b===92?x:p)}function x(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function nk(e,t,r,l,a,o){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(l),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):r(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(l),t):(e.enter(o),h(x))}function h(x){return x===u?(e.exit(o),d(u)):x===null?r(x):Ee(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Qe(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===u||x===null||Ee(x)?(e.exit("chunkString"),h(x)):(e.consume(x),x===92?p:m)}function p(x){return x===u||x===92?(e.consume(x),m):m(x)}}function Ro(e,t){let r;return l;function l(a){return Ee(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),r=!0,l):qe(a)?Qe(e,l,r?"linePrefix":"lineSuffix")(a):t(a)}}const NR={name:"definition",tokenize:TR},CR={partial:!0,tokenize:jR};function TR(e,t,r){const l=this;let a;return o;function o(b){return e.enter("definition"),u(b)}function u(b){return tk.call(l,e,c,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return a=Fn(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):r(b)}function d(b){return ot(b)?Ro(e,h)(b):h(b)}function h(b){return ek(e,m,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function m(b){return e.attempt(CR,p,p)(b)}function p(b){return qe(b)?Qe(e,x,"whitespace")(b):x(b)}function x(b){return b===null||Ee(b)?(e.exit("definition"),l.parser.defined.push(a),t(b)):r(b)}}function jR(e,t,r){return l;function l(c){return ot(c)?Ro(e,a)(c):r(c)}function a(c){return nk(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return qe(c)?Qe(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Ee(c)?t(c):r(c)}}const AR={name:"hardBreakEscape",tokenize:zR};function zR(e,t,r){return l;function l(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Ee(o)?(e.exit("hardBreakEscape"),t(o)):r(o)}}const MR={name:"headingAtx",resolve:DR,tokenize:RR};function DR(e,t){let r=e.length-2,l=3,a,o;return e[l][1].type==="whitespace"&&(l+=2),r-2>l&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(l===r-1||r-4>l&&e[r-2][1].type==="whitespace")&&(r-=l+1===r?2:4),r>l&&(a={type:"atxHeadingText",start:e[l][1].start,end:e[r][1].end},o={type:"chunkText",start:e[l][1].start,end:e[r][1].end,contentType:"text"},Sn(e,l,r-l+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function RR(e,t,r){let l=0;return a;function a(m){return e.enter("atxHeading"),o(m)}function o(m){return e.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&l++<6?(e.consume(m),u):m===null||ot(m)?(e.exit("atxHeadingSequence"),c(m)):r(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||Ee(m)?(e.exit("atxHeading"),t(m)):qe(m)?Qe(e,c,"whitespace")(m):(e.enter("atxHeadingText"),h(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),c(m))}function h(m){return m===null||m===35||ot(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),h)}}const OR=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],B1=["pre","script","style","textarea"],LR={concrete:!0,name:"htmlFlow",resolveTo:IR,tokenize:qR},HR={partial:!0,tokenize:VR},BR={partial:!0,tokenize:UR};function IR(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function qR(e,t,r){const l=this;let a,o,u,c,d;return h;function h(C){return m(C)}function m(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),p}function p(C){return C===33?(e.consume(C),x):C===47?(e.consume(C),o=!0,E):C===63?(e.consume(C),a=3,l.interrupt?t:D):Kt(C)?(e.consume(C),u=String.fromCharCode(C),_):r(C)}function x(C){return C===45?(e.consume(C),a=2,b):C===91?(e.consume(C),a=5,c=0,w):Kt(C)?(e.consume(C),a=4,l.interrupt?t:D):r(C)}function b(C){return C===45?(e.consume(C),l.interrupt?t:D):r(C)}function w(C){const $="CDATA[";return C===$.charCodeAt(c++)?(e.consume(C),c===$.length?l.interrupt?t:U:w):r(C)}function E(C){return Kt(C)?(e.consume(C),u=String.fromCharCode(C),_):r(C)}function _(C){if(C===null||C===47||C===62||ot(C)){const $=C===47,X=u.toLowerCase();return!$&&!o&&B1.includes(X)?(a=1,l.interrupt?t(C):U(C)):OR.includes(u.toLowerCase())?(a=6,$?(e.consume(C),S):l.interrupt?t(C):U(C)):(a=7,l.interrupt&&!l.parser.lazy[l.now().line]?r(C):o?N(C):k(C))}return C===45||Yt(C)?(e.consume(C),u+=String.fromCharCode(C),_):r(C)}function S(C){return C===62?(e.consume(C),l.interrupt?t:U):r(C)}function N(C){return qe(C)?(e.consume(C),N):H(C)}function k(C){return C===47?(e.consume(C),H):C===58||C===95||Kt(C)?(e.consume(C),A):qe(C)?(e.consume(C),k):H(C)}function A(C){return C===45||C===46||C===58||C===95||Yt(C)?(e.consume(C),A):M(C)}function M(C){return C===61?(e.consume(C),j):qe(C)?(e.consume(C),M):k(C)}function j(C){return C===null||C===60||C===61||C===62||C===96?r(C):C===34||C===39?(e.consume(C),d=C,L):qe(C)?(e.consume(C),j):R(C)}function L(C){return C===d?(e.consume(C),d=null,V):C===null||Ee(C)?r(C):(e.consume(C),L)}function R(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||ot(C)?M(C):(e.consume(C),R)}function V(C){return C===47||C===62||qe(C)?k(C):r(C)}function H(C){return C===62?(e.consume(C),B):r(C)}function B(C){return C===null||Ee(C)?U(C):qe(C)?(e.consume(C),B):r(C)}function U(C){return C===45&&a===2?(e.consume(C),z):C===60&&a===1?(e.consume(C),G):C===62&&a===4?(e.consume(C),q):C===63&&a===3?(e.consume(C),D):C===93&&a===5?(e.consume(C),K):Ee(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(HR,Y,ee)(C)):C===null||Ee(C)?(e.exit("htmlFlowData"),ee(C)):(e.consume(C),U)}function ee(C){return e.check(BR,I,Y)(C)}function I(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),F}function F(C){return C===null||Ee(C)?ee(C):(e.enter("htmlFlowData"),U(C))}function z(C){return C===45?(e.consume(C),D):U(C)}function G(C){return C===47?(e.consume(C),u="",Q):U(C)}function Q(C){if(C===62){const $=u.toLowerCase();return B1.includes($)?(e.consume(C),q):U(C)}return Kt(C)&&u.length<8?(e.consume(C),u+=String.fromCharCode(C),Q):U(C)}function K(C){return C===93?(e.consume(C),D):U(C)}function D(C){return C===62?(e.consume(C),q):C===45&&a===2?(e.consume(C),D):U(C)}function q(C){return C===null||Ee(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),q)}function Y(C){return e.exit("htmlFlow"),t(C)}}function UR(e,t,r){const l=this;return a;function a(u){return Ee(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),o):r(u)}function o(u){return l.parser.lazy[l.now().line]?r(u):t(u)}}function VR(e,t,r){return l;function l(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(as,t,r)}}const PR={name:"htmlText",tokenize:$R};function $R(e,t,r){const l=this;let a,o,u;return c;function c(D){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(D),d}function d(D){return D===33?(e.consume(D),h):D===47?(e.consume(D),M):D===63?(e.consume(D),k):Kt(D)?(e.consume(D),R):r(D)}function h(D){return D===45?(e.consume(D),m):D===91?(e.consume(D),o=0,w):Kt(D)?(e.consume(D),N):r(D)}function m(D){return D===45?(e.consume(D),b):r(D)}function p(D){return D===null?r(D):D===45?(e.consume(D),x):Ee(D)?(u=p,G(D)):(e.consume(D),p)}function x(D){return D===45?(e.consume(D),b):p(D)}function b(D){return D===62?z(D):D===45?x(D):p(D)}function w(D){const q="CDATA[";return D===q.charCodeAt(o++)?(e.consume(D),o===q.length?E:w):r(D)}function E(D){return D===null?r(D):D===93?(e.consume(D),_):Ee(D)?(u=E,G(D)):(e.consume(D),E)}function _(D){return D===93?(e.consume(D),S):E(D)}function S(D){return D===62?z(D):D===93?(e.consume(D),S):E(D)}function N(D){return D===null||D===62?z(D):Ee(D)?(u=N,G(D)):(e.consume(D),N)}function k(D){return D===null?r(D):D===63?(e.consume(D),A):Ee(D)?(u=k,G(D)):(e.consume(D),k)}function A(D){return D===62?z(D):k(D)}function M(D){return Kt(D)?(e.consume(D),j):r(D)}function j(D){return D===45||Yt(D)?(e.consume(D),j):L(D)}function L(D){return Ee(D)?(u=L,G(D)):qe(D)?(e.consume(D),L):z(D)}function R(D){return D===45||Yt(D)?(e.consume(D),R):D===47||D===62||ot(D)?V(D):r(D)}function V(D){return D===47?(e.consume(D),z):D===58||D===95||Kt(D)?(e.consume(D),H):Ee(D)?(u=V,G(D)):qe(D)?(e.consume(D),V):z(D)}function H(D){return D===45||D===46||D===58||D===95||Yt(D)?(e.consume(D),H):B(D)}function B(D){return D===61?(e.consume(D),U):Ee(D)?(u=B,G(D)):qe(D)?(e.consume(D),B):V(D)}function U(D){return D===null||D===60||D===61||D===62||D===96?r(D):D===34||D===39?(e.consume(D),a=D,ee):Ee(D)?(u=U,G(D)):qe(D)?(e.consume(D),U):(e.consume(D),I)}function ee(D){return D===a?(e.consume(D),a=void 0,F):D===null?r(D):Ee(D)?(u=ee,G(D)):(e.consume(D),ee)}function I(D){return D===null||D===34||D===39||D===60||D===61||D===96?r(D):D===47||D===62||ot(D)?V(D):(e.consume(D),I)}function F(D){return D===47||D===62||ot(D)?V(D):r(D)}function z(D){return D===62?(e.consume(D),e.exit("htmlTextData"),e.exit("htmlText"),t):r(D)}function G(D){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),Q}function Q(D){return qe(D)?Qe(e,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):K(D)}function K(D){return e.enter("htmlTextData"),u(D)}}const Km={name:"labelEnd",resolveAll:XR,resolveTo:QR,tokenize:ZR},GR={tokenize:KR},FR={tokenize:JR},YR={tokenize:WR};function XR(e){let t=-1;const r=[];for(;++t=3&&(h===null||Ee(h))?(e.exit("thematicBreak"),t(h)):r(h)}function d(h){return h===a?(e.consume(h),l++,d):(e.exit("thematicBreakSequence"),qe(h)?Qe(e,c,"whitespace")(h):c(h))}}const sn={continuation:{tokenize:uO},exit:fO,name:"list",tokenize:sO},aO={partial:!0,tokenize:dO},oO={partial:!0,tokenize:cO};function sO(e,t,r){const l=this,a=l.events[l.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,u=0;return c;function c(b){const w=l.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!l.containerState.marker||b===l.containerState.marker:um(b)){if(l.containerState.type||(l.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(nc,r,h)(b):h(b);if(!l.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return r(b)}function d(b){return um(b)&&++u<10?(e.consume(b),d):(!l.interrupt||u<2)&&(l.containerState.marker?b===l.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):r(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||b,e.check(as,l.interrupt?r:m,e.attempt(aO,x,p))}function m(b){return l.containerState.initialBlankLine=!0,o++,x(b)}function p(b){return qe(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),x):r(b)}function x(b){return l.containerState.size=o+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function uO(e,t,r){const l=this;return l.containerState._closeFlow=void 0,e.check(as,a,o);function a(c){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,Qe(e,t,"listItemIndent",l.containerState.size+1)(c)}function o(c){return l.containerState.furtherBlankLines||!qe(c)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,u(c)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(oO,t,u)(c))}function u(c){return l.containerState._closeFlow=!0,l.interrupt=void 0,Qe(e,e.attempt(sn,t,r),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function cO(e,t,r){const l=this;return Qe(e,a,"listItemIndent",l.containerState.size+1);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===l.containerState.size?t(o):r(o)}}function fO(e){e.exit(this.containerState.type)}function dO(e,t,r){const l=this;return Qe(e,a,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const u=l.events[l.events.length-1];return!qe(o)&&u&&u[1].type==="listItemPrefixWhitespace"?t(o):r(o)}}const I1={name:"setextUnderline",resolveTo:hO,tokenize:pO};function hO(e,t){let r=e.length,l,a,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){l=r;break}e[r][1].type==="paragraph"&&(a=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const u={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",u,t]),e.splice(o+1,0,["exit",e[l][1],t]),e[l][1].end={...e[o][1].end}):e[l][1]=u,e.push(["exit",u,t]),e}function pO(e,t,r){const l=this;let a;return o;function o(h){let m=l.events.length,p;for(;m--;)if(l.events[m][1].type!=="lineEnding"&&l.events[m][1].type!=="linePrefix"&&l.events[m][1].type!=="content"){p=l.events[m][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||p)?(e.enter("setextHeadingLine"),a=h,u(h)):r(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),qe(h)?Qe(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||Ee(h)?(e.exit("setextHeadingLine"),t(h)):r(h)}}const mO={tokenize:gO};function gO(e){const t=this,r=e.attempt(as,l,e.attempt(this.parser.constructs.flowInitial,a,Qe(e,e.attempt(this.parser.constructs.flow,a,e.attempt(wR,a)),"linePrefix")));return r;function l(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const xO={resolveAll:ik()},yO=rk("string"),vO=rk("text");function rk(e){return{resolveAll:ik(e==="text"?bO:void 0),tokenize:t};function t(r){const l=this,a=this.parser.constructs[e],o=r.attempt(a,u,c);return u;function u(m){return h(m)?o(m):c(m)}function c(m){if(m===null){r.consume(m);return}return r.enter("data"),r.consume(m),d}function d(m){return h(m)?(r.exit("data"),o(m)):(r.consume(m),d)}function h(m){if(m===null)return!0;const p=a[m];let x=-1;if(p)for(;++x-1){const c=u[0];typeof c=="string"?u[0]=c.slice(l):u.shift()}o>0&&u.push(e[a].slice(0,o))}return u}function DO(e,t){let r=-1;const l=[];let a;for(;++r0){const Qt=Ne.tokenStack[Ne.tokenStack.length-1];(Qt[1]||U1).call(Ne,void 0,Qt[0])}for(ge.position={start:mi(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:mi(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:r}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function FO(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function YO(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function XO(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=ba(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let u,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),u=e.footnoteOrder.length):u=o+1,c+=1,e.footnoteCounts.set(l,c);const d={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function QO(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ZO(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function ok(e,t){const r=t.referenceType;let l="]";if(r==="collapsed"?l+="[]":r==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=l:a.push({type:"text",value:l}),a}function KO(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return ok(e,t);const a={src:ba(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function JO(e,t){const r={src:ba(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,l),e.applyData(t,l)}function WO(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const l={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,l),e.applyData(t,l)}function e6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return ok(e,t);const a={href:ba(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function t6(e,t){const r={href:ba(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function n6(e,t,r){const l=e.all(t),a=r?r6(r):sk(t),o={},u=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c0){const Qt=Ne.tokenStack[Ne.tokenStack.length-1];(Qt[1]||U1).call(Ne,void 0,Qt[0])}for(ge.position={start:mi(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:mi(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe0&&(l.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:l,children:[{type:"text",value:r}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function YO(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function XO(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function QO(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(t.identifier).toUpperCase(),a=ba(l.toLowerCase()),o=e.footnoteOrder.indexOf(l);let u,c=e.footnoteCounts.get(l);c===void 0?(c=0,e.footnoteOrder.push(l),u=e.footnoteOrder.length):u=o+1,c+=1,e.footnoteCounts.set(l,c);const d={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+a,id:r+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function ZO(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function KO(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function ok(e,t){const r=t.referenceType;let l="]";if(r==="collapsed"?l+="[]":r==="full"&&(l+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+l}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const u=a[a.length-1];return u&&u.type==="text"?u.value+=l:a.push({type:"text",value:l}),a}function JO(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return ok(e,t);const a={src:ba(l.url||""),alt:t.alt};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function WO(e,t){const r={src:ba(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,l),e.applyData(t,l)}function e6(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const l={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,l),e.applyData(t,l)}function t6(e,t){const r=String(t.identifier).toUpperCase(),l=e.definitionById.get(r);if(!l)return ok(e,t);const a={href:ba(l.url||"")};l.title!==null&&l.title!==void 0&&(a.title=l.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function n6(e,t){const r={href:ba(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const l={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function r6(e,t,r){const l=e.all(t),a=r?i6(r):sk(t),o={},u=[];if(typeof t.checked=="boolean"){const m=l[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},l.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c1}function i6(e,t){const r={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++a0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},c=Gm(t.children[1]),d=U_(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function u6(e,t,r){const l=r?r.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",u=r&&r.type==="table"?r.align:void 0,c=u?u.length:t.children.length;let d=-1;const h=[];for(;++d0,!0),l[0]),a=l.index+l[0].length,l=r.exec(t);return o.push($1(t.slice(a),a>0,!1)),o.join("")}function $1(e,t,r){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(r){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function d6(e,t){const r={type:"text",value:f6(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function h6(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const p6={blockquote:PO,break:$O,code:GO,delete:FO,emphasis:YO,footnoteReference:XO,heading:QO,html:ZO,imageReference:KO,image:JO,inlineCode:WO,linkReference:e6,link:t6,listItem:n6,list:i6,paragraph:l6,root:a6,strong:o6,table:s6,tableCell:c6,tableRow:u6,text:d6,thematicBreak:h6,toml:Gu,yaml:Gu,definition:Gu,footnoteDefinition:Gu};function Gu(){}const uk=-1,Uc=0,Oo=1,vc=2,Jm=3,Wm=4,eg=5,tg=6,ck=7,fk=8,G1=typeof self=="object"?self:globalThis,m6=(e,t)=>{const r=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,u]=t[a];switch(o){case Uc:case uk:return r(u,a);case Oo:{const c=r([],a);for(const d of u)c.push(l(d));return c}case vc:{const c=r({},a);for(const[d,h]of u)c[l(d)]=l(h);return c}case Jm:return r(new Date(u),a);case Wm:{const{source:c,flags:d}=u;return r(new RegExp(c,d),a)}case eg:{const c=r(new Map,a);for(const[d,h]of u)c.set(l(d),l(h));return c}case tg:{const c=r(new Set,a);for(const d of u)c.add(l(d));return c}case ck:{const{name:c,message:d}=u;return r(new G1[c](d),a)}case fk:return r(BigInt(u),a);case"BigInt":return r(Object(BigInt(u)),a);case"ArrayBuffer":return r(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return r(new DataView(c),u)}}return r(new G1[o](u),a)};return l},F1=e=>m6(new Map,e)(0),Jl="",{toString:g6}={},{keys:x6}=Object,ko=e=>{const t=typeof e;if(t!=="object"||!e)return[Uc,t];const r=g6.call(e).slice(8,-1);switch(r){case"Array":return[Oo,Jl];case"Object":return[vc,Jl];case"Date":return[Jm,Jl];case"RegExp":return[Wm,Jl];case"Map":return[eg,Jl];case"Set":return[tg,Jl];case"DataView":return[Oo,r]}return r.includes("Array")?[Oo,r]:r.includes("Error")?[ck,r]:[vc,r]},Fu=([e,t])=>e===Uc&&(t==="function"||t==="symbol"),y6=(e,t,r,l)=>{const a=(u,c)=>{const d=l.push(u)-1;return r.set(c,d),d},o=u=>{if(r.has(u))return r.get(u);let[c,d]=ko(u);switch(c){case Uc:{let m=u;switch(d){case"bigint":c=fk,m=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([uk],u)}return a([c,m],u)}case Oo:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const m=[],p=a([c,m],u);for(const x of u)m.push(o(x));return p}case vc:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return o(u.toJSON());const m=[],p=a([c,m],u);for(const x of x6(u))(e||!Fu(ko(u[x])))&&m.push([o(x),o(u[x])]);return p}case Jm:return a([c,u.toISOString()],u);case Wm:{const{source:m,flags:p}=u;return a([c,{source:m,flags:p}],u)}case eg:{const m=[],p=a([c,m],u);for(const[x,b]of u)(e||!(Fu(ko(x))||Fu(ko(b))))&&m.push([o(x),o(b)]);return p}case tg:{const m=[],p=a([c,m],u);for(const x of u)(e||!Fu(ko(x)))&&m.push(o(x));return p}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return o},Y1=(e,{json:t,lossy:r}={})=>{const l=[];return y6(!(t||r),!!t,new Map,l)(e),l},bc=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?F1(Y1(e,t)):structuredClone(e):(e,t)=>F1(Y1(e,t));function v6(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function b6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function w6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||v6,l=e.options.footnoteBackLabel||b6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d0&&w.push({type:"text",value:" "});let C=typeof r=="string"?r:r(d,b);typeof C=="string"&&(C={type:"text",value:C}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(d,b),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const _=m[m.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const C=_.children[_.children.length-1];C&&C.type==="text"?C.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...w)}else m.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(m,!0)};e.patch(h,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...bc(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` +`});const h={type:"element",tagName:"li",properties:o,children:u};return e.patch(t,h),e.applyData(t,h)}function i6(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const r=e.children;let l=-1;for(;!t&&++l1}function l6(e,t){const r={},l=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++a0){const u={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},c=Gm(t.children[1]),d=U_(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function c6(e,t,r){const l=r?r.children:void 0,o=(l?l.indexOf(t):1)===0?"th":"td",u=r&&r.type==="table"?r.align:void 0,c=u?u.length:t.children.length;let d=-1;const h=[];for(;++d0,!0),l[0]),a=l.index+l[0].length,l=r.exec(t);return o.push($1(t.slice(a),a>0,!1)),o.join("")}function $1(e,t,r){let l=0,a=e.length;if(t){let o=e.codePointAt(l);for(;o===V1||o===P1;)l++,o=e.codePointAt(l)}if(r){let o=e.codePointAt(a-1);for(;o===V1||o===P1;)a--,o=e.codePointAt(a-1)}return a>l?e.slice(l,a):""}function h6(e,t){const r={type:"text",value:d6(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function p6(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const m6={blockquote:$O,break:GO,code:FO,delete:YO,emphasis:XO,footnoteReference:QO,heading:ZO,html:KO,imageReference:JO,image:WO,inlineCode:e6,linkReference:t6,link:n6,listItem:r6,list:l6,paragraph:a6,root:o6,strong:s6,table:u6,tableCell:f6,tableRow:c6,text:h6,thematicBreak:p6,toml:Gu,yaml:Gu,definition:Gu,footnoteDefinition:Gu};function Gu(){}const uk=-1,Uc=0,Oo=1,vc=2,Jm=3,Wm=4,eg=5,tg=6,ck=7,fk=8,G1=typeof self=="object"?self:globalThis,g6=(e,t)=>{const r=(a,o)=>(e.set(o,a),a),l=a=>{if(e.has(a))return e.get(a);const[o,u]=t[a];switch(o){case Uc:case uk:return r(u,a);case Oo:{const c=r([],a);for(const d of u)c.push(l(d));return c}case vc:{const c=r({},a);for(const[d,h]of u)c[l(d)]=l(h);return c}case Jm:return r(new Date(u),a);case Wm:{const{source:c,flags:d}=u;return r(new RegExp(c,d),a)}case eg:{const c=r(new Map,a);for(const[d,h]of u)c.set(l(d),l(h));return c}case tg:{const c=r(new Set,a);for(const d of u)c.add(l(d));return c}case ck:{const{name:c,message:d}=u;return r(new G1[c](d),a)}case fk:return r(BigInt(u),a);case"BigInt":return r(Object(BigInt(u)),a);case"ArrayBuffer":return r(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:c}=new Uint8Array(u);return r(new DataView(c),u)}}return r(new G1[o](u),a)};return l},F1=e=>g6(new Map,e)(0),Jl="",{toString:x6}={},{keys:y6}=Object,ko=e=>{const t=typeof e;if(t!=="object"||!e)return[Uc,t];const r=x6.call(e).slice(8,-1);switch(r){case"Array":return[Oo,Jl];case"Object":return[vc,Jl];case"Date":return[Jm,Jl];case"RegExp":return[Wm,Jl];case"Map":return[eg,Jl];case"Set":return[tg,Jl];case"DataView":return[Oo,r]}return r.includes("Array")?[Oo,r]:r.includes("Error")?[ck,r]:[vc,r]},Fu=([e,t])=>e===Uc&&(t==="function"||t==="symbol"),v6=(e,t,r,l)=>{const a=(u,c)=>{const d=l.push(u)-1;return r.set(c,d),d},o=u=>{if(r.has(u))return r.get(u);let[c,d]=ko(u);switch(c){case Uc:{let m=u;switch(d){case"bigint":c=fk,m=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([uk],u)}return a([c,m],u)}case Oo:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const m=[],p=a([c,m],u);for(const x of u)m.push(o(x));return p}case vc:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return o(u.toJSON());const m=[],p=a([c,m],u);for(const x of y6(u))(e||!Fu(ko(u[x])))&&m.push([o(x),o(u[x])]);return p}case Jm:return a([c,u.toISOString()],u);case Wm:{const{source:m,flags:p}=u;return a([c,{source:m,flags:p}],u)}case eg:{const m=[],p=a([c,m],u);for(const[x,b]of u)(e||!(Fu(ko(x))||Fu(ko(b))))&&m.push([o(x),o(b)]);return p}case tg:{const m=[],p=a([c,m],u);for(const x of u)(e||!Fu(ko(x)))&&m.push(o(x));return p}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return o},Y1=(e,{json:t,lossy:r}={})=>{const l=[];return v6(!(t||r),!!t,new Map,l)(e),l},bc=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?F1(Y1(e,t)):structuredClone(e):(e,t)=>F1(Y1(e,t));function b6(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function w6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function S6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||b6,l=e.options.footnoteBackLabel||w6,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d0&&w.push({type:"text",value:" "});let N=typeof r=="string"?r:r(d,b);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(b>1?"-"+b:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(d,b),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const _=m[m.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const N=_.children[_.children.length-1];N&&N.type==="text"?N.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...w)}else m.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(m,!0)};e.patch(h,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...bc(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:` -`}]}}const Vc=(function(e){if(e==null)return E6;if(typeof e=="function")return Pc(e);if(typeof e=="object")return Array.isArray(e)?S6(e):_6(e);if(typeof e=="string")return k6(e);throw new Error("Expected function, string, or object as test")});function S6(e){const t=[];let r=-1;for(;++r":""))+")"})}return x;function x(){let b=dk,w,k,_;if((!t||o(d,h,m[m.length-1]||void 0))&&(b=j6(r(d,m)),b[0]===fm))return b;if("children"in d&&d.children){const S=d;if(S.children&&b[0]!==T6)for(k=(l?S.children.length:-1)+u,_=m.concat(S);k>-1&&k":""))+")"})}return x;function x(){let b=dk,w,E,_;if((!t||o(d,h,m[m.length-1]||void 0))&&(b=A6(r(d,m)),b[0]===fm))return b;if("children"in d&&d.children){const S=d;if(S.children&&b[0]!==j6)for(E=(l?S.children.length:-1)+u,_=m.concat(S);E>-1&&E0&&r.push({type:"text",value:` -`}),r}function X1(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Q1(e,t){const r=z6(e,t),l=r.one(e,void 0),a=w6(r),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` -`},a),o}function L6(e,t){return e&&"run"in e?async function(r,l){const a=Q1(r,{file:l,...t});await e.run(a,l)}:function(r,l){return Q1(r,{file:l,...e||t})}}function Z1(e){if(e)throw e}var Cp,K1;function H6(){if(K1)return Cp;K1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},u=function(h,m){r&&m.name==="__proto__"?r(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(l)return l(h,m).value}else return;return h[m]};return Cp=function d(){var h,m,p,x,b,w,k=arguments[0],_=1,S=arguments.length,C=!1;for(typeof k=="boolean"&&(C=k,k=arguments[1]||{},_=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});_u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const m=h;if(c&&r)throw m;return a(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(o,a):d instanceof Error?a(d):o(d))}function a(u,...c){r||(r=!0,t(u,...c))}function o(u){a(null,u)}}const nr={basename:U6,dirname:V6,extname:P6,join:$6,sep:"/"};function U6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');os(e);let r=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else u<0&&(o=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=u));return r===l?l=u:l<0&&(l=e.length),e.slice(r,l)}function V6(e){if(os(e),e.length===0)return".";let t=-1,r=e.length,l;for(;--r;)if(e.codePointAt(r)===47){if(l){t=r;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function P6(e){os(e);let t=e.length,r=-1,l=0,a=-1,o=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){l=t+1;break}continue}r<0&&(u=!0,r=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===l+1?"":e.slice(a,r)}function $6(...e){let t=-1,r;for(;++t0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function F6(e,t){let r="",l=0,a=-1,o=0,u=-1,c,d;for(;++u<=e.length;){if(u2){if(d=r.lastIndexOf("/"),d!==r.length-1){d<0?(r="",l=0):(r=r.slice(0,d),l=r.length-1-r.lastIndexOf("/")),a=u,o=0;continue}}else if(r.length>0){r="",l=0,a=u,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",l=2)}else r.length>0?r+="/"+e.slice(a+1,u):r=e.slice(a+1,u),l=u-a-1;a=u,o=0}else c===46&&o>-1?o++:o=-1}return r}function os(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Y6={cwd:X6};function X6(){return"/"}function pm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Q6(e){if(typeof e=="string")e=new URL(e);else if(!pm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Z6(e)}function Z6(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let r=-1;for(;++r0){let[b,...w]=m;const k=l[x][1];hm(k)&&hm(b)&&(b=Tp(!0,k,b)),l[x]=[h,b,...w]}}}}const eL=new rg().freeze();function Mp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Dp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Rp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function W1(e){if(!hm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ew(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Yu(e){return tL(e)?e:new pk(e)}function tL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function nL(e){return typeof e=="string"||rL(e)}function rL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const iL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",tw=[],nw={allowDangerousHtml:!0},lL=/^(https?|ircs?|mailto|xmpp)$/i,aL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function $c(e){const t=oL(e),r=sL(e);return uL(t.runSync(t.parse(r),r),e)}function oL(e){const t=e.rehypePlugins||tw,r=e.remarkPlugins||tw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...nw}:nw;return eL().use(VO).use(r).use(L6,l).use(t)}function sL(e){const t=e.children||"",r=new pk;return typeof t=="string"&&(r.value=t),r}function uL(e,t){const r=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||cL;for(const m of aL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+iL+m.id,void 0);return ng(e,h),ED(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function h(m,p,x){if(m.type==="raw"&&x&&typeof p=="number")return u?x.children.splice(p,1):x.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in kp)if(Object.hasOwn(kp,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],k=kp[b];(k===null||k.includes(m.tagName))&&(m.properties[b]=d(String(w||""),b,m))}}if(m.type==="element"){let b=r?!r.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,x)),b&&x&&typeof p=="number")return c&&m.children?x.children.splice(p,1,...m.children):x.children.splice(p,1),p}}}function cL(e){const t=e.indexOf(":"),r=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||l!==-1&&t>l||lL.test(e.slice(0,t))?e:""}function rw(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=r.indexOf(t);for(;a!==-1;)l++,a=r.indexOf(t,a+t.length);return l}function fL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function dL(e,t,r){const a=Vc((r||{}).ignore||[]),o=hL(t);let u=-1;for(;++u0?{type:"text",value:j}:void 0),j===!1?x.lastIndex=A+1:(w!==A&&C.push({type:"text",value:h.value.slice(w,A)}),Array.isArray(j)?C.push(...j):j&&C.push(j),w=A+E[0].length,S=!0),!x.global)break;E=x.exec(h.value)}return S?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],l=r.indexOf(")");const a=rw(e,"(");let o=rw(e,")");for(;l!==-1&&a>o;)e+=r.slice(0,l+1),r=r.slice(l+1),l=r.indexOf(")"),o++;return[e,r]}function mk(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||rl(r)||Ic(r))&&(!t||r!==47)}gk.peek=LL;function TL(){this.buffer()}function jL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function AL(){this.buffer()}function zL(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ML(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function DL(e){this.exit(e)}function RL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function OL(e){this.exit(e)}function LL(){return"["}function gk(e,t,r,l){const a=r.createTracker(l);let o=a.move("[^");const u=r.enter("footnoteReference"),c=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),c(),u(),o+=a.move("]"),o}function HL(){return{enter:{gfmFootnoteCallString:TL,gfmFootnoteCall:jL,gfmFootnoteDefinitionLabelString:AL,gfmFootnoteDefinition:zL},exit:{gfmFootnoteCallString:ML,gfmFootnoteCall:DL,gfmFootnoteDefinitionLabelString:RL,gfmFootnoteDefinition:OL}}}function BL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:gk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(l,a,o,u){const c=o.createTracker(u);let d=c.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return d+=c.move(o.safe(o.associationId(l),{before:d,after:"]"})),m(),d+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),d+=c.move((t?` -`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?xk:IL))),h(),d}}function IL(e,t,r){return t===0?e:xk(e,t,r)}function xk(e,t,r){return(r?"":" ")+e}const qL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];yk.peek=GL;function UL(){return{canContainEols:["delete"],enter:{strikethrough:PL},exit:{strikethrough:$L}}}function VL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:qL}],handlers:{delete:yk}}}function PL(e){this.enter({type:"delete",children:[]},e)}function $L(e){this.exit(e)}function yk(e,t,r,l){const a=r.createTracker(l),o=r.enter("strikethrough");let u=a.move("~~");return u+=r.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),o(),u}function GL(){return"~"}function FL(e){return e.length}function YL(e,t){const r=t||{},l=(r.align||[]).concat(),a=r.stringLength||FL,o=[],u=[],c=[],d=[];let h=0,m=-1;for(;++mh&&(h=e[m].length);++Sd[S])&&(d[S]=E)}k.push(C)}u[m]=k,c[m]=_}let p=-1;if(typeof l=="object"&&"length"in l)for(;++pd[p]&&(d[p]=C),b[p]=C),x[p]=E}u.splice(1,0,x),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const u=r.indentLines(r.containerFlow(e,o.current()),ZL);return a(),u}function ZL(e,t,r){return">"+(r?"":" ")+e}function KL(e,t){return lw(e,t.inConstruct,!0)&&!lw(e,t.notInConstruct,!1)}function lw(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let l=-1;for(;++lu&&(u=o):o=1,a=l+t.length,l=r.indexOf(t,a);return u}function WL(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function e8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function t8(e,t,r,l){const a=e8(r),o=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(WL(e,r)){const p=r.enter("codeIndented"),x=r.indentLines(o,n8);return p(),x}const c=r.createTracker(l),d=a.repeat(Math.max(JL(o,a)+1,3)),h=r.enter("codeFenced");let m=c.move(d);if(e.lang){const p=r.enter(`codeFencedLang${u}`);m+=c.move(r.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${u}`);m+=c.move(" "),m+=c.move(r.safe(e.meta,{before:m,after:` +`}),r}function X1(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Q1(e,t){const r=M6(e,t),l=r.one(e,void 0),a=S6(r),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return a&&o.children.push({type:"text",value:` +`},a),o}function H6(e,t){return e&&"run"in e?async function(r,l){const a=Q1(r,{file:l,...t});await e.run(a,l)}:function(r,l){return Q1(r,{file:l,...e||t})}}function Z1(e){if(e)throw e}var Cp,K1;function B6(){if(K1)return Cp;K1=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},o=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var m=e.call(h,"constructor"),p=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!m&&!p)return!1;var x;for(x in h);return typeof x>"u"||e.call(h,x)},u=function(h,m){r&&m.name==="__proto__"?r(h,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):h[m.name]=m.newValue},c=function(h,m){if(m==="__proto__")if(e.call(h,m)){if(l)return l(h,m).value}else return;return h[m]};return Cp=function d(){var h,m,p,x,b,w,E=arguments[0],_=1,S=arguments.length,N=!1;for(typeof E=="boolean"&&(N=E,E=arguments[1]||{},_=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});_u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const m=h;if(c&&r)throw m;return a(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(o,a):d instanceof Error?a(d):o(d))}function a(u,...c){r||(r=!0,t(u,...c))}function o(u){a(null,u)}}const nr={basename:V6,dirname:P6,extname:$6,join:G6,sep:"/"};function V6(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');os(e);let r=0,l=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else l<0&&(o=!0,l=a+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let u=-1,c=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){r=a+1;break}}else u<0&&(o=!0,u=a+1),c>-1&&(e.codePointAt(a)===t.codePointAt(c--)?c<0&&(l=a):(c=-1,l=u));return r===l?l=u:l<0&&(l=e.length),e.slice(r,l)}function P6(e){if(os(e),e.length===0)return".";let t=-1,r=e.length,l;for(;--r;)if(e.codePointAt(r)===47){if(l){t=r;break}}else l||(l=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function $6(e){os(e);let t=e.length,r=-1,l=0,a=-1,o=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){l=t+1;break}continue}r<0&&(u=!0,r=t+1),c===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||r<0||o===0||o===1&&a===r-1&&a===l+1?"":e.slice(a,r)}function G6(...e){let t=-1,r;for(;++t0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function Y6(e,t){let r="",l=0,a=-1,o=0,u=-1,c,d;for(;++u<=e.length;){if(u2){if(d=r.lastIndexOf("/"),d!==r.length-1){d<0?(r="",l=0):(r=r.slice(0,d),l=r.length-1-r.lastIndexOf("/")),a=u,o=0;continue}}else if(r.length>0){r="",l=0,a=u,o=0;continue}}t&&(r=r.length>0?r+"/..":"..",l=2)}else r.length>0?r+="/"+e.slice(a+1,u):r=e.slice(a+1,u),l=u-a-1;a=u,o=0}else c===46&&o>-1?o++:o=-1}return r}function os(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const X6={cwd:Q6};function Q6(){return"/"}function pm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Z6(e){if(typeof e=="string")e=new URL(e);else if(!pm(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return K6(e)}function K6(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const t=e.pathname;let r=-1;for(;++r0){let[b,...w]=m;const E=l[x][1];hm(E)&&hm(b)&&(b=Tp(!0,E,b)),l[x]=[h,b,...w]}}}}const tL=new rg().freeze();function Mp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Dp(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Rp(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function W1(e){if(!hm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function ew(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Yu(e){return nL(e)?e:new pk(e)}function nL(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function rL(e){return typeof e=="string"||iL(e)}function iL(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lL="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",tw=[],nw={allowDangerousHtml:!0},aL=/^(https?|ircs?|mailto|xmpp)$/i,oL=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function $c(e){const t=sL(e),r=uL(e);return cL(t.runSync(t.parse(r),r),e)}function sL(e){const t=e.rehypePlugins||tw,r=e.remarkPlugins||tw,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...nw}:nw;return tL().use(PO).use(r).use(H6,l).use(t)}function uL(e){const t=e.children||"",r=new pk;return typeof t=="string"&&(r.value=t),r}function cL(e,t){const r=t.allowedElements,l=t.allowElement,a=t.components,o=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||fL;for(const m of oL)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+lL+m.id,void 0);return ng(e,h),ND(e,{Fragment:y.Fragment,components:a,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function h(m,p,x){if(m.type==="raw"&&x&&typeof p=="number")return u?x.children.splice(p,1):x.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let b;for(b in kp)if(Object.hasOwn(kp,b)&&Object.hasOwn(m.properties,b)){const w=m.properties[b],E=kp[b];(E===null||E.includes(m.tagName))&&(m.properties[b]=d(String(w||""),b,m))}}if(m.type==="element"){let b=r?!r.includes(m.tagName):o?o.includes(m.tagName):!1;if(!b&&l&&typeof p=="number"&&(b=!l(m,p,x)),b&&x&&typeof p=="number")return c&&m.children?x.children.splice(p,1,...m.children):x.children.splice(p,1),p}}}function fL(e){const t=e.indexOf(":"),r=e.indexOf("?"),l=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||r!==-1&&t>r||l!==-1&&t>l||aL.test(e.slice(0,t))?e:""}function rw(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let l=0,a=r.indexOf(t);for(;a!==-1;)l++,a=r.indexOf(t,a+t.length);return l}function dL(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function hL(e,t,r){const a=Vc((r||{}).ignore||[]),o=pL(t);let u=-1;for(;++u0?{type:"text",value:j}:void 0),j===!1?x.lastIndex=A+1:(w!==A&&N.push({type:"text",value:h.value.slice(w,A)}),Array.isArray(j)?N.push(...j):j&&N.push(j),w=A+k[0].length,S=!0),!x.global)break;k=x.exec(h.value)}return S?(w?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],l=r.indexOf(")");const a=rw(e,"(");let o=rw(e,")");for(;l!==-1&&a>o;)e+=r.slice(0,l+1),r=r.slice(l+1),l=r.indexOf(")"),o++;return[e,r]}function mk(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||rl(r)||Ic(r))&&(!t||r!==47)}gk.peek=HL;function jL(){this.buffer()}function AL(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function zL(){this.buffer()}function ML(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function DL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function RL(e){this.exit(e)}function OL(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Fn(this.sliceSerialize(e)).toLowerCase(),r.label=t}function LL(e){this.exit(e)}function HL(){return"["}function gk(e,t,r,l){const a=r.createTracker(l);let o=a.move("[^");const u=r.enter("footnoteReference"),c=r.enter("reference");return o+=a.move(r.safe(r.associationId(e),{after:"]",before:o})),c(),u(),o+=a.move("]"),o}function BL(){return{enter:{gfmFootnoteCallString:jL,gfmFootnoteCall:AL,gfmFootnoteDefinitionLabelString:zL,gfmFootnoteDefinition:ML},exit:{gfmFootnoteCallString:DL,gfmFootnoteCall:RL,gfmFootnoteDefinitionLabelString:OL,gfmFootnoteDefinition:LL}}}function IL(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:gk},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(l,a,o,u){const c=o.createTracker(u);let d=c.move("[^");const h=o.enter("footnoteDefinition"),m=o.enter("label");return d+=c.move(o.safe(o.associationId(l),{before:d,after:"]"})),m(),d+=c.move("]:"),l.children&&l.children.length>0&&(c.shift(4),d+=c.move((t?` +`:" ")+o.indentLines(o.containerFlow(l,c.current()),t?xk:qL))),h(),d}}function qL(e,t,r){return t===0?e:xk(e,t,r)}function xk(e,t,r){return(r?"":" ")+e}const UL=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];yk.peek=FL;function VL(){return{canContainEols:["delete"],enter:{strikethrough:$L},exit:{strikethrough:GL}}}function PL(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:UL}],handlers:{delete:yk}}}function $L(e){this.enter({type:"delete",children:[]},e)}function GL(e){this.exit(e)}function yk(e,t,r,l){const a=r.createTracker(l),o=r.enter("strikethrough");let u=a.move("~~");return u+=r.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),o(),u}function FL(){return"~"}function YL(e){return e.length}function XL(e,t){const r=t||{},l=(r.align||[]).concat(),a=r.stringLength||YL,o=[],u=[],c=[],d=[];let h=0,m=-1;for(;++mh&&(h=e[m].length);++Sd[S])&&(d[S]=k)}E.push(N)}u[m]=E,c[m]=_}let p=-1;if(typeof l=="object"&&"length"in l)for(;++pd[p]&&(d[p]=N),b[p]=N),x[p]=k}u.splice(1,0,x),c.splice(1,0,b),m=-1;const w=[];for(;++m "),o.shift(2);const u=r.indentLines(r.containerFlow(e,o.current()),KL);return a(),u}function KL(e,t,r){return">"+(r?"":" ")+e}function JL(e,t){return lw(e,t.inConstruct,!0)&&!lw(e,t.notInConstruct,!1)}function lw(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let l=-1;for(;++lu&&(u=o):o=1,a=l+t.length,l=r.indexOf(t,a);return u}function e8(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function t8(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function n8(e,t,r,l){const a=t8(r),o=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(e8(e,r)){const p=r.enter("codeIndented"),x=r.indentLines(o,r8);return p(),x}const c=r.createTracker(l),d=a.repeat(Math.max(WL(o,a)+1,3)),h=r.enter("codeFenced");let m=c.move(d);if(e.lang){const p=r.enter(`codeFencedLang${u}`);m+=c.move(r.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=r.enter(`codeFencedMeta${u}`);m+=c.move(" "),m+=c.move(r.safe(e.meta,{before:m,after:` `,encode:["`"],...c.current()})),p()}return m+=c.move(` `),o&&(m+=c.move(o+` -`)),m+=c.move(d),h(),m}function n8(e,t,r){return(r?"":" ")+e}function ig(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function r8(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("definition");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("[");return h+=d.move(r.safe(r.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":` -`,...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function i8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Xo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function wc(e,t,r){const l=ya(e),a=ya(t);return l===void 0?a===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}vk.peek=l8;function vk(e,t,r,l){const a=i8(r),o=r.enter("emphasis"),u=r.createTracker(l),c=u.move(a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=wc(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=wc(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function l8(e,t,r){return r.options.emphasis||"*"}function a8(e,t){let r=!1;return ng(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return r=!0,fm}),!!((!e.depth||e.depth<3)&&Qm(e)&&(t.options.setext||r))}function o8(e,t,r,l){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(l);if(a8(e,r)){const m=r.enter("headingSetext"),p=r.enter("phrasing"),x=r.containerPhrasing(e,{...o.current(),before:` +`)),m+=c.move(d),h(),m}function r8(e,t,r){return(r?"":" ")+e}function ig(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function i8(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("definition");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("[");return h+=d.move(r.safe(r.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":` +`,...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function l8(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Xo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function wc(e,t,r){const l=ya(e),a=ya(t);return l===void 0?a===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}vk.peek=a8;function vk(e,t,r,l){const a=l8(r),o=r.enter("emphasis"),u=r.createTracker(l),c=u.move(a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=wc(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=wc(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function a8(e,t,r){return r.options.emphasis||"*"}function o8(e,t){let r=!1;return ng(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return r=!0,fm}),!!((!e.depth||e.depth<3)&&Qm(e)&&(t.options.setext||r))}function s8(e,t,r,l){const a=Math.max(Math.min(6,e.depth||1),1),o=r.createTracker(l);if(o8(e,r)){const m=r.enter("headingSetext"),p=r.enter("phrasing"),x=r.containerPhrasing(e,{...o.current(),before:` `,after:` `});return p(),m(),x+` `+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(` `))+1))}const u="#".repeat(a),c=r.enter("headingAtx"),d=r.enter("phrasing");o.move(u+" ");let h=r.containerPhrasing(e,{before:"# ",after:` -`,...o.current()});return/^[\t ]/.test(h)&&(h=Xo(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,r.options.closeAtx&&(h+=" "+u),d(),c(),h}bk.peek=s8;function bk(e){return e.value||""}function s8(){return"<"}wk.peek=u8;function wk(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("image");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("![");return h+=d.move(r.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function u8(){return"!"}Sk.peek=c8;function Sk(e,t,r,l){const a=e.referenceType,o=r.enter("imageReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("![");const h=r.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function c8(){return"!"}_k.peek=f8;function _k(e,t,r){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Ek.peek=d8;function Ek(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.createTracker(l);let c,d;if(kk(e,r)){const m=r.stack;r.stack=[],c=r.enter("autolink");let p=u.move("<");return p+=u.move(r.containerPhrasing(e,{before:p,after:">",...u.current()})),p+=u.move(">"),c(),r.stack=m,p}c=r.enter("link"),d=r.enter("label");let h=u.move("[");return h+=u.move(r.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(r.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=r.enter("destinationRaw"),h+=u.move(r.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=r.enter(`title${o}`),h+=u.move(" "+a),h+=u.move(r.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function d8(e,t,r){return kk(e,r)?"<":"["}Nk.peek=h8;function Nk(e,t,r,l){const a=e.referenceType,o=r.enter("linkReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("[");const h=r.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function h8(){return"["}function lg(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function p8(e){const t=lg(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function m8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ck(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function g8(e,t,r,l){const a=r.enter("list"),o=r.bulletCurrent;let u=e.ordered?m8(r):lg(r);const c=e.ordered?u==="."?")":".":p8(r);let d=t&&r.bulletLastUsed?u===r.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&m&&(!m.children||!m.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(d=!0),Ck(r)===u&&m){let p=-1;for(;++p-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let u=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=r.createTracker(l);c.move(o+" ".repeat(u-o.length)),c.shift(u);const d=r.enter("listItem"),h=r.indentLines(r.containerFlow(e,c.current()),m);return d(),h;function m(p,x,b){return x?(b?"":" ".repeat(u))+p:(b?o:o+" ".repeat(u-o.length))+p}}function v8(e,t,r,l){const a=r.enter("paragraph"),o=r.enter("phrasing"),u=r.containerPhrasing(e,l);return o(),a(),u}const b8=Vc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function w8(e,t,r,l){return(e.children.some(function(u){return b8(u)})?r.containerPhrasing:r.containerFlow).call(r,e,l)}function S8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tk.peek=_8;function Tk(e,t,r,l){const a=S8(r),o=r.enter("strong"),u=r.createTracker(l),c=u.move(a+a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=wc(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=wc(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function _8(e,t,r){return r.options.strong||"*"}function k8(e,t,r,l){return r.safe(e.value,l)}function E8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function N8(e,t,r){const l=(Ck(r)+(r.options.ruleSpaces?" ":"")).repeat(E8(r));return r.options.ruleSpaces?l.slice(0,-1):l}const jk={blockquote:QL,break:aw,code:t8,definition:r8,emphasis:vk,hardBreak:aw,heading:o8,html:bk,image:wk,imageReference:Sk,inlineCode:_k,link:Ek,linkReference:Nk,list:g8,listItem:y8,paragraph:v8,root:w8,strong:Tk,text:k8,thematicBreak:N8};function C8(){return{enter:{table:T8,tableData:ow,tableHeader:ow,tableRow:A8},exit:{codeText:z8,table:j8,tableData:Bp,tableHeader:Bp,tableRow:Bp}}}function T8(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function j8(e){this.exit(e),this.data.inTable=void 0}function A8(e){this.enter({type:"tableRow",children:[]},e)}function Bp(e){this.exit(e)}function ow(e){this.enter({type:"tableCell",children:[]},e)}function z8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,M8));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function M8(e,t){return t==="|"?t:e}function D8(e){const t=e||{},r=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(b,w,k,_){return h(m(b,k,_),b.align)}function c(b,w,k,_){const S=p(b,k,_),C=h([S]);return C.slice(0,C.indexOf(` -`))}function d(b,w,k,_){const S=k.enter("tableCell"),C=k.enter("phrasing"),E=k.containerPhrasing(b,{..._,before:o,after:o});return C(),S(),E}function h(b,w){return YL(b,{align:w,alignDelimiters:l,padding:r,stringLength:a})}function m(b,w,k){const _=b.children;let S=-1;const C=[],E=w.enter("table");for(;++S<_.length;)C[S]=p(_[S],w,k);return E(),C}function p(b,w,k){const _=b.children;let S=-1;const C=[],E=w.enter("tableRow");for(;++S<_.length;)C[S]=d(_[S],b,w,k);return E(),C}function x(b,w,k){let _=jk.inlineCode(b,w,k);return k.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function R8(){return{exit:{taskListCheckValueChecked:sw,taskListCheckValueUnchecked:sw,paragraph:L8}}}function O8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:H8}}}function sw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function L8(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const l=r.children[0];if(l&&l.type==="text"){const a=t.children;let o=-1,u;for(;++o0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const K8={tokenize:l9,partial:!0};function J8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:n9,continuation:{tokenize:r9},exit:i9}},text:{91:{name:"gfmFootnoteCall",tokenize:t9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:W8,resolveTo:e9}}}}function W8(e,t,r){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let u;for(;a--;){const d=l.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return r(d);const h=Fn(l.sliceSerialize({start:u.end,end:l.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?r(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function e9(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[r+1],e[r+2],["enter",l,t],e[r+3],e[r+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",u,t],["exit",u,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(r,e.length-r+1,...c),e}function t9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,u;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),d}function d(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(p){if(o>999||p===93&&!u||p===null||p===91||ot(p))return r(p);if(p===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return ot(p)||(u=!0),o++,e.consume(p),p===92?m:h}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,h):h(p)}}function n9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):r(w)}function m(w){if(u>999||w===93&&!c||w===null||w===91||ot(w))return r(w);if(w===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return o=Fn(l.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return ot(w)||(c=!0),u++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),u++,m):m(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):r(w)}function b(w){return t(w)}}function r9(e,t,r){return e.check(as,t,e.attempt(K8,t,r))}function i9(e){e.exit("gfmFootnoteDefinition")}function l9(e,t,r){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(o):r(o)}}function a9(e){let r=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d1?d(w):(u.consume(w),p++,b);if(p<2&&!r)return d(w);const _=u.exit("strikethroughSequenceTemporary"),S=ya(w);return _._open=!S||S===2&&!!k,_._close=!k||k===2&&!!S,c(w)}}}class o9{constructor(){this.map=[]}add(t,r,l){s9(this,t,r,l)}consume(t){if(this.map.sort(function(o,u){return o[0]-u[0]}),this.map.length===0)return;let r=this.map.length;const l=[];for(;r>0;)r-=1,l.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function s9(e,t,r,l){let a=0;if(!(r===0&&l.length===0)){for(;a-1;){const I=l.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const U=B>-1?l.events[B][1].type:null,ee=U==="tableHead"||U==="tableRow"?j:d;return ee===j&&l.parser.lazy[l.now().line]?r(H):ee(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(u=!0,o+=1),m(H)}function m(H){return H===null?r(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):r(H):qe(H)?Qe(e,m,"whitespace")(H):(o+=1,u&&(u=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),u=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||ot(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?x:p)}function x(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?r(H):(e.enter("tableDelimiterRow"),u=!1,qe(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?_(H):H===124?(u=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),k):M(H)}function k(H){return qe(H)?Qe(e,_,"whitespace")(H):_(H)}function _(H){return H===58?(o+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),S):H===45?(o+=1,S(H)):H===null||Ee(H)?A(H):M(H)}function S(H){return H===45?(e.enter("tableDelimiterFiller"),C(H)):M(H)}function C(H){return H===45?(e.consume(H),C):H===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(H))}function E(H){return qe(H)?Qe(e,A,"whitespace")(H):A(H)}function A(H){return H===124?w(H):H===null||Ee(H)?!u||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return r(H)}function j(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):qe(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),O(H))}function O(H){return H===null||H===124||ot(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?P:O)}function P(H){return H===92||H===124?(e.consume(H),O):O(H)}}function d9(e,t){let r=-1,l=!0,a=0,o=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,m,p;const x=new o9;for(;++rr[2]+1){const w=r[2]+1,k=r[3]-r[2]-1;e.add(w,k,[])}}e.add(r[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ea(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function uw(e,t,r,l,a){const o=[],u=ea(t.events,r);a&&(a.end=Object.assign({},u),o.push(["exit",a,t])),l.end=Object.assign({},u),o.push(["exit",l,t]),e.add(r+1,0,o)}function ea(e,t){const r=e[t],l=r[0]==="enter"?"start":"end";return r[1][l]}const h9={name:"tasklistCheck",tokenize:m9};function p9(){return{text:{91:h9}}}function m9(e,t,r){const l=this;return a;function a(d){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?r(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),o)}function o(d){return ot(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):r(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):r(d)}function c(d){return Ee(d)?t(d):qe(d)?e.check({tokenize:g9},t,r)(d):r(d)}}function g9(e,t,r){return Qe(e,l,"whitespace");function l(a){return a===null?r(a):t(a)}}function x9(e){return X_([V8(),J8(),a9(e),c9(),p9()])}const y9={};function Gc(e){const t=this,r=e||y9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),u=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(x9(r)),o.push(B8()),u.push(I8(r))}const v9=new Set([".md",".markdown",".mdx"]);function b9({filePath:e,onClose:t}){const[r,l]=V.useState(null),[a,o]=V.useState(null),[u,c]=V.useState(!0),d=V.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const x=await p.json();l(x)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);V.useEffect(()=>{d()},[d]),V.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const h=r?v9.has(r.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(xw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),r&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:S9(r.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[u&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ca,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(ww,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),r&&!a&&(h?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(w9,{content:r.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:r.content}))]})]})})}function w9({content:e}){return y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function S9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function _9({node:e}){const t=fe(M=>M.sendGateResponse),r=fe(M=>M.wsStatus),[l,a]=V.useState(null),[o,u]=V.useState(""),[c,d]=V.useState(null),[h,m]=V.useState(!1),[p,x]=V.useState(null),b=e.status==="waiting",w=e.status==="completed";V.useEffect(()=>{b&&(a(null),u(""),d(null),m(!1))},[b]);const k=b&&r==="connected"&&l===null,_=(M,j)=>{if(k){if(j){a(M),d(j);return}a(M),m(!0),t(e.name,M)}},S=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),d(null)},C=e.option_details,E=C==null?void 0:C.find(M=>M.value===e.selected_option),A=(E==null?void 0:E.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!1,onFileClick:x})}),C&&C.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:C.map(M=>{const j=l===M.value,L=l!==null&&!j;return y.jsx("button",{disabled:!k&&!j,onClick:()=>_(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${j?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:j?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${j?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),h&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(ca,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),k&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!C&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>u(M.target.value),onKeyDown:M=>M.key==="Enter"&&S(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(vw,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Yi,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!0,onFileClick:x})}),A&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:A}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),C&&C.length>1&&y.jsx("div",{className:"space-y-1",children:C.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!C&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(E9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!0,onFileClick:x})})]}),p&&y.jsx(b9,{filePath:p,onClose:()=>x(null)})]})}function k9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function Ip({text:e,muted:t,onFileClick:r}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>r&&k9(a)?y.jsxs("button",{onClick:u=>{u.preventDefault(),r(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(xw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function E9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const r=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:r})}return t.length===0?null:y.jsx(sl,{items:t})}function N9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,a=E5()[e.name],o=e.type==="for_each_group",[u,c]=V.useState(!0),d=[];e.elapsed!=null&&d.push({label:"Elapsed",value:Jt(e.elapsed)}),a&&(d.push({label:"Total",value:a.total}),d.push({label:"Completed",value:a.completed}),a.failed>0&&d.push({label:"Failed",value:a.failed})),e.success_count!=null&&d.push({label:"Success",value:e.success_count}),e.failure_count!=null&&d.push({label:"Failures",value:e.failure_count});const h=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(sl,{items:d}),o&&h&&h.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!u),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[u?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Items (",h.length,")"]}),u&&y.jsx("div",{className:"space-y-1",children:h.map(m=>y.jsx(T9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const C9={running:Fe.running,completed:Fe.completed,failed:Fe.failed};function T9({groupName:e,item:t}){const[r,l]=V.useState(t.status==="running"),a=C9[t.status],o=qm(),u=fe(x=>x.navigateIntoSubworkflow),c=`${e}[${t.key}]`,d=o.find(x=>x.slotKey===c),h=!!d,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:Jt(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:$n(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:yi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!r),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?r?y.jsx(il,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(ca,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!r&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:Jt(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:$n(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:yi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),h&&y.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),u(c)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),u(c))},title:`Dive into ${(d==null?void 0:d.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(Sc,{className:"w-3 h-3"})})]}),r&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(sl,{items:p}),t.prompt&&y.jsx(nl,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(nl,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function j9({node:e}){const t=fe(h=>h.engageDialog),r=fe(h=>h.sendDialogDecline),l=fe(h=>h.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],u=l==="connected",c=o.find(h=>h.role==="agent"),d=()=>{u&&r(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx($c,{remarkPlugins:[Gc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(gm,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:d,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ll,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function A9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=fe(c=>c.navigateIntoSubworkflow),o=qm().filter(c=>c.parentAgent===e.name),u=[];return e.elapsed!=null&&u.push({label:"Elapsed",value:Jt(e.elapsed)}),e.cost_usd!=null&&u.push({label:"Cost",value:yi(e.cost_usd)}),e.tokens!=null&&u.push({label:"Tokens",value:$n(e.tokens)}),e.iteration!=null&&e.iteration>1&&u.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(sl,{items:u}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,d)=>y.jsx(z9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${d}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function z9({ctx:e,onClick:t}){const r=Fe[e.status]||Fe.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(Sc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:r}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(yw,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(mw,{className:"w-2.5 h-2.5"}),yi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${r}20`,color:r},children:e.status}),y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function M9(){const e=fe(d=>d.selectedNode),t=ol(),r=fe(d=>d.selectNode),l=fe(d=>d.dialogEngaged),[a,o]=V.useState(!1);V.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const u=e?t[e]:null;if(!e||!u)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(u.dialog_active&&!l)return j9;if(u.dialog_active&&l)return v1;switch(u.type){case"script":return Z4;case"human_gate":return _9;case"parallel_group":case"for_each_group":return N9;case"workflow":return A9;default:return v1}})();return y.jsxs("div",{className:He("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>r(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:u})})]})}function rc(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function D9(){const e=fe(_=>_.eventLog),t=fe(_=>_.activityLog),r=fe(_=>_.workflowOutput),l=fe(_=>_.workflowStatus),[a,o]=V.useState("log"),[u,c]=V.useState(!1),[d,h]=V.useState(0),[m,p]=V.useState(0),x=V.useCallback(_=>{o(_),_==="log"&&h(e.length),_==="activity"&&p(t.length)},[e.length,t.length]);V.useEffect(()=>{a==="log"&&h(e.length)},[a,e.length]),V.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),V.useEffect(()=>{l==="completed"&&r!=null&&o("output")},[l,r]);const b=r!=null,w=a!=="log"?Math.max(0,e.length-d):0,k=a!=="activity"?Math.max(0,t.length-m):0;return u?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(uN,{className:"w-3 h-3"}),y.jsx(Wy,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(qp,{active:a==="log",onClick:()=>x("log"),icon:y.jsx(Wy,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx(qp,{active:a==="activity",onClick:()=>x("activity"),icon:y.jsx(pw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:k}),y.jsx(qp,{active:a==="output",onClick:()=>x("output"),icon:y.jsx(mN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(il,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(R9,{entries:t}):a==="log"?y.jsx(O9,{entries:e}):y.jsx(L9,{output:r,status:l})})]})}function qp({active:e,onClick:t,icon:r,label:l,count:a,badge:o,unread:u}){return y.jsxs("button",{onClick:t,className:He("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[r,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:He("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&u!=null&&u>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:u>99?"99+":u})})]})}const cw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function R9({entries:e}){const t=V.useRef(null),r=V.useRef(!0),l=fe(d=>d.selectNode),[a,o]=V.useState(""),u=V.useCallback(()=>{const d=t.current;if(!d)return;const h=d.scrollHeight-d.scrollTop-d.clientHeight<30;r.current=h},[]),c=V.useMemo(()=>{if(!a)return e;const d=a.toLowerCase();return e.filter(h=>h.source.toLowerCase().includes(d)||rc(h.message).toLowerCase().includes(d))},[e,a]);return V.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(bN,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:d=>o(d.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(ll,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:u,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((d,h)=>{const m=cw[d.type]||cw.message,p=Bk(d.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:He("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(d.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${d.source}`,children:d.source}),y.jsx("span",{className:He("break-words min-w-0",m.color,d.type==="reasoning"&&"italic"),children:rc(d.message)})]}),d.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:rc(d.detail)})]},h)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const fw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function O9({entries:e}){const t=V.useRef(null),r=V.useRef(!0),l=fe(o=>o.selectNode),a=V.useCallback(()=>{const o=t.current;if(!o)return;const u=o.scrollHeight-o.scrollTop-o.clientHeight<30;r.current=u},[]);return V.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,u)=>{const c=fw[o.level]||fw.info,d=Bk(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:d}),y.jsx("span",{className:He("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:He("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:rc(o.message)})]},u)})})}function Bk(e){const t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${r}:${l}:${a}`}function L9({output:e,status:t}){const[r,l]=V.useState(!1),a=Sw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:r?y.jsxs(y.Fragment,{children:[y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(gw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(H9,{text:a}):a})})]})}function H9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function B9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function I9({node:e}){const t=fe(x=>x.sendDialogMessage),r=fe(x=>x.wsStatus),[l,a]=V.useState(""),o=V.useRef(null),u=e.dialog_active===!0,c=e.dialog_id||"",d=e.dialog_messages||[],h=u&&r==="connected";V.useEffect(()=>{var x;(x=o.current)==null||x.scrollIntoView({behavior:"smooth"})},[d.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!h||(t(e.name,c,l.trim()),a(""))},p=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[u?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(gm,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[d.map((x,b)=>y.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${x.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:x.role==="agent"?e.name:"You"}),y.jsx(B9,{text:x.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),u&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:x=>a(x.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!h,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!h||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(vw,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function q9(){const e=fe(l=>l.activeDialog),t=fe(l=>l.nodes);if(!e)return null;const r=t[e.agentName];return r?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(gm,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx(I9,{node:r})})]}):null}function U9(){const e=fe(l=>l.selectedNode),t=fe(l=>l.activeDialog),r=fe(l=>l.dialogEngaged);return y.jsxs(Vp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(Eo,{defaultSize:70,minSize:30,children:y.jsxs(Vp,{direction:"horizontal",className:"h-full",children:[y.jsx(Eo,{defaultSize:e?65:100,minSize:40,children:t&&r?y.jsx(q9,{}):y.jsx(V4,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Pp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(Eo,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(M9,{})})]})]})}),y.jsx(Pp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(Eo,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(D9,{})})]})}const V9=3e4;function P9(){const e=fe(p=>p.processEvent),t=fe(p=>p.replayState),r=fe(p=>p.setWsStatus),l=fe(p=>p.setWsSend),a=V.useRef(null),o=V.useRef(1e3),u=V.useRef(null),c=V.useRef(null),d=V.useRef(()=>{}),h=V.useCallback(()=>{r("reconnecting"),u.current=setTimeout(()=>{o.current=Math.min(o.current*2,V9),d.current()},o.current)},[r]),m=V.useCallback(()=>{r("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(x=>x.json()).then(x=>{x&&x.length>0&&t(x);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const k=new WebSocket(w);a.current=k,k.onopen=()=>{o.current=1e3,r("connected"),l(_=>{k.readyState===WebSocket.OPEN&&k.send(JSON.stringify(_))})},k.onmessage=_=>{try{const S=JSON.parse(_.data);e(S)}catch(S){console.error("Failed to parse WebSocket message:",S)}},k.onclose=()=>{r("disconnected"),l(null),a.current=null,h()},k.onerror=()=>{}}catch{h()}}).catch(x=>{p.signal.aborted||(console.error("Failed to fetch state:",x),h())})},[e,t,r,l,h]);d.current=m,V.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),u.current&&clearTimeout(u.current),a.current&&a.current.close(),l(null)}),[m,l])}function $9(){const e=fe(h=>h.setReplayMode),t=fe(h=>h.setWsStatus),r=fe(h=>h.replayPlaying),l=fe(h=>h.replayPosition),a=fe(h=>h.replayTotalEvents),o=fe(h=>h.replaySpeed),u=fe(h=>h.replayEvents),c=fe(h=>h.setReplayPosition);V.useEffect(()=>{t("connecting"),fetch("/api/state").then(h=>h.json()).then(h=>{e(h),t("connected")}).catch(h=>{console.error("Failed to load replay events:",h),t("disconnected")})},[e,t]);const d=V.useRef(null);V.useEffect(()=>{if(!r||l>=a){d.current&&clearTimeout(d.current),r&&l>=a&&fe.getState().setReplayPlaying(!1);return}const h=u[l-1],m=u[l];let p=100;if(h&&m){const x=(m.timestamp-h.timestamp)*1e3;p=Math.max(16,Math.min(x/o,2e3))}return d.current=setTimeout(()=>{c(l+1)},p),()=>{d.current&&clearTimeout(d.current)}},[r,l,a,o,u,c])}function G9(){return P9(),null}function F9(){return $9(),null}function Y9(){const[e,t]=V.useState(null),r=fe(o=>o.replayMode),l=fe(o=>o.selectNode),a=fe(o=>o.workflowName);return V.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),V.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),V.useEffect(()=>{const o=u=>{u.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(F9,{}):y.jsx(G9,{}),y.jsx(ON,{}),y.jsx(LN,{}),y.jsx(U9,{}),r?y.jsx(UN,{}):y.jsx(BN,{})]})}nN.createRoot(document.getElementById("root")).render(y.jsx(V.StrictMode,{children:y.jsx(Y9,{})})); +`,...o.current()});return/^[\t ]/.test(h)&&(h=Xo(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,r.options.closeAtx&&(h+=" "+u),d(),c(),h}bk.peek=u8;function bk(e){return e.value||""}function u8(){return"<"}wk.peek=c8;function wk(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.enter("image");let c=r.enter("label");const d=r.createTracker(l);let h=d.move("![");return h+=d.move(r.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=r.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(r.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=r.enter("destinationRaw"),h+=d.move(r.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=r.enter(`title${o}`),h+=d.move(" "+a),h+=d.move(r.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function c8(){return"!"}Sk.peek=f8;function Sk(e,t,r,l){const a=e.referenceType,o=r.enter("imageReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("![");const h=r.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function f8(){return"!"}_k.peek=d8;function _k(e,t,r){let l=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(l);)a+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++o\u007F]/.test(e.url))}Ek.peek=h8;function Ek(e,t,r,l){const a=ig(r),o=a==='"'?"Quote":"Apostrophe",u=r.createTracker(l);let c,d;if(kk(e,r)){const m=r.stack;r.stack=[],c=r.enter("autolink");let p=u.move("<");return p+=u.move(r.containerPhrasing(e,{before:p,after:">",...u.current()})),p+=u.move(">"),c(),r.stack=m,p}c=r.enter("link"),d=r.enter("label");let h=u.move("[");return h+=u.move(r.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=r.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(r.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=r.enter("destinationRaw"),h+=u.move(r.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=r.enter(`title${o}`),h+=u.move(" "+a),h+=u.move(r.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function h8(e,t,r){return kk(e,r)?"<":"["}Nk.peek=p8;function Nk(e,t,r,l){const a=e.referenceType,o=r.enter("linkReference");let u=r.enter("label");const c=r.createTracker(l);let d=c.move("[");const h=r.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),u();const m=r.stack;r.stack=[],u=r.enter("reference");const p=r.safe(r.associationId(e),{before:d,after:"]",...c.current()});return u(),r.stack=m,o(),a==="full"||!h||h!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function p8(){return"["}function lg(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function m8(e){const t=lg(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function g8(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ck(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function x8(e,t,r,l){const a=r.enter("list"),o=r.bulletCurrent;let u=e.ordered?g8(r):lg(r);const c=e.ordered?u==="."?")":".":m8(r);let d=t&&r.bulletLastUsed?u===r.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&m&&(!m.children||!m.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(d=!0),Ck(r)===u&&m){let p=-1;for(;++p-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let u=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(u=Math.ceil(u/4)*4);const c=r.createTracker(l);c.move(o+" ".repeat(u-o.length)),c.shift(u);const d=r.enter("listItem"),h=r.indentLines(r.containerFlow(e,c.current()),m);return d(),h;function m(p,x,b){return x?(b?"":" ".repeat(u))+p:(b?o:o+" ".repeat(u-o.length))+p}}function b8(e,t,r,l){const a=r.enter("paragraph"),o=r.enter("phrasing"),u=r.containerPhrasing(e,l);return o(),a(),u}const w8=Vc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function S8(e,t,r,l){return(e.children.some(function(u){return w8(u)})?r.containerPhrasing:r.containerFlow).call(r,e,l)}function _8(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Tk.peek=k8;function Tk(e,t,r,l){const a=_8(r),o=r.enter("strong"),u=r.createTracker(l),c=u.move(a+a);let d=u.move(r.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),m=wc(l.before.charCodeAt(l.before.length-1),h,a);m.inside&&(d=Xo(h)+d.slice(1));const p=d.charCodeAt(d.length-1),x=wc(l.after.charCodeAt(0),p,a);x.inside&&(d=d.slice(0,-1)+Xo(p));const b=u.move(a+a);return o(),r.attentionEncodeSurroundingInfo={after:x.outside,before:m.outside},c+d+b}function k8(e,t,r){return r.options.strong||"*"}function E8(e,t,r,l){return r.safe(e.value,l)}function N8(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function C8(e,t,r){const l=(Ck(r)+(r.options.ruleSpaces?" ":"")).repeat(N8(r));return r.options.ruleSpaces?l.slice(0,-1):l}const jk={blockquote:ZL,break:aw,code:n8,definition:i8,emphasis:vk,hardBreak:aw,heading:s8,html:bk,image:wk,imageReference:Sk,inlineCode:_k,link:Ek,linkReference:Nk,list:x8,listItem:v8,paragraph:b8,root:S8,strong:Tk,text:E8,thematicBreak:C8};function T8(){return{enter:{table:j8,tableData:ow,tableHeader:ow,tableRow:z8},exit:{codeText:M8,table:A8,tableData:Bp,tableHeader:Bp,tableRow:Bp}}}function j8(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function A8(e){this.exit(e),this.data.inTable=void 0}function z8(e){this.enter({type:"tableRow",children:[]},e)}function Bp(e){this.exit(e)}function ow(e){this.enter({type:"tableCell",children:[]},e)}function M8(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,D8));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function D8(e,t){return t==="|"?t:e}function R8(e){const t=e||{},r=t.tableCellPadding,l=t.tablePipeAlign,a=t.stringLength,o=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:d,tableRow:c}};function u(b,w,E,_){return h(m(b,E,_),b.align)}function c(b,w,E,_){const S=p(b,E,_),N=h([S]);return N.slice(0,N.indexOf(` +`))}function d(b,w,E,_){const S=E.enter("tableCell"),N=E.enter("phrasing"),k=E.containerPhrasing(b,{..._,before:o,after:o});return N(),S(),k}function h(b,w){return XL(b,{align:w,alignDelimiters:l,padding:r,stringLength:a})}function m(b,w,E){const _=b.children;let S=-1;const N=[],k=w.enter("table");for(;++S<_.length;)N[S]=p(_[S],w,E);return k(),N}function p(b,w,E){const _=b.children;let S=-1;const N=[],k=w.enter("tableRow");for(;++S<_.length;)N[S]=d(_[S],b,w,E);return k(),N}function x(b,w,E){let _=jk.inlineCode(b,w,E);return E.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function O8(){return{exit:{taskListCheckValueChecked:sw,taskListCheckValueUnchecked:sw,paragraph:H8}}}function L8(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:B8}}}function sw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function H8(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const l=r.children[0];if(l&&l.type==="text"){const a=t.children;let o=-1,u;for(;++o0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const J8={tokenize:a9,partial:!0};function W8(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:r9,continuation:{tokenize:i9},exit:l9}},text:{91:{name:"gfmFootnoteCall",tokenize:n9},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:e9,resolveTo:t9}}}}function e9(e,t,r){const l=this;let a=l.events.length;const o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let u;for(;a--;){const d=l.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return r(d);const h=Fn(l.sliceSerialize({start:u.end,end:l.now()}));return h.codePointAt(0)!==94||!o.includes(h.slice(1))?r(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function t9(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[r+1],e[r+2],["enter",l,t],e[r+3],e[r+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",u,t],["exit",u,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",l,t]];return e.splice(r,e.length-r+1,...c),e}function n9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o=0,u;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),d}function d(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(p){if(o>999||p===93&&!u||p===null||p===91||ot(p))return r(p);if(p===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Fn(l.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return ot(p)||(u=!0),o++,e.consume(p),p===92?m:h}function m(p){return p===91||p===92||p===93?(e.consume(p),o++,h):h(p)}}function r9(e,t,r){const l=this,a=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let o,u=0,c;return d;function d(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):r(w)}function m(w){if(u>999||w===93&&!c||w===null||w===91||ot(w))return r(w);if(w===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return o=Fn(l.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return ot(w)||(c=!0),u++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),u++,m):m(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(o)||a.push(o),Qe(e,b,"gfmFootnoteDefinitionWhitespace")):r(w)}function b(w){return t(w)}}function i9(e,t,r){return e.check(as,t,e.attempt(J8,t,r))}function l9(e){e.exit("gfmFootnoteDefinition")}function a9(e,t,r){const l=this;return Qe(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const u=l.events[l.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(o):r(o)}}function o9(e){let r=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:o,resolveAll:a};return r==null&&(r=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function a(u,c){let d=-1;for(;++d1?d(w):(u.consume(w),p++,b);if(p<2&&!r)return d(w);const _=u.exit("strikethroughSequenceTemporary"),S=ya(w);return _._open=!S||S===2&&!!E,_._close=!E||E===2&&!!S,c(w)}}}class s9{constructor(){this.map=[]}add(t,r,l){u9(this,t,r,l)}consume(t){if(this.map.sort(function(o,u){return o[0]-u[0]}),this.map.length===0)return;let r=this.map.length;const l=[];for(;r>0;)r-=1,l.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];l.push(t.slice()),t.length=0;let a=l.pop();for(;a;){for(const o of a)t.push(o);a=l.pop()}this.map.length=0}}function u9(e,t,r,l){let a=0;if(!(r===0&&l.length===0)){for(;a-1;){const I=l.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const U=B>-1?l.events[B][1].type:null,ee=U==="tableHead"||U==="tableRow"?j:d;return ee===j&&l.parser.lazy[l.now().line]?r(H):ee(H)}function d(H){return e.enter("tableHead"),e.enter("tableRow"),h(H)}function h(H){return H===124||(u=!0,o+=1),m(H)}function m(H){return H===null?r(H):Ee(H)?o>1?(o=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),b):r(H):qe(H)?Qe(e,m,"whitespace")(H):(o+=1,u&&(u=!1,a+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),u=!0,m):(e.enter("data"),p(H)))}function p(H){return H===null||H===124||ot(H)?(e.exit("data"),m(H)):(e.consume(H),H===92?x:p)}function x(H){return H===92||H===124?(e.consume(H),p):p(H)}function b(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?r(H):(e.enter("tableDelimiterRow"),u=!1,qe(H)?Qe(e,w,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):w(H))}function w(H){return H===45||H===58?_(H):H===124?(u=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),E):M(H)}function E(H){return qe(H)?Qe(e,_,"whitespace")(H):_(H)}function _(H){return H===58?(o+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),S):H===45?(o+=1,S(H)):H===null||Ee(H)?A(H):M(H)}function S(H){return H===45?(e.enter("tableDelimiterFiller"),N(H)):M(H)}function N(H){return H===45?(e.consume(H),N):H===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(H))}function k(H){return qe(H)?Qe(e,A,"whitespace")(H):A(H)}function A(H){return H===124?w(H):H===null||Ee(H)?!u||a!==o?M(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(H)):M(H)}function M(H){return r(H)}function j(H){return e.enter("tableRow"),L(H)}function L(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),L):H===null||Ee(H)?(e.exit("tableRow"),t(H)):qe(H)?Qe(e,L,"whitespace")(H):(e.enter("data"),R(H))}function R(H){return H===null||H===124||ot(H)?(e.exit("data"),L(H)):(e.consume(H),H===92?V:R)}function V(H){return H===92||H===124?(e.consume(H),R):R(H)}}function h9(e,t){let r=-1,l=!0,a=0,o=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,m,p;const x=new s9;for(;++rr[2]+1){const w=r[2]+1,E=r[3]-r[2]-1;e.add(w,E,[])}}e.add(r[3]+1,0,[["exit",p,t]])}return a!==void 0&&(o.end=Object.assign({},ea(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function uw(e,t,r,l,a){const o=[],u=ea(t.events,r);a&&(a.end=Object.assign({},u),o.push(["exit",a,t])),l.end=Object.assign({},u),o.push(["exit",l,t]),e.add(r+1,0,o)}function ea(e,t){const r=e[t],l=r[0]==="enter"?"start":"end";return r[1][l]}const p9={name:"tasklistCheck",tokenize:g9};function m9(){return{text:{91:p9}}}function g9(e,t,r){const l=this;return a;function a(d){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?r(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),o)}function o(d){return ot(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):r(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):r(d)}function c(d){return Ee(d)?t(d):qe(d)?e.check({tokenize:x9},t,r)(d):r(d)}}function x9(e,t,r){return Qe(e,l,"whitespace");function l(a){return a===null?r(a):t(a)}}function y9(e){return X_([P8(),W8(),o9(e),f9(),m9()])}const v9={};function Gc(e){const t=this,r=e||v9,l=t.data(),a=l.micromarkExtensions||(l.micromarkExtensions=[]),o=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),u=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);a.push(y9(r)),o.push(I8()),u.push(q8(r))}const b9=new Set([".md",".markdown",".mdx"]);function w9({filePath:e,onClose:t}){const[r,l]=P.useState(null),[a,o]=P.useState(null),[u,c]=P.useState(!0),d=P.useCallback(async()=>{c(!0),o(null);try{const m=e.split("/").map(b=>encodeURIComponent(b)).join("/"),p=await fetch(`/api/files/${m}`);if(!p.ok){const b=await p.json().catch(()=>({}));o(b.error||`HTTP ${p.status}`);return}const x=await p.json();l(x)}catch(m){o(m instanceof Error?m.message:"Failed to load file")}finally{c(!1)}},[e]);P.useEffect(()=>{d()},[d]),P.useEffect(()=>{const m=p=>{p.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const h=r?b9.has(r.extension):!1;return y.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:y.jsxs("div",{className:"relative flex flex-col w-[90vw] max-w-3xl max-h-[80vh] rounded-xl border border-[var(--border)] bg-[var(--surface)] shadow-2xl overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-[var(--border)] bg-[var(--surface-raised)] flex-shrink-0",children:[y.jsx(xw,{className:"w-4 h-4 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1",title:e,children:e}),r&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0 tabular-nums",children:_9(r.size)}),y.jsx("button",{onClick:t,className:"p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors flex-shrink-0",title:"Close (Esc)",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 min-h-0",children:[u&&y.jsx("div",{className:"flex items-center justify-center py-12",children:y.jsx(ca,{className:"w-5 h-5 text-[var(--text-muted)] animate-spin"})}),a&&y.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30",children:[y.jsx(ww,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs text-red-300",children:a})]}),r&&!a&&(h?y.jsx("div",{className:"file-viewer-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx(S9,{content:r.content})}):y.jsx("pre",{className:"font-mono text-[11px] leading-[1.6] text-[var(--text)] whitespace-pre-wrap break-words",children:r.content}))]})]})})}function S9({content:e}){return y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-base font-bold mb-3 mt-2 text-[var(--text)]",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 text-[var(--text)]",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-bold mb-1.5 mt-2 text-[var(--text)]",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-2 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1 ml-2",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1 ml-2",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-2 font-mono text-[11px] my-2 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-3 py-2.5 font-mono text-[11px] my-2 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-3 my-2 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-3"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})}function _9(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function k9({node:e}){const t=fe(M=>M.sendGateResponse),r=fe(M=>M.wsStatus),[l,a]=P.useState(null),[o,u]=P.useState(""),[c,d]=P.useState(null),[h,m]=P.useState(!1),[p,x]=P.useState(null),b=e.status==="waiting",w=e.status==="completed";P.useEffect(()=>{b&&(a(null),u(""),d(null),m(!1))},[b]);const E=b&&r==="connected"&&l===null,_=(M,j)=>{if(E){if(j){a(M),d(j);return}a(M),m(!0),t(e.name,M)}},S=()=>{if(l===null||c===null)return;const M={[c]:o};m(!0),t(e.name,l,M),d(null)},N=e.option_details,k=N==null?void 0:N.find(M=>M.value===e.selected_option),A=(k==null?void 0:k.label)||e.selected_option;return y.jsxs("div",{className:"space-y-3",children:[b&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-amber-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-amber-400 tracking-wide",children:"Decision Required"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-amber-500/50 pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!1,onFileClick:x})}),N&&N.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"flex flex-col gap-1.5",children:N.map(M=>{const j=l===M.value,L=l!==null&&!j;return y.jsx("button",{disabled:!E&&!j,onClick:()=>_(M.value,M.prompt_for),className:`w-full text-left px-3 py-2.5 rounded-lg border transition-all duration-150 ${j?"border-green-500/60 bg-green-500/10":L?"border-[var(--border)] opacity-40 cursor-default":"border-[var(--border)] bg-[var(--surface)] hover:border-amber-400/60 hover:bg-amber-500/5 cursor-pointer group"}`,children:y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("div",{className:"flex-shrink-0",children:j?y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}):y.jsx("div",{className:`w-4 h-4 rounded-full border-2 transition-colors ${L?"border-[var(--border)]":"border-[var(--border)] group-hover:border-amber-400"}`})}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-xs font-medium ${j?"text-green-400":"text-[var(--text)]"}`,children:M.label})}),M.route&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] flex-shrink-0",children:["→ ",M.route]})]})},M.value)})}),h&&!c&&y.jsxs("div",{className:"flex items-center gap-2 px-1",children:[y.jsx(ca,{className:"w-3 h-3 text-green-400 animate-spin"}),y.jsx("span",{className:"text-[10px] text-green-400",children:"Sending..."})]}),E&&y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] px-1",children:"Select an option to continue the workflow"})]}),!N&&e.options&&e.options.length>0&&y.jsxs("div",{className:"space-y-1.5",children:[y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"Options"}),y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded border border-[var(--border)] text-[var(--text-muted)]",children:M},M))})]}),c&&y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--bg)] overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:y.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:c})}),y.jsxs("div",{className:"p-3 space-y-2",children:[y.jsx("input",{type:"text",value:o,onChange:M=>u(M.target.value),onKeyDown:M=>M.key==="Enter"&&S(),placeholder:`Enter ${c}...`,className:"w-full text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-amber-400 transition-colors",autoFocus:!0}),y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:"Press Enter or click Submit"}),y.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg bg-amber-500 text-white hover:bg-amber-600 transition-colors font-medium",children:[y.jsx(vw,{className:"w-3 h-3"}),"Submit"]})]})]})]})]}),w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-green-500/10 border border-green-500/30",children:[y.jsx(Yi,{className:"w-3.5 h-3.5 text-green-400 flex-shrink-0"}),y.jsx("span",{className:"text-xs font-semibold text-green-400 tracking-wide",children:"Decision Completed"})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!0,onFileClick:x})}),A&&y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-green-500/30 bg-green-500/5",children:[y.jsx("div",{className:"w-4 h-4 rounded-full bg-green-500 flex items-center justify-center flex-shrink-0",children:y.jsx(Yi,{className:"w-2.5 h-2.5 text-white",strokeWidth:3})}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)]",children:A}),e.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",e.route]})]}),N&&N.length>1&&y.jsx("div",{className:"space-y-1",children:N.filter(M=>M.value!==e.selected_option).map(M=>y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg opacity-35",children:[y.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[var(--border)] flex-shrink-0"}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:M.label}),M.route&&y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:["→ ",M.route]})]},M.value))}),!N&&e.options&&e.options.length>0&&y.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.options.map(M=>y.jsxs("span",{className:`text-[11px] px-2.5 py-1 rounded-lg border ${M===e.selected_option?"border-green-500/30 text-green-400 bg-green-500/5":"border-[var(--border)] text-[var(--text-muted)] opacity-40"}`,children:[M===e.selected_option&&"✓ ",M]},M))}),y.jsx(N9,{node:e})]}),!b&&!w&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Human Gate"}),y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] capitalize",children:["(",e.status,")"]})]}),e.prompt&&y.jsx("div",{className:"border-l-2 border-[var(--border)] pl-3 py-0.5",children:y.jsx(Ip,{text:e.prompt,muted:!0,onFileClick:x})})]}),p&&y.jsx(w9,{filePath:p,onClose:()=>x(null)})]})}function E9(e){return!(!e||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith("//")||e.startsWith("#")||e.startsWith("/")||e.startsWith("\\"))}function Ip({text:e,muted:t,onFileClick:r}){const l=t?"text-[var(--text-muted)]":"text-[var(--text)]";return y.jsx("div",{className:`gate-markdown text-xs leading-relaxed ${l}`,children:y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:a})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:a}),h2:({children:a})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:a}),h3:({children:a})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:a}),p:({children:a})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:a}),ul:({children:a})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a}),ol:({children:a})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a}),li:({children:a})=>y.jsx("li",{children:a}),code:({children:a,className:o})=>(o==null?void 0:o.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:a}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:a}),pre:({children:a})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:a}),strong:({children:a})=>y.jsx("strong",{className:"font-semibold",children:a}),em:({children:a})=>y.jsx("em",{className:"italic",children:a}),a:({href:a,children:o})=>r&&E9(a)?y.jsxs("button",{onClick:u=>{u.preventDefault(),r(a)},className:"inline-flex items-center gap-0.5 text-blue-400 hover:text-blue-300 underline underline-offset-2 cursor-pointer",title:`Open ${a}`,children:[y.jsx(xw,{className:"w-3 h-3 inline flex-shrink-0"}),o]}):y.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:o}),blockquote:({children:a})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:a}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:a})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:a})}),th:({children:a})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:a}),td:({children:a})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:a})},children:e})})}function N9({node:e}){const t=[];if(e.route&&t.push({label:"Route",value:`→ ${e.route}`}),e.additional_input){const r=typeof e.additional_input=="object"?JSON.stringify(e.additional_input):e.additional_input;t.push({label:"Additional Input",value:r})}return t.length===0?null:y.jsx(sl,{items:t})}function C9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,a=E5()[e.name],o=e.type==="for_each_group",[u,c]=P.useState(!0),d=[];e.elapsed!=null&&d.push({label:"Elapsed",value:Jt(e.elapsed)}),a&&(d.push({label:"Total",value:a.total}),d.push({label:"Completed",value:a.completed}),a.failed>0&&d.push({label:"Failed",value:a.failed})),e.success_count!=null&&d.push({label:"Success",value:e.success_count}),e.failure_count!=null&&d.push({label:"Failures",value:e.failure_count});const h=e.for_each_items;return y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:o?"For-Each Group":"Parallel Group"})]}),a&&a.total>0&&y.jsxs("div",{className:"space-y-1",children:[y.jsxs("div",{className:"flex justify-between text-[10px] text-[var(--text-muted)]",children:[y.jsx("span",{children:"Progress"}),y.jsxs("span",{children:[a.completed+a.failed,"/",a.total]})]}),y.jsx("div",{className:"h-1.5 bg-[var(--bg)] rounded-full overflow-hidden",children:y.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${(a.completed+a.failed)/a.total*100}%`,background:a.failed>0?`linear-gradient(90deg, var(--completed) ${a.completed/(a.completed+a.failed)*100}%, var(--failed) 0%)`:"var(--completed)"}})})]}),y.jsx(sl,{items:d}),o&&h&&h.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("button",{onClick:()=>c(!u),className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold hover:text-[var(--text)] transition-colors",children:[u?y.jsx(il,{className:"w-3 h-3"}):y.jsx(Rr,{className:"w-3 h-3"}),"Items (",h.length,")"]}),u&&y.jsx("div",{className:"space-y-1",children:h.map(m=>y.jsx(j9,{groupName:e.name,item:m},`${m.key}-${m.index}`))})]})]})}const T9={running:Fe.running,completed:Fe.completed,failed:Fe.failed};function j9({groupName:e,item:t}){const[r,l]=P.useState(t.status==="running"),a=T9[t.status],o=qm(),u=fe(x=>x.navigateIntoSubworkflow),c=`${e}[${t.key}]`,d=o.find(x=>x.slotKey===c),h=!!d,m=!!(t.prompt||t.output!=null||t.activity&&t.activity.length>0||t.error_type),p=[];return t.elapsed!=null&&p.push({label:"Elapsed",value:Jt(t.elapsed)}),t.tokens!=null&&p.push({label:"Tokens",value:$n(t.tokens)}),t.cost_usd!=null&&p.push({label:"Cost",value:yi(t.cost_usd)}),y.jsxs("div",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[y.jsxs("button",{onClick:()=>m&&l(!r),className:"flex items-center gap-2 w-full px-3 py-2 text-left hover:bg-[var(--node-bg)] transition-colors",disabled:!m,children:[m?r?y.jsx(il,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):y.jsx(Rr,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}):t.status==="running"?y.jsx(ca,{className:"w-3 h-3 animate-spin flex-shrink-0",style:{color:a}}):y.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ml-0.5 mr-0.5",style:{backgroundColor:a}}),y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate flex-1 min-w-0",children:t.key}),!r&&(t.elapsed!=null||t.tokens!=null||t.cost_usd!=null)&&y.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)] flex-shrink-0",children:[t.elapsed!=null&&y.jsx("span",{children:Jt(t.elapsed)}),t.tokens!=null&&y.jsx("span",{children:$n(t.tokens)}),t.cost_usd!=null&&y.jsx("span",{children:yi(t.cost_usd)})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${a}20`,color:a},children:t.status}),h&&y.jsx("span",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),u(c)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),u(c))},title:`Dive into ${(d==null?void 0:d.workflowName)??c}`,className:"flex-shrink-0 p-1 rounded hover:bg-[var(--accent)]/20 hover:text-[var(--accent)] transition-colors text-[var(--text-muted)] cursor-pointer",children:y.jsx(Sc,{className:"w-3 h-3"})})]}),r&&m&&y.jsxs("div",{className:"px-3 py-3 space-y-3 border-t border-[var(--border)]",children:[p.length>0&&y.jsx(sl,{items:p}),t.prompt&&y.jsx(nl,{output:t.prompt,title:"Input / Prompt",defaultExpanded:!1}),t.activity&&t.activity.length>0&&y.jsx(Vm,{activity:t.activity,defaultExpanded:t.status!=="completed"}),t.output!=null&&y.jsx(nl,{output:t.output,title:"Output",defaultExpanded:!0}),t.status==="failed"&&(t.error_type||t.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[t.error_type&&y.jsx("span",{className:"font-semibold",children:t.error_type}),t.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",t.error_message]})]})]})]})}function A9({node:e}){const t=fe(h=>h.engageDialog),r=fe(h=>h.sendDialogDecline),l=fe(h=>h.wsStatus),a=e.dialog_id||"",o=e.dialog_messages||[],u=l==="connected",c=o.find(h=>h.role==="agent"),d=()=>{u&&r(e.name,a)};return y.jsxs("div",{className:"flex flex-col gap-4",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Requested"})]}),c&&y.jsxs("div",{className:"rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx($c,{remarkPlugins:[Gc],children:c.content})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:"How would you like to proceed?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsxs("button",{onClick:t,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-fuchsia-500/40 bg-fuchsia-500/10 text-fuchsia-300 hover:bg-fuchsia-500/20 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(gm,{className:"w-3 h-3"}),"💬 Discuss"]}),y.jsxs("button",{onClick:d,disabled:!u,className:"flex-1 flex items-center justify-center gap-1.5 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(ll,{className:"w-3 h-3"}),"✕ Skip & continue"]})]})]})]})}function z9({node:e}){const t=e.status,r=Fe[t]||Fe.pending,l=fe(c=>c.navigateIntoSubworkflow),o=qm().filter(c=>c.parentAgent===e.name),u=[];return e.elapsed!=null&&u.push({label:"Elapsed",value:Jt(e.elapsed)}),e.cost_usd!=null&&u.push({label:"Cost",value:yi(e.cost_usd)}),e.tokens!=null&&u.push({label:"Tokens",value:$n(e.tokens)}),e.iteration!=null&&e.iteration>1&&u.push({label:"Iteration",value:e.iteration}),y.jsxs("div",{className:"space-y-4",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{backgroundColor:`${r}20`,color:r},children:t}),y.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"Subworkflow Agent"})]}),y.jsx(sl,{items:u}),o.length>0&&y.jsxs("div",{className:"space-y-2",children:[y.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-[var(--text-muted)] font-semibold",children:["Subworkflow Runs (",o.length,")"]}),y.jsx("div",{className:"space-y-1",children:o.map((c,d)=>y.jsx(M9,{ctx:c,onClick:()=>l(c.slotKey)},`${c.slotKey}-${c.iteration}-${d}`))})]}),t==="failed"&&(e.error_type||e.error_message)&&y.jsxs("div",{className:"text-xs text-red-400",children:[e.error_type&&y.jsx("span",{className:"font-semibold",children:e.error_type}),e.error_message&&y.jsxs("span",{className:"ml-1",children:["— ",e.error_message]})]}),o.length===0&&t==="pending"&&y.jsx("div",{className:"text-xs text-[var(--text-muted)] italic",children:"Subworkflow has not started yet."})]})}function M9({ctx:e,onClick:t}){const r=Fe[e.status]||Fe.pending;return y.jsxs("button",{onClick:t,className:"flex items-center gap-2 w-full px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--surface)] hover:bg-[var(--node-bg)] transition-colors text-left",children:[y.jsx(Sc,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:r}}),y.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[y.jsx("span",{className:"text-xs font-medium text-[var(--text)] truncate",children:e.workflowName||e.workflowFile||"Subworkflow"}),y.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-[var(--text-muted)]",children:[e.agentsTotal>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(yw,{className:"w-2.5 h-2.5"}),e.agentsCompleted,"/",e.agentsTotal," agents"]}),e.totalCost>0&&y.jsxs("span",{className:"flex items-center gap-0.5",children:[y.jsx(mw,{className:"w-2.5 h-2.5"}),yi(e.totalCost)]})]})]}),y.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider flex-shrink-0 px-1.5 py-0.5 rounded",style:{backgroundColor:`${r}20`,color:r},children:e.status}),y.jsx(Rr,{className:"w-3.5 h-3.5 flex-shrink-0 text-[var(--text-muted)]"})]})}function D9(){const e=fe(d=>d.selectedNode),t=ol(),r=fe(d=>d.selectNode),l=fe(d=>d.dialogEngaged),[a,o]=P.useState(!1);P.useEffect(()=>(requestAnimationFrame(()=>o(!0)),()=>o(!1)),[e]);const u=e?t[e]:null;if(!e||!u)return y.jsxs("div",{className:"h-full flex flex-col bg-[var(--surface)]",children:[y.jsx("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Detail"})}),y.jsx("div",{className:"flex-1 flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Click a node to view details"})})]});const c=(()=>{if(u.dialog_active&&!l)return A9;if(u.dialog_active&&l)return v1;switch(u.type){case"script":return K4;case"human_gate":return k9;case"parallel_group":case"for_each_group":return C9;case"workflow":return z9;default:return v1}})();return y.jsxs("div",{className:He("h-full flex flex-col bg-[var(--surface)] transition-all duration-150 ease-out",a?"translate-x-0 opacity-100":"translate-x-4 opacity-0"),children:[y.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)] flex-shrink-0",children:[y.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] truncate",children:e}),y.jsx("button",{onClick:()=>r(null),className:"p-1 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",title:"Close panel",children:y.jsx(ll,{className:"w-4 h-4"})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:y.jsx(c,{node:u})})]})}function rc(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function R9(){const e=fe(_=>_.eventLog),t=fe(_=>_.activityLog),r=fe(_=>_.workflowOutput),l=fe(_=>_.workflowStatus),[a,o]=P.useState("log"),[u,c]=P.useState(!1),[d,h]=P.useState(0),[m,p]=P.useState(0),x=P.useCallback(_=>{o(_),_==="log"&&h(e.length),_==="activity"&&p(t.length)},[e.length,t.length]);P.useEffect(()=>{a==="log"&&h(e.length)},[a,e.length]),P.useEffect(()=>{a==="activity"&&p(t.length)},[a,t.length]),P.useEffect(()=>{l==="completed"&&r!=null&&o("output")},[l,r]);const b=r!=null,w=a!=="log"?Math.max(0,e.length-d):0,E=a!=="activity"?Math.max(0,t.length-m):0;return u?y.jsx("div",{className:"flex items-center bg-[var(--surface)] border-t border-[var(--border)] px-3 py-1",children:y.jsxs("button",{onClick:()=>c(!1),className:"flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[y.jsx(uN,{className:"w-3 h-3"}),y.jsx(Wy,{className:"w-3 h-3"}),y.jsx("span",{children:"Output"}),t.length>0&&y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)]",children:["(",t.length,")"]})]})}):y.jsxs("div",{className:"flex flex-col h-full bg-[var(--surface)] border-t border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center justify-between px-2 flex-shrink-0 border-b border-[var(--border)]",children:[y.jsxs("div",{className:"flex items-center gap-0.5",children:[y.jsx(qp,{active:a==="log",onClick:()=>x("log"),icon:y.jsx(Wy,{className:"w-3 h-3"}),label:"Log",count:e.length,unread:w}),y.jsx(qp,{active:a==="activity",onClick:()=>x("activity"),icon:y.jsx(pw,{className:"w-3 h-3"}),label:"Activity",count:t.length,unread:E}),y.jsx(qp,{active:a==="output",onClick:()=>x("output"),icon:y.jsx(mN,{className:"w-3 h-3"}),label:"Output",badge:b?l==="failed"?"error":"success":void 0})]}),y.jsx("button",{onClick:()=>c(!0),className:"p-1 rounded text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-hover)] transition-colors",title:"Collapse panel",children:y.jsx(il,{className:"w-3.5 h-3.5"})})]}),y.jsx("div",{className:"flex-1 overflow-hidden",children:a==="activity"?y.jsx(O9,{entries:t}):a==="log"?y.jsx(L9,{entries:e}):y.jsx(H9,{output:r,status:l})})]})}function qp({active:e,onClick:t,icon:r,label:l,count:a,badge:o,unread:u}){return y.jsxs("button",{onClick:t,className:He("relative flex items-center gap-1.5 px-3 py-1.5 text-xs transition-colors border-b-2 -mb-px",e?"text-[var(--text)] border-[var(--accent)]":"text-[var(--text-muted)] border-transparent hover:text-[var(--text-secondary)]"),children:[r,y.jsx("span",{children:l}),a!=null&&a>0&&y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums",children:a}),o&&y.jsx("span",{className:He("w-1.5 h-1.5 rounded-full",o==="success"?"bg-[var(--completed)]":"bg-[var(--failed)]")}),!e&&u!=null&&u>0&&y.jsx("span",{className:"absolute -top-0.5 -right-0.5 flex h-3.5 min-w-[14px] items-center justify-center rounded-full bg-[var(--accent)] px-1",children:y.jsx("span",{className:"text-[8px] font-bold text-white leading-none tabular-nums",children:u>99?"99+":u})})]})}const cw={reasoning:{color:"text-indigo-400/70",label:"THINK",labelColor:"text-indigo-500"},"tool-start":{color:"text-blue-400",label:"TOOL →",labelColor:"text-blue-500"},"tool-complete":{color:"text-green-400",label:"TOOL ←",labelColor:"text-green-600"},turn:{color:"text-amber-400",label:"STEP",labelColor:"text-amber-500"},message:{color:"text-[var(--text)]",label:"MSG",labelColor:"text-[var(--text-muted)]"},prompt:{color:"text-cyan-400/70",label:"PROMPT",labelColor:"text-cyan-600"}};function O9({entries:e}){const t=P.useRef(null),r=P.useRef(!0),l=fe(d=>d.selectNode),[a,o]=P.useState(""),u=P.useCallback(()=>{const d=t.current;if(!d)return;const h=d.scrollHeight-d.scrollTop-d.clientHeight<30;r.current=h},[]),c=P.useMemo(()=>{if(!a)return e;const d=a.toLowerCase();return e.filter(h=>h.source.toLowerCase().includes(d)||rc(h.message).toLowerCase().includes(d))},[e,a]);return P.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[c.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for agent activity…"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx(bN,{className:"w-3 h-3 text-[var(--text-muted)] flex-shrink-0"}),y.jsx("input",{type:"text",value:a,onChange:d=>o(d.target.value),placeholder:"Filter by agent or message…",className:"flex-1 bg-transparent text-[11px] text-[var(--text)] placeholder:text-[var(--text-muted)] outline-none min-w-0"}),a&&y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"text-[10px] text-[var(--text-muted)] tabular-nums flex-shrink-0",children:[c.length," of ",e.length]}),y.jsx("button",{onClick:()=>o(""),className:"text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0",title:"Clear filter",children:y.jsx(ll,{className:"w-3 h-3"})})]})]}),y.jsxs("div",{ref:t,onScroll:u,className:"flex-1 overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:[c.map((d,h)=>{const m=cw[d.type]||cw.message,p=Bk(d.timestamp);return y.jsxs("div",{className:"group",children:[y.jsxs("div",{className:"flex gap-1.5 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:p}),y.jsx("span",{className:He("flex-shrink-0 w-[5ch] text-[10px] font-semibold tabular-nums select-none",m.labelColor),children:m.label}),y.jsx("button",{onClick:()=>l(d.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${d.source}`,children:d.source}),y.jsx("span",{className:He("break-words min-w-0",m.color,d.type==="reasoning"&&"italic"),children:rc(d.message)})]}),d.detail&&y.jsx("div",{className:"ml-[calc(7ch+5ch+8ch+1rem)] px-2 py-1 my-0.5 bg-[var(--bg)] rounded text-[10px] text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto border-l-2 border-[var(--border)]",children:rc(d.detail)})]},h)}),a&&c.length===0&&y.jsx("div",{className:"flex items-center justify-center py-4",children:y.jsxs("p",{className:"text-xs text-[var(--text-muted)]",children:['No matches for "',a,'"']})})]})]})}const fw={info:{color:"text-blue-400",icon:"›"},success:{color:"text-green-400",icon:"✓"},error:{color:"text-red-400",icon:"✗"},warning:{color:"text-amber-400",icon:"⚠"},debug:{color:"text-[var(--text-muted)]",icon:"·"}};function L9({entries:e}){const t=P.useRef(null),r=P.useRef(!0),l=fe(o=>o.selectNode),a=P.useCallback(()=>{const o=t.current;if(!o)return;const u=o.scrollHeight-o.scrollTop-o.clientHeight<30;r.current=u},[]);return P.useEffect(()=>{t.current&&r.current&&(t.current.scrollTop=t.current.scrollHeight)},[e.length]),e.length===0?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Waiting for events…"})}):y.jsx("div",{ref:t,onScroll:a,className:"h-full overflow-y-auto font-mono text-[11px] leading-[1.6] px-3 py-2",children:e.map((o,u)=>{const c=fw[o.level]||fw.info,d=Bk(o.timestamp);return y.jsxs("div",{className:"flex gap-2 hover:bg-[var(--surface-hover)] rounded px-1 -mx-1",children:[y.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 select-none tabular-nums",children:d}),y.jsx("span",{className:He("flex-shrink-0 w-3 text-center select-none",c.color),children:c.icon}),y.jsx("button",{onClick:()=>l(o.source),className:"text-[var(--text-secondary)] flex-shrink-0 min-w-[8ch] max-w-[16ch] truncate hover:text-[var(--accent)] hover:underline transition-colors text-left",title:`Select ${o.source}`,children:o.source}),y.jsx("span",{className:He("break-words",o.level==="error"?"text-red-400":o.level==="success"?"text-green-400":"text-[var(--text)]"),children:rc(o.message)})]},u)})})}function Bk(e){const t=new Date(e*1e3),r=t.getHours().toString().padStart(2,"0"),l=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return`${r}:${l}:${a}`}function H9({output:e,status:t}){const[r,l]=P.useState(!1),a=Sw(e),o=async()=>{a&&(await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3))};return e==null?y.jsx("div",{className:"h-full flex items-center justify-center",children:y.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t==="running"?"Workflow running — output will appear when complete…":t==="failed"?"Workflow failed — no output produced":"No output yet"})}):y.jsxs("div",{className:"h-full flex flex-col",children:[y.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-[var(--border-subtle)] flex-shrink-0",children:[y.jsx("span",{className:"text-[10px] text-[var(--text-muted)] uppercase tracking-wider font-semibold",children:"Workflow Result"}),y.jsx("button",{onClick:o,className:"flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors px-1.5 py-0.5 rounded hover:bg-[var(--surface-hover)]",title:"Copy to clipboard",children:r?y.jsxs(y.Fragment,{children:[y.jsx(Yi,{className:"w-3 h-3 text-[var(--completed)]"}),y.jsx("span",{className:"text-[var(--completed)]",children:"Copied"})]}):y.jsxs(y.Fragment,{children:[y.jsx(gw,{className:"w-3 h-3"}),y.jsx("span",{children:"Copy"})]})})]}),y.jsx("div",{className:"flex-1 overflow-auto px-3 py-2",children:y.jsx("pre",{className:"font-mono text-[11px] leading-relaxed text-[var(--text)] whitespace-pre-wrap break-words",children:typeof e=="object"?y.jsx(B9,{text:a}):a})})]})}function B9({text:e}){const t=e.split(/("(?:[^"\\]|\\.)*")/g);return y.jsx(y.Fragment,{children:t.map((r,l)=>{if(l%2===1){const o=t.slice(l+1).join(""),u=/^\s*:/.test(o);return y.jsx("span",{className:u?"text-blue-400":"text-green-400",children:r},l)}const a=r.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(o,u,c)=>u?`${o}`:c?`${o}`:o);return y.jsx("span",{dangerouslySetInnerHTML:{__html:a}},l)})})}function I9({text:e}){return y.jsx("div",{className:"dialog-markdown text-xs leading-relaxed text-[var(--text)]",children:y.jsx($c,{remarkPlugins:[Gc],components:{h1:({children:t})=>y.jsx("h1",{className:"text-sm font-bold mb-2 mt-1",children:t}),h2:({children:t})=>y.jsx("h2",{className:"text-xs font-bold mb-1.5 mt-1",children:t}),h3:({children:t})=>y.jsx("h3",{className:"text-xs font-semibold mb-1 mt-1",children:t}),p:({children:t})=>y.jsx("p",{className:"mb-1.5 last:mb-0",children:t}),ul:({children:t})=>y.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:t}),ol:({children:t})=>y.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:t}),li:({children:t})=>y.jsx("li",{children:t}),code:({children:t,className:r})=>(r==null?void 0:r.includes("language-"))?y.jsx("code",{className:"block bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 font-mono text-[11px] my-1 overflow-x-auto whitespace-pre",children:t}):y.jsx("code",{className:"bg-[var(--bg)] border border-[var(--border)] rounded px-1 py-0.5 font-mono text-[11px]",children:t}),pre:({children:t})=>y.jsx("pre",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-md px-2.5 py-2 font-mono text-[11px] my-1.5 overflow-x-auto",children:t}),strong:({children:t})=>y.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>y.jsx("em",{className:"italic",children:t}),a:({href:t,children:r})=>y.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline underline-offset-2",children:r}),blockquote:({children:t})=>y.jsx("blockquote",{className:"border-l-2 border-[var(--border)] pl-2.5 my-1.5 opacity-80",children:t}),hr:()=>y.jsx("hr",{className:"border-[var(--border)] my-2"}),table:({children:t})=>y.jsx("div",{className:"overflow-x-auto my-2",children:y.jsx("table",{className:"text-[11px] border-collapse w-full",children:t})}),th:({children:t})=>y.jsx("th",{className:"border border-[var(--border)] px-2 py-1 text-left bg-[var(--bg)] font-semibold",children:t}),td:({children:t})=>y.jsx("td",{className:"border border-[var(--border)] px-2 py-1",children:t})},children:e})})}function q9({node:e}){const t=fe(x=>x.sendDialogMessage),r=fe(x=>x.wsStatus),[l,a]=P.useState(""),o=P.useRef(null),u=e.dialog_active===!0,c=e.dialog_id||"",d=e.dialog_messages||[],h=u&&r==="connected";P.useEffect(()=>{var x;(x=o.current)==null||x.scrollIntoView({behavior:"smooth"})},[d.length,e.dialog_awaiting_response]);const m=()=>{!l.trim()||!h||(t(e.name,c,l.trim()),a(""))},p=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),m())};return y.jsxs("div",{className:"flex flex-col h-full",children:[u?y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-fuchsia-500/10 border border-fuchsia-500/30 mb-3 flex-shrink-0",children:[y.jsxs("span",{className:"relative flex h-2.5 w-2.5 flex-shrink-0",children:[y.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-fuchsia-400 opacity-75"}),y.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-fuchsia-500"})]}),y.jsx("span",{className:"text-xs font-semibold text-fuchsia-400 tracking-wide",children:"Dialog Mode"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}):y.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] mb-3 flex-shrink-0",children:[y.jsx(gm,{className:"w-3.5 h-3.5 text-[var(--text-muted)]"}),y.jsx("span",{className:"text-xs font-semibold text-[var(--text-muted)] tracking-wide",children:"Dialog Completed"}),y.jsxs("span",{className:"ml-auto text-[10px] text-[var(--text-muted)]",children:[d.length," message",d.length!==1?"s":""]})]}),y.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 min-h-0 mb-3",children:[d.map((x,b)=>y.jsx("div",{className:`flex ${x.role==="user"?"justify-end":"justify-start"}`,children:y.jsxs("div",{className:`max-w-[85%] rounded-lg px-3 py-2 ${x.role==="agent"?"bg-amber-500/10 border border-amber-500/30":"bg-blue-500/10 border border-blue-500/30"}`,children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:x.role==="agent"?e.name:"You"}),y.jsx(I9,{text:x.content})]})},b)),e.dialog_awaiting_response&&y.jsx("div",{className:"flex justify-start",children:y.jsxs("div",{className:"max-w-[85%] rounded-lg px-3 py-2 bg-amber-500/10 border border-amber-500/30",children:[y.jsx("div",{className:"text-[10px] font-semibold mb-1 text-[var(--text-muted)]",children:e.name}),y.jsxs("div",{className:"flex gap-1 items-center h-4",children:[y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:0ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:150ms]"}),y.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60 animate-bounce [animation-delay:300ms]"})]})]})}),y.jsx("div",{ref:o})]}),u&&y.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] pt-3",children:[y.jsxs("div",{className:"flex gap-2",children:[y.jsx("input",{type:"text",value:l,onChange:x=>a(x.target.value),onKeyDown:p,placeholder:"Type your message...",className:"flex-1 text-xs px-3 py-2 rounded-lg border border-[var(--border)] bg-[var(--bg)] text-[var(--text)] outline-none focus:border-fuchsia-400 transition-colors",disabled:!h,autoFocus:!0}),y.jsxs("button",{onClick:m,disabled:!h||!l.trim(),className:"flex items-center justify-center gap-1.5 text-xs px-8 py-2 rounded-lg bg-fuchsia-500 text-white hover:bg-fuchsia-600 transition-colors font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[y.jsx(vw,{className:"w-3 h-3"}),"Send"]})]}),y.jsx("p",{className:"text-[10px] text-[var(--text-muted)] mt-1.5 px-1",children:'Press Enter to send · Type "done" to end dialog'})]})]})}function U9(){const e=fe(l=>l.activeDialog),t=fe(l=>l.nodes);if(!e)return null;const r=t[e.agentName];return r?y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)] overflow-hidden",children:[y.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3 border-b border-[var(--border)] bg-[var(--surface)] flex-shrink-0",children:[y.jsx(gm,{className:"w-4 h-4 text-fuchsia-400"}),y.jsxs("h2",{className:"text-sm font-semibold text-[var(--text)]",children:["Dialog with ",e.agentName]})]}),y.jsx("div",{className:"flex-1 overflow-hidden px-5 py-4",children:y.jsx(q9,{node:r})})]}):null}function V9(){const e=fe(l=>l.selectedNode),t=fe(l=>l.activeDialog),r=fe(l=>l.dialogEngaged);return y.jsxs(Vp,{direction:"vertical",className:"flex-1 overflow-hidden",children:[y.jsx(Eo,{defaultSize:70,minSize:30,children:y.jsxs(Vp,{direction:"horizontal",className:"h-full",children:[y.jsx(Eo,{defaultSize:e?65:100,minSize:40,children:t&&r?y.jsx(U9,{}):y.jsx(P4,{})}),e&&y.jsxs(y.Fragment,{children:[y.jsx(Pp,{className:"w-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-col-resize"}),y.jsx(Eo,{defaultSize:35,minSize:20,maxSize:60,children:y.jsx(D9,{})})]})]})}),y.jsx(Pp,{className:"h-[3px] bg-[var(--border)] hover:bg-[var(--text-muted)] transition-colors cursor-row-resize"}),y.jsx(Eo,{defaultSize:30,minSize:5,maxSize:70,collapsible:!0,children:y.jsx(R9,{})})]})}const P9=3e4;function $9(){const e=fe(p=>p.processEvent),t=fe(p=>p.replayState),r=fe(p=>p.setWsStatus),l=fe(p=>p.setWsSend),a=P.useRef(null),o=P.useRef(1e3),u=P.useRef(null),c=P.useRef(null),d=P.useRef(()=>{}),h=P.useCallback(()=>{r("reconnecting"),u.current=setTimeout(()=>{o.current=Math.min(o.current*2,P9),d.current()},o.current)},[r]),m=P.useCallback(()=>{r("connecting"),c.current&&c.current.abort();const p=new AbortController;c.current=p,fetch("/api/state",{signal:p.signal}).then(x=>x.json()).then(x=>{x&&x.length>0&&t(x);const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;try{const E=new WebSocket(w);a.current=E,E.onopen=()=>{o.current=1e3,r("connected"),l(_=>{E.readyState===WebSocket.OPEN&&E.send(JSON.stringify(_))})},E.onmessage=_=>{try{const S=JSON.parse(_.data);e(S)}catch(S){console.error("Failed to parse WebSocket message:",S)}},E.onclose=()=>{r("disconnected"),l(null),a.current=null,h()},E.onerror=()=>{}}catch{h()}}).catch(x=>{p.signal.aborted||(console.error("Failed to fetch state:",x),h())})},[e,t,r,l,h]);d.current=m,P.useEffect(()=>(m(),()=>{c.current&&c.current.abort(),u.current&&clearTimeout(u.current),a.current&&a.current.close(),l(null)}),[m,l])}function G9(){const e=fe(h=>h.setReplayMode),t=fe(h=>h.setWsStatus),r=fe(h=>h.replayPlaying),l=fe(h=>h.replayPosition),a=fe(h=>h.replayTotalEvents),o=fe(h=>h.replaySpeed),u=fe(h=>h.replayEvents),c=fe(h=>h.setReplayPosition);P.useEffect(()=>{t("connecting"),fetch("/api/state").then(h=>h.json()).then(h=>{e(h),t("connected")}).catch(h=>{console.error("Failed to load replay events:",h),t("disconnected")})},[e,t]);const d=P.useRef(null);P.useEffect(()=>{if(!r||l>=a){d.current&&clearTimeout(d.current),r&&l>=a&&fe.getState().setReplayPlaying(!1);return}const h=u[l-1],m=u[l];let p=100;if(h&&m){const x=(m.timestamp-h.timestamp)*1e3;p=Math.max(16,Math.min(x/o,2e3))}return d.current=setTimeout(()=>{c(l+1)},p),()=>{d.current&&clearTimeout(d.current)}},[r,l,a,o,u,c])}function F9(){return $9(),null}function Y9(){return G9(),null}function X9(){const[e,t]=P.useState(null),r=fe(o=>o.replayMode),l=fe(o=>o.selectNode),a=fe(o=>o.workflowName);return P.useEffect(()=>{fetch("/api/replay/info").then(o=>{o.ok?t(!0):t(!1)}).catch(()=>t(!1))},[]),P.useEffect(()=>{document.title=a?`Conductor — ${a}`:"Conductor Dashboard"},[a]),P.useEffect(()=>{const o=u=>{u.key==="Escape"&&l(null)};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]),e===null?null:y.jsxs("div",{className:"h-full flex flex-col bg-[var(--bg)]",children:[e?y.jsx(Y9,{}):y.jsx(F9,{}),y.jsx(ON,{}),y.jsx(LN,{}),y.jsx(V9,{}),r?y.jsx(UN,{}):y.jsx(BN,{})]})}nN.createRoot(document.getElementById("root")).render(y.jsx(P.StrictMode,{children:y.jsx(X9,{})})); diff --git a/src/conductor/web/static/index.html b/src/conductor/web/static/index.html index 83b5081..9768c92 100644 --- a/src/conductor/web/static/index.html +++ b/src/conductor/web/static/index.html @@ -5,7 +5,7 @@ Conductor Dashboard - +