zen-code 4.10.1 → 4.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/app.js +157 -2615
  2. package/dist/chunk-0ddrb30y.js +1 -0
  3. package/dist/chunk-215an3fz.js +1 -0
  4. package/dist/chunk-40ht9pe1.js +91 -0
  5. package/dist/chunk-4wnmk2tj.js +7 -0
  6. package/dist/chunk-4z0w0ng1.js +2 -0
  7. package/dist/chunk-57bj89e2.js +1 -0
  8. package/dist/chunk-5a5mepqj.js +1 -0
  9. package/dist/chunk-5c3bpcpm.js +1 -0
  10. package/dist/chunk-7kw7ss8d.js +1 -0
  11. package/dist/chunk-86m0rmtc.js +1 -0
  12. package/dist/chunk-8f19qk9r.js +26 -0
  13. package/dist/chunk-8tbtavry.js +6 -0
  14. package/dist/chunk-9rayxazs.js +8 -0
  15. package/dist/chunk-a9gpb2tx.js +2 -0
  16. package/dist/chunk-a9tw6d68.js +1 -0
  17. package/dist/chunk-anbtppz1.js +294 -0
  18. package/dist/chunk-bca8tkkr.js +1 -0
  19. package/dist/chunk-bdqds8vh.js +1 -0
  20. package/dist/chunk-bzgznka5.js +3 -0
  21. package/dist/chunk-c7kd2qrp.js +278 -0
  22. package/dist/chunk-dvbb3dd1.js +233 -0
  23. package/dist/chunk-e8kxa5vj.js +140 -0
  24. package/dist/chunk-ehmmd8qc.js +1 -0
  25. package/dist/chunk-ejfa95sm.js +1 -0
  26. package/dist/chunk-f0m4532p.js +54 -0
  27. package/dist/chunk-f7cps5x1.js +1 -0
  28. package/dist/chunk-fbemqjck.js +2 -0
  29. package/dist/chunk-feeqtzv5.js +1 -0
  30. package/dist/chunk-fzh0v6r0.js +6 -0
  31. package/dist/chunk-g2zskge5.js +81 -0
  32. package/dist/chunk-g974hxbz.js +3 -0
  33. package/dist/chunk-g9911ymn.js +1 -0
  34. package/dist/chunk-gfhmzpy7.js +176 -0
  35. package/dist/chunk-gt8c6dne.js +3 -0
  36. package/dist/chunk-h8fdexm4.js +2 -0
  37. package/dist/chunk-hnnwbfqk.js +3 -0
  38. package/dist/chunk-hp2jzn9x.js +166 -0
  39. package/dist/chunk-hve2a279.js +2 -0
  40. package/dist/chunk-js4qp900.js +2 -0
  41. package/dist/chunk-k4q8j7pg.js +2 -0
  42. package/dist/chunk-m21hvv91.js +2 -0
  43. package/dist/chunk-mmx0k2yq.js +1 -0
  44. package/dist/chunk-mnnyjmgw.js +224 -0
  45. package/dist/chunk-mw7x6xqp.js +1 -0
  46. package/dist/chunk-n7s6my89.js +112 -0
  47. package/dist/chunk-n9rpnke9.js +4 -0
  48. package/dist/chunk-nk62q95g.js +93 -0
  49. package/dist/chunk-nmzx5nmt.js +1 -0
  50. package/dist/chunk-nqh1pptf.js +88 -0
  51. package/dist/chunk-nsw5168d.js +2 -0
  52. package/dist/chunk-pe8mzxwn.js +16 -0
  53. package/dist/chunk-pg1ppq4y.js +1 -0
  54. package/dist/chunk-pzb224c5.js +2 -0
  55. package/dist/chunk-q1cxrg0x.js +2 -0
  56. package/dist/chunk-qxebn3jw.js +18 -0
  57. package/dist/chunk-s1tbdcs8.js +4 -0
  58. package/dist/chunk-s5cqejr6.js +79 -0
  59. package/dist/chunk-spa69h7p.js +2 -0
  60. package/dist/chunk-spx7nn8t.js +6 -0
  61. package/dist/chunk-swc7se71.js +2 -0
  62. package/dist/chunk-swyc15ym.js +1 -0
  63. package/dist/chunk-t2s3s6af.js +1 -0
  64. package/dist/chunk-t6440ajd.js +5 -0
  65. package/dist/chunk-tjg2e8v3.js +41 -0
  66. package/dist/chunk-tjvhqr94.js +1 -0
  67. package/dist/chunk-vbb3m0vz.js +1 -0
  68. package/dist/chunk-vdmq9d9x.js +4 -0
  69. package/dist/chunk-vfxjbdz4.js +2 -0
  70. package/dist/chunk-vrnj0659.js +213 -0
  71. package/dist/chunk-wmyc17aa.js +23 -0
  72. package/dist/chunk-wt3p1w1g.js +1 -0
  73. package/dist/chunk-y5ry5c7v.js +1 -0
  74. package/dist/chunk-y8qhrx11.js +2 -0
  75. package/dist/chunk-yy8p9zph.js +2 -0
  76. package/dist/chunk-z61m3anh.js +1 -0
  77. package/dist/chunk-zg54h6gy.js +1 -0
  78. package/dist/chunk-zr90qp47.js +1 -0
  79. package/dist/chunk-zsa62xr0.js +2 -0
  80. package/dist/cli.js +1 -3116
  81. package/dist/nonInteractive.js +180 -1950
  82. package/dist/zen-keyboard.js +3 -358
  83. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import{$g as Z1,Dg as b$,Eg as nQ,Gg as j8,Hg as C$,Wg as V0,Xg as fQ,Zg as H1,_g as o$,bh as W8,ch as q1}from"./chunk-hp2jzn9x.js";import{$j as Z$,Bi as V8,Fj as M8,Gj as X$,Ni as F8,Oj as XQ,Pj as F$,Qj as M1,Rj as K8,Uj as x1,Wh as kQ,Xh as a8,Xi as QQ,aj as j1,bi as Y1,bj as DQ,bk as YQ,ck as v$,dj as iQ,fk as Z0,hj as r8,ii as X1,kk as yQ,vi as U8,wj as K1}from"./chunk-nk62q95g.js";import{Hk as L$}from"./chunk-nmzx5nmt.js";import{tl as tQ}from"./chunk-tjg2e8v3.js";import{Cl as D1,wl as J$,xl as Y$}from"./chunk-hve2a279.js";var T="__start__",A="__end__",xQ="__input__",H$="__copy__",p="__error__",k0="__pregel_ns_writes",WQ="__pregel_send",g0="__pregel_call",AQ="__pregel_read",m="__pregel_checkpointer",EQ="__pregel_resuming",Y0="__pregel_task_id",K0="__pregel_stream";var X0="__pregel_resume_map",JQ="__pregel_scratchpad",M0="__pregel_previous",U$="__pregel_durability",w8="checkpoint_id",FQ="checkpoint_ns",V$="__pregel_node_finished",ZQ="checkpoint_map",R8="__pregel_abort_signals",S="__interrupt__",o="__resume__",m0="__no_writes__",jQ="__return__",aQ="__previous__",E="langsmith:hidden",D$="langsmith:nostream",T8="__self__",c="__pregel_tasks",r="__pregel_push",x0="__pregel_pull",n="00000000-0000-0000-0000-000000000000",G$=["langsmith:hidden","__input__","__interrupt__","__resume__","__error__","__no_writes__","__pregel_send","__pregel_read","__pregel_checkpointer","__pregel_durability","__pregel_stream","__pregel_resuming","__pregel_task_id","__pregel_call","__pregel_resume_value","__pregel_scratchpad","__pregel_previous","checkpoint_map","checkpoint_ns","checkpoint_id"],k="|",e=":",f0=Symbol.for("langgraph.command"),h0=class{[f0];constructor(Q){this[f0]=Q}};function u0(Q){let $=Q;return $!==null&&$!==void 0&&typeof $.node==="string"&&$.args!==void 0}var uQ=class{lg_name="Send";node;args;constructor(Q,$){this.node=Q,this.args=G0($)}toJSON(){return{lg_name:this.lg_name,node:this.node,args:this.args}}};function d(Q){return Q instanceof uQ}var j$="__overwrite__";function d0(Q){if(typeof Q==="object"&&Q!==null&&j$ in Q)return[!0,Q[j$]];return[!1,void 0]}function K$(Q){return d0(Q)[0]}function F0(Q){if(!Q||typeof Q!=="object")return!1;if(!("__interrupt__"in Q))return!1;return Array.isArray(Q.__interrupt__)}var a=class extends h0{lg_name="Command";lc_direct_tool_output=!0;graph;update;resume;goto=[];static PARENT="__parent__";constructor(Q){super(Q);if(this.resume=Q.resume,this.graph=Q.graph,this.update=Q.update,Q.goto)this.goto=Array.isArray(Q.goto)?G0(Q.goto):[G0(Q.goto)]}_updateAsTuples(){if(this.update&&typeof this.update==="object"&&!Array.isArray(this.update))return Object.entries(this.update);else if(Array.isArray(this.update)&&this.update.every((Q)=>Array.isArray(Q)&&Q.length===2&&typeof Q[0]==="string"))return this.update;else return[["__root__",this.update]]}toJSON(){let Q;if(typeof this.goto==="string")Q=this.goto;else if(d(this.goto))Q=this.goto.toJSON();else Q=this.goto?.map(($)=>{if(typeof $==="string")return $;else return $.toJSON()});return{lg_name:this.lg_name,update:this.update,resume:this.resume,goto:Q}}};function u(Q){if(typeof Q!=="object")return!1;if(Q===null||Q===void 0)return!1;if("lg_name"in Q&&Q.lg_name==="Command")return!0;return!1}function G0(Q,$=new Map){if(Q!==void 0&&Q!==null&&typeof Q==="object"){if($.has(Q))return $.get(Q);let J;if(Array.isArray(Q))J=[],$.set(Q,J),Q.forEach((Z,q)=>{J[q]=G0(Z,$)});else if(u(Q)&&!(Q instanceof a))J=new a(Q),$.set(Q,J);else if(u0(Q)&&!(Q instanceof uQ))J=new uQ(Q.node,Q.args),$.set(Q,J);else if(u(Q)||d(Q))J=Q,$.set(Q,J);else if("lc_serializable"in Q&&Q.lc_serializable)J=Q,$.set(Q,J);else{J={},$.set(Q,J);for(let[Z,q]of Object.entries(Q))J[Z]=G0(q,$)}return J}return Q}var OQ=class extends Error{lc_error_code;constructor(Q,$){let J=Q??"";if($?.lc_error_code)J=`${J}
2
+
3
+ Troubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${$.lc_error_code}/
4
+ `;super(J);this.lc_error_code=$?.lc_error_code}},p0=class extends OQ{get is_bubble_up(){return!0}},l0=class extends OQ{constructor(Q,$){super(Q,$);this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}},dQ=class extends OQ{constructor(Q,$){super(Q,$);this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}},PQ=class extends p0{interrupts;constructor(Q,$){super(JSON.stringify(Q,null,2),$);this.name="GraphInterrupt",this.interrupts=Q??[]}static get unminifiable_name(){return"GraphInterrupt"}},A0=class extends PQ{constructor(Q,$){super([{value:Q}],$);this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}},O0=class extends p0{command;constructor(Q){super();this.name="ParentCommand",this.command=Q}static get unminifiable_name(){return"ParentCommand"}};function o0(Q){return Q!==void 0&&Q.name===O0.unminifiable_name}function pQ(Q){return Q!==void 0&&Q.is_bubble_up===!0}function wQ(Q){return Q!==void 0&&[PQ.unminifiable_name,A0.unminifiable_name].includes(Q.name)}var P0=class extends OQ{constructor(Q,$){super(Q,$);this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}},v=class extends OQ{constructor(Q,$){super(Q,$);this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}},w=class extends OQ{constructor(Q,$){super(Q,$);this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}};var c0=class extends OQ{constructor(Q,$){super(Q,$);this.name="UnreachableNodeError"}static get unminifiable_name(){return"UnreachableNodeError"}};var B0=class extends OQ{constructor(Q,$){super(Q,$);this.name="StateGraphInputError",this.message="Invalid StateGraph input. Make sure to pass a valid StateDefinition, Annotation.Root, or Zod schema."}static get unminifiable_name(){return"StateGraphInputError"}};var V=(Q)=>BigInt(Q),C=(Q,$=0)=>new DataView(Q.buffer,Q.byteOffset+$,Q.byteLength-$),O$=V("0x9E3779B1"),P$=V("0x85EBCA77"),_1=V("0xC2B2AE3D"),lQ=V("0x9E3779B185EBCA87"),eQ=V("0xC2B2AE3D27D4EB4F"),w$=V("0x165667B19E3779F9"),_8=V("0x85EBCA77C2B2AE63"),N1=V("0x27D4EB2F165667C5"),I1=V("0x165667919E3779F9"),y1=V("0x9FB21C651E98DF25"),E1=(Q)=>{let $=Q.length;if($%2!==0)throw Error("String should have an even number of characters");let J=$/2,Z=new Uint8Array(J),q=0,z=0;while(z<J){let Y=Q.slice(q,q+=2);Z[z]=Number.parseInt(Y,16),z+=1}return C(Z)},RQ=E1("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),L0=(V(1)<<V(128))-V(1),R=(V(1)<<V(64))-V(1),n0=(V(1)<<V(32))-V(1);function W0(Q){if(!Q)throw Error("Assert failed")}function v1(Q){let $=new DataView(new ArrayBuffer(8));return $.setBigUint64(0,Q,!0),$.getBigUint64(0,!1)}function C1(Q){let $=Q;return $=($&V(65535))<<V(16)|($&V(4294901760))>>V(16),$=($&V(16711935))<<V(8)|($&V(4278255360))>>V(8),$}function f1(Q,$){return(Q&n0)*($&n0)&R}function k1(Q,$){return(Q<<$|Q>>V(32)-$)&n0}function R$(Q,$,J){for(let Z=0;Z<8;Z+=1){let q=$.getBigUint64(Z*8,!0),z=q^J.getBigUint64(Z*8,!0);Q[Z^1]+=q,Q[Z]+=f1(z,z>>V(32))}return Q}function M$(Q,$,J,Z){for(let q=0;q<Z;q+=1)R$(Q,C($,q*64),C(J,q*8));return Q}function g1(Q,$){for(let J=0;J<8;J+=1){let Z=$.getBigUint64(J*8,!0),q=Q[J];q=b8(q,V(47)),q^=Z,q*=O$,Q[J]=q&R}return Q}function i0(Q,$){return T$(Q[0]^$.getBigUint64(0,!0),Q[1]^$.getBigUint64(8,!0))}function x$(Q,$,J){let Z=J;return Z+=i0(Q.slice(0),C($,0)),Z+=i0(Q.slice(2),C($,16)),Z+=i0(Q.slice(4),C($,32)),Z+=i0(Q.slice(6),C($,48)),TQ(Z&R)}function m1(Q,$,J,Z,q){let z=Q,Y=Math.floor((J.byteLength-64)/8),X=64*Y,B=Math.floor(($.byteLength-1)/X);for(let F=0;F<B;F+=1)z=M$(z,C($,F*X),J,Y),z=q(z,C(J,J.byteLength-64));{let F=Math.floor(($.byteLength-1-X*B)/64);z=M$(z,C($,B*X),J,F),z=Z(z,C($,$.byteLength-64),C(J,J.byteLength-64-7))}return z}function h1(Q,$){let J=new BigUint64Array([_1,lQ,eQ,w$,_8,P$,N1,O$]);W0(Q.byteLength>128),J=m1(J,Q,$,R$,g1),W0(J.length*8===64);{let Z=x$(J,C($,11),V(Q.byteLength)*lQ&R);return x$(J,C($,$.byteLength-64-11),~(V(Q.byteLength)*eQ)&R)<<V(64)|Z}}function T$(Q,$){let J=Q*$&L0;return J&R^J>>V(64)}function A$(Q,$,J){return T$((Q.getBigUint64(0,!0)^$.getBigUint64(0,!0)+J)&R,(Q.getBigUint64(8,!0)^$.getBigUint64(8,!0)-J)&R)}function r0(Q,$,J,Z,q){let z=Q&R,Y=Q>>V(64)&R;return z+=A$($,Z,q),z^=J.getBigUint64(0,!0)+J.getBigUint64(8,!0),z&=R,Y+=A$(J,C(Z,16),q),Y^=$.getBigUint64(0,!0)+$.getBigUint64(8,!0),Y&=R,Y<<V(64)|z}function TQ(Q){let $=Q;return $^=$>>V(37),$*=I1,$&=R,$^=$>>V(32),$}function s0(Q){let $=Q;return $^=$>>V(33),$*=eQ,$&=R,$^=$>>V(29),$*=w$,$&=R,$^=$>>V(32),$}function u1(Q,$,J){let Z=Q.byteLength;W0(Z>0&&Z<=3);let q=V(Q.getUint8(Z-1))|V(Z<<8)|V(Q.getUint8(0)<<16)|V(Q.getUint8(Z>>1)<<24),z=(q^(V($.getUint32(0,!0))^V($.getUint32(4,!0)))+J)&R,Y=(V($.getUint32(8,!0))^V($.getUint32(12,!0)))-J;return(s0((k1(C1(q),V(13))^Y)&R)&R)<<V(64)|s0(z)}function b8(Q,$){return Q^Q>>$}function d1(Q,$,J){let Z=Q.byteLength;W0(Z>=4&&Z<=8);{let q=Q.getUint32(0,!0),z=Q.getUint32(Z-4,!0),Y=((V(q)|V(z)<<V(32))^($.getBigUint64(16,!0)^$.getBigUint64(24,!0))+J&R)*(lQ+(V(Z)<<V(2)))&L0;return Y+=(Y&R)<<V(65),Y&=L0,Y^=Y>>V(67),b8(b8(Y&R,V(35))*y1&R,V(28))|TQ(Y>>V(64))<<V(64)}}function p1(Q,$,J){let Z=Q.byteLength;W0(Z>=9&&Z<=16);{let q=($.getBigUint64(32,!0)^$.getBigUint64(40,!0))+J&R,z=($.getBigUint64(48,!0)^$.getBigUint64(56,!0))-J&R,Y=Q.getBigUint64(0,!0),X=Q.getBigUint64(Z-8,!0),B=(Y^X^q)*lQ,F=(B&R)+(V(Z-1)<<V(54));B=B&(L0^R)|F,X^=z,B+=X+(X&n0)*(P$-V(1))<<V(64),B&=L0,B^=v1(B>>V(64));let W=(B&R)*eQ;return W+=(B>>V(64))*eQ<<V(64),W&=L0,TQ(W&R)|TQ(W>>V(64))<<V(64)}}function l1(Q,$){let J=Q.byteLength;if(W0(J<=16),J>8)return p1(Q,RQ,$);if(J>=4)return d1(Q,RQ,$);if(J>0)return u1(Q,RQ,$);return s0($^RQ.getBigUint64(64,!0)^RQ.getBigUint64(72,!0))|s0($^RQ.getBigUint64(80,!0)^RQ.getBigUint64(88,!0))<<V(64)}function S8(Q){return~Q+V(1)&R}function o1(Q,$,J){let Z=V(Q.byteLength)*lQ&R,q=V(Q.byteLength-1)/V(32);while(q>=0){let X=Number(q);Z=r0(Z,C(Q,16*X),C(Q,Q.byteLength-16*(X+1)),C($,32*X),J),q-=V(1)}let z=Z+(Z>>V(64))&R;z=TQ(z);let Y=(Z&R)*lQ+(Z>>V(64))*_8+(V(Q.byteLength)-J&R)*eQ;return Y&=R,Y=S8(TQ(Y)),z|Y<<V(64)}function c1(Q,$,J){let Z=V(Q.byteLength)*lQ&R;for(let Y=32;Y<160;Y+=32)Z=r0(Z,C(Q,Y-32),C(Q,Y-16),C($,Y-32),J);Z=TQ(Z&R)|TQ(Z>>V(64))<<V(64);for(let Y=160;Y<=Q.byteLength;Y+=32)Z=r0(Z,C(Q,Y-32),C(Q,Y-16),C($,3+Y-160),J);Z=r0(Z,C(Q,Q.byteLength-16),C(Q,Q.byteLength-32),C($,103),S8(J));let q=Z+(Z>>V(64))&R;q=TQ(q);let z=(Z&R)*lQ+(Z>>V(64))*_8+(V(Q.byteLength)-J&R)*eQ;return z&=R,z=S8(TQ(z)),q|z<<V(64)}function vQ(Q,$=V(0)){let Z=C(typeof Q==="string"?new TextEncoder().encode(Q):Q),q=Z.byteLength,z=(Y)=>Y.toString(16).padStart(32,"0");if(q<=16)return z(l1(Z,$));if(q<=128)return z(o1(Z,RQ,$));if(q<=240)return z(c1(Z,RQ,$));return z(h1(Z,RQ))}function t0(Q){return/^[0-9a-f]{32}$/.test(Q)}function N8(Q){let $=QQ.getRunnableConfig();if(!$)throw Error("Called interrupt() outside the context of a graph.");let J=$.configurable;if(!J)throw Error("No configurable found in config");if(!J[m])throw new dQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=J[JQ];Z.interruptCounter+=1;let q=Z.interruptCounter;if(Z.resume.length>0&&q<Z.resume.length)return J[WQ]?.([[o,Z.resume]]),Z.resume[q];if(Z.nullResume!==void 0){if(Z.resume.length!==q)throw Error(`Resume length mismatch: ${Z.resume.length} !== ${q}`);let Y=Z.consumeNullResume();return Z.resume.push(Y),J[WQ]?.([[o,Z.resume]]),Y}let z=J[FQ]?.split(k);throw new PQ([{id:z?vQ(z.join(k)):void 0,value:Q}])}var I8=Symbol.for("langgraph.state.reduced_value"),BQ=class{[I8]=!0;valueSchema;inputSchema;reducer;jsonSchemaExtra;constructor(Q,$){this.reducer=$.reducer,this.jsonSchemaExtra=$.jsonSchemaExtra,this.valueSchema=Q,this.inputSchema="inputSchema"in $?$.inputSchema:Q,this.jsonSchemaExtra=$.jsonSchemaExtra}static isInstance(Q){return typeof Q==="object"&&Q!==null&&I8 in Q&&Q[I8]===!0}};function E8(Q){return Q!=null&&Q.lg_is_channel===!0}var l=class{ValueType;UpdateType;lg_is_channel=!0;consume(){return!1}finish(){return!1}isAvailable(){try{return this.get(),!0}catch(Q){if(Q.name===v.unminifiable_name)return!1;throw Q}}equals(Q){return this===Q}},y8=Symbol.for("LG_IS_ONLY_BASE_CHANNEL");function w0(Q){if(Q[y8]===!0)return Q;let $={};for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;let Z=Q[J];if(E8(Z))$[J]=Z}return Object.assign($,{[y8]:!0}),$}function oQ(Q,$){let J=w0(Q),Z={};for(let q in J){if(!Object.prototype.hasOwnProperty.call(J,q))continue;let z=$.channel_values[q];Z[q]=J[q].fromCheckpoint(z)}return Object.assign(Z,{[y8]:!0}),Z}function HQ(Q,$,J,Z){let q;if($===void 0)q=Q.channel_values;else{q={};for(let z in $){if(!Object.prototype.hasOwnProperty.call($,z))continue;try{q[z]=$[z].checkpoint()}catch(Y){if(Y.name===v.unminifiable_name);else throw Y}}}return{v:4,id:Z?.id??b$(J),ts:new Date().toISOString(),channel_values:q,channel_versions:Q.channel_versions,versions_seen:Q.versions_seen}}var i1=(Q)=>{return Q!=null&&Q.lc_graph_name==="BinaryOperatorAggregate"},bQ=class Q extends l{lc_graph_name="BinaryOperatorAggregate";value;operator;initialValueFactory;constructor($,J){super();this.operator=$,this.initialValueFactory=J,this.value=J?.()}fromCheckpoint($){let J=new Q(this.operator,this.initialValueFactory);if(typeof $<"u")J.value=$;return J}update($){let J=$;if(!J.length)return!1;if(this.value===void 0){let q=J[0],[z,Y]=d0(q);if(z)this.value=Y;else this.value=q;J=J.slice(1)}let Z=!1;for(let q of J)if(K$(q)){if(Z)throw new w("Can receive only one Overwrite value per step.");let[,z]=d0(q);this.value=z,Z=!0;continue}else if(!Z&&this.value!==void 0)this.value=this.operator(this.value,q);return!0}get(){if(this.value===void 0)throw new v;return this.value}checkpoint(){if(this.value===void 0)throw new v;return this.value}isAvailable(){return this.value!==void 0}equals($){if(this===$)return!0;if(!i1($))return!1;return this.operator===$.operator}};var UQ=class Q extends l{lc_graph_name="LastValue";value=[];constructor($){super();if(this.initialValueFactory=$,$)this.value=[$()]}fromCheckpoint($){let J=new Q(this.initialValueFactory);if(typeof $<"u")J.value=[$];return J}update($){if($.length===0)return!1;if($.length!==1)throw new w("LastValue can only receive one value per step.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this.value=[$[$.length-1]],!0}get(){if(this.value.length===0)throw new v;return this.value[0]}checkpoint(){if(this.value.length===0)throw new v;return this.value[0]}isAvailable(){return this.value.length!==0}},v8=class Q extends l{lc_graph_name="LastValueAfterFinish";value=[];finished=!1;fromCheckpoint($){let J=new Q;if(typeof $<"u"){let[Z,q]=$;J.value=[Z],J.finished=q}return J}update($){if($.length===0)return!1;return this.finished=!1,this.value=[$[$.length-1]],!0}get(){if(this.value.length===0||!this.finished)throw new v;return this.value[0]}checkpoint(){if(this.value.length===0)return;return[this.value[0],this.finished]}consume(){if(this.finished)return this.finished=!1,this.value=[],!0;return!1}finish(){if(!this.finished&&this.value.length>0)return this.finished=!0,!0;return!1}isAvailable(){return this.value.length!==0&&this.finished}};function SQ(Q){return typeof Q==="object"&&Q!==null&&"~standard"in Q&&typeof Q["~standard"]==="object"&&Q["~standard"]!==null&&"validate"in Q["~standard"]}function S$(Q){return typeof Q==="object"&&Q!==null&&"~standard"in Q&&typeof Q["~standard"]==="object"&&Q["~standard"]!==null&&"jsonSchema"in Q["~standard"]}function _Q(Q){if(S$(Q))try{return Q["~standard"].jsonSchema.input({target:"draft-07"})}catch{return}}function NQ(Q){if(Q==null)return;if(!SQ(Q))return;try{let $=Q["~standard"].validate(void 0);if($&&typeof $==="object"&&!(("then"in $)&&typeof $.then==="function")){let J=$;if(!J.issues){let Z=J.value;return()=>Z}}}catch{}}var C8=Symbol.for("langgraph.channel.missing"),R0=class Q extends l{lc_graph_name="UntrackedValue";guard;_value=C8;initialValueFactory;constructor($){super();if(this.guard=$?.guard??!0,this.initialValueFactory=$?.initialValueFactory,this.initialValueFactory)this._value=this.initialValueFactory()}fromCheckpoint($){return new Q({guard:this.guard,initialValueFactory:this.initialValueFactory})}update($){if($.length===0)return!1;if($.length!==1&&this.guard)throw new w("UntrackedValue(guard=true) can receive only one value per step. Use guard=false if you want to store any one of multiple values.",{lc_error_code:"INVALID_CONCURRENT_GRAPH_UPDATE"});return this._value=$[$.length-1],!0}get(){if(this._value===C8)throw new v;return this._value}checkpoint(){}isAvailable(){return this._value!==C8}};var f8=class Q extends l{lc_graph_name="Topic";unique=!1;accumulate=!1;seen;values;constructor($){super();this.unique=$?.unique??this.unique,this.accumulate=$?.accumulate??this.accumulate,this.seen=new Set,this.values=[]}fromCheckpoint($){let J=new Q({unique:this.unique,accumulate:this.accumulate});if(typeof $<"u")J.seen=new Set($[0]),J.values=$[1];return J}update($){let J=!1;if(!this.accumulate)J=this.values.length>0,this.values=[];let Z=$.flat();if(Z.length>0)if(this.unique){for(let q of Z)if(!this.seen.has(q))J=!0,this.seen.add(q),this.values.push(q)}else J=!0,this.values.push(...Z);return J}get(){if(this.values.length===0)throw new v;return this.values}checkpoint(){return[[...this.seen],this.values]}isAvailable(){return this.values.length!==0}};var VQ=class Q extends l{lc_graph_name="EphemeralValue";guard;value=[];constructor($=!0){super();this.guard=$}fromCheckpoint($){let J=new Q(this.guard);if(typeof $<"u")J.value=[$];return J}update($){if($.length===0){let J=this.value.length>0;return this.value=[],J}if($.length!==1&&this.guard)throw new w("EphemeralValue can only receive one value per step.");return this.value=[$[$.length-1]],!0}get(){if(this.value.length===0)throw new v;return this.value[0]}checkpoint(){if(this.value.length===0)throw new v;return this.value[0]}isAvailable(){return this.value.length!==0}};var cQ=(Q,$)=>Q.size===$.size&&[...Q].every((J)=>$.has(J)),k8=class Q extends l{lc_graph_name="NamedBarrierValue";names;seen;constructor($){super();this.names=$,this.seen=new Set}fromCheckpoint($){let J=new Q(this.names);if(typeof $<"u")J.seen=new Set($);return J}update($){let J=!1;for(let Z of $)if(this.names.has(Z)){if(!this.seen.has(Z))this.seen.add(Z),J=!0}else throw new w(`Value ${JSON.stringify(Z)} not in names ${JSON.stringify(this.names)}`);return J}get(){if(!cQ(this.names,this.seen))throw new v}checkpoint(){return[...this.seen]}consume(){if(this.seen&&this.names&&cQ(this.seen,this.names))return this.seen=new Set,!0;return!1}isAvailable(){return!!this.names&&cQ(this.names,this.seen)}},g8=class Q extends l{lc_graph_name="NamedBarrierValueAfterFinish";names;seen;finished;constructor($){super();this.names=$,this.seen=new Set,this.finished=!1}fromCheckpoint($){let J=new Q(this.names);if(typeof $<"u"){let[Z,q]=$;J.seen=new Set(Z),J.finished=q}return J}update($){let J=!1;for(let Z of $)if(this.names.has(Z)&&!this.seen.has(Z))this.seen.add(Z),J=!0;else if(!this.names.has(Z))throw new w(`Value ${JSON.stringify(Z)} not in names ${JSON.stringify(this.names)}`);return J}get(){if(!this.finished||!cQ(this.names,this.seen))throw new v}checkpoint(){return[[...this.seen],this.finished]}consume(){if(this.finished&&this.seen&&this.names&&cQ(this.seen,this.names))return this.seen=new Set,this.finished=!1,!0;return!1}finish(){if(!this.finished&&!!this.names&&cQ(this.names,this.seen))return this.finished=!0,!0;return!1}isAvailable(){return this.finished&&!!this.names&&cQ(this.names,this.seen)}};var _$=Symbol.for("langgraph.state.untracked_value"),IQ=class{[_$]=!0;schema;guard;constructor(Q,$){this.schema=Q,this.guard=$?.guard??!0}static isInstance(Q){return typeof Q==="object"&&Q!==null&&_$ in Q}};var m8=Symbol.for("langgraph.state.state_schema"),LQ=class{[m8]=!0;constructor(Q){this.fields=Q}getChannels(){let Q={};for(let[$,J]of Object.entries(this.fields))if(BQ.isInstance(J)){let Z=NQ(J.valueSchema);Q[$]=new bQ(J.reducer,Z)}else if(IQ.isInstance(J)){let Z=J.schema?NQ(J.schema):void 0;Q[$]=new R0({guard:J.guard,initialValueFactory:Z})}else if(SQ(J))Q[$]=new UQ(NQ(J));else throw Error(`Invalid state field "${$}": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`);return Q}getJsonSchema(){let Q={},$=[];for(let[J,Z]of Object.entries(this.fields)){let q;if(BQ.isInstance(Z)){if(q=_Q(Z.valueSchema),Z.jsonSchemaExtra)q={...q??{},...Z.jsonSchemaExtra}}else if(IQ.isInstance(Z))q=Z.schema?_Q(Z.schema):void 0;else if(SQ(Z))q=_Q(Z);if(q){Q[J]=q;let z=!1;if(BQ.isInstance(Z))z=NQ(Z.valueSchema)!==void 0;else if(IQ.isInstance(Z))z=Z.schema?NQ(Z.schema)!==void 0:!1;else z=NQ(Z)!==void 0;if(!z)$.push(J)}}return{type:"object",properties:Q,required:$.length>0?$:void 0}}getInputJsonSchema(){let Q={};for(let[$,J]of Object.entries(this.fields)){let Z;if(BQ.isInstance(J))Z=_Q(J.inputSchema);else if(IQ.isInstance(J))Z=J.schema?_Q(J.schema):void 0;else if(SQ(J))Z=_Q(J);if(Z)Q[$]=Z}return{type:"object",properties:Q}}getChannelKeys(){return Object.entries(this.fields).map(([Q])=>Q)}getAllKeys(){return Object.keys(this.fields)}async validateInput(Q){if(Q==null||typeof Q!=="object")return Q;let $={};for(let[J,Z]of Object.entries(Q)){let q=this.fields[J];if(q===void 0){$[J]=Z;continue}let z;if(BQ.isInstance(q))z=q.inputSchema;else if(IQ.isInstance(q))z=q.schema;else if(SQ(q))z=q;if(z){let Y=await z["~standard"].validate(Z);if(Y.issues)throw Error(`Validation failed for field "${J}": ${JSON.stringify(Y.issues)}`);$[J]=Y.value}else $[J]=Z}return $}static isInstance(Q){return typeof Q==="object"&&Q!==null&&m8 in Q&&Q[m8]===!0}};import{AsyncLocalStorage as r1}from"node:async_hooks";function N$(){QQ.initializeGlobalInstance(new r1)}var T0=class{lc_graph_name="AnnotationRoot";spec;constructor(Q){this.spec=Q}static isInstance(Q){return typeof Q==="object"&&Q!==null&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot"}},Q0=function(Q){if(Q)return a0(Q);else return new UQ};Q0.Root=(Q)=>new T0(Q);function a0(Q){if(typeof Q==="object"&&Q&&"reducer"in Q&&Q.reducer)return new bQ(Q.reducer,Q.default);if(typeof Q==="object"&&Q&&"value"in Q&&Q.value)return new bQ(Q.value,Q.default);return new UQ}var n1=["tags","metadata","callbacks","configurable"],s1=["tags","metadata","callbacks","runName","maxConcurrency","recursionLimit","configurable","runId","outputKeys","streamMode","store","writer","interrupt","context","interruptBefore","interruptAfter","checkpointDuring","durability","signal"],t1=25;function b0(...Q){let $={tags:[],metadata:{},callbacks:void 0,recursionLimit:t1,configurable:{}},J=QQ.getRunnableConfig();if(J!==void 0){for(let[Z,q]of Object.entries(J))if(q!==void 0)if(n1.includes(Z)){let z;if(Array.isArray(q))z=[...q];else if(typeof q==="object")if(Z==="callbacks"&&"copy"in q&&typeof q.copy==="function")z=q.copy();else z={...q};else z=q;$[Z]=z}else $[Z]=q}for(let Z of Q){if(Z===void 0)continue;for(let[q,z]of Object.entries(Z))if(z!==void 0&&s1.includes(q))$[q]=z}for(let[Z,q]of Object.entries($.configurable))if($.metadata=$.metadata??{},!Z.startsWith("__")&&(typeof q==="string"||typeof q==="number"||typeof q==="boolean")&&!(Z in $.metadata))$.metadata[Z]=q;return $}function h8(){return QQ.getRunnableConfig()}function a1(Q){let $=Q??QQ.getRunnableConfig();if($===void 0)throw Error(["Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.","If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly."].join(`
5
+ `));if($.configurable?.[JQ]?.currentTaskInput===void 0)throw Error("BUG: internal scratchpad not initialized.");return $.configurable[JQ].currentTaskInput}function e0(Q){return Q.split(k).filter(($)=>!$.match(/^\d+$/)).map(($)=>$.split(e)[0]).join(k)}function I$(Q){let $=Q.split(k);while($.length>1&&$[$.length-1].match(/^\d+$/))$.pop();return $.slice(0,-1).join(k)}var s=class extends YQ{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;constructor(Q){super();this.name=Q.name??Q.func.name,this.func=Q.func,this.config=Q.tags?{tags:Q.tags}:void 0,this.trace=Q.trace??this.trace,this.recurse=Q.recurse??this.recurse}async _tracedInvoke(Q,$,J){return new Promise((Z,q)=>{let z=iQ($,{callbacks:J?.getChild()});QQ.runWithConfig(z,async()=>{try{Z(await this.func(Q,z))}catch(Y){q(Y)}})})}async invoke(Q,$){let J,Z=b0($),q=DQ(this.config,Z);if(this.trace)J=await this._callWithConfig(this._tracedInvoke,Q,q);else J=await QQ.runWithConfig(q,async()=>this.func(Q,q));if(YQ.isRunnable(J)&&this.recurse)return await QQ.runWithConfig(q,async()=>J.invoke(Q,q));return J}};function*CQ(Q,$){if($===void 0)yield*Q;else for(let J of Q)yield[$,J]}async function GQ(Q){let $=[];for await(let J of await Q)$.push(J);return $}function $0(Q){let $=[];for(let J of Q)$.push(J);return $}function J0(Q,$){if(!Q)return{configurable:$};else if(!("configurable"in Q))return{...Q,configurable:$};else return{...Q,configurable:{...Q.configurable,...$}}}function y$(Q){return Q!=null&&typeof Q==="function"&&Q instanceof Object.getPrototypeOf(async function*(){}).constructor}function E$(Q){return Q!=null&&typeof Q==="function"&&Q instanceof Object.getPrototypeOf(function*(){}).constructor}var IZ={[Symbol.for("LG_SKIP_WRITE")]:!0};function e1(Q){return typeof Q==="object"&&Q?.[Symbol.for("LG_SKIP_WRITE")]!==void 0}var qQ={[Symbol.for("LG_PASSTHROUGH")]:!0};function Q8(Q){return typeof Q==="object"&&Q?.[Symbol.for("LG_PASSTHROUGH")]!==void 0}var u8=Symbol("IS_WRITER"),h=class Q extends s{writes;constructor($,J){let Z=`ChannelWrite<${$.map((q)=>{if(d(q))return q.node;else if("channel"in q)return q.channel;return"..."}).join(",")}>`;super({writes:$,name:Z,tags:J,trace:!1,func:async(q,z)=>{return this._write(q,z??{})}});this.writes=$}async _write($,J){let Z=this.writes.map((q)=>{if(d8(q)&&Q8(q.value))return{mapper:q.mapper,value:$};else if($8(q)&&Q8(q.value))return{channel:q.channel,value:$,skipNone:q.skipNone,mapper:q.mapper};else return q});return await Q.doWrite(J,Z),$}static async doWrite($,J){for(let z of J){if($8(z)){if(z.channel===c)throw new w("Cannot write to the reserved channel TASKS");if(Q8(z.value))throw new w("PASSTHROUGH value must be replaced")}if(d8(z)){if(Q8(z.value))throw new w("PASSTHROUGH value must be replaced")}}let Z=[];for(let z of J)if(d(z))Z.push([c,z]);else if(d8(z)){let Y=await z.mapper.invoke(z.value,$);if(Y!=null&&Y.length>0)Z.push(...Y)}else if($8(z)){let Y=z.mapper!==void 0?await z.mapper.invoke(z.value,$):z.value;if(e1(Y))continue;if(z.skipNone&&Y===void 0)continue;Z.push([z.channel,Y])}else throw Error(`Invalid write entry: ${JSON.stringify(z)}`);let q=$.configurable?.[WQ];q(Z)}static isWriter($){return $ instanceof Q||u8 in $&&!!$[u8]}static registerWriter($){return Object.defineProperty($,u8,{value:!0})}};function $8(Q){return Q!==void 0&&typeof Q.channel==="string"}function d8(Q){return Q!==void 0&&!$8(Q)&&YQ.isRunnable(Q.mapper)}var f$=class Q extends s{lc_graph_name="ChannelRead";channel;fresh=!1;mapper;constructor($,J,Z=!1){super({trace:!1,func:(q,z)=>Q.doRead(z,this.channel,this.fresh,this.mapper)});this.fresh=Z,this.mapper=J,this.channel=$,this.name=Array.isArray($)?`ChannelRead<${$.join(",")}>`:`ChannelRead<${$}>`}static doRead($,J,Z,q){let z=$.configurable?.[AQ];if(!z)throw Error("Runnable is not configured with a read function. Make sure to call in the context of a Pregel process");if(q)return q(z(J,Z));else return z(J,Z)}},j0=new C$,KQ=class Q extends v${lc_graph_name="PregelNode";channels;triggers=[];mapper;writers=[];bound=j0;kwargs={};metadata={};tags=[];retryPolicy;cachePolicy;subgraphs;ends;constructor($){let{channels:J,triggers:Z,mapper:q,writers:z,bound:Y,kwargs:X,metadata:B,retryPolicy:F,cachePolicy:W,tags:L,subgraphs:H,ends:j}=$,U=[...$.config?.tags?$.config.tags:[],...L??[]];super({...$,bound:$.bound??j0,config:{...$.config?$.config:{},tags:U}});this.channels=J,this.triggers=Z,this.mapper=q,this.writers=z??this.writers,this.bound=Y??this.bound,this.kwargs=X??this.kwargs,this.metadata=B??this.metadata,this.tags=U,this.retryPolicy=F,this.cachePolicy=W,this.subgraphs=H,this.ends=j}getWriters(){let $=[...this.writers];while($.length>1&&$[$.length-1]instanceof h&&$[$.length-2]instanceof h){let J=$.slice(-2),Z=J[0].writes.concat(J[1].writes);$[$.length-2]=new h(Z,J[0].config?.tags),$.pop()}return $}getNode(){let $=this.getWriters();if(this.bound===j0&&$.length===0)return;else if(this.bound===j0&&$.length===1)return $[0];else if(this.bound===j0)return new Z0({first:$[0],middle:$.slice(1,$.length-1),last:$[$.length-1],omitSequenceTags:!0});else if($.length>0)return new Z0({first:this.bound,middle:$.slice(0,$.length-1),last:$[$.length-1],omitSequenceTags:!0});else return this.bound}join($){if(!Array.isArray($))throw Error("channels must be a list");if(typeof this.channels!=="object")throw Error("all channels must be named when using .join()");return new Q({channels:{...this.channels,...Object.fromEntries($.map((J)=>[J,J]))},triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound,kwargs:this.kwargs,config:this.config,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}pipe($){if(h.isWriter($))return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:[...this.writers,$],bound:this.bound,config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy});else if(this.bound===j0)return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:yQ($),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy});else return new Q({channels:this.channels,triggers:this.triggers,mapper:this.mapper,writers:this.writers,bound:this.bound.pipe($),config:this.config,kwargs:this.kwargs,retryPolicy:this.retryPolicy,cachePolicy:this.cachePolicy})}};function Q6(Q){return"steps"in Q&&Array.isArray(Q.steps)}function S0(Q){return"lg_is_pregel"in Q&&Q.lg_is_pregel===!0}function J8(Q){let $=[Q];for(let J of $)if(S0(J))return J;else if(Q6(J))$.push(...J.steps)}function q0(Q,$,J=!0,Z=!1){try{return Q[$].get()}catch(q){if(q.name===v.unminifiable_name){if(Z)return q;else if(J)return null}throw q}}function MQ(Q,$,J=!0){if(Array.isArray($)){let Z={};for(let q of $)try{Z[q]=q0(Q,q,!J)}catch(z){if(z.name===v.unminifiable_name)continue}return Z}else return q0(Q,$)}function*k$(Q,$){if(Q.graph===a.PARENT)throw new w("There is no parent graph.");if(Q.goto){let J;if(Array.isArray(Q.goto))J=Q.goto;else J=[Q.goto];for(let Z of J)if(d(Z))yield[n,c,Z];else if(typeof Z==="string")yield[n,`branch:to:${Z}`,"__start__"];else throw Error(`In Command.send, expected Send or string, got ${typeof Z}`)}if(Q.resume)if(typeof Q.resume==="object"&&Object.keys(Q.resume).length&&Object.keys(Q.resume).every(t0))for(let[J,Z]of Object.entries(Q.resume)){let q=$.filter((z)=>z[0]===J&&z[1]===o).map((z)=>z[2]).slice(0,1)??[];q.push(Z),yield[J,o,q]}else yield[n,o,Q.resume];if(Q.update){if(typeof Q.update!=="object"||!Q.update)throw Error("Expected cmd.update to be a dict mapping channel names to update values");if(Array.isArray(Q.update))for(let[J,Z]of Q.update)yield[n,J,Z];else for(let[J,Z]of Object.entries(Q.update))yield[n,J,Z]}}function*Z8(Q,$){if($!==void 0&&$!==null)if(Array.isArray(Q)&&typeof $==="object"&&!Array.isArray($)){for(let J in $)if(Q.includes(J))yield[J,$[J]]}else if(Array.isArray(Q))throw Error('Input chunk must be an object when "inputChannels" is an array');else yield[Q,$]}function*q8(Q,$,J){if(Array.isArray(Q)){if($===!0||$.find(([Z,q])=>Q.includes(Z)))yield MQ(J,Q)}else if($===!0||$.some(([Z,q])=>Z===Q))yield q0(J,Q)}function*g$(Q,$,J){let Z=$.filter(([X,B])=>{return(X.config===void 0||!X.config.tags?.includes(E))&&B[0][0]!==p&&B[0][0]!==S});if(!Z.length)return;let q;if(Z.some(([X])=>X.writes.some(([B,F])=>B===jQ)))q=Z.flatMap(([X])=>X.writes.filter(([B,F])=>B===jQ).map(([B,F])=>[X.name,F]));else if(!Array.isArray(Q))q=Z.flatMap(([X])=>X.writes.filter(([B,F])=>B===Q).map(([B,F])=>[X.name,F]));else q=Z.flatMap(([X])=>{let{writes:B}=X,F={};for(let[W]of B)if(Q.includes(W))F[W]=(F[W]||0)+1;if(Object.values(F).some((W)=>W>1))return B.filter(([W])=>Q.includes(W)).map(([W,L])=>[X.name,{[W]:L}]);else return[[X.name,Object.fromEntries(B.filter(([W])=>Q.includes(W)))]]});let z={};for(let[X,B]of q){if(!(X in z))z[X]=[];z[X].push(B)}let Y={};for(let X in z)if(z[X].length===1){let[B]=z[X];Y[X]=B}else Y[X]=z[X];if(J)Y.__metadata__={cached:J};yield Y}function z8(Q){let $=typeof Q[T];if($==="number")return 0;if($==="string")return"";for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;let Z=typeof Q[J];if(Z==="number")return 0;if(Z==="string")return"";break}}function H0(Q,$){if(Object.keys(Q).length>0){let J=z8($);return Object.fromEntries(Object.entries($).filter(([Z,q])=>q>(Q[Z]??J)))}else return $}function m$(Q,$){return Q&&!Array.isArray(Q)&&!(Q instanceof Date)&&typeof Q==="object"?Q:{[$]:Q}}function zQ(Q,$){if(Q===null)return{configurable:$};else if(Q?.configurable===void 0)return{...Q,configurable:$};else return{...Q,configurable:{...Q.configurable,...$}}}function rQ(Q,$){let J=$?.parents??{};if(Object.keys(J).length>0)return zQ(Q,{[ZQ]:{...J,[Q.configurable?.checkpoint_ns??""]:Q.configurable?.checkpoint_id}});else return Q}function U0(...Q){let $=[...new Set(Q.filter(Boolean))];if($.length===0)return{signal:void 0,dispose:void 0};if($.length===1)return{signal:$[0],dispose:void 0};let J=new AbortController,Z=()=>{let z=$.find((Y)=>Y.aborted)?.reason;J.abort(z),$.forEach((Y)=>Y.removeEventListener("abort",Z))};$.forEach((z)=>z.addEventListener("abort",Z,{once:!0}));let q=$.find((z)=>z.aborted);if(q)J.abort(q.reason);return{signal:J.signal,dispose:()=>{$.forEach((z)=>z.removeEventListener("abort",Z))}}}var h$=(Q,$)=>{if(!Q&&!$)return;if(!Q)return $;if(!$)return Q;if(Array.isArray(Q)&&Array.isArray($))return[...Q,...$];if(Array.isArray(Q))return[...Q,$];if(Array.isArray($))return[Q,...$];return[Q,$]};var u$=class{func;name;input;retry;cache;callbacks;__lg_type="call";constructor({func:Q,name:$,input:J,retry:Z,cache:q,callbacks:z}){this.func=Q,this.name=$,this.input=J,this.retry=Z,this.cache=q,this.callbacks=z}};function d$(Q){return typeof Q==="object"&&Q!==null&&"__lg_type"in Q&&Q.__lg_type==="call"}function p$(Q,$){return new Z0({name:Q,first:new s({func:(J)=>$(...J),name:Q,trace:!1,recurse:!1}),last:new h([{channel:jQ,value:qQ}],[E])})}function l$(Q,$){return new s({func:(J,Z)=>{return $(J,Z)},name:Q,trace:!1,recurse:!1})}var c$=(Q)=>{return Q!==void 0?Q+1:1};function $6(Q,$){if($==null)return!1;for(let J of Q)if($[J])return!0;return!1}function J6(Q){let $;for(let J in Q){if(!Object.prototype.hasOwnProperty.call(Q,J))continue;if($==null)$=Q[J];else $=o$($,Q[J])}return $}function N0(Q,$,J){let Z=z8(Q.channel_versions),q=Q.versions_seen[S]??{},z=!1;if((Q.channel_versions[T]??Z)>(q[T]??Z))z=!0;else for(let X in Q.channel_versions){if(!Object.prototype.hasOwnProperty.call(Q.channel_versions,X))continue;if(Q.channel_versions[X]>(q[X]??Z)){z=!0;break}}let Y=J.some((X)=>$==="*"?!X.config?.tags?.includes(E):$.includes(X.name));return z&&Y}function _0(Q,$,J,Z,q=!1){let z=new Set;if(!Array.isArray(Z)){for(let[X]of J.writes)if(X===Z){z=new Set([X]);break}z=z||new Set}else z=new Set(Z.filter((X)=>J.writes.some(([B,F])=>B===X)));let Y;if(q&&z.size>0){let X=Object.fromEntries(Object.entries($).filter(([W,L])=>z.has(W))),B=HQ(Q,X,-1),F=oQ(X,B);$Q(fQ(B),F,[J],void 0,void 0),Y=MQ({...$,...F},Z)}else Y=MQ($,Z);return Y}function p8(Q,$,J){for(let[Z,q]of J)if([r,c].includes(Z)&&q!=null){if(!d(q))throw new w(`Invalid packet type, expected SendProtocol, got ${JSON.stringify(q)}`);if(!(q.node in $))throw new w(`Invalid node name "${q.node}" in Send packet`)}Q(J)}var Z6=new Set([m0,r,o,S,jQ,p]);function $Q(Q,$,J,Z,q){J.sort((H,j)=>{let U=H.path?.slice(0,3)||[],D=j.path?.slice(0,3)||[];for(let M=0;M<Math.min(U.length,D.length);M+=1){if(U[M]<D[M])return-1;if(U[M]>D[M])return 1}return U.length-D.length});let z=J.some((H)=>H.triggers.length>0),Y=w0($);for(let H of J){Q.versions_seen[H.name]??={};for(let j of H.triggers)if(j in Q.channel_versions)Q.versions_seen[H.name][j]=Q.channel_versions[j]}let X=J6(Q.channel_versions),B=new Set(J.flatMap((H)=>H.triggers).filter((H)=>!G$.includes(H))),F=!1;for(let H of B)if(H in Y&&Y[H].consume()){if(Z!==void 0)Q.channel_versions[H]=Z(X),F=!0}let W={};for(let H of J)for(let[j,U]of H.writes)if(Z6.has(j));else if(j in Y)W[j]??=[],W[j].push(U);if(X!=null&&Z!=null)X=F?Z(X):X;let L=new Set;for(let[H,j]of Object.entries(W))if(H in Y){let U=Y[H],D;try{D=U.update(j)}catch(M){if(M.name===w.unminifiable_name){let O=new w(`Invalid update for channel "${H}" with values ${JSON.stringify(j)}: ${M.message}`);throw O.lc_error_code=M.lc_error_code,O}else throw M}if(D&&Z!==void 0){if(Q.channel_versions[H]=Z(X),U.isAvailable())L.add(H)}}if(z)for(let H in Y){if(!Object.prototype.hasOwnProperty.call(Y,H))continue;let j=Y[H];if(j.isAvailable()&&!L.has(H)){if(j.update([])&&Z!==void 0){if(Q.channel_versions[H]=Z(X),j.isAvailable())L.add(H)}}}if(z&&!$6(L,q))for(let H in Y){if(!Object.prototype.hasOwnProperty.call(Y,H))continue;let j=Y[H];if(j.finish()&&Z!==void 0){if(Q.channel_versions[H]=Z(X),j.isAvailable())L.add(H)}}return L}function*q6(Q,$,J){if(J.updatedChannels!=null&&J.triggerToNodes!=null){let Z=new Set;for(let q of J.updatedChannels){let z=J.triggerToNodes[q];for(let Y of z??[])Z.add(Y)}yield*[...Z].sort();return}if((()=>{for(let Z in Q.channel_versions)if(Q.channel_versions[Z]!==null)return!1;return!0})())return;for(let Z in $){if(!Object.prototype.hasOwnProperty.call($,Z))continue;yield Z}}function sQ(Q,$,J,Z,q,z,Y){let X={},B=Z[c];if(B?.isAvailable()){let F=B.get().length;for(let W=0;W<F;W+=1){let L=Y8([r,W],Q,$,J,Z,q,z,Y);if(L!==void 0)X[L.id]=L}}for(let F of q6(Q,J,Y)){let W=Y8([x0,F],Q,$,J,Z,q,z,Y);if(W!==void 0)X[W.id]=W}return X}function Y8(Q,$,J,Z,q,z,Y,X){let{step:B,checkpointer:F,manager:W}=X,L=z.configurable??{},H=L.checkpoint_ns??"";if(Q[0]===r&&d$(Q[Q.length-1])){let j=Q[Q.length-1],U=p$(j.name,j.func),D=[r],M=H===""?j.name:`${H}${k}${j.name}`,O=nQ(JSON.stringify([M,B.toString(),j.name,r,Q[1],Q[2]]),$.id),_=`${M}${e}${O}`,P=[...Q.slice(0,3),!0],I={langgraph_step:B,langgraph_node:j.name,langgraph_triggers:D,langgraph_path:P,langgraph_checkpoint_ns:_};if(Y){let N=[];return{name:j.name,input:j.input,proc:U,writes:N,config:iQ(DQ(z,{metadata:I,store:X.store??z.store}),{runName:j.name,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[Y0]:O,[WQ]:(f)=>p8((K)=>N.push(...K),Z,f),[AQ]:(f,K=!1)=>_0($,q,{name:j.name,writes:N,triggers:D,path:P},f,K),[m]:F??L[m],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:l8({pendingWrites:J??[],taskId:O,currentTaskInput:j.input,resumeMap:z.configurable?.[X0],namespaceHash:vQ(_)}),[M0]:$.channel_values[aQ],checkpoint_id:void 0,checkpoint_ns:_}}),triggers:D,retry_policy:j.retry,cache_key:j.cache?{key:vQ((j.cache.keyFunc??JSON.stringify)([j.input])),ns:[k0,j.name??"__dynamic__"],ttl:j.cache.ttl}:void 0,id:O,path:P,writers:[]}}else return{id:O,name:j.name,interrupts:[],path:P}}else if(Q[0]===r){let j=typeof Q[1]==="number"?Q[1]:parseInt(Q[1],10);if(!q[c]?.isAvailable())return;let U=q[c].get();if(j<0||j>=U.length)return;let D=u0(U[j])&&!d(U[j])?new uQ(U[j].node,U[j].args):U[j];if(!u0(D)){console.warn(`Ignoring invalid packet ${JSON.stringify(D)} in pending sends.`);return}if(!(D.node in Z)){console.warn(`Ignoring unknown node name ${D.node} in pending sends.`);return}let M=[r],O=H===""?D.node:`${H}${k}${D.node}`,_=nQ(JSON.stringify([O,B.toString(),D.node,r,j.toString()]),$.id),P=`${O}${e}${_}`,I={langgraph_step:B,langgraph_node:D.node,langgraph_triggers:M,langgraph_path:Q.slice(0,3),langgraph_checkpoint_ns:P};if(Y){let N=Z[D.node],f=N.getNode();if(f!==void 0){if(N.metadata!==void 0)I={...I,...N.metadata};let K=[];return{name:D.node,input:D.args,proc:f,subgraphs:N.subgraphs,writes:K,config:iQ(DQ(z,{metadata:I,tags:N.tags,store:X.store??z.store}),{runName:D.node,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[Y0]:_,[WQ]:(x)=>p8((b)=>K.push(...b),Z,x),[AQ]:(x,b=!1)=>_0($,q,{name:D.node,writes:K,triggers:M,path:Q},x,b),[m]:F??L[m],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:l8({pendingWrites:J??[],taskId:_,currentTaskInput:D.args,resumeMap:z.configurable?.[X0],namespaceHash:vQ(P)}),[M0]:$.channel_values[aQ],checkpoint_id:void 0,checkpoint_ns:P}}),triggers:M,retry_policy:N.retryPolicy,cache_key:N.cachePolicy?{key:vQ((N.cachePolicy.keyFunc??JSON.stringify)([D.args])),ns:[k0,N.name??"__dynamic__",D.node],ttl:N.cachePolicy.ttl}:void 0,id:_,path:Q,writers:N.getWriters()}}}else return{id:_,name:D.node,interrupts:[],path:Q}}else if(Q[0]===x0){let j=Q[1].toString(),U=Z[j];if(U===void 0)return;if(J?.length){let _=H===""?j:`${H}${k}${j}`,P=nQ(JSON.stringify([_,B.toString(),j,x0,j]),$.id);if(J.some((I)=>I[0]===P&&I[1]!==p))return}let D=z8($.channel_versions);if(D===void 0)return;let M=$.versions_seen[j]??{},O=U.triggers.find((_)=>{if(!q[_].isAvailable())return!1;return($.channel_versions[_]??D)>(M[_]??D)});if(O!==void 0){let _=z6(U,q,Y);if(_===void 0)return;let P=H===""?j:`${H}${k}${j}`,I=nQ(JSON.stringify([P,B.toString(),j,x0,[O]]),$.id),N=`${P}${e}${I}`,f={langgraph_step:B,langgraph_node:j,langgraph_triggers:[O],langgraph_path:Q,langgraph_checkpoint_ns:N};if(Y){let K=U.getNode();if(K!==void 0){if(U.metadata!==void 0)f={...f,...U.metadata};let x=[];return{name:j,input:_,proc:K,subgraphs:U.subgraphs,writes:x,config:iQ(DQ(z,{metadata:f,tags:U.tags,store:X.store??z.store}),{runName:j,callbacks:W?.getChild(`graph:step:${B}`),configurable:{[Y0]:I,[WQ]:(b)=>p8((G)=>{x.push(...G)},Z,b),[AQ]:(b,G=!1)=>_0($,q,{name:j,writes:x,triggers:[O],path:Q},b,G),[m]:F??L[m],[ZQ]:{...L[ZQ],[H]:$.id},[JQ]:l8({pendingWrites:J??[],taskId:I,currentTaskInput:_,resumeMap:z.configurable?.[X0],namespaceHash:vQ(N)}),[M0]:$.channel_values[aQ],checkpoint_id:void 0,checkpoint_ns:N}}),triggers:[O],retry_policy:U.retryPolicy,cache_key:U.cachePolicy?{key:vQ((U.cachePolicy.keyFunc??JSON.stringify)([_])),ns:[k0,U.name??"__dynamic__",j],ttl:U.cachePolicy.ttl}:void 0,id:I,path:Q,writers:U.getWriters()}}}else return{id:I,name:j,interrupts:[],path:Q}}}}function z6(Q,$,J){let Z;if(typeof Q.channels==="object"&&!Array.isArray(Q.channels)){Z={};for(let[q,z]of Object.entries(Q.channels))if(Q.triggers.includes(z))try{Z[q]=q0($,z,!1)}catch(Y){if(Y.name===v.unminifiable_name)return;else throw Y}else if(z in $)try{Z[q]=q0($,z,!1)}catch(Y){if(Y.name===v.unminifiable_name)continue;else throw Y}}else if(Array.isArray(Q.channels)){let q=!1;for(let z of Q.channels)try{Z=q0($,z,!1),q=!0;break}catch(Y){if(Y.name===v.unminifiable_name)continue;else throw Y}if(!q)return}else throw Error(`Invalid channels type, expected list or dict, got ${Q.channels}`);if(J&&Q.mapper!==void 0)Z=Q.mapper(Z);return Z}function i$(Q,$){if(typeof Q.args!=="object"||Q.args===null)return Q;let J={};for(let[Z,q]of Object.entries(Q.args)){let z=$[Z];if(!z||z.lc_graph_name!=="UntrackedValue")J[Z]=q}return new uQ(Q.node,J)}function l8({pendingWrites:Q,taskId:$,currentTaskInput:J,resumeMap:Z,namespaceHash:q}){let z=Q.find(([X,B])=>X===n&&B===o)?.[2],Y={callCounter:0,interruptCounter:-1,resume:(()=>{let X=Q.filter(([B,F])=>B===$&&F===o).flatMap(([B,F,W])=>W);if(Z!=null&&q in Z){let B=Z[q];X.push(B)}return X})(),nullResume:z,subgraphCounter:0,currentTaskInput:J,consumeNullResume:()=>{if(Y.nullResume)return delete Y.nullResume,Q.splice(Q.findIndex(([X,B])=>X===n&&B===o),1),z}};return Y}var I0={blue:{start:"\x1B[34m",end:"\x1B[0m"},green:{start:"\x1B[32m",end:"\x1B[0m"},yellow:{start:"\x1B[33;1m",end:"\x1B[0m"}},y0=(Q,$)=>`${Q.start}${$}${Q.end}`;function*o8(Q){for(let{id:$,name:J,input:Z,config:q,triggers:z,writes:Y}of Q){if(q?.tags?.includes(E))continue;yield{id:$,name:J,input:Z,triggers:z,interrupts:Y.filter(([X,B])=>{return X===$&&B===S}).map(([,X])=>{return X})}}}function Y6(Q){if(typeof Q!=="object"||Q===null)return!1;return"$writes"in Q&&Array.isArray(Q.$writes)}function r$(Q){let $={};for(let[J,Z]of Q){let q=String(J);if(q in $){let z=Y6($[q])?$[q].$writes:[$[q]];z.push(Z),$[q]={$writes:z}}else $[q]=Z}return $}function*n$(Q,$){for(let[{id:J,name:Z,config:q},z]of Q){if(q?.tags?.includes(E))continue;yield{id:J,name:Z,result:r$(z.filter(([Y])=>{return Array.isArray($)?$.includes(Y):Y===$})),interrupts:z.filter((Y)=>Y[0]===S).map((Y)=>Y[1])}}}function*s$(Q,$,J,Z,q,z,Y,X){function B(L){let H={};if(L.callbacks!=null)H.callbacks=L.callbacks;if(L.configurable!=null)H.configurable=L.configurable;if(L.maxConcurrency!=null)H.max_concurrency=L.maxConcurrency;if(L.metadata!=null)H.metadata=L.metadata;if(L.recursionLimit!=null)H.recursion_limit=L.recursionLimit;if(L.runId!=null)H.run_id=L.runId;if(L.runName!=null)H.run_name=L.runName;if(L.tags!=null)H.tags=L.tags;return H}let F=Q.configurable?.checkpoint_ns,W={};for(let L of q){if(!((L.subgraphs?.length)?L.subgraphs:[L.proc]).find(J8))continue;let H=`${L.name}:${L.id}`;if(F)H=`${F}|${H}`;W[L.id]={configurable:{thread_id:Q.configurable?.thread_id,checkpoint_ns:H}}}yield{config:B(Q),values:MQ($,J),metadata:Z,next:q.map((L)=>L.name),tasks:c8(q,z,W,X),parentConfig:Y?B(Y):void 0}}function c8(Q,$,J,Z){return Q.map((q)=>{let z=$.find(([F,W])=>F===q.id&&W===p)?.[2],Y=$.filter(([F,W])=>F===q.id&&W===S).map(([,,F])=>F),X=(()=>{if(z||Y.length||!$.length)return;let F=$.findIndex(([W,L])=>W===q.id&&L===jQ);if(F>=0)return $[F][2];if(typeof Z==="string")return $.find(([W,L])=>W===q.id&&L===Z)?.[2];if(Array.isArray(Z)){let W=$.filter(([L,H])=>L===q.id&&Z.includes(H)).map(([,L,H])=>[L,H]);if(!W.length)return;return r$(W)}})();if(z)return{id:q.id,name:q.name,path:q.path,error:z,interrupts:Y,result:X};let B=J?.[q.id];return{id:q.id,name:q.name,path:q.path,interrupts:Y,...B!==void 0?{state:B}:{},result:X}})}function t$(Q,$,J){console.log([`${y0(I0.blue,`[${Q}:checkpoint]`)}`,`\x1B[1m State at the end of step ${Q}:\x1B[0m
6
+ `,JSON.stringify(MQ($,J),null,2)].join(""))}function X8(Q,$){let J=$.length;console.log([`${y0(I0.blue,`[${Q}:tasks]`)}`,`\x1B[1m Starting step ${Q} with ${J} task${J===1?"":"s"}:\x1B[0m
7
+ `,$.map((Z)=>`- ${y0(I0.green,String(Z.name))} -> ${JSON.stringify(Z.input,null,2)}`).join(`
8
+ `)].join(""))}function a$(Q,$,J){let Z={};for(let[q,z]of $)if(J.includes(q)){if(!Z[q])Z[q]=[];Z[q].push(z)}console.log([`${y0(I0.blue,`[${Q}:writes]`)}`,`\x1B[1m Finished step ${Q} with writes to ${Object.keys(Z).length} channel${Object.keys(Z).length!==1?"s":""}:\x1B[0m
9
+ `,Object.entries(Z).map(([q,z])=>`- ${y0(I0.yellow,q)} -> ${z.map((Y)=>JSON.stringify(Y)).join(", ")}`).join(`
10
+ `)].join(""))}var n8=class extends r8{_abortController;_innerReader;constructor(Q,$){let J=Q.getReader(),Z=$??new AbortController;super({start(q){return z();function z(){return J.read().then(({done:Y,value:X})=>{if(Y){q.close();return}return q.enqueue(X),z()})}}});this._abortController=Z,this._innerReader=J}async cancel(Q){this._abortController.abort(Q),this._innerReader.releaseLock()}get signal(){return this._abortController.signal}},B8=class extends r8{modes;controller;passthroughFn;_closed=!1;get closed(){return this._closed}constructor(Q){let $,J=new Promise((Z)=>{$=Z});super({start:(Z)=>{$(Z)}});J.then((Z)=>{this.controller=Z}),this.passthroughFn=Q.passthroughFn,this.modes=Q.modes}push(Q){this.passthroughFn?.(Q),this.controller.enqueue(Q)}close(){try{this.controller.close()}catch(Q){}finally{this._closed=!0}}error(Q){this.controller.error(Q)}},$1=class extends F8{name="StreamToolsHandler";streamFn;runs={};constructor(Q){super();this.streamFn=Q}handleToolStart(Q,$,J,Z,q,z,Y,X){if(!z||q&&q.includes(E))return;let B=z.langgraph_checkpoint_ns?.split("|")??[],F={ns:B,toolCallId:X,toolName:Y??"unknown",input:$};this.runs[J]=F,this.streamFn([B,"tools",{event:"on_tool_start",toolCallId:F.toolCallId,name:F.toolName,input:$}])}handleToolEvent(Q,$){let J=this.runs[$];if(!J)return;this.streamFn([J.ns,"tools",{event:"on_tool_event",toolCallId:J.toolCallId,name:J.toolName,data:Q}])}handleToolEnd(Q,$){let J=this.runs[$];if(delete this.runs[$],!J)return;this.streamFn([J.ns,"tools",{event:"on_tool_end",toolCallId:J.toolCallId,name:J.toolName,output:Q}])}handleToolError(Q,$){let J=this.runs[$];if(delete this.runs[$],!J)return;this.streamFn([J.ns,"tools",{event:"on_tool_error",toolCallId:J.toolCallId,name:J.toolName,error:Q}])}};function X6(Q){return JSON.stringify(Q,function($,J){let Z=this[$];if(Z!=null&&typeof Z==="object"&&"toDict"in Z&&typeof Z.toDict==="function"){let{type:q,data:z}=Z.toDict();return{...z,type:q}}return J})}function F6(Q){if(Q instanceof Error)return{error:Q.name,message:Q.message};return{error:"Error",message:JSON.stringify(Q)}}function s8(Q){if(typeof Q!=="object"||Q==null)return!1;return"configurable"in Q&&typeof Q.configurable==="object"&&Q.configurable!=null}function i8(Q){if(!s8(Q)||!Q.configurable.thread_id)return null;return{thread_id:Q.configurable.thread_id,checkpoint_ns:Q.configurable.checkpoint_ns||"",checkpoint_id:Q.configurable.checkpoint_id||null,checkpoint_map:Q.configurable.checkpoint_map||null}}function e$(Q){if(s8(Q)){let $=Object.fromEntries(Object.entries(Q.configurable).filter(([Z])=>!Z.startsWith("__"))),J={...Q,configurable:$};return delete J.callbacks,J}return Q}function Q1(Q){let $={...Q,checkpoint:i8(Q.config),parent_checkpoint:i8(Q.parentConfig),config:e$(Q.config),parent_config:e$(Q.parentConfig),tasks:Q.tasks.map((J)=>{if(s8(J.state)){let Z=i8(J.state);if(Z!=null){let q={...J,checkpoint:Z};return delete q.state,q}}return J})};return delete $.parentConfig,$}function J1(Q){let $=new TextEncoder;return new ReadableStream({async start(J){let Z=(q)=>{J.enqueue($.encode(`event: ${q.event}
11
+ data: ${X6(q.data)}
12
+
13
+ `))};try{for await(let q of Q){let[z,Y,X]=q,B=X;if(Y==="debug"){let F=X;if(F.type==="checkpoint")B={...F,payload:Q1(F.payload)}}if(Y==="checkpoints")B=Q1(X);Z({event:z?.length?`${Y}|${z.join("|")}`:Y,data:B})}}catch(q){Z({event:"error",data:F6(q)})}J.close()}})}var L8=Symbol.for("INPUT_DONE"),t8=Symbol.for("INPUT_RESUMING"),B6=25;function L6(...Q){return new B8({passthroughFn:($)=>{for(let J of Q)if(J.modes.has($[1]))J.push($)},modes:new Set(Q.flatMap(($)=>Array.from($.modes)))})}var W6=class extends q1{cache;queue=Promise.resolve();constructor(Q){super();this.cache=Q}async get(Q){return this.enqueueOperation("get",Q)}async set(Q){return this.enqueueOperation("set",Q)}async clear(Q){return this.enqueueOperation("clear",Q)}async stop(){await this.queue}enqueueOperation(Q,...$){let J=this.queue.then(()=>{return this.cache[Q](...$)});return this.queue=J.then(()=>{return},()=>{return}),J}},z1=class Q{input;output;config;checkpointer;checkpointerGetNextVersion;channels;checkpoint;checkpointIdSaved;checkpointConfig;checkpointMetadata;checkpointNamespace;checkpointPendingWrites=[];checkpointPreviousVersions;step;stop;durability;outputKeys;streamKeys;nodes;skipDoneTasks;prevCheckpointConfig;updatedChannels;status="pending";tasks={};stream;checkpointerPromises=[];isNested;_checkpointerChainedPromise=Promise.resolve();store;cache;manager;interruptAfter;interruptBefore;toInterrupt=[];debug=!1;triggerToNodes;get isResuming(){let $=!1;if(T in this.checkpoint.channel_versions)$=!0;else for(let X in this.checkpoint.channel_versions)if(Object.prototype.hasOwnProperty.call(this.checkpoint.channel_versions,X)){$=!0;break}let J=this.config.configurable?.[EQ]!==void 0&&this.config.configurable?.[EQ],Z=this.input===null||this.input===void 0,q=u(this.input)&&this.input.resume!=null,z=this.input===t8,Y=!this.isNested&&this.config.metadata?.run_id!==void 0&&this.checkpointMetadata?.run_id!==void 0&&this.config.metadata.run_id===this.checkpointMetadata?.run_id;return $&&(J||Z||q||z||Y)}constructor($){if(this.input=$.input,this.checkpointer=$.checkpointer,this.checkpointer!==void 0)this.checkpointerGetNextVersion=this.checkpointer.getNextVersion.bind(this.checkpointer);else this.checkpointerGetNextVersion=c$;this.checkpoint=$.checkpoint,this.checkpointMetadata=$.checkpointMetadata,this.checkpointPreviousVersions=$.checkpointPreviousVersions,this.channels=$.channels,this.checkpointPendingWrites=$.checkpointPendingWrites,this.step=$.step,this.stop=$.stop,this.config=$.config,this.checkpointConfig=$.checkpointConfig,this.isNested=$.isNested,this.manager=$.manager,this.outputKeys=$.outputKeys,this.streamKeys=$.streamKeys,this.nodes=$.nodes,this.skipDoneTasks=$.skipDoneTasks,this.store=$.store,this.cache=$.cache?new W6($.cache):void 0,this.stream=$.stream,this.checkpointNamespace=$.checkpointNamespace,this.prevCheckpointConfig=$.prevCheckpointConfig,this.interruptAfter=$.interruptAfter,this.interruptBefore=$.interruptBefore,this.durability=$.durability,this.debug=$.debug,this.triggerToNodes=$.triggerToNodes}static async initialize($){let{config:J,stream:Z}=$;if(Z!==void 0&&J.configurable?.[K0]!==void 0)Z=L6(Z,J.configurable[K0]);let q=J.configurable?!("checkpoint_id"in J.configurable):!0,z=J.configurable?.[JQ];if(J.configurable&&z){if(z.subgraphCounter>0)J=zQ(J,{[FQ]:[J.configurable[FQ],z.subgraphCounter.toString()].join(k)});z.subgraphCounter+=1}let Y=AQ in(J.configurable??{});if(!Y&&J.configurable?.checkpoint_ns!==void 0&&J.configurable?.checkpoint_ns!=="")J=zQ(J,{checkpoint_ns:"",checkpoint_id:void 0});let X=J;if(J.configurable?.[ZQ]!==void 0&&J.configurable?.[ZQ]?.[J.configurable?.checkpoint_ns])X=zQ(J,{checkpoint_id:J.configurable[ZQ][J.configurable?.checkpoint_ns]});let B=J.configurable?.checkpoint_ns?.split(k)??[],F=await $.checkpointer?.getTuple(X)??{config:J,checkpoint:V0(),metadata:{source:"input",step:-2,parents:{}},pendingWrites:[]};X={...J,...F.config,configurable:{checkpoint_ns:"",...J.configurable,...F.config.configurable}};let W=F.parentConfig,L=fQ(F.checkpoint),H={...F.metadata},j=F.pendingWrites??[],U=oQ($.channelSpecs,L),D=(H.step??0)+1,M=D+(J.recursionLimit??B6)+1,O={...L.channel_versions},_=$.store?new W8($.store):void 0;if(_)await _.start();return new Q({input:$.input,config:J,checkpointer:$.checkpointer,checkpoint:L,checkpointMetadata:H,checkpointConfig:X,prevCheckpointConfig:W,checkpointNamespace:B,channels:U,isNested:Y,manager:$.manager,skipDoneTasks:q,step:D,stop:M,checkpointPreviousVersions:O,checkpointPendingWrites:j,outputKeys:$.outputKeys??[],streamKeys:$.streamKeys??[],nodes:$.nodes,stream:Z,store:_,cache:$.cache,interruptAfter:$.interruptAfter,interruptBefore:$.interruptBefore,durability:$.durability,debug:$.debug,triggerToNodes:$.triggerToNodes})}_checkpointerPutAfterPrevious($){this._checkpointerChainedPromise=this._checkpointerChainedPromise.then(()=>{return this.checkpointer?.put($.config,$.checkpoint,$.metadata,$.newVersions)}),this.checkpointerPromises.push(this._checkpointerChainedPromise)}putWrites($,J){let Z=J;if(Z.length===0)return;if(Z.every(([B])=>(B in Z1)))Z=Array.from(new Map(Z.map((B)=>[B[0],B])).values());let q=!1;for(let B in this.channels)if(Object.prototype.hasOwnProperty.call(this.channels,B)){if(this.channels[B].lc_graph_name==="UntrackedValue"){q=!0;break}}let z=Z;if(q)z=Z.filter(([B])=>{let F=this.channels[B];return!F||F.lc_graph_name!=="UntrackedValue"}).map(([B,F])=>{if(B===c&&d(F))return[B,i$(F,this.channels)];return[B,F]});this.checkpointPendingWrites=this.checkpointPendingWrites.filter((B)=>B[0]!==$);for(let[B,F]of z)this.checkpointPendingWrites.push([$,B,F]);let Y=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??"",[w8]:this.checkpoint.id});if(this.durability!=="exit"&&this.checkpointer!=null)this.checkpointerPromises.push(this.checkpointer.putWrites(Y,z,$));if(this.tasks)this._outputWrites($,Z);if(!J.length||!this.cache||!this.tasks)return;let X=this.tasks[$];if(X==null||X.cache_key==null)return;if(J[0][0]===p||J[0][0]===S)return;this.cache.set([{key:[X.cache_key.ns,X.cache_key.key],value:X.writes,ttl:X.cache_key.ttl}])}_outputWrites($,J,Z=!1){let q=this.tasks[$];if(q!==void 0){if(q.config!==void 0&&(q.config.tags??[]).includes(E))return;if(J.length>0){if(J[0][0]===S){if(q.path?.[0]===r&&q.path?.[q.path.length-1]===!0)return;let z=J.filter((Y)=>Y[0]===S).flatMap((Y)=>Y[1]);this._emit([["updates",{[S]:z}],["values",{[S]:z}]])}else if(J[0][0]!==p)this._emit($0(CQ(g$(this.outputKeys,[[q,J]],Z),"updates")))}if(!Z)this._emit($0(CQ(n$([[q,J]],this.streamKeys),"tasks")))}}async _matchCachedWrites(){if(!this.cache)return[];let $=[],J=([Y,X])=>{return`ns:${Y.join(",")}|key:${X}`},Z=[],q={};for(let Y of Object.values(this.tasks))if(Y.cache_key!=null&&!Y.writes.length)Z.push([Y.cache_key.ns,Y.cache_key.key]),q[J([Y.cache_key.ns,Y.cache_key.key])]=Y;if(Z.length===0)return[];let z=await this.cache.get(Z);for(let{key:Y,value:X}of z){let B=q[J(Y)];if(B!=null)B.writes.push(...X),$.push({task:B,result:X})}return $}async tick($){if(this.store&&!this.store.isRunning)await this.store?.start();let{inputKeys:J=[]}=$;if(this.status!=="pending")throw Error(`Cannot tick when status is no longer "pending". Current status: "${this.status}"`);if(![L8,t8].includes(this.input))await this._first(J);else if(this.toInterrupt.length>0)throw this.status="interrupt_before",new PQ;else if(Object.values(this.tasks).every((q)=>q.writes.length>0)){let q=Object.values(this.tasks).flatMap((Y)=>Y.writes);this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes);let z=await GQ(CQ(q8(this.outputKeys,q,this.channels),"values"));if(this._emit(z),this.checkpointPendingWrites=[],await this._putCheckpoint({source:"loop"}),N0(this.checkpoint,this.interruptAfter,Object.values(this.tasks)))throw this.status="interrupt_after",new PQ;if(this.config.configurable?.[EQ]!==void 0)delete this.config.configurable?.[EQ]}else return!1;if(this.step>this.stop)return this.status="out_of_steps",!1;if(this.tasks=sQ(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step,checkpointer:this.checkpointer,isResuming:this.isResuming,manager:this.manager,store:this.store,stream:this.stream,triggerToNodes:this.triggerToNodes,updatedChannels:this.updatedChannels}),this.checkpointer)this._emit(await GQ(CQ(s$(this.checkpointConfig,this.channels,this.streamKeys,this.checkpointMetadata,Object.values(this.tasks),this.checkpointPendingWrites,this.prevCheckpointConfig,this.outputKeys),"checkpoints")));if(Object.values(this.tasks).length===0)return this.status="done",!1;if(this.skipDoneTasks&&this.checkpointPendingWrites.length>0){for(let[q,z,Y]of this.checkpointPendingWrites){if(z===p||z===S||z===o)continue;let X=Object.values(this.tasks).find((B)=>B.id===q);if(X)X.writes.push([z,Y])}for(let q of Object.values(this.tasks))if(q.writes.length>0)this._outputWrites(q.id,q.writes,!0)}if(Object.values(this.tasks).every((q)=>q.writes.length>0))return this.tick({inputKeys:J});if(N0(this.checkpoint,this.interruptBefore,Object.values(this.tasks)))throw this.status="interrupt_before",new PQ;let Z=await GQ(CQ(o8(Object.values(this.tasks)),"tasks"));return this._emit(Z),!0}async finishAndHandleError($){if(this.durability==="exit"&&(!this.isNested||typeof $<"u"||this.checkpointNamespace.every((Z)=>!Z.includes(e))))this._putCheckpoint(this.checkpointMetadata),this._flushPendingWrites();let J=this._suppressInterrupt($);if(J||$===void 0)this.output=MQ(this.channels,this.outputKeys);if(J){if(this.tasks!==void 0&&this.checkpointPendingWrites.length>0&&Object.values(this.tasks).some((Z)=>Z.writes.length>0))this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(this.tasks),this.checkpointerGetNextVersion,this.triggerToNodes),this._emit($0(CQ(q8(this.outputKeys,Object.values(this.tasks).flatMap((Z)=>Z.writes),this.channels),"values")));if(wQ($)&&!$.interrupts.length)this._emit([["updates",{[S]:[]}],["values",{[S]:[]}]])}return J}async acceptPush($,J,Z){if(this.interruptAfter?.length>0&&N0(this.checkpoint,this.interruptAfter,[$])){this.toInterrupt.push($);return}let q=Y8([r,$.path??[],J,$.id,Z],this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,$.config??{},!0,{step:this.step,checkpointer:this.checkpointer,manager:this.manager,store:this.store,stream:this.stream});if(!q)return;if(this.interruptBefore?.length>0&&N0(this.checkpoint,this.interruptBefore,[q])){this.toInterrupt.push(q);return}if(this._emit($0(CQ(o8([q]),"tasks"))),this.debug)X8(this.step,[q]);if(this.tasks[q.id]=q,this.skipDoneTasks)this._matchWrites({[q.id]:q});let z=await this._matchCachedWrites();for(let{task:Y}of z)this._outputWrites(Y.id,Y.writes,!0);return q}_suppressInterrupt($){return wQ($)&&!this.isNested}async _first($){let{configurable:J}=this.config,Z=J?.[JQ];if(Z&&Z.nullResume!==void 0)this.putWrites(n,[[o,Z.nullResume]]);if(u(this.input)){let Y=this.input.resume!=null;if(this.input.resume!=null&&typeof this.input.resume==="object"&&Object.keys(this.input.resume).every(t0))this.config.configurable??={},this.config.configurable[X0]=this.input.resume;if(Y&&this.checkpointer==null)throw Error("Cannot use Command(resume=...) without checkpointer");let X={};for(let[B,F,W]of k$(this.input,this.checkpointPendingWrites))X[B]??=[],X[B].push([F,W]);if(Object.keys(X).length===0)throw new P0("Received empty Command input");for(let[B,F]of Object.entries(X))this.putWrites(B,F)}let q=(this.checkpointPendingWrites??[]).filter((Y)=>Y[0]===n).map((Y)=>Y.slice(1));if(q.length>0)$Q(this.checkpoint,this.channels,[{name:xQ,writes:q,triggers:[]}],this.checkpointerGetNextVersion,this.triggerToNodes);let z=u(this.input)&&q.length>0;if(this.isResuming||z){for(let X in this.channels){if(!Object.prototype.hasOwnProperty.call(this.channels,X))continue;if(this.checkpoint.channel_versions[X]!==void 0){let B=this.checkpoint.channel_versions[X];this.checkpoint.versions_seen[S]={...this.checkpoint.versions_seen[S],[X]:B}}}let Y=await GQ(CQ(q8(this.outputKeys,!0,this.channels),"values"));this._emit(Y)}if(this.isResuming)this.input=t8;else if(z)await this._putCheckpoint({source:"input"}),this.input=L8;else{let Y=await GQ(Z8($,this.input));if(Y.length>0){let X=sQ(this.checkpoint,this.checkpointPendingWrites,this.nodes,this.channels,this.config,!0,{step:this.step});this.updatedChannels=$Q(this.checkpoint,this.channels,Object.values(X).concat([{name:xQ,writes:Y,triggers:[]}]),this.checkpointerGetNextVersion,this.triggerToNodes),await this._putCheckpoint({source:"input"}),this.input=L8}else if(!(EQ in(this.config.configurable??{})))throw new P0(`Received no input writes for ${JSON.stringify($,null,2)}`);else this.input=L8}if(!this.isNested)this.config=zQ(this.config,{[EQ]:this.isResuming})}_emit($){for(let[J,Z]of $){if(this.stream.modes.has(J))this.stream.push([this.checkpointNamespace,J,Z]);if((J==="checkpoints"||J==="tasks")&&this.stream.modes.has("debug")){let q=J==="checkpoints"?this.step-1:this.step,z=new Date().toISOString(),Y=(()=>{if(J==="checkpoints")return"checkpoint";else if(typeof Z==="object"&&Z!=null&&"result"in Z)return"task_result";else return"task"})();this.stream.push([this.checkpointNamespace,"debug",{step:q,type:Y,timestamp:z,payload:Z}])}}}_putCheckpoint($){let J=this.checkpointMetadata===$,Z=this.checkpointer!=null&&(this.durability!=="exit"||J),q=(z)=>{this.prevCheckpointConfig=this.checkpointConfig?.configurable?.checkpoint_id?this.checkpointConfig:void 0,this.checkpointConfig=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??""});let Y={...this.checkpoint.channel_versions},X=H0(this.checkpointPreviousVersions,Y);this.checkpointPreviousVersions=Y,this._checkpointerPutAfterPrevious({config:{...this.checkpointConfig},checkpoint:fQ(z),metadata:{...this.checkpointMetadata},newVersions:X}),this.checkpointConfig={...this.checkpointConfig,configurable:{...this.checkpointConfig.configurable,checkpoint_id:this.checkpoint.id}}};if(!J)this.checkpointMetadata={...$,step:this.step,parents:this.config.configurable?.[ZQ]??{}};if(this.checkpoint=HQ(this.checkpoint,Z?this.channels:void 0,this.step,J?{id:this.checkpoint.id}:void 0),Z)q(this.checkpoint);if(!J)this.step+=1}_flushPendingWrites(){if(this.checkpointer==null)return;if(this.checkpointPendingWrites.length===0)return;let $=zQ(this.checkpointConfig,{[FQ]:this.config.configurable?.checkpoint_ns??"",[w8]:this.checkpoint.id}),J={};for(let[Z,q,z]of this.checkpointPendingWrites)J[Z]??=[],J[Z].push([q,z]);for(let[Z,q]of Object.entries(J))this.checkpointerPromises.push(this.checkpointer.putWrites($,q,Z))}_matchWrites($){for(let[J,Z,q]of this.checkpointPendingWrites){if(Z===p||Z===S||Z===o)continue;let z=Object.values($).find((Y)=>Y.id===J);if(z)z.writes.push([Z,q])}for(let J of Object.values($))if(J.writes.length>0)this._outputWrites(J.id,J.writes,!0)}};function j6(Q){return kQ(Q?.message)}var F1=class extends F8{name="StreamMessagesHandler";streamFn;metadatas={};seen={};emittedChatModelRunIds={};stableMessageIdMap={};lc_prefer_streaming=!0;constructor(Q){super();this.streamFn=Q}_emit(Q,$,J,Z=!1){if(Z&&$.id!==void 0&&this.seen[$.id]!==void 0)return;let q=$.id;if(J!=null)if(Y1($))q??=`run-${J}-tool-${$.tool_call_id}`;else{if(q==null||q===`run-${J}`)q=this.stableMessageIdMap[J]??q??`run-${J}`;this.stableMessageIdMap[J]??=q}if(q!==$.id)$.id=q,$.lc_kwargs.id=q;if($.id!=null)this.seen[$.id]=$;this.streamFn([Q[0],"messages",[$,Q[1]]])}handleChatModelStart(Q,$,J,Z,q,z,Y,X){if(Y&&(!z||!z.includes(D$)&&!z.includes("nostream")))this.metadatas[J]=[Y.langgraph_checkpoint_ns.split("|"),{tags:z,name:X,...Y}]}handleLLMNewToken(Q,$,J,Z,q,z){let Y=z?.chunk;if(this.emittedChatModelRunIds[J]=!0,this.metadatas[J]!==void 0)if(j6(Y))this._emit(this.metadatas[J],Y.message,J);else this._emit(this.metadatas[J],new X1({content:Q}),J)}handleLLMEnd(Q,$){if(this.metadatas[$]===void 0)return;if(!this.emittedChatModelRunIds[$]){let J=Q.generations?.[0]?.[0];if(kQ(J?.message))this._emit(this.metadatas[$],J?.message,$,!0);delete this.emittedChatModelRunIds[$]}delete this.metadatas[$],delete this.stableMessageIdMap[$]}handleLLMError(Q,$){delete this.metadatas[$]}handleChainStart(Q,$,J,Z,q,z,Y,X){if(z!==void 0&&X===z.langgraph_node&&(q===void 0||!q.includes(E))){if(this.metadatas[J]=[z.langgraph_checkpoint_ns.split("|"),{tags:q,name:X,...z}],typeof $==="object"){for(let B of Object.values($))if((kQ(B)||a8(B))&&B.id!==void 0)this.seen[B.id]=B;else if(Array.isArray(B)){for(let F of B)if((kQ(F)||a8(F))&&F.id!==void 0)this.seen[F.id]=F}}}}handleChainEnd(Q,$){let J=this.metadatas[$];if(delete this.metadatas[$],J!==void 0){if(kQ(Q))this._emit(J,Q,$,!0);else if(Array.isArray(Q)){for(let Z of Q)if(kQ(Z))this._emit(J,Z,$,!0)}else if(Q!=null&&typeof Q==="object"){for(let Z of Object.values(Q))if(kQ(Z))this._emit(J,Z,$,!0);else if(Array.isArray(Z)){for(let q of Z)if(kQ(q))this._emit(J,q,$,!0)}}}}handleChainError(Q,$){delete this.metadatas[$]}};var H6=500,U6=2,V6=128000,D6=3,G6=[400,401,402,403,404,405,406,407,409],K6=(Q)=>{if(Q.message.startsWith("Cancel")||Q.message.startsWith("AbortError")||Q.name==="AbortError")return!1;if(Q.name==="GraphValueError")return!1;if(Q?.code==="ECONNABORTED")return!1;let $=Q?.response?.status??Q?.status;if($&&G6.includes(+$))return!1;if(Q?.error?.code==="insufficient_quota")return!1;return!0};async function e8(Q,$,J,Z){let q=Q.retry_policy??$,z=q!==void 0?q.initialInterval??H6:0,Y=0,X,B,{config:F}=Q;if(J)F=zQ(F,J);F={...F,signal:Z};while(!0){if(Z?.aborted)break;Q.writes.splice(0,Q.writes.length),X=void 0;try{B=await Q.proc.invoke(Q.input,F);break}catch(W){if(X=W,X.pregelTaskId=Q.id,o0(X)){let j=F?.configurable?.checkpoint_ns,U=X.command;if(U.graph===j){for(let D of Q.writers)await D.invoke(U,F);X=void 0;break}else if(U.graph===a.PARENT){let D=I$(j);X.command=new a({...X.command,graph:D})}}if(pQ(X))break;if(q===void 0)break;if(Y+=1,Y>=(q.maxAttempts??D6))break;if(!(q.retryOn??K6)(X))break;z=Math.min(q.maxInterval??V6,z*(q.backoffFactor??U6));let L=q.jitter?Math.floor(z+Math.random()*1000):z;await new Promise((j)=>setTimeout(j,L));let H=X.name??X.constructor.unminifiable_name??X.constructor.name;if(q?.logWarning??!0)console.log(`Retrying task "${String(Q.name)}" after ${z.toFixed(2)}ms (attempt ${Y}) after ${H}: ${X}`);F=zQ(F,{[EQ]:!0})}}return{task:Q,result:B,error:X,signalAborted:Z?.aborted}}var Q$=Symbol.for("promiseAdded");function M6(){let Q={next:()=>{return},wait:Promise.resolve(Q$)};function $(J){Q.next=()=>{Q.wait=new Promise($),J(Q$)}}return Q.wait=new Promise($),Q}var B1=class{nodeFinished;loop;constructor({loop:Q,nodeFinished:$}){this.loop=Q,this.nodeFinished=$}async tick(Q={}){let{timeout:$,retryPolicy:J,onStepWrite:Z,maxConcurrency:q}=Q,z=new Set,Y,X=new AbortController,B=X.signal,F=$?AbortSignal.timeout($):void 0,W=Object.values(this.loop.tasks).filter((U)=>U.writes.length===0),{signals:L,disposeCombinedSignal:H}=this._initializeAbortSignals({exceptionSignal:B,stepTimeoutSignal:F,signal:Q.signal}),j=this._executeTasksWithRetry(W,{signals:L,retryPolicy:J,maxConcurrency:q});for await(let{task:U,error:D,signalAborted:M}of j)if(this._commit(U,D),wQ(D))Y=D;else if(pQ(D)&&!wQ(Y))Y=D;else if(D&&(z.size===0||!M))X.abort(),z.add(D);if(H?.(),Z?.(this.loop.step,Object.values(this.loop.tasks).map((U)=>U.writes).flat()),z.size===1)throw Array.from(z)[0];else if(z.size>1)throw AggregateError(Array.from(z),`Multiple errors occurred during superstep ${this.loop.step}. See the "errors" field of this exception for more details.`);if(wQ(Y))throw Y;if(pQ(Y)&&this.loop.isNested)throw Y}_initializeAbortSignals({exceptionSignal:Q,stepTimeoutSignal:$,signal:J}){let Z=this.loop.config.configurable?.[R8]??{},q=Z.externalAbortSignal??J,z=$??Z.timeoutAbortSignal,{signal:Y,dispose:X}=U0(q,z,Q),B={externalAbortSignal:q,timeoutAbortSignal:z,composedAbortSignal:Y};return this.loop.config=zQ(this.loop.config,{[R8]:B}),{signals:B,disposeCombinedSignal:X}}async*_executeTasksWithRetry(Q,$){let{retryPolicy:J,maxConcurrency:Z,signals:q}=$??{},z=M6(),Y={},X={executingTasksMap:Y,barrier:z,retryPolicy:J,scheduleTask:async(H,j,U)=>this.loop.acceptPush(H,j,U)};if(q?.composedAbortSignal?.aborted)throw Error("Abort");let B=0,F,W=U0(q?.externalAbortSignal,q?.timeoutAbortSignal),L=W.signal?new Promise((H,j)=>{F=()=>j(Error("Abort")),W.signal?.addEventListener("abort",F,{once:!0})}):void 0;while((B===0||Object.keys(Y).length>0)&&Q.length){for(;Object.values(Y).length<(Z??Q.length)&&B<Q.length;B+=1){let j=Q[B];Y[j.id]=e8(j,J,{[g0]:L1?.bind(X,this,j)},q?.composedAbortSignal).catch((U)=>{return{task:j,error:U,signalAborted:q?.composedAbortSignal?.aborted}})}let H=await Promise.race([...Object.values(Y),...L?[L]:[],z.wait]);if(H===Q$)continue;if(yield H,F!=null)W.signal?.removeEventListener("abort",F),W.dispose?.();delete Y[H.task.id]}}_commit(Q,$){if($!==void 0)if(wQ($)){if($.interrupts.length){let J=$.interrupts.map((q)=>[S,q]),Z=Q.writes.filter((q)=>q[0]===o);if(Z.length)J.push(...Z);this.loop.putWrites(Q.id,J)}}else if(pQ($)&&Q.writes.length)this.loop.putWrites(Q.id,Q.writes);else this.loop.putWrites(Q.id,[[p,{message:$.message,name:$.name}]]);else{if(this.nodeFinished&&(Q.config?.tags==null||!Q.config.tags.includes(E)))this.nodeFinished(String(Q.name));if(Q.writes.length===0)Q.writes.push([m0,null]);this.loop.putWrites(Q.id,Q.writes)}}};async function L1(Q,$,J,Z,q,z={}){let Y=$.config?.configurable?.[JQ];if(!Y)throw Error(`BUG: No scratchpad found on task ${$.name}__${$.id}`);let X=Y.callCounter;Y.callCounter+=1;let B=new u$({func:J,name:Z,input:q,cache:z.cache,retry:z.retry,callbacks:z.callbacks}),F=await this.scheduleTask($,X,B);if(!F)return;let W=this.executingTasksMap[F.id];if(W!==void 0)return W;if(F.writes.length>0){let L=F.writes.filter(([j])=>j===jQ),H=F.writes.filter(([j])=>j===p);if(L.length>0){if(L.length===1)return Promise.resolve(L[0][1]);throw Error(`BUG: multiple returns found for task ${F.name}__${F.id}`)}if(H.length>0){if(H.length===1){let j=H[0][1],U=j instanceof Error?j:Error(String(j));return Promise.reject(U)}throw Error(`BUG: multiple errors found for task ${F.name}__${F.id}`)}return}else{let L=e8(F,z.retry,{[g0]:L1.bind(this,Q,F)});return this.executingTasksMap[F.id]=L,this.barrier.next(),L.then(({result:H,error:j})=>{if(j)return Promise.reject(j);return H})}}var gQ=class extends Error{constructor(Q){super(Q);this.name="GraphValidationError"}};function W1({nodes:Q,channels:$,inputChannels:J,outputChannels:Z,streamChannels:q,interruptAfterNodes:z,interruptBeforeNodes:Y}){if(!$)throw new gQ("Channels not provided");let X=new Set,B=new Set;for(let[F,W]of Object.entries(Q)){if(F===S)throw new gQ(`"Node name ${S} is reserved"`);if(W.constructor===KQ)W.triggers.forEach((L)=>X.add(L));else throw new gQ(`Invalid node type ${typeof W}, expected PregelNode`)}for(let F of X)if(!(F in $))throw new gQ(`Subscribed channel '${String(F)}' not in channels`);if(!Array.isArray(J)){if(!X.has(J))throw new gQ(`Input channel ${String(J)} is not subscribed to by any node`)}else if(J.every((F)=>!X.has(F)))throw new gQ(`None of the input channels ${J} are subscribed to by any node`);if(!Array.isArray(Z))B.add(Z);else Z.forEach((F)=>B.add(F));if(q&&!Array.isArray(q))B.add(q);else if(Array.isArray(q))q.forEach((F)=>B.add(F));for(let F of B)if(!(F in $))throw new gQ(`Output channel '${String(F)}' not in channels`);if(z&&z!=="*"){for(let F of z)if(!(F in Q))throw new gQ(`Node ${String(F)} not in nodes`)}if(Y&&Y!=="*"){for(let F of Y)if(!(F in Q))throw new gQ(`Node ${String(F)} not in nodes`)}}function $$(Q,$){if(Array.isArray(Q)){for(let J of Q)if(!(J in $))throw Error(`Key ${String(J)} not found in channels`)}else if(!(Q in $))throw Error(`Key ${String(Q)} not found in channels`)}var U1=class{static subscribeTo(Q,$){let{key:J,tags:Z}={key:void 0,tags:void 0,...$??{}};if(Array.isArray(Q)&&J!==void 0)throw Error("Can't specify a key when subscribing to multiple channels");let q;if(typeof Q==="string")if(J)q={[J]:Q};else q=[Q];else q=Object.fromEntries(Q.map((z)=>[z,z]));return new KQ({channels:q,triggers:Array.isArray(Q)?Q:[Q],tags:Z})}static writeTo(Q,$){let J=[];for(let Z of Q)J.push({channel:Z,value:qQ,skipNone:!1});for(let[Z,q]of Object.entries($??{}))if(YQ.isRunnable(q)||typeof q==="function")J.push({channel:Z,value:qQ,skipNone:!0,mapper:yQ(q)});else J.push({channel:Z,value:q,skipNone:!1});return new h(J)}},x6=class extends YQ{lc_namespace=["langgraph","pregel"];invoke(Q,$){throw Error("Not implemented")}withConfig(Q){return super.withConfig(Q)}stream(Q,$){return super.stream(Q,$)}},H8=class extends x6{static lc_name(){return"LangGraph"}lc_namespace=["langgraph","pregel"];lg_is_pregel=!0;nodes;channels;inputChannels;outputChannels;autoValidate=!0;streamMode=["values"];streamChannels;interruptAfter;interruptBefore;stepTimeout;debug=!1;checkpointer;retryPolicy;config;store;cache;userInterrupt;triggerToNodes={};constructor(Q){super(Q);let{streamMode:$}=Q;if($!=null&&!Array.isArray($))$=[$];if(this.nodes=Q.nodes,this.channels=Q.channels,c in this.channels&&"lc_graph_name"in this.channels[c]&&this.channels[c].lc_graph_name!=="Topic")throw Error(`Channel '${c}' is reserved and cannot be used in the graph.`);else this.channels[c]=new f8({accumulate:!1});if(this.autoValidate=Q.autoValidate??this.autoValidate,this.streamMode=$??this.streamMode,this.inputChannels=Q.inputChannels,this.outputChannels=Q.outputChannels,this.streamChannels=Q.streamChannels??this.streamChannels,this.interruptAfter=Q.interruptAfter,this.interruptBefore=Q.interruptBefore,this.stepTimeout=Q.stepTimeout??this.stepTimeout,this.debug=Q.debug??this.debug,this.checkpointer=Q.checkpointer,this.retryPolicy=Q.retryPolicy,this.config=Q.config,this.store=Q.store,this.cache=Q.cache,this.name=Q.name,this.triggerToNodes=Q.triggerToNodes??this.triggerToNodes,this.userInterrupt=Q.userInterrupt,this.autoValidate)this.validate()}withConfig(Q){let $=DQ(this.config,Q);return new this.constructor({...this,config:$})}validate(){W1({nodes:this.nodes,channels:this.channels,outputChannels:this.outputChannels,inputChannels:this.inputChannels,streamChannels:this.streamChannels,interruptAfterNodes:this.interruptAfter,interruptBeforeNodes:this.interruptBefore});for(let[Q,$]of Object.entries(this.nodes))for(let J of $.triggers)this.triggerToNodes[J]??=[],this.triggerToNodes[J].push(Q);return this}get streamChannelsList(){if(Array.isArray(this.streamChannels))return this.streamChannels;else if(this.streamChannels)return[this.streamChannels];else return Object.keys(this.channels)}get streamChannelsAsIs(){if(this.streamChannels)return this.streamChannels;else return Object.keys(this.channels)}async getGraphAsync(Q){return this.getGraph(Q)}*getSubgraphs(Q,$){for(let[J,Z]of Object.entries(this.nodes)){if(Q!==void 0){if(!Q.startsWith(J))continue}let q=Z.subgraphs?.length?Z.subgraphs:[Z.bound];for(let z of q){let Y=J8(z);if(Y!==void 0){if(J===Q){yield[J,Y];return}if(Q===void 0)yield[J,Y];if($){let X=Q;if(Q!==void 0)X=Q.slice(J.length+1);for(let[B,F]of Y.getSubgraphs(X,$))yield[`${J}${k}${B}`,F]}}}}}async*getSubgraphsAsync(Q,$){yield*this.getSubgraphs(Q,$)}async _prepareStateSnapshot({config:Q,saved:$,subgraphCheckpointer:J,applyPendingWrites:Z=!1}){if($===void 0)return{values:{},next:[],config:Q,tasks:[]};let q=oQ(this.channels,$.checkpoint);if($.pendingWrites?.length){let L=$.pendingWrites.filter(([H,j])=>H===n).map(([H,j,U])=>[String(j),U]);if(L.length>0)$Q($.checkpoint,q,[{name:xQ,writes:L,triggers:[]}],void 0,this.triggerToNodes)}let z=Object.values(sQ($.checkpoint,$.pendingWrites,this.nodes,q,$.config,!0,{step:($.metadata?.step??-1)+1,store:this.store})),Y=await GQ(this.getSubgraphsAsync()),X=$.config.configurable?.checkpoint_ns??"",B={};for(let L of z){let H=Y.find(([U])=>U===L.name);if(!H)continue;let j=`${String(L.name)}${e}${L.id}`;if(X)j=`${X}${k}${j}`;if(J===void 0){let U={configurable:{thread_id:$.config.configurable?.thread_id,checkpoint_ns:j}};B[L.id]=U}else{let U={configurable:{[m]:J,thread_id:$.config.configurable?.thread_id,checkpoint_ns:j}},D=H[1];B[L.id]=await D.getState(U,{subgraphs:!0})}}if(Z&&$.pendingWrites?.length){let L=Object.fromEntries(z.map((j)=>[j.id,j]));for(let[j,U,D]of $.pendingWrites){if([p,S,j8].includes(U))continue;if(!(j in L))continue;L[j].writes.push([String(U),D])}let H=z.filter((j)=>j.writes.length>0);if(H.length>0)$Q($.checkpoint,q,H,void 0,this.triggerToNodes)}let F=$?.metadata;if(F&&$?.config?.configurable?.thread_id)F={...F,thread_id:$.config.configurable.thread_id};let W=z.filter((L)=>L.writes.length===0).map((L)=>L.name);return{values:MQ(q,this.streamChannelsAsIs),next:W,tasks:c8(z,$?.pendingWrites??[],B,this.streamChannelsAsIs),metadata:F,config:rQ($.config,$.metadata),createdAt:$.checkpoint.ts,parentConfig:$.parentConfig}}async getState(Q,$){let J=Q.configurable?.[m]??this.checkpointer;if(!J)throw new dQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[m]===void 0){let Y=e0(Z);for await(let[X,B]of this.getSubgraphsAsync(Y,!0))if(X===Y)return await B.getState(J0(Q,{[m]:J}),{subgraphs:$?.subgraphs});throw Error(`Subgraph with namespace "${Y}" not found.`)}let q=DQ(this.config,Q),z=await J.getTuple(Q);return await this._prepareStateSnapshot({config:q,saved:z,subgraphCheckpointer:$?.subgraphs?J:void 0,applyPendingWrites:!Q.configurable?.checkpoint_id})}async*getStateHistory(Q,$){let J=Q.configurable?.[m]??this.checkpointer;if(!J)throw new dQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[m]===void 0){let z=e0(Z);for await(let[Y,X]of this.getSubgraphsAsync(z,!0))if(Y===z){yield*X.getStateHistory(J0(Q,{[m]:J}),$);return}throw Error(`Subgraph with namespace "${z}" not found.`)}let q=DQ(this.config,Q,{configurable:{checkpoint_ns:Z}});for await(let z of J.list(q,$))yield this._prepareStateSnapshot({config:z.config,saved:z})}async bulkUpdateState(Q,$){let J=Q.configurable?.[m]??this.checkpointer;if(!J)throw new dQ("No checkpointer set",{lc_error_code:"MISSING_CHECKPOINTER"});if($.length===0)throw Error("No supersteps provided");if($.some((Y)=>Y.updates.length===0))throw Error("No updates provided");let Z=Q.configurable?.checkpoint_ns??"";if(Z!==""&&Q.configurable?.[m]===void 0){let Y=e0(Z);for await(let[,X]of this.getSubgraphsAsync(Y,!0))return await X.bulkUpdateState(J0(Q,{[m]:J}),$);throw Error(`Subgraph "${Y}" not found`)}let q=async(Y,X)=>{let B=this.config?DQ(this.config,Y):Y,F=await J.getTuple(B),W=F!==void 0?fQ(F.checkpoint):V0(),L={...F?.checkpoint.channel_versions},H=F?.metadata?.step??-1,j=J0(B,{checkpoint_ns:B.configurable?.checkpoint_ns??""}),U=B.metadata??{};if(F?.config.configurable)j=J0(B,F.config.configurable),U={...F.metadata,...U};let{values:D,asNode:M}=X[0];if(D==null&&M===void 0){if(X.length>1)throw new w("Cannot create empty checkpoint with multiple updates");return rQ(await J.put(j,HQ(W,void 0,H),{source:"update",step:H+1,parents:F?.metadata?.parents??{}},{}),F?F.metadata:void 0)}let O=oQ(this.channels,W);if(D===null&&M===A){if(X.length>1)throw new w("Cannot apply multiple updates when clearing state");if(F){let K=sQ(W,F.pendingWrites||[],this.nodes,O,F.config,!0,{step:(F.metadata?.step??-1)+1,checkpointer:J,store:this.store}),x=(F.pendingWrites||[]).filter((b)=>b[0]===n).map((b)=>b.slice(1));if(x.length>0)$Q(W,O,[{name:xQ,writes:x,triggers:[]}],J.getNextVersion.bind(J),this.triggerToNodes);for(let[b,G,y]of F.pendingWrites||[]){if([p,S,j8].includes(G))continue;if(!(b in K))continue;K[b].writes.push([G,y])}$Q(W,O,Object.values(K),J.getNextVersion.bind(J),this.triggerToNodes)}return rQ(await J.put(j,HQ(W,O,H),{...U,source:"update",step:H+1,parents:F?.metadata?.parents??{}},H0(L,W.channel_versions)),F?F.metadata:void 0)}if(M===H$){if(X.length>1)throw new w("Cannot copy checkpoint with multiple updates");if(F==null)throw new w("Cannot copy a non-existent checkpoint");let K=(G)=>{if(!Array.isArray(G))return!1;if(G.length===0)return!1;return G.every((y)=>Array.isArray(y)&&y.length===2)},x=HQ(W,void 0,H),b=await J.put(F.parentConfig??J0(F.config,{checkpoint_id:void 0}),x,{source:"fork",step:H+1,parents:F.metadata?.parents??{}},{});if(K(D)){let G=sQ(x,F.pendingWrites,this.nodes,O,b,!1,{step:H+2}),y=Object.values(G).reduce((i,{name:C0,id:P8})=>{return i[C0]??=[],i[C0].push({id:P8}),i},{}),g=D.reduce((i,C0)=>{let[P8,D0]=C0;i[D0]??=[];let b1=i[D0].length,S1=y[D0]?.[b1]?.id;return i[D0].push({values:P8,asNode:D0,taskId:S1}),i},{});return q(rQ(b,F.metadata),Object.values(g).flat())}return rQ(b,F.metadata)}if(M===xQ){if(X.length>1)throw new w("Cannot apply multiple updates when updating as input");let K=await GQ(Z8(this.inputChannels,D));if(K.length===0)throw new w(`Received no input writes for ${JSON.stringify(this.inputChannels,null,2)}`);$Q(W,O,[{name:xQ,writes:K,triggers:[]}],J.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let x=F?.metadata?.step!=null?F.metadata.step+1:-1,b=await J.put(j,HQ(W,O,x),{source:"input",step:x,parents:F?.metadata?.parents??{}},H0(L,W.channel_versions));return await J.putWrites(b,K,nQ(xQ,W.id)),rQ(b,F?F.metadata:void 0)}if(B.configurable?.checkpoint_id===void 0&&F?.pendingWrites!==void 0&&F.pendingWrites.length>0){let K=sQ(W,F.pendingWrites,this.nodes,O,F.config,!0,{store:this.store,checkpointer:this.checkpointer,step:(F.metadata?.step??-1)+1}),x=(F.pendingWrites??[]).filter((G)=>G[0]===n).map((G)=>G.slice(1));if(x.length>0)$Q(F.checkpoint,O,[{name:xQ,writes:x,triggers:[]}],void 0,this.triggerToNodes);for(let[G,y,g]of F.pendingWrites){if([p,S,j8].includes(y)||K[G]===void 0)continue;K[G].writes.push([y,g])}let b=Object.values(K).filter((G)=>{return G.writes.length>0});if(b.length>0)$Q(W,O,b,void 0,this.triggerToNodes)}let _=Object.values(W.versions_seen).map((K)=>{return Object.values(K)}).flat().find((K)=>!!K),P=[];if(X.length===1){let{values:K,asNode:x,taskId:b}=X[0];if(x===void 0&&Object.keys(this.nodes).length===1)[x]=Object.keys(this.nodes);else if(x===void 0&&_===void 0){if(typeof this.inputChannels==="string"&&this.nodes[this.inputChannels]!==void 0)x=this.inputChannels}else if(x===void 0){let G=Object.entries(W.versions_seen).map(([y,g])=>{return Object.values(g).map((i)=>{return[i,y]})}).flat().filter(([y,g])=>g!==S).sort(([y],[g])=>H1(y,g));if(G){if(G.length===1)x=G[0][1];else if(G[G.length-1][0]!==G[G.length-2][0])x=G[G.length-1][1]}}if(x===void 0)throw new w('Ambiguous update, specify "asNode"');P.push({values:K,asNode:x,taskId:b})}else for(let{asNode:K,values:x,taskId:b}of X){if(K==null)throw new w('"asNode" is required when applying multiple updates');P.push({values:x,asNode:K,taskId:b})}let I=[];for(let{asNode:K,values:x,taskId:b}of P){if(this.nodes[K]===void 0)throw new w(`Node "${K.toString()}" does not exist`);let G=this.nodes[K].getWriters();if(!G.length)throw new w(`No writers found for node "${K.toString()}"`);I.push({name:K,input:x,proc:G.length>1?Z0.from(G,{omitSequenceTags:!0}):G[0],writes:[],triggers:[S],id:b??nQ(S,W.id),writers:[]})}for(let K of I)await K.proc.invoke(K.input,iQ({...B,store:B?.store??this.store},{runName:B.runName??`${this.getName()}UpdateState`,configurable:{[WQ]:(x)=>K.writes.push(...x),[AQ]:(x,b=!1)=>_0(W,O,K,x,b)}}));for(let K of I){let x=K.writes.filter((b)=>b[0]!==r);if(F!==void 0&&x.length>0)await J.putWrites(j,x,K.id)}$Q(W,O,I,J.getNextVersion.bind(this.checkpointer),this.triggerToNodes);let N=H0(L,W.channel_versions),f=await J.put(j,HQ(W,O,H+1),{source:"update",step:H+1,parents:F?.metadata?.parents??{}},N);for(let K of I){let x=K.writes.filter((b)=>b[0]===r);if(x.length>0)await J.putWrites(f,x,K.id)}return rQ(f,F?F.metadata:void 0)},z=Q;for(let{updates:Y}of $)z=await q(z,Y);return z}async updateState(Q,$,J){return this.bulkUpdateState(Q,[{updates:[{values:$,asNode:J}]}])}_defaults(Q){let{debug:$,streamMode:J,inputKeys:Z,outputKeys:q,interruptAfter:z,interruptBefore:Y,...X}=Q,B=!0,F=$!==void 0?$:this.debug,W=q;if(W===void 0)W=this.streamChannelsAsIs;else $$(W,this.channels);let L=Z;if(L===void 0)L=this.inputChannels;else $$(L,this.channels);let H=Y??this.interruptBefore??[],j=z??this.interruptAfter??[],U;if(J!==void 0)U=Array.isArray(J)?J:[J],B=typeof J==="string";else{if(Q.configurable?.[Y0]!==void 0)U=["values"];else U=this.streamMode;B=!0}let D;if(this.checkpointer===!1)D=void 0;else if(Q!==void 0&&Q.configurable?.[m]!==void 0)D=Q.configurable[m];else if(this.checkpointer===!0)throw Error("checkpointer: true cannot be used for root graphs.");else D=this.checkpointer;let M=Q.store??this.store,O=Q.cache??this.cache;if(Q.durability!=null&&Q.checkpointDuring!=null)throw Error("Cannot use both `durability` and `checkpointDuring` at the same time.");let _=(()=>{if(Q.checkpointDuring==null)return;if(Q.checkpointDuring===!1)return"exit";return"async"})(),P=Q.durability??_??Q?.configurable?.[U$]??"async";return[F,U,L,W,X,H,j,D,M,B,O,P]}async stream(Q,$){let J=new AbortController,Z={recursionLimit:this.config?.recursionLimit,...$,signal:U0($?.signal,J.signal).signal},q=await super.stream(Q,Z);return new n8($?.encoding==="text/event-stream"?J1(q):q,J)}streamEvents(Q,$,J){let Z=new AbortController,q={recursionLimit:this.config?.recursionLimit,...$,callbacks:h$(this.config?.callbacks,$?.callbacks),signal:U0($?.signal,Z.signal).signal};return new n8(super.streamEvents(Q,q,J),Z)}async _validateInput(Q){return Q}async _validateContext(Q){return Q}async*_streamIterator(Q,$){let J="version"in($??{})?void 0:$?.encoding??void 0,Z=$?.subgraphs,q=b0(this.config,$);if(q.recursionLimit===void 0||q.recursionLimit<1)throw Error('Passed "recursionLimit" must be at least 1.');if(this.checkpointer!==void 0&&this.checkpointer!==!1&&q.configurable===void 0)throw Error('Checkpointer requires one or more of the following "configurable" keys: "thread_id", "checkpoint_ns", "checkpoint_id"');let z=await this._validateInput(Q),{runId:Y,...X}=q,[B,F,,W,L,H,j,U,D,M,O,_]=this._defaults(X);if(typeof L.context<"u")L.context=await this._validateContext(L.context);else L.configurable=await this._validateContext(L.configurable);let P=new B8({modes:new Set(F)});if(this.checkpointer===!0){L.configurable??={};let G=L.configurable[FQ]??"";L.configurable[FQ]=G.split(k).map((y)=>y.split(e)[0]).join(k)}if(F.includes("messages")){let G=new F1((g)=>P.push(g)),{callbacks:y}=L;if(y===void 0)L.callbacks=[G];else if(Array.isArray(y))L.callbacks=y.concat(G);else{let g=y.copy();g.addHandler(G,!0),L.callbacks=g}}if(F.includes("tools")){let G=new $1((g)=>P.push(g)),{callbacks:y}=L;if(y===void 0)L.callbacks=[G];else if(Array.isArray(y))L.callbacks=y.concat(G);else{let g=y.copy();g.addHandler(G,!0),L.callbacks=g}}L.writer??=(G)=>{if(!F.includes("custom"))return;let y=h8()?.configurable?.[FQ]?.split(k).slice(0,-1);P.push([y??[],"custom",G])},L.interrupt??=this.userInterrupt??N8;let I=await(await j1(L))?.handleChainStart(this.toJSON(),m$(Q,"input"),Y,void 0,void 0,void 0,L?.runName??this.getName()),N=w0(this.channels),f,K,b=(async()=>{try{f=await z1.initialize({input:z,config:L,checkpointer:U,nodes:this.nodes,channelSpecs:N,outputKeys:W,streamKeys:this.streamChannelsAsIs,store:D,cache:O,stream:P,interruptAfter:j,interruptBefore:H,manager:I,debug:this.debug,triggerToNodes:this.triggerToNodes,durability:_});let G=new B1({loop:f,nodeFinished:L.configurable?.[V$]});if($?.subgraphs)f.config.configurable={...f.config.configurable,[K0]:f.stream};if(await this._runLoop({loop:f,runner:G,debug:B,config:L}),_==="sync")await Promise.all(f?.checkpointerPromises??[])}catch(G){K=G}finally{try{if(f)await f.store?.stop(),await f.cache?.stop();await Promise.all(f?.checkpointerPromises??[])}catch(G){K=K??G}if(K)P.error(K);else P.close()}})();try{for await(let G of P){if(G===void 0)throw Error("Data structure error.");let[y,g,i]=G;if(F.includes(g)){if(J==="text/event-stream"){if(Z)yield[y,g,i];else yield[null,g,i];continue}if(Z&&!M)yield[y,g,i];else if(!M)yield[g,i];else if(Z)yield[y,i];else yield i}}}catch(G){throw await I?.handleChainError(K),G}finally{await b}await I?.handleChainEnd(f?.output??{},Y,void 0,void 0,void 0)}async invoke(Q,$){let J=$?.streamMode??"values",Z={...$,outputKeys:$?.outputKeys??this.outputChannels,streamMode:J,encoding:void 0},q=[],z=await this.stream(Q,Z),Y=[],X;for await(let B of z)if(J==="values")if(F0(B))Y.push(B[S]);else X=B;else q.push(B);if(J==="values"){if(Y.length>0){let B=Y.flat(1);if(X==null)return{[S]:B};if(typeof X==="object")return{...X,[S]:B}}return X}return q}async _runLoop(Q){let{loop:$,runner:J,debug:Z,config:q}=Q,z;try{while(await $.tick({inputKeys:this.inputChannels})){for(let{task:Y}of await $._matchCachedWrites())$._outputWrites(Y.id,Y.writes,!0);if(Z)t$($.checkpointMetadata.step,$.channels,this.streamChannelsList);if(Z)X8($.step,Object.values($.tasks));await J.tick({timeout:this.stepTimeout,retryPolicy:this.retryPolicy,onStepWrite:(Y,X)=>{if(Z)a$(Y,X,this.streamChannelsList)},maxConcurrency:q.maxConcurrency,signal:q.signal})}if($.status==="out_of_steps")throw new l0([`Recursion limit of ${q.recursionLimit} reached`,"without hitting a stop condition. You can increase the",'limit by setting the "recursionLimit" config key.'].join(" "),{lc_error_code:"GRAPH_RECURSION_LIMIT"})}catch(Y){if(z=Y,!await $.finishAndHandleError(z))throw Y}finally{if(z===void 0)await $.finishAndHandleError()}}async clearCache(){await this.cache?.clear([])}};D1();var q$=class{path;ends;constructor(Q){if(YQ.isRunnable(Q.path))this.path=Q.path;else this.path=yQ(Q.path);this.ends=Array.isArray(Q.pathMap)?Q.pathMap.reduce(($,J)=>{return $[J]=J,$},{}):Q.pathMap}run(Q,$){return h.registerWriter(new s({name:"<branch_run>",trace:!1,func:async(J,Z)=>{try{return await this._route(J,Z,Q,$)}catch(q){if(q.name===A0.unminifiable_name)console.warn(`[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.
14
+ NodeInterrupt should only be thrown inside a node, not in edge conditions.`);throw q}}}))}async _route(Q,$,J,Z){let q=await this.path.invoke(Z?Z($):Q,$);if(!Array.isArray(q))q=[q];let z;if(this.ends)z=q.map((Y)=>d(Y)?Y:this.ends[Y]);else z=q;if(z.some((Y)=>!Y))throw Error("Branch condition returned unknown or null destination");if(z.filter(d).some((Y)=>Y.node===A))throw new w("Cannot send a packet to the END node");return await J(z,$)??Q}},E0=class{nodes;edges;branches;entryPoint;compiled=!1;constructor(){this.nodes={},this.edges=new Set,this.branches={}}warnIfCompiled(Q){if(this.compiled)console.warn(Q)}get allEdges(){return this.edges}addNode(...Q){function $(Z){return Z.length>=1&&typeof Z[0]!=="string"}let J=$(Q)?Array.isArray(Q[0])?Q[0]:Object.entries(Q[0]):[[Q[0],Q[1],Q[2]]];if(J.length===0)throw Error("No nodes provided in `addNode`");for(let[Z,q,z]of J){for(let X of[k,e])if(Z.includes(X))throw Error(`"${X}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),Z in this.nodes)throw Error(`Node \`${Z}\` already present.`);if(Z===A)throw Error(`Node \`${Z}\` is reserved.`);let Y=yQ(q);this.nodes[Z]={runnable:Y,metadata:z?.metadata,subgraphs:S0(Y)?[Y]:z?.subgraphs,ends:z?.ends}}return this}addEdge(Q,$){if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),Q===A)throw Error("END cannot be a start node");if($===T)throw Error("START cannot be an end node");if(Array.from(this.edges).some(([J])=>J===Q)&&!("channels"in this))throw Error(`Already found path for ${Q}. For multiple edges, use StateGraph.`);return this.edges.add([Q,$]),this}addConditionalEdges(Q,$,J){let Z=typeof Q==="object"?Q:{source:Q,path:$,pathMap:J};if(this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph."),!YQ.isRunnable(Z.path))Z.path=yQ(Z.path);let q=Z.path.getName()==="RunnableLambda"?"condition":Z.path.getName();if(this.branches[Z.source]&&this.branches[Z.source][q])throw Error(`Condition \`${q}\` already present for node \`${Q}\``);return this.branches[Z.source]??={},this.branches[Z.source][q]=new q$(Z),this}setEntryPoint(Q){return this.warnIfCompiled("Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(T,Q)}setFinishPoint(Q){return this.warnIfCompiled("Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph."),this.addEdge(Q,A)}compile({checkpointer:Q,interruptBefore:$,interruptAfter:J,name:Z}={}){this.validate([...Array.isArray($)?$:[],...Array.isArray(J)?J:[]]);let q=new z$({builder:this,checkpointer:Q,interruptAfter:J,interruptBefore:$,autoValidate:!1,nodes:{},channels:{[T]:new VQ,[A]:new VQ},inputChannels:T,outputChannels:A,streamChannels:[],streamMode:"values",name:Z});for(let[z,Y]of Object.entries(this.nodes))q.attachNode(z,Y);for(let[z,Y]of this.edges)q.attachEdge(z,Y);for(let[z,Y]of Object.entries(this.branches))for(let[X,B]of Object.entries(Y))q.attachBranch(z,X,B);return q.validate()}validate(Q){let $=new Set([...this.allEdges].map(([Z,q])=>Z));for(let[Z]of Object.entries(this.branches))$.add(Z);for(let Z of $)if(Z!==T&&!(Z in this.nodes))throw Error(`Found edge starting at unknown node \`${Z}\``);let J=new Set([...this.allEdges].map(([Z,q])=>q));for(let[Z,q]of Object.entries(this.branches))for(let z of Object.values(q))if(z.ends!=null)for(let Y of Object.values(z.ends))J.add(Y);else{J.add(A);for(let Y of Object.keys(this.nodes))if(Y!==Z)J.add(Y)}for(let Z of Object.values(this.nodes))for(let q of Z.ends??[])J.add(q);for(let Z of Object.keys(this.nodes))if(!J.has(Z))throw new c0([`Node \`${Z}\` is not reachable.`,"","If you are returning Command objects from your node,",'make sure you are passing names of potential destination nodes as an "ends" array','into ".addNode(..., { ends: ["node1", "node2"] })".'].join(`
15
+ `),{lc_error_code:"UNREACHABLE_NODE"});for(let Z of J)if(Z!==A&&!(Z in this.nodes))throw Error(`Found edge ending at unknown node \`${Z}\``);if(Q){for(let Z of Q)if(!(Z in this.nodes))throw Error(`Interrupt node \`${Z}\` is not present`)}this.compiled=!0}},z$=class extends H8{builder;constructor({builder:Q,...$}){super($);this.builder=Q}attachNode(Q,$){this.channels[Q]=new VQ,this.nodes[Q]=new KQ({channels:[],triggers:[],metadata:$.metadata,subgraphs:$.subgraphs,ends:$.ends}).pipe($.runnable).pipe(new h([{channel:Q,value:qQ}],[E])),this.streamChannels.push(Q)}attachEdge(Q,$){if($===A){if(Q===T)throw Error("Cannot have an edge from START to END");this.nodes[Q].writers.push(new h([{channel:A,value:qQ}],[E]))}else this.nodes[$].triggers.push(Q),this.nodes[$].channels.push(Q)}attachBranch(Q,$,J){if(Q===T&&!this.nodes[T])this.nodes[T]=U1.subscribeTo(T,{tags:[E]});this.nodes[Q].pipe(J.run((q)=>{return new h(q.map((z)=>{if(d(z))return z;return{channel:z===A?A:`branch:${Q}:${$}:${z}`,value:qQ}}),[E])}));let Z=J.ends?Object.values(J.ends):Object.keys(this.nodes);for(let q of Z)if(q!==A){let z=`branch:${Q}:${$}:${q}`;this.channels[z]=new VQ,this.nodes[q].triggers.push(z),this.nodes[q].channels.push(z)}}async getGraphAsync(Q){let $=Q?.xray,J=new Z$,Z={[T]:J.addNode({schema:tQ.any()},T)},q={},z={};if($)z=Object.fromEntries((await GQ(this.getSubgraphsAsync())).filter((B)=>V1(B[1])));function Y(B,F,W,L=!1){if(F===A&&q[A]===void 0)q[A]=J.addNode({schema:tQ.any()},A);if(Z[B]===void 0)return;if(q[F]===void 0)throw Error(`End node ${F} not found!`);return J.addEdge(Z[B],q[F],W!==F?W:void 0,L)}for(let[B,F]of Object.entries(this.builder.nodes)){let W=t(B),L=F.runnable,H=F.metadata??{};if(this.interruptBefore?.includes(B)&&this.interruptAfter?.includes(B))H.__interrupt="before,after";else if(this.interruptBefore?.includes(B))H.__interrupt="before";else if(this.interruptAfter?.includes(B))H.__interrupt="after";if($){let j=typeof $==="number"?$-1:$,U=z[B]!==void 0?await z[B].getGraphAsync({...Q,xray:j}):L.getGraph(Q);if(U.trimFirstNode(),U.trimLastNode(),Object.keys(U.nodes).length>1){let O=function(P){return P?P.lc_runnable:!1},_=function(P,I){if(P!==void 0&&!J$(P))return P;else if(O(I))try{let N=I.getName();return N=N.startsWith("Runnable")?N.slice(8):N,N}catch(N){return I.getName()}else return I.name??"UnknownSchema"},[D,M]=J.extend(U,W);if(D===void 0)throw Error(`Could not extend subgraph "${B}" due to missing entrypoint.`);if(M!==void 0)Z[W]={name:_(M.id,M.data),...M};q[W]={name:_(D.id,D.data),...D}}else{let D=J.addNode(L,W,H);Z[W]=D,q[W]=D}}else{let j=J.addNode(L,W,H);Z[W]=j,q[W]=j}}let X=[...this.builder.allEdges].sort(([B],[F])=>{if(B<F)return-1;else if(F>B)return 1;else return 0});for(let[B,F]of X)Y(t(B),t(F));for(let[B,F]of Object.entries(this.builder.branches)){let W={...Object.fromEntries(Object.keys(this.builder.nodes).filter((L)=>L!==B).map((L)=>[t(L),t(L)])),[A]:A};for(let L of Object.values(F)){let H;if(L.ends!==void 0)H=L.ends;else H=W;for(let[j,U]of Object.entries(H))Y(t(B),t(U),j,!0)}}for(let[B,F]of Object.entries(this.builder.nodes))if(F.ends!==void 0)for(let W of F.ends)Y(t(B),t(W),void 0,!0);return J}getGraph(Q){let $=Q?.xray,J=new Z$,Z={[T]:J.addNode({schema:tQ.any()},T)},q={},z={};if($)z=Object.fromEntries($0(this.getSubgraphs()).filter((B)=>V1(B[1])));function Y(B,F,W,L=!1){if(F===A&&q[A]===void 0)q[A]=J.addNode({schema:tQ.any()},A);return J.addEdge(Z[B],q[F],W!==F?W:void 0,L)}for(let[B,F]of Object.entries(this.builder.nodes)){let W=t(B),L=F.runnable,H=F.metadata??{};if(this.interruptBefore?.includes(B)&&this.interruptAfter?.includes(B))H.__interrupt="before,after";else if(this.interruptBefore?.includes(B))H.__interrupt="before";else if(this.interruptAfter?.includes(B))H.__interrupt="after";if($){let j=typeof $==="number"?$-1:$,U=z[B]!==void 0?z[B].getGraph({...Q,xray:j}):L.getGraph(Q);if(U.trimFirstNode(),U.trimLastNode(),Object.keys(U.nodes).length>1){let O=function(P){return P?P.lc_runnable:!1},_=function(P,I){if(P!==void 0&&!J$(P))return P;else if(O(I))try{let N=I.getName();return N=N.startsWith("Runnable")?N.slice(8):N,N}catch(N){return I.getName()}else return I.name??"UnknownSchema"},[D,M]=J.extend(U,W);if(D===void 0)throw Error(`Could not extend subgraph "${B}" due to missing entrypoint.`);if(M!==void 0)Z[W]={name:_(M.id,M.data),...M};q[W]={name:_(D.id,D.data),...D}}else{let D=J.addNode(L,W,H);Z[W]=D,q[W]=D}}else{let j=J.addNode(L,W,H);Z[W]=j,q[W]=j}}let X=[...this.builder.allEdges].sort(([B],[F])=>{if(B<F)return-1;else if(F>B)return 1;else return 0});for(let[B,F]of X)Y(t(B),t(F));for(let[B,F]of Object.entries(this.builder.branches)){let W={...Object.fromEntries(Object.keys(this.builder.nodes).filter((L)=>L!==B).map((L)=>[t(L),t(L)])),[A]:A};for(let L of Object.values(F)){let H;if(L.ends!==void 0)H=L.ends;else H=W;for(let[j,U]of Object.entries(H))Y(t(B),t(U),j,!0)}}return J}};function V1(Q){return typeof Q.attachNode==="function"&&typeof Q.attachEdge==="function"}function t(Q){if(Q==="subgraph")return`"${Q}"`;return Q}D1();var D8="__remove_all__";function mQ(Q,$){let J=Array.isArray(Q)?Q:[Q],Z=Array.isArray($)?$:[$],q=J.map(V8),z=Z.map(V8);for(let W of q)if(W.id===null||W.id===void 0)W.id=Y$(),W.lc_kwargs.id=W.id;let Y;for(let W=0;W<z.length;W+=1){let L=z[W];if(L.id===null||L.id===void 0)L.id=Y$(),L.lc_kwargs.id=L.id;if(U8.isInstance(L)&&L.id===D8)Y=W}if(Y!=null)return z.slice(Y+1);let X=[...q],B=new Map(X.map((W,L)=>[W.id,L])),F=new Set;for(let W of z){let L=B.get(W.id);if(L!==void 0)if(U8.isInstance(W))F.add(W.id);else F.delete(W.id),X[L]=W;else{if(U8.isInstance(W))throw Error(`Attempting to delete a message with an ID that doesn't exist ('${W.id}')`);B.set(W.id,X.length),X.push(W)}}return X.filter((W)=>!F.has(W.id))}var A6=tQ.custom().default(()=>[]),O6=tQ.custom(),G8=new BQ(A6,{inputSchema:O6,reducer:mQ,jsonSchemaExtra:{langgraph_type:"messages",description:"A list of chat messages"}});var P6="lg:",w6=class{_map=new Map;_extensionCache=new Map;get(Q){return this._map.get(Q)}extend(Q,$){let J=this.get(Q);this._map.set(Q,$(J))}remove(Q){return this._map.delete(Q),this}has(Q){return this._map.has(Q)}getChannelsForSchema(Q){let $={},J=F$(Q);for(let[Z,q]of Object.entries(J)){let z=this.get(q);if(z?.reducer)$[Z]=new bQ(z.reducer.fn,z.default);else $[Z]=new UQ(z?.default)}return $}getExtendedChannelSchemas(Q,$){if(Object.keys($).length===0)return Q;let J=Object.entries($).filter(([,z])=>z===!0).sort(([z],[Y])=>z.localeCompare(Y)).map(([z,Y])=>`${z}:${Y}`).join("|"),Z=this._extensionCache.get(J)??new Map;if(Z.has(Q))return Z.get(Q);let q=Q;if($.withReducerSchema||$.withJsonSchemaExtrasAsDescription){let z=Object.entries(F$(Q)).map(([Y,X])=>{let B=this.get(X),F=$.withReducerSchema?B?.reducer?.schema??X:X;if($.withJsonSchemaExtrasAsDescription&&B?.jsonSchemaExtra){let W=X$(F)??X$(X),L=JSON.stringify({...B.jsonSchemaExtra,description:W});F=F.describe(`${P6}${L}`)}return[Y,F]});if(q=M1(Q,Object.fromEntries(z)),K1(q))q._def.unknownKeys="strip"}if($.asPartial)q=K8(q);return Z.set(Q,q),this._extensionCache.set(J,Z),q}},v0=new w6;function A1(Q,$){if($.reducer&&!$.default){let J=x1(Q);if(J!=null)$.default=J}if($.reducer){let J=Object.assign(Q,{lg_reducer_schema:$.reducer?.schema??Q});return v0.extend(J,()=>$),J}else return v0.extend(Q,()=>$),Q}function z0(Q){if(Q==null)return!1;if(LQ.isInstance(Q))return!0;if(XQ(Q))return!0;if(typeof Q==="object"&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot")return!0;if(typeof Q==="object"&&!Array.isArray(Q)&&Object.keys(Q).length>0&&Object.values(Q).every(($)=>typeof $==="function"||E8($)))return!0;return!1}function O1(Q){if(typeof Q!=="object"||Q==null)return!1;let $=Q,J="state"in $&&z0($.state),Z="stateSchema"in $&&z0($.stateSchema),q="input"in $&&z0($.input);if(!J&&!Z&&!q)return!1;if("input"in $&&$.input!=null&&!z0($.input))return!1;if("output"in $&&$.output!=null&&!z0($.output))return!1;return!0}var hQ="__root__",x8=Symbol.for("langgraph.state.partial"),A8=class extends E0{channels={};waitingEdges=new Set;_schemaDefinition;_schemaRuntimeDefinition;_inputDefinition;_inputRuntimeDefinition;_outputDefinition;_outputRuntimeDefinition;_schemaDefinitions=new Map;_metaRegistry=v0;_configSchema;_configRuntimeSchema;_interrupt;_writer;constructor(Q,$){super();let J=this._normalizeToStateGraphInit(Q,$),Z=J.state??J.stateSchema??J.input;if(!Z)throw new B0;let q=this._getChannelsFromSchema(Z);if(this._schemaDefinition=q,LQ.isInstance(Z))this._schemaRuntimeDefinition=Z;else if(XQ(Z))this._schemaRuntimeDefinition=Z;if(J.input)if(LQ.isInstance(J.input))this._inputRuntimeDefinition=J.input;else if(XQ(J.input))this._inputRuntimeDefinition=J.input;else this._inputRuntimeDefinition=x8;else this._inputRuntimeDefinition=x8;if(J.output)if(LQ.isInstance(J.output))this._outputRuntimeDefinition=J.output;else if(XQ(J.output))this._outputRuntimeDefinition=J.output;else this._outputRuntimeDefinition=this._schemaRuntimeDefinition;else this._outputRuntimeDefinition=this._schemaRuntimeDefinition;let z=J.input?this._getChannelsFromSchema(J.input):q,Y=J.output?this._getChannelsFromSchema(J.output):q;if(this._inputDefinition=z,this._outputDefinition=Y,this._addSchema(this._schemaDefinition),this._addSchema(this._inputDefinition),this._addSchema(this._outputDefinition),J.context){if(XQ(J.context))this._configRuntimeSchema=J.context}this._interrupt=J.interrupt,this._writer=J.writer}_normalizeToStateGraphInit(Q,$){if(O1(Q)){if(XQ($)||T0.isInstance($))return{...Q,context:$};let J=$;return{...Q,input:Q.input??J?.input,output:Q.output??J?.output,context:Q.context??J?.context,interrupt:Q.interrupt??J?.interrupt,writer:Q.writer??J?.writer,nodes:Q.nodes??J?.nodes}}if(z0(Q)){if(XQ($)||T0.isInstance($))return{state:Q,context:$};let J=$;return{state:Q,input:J?.input,output:J?.output,context:J?.context,interrupt:J?.interrupt,writer:J?.writer,nodes:J?.nodes}}if(T6(Q))return{state:R6(Q.channels)};throw new B0}_getChannelsFromSchema(Q){if(LQ.isInstance(Q))return Q.getChannels();if(XQ(Q))return this._metaRegistry.getChannelsForSchema(Q);if(typeof Q==="object"&&"lc_graph_name"in Q&&Q.lc_graph_name==="AnnotationRoot")return Q.spec;if(typeof Q==="object"&&!Array.isArray(Q)&&Object.keys(Q).length>0)return Q;throw new B0("Invalid schema type. Expected StateSchema, Zod object, AnnotationRoot, or StateDefinition.")}get allEdges(){return new Set([...this.edges,...Array.from(this.waitingEdges).flatMap(([Q,$])=>Q.map((J)=>[J,$]))])}_addSchema(Q){if(this._schemaDefinitions.has(Q))return;this._schemaDefinitions.set(Q,Q);for(let[$,J]of Object.entries(Q)){let Z;if(typeof J==="function")Z=J();else Z=J;if(this.channels[$]!==void 0){if(!this.channels[$].equals(Z)){if(Z.lc_graph_name!=="LastValue")throw Error(`Channel "${$}" already exists with a different type.`)}}else this.channels[$]=Z}}addNode(...Q){function $(Z){return Z.length>=1&&typeof Z[0]!=="string"}let J=$(Q)?Array.isArray(Q[0])?Q[0]:Object.entries(Q[0]).map(([Z,q])=>[Z,q]):[[Q[0],Q[1],Q[2]]];if(J.length===0)throw Error("No nodes provided in `addNode`");for(let[Z,q,z]of J){if(Z in this.channels)throw Error(`${Z} is already being used as a state attribute (a.k.a. a channel), cannot also be used as a node name.`);for(let W of[k,e])if(Z.includes(W))throw Error(`"${W}" is a reserved character and is not allowed in node names.`);if(this.warnIfCompiled("Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph."),Z in this.nodes)throw Error(`Node \`${Z}\` already present.`);if(Z===A||Z===T)throw Error(`Node \`${Z}\` is reserved.`);let Y=this._schemaDefinition;if(z?.input!==void 0)Y=this._getChannelsFromSchema(z.input);this._addSchema(Y);let X;if(YQ.isRunnable(q))X=q;else if(typeof q==="function")X=new s({func:q,name:Z,trace:!1});else X=yQ(q);let B=z?.cachePolicy;if(typeof B==="boolean")B=B?{}:void 0;let F={runnable:X,retryPolicy:z?.retryPolicy,cachePolicy:B,metadata:z?.metadata,input:Y??this._schemaDefinition,subgraphs:S0(X)?[X]:z?.subgraphs,ends:z?.ends,defer:z?.defer};this.nodes[Z]=F}return this}addEdge(Q,$){if(typeof Q==="string")return super.addEdge(Q,$);if(this.compiled)console.warn("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");for(let J of Q){if(J===A)throw Error("END cannot be a start node");if(!Object.keys(this.nodes).some((Z)=>Z===J))throw Error(`Need to add a node named "${J}" first`)}if($===A)throw Error("END cannot be an end node");if(!Object.keys(this.nodes).some((J)=>J===$))throw Error(`Need to add a node named "${$}" first`);return this.waitingEdges.add([Q,$]),this}addSequence(Q){let $=Array.isArray(Q)?Q:Object.entries(Q);if($.length===0)throw Error("Sequence requires at least one node.");let J;for(let[Z,q,z]of $){if(Z in this.nodes)throw Error(`Node names must be unique: node with the name "${Z}" already exists.`);let Y=Z;if(this.addNode(Y,q,z),J!=null)this.addEdge(J,Y);J=Y}return this}compile({checkpointer:Q,store:$,cache:J,interruptBefore:Z,interruptAfter:q,name:z,description:Y}={}){this.validate([...Array.isArray(Z)?Z:[],...Array.isArray(q)?q:[]]);let X=Object.keys(this._schemaDefinitions.get(this._outputDefinition)),B=X.length===1&&X[0]===hQ?hQ:X,F=Object.keys(this.channels),W=F.length===1&&F[0]===hQ?hQ:F,L=this._interrupt,H=new O8({builder:this,checkpointer:Q,interruptAfter:q,interruptBefore:Z,autoValidate:!1,nodes:{},channels:{...this.channels,[T]:new VQ},inputChannels:T,outputChannels:B,streamChannels:W,streamMode:"updates",store:$,cache:J,name:z,description:Y,userInterrupt:L});H.attachNode(T);for(let[j,U]of Object.entries(this.nodes))H.attachNode(j,U);H.attachBranch(T,T8,P1(),{withReader:!1});for(let[j]of Object.entries(this.nodes))H.attachBranch(j,T8,P1(),{withReader:!1});for(let[j,U]of this.edges)H.attachEdge(j,U);for(let[j,U]of this.waitingEdges)H.attachEdge(j,U);for(let[j,U]of Object.entries(this.branches))for(let[D,M]of Object.entries(U))H.attachBranch(j,D,M);return H.validate()}};function R6(Q){let $={};for(let[J,Z]of Object.entries(Q))if(J===hQ)$[J]=a0(Z);else $[J]=a0(Z);return $}var O8=class extends z${description;_metaRegistry=v0;constructor({description:Q,...$}){super($);this.description=Q}attachNode(Q,$){let J;if(Q===T)J=Object.entries(this.builder._schemaDefinitions.get(this.builder._inputDefinition)).map(([X])=>X);else J=Object.keys(this.builder.channels);function Z(X){if(u(X)){if(X.graph===a.PARENT)return null;return X._updateAsTuples()}else if(Array.isArray(X)&&X.length>0&&X.some((B)=>u(B))){let B=[];for(let F of X)if(u(F)){if(F.graph===a.PARENT)continue;B.push(...F._updateAsTuples())}else B.push([hQ,F]);return B}else if(X!=null)return[[hQ,X]];return null}let q=Q;function z(X){if(!X)return null;else if(u(X)){if(X.graph===a.PARENT)return null;return X._updateAsTuples().filter(([B])=>J.includes(B))}else if(Array.isArray(X)&&X.length>0&&X.some(u)){let B=[];for(let F of X)if(u(F)){if(F.graph===a.PARENT)continue;B.push(...F._updateAsTuples().filter(([W])=>J.includes(W)))}else{let W=z(F);if(W)B.push(...W??[])}return B}else if(typeof X==="object"&&!Array.isArray(X))return Object.entries(X).filter(([B])=>J.includes(B));else{let B=Array.isArray(X)?"array":typeof X;throw new w(`Expected node "${q.toString()}" to return an object or an array containing at least one Command object, received ${B}`,{lc_error_code:"INVALID_GRAPH_NODE_RETURN_VALUE"})}}let Y=[{value:qQ,mapper:new s({func:J.length&&J[0]===hQ?Z:z,trace:!1,recurse:!1})}];if(Q===T)this.nodes[Q]=new KQ({tags:[E],triggers:[T],channels:[T],writers:[new h(Y,[E])]});else{let X=$?.input??this.builder._schemaDefinition,B=Object.fromEntries(Object.keys(this.builder._schemaDefinitions.get(X)).map((L)=>[L,L])),F=Object.keys(B).length===1&&hQ in B,W=`branch:to:${Q}`;this.channels[W]=$?.defer?new v8:new VQ(!1),this.nodes[Q]=new KQ({triggers:[W],channels:F?Object.keys(B):B,writers:[new h(Y,[E])],mapper:F?void 0:(L)=>{return Object.fromEntries(Object.entries(L).filter(([H])=>(H in B)))},bound:$?.runnable,metadata:$?.metadata,retryPolicy:$?.retryPolicy,cachePolicy:$?.cachePolicy,subgraphs:$?.subgraphs,ends:$?.ends})}}attachEdge(Q,$){if($===A)return;if(typeof Q==="string")this.nodes[Q].writers.push(new h([{channel:`branch:to:${$}`,value:null}],[E]));else if(Array.isArray(Q)){let J=`join:${Q.join("+")}:${$}`;this.channels[J]=this.builder.nodes[$].defer?new g8(new Set(Q)):new k8(new Set(Q)),this.nodes[$].triggers.push(J);for(let Z of Q)this.nodes[Z].writers.push(new h([{channel:J,value:Z}],[E]))}}attachBranch(Q,$,J,Z={withReader:!0}){let q=async(z,Y)=>{let X=z.filter((F)=>F!==A);if(!X.length)return;let B=X.map((F)=>{if(d(F))return F;return{channel:F===A?F:`branch:to:${F}`,value:Q}});await h.doWrite({...Y,tags:(Y.tags??[]).concat([E])},B)};this.nodes[Q].writers.push(J.run(q,Z.withReader?(z)=>f$.doRead(z,this.streamChannels??this.outputChannels,!0):void 0))}async _validateInput(Q){if(Q==null)return Q;let $=this.builder._inputRuntimeDefinition,J=this.builder._schemaRuntimeDefinition;if(LQ.isInstance($)){if(u(Q)){let q=Q;if(Q.update)q.update=await $.validateInput(Array.isArray(Q.update)?Object.fromEntries(Q.update):Q.update);return q}return await $.validateInput(Q)}if($===x8&&LQ.isInstance(J)){if(u(Q)){let q=Q;if(Q.update)q.update=await J.validateInput(Array.isArray(Q.update)?Object.fromEntries(Q.update):Q.update);return q}return await J.validateInput(Q)}let Z=(()=>{let q=(z)=>{if(z==null)return;return this._metaRegistry.getExtendedChannelSchemas(z,{withReducerSchema:!0})};if(XQ($))return q($);if($===x8){if(XQ(J))return K8(q(J));return}})();if(u(Q)){let q=Q;if(Q.update&&Z!=null)q.update=M8(Z,Q.update);return q}if(Z!=null)return M8(Z,Q);return Q}isInterrupted(Q){return F0(Q)}async _validateContext(Q){let $=this.builder._configRuntimeSchema;if(XQ($))M8($,Q);return Q}};function T6(Q){return typeof Q==="object"&&Q!==null&&Q.channels!==void 0}function b6(Q){if(d(Q))return[Q];let $=[];if(u(Q))$.push(Q);else if(Array.isArray(Q))$.push(...Q.filter(u));let J=[];for(let Z of $){if(Z.graph===a.PARENT)throw new O0(Z);if(d(Z.goto))J.push(Z.goto);else if(typeof Z.goto==="string")J.push(Z.goto);else if(Array.isArray(Z.goto))J.push(...Z.goto)}return J}function P1(){return new q$({path:new s({func:b6,tags:[E],trace:!1,recurse:!1,name:"<control_branch>"})})}var B$=function($,J){let{name:Z,checkpointer:q,store:z,cache:Y}=typeof $==="string"?{name:$,checkpointer:void 0,store:void 0}:$;if(y$(J)||E$(J))throw Error("Generators are disallowed as entrypoints. For streaming responses, use config.write.");let X="updates",B=l$(Z,J);function F(j){return typeof j==="object"&&j!==null&&"__lg_type"in j&&j.__lg_type==="__pregel_final"}let W=new s({name:"pluckReturnValue",func:(j)=>{return F(j)?j.value:j}}),L=new s({name:"pluckSaveValue",func:(j)=>{return F(j)?j.save:j}}),H=new KQ({bound:B,triggers:[T],channels:[T],writers:[new h([{channel:A,value:qQ,mapper:W},{channel:aQ,value:qQ,mapper:L}],[E])]});return new H8({name:Z,checkpointer:q,nodes:{[Z]:H},channels:{[T]:new VQ,[A]:new UQ,[aQ]:new UQ},inputChannels:T,outputChannels:A,streamChannels:A,streamMode:X,store:z,cache:Y})};B$.final=function({value:$,save:J}){return{value:$,save:J,__lg_type:"__pregel_final"}};var w1=Q0.Root({messages:Q0({reducer:mQ,default:()=>[]})}),W$={reducer:{fn:mQ},jsonSchemaExtra:{langgraph_type:"messages"},default:()=>[]},R1=L$.object({messages:A1(L$.custom(),W$)});N$();
16
+ export{T as jg,A as kg,uQ as lg,a as mg,u as ng,pQ as og,wQ as pg,Q0 as qg,a1 as rg,N8 as sg,BQ as tg,IQ as ug,LQ as vg,G8 as wg,v0 as xg,A1 as yg,A8 as zg,w1 as Ag,W$ as Bg};
@@ -0,0 +1 @@
1
+ import{M as A,O as q,R as c}from"./chunk-m21hvv91.js";import{Je as w,we as R}from"./chunk-c7kd2qrp.js";import{Dl as K}from"./chunk-y8qhrx11.js";function ZP(G){return G?.replace(process.cwd(),".")||G||""}var v=K(R(),1);var r=()=>{return process.env.TERM?.includes("256color")||process.env.TERM==="xterm-256color"||process.env.WT_SESSION!==void 0||process.platform==="darwin"||process.env.TERM_PROGRAM==="vscode"||process.env.TERM_PROGRAM==="iTerm.app"};var m={success:{hex:"#4fd6be",fallback:"green"},warning:{hex:"#ffdb95",fallback:"yellow"},error:{hex:"#f7768e",fallback:"red"},info:{hex:"#7dcfff",fallback:"cyan"},muted:{hex:"#565f89",fallback:"gray"},highlight:{hex:"#7dcfff",fallback:"cyanBright"},accent:{hex:"#bb9af7",fallback:"magentaBright"},border:{hex:"#414868",fallback:"gray"},primary:{hex:"#7aa2f7",fallback:"cyan"},secondary:{hex:"#bb9af7",fallback:"magenta"},keyword:{hex:"#bb9af7",fallback:"magenta"},function:{hex:"#7aa2f7",fallback:"blue"},string:{hex:"#9ece6a",fallback:"green"},number:{hex:"#ff9e64",fallback:"yellow"},comment:{hex:"#565f89",fallback:"gray"},variable:{hex:"#c0caf5",fallback:"white"},type:{hex:"#0db9d7",fallback:"cyan"},constant:{hex:"#e0af68",fallback:"yellow"},textPrimary:{hex:"#c0caf5",fallback:"white"},textSecondary:{hex:"#9aa5ce",fallback:"whiteBright"},textMuted:{hex:"#565f89",fallback:"gray"},bg:{hex:"#1a1b26",fallback:"black"},bgCard:{hex:"#24283b",fallback:"black"},indigo:{hex:"#6366f1",fallback:"blue"},purple:{hex:"#a855f7",fallback:"magenta"},pink:{hex:"#ec4899",fallback:"redBright"},rose:{hex:"#f43f5e",fallback:"red"},orange:{hex:"#f97316",fallback:"yellowBright"},amber:{hex:"#f59e0b",fallback:"yellow"},emerald:{hex:"#10b981",fallback:"green"},teal:{hex:"#14b8a6",fallback:"cyan"},sky:{hex:"#0ea5e9",fallback:"blue"}},VP=(G)=>{if(!(G in m))G="sky";return r()?m[G].hex:m[G].fallback};import o from"os";function BP(){try{return o.userInfo().username}catch(G){return process.env.USER||process.env.USERNAME||"User"}}var $=K(R(),1);var p=K(w(),1),n=50,a=1800000,t=300000,e=$.createContext(null);var CP=({children:G})=>{let[X,J]=$.useState([]),[Q,D]=$.useState(null),y=$.useCallback(async(Z)=>{let z=Z.tool;if(!z)return;let{status:W,editedArgs:F}=Z;if(W==="approved")z.sendResumeData({type:"approve"});else if(W==="edited"){let H={name:z.message.name,args:F};z.sendResumeData({type:"edit",edited_action:H})}else if(W==="rejected")z.sendResumeData({type:"reject",message:"User rejected to run this tool"});else console.error("[ChatWrapper] Unknown approval status:",W)},[]),V=$.useCallback(()=>{return`approval_${Date.now()}_${Math.random().toString(36).substring(2,9)}`},[]),j=$.useCallback((Z)=>{let z={...Z,id:V(),status:"pending",createdAt:new Date};return J((W)=>{let F=[...W,z];if(F.length>n){let H=F.filter((P)=>P.status!=="pending");if(H.length>0)return F.filter((P)=>P.id!==H[0].id)}if(W.length===0)D(z.id);return F}),z.id},[V]),N=$.useCallback((Z,z)=>{J((W)=>W.map((F)=>F.id===Z?{...F,...z}:F))},[]),S=$.useCallback((Z)=>{J((z)=>{let W=z.filter((F)=>F.id!==Z);if(Q===Z)D(W.length>0?W[0].id:null);return W})},[Q]),_=$.useCallback(()=>{J((Z)=>{let z=Z.filter((W)=>W.status==="pending");if(z.length===0)D(null);else if(Q&&!z.find((W)=>W.id===Q))D(z[0].id);return z})},[Q]),L=$.useCallback(async()=>{let Z=X.filter((z)=>z.status==="approved"||z.status==="edited"||z.status==="rejected");if(Z.length===0)return;for(let z of Z)try{await y(z)}catch(W){console.error(`[ApprovalContext] Execute approval request failed: ${z.id}`,W)}_()},[X,y,_]),h=$.useCallback(async(Z)=>{await y(Z)},[y]),B=$.useMemo(()=>X.some((Z)=>Z.status==="pending"),[X]),x=$.useMemo(()=>X.length>0&&!B,[X.length,B]),f=$.useCallback(()=>{let Z=Date.now();J((z)=>z.filter((W)=>W.createdAt.getTime()>Z-a))},[]);A(()=>{f()},t),q(()=>{J((Z)=>Z.map((z)=>({...z,tool:void 0})))}),$.useEffect(()=>{if(x)L()},[x,L]);let M=$.useMemo(()=>({requests:X,addApprovalRequest:j,updateApprovalRequest:N,removeApprovalRequest:S,clearCompletedApprovals:_,executeRequest:h,executeApproved:L,hasPendingRequests:B,allRequestsProcessed:x}),[X,j,N,S,_,h,L,B,x]);return p.jsxDEV(e.Provider,{value:M,children:G},void 0,!1,void 0,this)};var O=K(R(),1);var d=K(w(),1),PP=1800000,HP=300000,g=O.createContext(null),lP=({children:G})=>{let[X,J]=O.useState(""),Q=O.useRef(Date.now()),D=O.useCallback(()=>{J("")},[]),y=O.useCallback((j)=>{Q.current=Date.now(),J(j)},[]);A(()=>{if(Date.now()-Q.current>PP)D()},HP);let V={bufferedMessage:X,setBufferedMessage:y,clearBuffer:D};return d.jsxDEV(g.Provider,{value:V,children:G},void 0,!1,void 0,this)},iP=()=>{let G=O.useContext(g);if(!G)throw Error("useChatInputBuffer must be used within ChatInputBufferProvider");return G};var T=K(R(),1);var zP=K(w(),1),sP=T.createContext(void 0);var Y=K(R(),1);var l=K(w(),1),JP=100,WP=1800000,YP=300000,u=Y.createContext(null),zH=()=>{let G=Y.useContext(u);if(!G)throw Error("useInteractionContext must be used within InteractionProvider");return G},JH=({children:G,onInteractionSubmit:X})=>{let[J,Q]=Y.useState([]),[D,y]=Y.useState(0),V=Y.useCallback(()=>{return`interaction_${Date.now()}_${Math.random().toString(36).substring(2,9)}`},[]),j=Y.useCallback((H,P)=>{let U=new Date,E={id:V(),category:"panel",state:"idle",metadata:{title:P?.metadata?.title,description:P?.metadata?.description,icon:P?.metadata?.icon,priority:P?.metadata?.priority??"medium",groupKey:P?.metadata?.groupKey,messageIndex:P?.metadata?.messageIndex},tool:P?.tool,config:{layout:{border:!0,padding:1,...P?.config?.layout},interaction:{autoSubmit:!1,allowSkip:!1,showPreview:!0,...P?.config?.interaction},style:P?.config?.style??{}},content:H,createdAt:U,updatedAt:U};return Q((I)=>{let k=[...I,E];if(k.length>JP){let C=k.filter((b)=>b.state==="submitted"||b.state==="edited"||b.state==="cancelled");if(C.length>0){let b=C[0].id;return k.filter((i)=>i.id!==b)}}return k}),y((I)=>I+1),E},[V]),N=Y.useCallback((H,P)=>{Q((U)=>U.map((E)=>E.id===H?{...E,...P,updatedAt:new Date}:E)),y((U)=>U+1)},[]),S=Y.useCallback((H)=>{Q((P)=>P.filter((U)=>U.id!==H)),y((P)=>P+1)},[]),_=Y.useCallback(()=>{Q([]),y((H)=>H+1)},[]),L=Y.useCallback((H)=>{return J.find((P)=>P.id===H)},[J]),h=Y.useCallback(()=>{return[...J]},[J]),B=Y.useCallback((H)=>{return J.filter((P)=>P.state===H)},[J]),x=Y.useCallback((H)=>{return J.filter((P)=>P.content.type===H)},[J]),f=Y.useCallback(async()=>{let H=J.filter((P)=>P.state==="submitted"||P.state==="edited"||P.state==="cancelled");for(let P of H)if(!P.resultSent&&X)await X(P),N(P.id,{resultSent:!0})},[J,X,N]),M=Y.useCallback(()=>{Q((H)=>H.filter((P)=>P.state==="idle"||P.state==="active")),y((H)=>H+1)},[]),Z=Y.useCallback(()=>{let H=Date.now();Q((P)=>P.filter((U)=>U.updatedAt.getTime()>H-WP))},[]);A(()=>{Z()},YP),q(()=>{Q((H)=>H.map((P)=>({...P,tool:void 0})))});let z=Y.useMemo(()=>J.some((H)=>H.state==="idle"||H.state==="active"),[J]),W=Y.useMemo(()=>J.length>0&&J.every((H)=>H.state==="submitted"||H.state==="edited"||H.state==="cancelled"),[J]);c(()=>{M()},W&&z===!1?100:null),Y.useEffect(()=>{if(W&&z===!1)f()},[W,z,f]);let F=Y.useMemo(()=>({addInteraction:j,updateInteraction:N,removeInteraction:S,clearAll:_,getInteraction:L,getInteractions:h,getInteractionsByState:B,getInteractionsByContent:x,submitInteractions:f,clearCompleted:M,interactions:J,updateCount:D,hasPendingInteractions:z,allInteractionsProcessed:W}),[j,N,S,_,L,h,B,x,f,M,J,D,z,W]);return l.jsxDEV(u.Provider,{value:F,children:G},void 0,!1,void 0,this)};export{ZP as D,VP as E,BP as F,CP as G,lP as H,iP as I,zH as J,JH as K};
@@ -0,0 +1,2 @@
1
+ import{Dl as X,Fl as U}from"./chunk-y8qhrx11.js";var S=U((Z,Q)=>{var V=Object.prototype.hasOwnProperty,H="~";function O(){}if(Object.create){if(O.prototype=Object.create(null),!new O().__proto__)H=!1}function W(B,q,y){this.fn=B,this.context=q,this.once=y||!1}function R(B,q,y,z,I){if(typeof y!=="function")throw TypeError("The listener must be a function");var F=new W(y,z||B,I),C=H?H+q:q;if(!B._events[C])B._events[C]=F,B._eventsCount++;else if(!B._events[C].fn)B._events[C].push(F);else B._events[C]=[B._events[C],F];return B}function P(B,q){if(--B._eventsCount===0)B._events=new O;else delete B._events[q]}function G(){this._events=new O,this._eventsCount=0}G.prototype.eventNames=function(){var q=[],y,z;if(this._eventsCount===0)return q;for(z in y=this._events)if(V.call(y,z))q.push(H?z.slice(1):z);if(Object.getOwnPropertySymbols)return q.concat(Object.getOwnPropertySymbols(y));return q};G.prototype.listeners=function(q){var y=H?H+q:q,z=this._events[y];if(!z)return[];if(z.fn)return[z.fn];for(var I=0,F=z.length,C=Array(F);I<F;I++)C[I]=z[I].fn;return C};G.prototype.listenerCount=function(q){var y=H?H+q:q,z=this._events[y];if(!z)return 0;if(z.fn)return 1;return z.length};G.prototype.emit=function(q,y,z,I,F,C){var J=H?H+q:q;if(!this._events[J])return!1;var k=this._events[J],K=arguments.length,M,D;if(k.fn){if(k.once)this.removeListener(q,k.fn,void 0,!0);switch(K){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,y),!0;case 3:return k.fn.call(k.context,y,z),!0;case 4:return k.fn.call(k.context,y,z,I),!0;case 5:return k.fn.call(k.context,y,z,I,F),!0;case 6:return k.fn.call(k.context,y,z,I,F,C),!0}for(D=1,M=Array(K-1);D<K;D++)M[D-1]=arguments[D];k.fn.apply(k.context,M)}else{var T=k.length,N;for(D=0;D<T;D++){if(k[D].once)this.removeListener(q,k[D].fn,void 0,!0);switch(K){case 1:k[D].fn.call(k[D].context);break;case 2:k[D].fn.call(k[D].context,y);break;case 3:k[D].fn.call(k[D].context,y,z);break;case 4:k[D].fn.call(k[D].context,y,z,I);break;default:if(!M)for(N=1,M=Array(K-1);N<K;N++)M[N-1]=arguments[N];k[D].fn.apply(k[D].context,M)}}}return!0};G.prototype.on=function(q,y,z){return R(this,q,y,z,!1)};G.prototype.once=function(q,y,z){return R(this,q,y,z,!0)};G.prototype.removeListener=function(q,y,z,I){var F=H?H+q:q;if(!this._events[F])return this;if(!y)return P(this,F),this;var C=this._events[F];if(C.fn){if(C.fn===y&&(!I||C.once)&&(!z||C.context===z))P(this,F)}else{for(var J=0,k=[],K=C.length;J<K;J++)if(C[J].fn!==y||I&&!C[J].once||z&&C[J].context!==z)k.push(C[J]);if(k.length)this._events[F]=k.length===1?k[0]:k;else P(this,F)}return this};G.prototype.removeAllListeners=function(q){var y;if(q){if(y=H?H+q:q,this._events[y])P(this,y)}else this._events=new O,this._eventsCount=0;return this};G.prototype.off=G.prototype.removeListener;G.prototype.addListener=G.prototype.on;G.prefixed=H;G.EventEmitter=G;if(typeof Q<"u")Q.exports=G});var Y=X(S(),1);
2
+ export{Y as C};
@@ -0,0 +1,2 @@
1
+ import{tl as o}from"./chunk-tjg2e8v3.js";var e=o;
2
+ export{e as Jk};
@@ -0,0 +1,18 @@
1
+ import{tl as h}from"./chunk-tjg2e8v3.js";import{Dl as yw,Fl as d,Il as t}from"./chunk-y8qhrx11.js";var G0=d((n1)=>{n1.isInteger=($)=>{if(typeof $==="number")return Number.isInteger($);if(typeof $==="string"&&$.trim()!=="")return Number.isInteger(Number($));return!1};n1.find=($,w)=>$.nodes.find((q)=>q.type===w);n1.exceedsLimit=($,w,q=1,J)=>{if(J===!1)return!1;if(!n1.isInteger($)||!n1.isInteger(w))return!1;return(Number(w)-Number($))/Number(q)>=J};n1.escapeNode=($,w=0,q)=>{let J=$.nodes[w];if(!J)return;if(q&&J.type===q||J.type==="open"||J.type==="close"){if(J.escaped!==!0)J.value="\\"+J.value,J.escaped=!0}};n1.encloseBrace=($)=>{if($.type!=="brace")return!1;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;return!1};n1.isInvalidBrace=($)=>{if($.type!=="brace")return!1;if($.invalid===!0||$.dollar)return!0;if($.commas>>0+$.ranges>>0===0)return $.invalid=!0,!0;if($.open!==!0||$.close!==!0)return $.invalid=!0,!0;return!1};n1.isOpenOrClose=($)=>{if($.type==="open"||$.type==="close")return!0;return $.open===!0||$.close===!0};n1.reduce=($)=>$.reduce((w,q)=>{if(q.type==="text")w.push(q.value);if(q.type==="range")q.type="text";return w},[]);n1.flatten=(...$)=>{let w=[],q=(J)=>{for(let f=0;f<J.length;f++){let Z=J[f];if(Array.isArray(Z)){q(Z);continue}if(Z!==void 0)w.push(Z)}return w};return q($),w}});var M0=d((jw,v0)=>{var d0=G0();v0.exports=($,w={})=>{let q=(J,f={})=>{let Z=w.escapeInvalid&&d0.isInvalidBrace(f),V=J.invalid===!0&&w.escapeInvalid===!0,F="";if(J.value){if((Z||V)&&d0.isOpenOrClose(J))return"\\"+J.value;return J.value}if(J.value)return J.value;if(J.nodes)for(let N of J.nodes)F+=q(N);return F};return q($)}});var l0=d((zw,m0)=>{/*!
2
+ * is-number <https://github.com/jonschlinkert/is-number>
3
+ *
4
+ * Copyright (c) 2014-present, Jon Schlinkert.
5
+ * Released under the MIT License.
6
+ */m0.exports=function($){if(typeof $==="number")return $-$===0;if(typeof $==="string"&&$.trim()!=="")return Number.isFinite?Number.isFinite(+$):isFinite(+$);return!1}});var e0=d((Iw,s0)=>{/*!
7
+ * to-regex-range <https://github.com/micromatch/to-regex-range>
8
+ *
9
+ * Copyright (c) 2015-present, Jon Schlinkert.
10
+ * Released under the MIT License.
11
+ */var u0=l0(),q0=($,w,q)=>{if(u0($)===!1)throw TypeError("toRegexRange: expected the first argument to be a number");if(w===void 0||$===w)return String($);if(u0(w)===!1)throw TypeError("toRegexRange: expected the second argument to be a number.");let J={relaxZeros:!0,...q};if(typeof J.strictZeros==="boolean")J.relaxZeros=J.strictZeros===!1;let f=String(J.relaxZeros),Z=String(J.shorthand),V=String(J.capture),F=String(J.wrap),N=$+":"+w+"="+f+Z+V+F;if(q0.cache.hasOwnProperty(N))return q0.cache[N].result;let K=Math.min($,w),B=Math.max($,w);if(Math.abs(K-B)===1){let M=$+"|"+w;if(J.capture)return`(${M})`;if(J.wrap===!1)return M;return`(?:${M})`}let j=a0($)||a0(w),X={min:$,max:w,a:K,b:B},H=[],y=[];if(j)X.isPadded=j,X.maxLen=String(X.max).length;if(K<0){let M=B<0?Math.abs(B):1;y=c0(M,Math.abs(K),X,J),K=X.a=0}if(B>=0)H=c0(K,B,X,J);if(X.negatives=y,X.positives=H,X.result=q$(y,H,J),J.capture===!0)X.result=`(${X.result})`;else if(J.wrap!==!1&&H.length+y.length>1)X.result=`(?:${X.result})`;return q0.cache[N]=X,X.result};function q$($,w,q){let J=P0($,w,"-",!1,q)||[],f=P0(w,$,"",!1,q)||[],Z=P0($,w,"-?",!0,q)||[];return J.concat(Z).concat(f).join("|")}function J$($,w){let q=1,J=1,f=i0($,q),Z=new Set([w]);while($<=f&&f<=w)Z.add(f),q+=1,f=i0($,q);f=n0(w+1,J)-1;while($<f&&f<=w)Z.add(f),J+=1,f=n0(w+1,J)-1;return Z=[...Z],Z.sort(Z$),Z}function f$($,w,q){if($===w)return{pattern:$,count:[],digits:0};let J=V$($,w),f=J.length,Z="",V=0;for(let F=0;F<f;F++){let[N,K]=J[F];if(N===K)Z+=N;else if(N!=="0"||K!=="9")Z+=Y$(N,K,q);else V++}if(V)Z+=q.shorthand===!0?"\\d":"[0-9]";return{pattern:Z,count:[V],digits:f}}function c0($,w,q,J){let f=J$($,w),Z=[],V=$,F;for(let N=0;N<f.length;N++){let K=f[N],B=f$(String(V),String(K),J),j="";if(!q.isPadded&&F&&F.pattern===B.pattern){if(F.count.length>1)F.count.pop();F.count.push(B.count[0]),F.string=F.pattern+p0(F.count),V=K+1;continue}if(q.isPadded)j=W$(K,q,J);B.string=j+B.pattern+p0(B.count),Z.push(B),V=K+1,F=B}return Z}function P0($,w,q,J,f){let Z=[];for(let V of $){let{string:F}=V;if(!J&&!r0(w,"string",F))Z.push(q+F);if(J&&r0(w,"string",F))Z.push(q+F)}return Z}function V$($,w){let q=[];for(let J=0;J<$.length;J++)q.push([$[J],w[J]]);return q}function Z$($,w){return $>w?1:w>$?-1:0}function r0($,w,q){return $.some((J)=>J[w]===q)}function i0($,w){return Number(String($).slice(0,-w)+"9".repeat(w))}function n0($,w){return $-$%Math.pow(10,w)}function p0($){let[w=0,q=""]=$;if(q||w>1)return`{${w+(q?","+q:"")}}`;return""}function Y$($,w,q){return`[${$}${w-$===1?"":"-"}${w}]`}function a0($){return/^-?(0+)\d/.test($)}function W$($,w,q){if(!w.isPadded)return $;let J=Math.abs(w.maxLen-String($).length),f=q.relaxZeros!==!1;switch(J){case 0:return"";case 1:return f?"0?":"0";case 2:return f?"0{0,2}":"00";default:return f?`0{0,${J}}`:`0{${J}}`}}q0.cache={};q0.clearCache=()=>q0.cache={};s0.exports=q0});var E0=d((Cw,f1)=>{/*!
12
+ * fill-range <https://github.com/jonschlinkert/fill-range>
13
+ *
14
+ * Copyright (c) 2014-present, Jon Schlinkert.
15
+ * Licensed under the MIT License.
16
+ */var F$=t("util"),t0=e0(),o0=($)=>$!==null&&typeof $==="object"&&!Array.isArray($),U$=($)=>{return(w)=>$===!0?Number(w):String(w)},L0=($)=>{return typeof $==="number"||typeof $==="string"&&$!==""},Y0=($)=>Number.isInteger(+$),O0=($)=>{let w=`${$}`,q=-1;if(w[0]==="-")w=w.slice(1);if(w==="0")return!1;while(w[++q]==="0");return q>0},X$=($,w,q)=>{if(typeof $==="string"||typeof w==="string")return!0;return q.stringify===!0},Q$=($,w,q)=>{if(w>0){let J=$[0]==="-"?"-":"";if(J)$=$.slice(1);$=J+$.padStart(J?w-1:w,"0")}if(q===!1)return String($);return $},K0=($,w)=>{let q=$[0]==="-"?"-":"";if(q)$=$.slice(1),w--;while($.length<w)$="0"+$;return q?"-"+$:$},B$=($,w,q)=>{$.negatives.sort((F,N)=>F<N?-1:F>N?1:0),$.positives.sort((F,N)=>F<N?-1:F>N?1:0);let J=w.capture?"":"?:",f="",Z="",V;if($.positives.length)f=$.positives.map((F)=>K0(String(F),q)).join("|");if($.negatives.length)Z=`-(${J}${$.negatives.map((F)=>K0(String(F),q)).join("|")})`;if(f&&Z)V=`${f}|${Z}`;else V=f||Z;if(w.wrap)return`(${J}${V})`;return V},$1=($,w,q,J)=>{if(q)return t0($,w,{wrap:!1,...J});let f=String.fromCharCode($);if($===w)return f;let Z=String.fromCharCode(w);return`[${f}-${Z}]`},w1=($,w,q)=>{if(Array.isArray($)){let J=q.wrap===!0,f=q.capture?"":"?:";return J?`(${f}${$.join("|")})`:$.join("|")}return t0($,w,q)},q1=(...$)=>{return RangeError("Invalid range arguments: "+F$.inspect(...$))},J1=($,w,q)=>{if(q.strictRanges===!0)throw q1([$,w]);return[]},N$=($,w)=>{if(w.strictRanges===!0)throw TypeError(`Expected step "${$}" to be a number`);return[]},G$=($,w,q=1,J={})=>{let f=Number($),Z=Number(w);if(!Number.isInteger(f)||!Number.isInteger(Z)){if(J.strictRanges===!0)throw q1([$,w]);return[]}if(f===0)f=0;if(Z===0)Z=0;let V=f>Z,F=String($),N=String(w),K=String(q);q=Math.max(Math.abs(q),1);let B=O0(F)||O0(N)||O0(K),j=B?Math.max(F.length,N.length,K.length):0,X=B===!1&&X$($,w,J)===!1,H=J.transform||U$(X);if(J.toRegex&&q===1)return $1(K0($,j),K0(w,j),!0,J);let y={negatives:[],positives:[]},M=(u)=>y[u<0?"negatives":"positives"].push(Math.abs(u)),L=[],A=0;while(V?f>=Z:f<=Z){if(J.toRegex===!0&&q>1)M(f);else L.push(Q$(H(f,A),j,X));f=V?f-q:f+q,A++}if(J.toRegex===!0)return q>1?B$(y,J,j):w1(L,null,{wrap:!1,...J});return L},M$=($,w,q=1,J={})=>{if(!Y0($)&&$.length>1||!Y0(w)&&w.length>1)return J1($,w,J);let f=J.transform||((X)=>String.fromCharCode(X)),Z=`${$}`.charCodeAt(0),V=`${w}`.charCodeAt(0),F=Z>V,N=Math.min(Z,V),K=Math.max(Z,V);if(J.toRegex&&q===1)return $1(N,K,!1,J);let B=[],j=0;while(F?Z>=V:Z<=V)B.push(f(Z,j)),Z=F?Z-q:Z+q,j++;if(J.toRegex===!0)return w1(B,null,{wrap:!1,options:J});return B},y0=($,w,q,J={})=>{if(w==null&&L0($))return[$];if(!L0($)||!L0(w))return J1($,w,J);if(typeof q==="function")return y0($,w,1,{transform:q});if(o0(q))return y0($,w,0,q);let f={...J};if(f.capture===!0)f.wrap=!0;if(q=q||f.step||1,!Y0(q)){if(q!=null&&!o0(q))return N$(q,f);return y0($,w,1,q)}if(Y0($)&&Y0(w))return G$($,w,q,f);return M$($,w,Math.max(Math.abs(q),1),f)};f1.exports=y0});var Y1=d((Dw,Z1)=>{var y$=E0(),V1=G0(),K$=($,w={})=>{let q=(J,f={})=>{let Z=V1.isInvalidBrace(f),V=J.invalid===!0&&w.escapeInvalid===!0,F=Z===!0||V===!0,N=w.escapeInvalid===!0?"\\":"",K="";if(J.isOpen===!0)return N+J.value;if(J.isClose===!0)return console.log("node.isClose",N,J.value),N+J.value;if(J.type==="open")return F?N+J.value:"(";if(J.type==="close")return F?N+J.value:")";if(J.type==="comma")return J.prev.type==="comma"?"":F?J.value:"|";if(J.value)return J.value;if(J.nodes&&J.ranges>0){let B=V1.reduce(J.nodes),j=y$(...B,{...w,wrap:!1,toRegex:!0,strictZeros:!0});if(j.length!==0)return B.length>1&&j.length>1?`(${j})`:j}if(J.nodes)for(let B of J.nodes)K+=q(B,J);return K};return q($)};Z1.exports=K$});var U1=d((Hw,F1)=>{var j$=E0(),W1=M0(),V0=G0(),J0=($="",w="",q=!1)=>{let J=[];if($=[].concat($),w=[].concat(w),!w.length)return $;if(!$.length)return q?V0.flatten(w).map((f)=>`{${f}}`):w;for(let f of $)if(Array.isArray(f))for(let Z of f)J.push(J0(Z,w,q));else for(let Z of w){if(q===!0&&typeof Z==="string")Z=`{${Z}}`;J.push(Array.isArray(Z)?J0(f,Z,q):f+Z)}return V0.flatten(J)},z$=($,w={})=>{let q=w.rangeLimit===void 0?1000:w.rangeLimit,J=(f,Z={})=>{f.queue=[];let V=Z,F=Z.queue;while(V.type!=="brace"&&V.type!=="root"&&V.parent)V=V.parent,F=V.queue;if(f.invalid||f.dollar){F.push(J0(F.pop(),W1(f,w)));return}if(f.type==="brace"&&f.invalid!==!0&&f.nodes.length===2){F.push(J0(F.pop(),["{}"]));return}if(f.nodes&&f.ranges>0){let j=V0.reduce(f.nodes);if(V0.exceedsLimit(...j,w.step,q))throw RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let X=j$(...j,w);if(X.length===0)X=W1(f,w);F.push(J0(F.pop(),X)),f.nodes=[];return}let N=V0.encloseBrace(f),K=f.queue,B=f;while(B.type!=="brace"&&B.type!=="root"&&B.parent)B=B.parent,K=B.queue;for(let j=0;j<f.nodes.length;j++){let X=f.nodes[j];if(X.type==="comma"&&f.type==="brace"){if(j===1)K.push("");K.push("");continue}if(X.type==="close"){F.push(J0(F.pop(),K,N));continue}if(X.value&&X.type!=="open"){K.push(J0(K.pop(),X.value));continue}if(X.nodes)J(X,f)}return K};return V0.flatten(J($))};F1.exports=z$});var Q1=d((Pw,X1)=>{X1.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
17
+ `,CHAR_NO_BREAK_SPACE:" ",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:"\t",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var y1=d((Lw,M1)=>{var I$=M0(),{MAX_LENGTH:B1,CHAR_BACKSLASH:R0,CHAR_BACKTICK:C$,CHAR_COMMA:D$,CHAR_DOT:H$,CHAR_LEFT_PARENTHESES:P$,CHAR_RIGHT_PARENTHESES:L$,CHAR_LEFT_CURLY_BRACE:O$,CHAR_RIGHT_CURLY_BRACE:E$,CHAR_LEFT_SQUARE_BRACKET:N1,CHAR_RIGHT_SQUARE_BRACKET:G1,CHAR_DOUBLE_QUOTE:R$,CHAR_SINGLE_QUOTE:_$,CHAR_NO_BREAK_SPACE:T$,CHAR_ZERO_WIDTH_NOBREAK_SPACE:A$}=Q1(),S$=($,w={})=>{if(typeof $!=="string")throw TypeError("Expected a string");let q=w||{},J=typeof q.maxLength==="number"?Math.min(B1,q.maxLength):B1;if($.length>J)throw SyntaxError(`Input length (${$.length}), exceeds max characters (${J})`);let f={type:"root",input:$,nodes:[]},Z=[f],V=f,F=f,N=0,K=$.length,B=0,j=0,X,H=()=>$[B++],y=(M)=>{if(M.type==="text"&&F.type==="dot")F.type="text";if(F&&F.type==="text"&&M.type==="text"){F.value+=M.value;return}return V.nodes.push(M),M.parent=V,M.prev=F,F=M,M};y({type:"bos"});while(B<K){if(V=Z[Z.length-1],X=H(),X===A$||X===T$)continue;if(X===R0){y({type:"text",value:(w.keepEscaping?X:"")+H()});continue}if(X===G1){y({type:"text",value:"\\"+X});continue}if(X===N1){N++;let M;while(B<K&&(M=H())){if(X+=M,M===N1){N++;continue}if(M===R0){X+=H();continue}if(M===G1){if(N--,N===0)break}}y({type:"text",value:X});continue}if(X===P$){V=y({type:"paren",nodes:[]}),Z.push(V),y({type:"text",value:X});continue}if(X===L$){if(V.type!=="paren"){y({type:"text",value:X});continue}V=Z.pop(),y({type:"text",value:X}),V=Z[Z.length-1];continue}if(X===R$||X===_$||X===C$){let M=X,L;if(w.keepQuotes!==!0)X="";while(B<K&&(L=H())){if(L===R0){X+=L+H();continue}if(L===M){if(w.keepQuotes===!0)X+=L;break}X+=L}y({type:"text",value:X});continue}if(X===O$){j++;let L={type:"brace",open:!0,close:!1,dollar:F.value&&F.value.slice(-1)==="$"||V.dollar===!0,depth:j,commas:0,ranges:0,nodes:[]};V=y(L),Z.push(V),y({type:"open",value:X});continue}if(X===E$){if(V.type!=="brace"){y({type:"text",value:X});continue}let M="close";V=Z.pop(),V.close=!0,y({type:M,value:X}),j--,V=Z[Z.length-1];continue}if(X===D$&&j>0){if(V.ranges>0){V.ranges=0;let M=V.nodes.shift();V.nodes=[M,{type:"text",value:I$(V)}]}y({type:"comma",value:X}),V.commas++;continue}if(X===H$&&j>0&&V.commas===0){let M=V.nodes;if(j===0||M.length===0){y({type:"text",value:X});continue}if(F.type==="dot"){if(V.range=[],F.value+=X,F.type="range",V.nodes.length!==3&&V.nodes.length!==5){V.invalid=!0,V.ranges=0,F.type="text";continue}V.ranges++,V.args=[];continue}if(F.type==="range"){M.pop();let L=M[M.length-1];L.value+=F.value+X,F=L,V.ranges--;continue}y({type:"dot",value:X});continue}y({type:"text",value:X})}do if(V=Z.pop(),V.type!=="root"){V.nodes.forEach((A)=>{if(!A.nodes){if(A.type==="open")A.isOpen=!0;if(A.type==="close")A.isClose=!0;if(!A.nodes)A.type="text";A.invalid=!0}});let M=Z[Z.length-1],L=M.nodes.indexOf(V);M.nodes.splice(L,1,...V.nodes)}while(Z.length>0);return y({type:"eos"}),f};M1.exports=S$});var z1=d((Ow,j1)=>{var K1=M0(),x$=Y1(),g$=U1(),h$=y1(),r=($,w={})=>{let q=[];if(Array.isArray($))for(let J of $){let f=r.create(J,w);if(Array.isArray(f))q.push(...f);else q.push(f)}else q=[].concat(r.create($,w));if(w&&w.expand===!0&&w.nodupes===!0)q=[...new Set(q)];return q};r.parse=($,w={})=>h$($,w);r.stringify=($,w={})=>{if(typeof $==="string")return K1(r.parse($,w),w);return K1($,w)};r.compile=($,w={})=>{if(typeof $==="string")$=r.parse($,w);return x$($,w)};r.expand=($,w={})=>{if(typeof $==="string")$=r.parse($,w);let q=g$($,w);if(w.noempty===!0)q=q.filter(Boolean);if(w.nodupes===!0)q=[...new Set(q)];return q};r.create=($,w={})=>{if($===""||$.length<3)return[$];return w.expand!==!0?r.compile($,w):r.expand($,w)};j1.exports=r});var W0=d((Ew,C1)=>{var k$=t("path"),I1={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:"[^/]",END_ANCHOR:"(?:\\/|$)",DOTS_SLASH:"\\.{1,2}(?:\\/|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|\\/)\\.{1,2}(?:\\/|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:\\/|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:\\/|$))",QMARK_NO_DOT:"[^.\\/]",STAR:"[^/]*?",START_ANCHOR:"(?:^|\\/)"},b$={...I1,SLASH_LITERAL:"[\\\\/]",QMARK:"[^\\\\/]",STAR:"[^\\\\/]*?",DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)"},d$={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};C1.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:d$,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:k$.sep,extglobChars($){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${$.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars($){return $===!0?b$:I1}}});var F0=d((i$)=>{var v$=t("path"),m$=process.platform==="win32",{REGEX_BACKSLASH:l$,REGEX_REMOVE_BACKSLASH:u$,REGEX_SPECIAL_CHARS:c$,REGEX_SPECIAL_CHARS_GLOBAL:r$}=W0();i$.isObject=($)=>$!==null&&typeof $==="object"&&!Array.isArray($);i$.hasRegexChars=($)=>c$.test($);i$.isRegexChar=($)=>$.length===1&&i$.hasRegexChars($);i$.escapeRegex=($)=>$.replace(r$,"\\$1");i$.toPosixSlashes=($)=>$.replace(l$,"/");i$.removeBackslashes=($)=>{return $.replace(u$,(w)=>{return w==="\\"?"":w})};i$.supportsLookbehinds=()=>{let $=process.version.slice(1).split(".").map(Number);if($.length===3&&$[0]>=9||$[0]===8&&$[1]>=10)return!0;return!1};i$.isWindows=($)=>{if($&&typeof $.windows==="boolean")return $.windows;return m$===!0||v$.sep==="\\"};i$.escapeLast=($,w,q)=>{let J=$.lastIndexOf(w,q);if(J===-1)return $;if($[J-1]==="\\")return i$.escapeLast($,w,J-1);return`${$.slice(0,J)}\\${$.slice(J)}`};i$.removePrefix=($,w={})=>{let q=$;if(q.startsWith("./"))q=q.slice(2),w.prefix="./";return q};i$.wrapOutput=($,w={},q={})=>{let J=q.contains?"":"^",f=q.contains?"":"$",Z=`${J}(?:${$})${f}`;if(w.negated===!0)Z=`(?:^(?!${Z}).*$)`;return Z}});var A1=d((_w,T1)=>{var P1=F0(),{CHAR_ASTERISK:_0,CHAR_AT:qw,CHAR_BACKWARD_SLASH:U0,CHAR_COMMA:Jw,CHAR_DOT:T0,CHAR_EXCLAMATION_MARK:A0,CHAR_FORWARD_SLASH:_1,CHAR_LEFT_CURLY_BRACE:S0,CHAR_LEFT_PARENTHESES:x0,CHAR_LEFT_SQUARE_BRACKET:fw,CHAR_PLUS:Vw,CHAR_QUESTION_MARK:L1,CHAR_RIGHT_CURLY_BRACE:Zw,CHAR_RIGHT_PARENTHESES:O1,CHAR_RIGHT_SQUARE_BRACKET:Yw}=W0(),E1=($)=>{return $===_1||$===U0},R1=($)=>{if($.isPrefix!==!0)$.depth=$.isGlobstar?1/0:1},Ww=($,w)=>{let q=w||{},J=$.length-1,f=q.parts===!0||q.scanToEnd===!0,Z=[],V=[],F=[],N=$,K=-1,B=0,j=0,X=!1,H=!1,y=!1,M=!1,L=!1,A=!1,u=!1,S=!1,n=!1,b=!1,e=0,v,z,P={value:"",depth:0,isGlob:!1},k=()=>K>=J,U=()=>N.charCodeAt(K+1),_=()=>{return v=z,N.charCodeAt(++K)};while(K<J){z=_();let m;if(z===U0){if(u=P.backslashes=!0,z=_(),z===S0)A=!0;continue}if(A===!0||z===S0){e++;while(k()!==!0&&(z=_())){if(z===U0){u=P.backslashes=!0,_();continue}if(z===S0){e++;continue}if(A!==!0&&z===T0&&(z=_())===T0){if(X=P.isBrace=!0,y=P.isGlob=!0,b=!0,f===!0)continue;break}if(A!==!0&&z===Jw){if(X=P.isBrace=!0,y=P.isGlob=!0,b=!0,f===!0)continue;break}if(z===Zw){if(e--,e===0){A=!1,X=P.isBrace=!0,b=!0;break}}}if(f===!0)continue;break}if(z===_1){if(Z.push(K),V.push(P),P={value:"",depth:0,isGlob:!1},b===!0)continue;if(v===T0&&K===B+1){B+=2;continue}j=K+1;continue}if(q.noext!==!0){if((z===Vw||z===qw||z===_0||z===L1||z===A0)===!0&&U()===x0){if(y=P.isGlob=!0,M=P.isExtglob=!0,b=!0,z===A0&&K===B)n=!0;if(f===!0){while(k()!==!0&&(z=_())){if(z===U0){u=P.backslashes=!0,z=_();continue}if(z===O1){y=P.isGlob=!0,b=!0;break}}continue}break}}if(z===_0){if(v===_0)L=P.isGlobstar=!0;if(y=P.isGlob=!0,b=!0,f===!0)continue;break}if(z===L1){if(y=P.isGlob=!0,b=!0,f===!0)continue;break}if(z===fw){while(k()!==!0&&(m=_())){if(m===U0){u=P.backslashes=!0,_();continue}if(m===Yw){H=P.isBracket=!0,y=P.isGlob=!0,b=!0;break}}if(f===!0)continue;break}if(q.nonegate!==!0&&z===A0&&K===B){S=P.negated=!0,B++;continue}if(q.noparen!==!0&&z===x0){if(y=P.isGlob=!0,f===!0){while(k()!==!0&&(z=_())){if(z===x0){u=P.backslashes=!0,z=_();continue}if(z===O1){b=!0;break}}continue}break}if(y===!0){if(b=!0,f===!0)continue;break}}if(q.noext===!0)M=!1,y=!1;let O=N,o="",Y="";if(B>0)o=N.slice(0,B),N=N.slice(B),j-=B;if(O&&y===!0&&j>0)O=N.slice(0,j),Y=N.slice(j);else if(y===!0)O="",Y=N;else O=N;if(O&&O!==""&&O!=="/"&&O!==N){if(E1(O.charCodeAt(O.length-1)))O=O.slice(0,-1)}if(q.unescape===!0){if(Y)Y=P1.removeBackslashes(Y);if(O&&u===!0)O=P1.removeBackslashes(O)}let W={prefix:o,input:$,start:B,base:O,glob:Y,isBrace:X,isBracket:H,isGlob:y,isExtglob:M,isGlobstar:L,negated:S,negatedExtglob:n};if(q.tokens===!0){if(W.maxDepth=0,!E1(z))V.push(P);W.tokens=V}if(q.parts===!0||q.tokens===!0){let m;for(let D=0;D<Z.length;D++){let p=m?m+1:B,a=Z[D],c=$.slice(p,a);if(q.tokens){if(D===0&&B!==0)V[D].isPrefix=!0,V[D].value=o;else V[D].value=c;R1(V[D]),W.maxDepth+=V[D].depth}if(D!==0||c!=="")F.push(c);m=a}if(m&&m+1<$.length){let D=$.slice(m+1);if(F.push(D),q.tokens)V[V.length-1].value=D,R1(V[V.length-1]),W.maxDepth+=V[V.length-1].depth}W.slashes=Z,W.parts=F}return W};T1.exports=Ww});var g1=d((Tw,x1)=>{var j0=W0(),i=F0(),{MAX_LENGTH:z0,POSIX_REGEX_SOURCE:Fw,REGEX_NON_SPECIAL_CHARS:Uw,REGEX_SPECIAL_CHARS_BACKREF:Xw,REPLACEMENTS:S1}=j0,Qw=($,w)=>{if(typeof w.expandRange==="function")return w.expandRange(...$,w);$.sort();let q=`[${$.join("-")}]`;try{new RegExp(q)}catch(J){return $.map((f)=>i.escapeRegex(f)).join("..")}return q},Z0=($,w)=>{return`Missing ${$}: "${w}" - use "\\\\${w}" to match literal characters`},g0=($,w)=>{if(typeof $!=="string")throw TypeError("Expected a string");$=S1[$]||$;let q={...w},J=typeof q.maxLength==="number"?Math.min(z0,q.maxLength):z0,f=$.length;if(f>J)throw SyntaxError(`Input length: ${f}, exceeds maximum allowed length: ${J}`);let Z={type:"bos",value:"",output:q.prepend||""},V=[Z],F=q.capture?"":"?:",N=i.isWindows(w),K=j0.globChars(N),B=j0.extglobChars(K),{DOT_LITERAL:j,PLUS_LITERAL:X,SLASH_LITERAL:H,ONE_CHAR:y,DOTS_SLASH:M,NO_DOT:L,NO_DOT_SLASH:A,NO_DOTS_SLASH:u,QMARK:S,QMARK_NO_DOT:n,STAR:b,START_ANCHOR:e}=K,v=(G)=>{return`(${F}(?:(?!${e}${G.dot?M:j}).)*?)`},z=q.dot?"":L,P=q.dot?S:n,k=q.bash===!0?v(q):b;if(q.capture)k=`(${k})`;if(typeof q.noext==="boolean")q.noextglob=q.noext;let U={input:$,index:-1,start:0,dot:q.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:V};$=i.removePrefix($,U),f=$.length;let _=[],O=[],o=[],Y=Z,W,m=()=>U.index===f-1,D=U.peek=(G=1)=>$[U.index+G],p=U.advance=()=>$[++U.index]||"",a=()=>$.slice(U.index+1),c=(G="",E=0)=>{U.consumed+=G,U.index+=E},X0=(G)=>{U.output+=G.output!=null?G.output:G.value,c(G.value)},r1=()=>{let G=1;while(D()==="!"&&(D(2)!=="("||D(3)==="?"))p(),U.start++,G++;if(G%2===0)return!1;return U.negated=!0,U.start++,!0},Q0=(G)=>{U[G]++,o.push(G)},w0=(G)=>{U[G]--,o.pop()},C=(G)=>{if(Y.type==="globstar"){let E=U.braces>0&&(G.type==="comma"||G.type==="brace"),Q=G.extglob===!0||_.length&&(G.type==="pipe"||G.type==="paren");if(G.type!=="slash"&&G.type!=="paren"&&!E&&!Q)U.output=U.output.slice(0,-Y.output.length),Y.type="star",Y.value="*",Y.output=k,U.output+=Y.output}if(_.length&&G.type!=="paren")_[_.length-1].inner+=G.value;if(G.value||G.output)X0(G);if(Y&&Y.type==="text"&&G.type==="text"){Y.value+=G.value,Y.output=(Y.output||"")+G.value;return}G.prev=Y,V.push(G),Y=G},B0=(G,E)=>{let Q={...B[E],conditions:1,inner:""};Q.prev=Y,Q.parens=U.parens,Q.output=U.output;let I=(q.capture?"(":"")+Q.open;Q0("parens"),C({type:G,value:E,output:U.output?"":y}),C({type:"paren",extglob:!0,value:p(),output:I}),_.push(Q)},i1=(G)=>{let E=G.close+(q.capture?")":""),Q;if(G.type==="negate"){let I=k;if(G.inner&&G.inner.length>1&&G.inner.includes("/"))I=v(q);if(I!==k||m()||/^\)+$/.test(a()))E=G.close=`)$))${I}`;if(G.inner.includes("*")&&(Q=a())&&/^\.[^\\/.]+$/.test(Q)){let T=g0(Q,{...w,fastpaths:!1}).output;E=G.close=`)${T})${I})`}if(G.prev.type==="bos")U.negatedExtglob=!0}C({type:"paren",extglob:!0,value:W,output:E}),w0("parens")};if(q.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test($)){let G=!1,E=$.replace(Xw,(Q,I,T,l,g,D0)=>{if(l==="\\")return G=!0,Q;if(l==="?"){if(I)return I+l+(g?S.repeat(g.length):"");if(D0===0)return P+(g?S.repeat(g.length):"");return S.repeat(T.length)}if(l===".")return j.repeat(T.length);if(l==="*"){if(I)return I+l+(g?k:"");return k}return I?Q:`\\${Q}`});if(G===!0)if(q.unescape===!0)E=E.replace(/\\/g,"");else E=E.replace(/\\+/g,(Q)=>{return Q.length%2===0?"\\\\":Q?"\\":""});if(E===$&&q.contains===!0)return U.output=$,U;return U.output=i.wrapOutput(E,U,w),U}while(!m()){if(W=p(),W==="\x00")continue;if(W==="\\"){let Q=D();if(Q==="/"&&q.bash!==!0)continue;if(Q==="."||Q===";")continue;if(!Q){W+="\\",C({type:"text",value:W});continue}let I=/^\\+/.exec(a()),T=0;if(I&&I[0].length>2){if(T=I[0].length,U.index+=T,T%2!==0)W+="\\"}if(q.unescape===!0)W=p();else W+=p();if(U.brackets===0){C({type:"text",value:W});continue}}if(U.brackets>0&&(W!=="]"||Y.value==="["||Y.value==="[^")){if(q.posix!==!1&&W===":"){let Q=Y.value.slice(1);if(Q.includes("[")){if(Y.posix=!0,Q.includes(":")){let I=Y.value.lastIndexOf("["),T=Y.value.slice(0,I),l=Y.value.slice(I+2),g=Fw[l];if(g){if(Y.value=T+g,U.backtrack=!0,p(),!Z.output&&V.indexOf(Y)===1)Z.output=y;continue}}}}if(W==="["&&D()!==":"||W==="-"&&D()==="]")W=`\\${W}`;if(W==="]"&&(Y.value==="["||Y.value==="[^"))W=`\\${W}`;if(q.posix===!0&&W==="!"&&Y.value==="[")W="^";Y.value+=W,X0({value:W});continue}if(U.quotes===1&&W!=='"'){W=i.escapeRegex(W),Y.value+=W,X0({value:W});continue}if(W==='"'){if(U.quotes=U.quotes===1?0:1,q.keepQuotes===!0)C({type:"text",value:W});continue}if(W==="("){Q0("parens"),C({type:"paren",value:W});continue}if(W===")"){if(U.parens===0&&q.strictBrackets===!0)throw SyntaxError(Z0("opening","("));let Q=_[_.length-1];if(Q&&U.parens===Q.parens+1){i1(_.pop());continue}C({type:"paren",value:W,output:U.parens?")":"\\)"}),w0("parens");continue}if(W==="["){if(q.nobracket===!0||!a().includes("]")){if(q.nobracket!==!0&&q.strictBrackets===!0)throw SyntaxError(Z0("closing","]"));W=`\\${W}`}else Q0("brackets");C({type:"bracket",value:W});continue}if(W==="]"){if(q.nobracket===!0||Y&&Y.type==="bracket"&&Y.value.length===1){C({type:"text",value:W,output:`\\${W}`});continue}if(U.brackets===0){if(q.strictBrackets===!0)throw SyntaxError(Z0("opening","["));C({type:"text",value:W,output:`\\${W}`});continue}w0("brackets");let Q=Y.value.slice(1);if(Y.posix!==!0&&Q[0]==="^"&&!Q.includes("/"))W=`/${W}`;if(Y.value+=W,X0({value:W}),q.literalBrackets===!1||i.hasRegexChars(Q))continue;let I=i.escapeRegex(Y.value);if(U.output=U.output.slice(0,-Y.value.length),q.literalBrackets===!0){U.output+=I,Y.value=I;continue}Y.value=`(${F}${I}|${Y.value})`,U.output+=Y.value;continue}if(W==="{"&&q.nobrace!==!0){Q0("braces");let Q={type:"brace",value:W,output:"(",outputIndex:U.output.length,tokensIndex:U.tokens.length};O.push(Q),C(Q);continue}if(W==="}"){let Q=O[O.length-1];if(q.nobrace===!0||!Q){C({type:"text",value:W,output:W});continue}let I=")";if(Q.dots===!0){let T=V.slice(),l=[];for(let g=T.length-1;g>=0;g--){if(V.pop(),T[g].type==="brace")break;if(T[g].type!=="dots")l.unshift(T[g].value)}I=Qw(l,q),U.backtrack=!0}if(Q.comma!==!0&&Q.dots!==!0){let T=U.output.slice(0,Q.outputIndex),l=U.tokens.slice(Q.tokensIndex);Q.value=Q.output="\\{",W=I="\\}",U.output=T;for(let g of l)U.output+=g.output||g.value}C({type:"brace",value:W,output:I}),w0("braces"),O.pop();continue}if(W==="|"){if(_.length>0)_[_.length-1].conditions++;C({type:"text",value:W});continue}if(W===","){let Q=W,I=O[O.length-1];if(I&&o[o.length-1]==="braces")I.comma=!0,Q="|";C({type:"comma",value:W,output:Q});continue}if(W==="/"){if(Y.type==="dot"&&U.index===U.start+1){U.start=U.index+1,U.consumed="",U.output="",V.pop(),Y=Z;continue}C({type:"slash",value:W,output:H});continue}if(W==="."){if(U.braces>0&&Y.type==="dot"){if(Y.value===".")Y.output=j;let Q=O[O.length-1];Y.type="dots",Y.output+=W,Y.value+=W,Q.dots=!0;continue}if(U.braces+U.parens===0&&Y.type!=="bos"&&Y.type!=="slash"){C({type:"text",value:W,output:j});continue}C({type:"dot",value:W,output:j});continue}if(W==="?"){if(!(Y&&Y.value==="(")&&q.noextglob!==!0&&D()==="("&&D(2)!=="?"){B0("qmark",W);continue}if(Y&&Y.type==="paren"){let I=D(),T=W;if(I==="<"&&!i.supportsLookbehinds())throw Error("Node.js v10 or higher is required for regex lookbehinds");if(Y.value==="("&&!/[!=<:]/.test(I)||I==="<"&&!/<([!=]|\w+>)/.test(a()))T=`\\${W}`;C({type:"text",value:W,output:T});continue}if(q.dot!==!0&&(Y.type==="slash"||Y.type==="bos")){C({type:"qmark",value:W,output:n});continue}C({type:"qmark",value:W,output:S});continue}if(W==="!"){if(q.noextglob!==!0&&D()==="("){if(D(2)!=="?"||!/[!=<:]/.test(D(3))){B0("negate",W);continue}}if(q.nonegate!==!0&&U.index===0){r1();continue}}if(W==="+"){if(q.noextglob!==!0&&D()==="("&&D(2)!=="?"){B0("plus",W);continue}if(Y&&Y.value==="("||q.regex===!1){C({type:"plus",value:W,output:X});continue}if(Y&&(Y.type==="bracket"||Y.type==="paren"||Y.type==="brace")||U.parens>0){C({type:"plus",value:W});continue}C({type:"plus",value:X});continue}if(W==="@"){if(q.noextglob!==!0&&D()==="("&&D(2)!=="?"){C({type:"at",extglob:!0,value:W,output:""});continue}C({type:"text",value:W});continue}if(W!=="*"){if(W==="$"||W==="^")W=`\\${W}`;let Q=Uw.exec(a());if(Q)W+=Q[0],U.index+=Q[0].length;C({type:"text",value:W});continue}if(Y&&(Y.type==="globstar"||Y.star===!0)){Y.type="star",Y.star=!0,Y.value+=W,Y.output=k,U.backtrack=!0,U.globstar=!0,c(W);continue}let G=a();if(q.noextglob!==!0&&/^\([^?]/.test(G)){B0("star",W);continue}if(Y.type==="star"){if(q.noglobstar===!0){c(W);continue}let Q=Y.prev,I=Q.prev,T=Q.type==="slash"||Q.type==="bos",l=I&&(I.type==="star"||I.type==="globstar");if(q.bash===!0&&(!T||G[0]&&G[0]!=="/")){C({type:"star",value:W,output:""});continue}let g=U.braces>0&&(Q.type==="comma"||Q.type==="brace"),D0=_.length&&(Q.type==="pipe"||Q.type==="paren");if(!T&&Q.type!=="paren"&&!g&&!D0){C({type:"star",value:W,output:""});continue}while(G.slice(0,3)==="/**"){let N0=$[U.index+4];if(N0&&N0!=="/")break;G=G.slice(3),c("/**",3)}if(Q.type==="bos"&&m()){Y.type="globstar",Y.value+=W,Y.output=v(q),U.output=Y.output,U.globstar=!0,c(W);continue}if(Q.type==="slash"&&Q.prev.type!=="bos"&&!l&&m()){U.output=U.output.slice(0,-(Q.output+Y.output).length),Q.output=`(?:${Q.output}`,Y.type="globstar",Y.output=v(q)+(q.strictSlashes?")":"|$)"),Y.value+=W,U.globstar=!0,U.output+=Q.output+Y.output,c(W);continue}if(Q.type==="slash"&&Q.prev.type!=="bos"&&G[0]==="/"){let N0=G[1]!==void 0?"|$":"";U.output=U.output.slice(0,-(Q.output+Y.output).length),Q.output=`(?:${Q.output}`,Y.type="globstar",Y.output=`${v(q)}${H}|${H}${N0})`,Y.value+=W,U.output+=Q.output+Y.output,U.globstar=!0,c(W+p()),C({type:"slash",value:"/",output:""});continue}if(Q.type==="bos"&&G[0]==="/"){Y.type="globstar",Y.value+=W,Y.output=`(?:^|${H}|${v(q)}${H})`,U.output=Y.output,U.globstar=!0,c(W+p()),C({type:"slash",value:"/",output:""});continue}U.output=U.output.slice(0,-Y.output.length),Y.type="globstar",Y.output=v(q),Y.value+=W,U.output+=Y.output,U.globstar=!0,c(W);continue}let E={type:"star",value:W,output:k};if(q.bash===!0){if(E.output=".*?",Y.type==="bos"||Y.type==="slash")E.output=z+E.output;C(E);continue}if(Y&&(Y.type==="bracket"||Y.type==="paren")&&q.regex===!0){E.output=W,C(E);continue}if(U.index===U.start||Y.type==="slash"||Y.type==="dot"){if(Y.type==="dot")U.output+=A,Y.output+=A;else if(q.dot===!0)U.output+=u,Y.output+=u;else U.output+=z,Y.output+=z;if(D()!=="*")U.output+=y,Y.output+=y}C(E)}while(U.brackets>0){if(q.strictBrackets===!0)throw SyntaxError(Z0("closing","]"));U.output=i.escapeLast(U.output,"["),w0("brackets")}while(U.parens>0){if(q.strictBrackets===!0)throw SyntaxError(Z0("closing",")"));U.output=i.escapeLast(U.output,"("),w0("parens")}while(U.braces>0){if(q.strictBrackets===!0)throw SyntaxError(Z0("closing","}"));U.output=i.escapeLast(U.output,"{"),w0("braces")}if(q.strictSlashes!==!0&&(Y.type==="star"||Y.type==="bracket"))C({type:"maybe_slash",value:"",output:`${H}?`});if(U.backtrack===!0){U.output="";for(let G of U.tokens)if(U.output+=G.output!=null?G.output:G.value,G.suffix)U.output+=G.suffix}return U};g0.fastpaths=($,w)=>{let q={...w},J=typeof q.maxLength==="number"?Math.min(z0,q.maxLength):z0,f=$.length;if(f>J)throw SyntaxError(`Input length: ${f}, exceeds maximum allowed length: ${J}`);$=S1[$]||$;let Z=i.isWindows(w),{DOT_LITERAL:V,SLASH_LITERAL:F,ONE_CHAR:N,DOTS_SLASH:K,NO_DOT:B,NO_DOTS:j,NO_DOTS_SLASH:X,STAR:H,START_ANCHOR:y}=j0.globChars(Z),M=q.dot?j:B,L=q.dot?X:B,A=q.capture?"":"?:",u={negated:!1,prefix:""},S=q.bash===!0?".*?":H;if(q.capture)S=`(${S})`;let n=(z)=>{if(z.noglobstar===!0)return S;return`(${A}(?:(?!${y}${z.dot?K:V}).)*?)`},b=(z)=>{switch(z){case"*":return`${M}${N}${S}`;case".*":return`${V}${N}${S}`;case"*.*":return`${M}${S}${V}${N}${S}`;case"*/*":return`${M}${S}${F}${N}${L}${S}`;case"**":return M+n(q);case"**/*":return`(?:${M}${n(q)}${F})?${L}${N}${S}`;case"**/*.*":return`(?:${M}${n(q)}${F})?${L}${S}${V}${N}${S}`;case"**/.*":return`(?:${M}${n(q)}${F})?${V}${N}${S}`;default:{let P=/^(.*?)\.(\w+)$/.exec(z);if(!P)return;let k=b(P[1]);if(!k)return;return k+V+P[2]}}},e=i.removePrefix($,u),v=b(e);if(v&&q.strictSlashes!==!0)v+=`${F}?`;return v};x1.exports=g0});var k1=d((Aw,h1)=>{var Bw=t("path"),Nw=A1(),h0=g1(),k0=F0(),Gw=W0(),Mw=($)=>$&&typeof $==="object"&&!Array.isArray($),x=($,w,q=!1)=>{if(Array.isArray($)){let B=$.map((X)=>x(X,w,q));return(X)=>{for(let H of B){let y=H(X);if(y)return y}return!1}}let J=Mw($)&&$.tokens&&$.input;if($===""||typeof $!=="string"&&!J)throw TypeError("Expected pattern to be a non-empty string");let f=w||{},Z=k0.isWindows(w),V=J?x.compileRe($,w):x.makeRe($,w,!1,!0),F=V.state;delete V.state;let N=()=>!1;if(f.ignore){let B={...w,ignore:null,onMatch:null,onResult:null};N=x(f.ignore,B,q)}let K=(B,j=!1)=>{let{isMatch:X,match:H,output:y}=x.test(B,V,w,{glob:$,posix:Z}),M={glob:$,state:F,regex:V,posix:Z,input:B,output:y,match:H,isMatch:X};if(typeof f.onResult==="function")f.onResult(M);if(X===!1)return M.isMatch=!1,j?M:!1;if(N(B)){if(typeof f.onIgnore==="function")f.onIgnore(M);return M.isMatch=!1,j?M:!1}if(typeof f.onMatch==="function")f.onMatch(M);return j?M:!0};if(q)K.state=F;return K};x.test=($,w,q,{glob:J,posix:f}={})=>{if(typeof $!=="string")throw TypeError("Expected input to be a string");if($==="")return{isMatch:!1,output:""};let Z=q||{},V=Z.format||(f?k0.toPosixSlashes:null),F=$===J,N=F&&V?V($):$;if(F===!1)N=V?V($):$,F=N===J;if(F===!1||Z.capture===!0)if(Z.matchBase===!0||Z.basename===!0)F=x.matchBase($,w,q,f);else F=w.exec(N);return{isMatch:Boolean(F),match:F,output:N}};x.matchBase=($,w,q,J=k0.isWindows(q))=>{return(w instanceof RegExp?w:x.makeRe(w,q)).test(Bw.basename($))};x.isMatch=($,w,q)=>x(w,q)($);x.parse=($,w)=>{if(Array.isArray($))return $.map((q)=>x.parse(q,w));return h0($,{...w,fastpaths:!1})};x.scan=($,w)=>Nw($,w);x.compileRe=($,w,q=!1,J=!1)=>{if(q===!0)return $.output;let f=w||{},Z=f.contains?"":"^",V=f.contains?"":"$",F=`${Z}(?:${$.output})${V}`;if($&&$.negated===!0)F=`^(?!${F}).*$`;let N=x.toRegex(F,w);if(J===!0)N.state=$;return N};x.makeRe=($,w={},q=!1,J=!1)=>{if(!$||typeof $!=="string")throw TypeError("Expected a non-empty string");let f={negated:!1,fastpaths:!0};if(w.fastpaths!==!1&&($[0]==="."||$[0]==="*"))f.output=h0.fastpaths($,w);if(!f.output)f=h0($,w);return x.compileRe(f,w,q,J)};x.toRegex=($,w)=>{try{let q=w||{};return new RegExp($,q.flags||(q.nocase?"i":""))}catch(q){if(w&&w.debug===!0)throw q;return/$^/}};x.constants=Gw;h1.exports=x});var u1=d((Sw,l1)=>{var d1=t("util"),v1=z1(),s=k1(),b0=F0(),b1=($)=>$===""||$==="./",m1=($)=>{let w=$.indexOf("{");return w>-1&&$.indexOf("}",w)>-1},R=($,w,q)=>{w=[].concat(w),$=[].concat($);let J=new Set,f=new Set,Z=new Set,V=0,F=(B)=>{if(Z.add(B.output),q&&q.onResult)q.onResult(B)};for(let B=0;B<w.length;B++){let j=s(String(w[B]),{...q,onResult:F},!0),X=j.state.negated||j.state.negatedExtglob;if(X)V++;for(let H of $){let y=j(H,!0);if(!(X?!y.isMatch:y.isMatch))continue;if(X)J.add(y.output);else J.delete(y.output),f.add(y.output)}}let K=(V===w.length?[...Z]:[...f]).filter((B)=>!J.has(B));if(q&&K.length===0){if(q.failglob===!0)throw Error(`No matches found for "${w.join(", ")}"`);if(q.nonull===!0||q.nullglob===!0)return q.unescape?w.map((B)=>B.replace(/\\/g,"")):w}return K};R.match=R;R.matcher=($,w)=>s($,w);R.isMatch=($,w,q)=>s(w,q)($);R.any=R.isMatch;R.not=($,w,q={})=>{w=[].concat(w).map(String);let J=new Set,f=[],V=new Set(R($,w,{...q,onResult:(F)=>{if(q.onResult)q.onResult(F);f.push(F.output)}}));for(let F of f)if(!V.has(F))J.add(F);return[...J]};R.contains=($,w,q)=>{if(typeof $!=="string")throw TypeError(`Expected a string: "${d1.inspect($)}"`);if(Array.isArray(w))return w.some((J)=>R.contains($,J,q));if(typeof w==="string"){if(b1($)||b1(w))return!1;if($.includes(w)||$.startsWith("./")&&$.slice(2).includes(w))return!0}return R.isMatch($,w,{...q,contains:!0})};R.matchKeys=($,w,q)=>{if(!b0.isObject($))throw TypeError("Expected the first argument to be an object");let J=R(Object.keys($),w,q),f={};for(let Z of J)f[Z]=$[Z];return f};R.some=($,w,q)=>{let J=[].concat($);for(let f of[].concat(w)){let Z=s(String(f),q);if(J.some((V)=>Z(V)))return!0}return!1};R.every=($,w,q)=>{let J=[].concat($);for(let f of[].concat(w)){let Z=s(String(f),q);if(!J.every((V)=>Z(V)))return!1}return!0};R.all=($,w,q)=>{if(typeof $!=="string")throw TypeError(`Expected a string: "${d1.inspect($)}"`);return[].concat(w).every((J)=>s(J,q)($))};R.capture=($,w,q)=>{let J=b0.isWindows(q),Z=s.makeRe(String($),{...q,capture:!0}).exec(J?b0.toPosixSlashes(w):w);if(Z)return Z.slice(1).map((V)=>V===void 0?"":V)};R.makeRe=(...$)=>s.makeRe(...$);R.scan=(...$)=>s.scan(...$);R.parse=($,w)=>{let q=[];for(let J of[].concat($||[]))for(let f of v1(String(J),w))q.push(s.parse(f,w));return q};R.braces=($,w)=>{if(typeof $!=="string")throw TypeError("Expected a string");if(w&&w.nobrace===!0||!m1($))return[$];return v1($,w)};R.braceExpand=($,w)=>{if(typeof $!=="string")throw TypeError("Expected a string");return R.braces($,{...w,expand:!0})};R.hasBraces=m1;l1.exports=R});var c1=yw(u1(),1);var I0;((J)=>{J.ALLOW="allow";J.ASK="ask";J.DENY="deny"})(I0||={});var gw=h.object({tool:h.string(),specifier:h.string().optional(),action:h.nativeEnum(I0)}),hw=h.object({allow:h.array(h.string()).optional(),ask:h.array(h.string()).optional(),deny:h.array(h.string()).optional(),defaultMode:h.nativeEnum(I0).optional()}),kw=h.object({name:h.string(),args:h.record(h.string(),h.any())});class f0{rules;defaultMode;patternCache=new Map;constructor($){this.rules=$.rules,this.defaultMode=$.defaultMode||"ask",this.rules.sort((w,q)=>{let J={deny:0,ask:1,allow:2},f=J[w.action]-J[q.action];if(f!==0)return f;let Z=w.specifier==null?1:0,V=q.specifier==null?1:0;return Z-V})}checkPermission($){for(let w of this.rules)if(this.matchRule(w,$))return{allowed:w.action==="allow"||w.action==="ask",requiresApproval:w.action==="ask",matchedRule:w,reason:this.getReason(w)};return{allowed:this.defaultMode==="allow"||this.defaultMode==="ask",requiresApproval:this.defaultMode==="ask",reason:`No matching rule, using default mode: ${this.defaultMode}`}}matchRule($,w){if($.tool!==w.name)return!1;if(!$.specifier)return!0;let q=this.argsToString(w.args);if(w.name==="Bash")return this.matchBashCommand($.specifier,q);if($.specifier.endsWith(" ")&&!/[*?[\\]/.test($.specifier))return q.startsWith($.specifier);return this.matchGlob($.specifier,q)}matchBashCommand($,w){if(/[;&|]/.test(w))return!1;let J=/[<>()]/;if(J.test(w)){let f=w.split(J)[0].trim();return this.matchBashPattern($,f)}return this.matchBashPattern($,w)}matchBashPattern($,w){if($.endsWith(" "))return w.startsWith($);return this.matchGlob($,w)}matchGlob($,w){try{let q=$.replace(/^\.\//,""),J=w.replace(/^\.\//,""),f=`${$}::${w}`,Z=this.patternCache.get(f);if(Z!==void 0)return Z;let V=c1.default.isMatch(J,q,{nocase:!1,dot:!0});return this.cacheResult(f,V),V}catch(q){return w===$}}cacheResult($,w){if(this.patternCache.size>1000){let q=this.patternCache.keys().next().value;if(q)this.patternCache.delete(q)}this.patternCache.set($,w)}argsToString($){if(typeof $==="object"&&$!==null){if("command"in $&&$.command)return String($.command);if("file_path"in $&&$.file_path)return String($.file_path);return Object.values($).flat().join(" ")}return String($)}getReason($){let w=$.action.toUpperCase(),q=$.tool,J=$.specifier?`(${$.specifier})`:"";return`${w} rule matched: ${q}${J}`}static parseRule($,w){let q=$.match(/^(\w+)(?:\((.*)\))?$/);if(!q)throw Error(`Invalid permission rule format: ${$}`);let[,J,f]=q;return{tool:J,specifier:f,action:w}}static fromConfig($){let w=[];for(let q of $.allow||[])w.push(f0.parseRule(q,"allow"));for(let q of $.ask||[])w.push(f0.parseRule(q,"ask"));for(let q of $.deny||[])w.push(f0.parseRule(q,"deny"));return new f0({rules:w,defaultMode:$.defaultMode||"ask"})}clearCache(){this.patternCache.clear()}getCacheSize(){return this.patternCache.size}}class $0{configStore;toolNameMapper={};constructor($){this.configStore=$}static instance=null;static getInstance($){if(!$0.instance){if(!$)throw Error("PermissionStore not initialized. Provide configStore on first call.");$0.instance=new $0($)}return $0.instance}static resetInstance(){$0.instance=null}async getPermissions(){let $=await this.configStore.getConfig();if($.permissions)return f0.fromConfig($.permissions);return}async checkBashPermission($,w){return(await this.getPermissions())?.checkPermission({name:"Bash",args:{command:$,cwd:w}})}async checkReadPermission($){return(await this.getPermissions())?.checkPermission({name:"Read",args:{file_path:$}})}async checkWritePermission($){return(await this.getPermissions())?.checkPermission({name:"Write",args:{file_path:$}})}}class C0{configStore;skillStore;pluginStore;remoteStore;permissionStore;_initialized=!1;constructor($,w,q,J){this.configStore=$,this.skillStore=w,this.pluginStore=q,this.remoteStore=J,this.permissionStore=$0.getInstance($)}async initialize(){if(this._initialized)return;if("initialize"in this.configStore&&typeof this.configStore.initialize==="function")await this.configStore.initialize();if("initialize"in this.skillStore&&typeof this.skillStore.initialize==="function")await this.skillStore.initialize();if("initialize"in this.pluginStore&&typeof this.pluginStore.initialize==="function")await this.pluginStore.initialize();this._initialized=!0}async ensureInitialized(){if(!this._initialized)throw Error("ConfigManager not initialized. Call await manager.initialize() first.")}async getConfig(){return await this.ensureInitialized(),await this.configStore.getConfig()}async updateConfig($){return await this.ensureInitialized(),await this.configStore.updateConfig($)}async listSkills(){return await this.ensureInitialized(),await this.skillStore.listSkills()}async getSkill($){return await this.ensureInitialized(),await this.skillStore.getSkill($)}async saveSkill($,w){return await this.ensureInitialized(),await this.skillStore.saveSkill($,w)}async deleteSkill($){return await this.ensureInitialized(),await this.skillStore.deleteSkill($)}async syncSkillsFromRemote(){if(await this.ensureInitialized(),!this.remoteStore)throw Error("Remote store not configured");return await this.skillStore.syncFromRemote(this.remoteStore)}async listPlugins(){return await this.ensureInitialized(),await this.pluginStore.listPlugins()}async getPluginConfig($){return await this.ensureInitialized(),await this.pluginStore.getPluginConfig($)}async updatePluginConfig($,w){return await this.ensureInitialized(),await this.pluginStore.updatePluginConfig($,w)}async installPlugin($,w){return await this.ensureInitialized(),await this.pluginStore.installPlugin($,w)}async uninstallPlugin($){return await this.ensureInitialized(),await this.pluginStore.uninstallPlugin($)}async checkBashPermission($,w){return await this.ensureInitialized(),await this.permissionStore.checkBashPermission($,w)}async checkReadPermission($){return await this.ensureInitialized(),await this.permissionStore.checkReadPermission($)}async checkWritePermission($){return await this.ensureInitialized(),await this.permissionStore.checkWritePermission($)}async getPermissionMatcher(){return await this.ensureInitialized(),await this.permissionStore.getPermissions()}getConfigPath(){return this.configStore?.dbPath}}async function ow(){let{FileSystemConfigStore:$}=await import("./chunk-86m0rmtc.js"),{FileSystemSkillStore:w}=await import("./chunk-bca8tkkr.js"),{FileSystemPluginStore:q}=await import("./chunk-57bj89e2.js"),J=new $,f=new w,Z=new q,V=new C0(J,f,Z);return await V.initialize(),V}async function tw($){let{configStore:w,skillStore:q,pluginStore:J,remoteStore:f}=$,Z=new C0(w,q,J,f);return await Z.initialize(),Z}
18
+ export{ow as if,tw as jf};
@@ -0,0 +1,4 @@
1
+ import{j as o}from"./chunk-h8fdexm4.js";import{R as n}from"./chunk-m21hvv91.js";import{U as m,X as d,Y as x}from"./chunk-4wnmk2tj.js";import{Ae as G,De as a,Ie as g,Je as D,Ke as E,we as u,ze as X}from"./chunk-c7kd2qrp.js";import"./chunk-a9tw6d68.js";import"./chunk-k4q8j7pg.js";import"./chunk-spx7nn8t.js";import"./chunk-vfxjbdz4.js";import"./chunk-qxebn3jw.js";import"./chunk-e8kxa5vj.js";import"./chunk-q1cxrg0x.js";import"./chunk-tjg2e8v3.js";import{Dl as S}from"./chunk-y8qhrx11.js";var H=S(u(),1);var b=S(u(),1);var _=S(D(),1);function Xz(Y){try{let $=JSON.parse(Y);if(typeof $!=="object"||$===null)return{isValid:!1,error:{message:"配置必须是 JSON 对象"}};if(!$.command&&!$.url)return{isValid:!1,error:{message:'配置必须包含 "command" (stdio) 或 "url" (SSE)'}};return{isValid:!0,config:$}}catch($){let L=$ instanceof Error?$.message:String($),B=L.match(/position (\d+)/),Q=B?parseInt(B[1],10):void 0;return{isValid:!1,error:{message:`JSON 格式错误: ${L}`,line:Q}}}}function Yz(Y,$,L){if(!Y||Y.length<2||Y.length>32)return"名称必须为 2-32 个字符";if(!/^[a-zA-Z0-9_-]+$/.test(Y))return"名称只能包含字母、数字、下划线和连字符";if($.includes(Y)&&Y!==L)return"名称已存在";return null}function Zz(Y,$=2){return JSON.stringify(Y,null,$)}var _z=[{key:"serverName",label:"Server ID"},{key:"config",label:"Config (JSON)"}],$z=({mode:Y,serverName:$,serverConfig:L,onCancel:B,onSave:Q})=>{let[O,y]=b.useState({serverName:$||"",configJSON:L?Zz(L):""}),[F,I]=b.useState(0),[j,V]=b.useState(null),M=b.useMemo(()=>{return[]},[]),U=b.useMemo(()=>{return Xz(O.configJSON)},[O.configJSON]),k=b.useCallback(()=>{let A=Yz(O.serverName,M,Y==="edit"?$:void 0);return V(A),A===null},[O.serverName,M,$,Y]),N=b.useCallback(()=>{if(Y==="add"&&!k())return;if(!U.isValid||!U.config)return;Q(O.serverName,U.config)},[Y,O.serverName,U,Q,k]),w=b.useCallback((A)=>{let h=Y==="add"?_z.length-1:1,q=A==="next"?(F+1)%h:(F-1+h)%h;I(q)},[F,Y]),f=()=>{if(Y!=="add")return null;let A=F===0,h=j!==null;return _.jsxDEV(X,{marginBottom:1,children:[_.jsxDEV(G,{color:A?"cyan":h?"red":"gray",children:"Server ID: "},void 0,!1,void 0,this),A?_.jsxDEV(X,{width:40,children:_.jsxDEV(E,{value:O.serverName,onChange:(q)=>{y((K)=>({...K,serverName:q})),V(null)},onSubmit:N,placeholder:"my-server",maxVisibleLines:1,showCursor:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this):_.jsxDEV(G,{children:O.serverName||"my-server"},void 0,!1,void 0,this),h&&_.jsxDEV(G,{color:"red",children:[" ",j]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},p=()=>{let A=Y==="add"?F===1:F===0,h=U.isValid;return _.jsxDEV(X,{flexDirection:"column",marginBottom:1,children:[_.jsxDEV(G,{color:A?"cyan":"gray",children:"Config (JSON):"},void 0,!1,void 0,this),_.jsxDEV(X,{marginTop:1,children:_.jsxDEV(E,{value:O.configJSON,onChange:(q)=>y((K)=>({...K,configJSON:q})),onSubmit:N,placeholder:`{
2
+ "command": "npx",
3
+ "args": ["-y", "..."]
4
+ }`,showCursor:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),O.configJSON&&_.jsxDEV(X,{marginTop:1,children:h?_.jsxDEV(G,{color:"green",children:"✓ JSON 格式有效"},void 0,!1,void 0,this):_.jsxDEV(G,{color:"red",children:["✗ ",U.error?.message||"JSON 格式错误"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},P=()=>_.jsxDEV(X,{marginTop:1,children:_.jsxDEV(G,{color:"gray",dimColor:!0,children:[_.jsxDEV(G,{color:"cyan",children:"Enter"},void 0,!1,void 0,this)," 保存 ",_.jsxDEV(G,{color:"cyan",children:"Tab"},void 0,!1,void 0,this)," 切换字段"," ",_.jsxDEV(G,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 取消"]},void 0,!0,void 0,this)},void 0,!1,void 0,this);return _.jsxDEV(X,{flexDirection:"column",paddingX:2,children:[_.jsxDEV(X,{marginBottom:1,children:_.jsxDEV(G,{bold:!0,color:"cyan",children:Y==="add"?"Add MCP Server":`Edit MCP Server: ${$}`},void 0,!1,void 0,this)},void 0,!1,void 0,this),_.jsxDEV(X,{flexDirection:"column",gap:1,children:[f(),p()]},void 0,!0,void 0,this),P()]},void 0,!0,void 0,this)},l=$z;function i({mcpConfig:Y,updateConfig:$}){let L=m(),B=d({mutationFn:async(Q)=>{return await $({mcp_config:Q}),Q},onSuccess:(Q)=>{L.setQueryData(x.mcp.config(),Q)}});return{mcpConfig:Y,updateMcpConfig:B.mutateAsync,isUpdating:B.isPending}}var z=S(D(),1),Hz=({onClose:Y})=>{let{config:$,updateConfig:L}=o(),B=$?.mcp_config||{},{mcpConfig:Q,updateMcpConfig:O}=i({mcpConfig:B,updateConfig:L}),[y,F]=H.useState("list"),[I,j]=H.useState("add"),[V,M]=H.useState(null),[U,k]=H.useState(0),[N,w]=H.useState(null),[f,p]=H.useState(null),[P,A]=H.useState(null),h=H.useCallback(()=>w(null),[]);n(h,N?3000:null);let q=Object.keys(Q),K=q[U],R=K?Q[K]:null,v=H.useCallback((W)=>{if(W.command)return"stdio";if(W.url)return"SSE";return"unknown"},[]),r=H.useCallback(()=>{j("add"),M(null),F("json"),w(null)},[]),t=H.useCallback(()=>{if(!K||!R)return;j("edit"),M(K),F("json"),w(null)},[K,R]),s=H.useCallback(async()=>{if(!K||!R)return;p(K),A(null),F("test");try{let W=!!(R.command&&R.args),Z=!!R.url;if(!W&&!Z){A({success:!1,message:"配置无效:必须包含 command (stdio) 或 url (SSE)"});return}if(W&&(!R.command||!Array.isArray(R.args))){A({success:!1,message:"配置无效:stdio 模式需要 command 和 args 字段"});return}A({success:!0,message:`配置格式验证通过 (${Z?"SSE":"stdio"} 模式)`,tools:[]})}catch(W){A({success:!1,message:`验证失败: ${W instanceof Error?W.message:String(W)}`})}},[K,R]),C=H.useCallback(()=>{F("list"),M(null),A(null),w(null)},[]),e=H.useCallback(async(W,Z)=>{let J={...Q};if(J[W]=Z,await O(J),w(I==="add"?`已添加服务器: ${W}`:`已更新服务器: ${W}`),I==="add"){let T=Object.keys(J).findIndex((c)=>c===W);k(T>=0?T:0)}C()},[I,Q,O,C]),zz=H.useCallback(async()=>{if(!K)return;let W={...Q};delete W[K],await O(W);let Z=Math.min(U,Object.keys(W).length-1);k(Z>=0?Z:0),w(`已删除服务器: ${K}`)},[K,U,Q,O]);g((W,Z)=>{if(y==="json"||y==="test"){if(Z.escape)C();return}if(Z.upArrow)k((J)=>J>0?J-1:q.length-1);else if(Z.downArrow)k((J)=>J<q.length-1?J+1:0);else if(W==="n"||W==="N")r();else if((W==="e"||W==="E"||Z.return)&&K)t();else if((W==="d"||W==="D")&&K)zz();else if((W==="t"||W==="T")&&K)s();else if(Z.escape)Y()},{isActive:!0});let Gz=H.useMemo(()=>{if(q.length===0)return z.jsxDEV(X,{paddingX:2,paddingY:1,children:[z.jsxDEV(G,{color:"yellow",children:"未配置任何 MCP 服务器"},void 0,!1,void 0,this),z.jsxDEV(X,{marginTop:1,children:z.jsxDEV(G,{color:"gray",dimColor:!0,children:["按 ",z.jsxDEV(G,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 添加新服务器"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return z.jsxDEV(X,{flexDirection:"column",paddingX:2,gap:1,children:[q.map((W,Z)=>{let J=Q[W],T=v(J);return z.jsxDEV(X,{marginBottom:0,gap:1,children:[z.jsxDEV(G,{color:Z===U?"cyan":"gray",bold:Z===U,children:Z===U?">":" "},void 0,!1,void 0,this),z.jsxDEV(G,{bold:Z===U,color:Z===U?"cyan":void 0,children:W},void 0,!1,void 0,this),z.jsxDEV(a,{},void 0,!1,void 0,this),z.jsxDEV(G,{color:T==="stdio"?"green":T==="SSE"?"blue":"yellow",dimColor:Z!==U,children:["[",T.toUpperCase(),"]"]},void 0,!0,void 0,this)]},`server-${Z}-${W}`,!0,void 0,this)}),z.jsxDEV(X,{marginTop:1,children:z.jsxDEV(G,{color:"gray",dimColor:!0,children:[z.jsxDEV(G,{color:"cyan",children:"↑↓"},void 0,!1,void 0,this)," 导航 ",z.jsxDEV(G,{color:"cyan",children:"n"},void 0,!1,void 0,this)," 新增 ",z.jsxDEV(G,{color:"cyan",children:"e"},void 0,!1,void 0,this)," ","编辑 ",z.jsxDEV(G,{color:"cyan",children:"d"},void 0,!1,void 0,this)," 删除 ",z.jsxDEV(G,{color:"cyan",children:"t"},void 0,!1,void 0,this)," 测试"," ",z.jsxDEV(G,{color:"cyan",children:"Esc"},void 0,!1,void 0,this)," 关闭"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},[q,Q,U,v]),Wz=H.useMemo(()=>{if(!f||!P)return z.jsxDEV(X,{paddingX:2,paddingY:1,children:z.jsxDEV(G,{color:"yellow",children:"正在验证配置..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(P.success)return z.jsxDEV(X,{flexDirection:"column",paddingX:2,gap:1,children:[z.jsxDEV(X,{children:z.jsxDEV(G,{color:"green",children:["✓ ",P.message]},void 0,!0,void 0,this)},void 0,!1,void 0,this),P.tools&&P.tools.length>0&&z.jsxDEV(X,{flexDirection:"column",marginTop:1,children:[z.jsxDEV(G,{color:"gray",children:["发现 ",P.tools.length," 个工具:"]},void 0,!0,void 0,this),P.tools.slice(0,10).map((W)=>z.jsxDEV(X,{paddingLeft:2,children:z.jsxDEV(G,{color:"gray",children:["- ",W]},void 0,!0,void 0,this)},W,!1,void 0,this)),P.tools.length>10&&z.jsxDEV(X,{paddingLeft:2,children:z.jsxDEV(G,{color:"gray",children:["... 还有 ",P.tools.length-10," 个工具"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(X,{marginTop:1,children:z.jsxDEV(G,{color:"gray",dimColor:!0,children:["按 ",z.jsxDEV(G,{color:"cyan",children:"Enter"},void 0,!1,void 0,this)," 关闭"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);else return z.jsxDEV(X,{flexDirection:"column",paddingX:2,gap:1,children:[z.jsxDEV(X,{children:z.jsxDEV(G,{color:"red",children:"✗ 验证失败"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(X,{children:z.jsxDEV(G,{color:"yellow",children:P.message},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV(X,{marginTop:1,children:[z.jsxDEV(G,{color:"gray",children:"建议检查:"},void 0,!1,void 0,this),z.jsxDEV(G,{color:"gray",children:"- 配置格式是否正确"},void 0,!1,void 0,this),z.jsxDEV(G,{color:"gray",children:"- 命令是否已安装(stdio 模式)"},void 0,!1,void 0,this),z.jsxDEV(G,{color:"gray",children:"- URL 是否可访问(SSE 模式)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(X,{marginTop:1,children:z.jsxDEV(G,{color:"gray",dimColor:!0,children:["按 ",z.jsxDEV(G,{color:"cyan",children:"Enter"},void 0,!1,void 0,this)," 关闭"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},[f,P]);return g((W,Z)=>{if(y==="test"&&Z.return)C()},{isActive:y==="test"}),z.jsxDEV(X,{flexDirection:"column",children:[z.jsxDEV(X,{paddingX:2,paddingY:1,children:z.jsxDEV(G,{bold:!0,color:"cyan",children:"MCP Servers"},void 0,!1,void 0,this)},void 0,!1,void 0,this),y==="list"?Gz:y==="json"?z.jsxDEV(l,{mode:I,serverName:V||void 0,serverConfig:R||void 0,onCancel:C,onSave:e},void 0,!1,void 0,this):Wz,N&&z.jsxDEV(X,{paddingX:2,paddingY:0,children:z.jsxDEV(G,{color:"green",children:N},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},kz=Hz;export{kz as default};