@decocms/mesh 2.11.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-C-YsmNug.js → AlertCircle-Cso_Xxvk.js} +1 -1
- package/dist/client/assets/{ArrowLeft-I0eE0ajz.js → ArrowLeft-BrsZ2N_5.js} +1 -1
- package/dist/client/assets/{Check-Bn7iaq_h.js → Check-JFkjTCfG.js} +1 -1
- package/dist/client/assets/{ChevronDown-CXsTFOR4.js → ChevronDown-HtFMO0lw.js} +1 -1
- package/dist/client/assets/{Clock-7YlOAEqw.js → Clock-CW5u1cfj.js} +1 -1
- package/dist/client/assets/{Code01-Dp2-HwWV.js → Code01-CgNchnl3.js} +1 -1
- package/dist/client/assets/{Copy01-Cufxb7u1.js → Copy01-Dadp_RDG.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-Cq3m_A8z.js → DotsHorizontal-B0A7sUYv.js} +1 -1
- package/dist/client/assets/{DotsVertical-BIpduKLf.js → DotsVertical-BHUUUCDx.js} +1 -1
- package/dist/client/assets/Edit01-CxRkZTQ1.js +1 -0
- package/dist/client/assets/{File06-DD5RANl_.js → File06-D0TXCuMx.js} +1 -1
- package/dist/client/assets/{FilterLines-1Ine1y4n.js → FilterLines-_uykt7r4.js} +1 -1
- package/dist/client/assets/{FlipBackward-DBqfxU3c.js → FlipBackward-GGMv99yc.js} +1 -1
- package/dist/client/assets/{GitBranch01-BHo3ByP2.js → GitBranch01-BUTuezlq.js} +1 -1
- package/dist/client/assets/{Grid01-C578o4mm.js → Grid01-BbdtRdR8.js} +1 -1
- package/dist/client/assets/{Inbox01-BtHWN2dX.js → Inbox01-CgwXLK3n.js} +1 -1
- package/dist/client/assets/{InfoCircle-BkGKY7qc.js → InfoCircle-D6qJG9Nl.js} +1 -1
- package/dist/client/assets/{Key01-DYP1HQKa.js → Key01-8ewaPBuD.js} +1 -1
- package/dist/client/assets/{LinkExternal01-d5tCjGRk.js → LinkExternal01-D0Wjfr3t.js} +1 -1
- package/dist/client/assets/{Loading01-BGeWv0Kv.js → Loading01-NW_f44Lz.js} +1 -1
- package/dist/client/assets/{Lock01-jWWo80rN.js → Lock01-BTPtPjN4.js} +1 -1
- package/dist/client/assets/{Play-B3EbuXEZ.js → Play-CIMfsFF1.js} +1 -1
- package/dist/client/assets/{Plus-CgN71ZpK.js → Plus-DaP4KLuJ.js} +1 -1
- package/dist/client/assets/{SearchMd-u2U3iAnY.js → SearchMd-tOSOFUes.js} +1 -1
- package/dist/client/assets/{Terminal-Fj__rdxn.js → Terminal-ANRX3jJ8.js} +1 -1
- package/dist/client/assets/{Trash01-Vutqn1RC.js → Trash01-CjDzx3jP.js} +1 -1
- package/dist/client/assets/{X-P1RHfgBU.js → X-D3ljCSd1.js} +1 -1
- package/dist/client/assets/{XClose-DeI9b46h.js → XClose-Ba3zyI0J.js} +1 -1
- package/dist/client/assets/{alert-dialog-BApkfnBU.js → alert-dialog-_Gzpv9vf.js} +1 -1
- package/dist/client/assets/{auth-B4yoGafc.js → auth-C9dSkS_x.js} +1 -1
- package/dist/client/assets/{auth-catchall-CbILVwsO.js → auth-catchall-DRL5ZGJM.js} +1 -1
- package/dist/client/assets/{avatar-HUmJyCrO.js → avatar-D1o5pnzU.js} +1 -1
- package/dist/client/assets/{badge-_9VZKl7s.js → badge-0b6sJe4S.js} +1 -1
- package/dist/client/assets/{card-DUrBojml.js → card-B3fsloDi.js} +1 -1
- package/dist/client/assets/{checkbox-y4VvHU-Y.js → checkbox-2xIaHvS4.js} +1 -1
- package/dist/client/assets/{collection-detail-o5P4OEwm.js → collection-detail-Bu5gtjud.js} +31 -31
- package/dist/client/assets/{collection-display-button-D_pspwv8.js → collection-display-button-BGIcja12.js} +1 -1
- package/dist/client/assets/{collection-header-DjAukiYw.js → collection-header-DhWbmVkk.js} +1 -1
- package/dist/client/assets/{collection-page-DUwIO-4_.js → collection-page-B4ZjGX9V.js} +1 -1
- package/dist/client/assets/{collection-search-C8qrPxpe.js → collection-search-CYZk6T6Z.js} +1 -1
- package/dist/client/assets/collection-tab-IeT0mJ-2.js +1 -0
- package/dist/client/assets/{collection-table-wrapper-m6-zCmZ8.js → collection-table-wrapper-D2niE2Ci.js} +1 -1
- package/dist/client/assets/connection-card-D0c_wvmz.js +1 -0
- package/dist/client/assets/connection-detail-BmNPUV8x.js +1 -0
- package/dist/client/assets/connections-U2y3agtD.js +1 -0
- package/dist/client/assets/constants-Cy709IUA.js +1 -0
- package/dist/client/assets/{create-organization-dialog-DJCSaeq_.js → create-organization-dialog-D0WQQsLG.js} +1 -1
- package/dist/client/assets/{dialog-DPjf1g07.js → dialog-BXeLl5mO.js} +1 -1
- package/dist/client/assets/{dropdown-menu-JqpADJWR.js → dropdown-menu-CnL8UM0z.js} +1 -1
- package/dist/client/assets/{empty-state-B1YgYZRX.js → empty-state-BmkZOMzL.js} +1 -1
- package/dist/client/assets/empty-state-DzS1Zp7m.js +2 -0
- package/dist/client/assets/{env-vars-editor-58M0X5HW.js → env-vars-editor-B_mIaT86.js} +1 -1
- package/dist/client/assets/{error-boundary-swyLIuj9.js → error-boundary-BQnJ9S9E.js} +1 -1
- package/dist/client/assets/{extract-connection-data-yHByD-hG.js → extract-connection-data-DPoJQhk8.js} +1 -1
- package/dist/client/assets/{form-BNePwzri.js → form-DrOt6d2d.js} +1 -1
- package/dist/client/assets/gateway-detail-CniDbJPb.js +1 -0
- package/dist/client/assets/gateways-DmEpJOpx.js +1 -0
- package/dist/client/assets/{home-Dge_UN-5.js → home-HrkEcREJ.js} +1 -1
- package/dist/client/assets/{index-Dd-uCtJP.js → index-Bb8rHnPb.js} +1 -1
- package/dist/client/assets/index-CBIrwxtj.js +88 -0
- package/dist/client/assets/index-ChrSnaFS.css +1 -0
- package/dist/client/assets/{index-D825aBGT.js → index-DMNk-OUX.js} +3 -3
- package/dist/client/assets/index-GoXtajA4.js +25 -0
- package/dist/client/assets/{index-CZYkP-qE.js → index-XOpbMEap.js} +1 -1
- package/dist/client/assets/{input-CUSLU-5Y.js → input-68J17rBp.js} +1 -1
- package/dist/client/assets/{layout-DiLh4D4s.js → layout-Olb4shdE.js} +1 -1
- package/dist/client/assets/{lazy-highlighter-Bva2qxQ8.js → lazy-highlighter-Ccgc_fxj.js} +1 -1
- package/dist/client/assets/localstorage-keys-C62ZbWuB.js +1 -0
- package/dist/client/assets/{login-5v9kcVjq.js → login-UTKAAaeX.js} +1 -1
- package/dist/client/assets/{mcp-oauth-2LWG2fNF.js → mcp-oauth-Db8WtQ8u.js} +1 -1
- package/dist/client/assets/mcp-server-detail-BvVQovUz.js +1 -0
- package/dist/client/assets/members-V-vtwMYY.js +3 -0
- package/dist/client/assets/{monaco-editor-CXJFCG3L.js → monaco-editor-B_MycISs.js} +1 -1
- package/dist/client/assets/{monitoring-BxS1M7G9.js → monitoring-CBmCnQ7i.js} +20 -20
- package/dist/client/assets/{oauth-callback-D352dL7W.js → oauth-callback-BYBqbF1w.js} +1 -1
- package/dist/client/assets/page-DYF0Qz3l.js +1 -0
- package/dist/client/assets/page-DrIZd1pO.js +35 -0
- package/dist/client/assets/{pin-to-sidebar-button-CxO4Rtia.js → pin-to-sidebar-button-B1xHHS9n.js} +1 -1
- package/dist/client/assets/{popover-CiuXmEMm.js → popover-DC9U4d6e.js} +1 -1
- package/dist/client/assets/{project-context-provider-Y7j1MLG3.js → project-context-provider-BJIP5a-U.js} +1 -1
- package/dist/client/assets/{resizable-CpuhJlAj.js → resizable-CW5_SPIS.js} +1 -1
- package/dist/client/assets/{resource-tabs-DzYdyOT8.js → resource-tabs-BKSlcL1W.js} +1 -1
- package/dist/client/assets/{select-BiK6lA7A.js → select-B9KJyTZZ.js} +1 -1
- package/dist/client/assets/{settings-BydLLEEd.js → settings-CYg4YPRI.js} +1 -1
- package/dist/client/assets/shell-layout-KIN6fL5j.js +3 -0
- package/dist/client/assets/{spinner-D8JOERWZ.js → spinner-B0sczm1j.js} +1 -1
- package/dist/client/assets/{switch-CHSRGx1X.js → switch-BuVvmF04.js} +1 -1
- package/dist/client/assets/{textarea-DA688jdJ.js → textarea-BAUX8Qgd.js} +1 -1
- package/dist/client/assets/thread-history-popover-Dv63nk6L.js +20 -0
- package/dist/client/assets/tool-set-selector-DMsE0yRo.js +1 -0
- package/dist/client/assets/tools-list-Dgf0oqyC.js +1 -0
- package/dist/client/assets/{use-binding-pQGzNysE.js → use-binding-Dj4lal1A.js} +1 -1
- package/dist/client/assets/use-connection-DoWszS3j.js +1 -0
- package/dist/client/assets/{use-connection-resources-CrBNfIuI.js → use-connection-resources-BywYCfzc.js} +1 -1
- package/dist/client/assets/use-create-gateway-Ca5SEa8I.js +1 -0
- package/dist/client/assets/use-gateway-CRpsitbG.js +1 -0
- package/dist/client/assets/{use-gateway-system-prompt-D3bv_TPR.js → use-gateway-system-prompt-B4ia2QxW.js} +1 -1
- package/dist/client/assets/{use-list-state-CUahB2OC.js → use-list-state-CPUcOhR_.js} +1 -1
- package/dist/client/assets/use-mcp-L2lisTXg.js +1 -0
- package/dist/client/assets/{use-members-BlHxrgPJ.js → use-members-7eRdYOTr.js} +1 -1
- package/dist/client/assets/{use-mobile-DSucR6ge.js → use-mobile--ytA5LT5.js} +1 -1
- package/dist/client/assets/use-organization-settings-D6rXW2c_.js +1 -0
- package/dist/client/assets/use-tool-call-BBonHr6l.js +1 -0
- package/dist/client/assets/{value-BHNPJ9GX.js → value-Bd2XBV_y.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-Do1cIl7g.js → view-mode-toggle-BpjQ6V4P.js} +1 -1
- package/dist/client/assets/workflow-CjynHD6b.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +236 -208
- package/dist/server/migrate.js +129 -129
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/LICENSE +47 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/README.md +82 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.d.ts +11 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.mjs +43 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cjs +45 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cloudflare.cjs +46 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.cloudflare.d.ts +11 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.d.ts +11 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.mjs +46 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.wasm +0 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.d.mts +83 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.d.ts +83 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.js +2 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.js.map +1 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.mjs +2 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/ffi.mjs.map +1 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.d.mts +20 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.d.ts +20 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js +2 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.js.map +1 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs +2 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/index.mjs.map +1 -0
- package/dist/server/node_modules/@jitl/quickjs-wasmfile-release-sync/package.json +61 -0
- package/dist/server/server.js +228 -200
- package/package.json +1 -1
- package/dist/client/assets/collection-tab-BtKR4Bs-.js +0 -1
- package/dist/client/assets/connection-card-Bho36DLV.js +0 -1
- package/dist/client/assets/connection-detail-DzUkx3x6.js +0 -1
- package/dist/client/assets/connections-CGjqBYcN.js +0 -1
- package/dist/client/assets/constants-CDd5Bb9b.js +0 -1
- package/dist/client/assets/gateway-detail-7_rs5-Bk.js +0 -1
- package/dist/client/assets/gateways-LhzXTNdU.js +0 -1
- package/dist/client/assets/index-DfsK7wxC.js +0 -88
- package/dist/client/assets/index-KJvlasGf.css +0 -1
- package/dist/client/assets/index-sXi95TSr.js +0 -25
- package/dist/client/assets/localstorage-keys-DCk__Bcu.js +0 -1
- package/dist/client/assets/mcp-server-detail-Bl4-1OcQ.js +0 -1
- package/dist/client/assets/members-DUjkcn9b.js +0 -3
- package/dist/client/assets/page-DJ2XmEDk.js +0 -1
- package/dist/client/assets/page-DlLPoWnp.js +0 -35
- package/dist/client/assets/shell-layout-hT1WnhFU.js +0 -3
- package/dist/client/assets/thread-history-popover-d49eUsmE.js +0 -72
- package/dist/client/assets/tool-set-selector-qCxd45H-.js +0 -1
- package/dist/client/assets/tools-list-aRycV8Sk.js +0 -1
- package/dist/client/assets/use-connection-CJ5nWy0c.js +0 -2
- package/dist/client/assets/use-gateway-Cov2sDNb.js +0 -1
- package/dist/client/assets/use-mcp-Wds2Jlc5.js +0 -1
- package/dist/client/assets/use-organization-settings-zICyumVv.js +0 -1
- package/dist/client/assets/use-tool-call-CS4qR4o3.js +0 -1
- package/dist/client/assets/useQuery-El_kGGDY.js +0 -1
- package/dist/client/assets/workflow-C_xTbZed.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,ac as
|
|
1
|
+
import{r as c,ac as T,j as i,ad as C,aa as y,ai as I,af as M,aO as H,aN as z,c as A}from"./index-DMNk-OUX.js";import{c as g}from"./input-68J17rBp.js";var b="Switch",[O]=T(b),[U,q]=O(b),E=c.forwardRef((s,e)=>{const{__scopeSwitch:t,name:r,checked:a,defaultChecked:n,required:o,disabled:d,value:u="on",onCheckedChange:k,form:l,...w}=s,[p,h]=c.useState(null),v=y(e,m=>h(m)),x=c.useRef(!1),S=p?l||!!p.closest("form"):!0,[f,j]=I({prop:a,defaultProp:n??!1,onChange:k,caller:b});return i.jsxs(U,{scope:t,checked:f,disabled:d,children:[i.jsx(C.button,{type:"button",role:"switch","aria-checked":f,"aria-required":o,"data-state":N(f),"data-disabled":d?"":void 0,disabled:d,value:u,...w,ref:v,onClick:M(s.onClick,m=>{j(B=>!B),S&&(x.current=m.isPropagationStopped(),x.current||m.stopPropagation())})}),S&&i.jsx(_,{control:p,bubbles:!x.current,name:r,value:u,checked:f,required:o,disabled:d,form:l,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var P="SwitchThumb",R=c.forwardRef((s,e)=>{const{__scopeSwitch:t,...r}=s,a=q(P,t);return i.jsx(C.span,{"data-state":N(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:e})});R.displayName=P;var L="SwitchBubbleInput",_=c.forwardRef(({__scopeSwitch:s,control:e,checked:t,bubbles:r=!0,...a},n)=>{const o=c.useRef(null),d=y(o,n),u=H(t),k=z(e);return c.useEffect(()=>{const l=o.current;if(!l)return;const w=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&h){const v=new Event("click",{bubbles:r});h.call(l,t),l.dispatchEvent(v)}},[u,t,r]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...a,tabIndex:-1,ref:d,style:{...a.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});_.displayName=L;function N(s){return s?"checked":"unchecked"}var $=E,D=R;function X(s){const e=A.c(9);let t,r;e[0]!==s?({className:t,...r}=s,e[0]=s,e[1]=t,e[2]=r):(t=e[1],r=e[2]);let a;e[3]!==t?(a=g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),e[3]=t,e[4]=a):a=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")}),e[5]=n):n=e[5];let o;return e[6]!==r||e[7]!==a?(o=i.jsx($,{"data-slot":"switch",className:a,...r,children:n}),e[6]=r,e[7]=a,e[8]=o):o=e[8],o}export{X as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o,j as n}from"./index-
|
|
1
|
+
import{c as o,j as n}from"./index-DMNk-OUX.js";import{c as l}from"./input-68J17rBp.js";function u(s){const e=o.c(8);let r,i;e[0]!==s?({className:r,...i}=s,e[0]=s,e[1]=r,e[2]=i):(r=e[1],i=e[2]);let t;e[3]!==r?(t=l("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-xl border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),e[3]=r,e[4]=t):t=e[4];let a;return e[5]!==i||e[6]!==t?(a=n.jsx("textarea",{"data-slot":"textarea",className:t,...i}),e[5]=i,e[6]=t,e[7]=a):a=e[7],a}export{u as T};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import{r as B,c as z,j as p,s as da,d as Ot,K as Mt,t as ze,E as pa,F as ma,H as W,w as g,_ as Me,I as Pt,J as fa,L as ha,M as ga,Q as q,U as Ee,V as Te,v as O,W as _,X as oe,Y as va,Z as M,$ as ya,a0 as ba,f as kt,p as xa}from"./index-DMNk-OUX.js";import{c as J,B as Pe}from"./input-68J17rBp.js";import{u as He,c as Qe,b as Xe,T as Ke,a as Dt}from"./project-context-provider-BJIP5a-U.js";import{E as _a}from"./use-binding-Dj4lal1A.js";import{l as wa,m as Ea,n as Ia,o as Na,h as Sa,p as Ta}from"./index-CBIrwxtj.js";import{u as Ca}from"./localstorage-keys-C62ZbWuB.js";import{u as Ra}from"./use-gateway-system-prompt-B4ia2QxW.js";import{I as ja,E as Aa}from"./empty-state-DzS1Zp7m.js";import{b as et,a as tt,P as at}from"./popover-DC9U4d6e.js";import{t as Oa}from"./ChevronDown-HtFMO0lw.js";import{i as Ma}from"./use-gateway-CRpsitbG.js";import{i as Pa}from"./Edit01-CxRkZTQ1.js";import{a as ka}from"./use-connection-DoWszS3j.js";import{O as Da,a as $a,g as Za}from"./well-known-mcp-D13f-8h2.js";import{g as La}from"./generate-id-Dyweu44Y.js";import{s as it}from"./Clock-CW5u1cfj.js";import{i as Ua}from"./SearchMd-tOSOFUes.js";import{s as Ba}from"./Trash01-CjDzx3jP.js";const $t=({size:t=24,color:e="currentColor",...a})=>B.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...a},B.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));$t.displayName="XCircle";function lt(t){const e=z.c(8);let a,s;e[0]!==t?({className:a,...s}=t,e[0]=t,e[1]=a,e[2]=s):(a=e[1],s=e[2]);let r;e[3]!==a?(r=J("bg-accent animate-pulse rounded-md",a),e[3]=a,e[4]=r):r=e[4];let n;return e[5]!==s||e[6]!==r?(n=p.jsx("div",{"data-slot":"skeleton",className:r,...s}),e[5]=s,e[6]=r,e[7]=n):n=e[7],n}function cn(){const t=z.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=p.jsx("div",{className:"size-6 rounded-lg bg-muted animate-pulse"}),t[0]=e):e=t[0];let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsxs("div",{className:"flex items-center gap-3",children:[e,p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx("div",{className:"h-3.5 w-28 rounded bg-muted animate-pulse"}),p.jsx("div",{className:"h-3 w-40 rounded bg-muted/60 animate-pulse"})]})]}),t[1]=a):a=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("div",{className:"flex items-center h-12 flex-none border-b border-border/80 px-4",children:p.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[a,p.jsxs("div",{className:"flex items-end gap-2",children:[p.jsx("div",{className:"h-6 w-6 rounded-full bg-muted animate-pulse"}),p.jsx("div",{className:"h-6 w-6 rounded-lg bg-muted animate-pulse"})]})]})}),t[2]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"flex-1 overflow-hidden px-4 py-4",children:p.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-4",children:[p.jsx(je,{align:"right",width:"w-3/4"}),p.jsx(je,{align:"left",width:"w-full",lines:3}),p.jsx(je,{align:"right",width:"w-2/3"}),p.jsx(je,{align:"left",width:"w-5/6",lines:2})]})}),t[3]=r):r=t[3];let n;t[4]===Symbol.for("react.memo_cache_sentinel")?(n=p.jsx("div",{className:"relative flex flex-1 flex-col gap-2 p-2.5",children:p.jsx("div",{className:"relative flex-1",children:p.jsxs("div",{className:"space-y-2 p-2",children:[p.jsx("div",{className:"h-3 w-full rounded bg-muted/40 animate-pulse"}),p.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40 animate-pulse"})]})})}),t[4]=n):n=t[4];let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx("div",{className:"flex items-center gap-1",children:p.jsx("div",{className:"size-8 rounded-full bg-muted/60 animate-pulse"})}),t[5]=i):i=t[5];let o;return t[6]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsxs("div",{className:"flex h-full w-full flex-col bg-sidebar",children:[s,r,p.jsx("div",{className:"px-4 py-4",children:p.jsx("div",{className:"mx-auto w-full max-w-2xl",children:p.jsxs("div",{className:"relative flex min-h-[130px] flex-col rounded-xl border border-border bg-background shadow-sm",children:[n,p.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2.5",children:[i,p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("div",{className:"h-8 w-32 rounded-lg bg-muted/60 animate-pulse"}),p.jsx("div",{className:"size-8 rounded-full bg-muted animate-pulse"})]})]})]})})})]}),t[6]=o):o=t[6],o}function je(t){const e=z.c(22),{align:a,width:s,lines:r}=t,n=s===void 0?"w-full":s,i=r===void 0?1:r,o=a==="right"?"flex-row-reverse":"flex-row";let c;e[0]!==o?(c=J("flex w-full gap-4 px-4 py-2",o),e[0]=o,e[1]=c):c=e[1];const l=a==="right"?"ml-auto max-w-3/4 items-end":"w-full items-start";let d;e[2]!==l?(d=J("flex min-w-0 flex-col gap-2",l),e[2]=l,e[3]=d):d=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx("div",{className:"h-3 w-16 rounded bg-muted/40 animate-pulse"}),e[4]=m):m=e[4];const h=a==="right"?"bg-muted":"bg-transparent border border-border/40";let f;e[5]!==h||e[6]!==n?(f=J("min-w-0 rounded-2xl p-4",h,n),e[5]=h,e[6]=n,e[7]=f):f=e[7];let v;e[8]!==i?(v=Array.from({length:i}),e[8]=i,e[9]=v):v=e[9];let b;e[10]!==i||e[11]!==v?(b=p.jsx("div",{className:"space-y-2",children:v.map((u,T)=>p.jsx("div",{className:J("h-3 rounded bg-muted-foreground/20 animate-pulse",T===i-1?"w-3/4":"w-full"),style:{animationDelay:`${T*.1}s`}},T))}),e[10]=i,e[11]=v,e[12]=b):b=e[12];let y;e[13]!==b||e[14]!==f?(y=p.jsx("div",{className:f,children:b}),e[13]=b,e[14]=f,e[15]=y):y=e[15];let x;e[16]!==y||e[17]!==d?(x=p.jsxs("div",{className:d,children:[m,y]}),e[16]=y,e[17]=d,e[18]=x):x=e[18];let N;return e[19]!==x||e[20]!==c?(N=p.jsx("div",{className:c,children:x}),e[19]=x,e[20]=c,e[21]=N):N=e[21],N}var Ie;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const n={};for(const i of r)n[i]=i;return n},t.getValidEnumValues=r=>{const n=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of n)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(n){return r[n]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.push(i);return n},t.find=(r,n)=>{for(const i of r)if(n(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}t.joinValues=s,t.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(Ie||(Ie={}));var ct;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(ct||(ct={}));Ie.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);Ie.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ke extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(n){return n.message},s={_errors:[]},r=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(a(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(a(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return r(this),s}static assert(e){if(!(e instanceof ke))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ie.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];a[n]=a[n]||[],a[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}ke.create=t=>new ke(t);var ut;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ut||(ut={}));var E;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(E||(E={}));function un(){const t=z.c(5),e=da(),{org:a}=He();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},t[0]=s):s=t[0];const r=Ot(s);let n;return t[1]!==a||t[2]!==r||t[3]!==e?(n=i=>{const c=i.toolCall.toolName.match(/^COLLECTION_([A-Z_]+)_(CREATE|UPDATE|DELETE)$/);if(!c||!c[1])return;const l=c[1],d=r.connectionId;if(!d)return;e.invalidateQueries({queryKey:Mt.collection(a.slug,d,l)});const m=l.toLowerCase().replace(/_/g," ");ze.success(`${m} updated`)},t[1]=a,t[2]=r,t[3]=e,t[4]=n):n=t[4],n}var Zt="vercel.ai.error",za=Symbol.for(Zt),dt,pt,ue=class Lt extends(pt=Error,dt=za,pt){constructor({name:e,message:a,cause:s}){super(a),this[dt]=!0,this.name=e,this.cause=s}static isInstance(e){return Lt.hasMarker(e,Zt)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function Ut(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Bt="AI_InvalidArgumentError",zt=`vercel.ai.error.${Bt}`,Fa=Symbol.for(zt),mt,ft,Va=class extends(ft=ue,mt=Fa,ft){constructor({message:t,cause:e,argument:a}){super({name:Bt,message:t,cause:e}),this[mt]=!0,this.argument=a}static isInstance(t){return ue.hasMarker(t,zt)}},Ft="AI_JSONParseError",Vt=`vercel.ai.error.${Ft}`,qa=Symbol.for(Vt),ht,gt,vt=class extends(gt=ue,ht=qa,gt){constructor({text:t,cause:e}){super({name:Ft,message:`JSON parsing failed: Text: ${t}.
|
|
2
|
+
Error message: ${Ut(e)}`,cause:e}),this[ht]=!0,this.text=t}static isInstance(t){return ue.hasMarker(t,Vt)}},qt="AI_TypeValidationError",Jt=`vercel.ai.error.${qt}`,Ja=Symbol.for(Jt),yt,bt,be=class Fe extends(bt=ue,yt=Ja,bt){constructor({value:e,cause:a}){super({name:qt,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
3
|
+
Error message: ${Ut(a)}`,cause:a}),this[yt]=!0,this.value=e}static isInstance(e){return ue.hasMarker(e,Jt)}static wrap({value:e,cause:a}){return Fe.isInstance(a)&&a.value===e?a:new Fe({value:e,cause:a})}},Ce=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const n=a.length,i=new Array(e);for(let o=0;o<e;o++)i[o]=a[Math.random()*n|0];return i.join("")};if(t==null)return r;if(a.includes(s))throw new Va({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},Wa=Ce();function xt(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function pe(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function _t(t,...e){const a=new Headers(pe(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var Ga=/"__proto__"\s*:/,Ya=/"constructor"\s*:/;function wt(t){const e=JSON.parse(t);return e===null||typeof e!="object"||Ga.test(t)===!1&&Ya.test(t)===!1?e:Ha(e)}function Ha(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const n=s[r];n&&typeof n=="object"&&e.push(n)}}}return t}function Qa(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return wt(t)}try{return wt(t)}finally{Error.stackTraceLimit=e}}function st(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=de(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(de):de(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(de)),t.allOf!=null&&(t.allOf=t.allOf.map(de)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(de));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=de(e[a]);return t}function de(t){return typeof t=="boolean"?t:st(t)}var Xa=Symbol("Let zodToJsonSchema decide on which parser to use"),Et={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Ka=t=>typeof t=="string"?{...Et,name:t}:{...Et,...t};function Y(){return{}}function es(t,e){var a,s,r;const n={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==E.ZodAny&&(n.items=A(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(n.minItems=t.minLength.value),t.maxLength&&(n.maxItems=t.maxLength.value),t.exactLength&&(n.minItems=t.exactLength.value,n.maxItems=t.exactLength.value),n}function ts(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function as(){return{type:"boolean"}}function Wt(t,e){return A(t.type._def,e)}var ss=(t,e)=>A(t.innerType._def,e);function Gt(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>Gt(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return rs(t)}}var rs=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function ns(t,e){return{...A(t.innerType._def,e),default:t.defaultValue()}}function os(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):Y()}function is(t){return{type:"string",enum:Array.from(t.values)}}var ls=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function cs(t,e){const a=[A(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),A(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(ls(r))s.push(...r.allOf);else{let n=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:i,...o}=r;n=o}s.push(n)}}),s.length?{allOf:s}:void 0}function us(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var Le=void 0,K={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Le===void 0&&(Le=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Le),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Yt(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":ee(a,"email",s.message,e);break;case"format:idn-email":ee(a,"idn-email",s.message,e);break;case"pattern:zod":V(a,K.email,s.message,e);break}break;case"url":ee(a,"uri",s.message,e);break;case"uuid":ee(a,"uuid",s.message,e);break;case"regex":V(a,s.regex,s.message,e);break;case"cuid":V(a,K.cuid,s.message,e);break;case"cuid2":V(a,K.cuid2,s.message,e);break;case"startsWith":V(a,RegExp(`^${Ue(s.value,e)}`),s.message,e);break;case"endsWith":V(a,RegExp(`${Ue(s.value,e)}$`),s.message,e);break;case"datetime":ee(a,"date-time",s.message,e);break;case"date":ee(a,"date",s.message,e);break;case"time":ee(a,"time",s.message,e);break;case"duration":ee(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{V(a,RegExp(Ue(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&ee(a,"ipv4",s.message,e),s.version!=="v4"&&ee(a,"ipv6",s.message,e);break}case"base64url":V(a,K.base64url,s.message,e);break;case"jwt":V(a,K.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&V(a,K.ipv4Cidr,s.message,e),s.version!=="v4"&&V(a,K.ipv6Cidr,s.message,e);break}case"emoji":V(a,K.emoji(),s.message,e);break;case"ulid":{V(a,K.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ee(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{V(a,K.base64,s.message,e);break}}break}case"nanoid":V(a,K.nanoid,s.message,e)}return a}function Ue(t,e){return e.patternStrategy==="escape"?ps(t):t}var ds=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ps(t){let e="";for(let a=0;a<t.length;a++)ds.has(t[a])||(e+="\\"),e+=t[a];return e}function ee(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function V(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:It(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=It(e,s)}function It(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let n="",i=!1,o=!1,c=!1;for(let l=0;l<r.length;l++){if(i){n+=r[l],i=!1;continue}if(s.i){if(o){if(r[l].match(/[a-z]/)){c?(n+=r[l],n+=`${r[l-2]}-${r[l]}`.toUpperCase(),c=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(n+=r[l],c=!0):n+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){n+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){n+=`(^|(?<=[\r
|
|
4
|
+
]))`;continue}else if(r[l]==="$"){n+=`($|(?=[\r
|
|
5
|
+
]))`;continue}}if(s.s&&r[l]==="."){n+=o?`${r[l]}\r
|
|
6
|
+
`:`[${r[l]}\r
|
|
7
|
+
]`;continue}n+=r[l],r[l]==="\\"?i=!0:o&&r[l]==="]"?o=!1:!o&&r[l]==="["&&(o=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}function Ht(t,e){var a,s,r,n,i,o;const c={type:"object",additionalProperties:(a=A(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]}))!=null?a:e.allowedAdditionalProperties};if(((s=t.keyType)==null?void 0:s._def.typeName)===E.ZodString&&((r=t.keyType._def.checks)!=null&&r.length)){const{type:l,...d}=Yt(t.keyType._def,e);return{...c,propertyNames:d}}else{if(((n=t.keyType)==null?void 0:n._def.typeName)===E.ZodEnum)return{...c,propertyNames:{enum:t.keyType._def.values}};if(((i=t.keyType)==null?void 0:i._def.typeName)===E.ZodBranded&&t.keyType._def.type._def.typeName===E.ZodString&&((o=t.keyType._def.type._def.checks)!=null&&o.length)){const{type:l,...d}=Wt(t.keyType._def,e);return{...c,propertyNames:d}}}return c}function ms(t,e){if(e.mapStrategy==="record")return Ht(t,e);const a=A(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Y(),s=A(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Y();return{type:"array",maxItems:125,items:{type:"array",items:[a,s],minItems:2,maxItems:2}}}function fs(t){const e=t.values,s=Object.keys(t.values).filter(n=>typeof e[e[n]]!="number").map(n=>e[n]),r=Array.from(new Set(s.map(n=>typeof n)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function hs(){return{not:Y()}}function gs(){return{type:"null"}}var Ve={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function vs(t,e){const a=t.options instanceof Map?Array.from(t.options.values()):t.options;if(a.every(s=>s._def.typeName in Ve&&(!s._def.checks||!s._def.checks.length))){const s=a.reduce((r,n)=>{const i=Ve[n._def.typeName];return i&&!r.includes(i)?[...r,i]:r},[]);return{type:s.length>1?s:s[0]}}else if(a.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){const s=a.reduce((r,n)=>{const i=typeof n._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];case"bigint":return[...r,"integer"];case"object":if(n._def.value===null)return[...r,"null"];default:return r}},[]);if(s.length===a.length){const r=s.filter((n,i,o)=>o.indexOf(n)===i);return{type:r.length>1?r:r[0],enum:a.reduce((n,i)=>n.includes(i._def.value)?n:[...n,i._def.value],[])}}}else if(a.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:a.reduce((s,r)=>[...s,...r._def.values.filter(n=>!s.includes(n))],[])};return ys(t,e)}var ys=(t,e)=>{const a=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,r)=>A(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return a.length?{anyOf:a}:void 0};function bs(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Ve[t.innerType._def.typeName],"null"]};const a=A(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}function xs(t){const e={type:"number"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"int":e.type="integer";break;case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function _s(t,e){const a={type:"object",properties:{}},s=[],r=t.shape();for(const i in r){let o=r[i];if(o===void 0||o._def===void 0)continue;const c=Es(o),l=A(o._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(a.properties[i]=l,c||s.push(i))}s.length&&(a.required=s);const n=ws(t,e);return n!==void 0&&(a.additionalProperties=n),a}function ws(t,e){if(t.catchall._def.typeName!=="ZodNever")return A(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Es(t){try{return t.isOptional()}catch{return!0}}var Is=(t,e)=>{var a;if(e.currentPath.toString()===((a=e.propertyPath)==null?void 0:a.toString()))return A(t.innerType._def,e);const s=A(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return s?{anyOf:[{not:Y()},s]}:Y()},Ns=(t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);const a=A(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=A(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",a?"1":"0"]});return{allOf:[a,s].filter(r=>r!==void 0)}};function Ss(t,e){return A(t.type._def,e)}function Ts(t,e){const s={type:"array",uniqueItems:!0,items:A(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&(s.minItems=t.minSize.value),t.maxSize&&(s.maxItems=t.maxSize.value),s}function Cs(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((a,s)=>A(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[]),additionalItems:A(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((a,s)=>A(a._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((a,s)=>s===void 0?a:[...a,s],[])}}function Rs(){return{not:Y()}}function js(){return Y()}var As=(t,e)=>A(t.innerType._def,e),Os=(t,e,a)=>{switch(e){case E.ZodString:return Yt(t,a);case E.ZodNumber:return xs(t);case E.ZodObject:return _s(t,a);case E.ZodBigInt:return ts(t);case E.ZodBoolean:return as();case E.ZodDate:return Gt(t,a);case E.ZodUndefined:return Rs();case E.ZodNull:return gs();case E.ZodArray:return es(t,a);case E.ZodUnion:case E.ZodDiscriminatedUnion:return vs(t,a);case E.ZodIntersection:return cs(t,a);case E.ZodTuple:return Cs(t,a);case E.ZodRecord:return Ht(t,a);case E.ZodLiteral:return us(t);case E.ZodEnum:return is(t);case E.ZodNativeEnum:return fs(t);case E.ZodNullable:return bs(t,a);case E.ZodOptional:return Is(t,a);case E.ZodMap:return ms(t,a);case E.ZodSet:return Ts(t,a);case E.ZodLazy:return()=>t.getter()._def;case E.ZodPromise:return Ss(t,a);case E.ZodNaN:case E.ZodNever:return hs();case E.ZodEffects:return os(t,a);case E.ZodAny:return Y();case E.ZodUnknown:return js();case E.ZodDefault:return ns(t,a);case E.ZodBranded:return Wt(t,a);case E.ZodReadonly:return As(t,a);case E.ZodCatch:return ss(t,a);case E.ZodPipeline:return Ns(t,a);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(s=>{})()}},Ms=(t,e)=>{let a=0;for(;a<t.length&&a<e.length&&t[a]===e[a];a++);return[(t.length-a).toString(),...e.slice(a)].join("/")};function A(t,e,a=!1){var s;const r=e.seen.get(t);if(e.override){const c=(s=e.override)==null?void 0:s.call(e,t,e,r,a);if(c!==Xa)return c}if(r&&!a){const c=Ps(r,e);if(c!==void 0)return c}const n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);const i=Os(t,t.typeName,e),o=typeof i=="function"?A(i(),e):i;if(o&&ks(t,e,o),e.postProcess){const c=e.postProcess(o,t,e);return n.jsonSchema=o,c}return n.jsonSchema=o,o}var Ps=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Ms(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((a,s)=>e.currentPath[s]===a)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Y()):e.$refStrategy==="seen"?Y():void 0}},ks=(t,e,a)=>(t.description&&(a.description=t.description),a),Ds=t=>{const e=Ka(t),a=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}},$s=(t,e)=>{var a;const s=Ds(e);let r=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[d,m])=>{var h;return{...l,[d]:(h=A(m._def,{...s,currentPath:[...s.basePath,s.definitionPath,d]},!0))!=null?h:Y()}},{}):void 0;const n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,i=(a=A(t._def,n===void 0?s:{...s,currentPath:[...s.basePath,s.definitionPath,n]},!1))!=null?a:Y(),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(i.title=o);const c=n===void 0?r?{...i,[s.definitionPath]:r}:i:{$ref:[...s.$refStrategy==="relative"?[]:s.basePath,s.definitionPath,n].join("/"),[s.definitionPath]:{...r,[n]:i}};return c.$schema="http://json-schema.org/draft-07/schema#",c},qe=Symbol.for("vercel.ai.schema");function Zs(t){let e;return()=>(e==null&&(e=t()),e)}function De(t,{validate:e}={}){return{[qe]:!0,_type:void 0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:e}}function Ls(t){return typeof t=="object"&&t!==null&&qe in t&&t[qe]===!0&&"jsonSchema"in t&&"validate"in t}function rt(t){return t==null?De({properties:{},additionalProperties:!1}):Ls(t)?t:"~standard"in t?t["~standard"].vendor==="zod"?Qt(t):Us(t):t()}function Us(t){return De(()=>st(t["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async e=>{const a=await t["~standard"].validate(e);return"value"in a?{success:!0,value:a.value}:{success:!1,error:new be({value:e,cause:a.issues})}}})}function Bs(t,e){var a;const s=(a=void 0)!=null?a:!1;return De(()=>$s(t,{$refStrategy:s?"root":"none"}),{validate:async r=>{const n=await t.safeParseAsync(r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function zs(t,e){var a;const s=(a=void 0)!=null?a:!1;return De(()=>st(ma(t,{target:"draft-7",io:"input",reused:s?"ref":"inline"})),{validate:async r=>{const n=await pa(t,r);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function Fs(t){return"_zod"in t}function Qt(t,e){return Fs(t)?zs(t):Bs(t)}async function Nt({value:t,schema:e}){const a=await Ne({value:t,schema:e});if(!a.success)throw be.wrap({value:t,cause:a.error});return a.value}async function Ne({value:t,schema:e}){const a=rt(e);try{if(a.validate==null)return{success:!0,value:t,rawValue:t};const s=await a.validate(t);return s.success?{success:!0,value:s.value,rawValue:t}:{success:!1,error:be.wrap({value:t,cause:s.error}),rawValue:t}}catch(s){return{success:!1,error:be.wrap({value:t,cause:s}),rawValue:t}}}async function me({text:t,schema:e}){try{const a=Qa(t);return e==null?{success:!0,value:a,rawValue:a}:await Ne({value:a,schema:e})}catch(a){return{success:!1,error:vt.isInstance(a)?a:new vt({text:t,cause:a}),rawValue:void 0}}}function Vs({stream:t,schema:e}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new _a).pipeThrough(new TransformStream({async transform({data:a},s){a!=="[DONE]"&&s.enqueue(await me({text:a,schema:e}))}}))}async function le(t){return typeof t=="function"&&(t=t()),Promise.resolve(t)}var qs=Object.defineProperty,Js=(t,e)=>{for(var a in e)qs(t,a,{get:e[a],enumerable:!0})},Xt="AI_NoObjectGeneratedError",Kt=`vercel.ai.error.${Xt}`,Ws=Symbol.for(Kt),ea,ce=class extends ue{constructor({message:t="No object generated.",cause:e,text:a,response:s,usage:r,finishReason:n}){super({name:Xt,message:t,cause:e}),this[ea]=!0,this.text=a,this.response=s,this.usage=r,this.finishReason=n}static isInstance(t){return ue.hasMarker(t,Kt)}};ea=Ws;var St="6.0.33",ta=W([g(),Me(Uint8Array),Me(ArrayBuffer),Pt(t=>{var e,a;return(a=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?a:!1},{message:"Must be a Buffer"})]),Se=fa(()=>W([ha(),g(),ga(),q(),Ee(g(),Se.optional()),Te(Se)])),R=Ee(g(),Ee(g(),Se.optional())),aa=O({type:_("text"),text:g(),providerOptions:R.optional()}),Gs=O({type:_("image"),image:W([ta,Me(URL)]),mediaType:g().optional(),providerOptions:R.optional()}),sa=O({type:_("file"),data:W([ta,Me(URL)]),filename:g().optional(),mediaType:g(),providerOptions:R.optional()}),Ys=O({type:_("reasoning"),text:g(),providerOptions:R.optional()}),Hs=O({type:_("tool-call"),toolCallId:g(),toolName:g(),input:oe(),providerOptions:R.optional(),providerExecuted:q().optional()}),Qs=va("type",[O({type:_("text"),value:g(),providerOptions:R.optional()}),O({type:_("json"),value:Se,providerOptions:R.optional()}),O({type:_("execution-denied"),reason:g().optional(),providerOptions:R.optional()}),O({type:_("error-text"),value:g(),providerOptions:R.optional()}),O({type:_("error-json"),value:Se,providerOptions:R.optional()}),O({type:_("content"),value:Te(W([O({type:_("text"),text:g(),providerOptions:R.optional()}),O({type:_("media"),data:g(),mediaType:g()}),O({type:_("file-data"),data:g(),mediaType:g(),filename:g().optional(),providerOptions:R.optional()}),O({type:_("file-url"),url:g(),providerOptions:R.optional()}),O({type:_("file-id"),fileId:W([g(),Ee(g(),g())]),providerOptions:R.optional()}),O({type:_("image-data"),data:g(),mediaType:g(),providerOptions:R.optional()}),O({type:_("image-url"),url:g(),providerOptions:R.optional()}),O({type:_("image-file-id"),fileId:W([g(),Ee(g(),g())]),providerOptions:R.optional()}),O({type:_("custom"),providerOptions:R.optional()})]))})]),ra=O({type:_("tool-result"),toolCallId:g(),toolName:g(),output:Qs,providerOptions:R.optional()}),Xs=O({type:_("tool-approval-request"),approvalId:g(),toolCallId:g()}),Ks=O({type:_("tool-approval-response"),approvalId:g(),approved:q(),reason:g().optional()}),er=O({role:_("system"),content:g(),providerOptions:R.optional()}),tr=O({role:_("user"),content:W([g(),Te(W([aa,Gs,sa]))]),providerOptions:R.optional()}),ar=O({role:_("assistant"),content:W([g(),Te(W([aa,sa,Ys,Hs,ra,Xs]))]),providerOptions:R.optional()}),sr=O({role:_("tool"),content:Te(W([ra,Ks])),providerOptions:R.optional()});W([er,tr,ar,sr]);function na(t,e){if(t===void 0&&e===void 0)return;if(t===void 0)return e;if(e===void 0)return t;const a={...t};for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(r===void 0)continue;const n=s in t?t[s]:void 0,i=r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp),o=n!=null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp);i&&o?a[s]=na(n,r):a[s]=r}return a}var rr={};Js(rr,{array:()=>lr,choice:()=>cr,json:()=>ur,object:()=>ir,text:()=>or});function nr(t){const e=["ROOT"];let a=-1,s=null;function r(c,l,d){switch(c){case'"':{a=l,e.pop(),e.push(d),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{a=l,s=l,e.pop(),e.push(d),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=l,e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"{":{a=l,e.pop(),e.push(d),e.push("INSIDE_OBJECT_START");break}case"[":{a=l,e.pop(),e.push(d),e.push("INSIDE_ARRAY_START");break}}}function n(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=l,e.pop();break}}}function i(c,l){switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=l,e.pop();break}}}for(let c=0;c<t.length;c++){const l=t[c];switch(e[e.length-1]){case"ROOT":r(l,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(l){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{a=c,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_KEY"));break}case"INSIDE_OBJECT_KEY":{l==='"'&&(e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY"));break}case"INSIDE_OBJECT_AFTER_KEY":{l===":"&&(e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE"));break}case"INSIDE_OBJECT_BEFORE_VALUE":{r(l,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{n(l,c);break}case"INSIDE_STRING":{switch(l){case'"':{e.pop(),a=c;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:a=c}break}case"INSIDE_ARRAY_START":{l==="]"?(a=c,e.pop()):(a=c,r(l,c,"INSIDE_ARRAY_AFTER_VALUE"));break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{a=c,e.pop();break}default:{a=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{r(l,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),a=c;break}case"INSIDE_NUMBER":{switch(l){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=c;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&n(l,c);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const m=t.substring(s,c+1);!"false".startsWith(m)&&!"true".startsWith(m)&&!"null".startsWith(m)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?n(l,c):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(l,c)):a=c;break}}}let o=t.slice(0,a+1);for(let c=e.length-1;c>=0;c--)switch(e[c]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const d=t.substring(s,t.length);"true".startsWith(d)?o+="true".slice(d.length):"false".startsWith(d)?o+="false".slice(d.length):"null".startsWith(d)&&(o+="null".slice(d.length))}}return o}async function Re(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=await me({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=await me({text:nr(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var or=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:t}){return t},async parsePartialOutput({text:t}){return{partial:t}},createElementStreamTransform(){}}),ir=({schema:t,name:e,description:a})=>{const s=rt(t);return{name:"object",responseFormat:le(s.jsonSchema).then(r=>({type:"json",schema:r,...e!=null&&{name:e},...a!=null&&{description:a}})),async parseCompleteOutput({text:r},n){const i=await me({text:r});if(!i.success)throw new ce({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=await Ne({value:i.value,schema:s});if(!o.success)throw new ce({message:"No object generated: response did not match schema.",cause:o.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});return o.value},async parsePartialOutput({text:r}){const n=await Re(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:n.value}}},createElementStreamTransform(){}}},lr=({element:t,name:e,description:a})=>{const s=rt(t);return{name:"array",responseFormat:le(s.jsonSchema).then(r=>{const{$schema:n,...i}=r;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:i}},required:["elements"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}}),async parseCompleteOutput({text:r},n){const i=await me({text:r});if(!i.success)throw new ce({message:"No object generated: could not parse the response.",cause:i.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});const o=i.value;if(o==null||typeof o!="object"||!("elements"in o)||!Array.isArray(o.elements))throw new ce({message:"No object generated: response did not match schema.",cause:new be({value:o,cause:"response must be an object with an elements array"}),text:r,response:n.response,usage:n.usage,finishReason:n.finishReason});for(const c of o.elements){const l=await Ne({value:c,schema:s});if(!l.success)throw new ce({message:"No object generated: response did not match schema.",cause:l.error,text:r,response:n.response,usage:n.usage,finishReason:n.finishReason})}return o.elements},async parsePartialOutput({text:r}){const n=await Re(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const i=n.value;if(i==null||typeof i!="object"||!("elements"in i)||!Array.isArray(i.elements))return;const o=n.state==="repaired-parse"&&i.elements.length>0?i.elements.slice(0,-1):i.elements,c=[];for(const l of o){const d=await Ne({value:l,schema:s});d.success&&c.push(d.value)}return{partial:c}}}},createElementStreamTransform(){let r=0;return new TransformStream({transform({partialOutput:n},i){if(n!=null)for(;r<n.length;r++)i.enqueue(n[r])}})}}},cr=({options:t,name:e,description:a})=>({name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},...e!=null&&{name:e},...a!=null&&{description:a}}),async parseCompleteOutput({text:s},r){const n=await me({text:s});if(!n.success)throw new ce({message:"No object generated: could not parse the response.",cause:n.error,text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});const i=n.value;if(i==null||typeof i!="object"||!("result"in i)||typeof i.result!="string"||!t.includes(i.result))throw new ce({message:"No object generated: response did not match schema.",cause:new be({value:i,cause:"response must be an object that contains a choice value."}),text:s,response:r.response,usage:r.usage,finishReason:r.finishReason});return i.result},async parsePartialOutput({text:s}){const r=await Re(s);switch(r.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{const n=r.value;if(n==null||typeof n!="object"||!("result"in n)||typeof n.result!="string")return;const i=t.filter(o=>o.startsWith(n.result));return r.state==="successful-parse"?i.includes(n.result)?{partial:n.result}:void 0:i.length===1?{partial:i[0]}:void 0}}},createElementStreamTransform(){}}),ur=({name:t,description:e}={})=>({name:"json",responseFormat:Promise.resolve({type:"json",...t!=null&&{name:t},...e!=null&&{description:e}}),async parseCompleteOutput({text:a},s){const r=await me({text:a});if(!r.success)throw new ce({message:"No object generated: could not parse the response.",cause:r.error,text:a,response:s.response,usage:s.usage,finishReason:s.finishReason});return r.value},async parsePartialOutput({text:a}){const s=await Re(a);switch(s.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return s.value===void 0?void 0:{partial:s.value}}},createElementStreamTransform(){}});Ce({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,e){e.enqueue(`data: ${JSON.stringify(t)}
|
|
8
|
+
|
|
9
|
+
`)},flush(t){t.enqueue(`data: [DONE]
|
|
10
|
+
|
|
11
|
+
`)}})}});var dr=Zs(()=>Qt(W([M({type:_("text-start"),id:g(),providerMetadata:R.optional()}),M({type:_("text-delta"),id:g(),delta:g(),providerMetadata:R.optional()}),M({type:_("text-end"),id:g(),providerMetadata:R.optional()}),M({type:_("error"),errorText:g()}),M({type:_("tool-input-start"),toolCallId:g(),toolName:g(),providerExecuted:q().optional(),dynamic:q().optional(),title:g().optional()}),M({type:_("tool-input-delta"),toolCallId:g(),inputTextDelta:g()}),M({type:_("tool-input-available"),toolCallId:g(),toolName:g(),input:oe(),providerExecuted:q().optional(),providerMetadata:R.optional(),dynamic:q().optional(),title:g().optional()}),M({type:_("tool-input-error"),toolCallId:g(),toolName:g(),input:oe(),providerExecuted:q().optional(),providerMetadata:R.optional(),dynamic:q().optional(),errorText:g(),title:g().optional()}),M({type:_("tool-approval-request"),approvalId:g(),toolCallId:g()}),M({type:_("tool-output-available"),toolCallId:g(),output:oe(),providerExecuted:q().optional(),dynamic:q().optional(),preliminary:q().optional()}),M({type:_("tool-output-error"),toolCallId:g(),errorText:g(),providerExecuted:q().optional(),dynamic:q().optional()}),M({type:_("tool-output-denied"),toolCallId:g()}),M({type:_("reasoning-start"),id:g(),providerMetadata:R.optional()}),M({type:_("reasoning-delta"),id:g(),delta:g(),providerMetadata:R.optional()}),M({type:_("reasoning-end"),id:g(),providerMetadata:R.optional()}),M({type:_("source-url"),sourceId:g(),url:g(),title:g().optional(),providerMetadata:R.optional()}),M({type:_("source-document"),sourceId:g(),mediaType:g(),title:g(),filename:g().optional(),providerMetadata:R.optional()}),M({type:_("file"),url:g(),mediaType:g(),providerMetadata:R.optional()}),M({type:Pt(t=>typeof t=="string"&&t.startsWith("data-"),{message:'Type must start with "data-"'}),id:g().optional(),data:oe(),transient:q().optional()}),M({type:_("start-step")}),M({type:_("finish-step")}),M({type:_("start"),messageId:g().optional(),messageMetadata:oe().optional()}),M({type:_("finish"),finishReason:ya(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:oe().optional()}),M({type:_("abort"),reason:g().optional()}),M({type:_("message-metadata"),messageMetadata:oe()})])));function pr(t){return t.type.startsWith("data-")}function Je(t){return t.type.startsWith("tool-")}function mr(t){return t.type==="dynamic-tool"}function We(t){return Je(t)||mr(t)}function Tt(t){return t.type.split("-").slice(1).join("-")}function fr({lastMessage:t,messageId:e}){return{message:t?.role==="assistant"?t:{id:e,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function hr({stream:t,messageMetadataSchema:e,dataPartSchemas:a,runUpdateMessageJob:s,onError:r,onToolCall:n,onData:i}){return t.pipeThrough(new TransformStream({async transform(o,c){await s(async({state:l,write:d})=>{var m,h,f,v;function b(u){const S=l.message.parts.filter(We).find(w=>w.toolCallId===u);if(S==null)throw new Error(`no tool invocation found for tool call ${u}`);return S}function y(u){var T;const S=l.message.parts.find(j=>Je(j)&&j.toolCallId===u.toolCallId),w=u,I=S;S!=null?(S.state=u.state,I.input=w.input,I.output=w.output,I.errorText=w.errorText,I.rawInput=w.rawInput,I.preliminary=w.preliminary,u.title!==void 0&&(I.title=u.title),I.providerExecuted=(T=w.providerExecuted)!=null?T:S.providerExecuted,w.providerMetadata!=null&&S.state==="input-available"&&(S.callProviderMetadata=w.providerMetadata)):l.message.parts.push({type:`tool-${u.toolName}`,toolCallId:u.toolCallId,state:u.state,title:u.title,input:w.input,output:w.output,rawInput:w.rawInput,errorText:w.errorText,providerExecuted:w.providerExecuted,preliminary:w.preliminary,...w.providerMetadata!=null?{callProviderMetadata:w.providerMetadata}:{}})}function x(u){var T,S;const w=l.message.parts.find($=>$.type==="dynamic-tool"&&$.toolCallId===u.toolCallId),I=u,j=w;w!=null?(w.state=u.state,j.toolName=u.toolName,j.input=I.input,j.output=I.output,j.errorText=I.errorText,j.rawInput=(T=I.rawInput)!=null?T:j.rawInput,j.preliminary=I.preliminary,u.title!==void 0&&(j.title=u.title),j.providerExecuted=(S=I.providerExecuted)!=null?S:w.providerExecuted,I.providerMetadata!=null&&w.state==="input-available"&&(w.callProviderMetadata=I.providerMetadata)):l.message.parts.push({type:"dynamic-tool",toolName:u.toolName,toolCallId:u.toolCallId,state:u.state,input:I.input,output:I.output,errorText:I.errorText,preliminary:I.preliminary,providerExecuted:I.providerExecuted,title:u.title,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}async function N(u){if(u!=null){const T=l.message.metadata!=null?na(l.message.metadata,u):u;e!=null&&await Nt({value:T,schema:e}),l.message.metadata=T}}switch(o.type){case"text-start":{const u={type:"text",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeTextParts[o.id]=u,l.message.parts.push(u),d();break}case"text-delta":{const u=l.activeTextParts[o.id];u.text+=o.delta,u.providerMetadata=(m=o.providerMetadata)!=null?m:u.providerMetadata,d();break}case"text-end":{const u=l.activeTextParts[o.id];u.state="done",u.providerMetadata=(h=o.providerMetadata)!=null?h:u.providerMetadata,delete l.activeTextParts[o.id],d();break}case"reasoning-start":{const u={type:"reasoning",text:"",providerMetadata:o.providerMetadata,state:"streaming"};l.activeReasoningParts[o.id]=u,l.message.parts.push(u),d();break}case"reasoning-delta":{const u=l.activeReasoningParts[o.id];u.text+=o.delta,u.providerMetadata=(f=o.providerMetadata)!=null?f:u.providerMetadata,d();break}case"reasoning-end":{const u=l.activeReasoningParts[o.id];u.providerMetadata=(v=o.providerMetadata)!=null?v:u.providerMetadata,u.state="done",delete l.activeReasoningParts[o.id],d();break}case"file":{l.message.parts.push({type:"file",mediaType:o.mediaType,url:o.url}),d();break}case"source-url":{l.message.parts.push({type:"source-url",sourceId:o.sourceId,url:o.url,title:o.title,providerMetadata:o.providerMetadata}),d();break}case"source-document":{l.message.parts.push({type:"source-document",sourceId:o.sourceId,mediaType:o.mediaType,title:o.title,filename:o.filename,providerMetadata:o.providerMetadata}),d();break}case"tool-input-start":{const u=l.message.parts.filter(Je);l.partialToolCalls[o.toolCallId]={text:"",toolName:o.toolName,index:u.length,dynamic:o.dynamic,title:o.title},o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-streaming",input:void 0,providerExecuted:o.providerExecuted,title:o.title}),d();break}case"tool-input-delta":{const u=l.partialToolCalls[o.toolCallId];u.text+=o.inputTextDelta;const{value:T}=await Re(u.text);u.dynamic?x({toolCallId:o.toolCallId,toolName:u.toolName,state:"input-streaming",input:T,title:u.title}):y({toolCallId:o.toolCallId,toolName:u.toolName,state:"input-streaming",input:T,title:u.title}),d();break}case"tool-input-available":{o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"input-available",input:o.input,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata,title:o.title}),d(),n&&!o.providerExecuted&&await n({toolCall:o});break}case"tool-input-error":{o.dynamic?x({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}):y({toolCallId:o.toolCallId,toolName:o.toolName,state:"output-error",input:void 0,rawInput:o.input,errorText:o.errorText,providerExecuted:o.providerExecuted,providerMetadata:o.providerMetadata}),d();break}case"tool-approval-request":{const u=b(o.toolCallId);u.state="approval-requested",u.approval={id:o.approvalId},d();break}case"tool-output-denied":{const u=b(o.toolCallId);u.state="output-denied",d();break}case"tool-output-available":{const u=b(o.toolCallId);u.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:u.toolName,state:"output-available",input:u.input,output:o.output,preliminary:o.preliminary,providerExecuted:o.providerExecuted,title:u.title}):y({toolCallId:o.toolCallId,toolName:Tt(u),state:"output-available",input:u.input,output:o.output,providerExecuted:o.providerExecuted,preliminary:o.preliminary,title:u.title}),d();break}case"tool-output-error":{const u=b(o.toolCallId);u.type==="dynamic-tool"?x({toolCallId:o.toolCallId,toolName:u.toolName,state:"output-error",input:u.input,errorText:o.errorText,providerExecuted:o.providerExecuted,title:u.title}):y({toolCallId:o.toolCallId,toolName:Tt(u),state:"output-error",input:u.input,rawInput:u.rawInput,errorText:o.errorText,providerExecuted:o.providerExecuted,title:u.title}),d();break}case"start-step":{l.message.parts.push({type:"step-start"});break}case"finish-step":{l.activeTextParts={},l.activeReasoningParts={};break}case"start":{o.messageId!=null&&(l.message.id=o.messageId),await N(o.messageMetadata),(o.messageId!=null||o.messageMetadata!=null)&&d();break}case"finish":{o.finishReason!=null&&(l.finishReason=o.finishReason),await N(o.messageMetadata),o.messageMetadata!=null&&d();break}case"message-metadata":{await N(o.messageMetadata),o.messageMetadata!=null&&d();break}case"error":{r?.(new Error(o.errorText));break}default:if(pr(o)){a?.[o.type]!=null&&await Nt({value:o.data,schema:a[o.type]});const u=o;if(u.transient){i?.(u);break}const T=u.id!=null?l.message.parts.find(S=>u.type===S.type&&u.id===S.id):void 0;T!=null?T.data=u.data:l.message.parts.push(u),i?.(u),d()}}c.enqueue(o)})}}))}async function gr({stream:t,onError:e}){const a=t.getReader();try{for(;;){const{done:s}=await a.read();if(s)break}}catch(s){e?.(s)}finally{a.releaseLock()}}Ce({prefix:"aitxt",size:24});Ce({prefix:"aiobj",size:24});var vr=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(t){return new Promise((e,a)=>{this.queue.push(async()=>{try{await t(),e()}catch(s){a(s)}}),this.processQueue()})}};Ce({prefix:"aiobj",size:24});async function yr(t){if(t==null)return[];if(!globalThis.FileList||!(t instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(t).map(async e=>{const{name:a,type:s}=e,r=await new Promise((n,i)=>{const o=new FileReader;o.onload=c=>{var l;n((l=c.target)==null?void 0:l.result)},o.onerror=c=>i(c),o.readAsDataURL(e)});return{type:"file",mediaType:s,filename:a,url:r}}))}var br=class{constructor({api:t="/api/chat",credentials:e,headers:a,body:s,fetch:r,prepareSendMessagesRequest:n,prepareReconnectToStreamRequest:i}){this.api=t,this.credentials=e,this.headers=a,this.body=s,this.fetch=r,this.prepareSendMessagesRequest=n,this.prepareReconnectToStreamRequest=i}async sendMessages({abortSignal:t,...e}){var a,s,r,n,i;const o=await le(this.body),c=await le(this.headers),l=await le(this.credentials),d={...pe(c),...pe(e.headers)},m=await((a=this.prepareSendMessagesRequest)==null?void 0:a.call(this,{api:this.api,id:e.chatId,messages:e.messages,body:{...o,...e.body},headers:d,credentials:l,requestMetadata:e.metadata,trigger:e.trigger,messageId:e.messageId})),h=(s=m?.api)!=null?s:this.api,f=m?.headers!==void 0?pe(m.headers):d,v=m?.body!==void 0?m.body:{...o,...e.body,id:e.chatId,messages:e.messages,trigger:e.trigger,messageId:e.messageId},b=(r=m?.credentials)!=null?r:l,x=await((n=this.fetch)!=null?n:globalThis.fetch)(h,{method:"POST",headers:_t({"Content-Type":"application/json",...f},`ai-sdk/${St}`,xt()),body:JSON.stringify(v),credentials:b,signal:t});if(!x.ok)throw new Error((i=await x.text())!=null?i:"Failed to fetch the chat response.");if(!x.body)throw new Error("The response body is empty.");return this.processResponseStream(x.body)}async reconnectToStream(t){var e,a,s,r,n;const i=await le(this.body),o=await le(this.headers),c=await le(this.credentials),l={...pe(o),...pe(t.headers)},d=await((e=this.prepareReconnectToStreamRequest)==null?void 0:e.call(this,{api:this.api,id:t.chatId,body:{...i,...t.body},headers:l,credentials:c,requestMetadata:t.metadata})),m=(a=d?.api)!=null?a:`${this.api}/${t.chatId}/stream`,h=d?.headers!==void 0?pe(d.headers):l,f=(s=d?.credentials)!=null?s:c,b=await((r=this.fetch)!=null?r:globalThis.fetch)(m,{method:"GET",headers:_t(h,`ai-sdk/${St}`,xt()),credentials:f});if(b.status===204)return null;if(!b.ok)throw new Error((n=await b.text())!=null?n:"Failed to fetch the chat response.");if(!b.body)throw new Error("The response body is empty.");return this.processResponseStream(b.body)}},oa=class extends br{constructor(t={}){super(t)}processResponseStream(t){return Vs({stream:t,schema:dr}).pipeThrough(new TransformStream({async transform(e,a){if(!e.success)throw e.error;a.enqueue(e.value)}}))}},xr=class{constructor({generateId:t=Wa,id:e=t(),transport:a=new oa,messageMetadataSchema:s,dataPartSchemas:r,state:n,onError:i,onToolCall:o,onFinish:c,onData:l,sendAutomaticallyWhen:d}){this.activeResponse=void 0,this.jobExecutor=new vr,this.sendMessage=async(m,h)=>{var f,v,b,y;if(m==null){await this.makeRequest({trigger:"submit-message",messageId:(f=this.lastMessage)==null?void 0:f.id,...h});return}let x;if("text"in m||"files"in m?x={parts:[...Array.isArray(m.files)?m.files:await yr(m.files),..."text"in m&&m.text!=null?[{type:"text",text:m.text}]:[]]}:x=m,m.messageId!=null){const N=this.state.messages.findIndex(u=>u.id===m.messageId);if(N===-1)throw new Error(`message with id ${m.messageId} not found`);if(this.state.messages[N].role!=="user")throw new Error(`message with id ${m.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,N+1),this.state.replaceMessage(N,{...x,id:m.messageId,role:(v=x.role)!=null?v:"user",metadata:m.metadata})}else this.state.pushMessage({...x,id:(b=x.id)!=null?b:this.generateId(),role:(y=x.role)!=null?y:"user",metadata:m.metadata});await this.makeRequest({trigger:"submit-message",messageId:m.messageId,...h})},this.regenerate=async({messageId:m,...h}={})=>{const f=m==null?this.state.messages.length-1:this.state.messages.findIndex(v=>v.id===m);if(f===-1)throw new Error(`message ${m} not found`);this.state.messages=this.state.messages.slice(0,this.messages[f].role==="assistant"?f:f+1),await this.makeRequest({trigger:"regenerate-message",messageId:m,...h})},this.resumeStream=async(m={})=>{await this.makeRequest({trigger:"resume-stream",...m})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolApprovalResponse=async({id:m,approved:h,reason:f})=>this.jobExecutor.run(async()=>{var v,b;const y=this.state.messages,x=y[y.length-1],N=u=>We(u)&&u.state==="approval-requested"&&u.approval.id===m?{...u,state:"approval-responded",approval:{id:m,approved:h,reason:f}}:u;this.state.replaceMessage(y.length-1,{...x,parts:x.parts.map(N)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(N)),this.status!=="streaming"&&this.status!=="submitted"&&((v=this.sendAutomaticallyWhen)!=null&&v.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(b=this.lastMessage)==null?void 0:b.id})}),this.addToolOutput=async({state:m="output-available",tool:h,toolCallId:f,output:v,errorText:b})=>this.jobExecutor.run(async()=>{var y,x;const N=this.state.messages,u=N[N.length-1],T=S=>We(S)&&S.toolCallId===f?{...S,state:m,output:v,errorText:b}:S;this.state.replaceMessage(N.length-1,{...u,parts:u.parts.map(T)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(T)),this.status!=="streaming"&&this.status!=="submitted"&&((y=this.sendAutomaticallyWhen)!=null&&y.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(x=this.lastMessage)==null?void 0:x.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var m;this.status!=="streaming"&&this.status!=="submitted"||(m=this.activeResponse)!=null&&m.abortController&&this.activeResponse.abortController.abort()},this.id=e,this.transport=a,this.generateId=t,this.messageMetadataSchema=s,this.dataPartSchemas=r,this.state=n,this.onError=i,this.onToolCall=o,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=d}get status(){return this.state.status}setStatus({status:t,error:e}){this.status!==t&&(this.state.status=t,this.state.error=e)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(t){this.state.messages=t}async makeRequest({trigger:t,metadata:e,headers:a,body:s,messageId:r}){var n,i,o,c;this.setStatus({status:"submitted",error:void 0});const l=this.lastMessage;let d=!1,m=!1,h=!1;try{const f={state:fr({lastMessage:this.state.snapshot(l),messageId:this.generateId()}),abortController:new AbortController};f.abortController.signal.addEventListener("abort",()=>{d=!0}),this.activeResponse=f;let v;if(t==="resume-stream"){const y=await this.transport.reconnectToStream({chatId:this.id,metadata:e,headers:a,body:s});if(y==null){this.setStatus({status:"ready"});return}v=y}else v=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:f.abortController.signal,metadata:e,headers:a,body:s,trigger:t,messageId:r});const b=y=>this.jobExecutor.run(()=>y({state:f.state,write:()=>{var x;this.setStatus({status:"streaming"}),f.state.message.id===((x=this.lastMessage)==null?void 0:x.id)?this.state.replaceMessage(this.state.messages.length-1,f.state.message):this.state.pushMessage(f.state.message)}}));await gr({stream:hr({stream:v,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:b,onError:y=>{throw y}}),onError:y=>{throw y}}),this.setStatus({status:"ready"})}catch(f){if(d||f.name==="AbortError")return d=!0,this.setStatus({status:"ready"}),null;h=!0,f instanceof TypeError&&(f.message.toLowerCase().includes("fetch")||f.message.toLowerCase().includes("network"))&&(m=!0),this.onError&&f instanceof Error&&this.onError(f),this.setStatus({status:"error",error:f})}finally{try{(i=this.onFinish)==null||i.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:d,isDisconnect:m,isError:h,finishReason:(n=this.activeResponse)==null?void 0:n.state.finishReason})}catch(f){console.error(f)}this.activeResponse=void 0}(o=this.sendAutomaticallyWhen)!=null&&o.call(this,{messages:this.state.messages})&&!h&&await this.makeRequest({trigger:"submit-message",messageId:(c=this.lastMessage)==null?void 0:c.id,metadata:e,headers:a,body:s})}},Be,Ct;function _r(){if(Ct)return Be;Ct=1;function t(e,a){if(typeof e!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let s,r=0;return function(...i){clearTimeout(s);const o=Date.now(),c=o-r,l=a-c;l<=0?(r=o,e.apply(this,i)):s=setTimeout(()=>{r=Date.now(),e.apply(this,i)},l)}}return Be=t,Be}var wr=_r();const Er=ba(wr);var ia=(t,e,a)=>{if(!e.has(t))throw TypeError("Cannot "+a)},P=(t,e,a)=>(ia(t,e,"read from private field"),a?a.call(t):e.get(t)),ne=(t,e,a)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,a)},ie=(t,e,a,s)=>(ia(t,e,"write to private field"),e.set(t,a),a);function Ir(t,e){return e!=null?Er(t,e):t}var Q,Ae,Oe,xe,_e,we,ve,Ge,Ye,Nr=class{constructor(t=[]){ne(this,Q,void 0),ne(this,Ae,"ready"),ne(this,Oe,void 0),ne(this,xe,new Set),ne(this,_e,new Set),ne(this,we,new Set),this.pushMessage=e=>{ie(this,Q,P(this,Q).concat(e)),P(this,ve).call(this)},this.popMessage=()=>{ie(this,Q,P(this,Q).slice(0,-1)),P(this,ve).call(this)},this.replaceMessage=(e,a)=>{ie(this,Q,[...P(this,Q).slice(0,e),this.snapshot(a),...P(this,Q).slice(e+1)]),P(this,ve).call(this)},this.snapshot=e=>structuredClone(e),this["~registerMessagesCallback"]=(e,a)=>{const s=a?Ir(e,a):e;return P(this,xe).add(s),()=>{P(this,xe).delete(s)}},this["~registerStatusCallback"]=e=>(P(this,_e).add(e),()=>{P(this,_e).delete(e)}),this["~registerErrorCallback"]=e=>(P(this,we).add(e),()=>{P(this,we).delete(e)}),ne(this,ve,()=>{P(this,xe).forEach(e=>e())}),ne(this,Ge,()=>{P(this,_e).forEach(e=>e())}),ne(this,Ye,()=>{P(this,we).forEach(e=>e())}),ie(this,Q,t)}get status(){return P(this,Ae)}set status(t){ie(this,Ae,t),P(this,Ge).call(this)}get error(){return P(this,Oe)}set error(t){ie(this,Oe,t),P(this,Ye).call(this)}get messages(){return P(this,Q)}set messages(t){ie(this,Q,[...t]),P(this,ve).call(this)}};Q=new WeakMap;Ae=new WeakMap;Oe=new WeakMap;xe=new WeakMap;_e=new WeakMap;we=new WeakMap;ve=new WeakMap;Ge=new WeakMap;Ye=new WeakMap;var ye,Rt=class extends xr{constructor({messages:t,...e}){const a=new Nr(t);super({...e,state:a}),ne(this,ye,void 0),this["~registerMessagesCallback"]=(s,r)=>P(this,ye)["~registerMessagesCallback"](s,r),this["~registerStatusCallback"]=s=>P(this,ye)["~registerStatusCallback"](s),this["~registerErrorCallback"]=s=>P(this,ye)["~registerErrorCallback"](s),ie(this,ye,a)}};ye=new WeakMap;function Sr({experimental_throttle:t,resume:e=!1,...a}={}){const s=B.useRef("chat"in a?{}:{onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});"chat"in a||(s.current={onToolCall:a.onToolCall,onData:a.onData,onFinish:a.onFinish,onError:a.onError,sendAutomaticallyWhen:a.sendAutomaticallyWhen});const r={...a,onToolCall:h=>{var f,v;return(v=(f=s.current).onToolCall)==null?void 0:v.call(f,h)},onData:h=>{var f,v;return(v=(f=s.current).onData)==null?void 0:v.call(f,h)},onFinish:h=>{var f,v;return(v=(f=s.current).onFinish)==null?void 0:v.call(f,h)},onError:h=>{var f,v;return(v=(f=s.current).onError)==null?void 0:v.call(f,h)},sendAutomaticallyWhen:h=>{var f,v,b;return(b=(v=(f=s.current).sendAutomaticallyWhen)==null?void 0:v.call(f,h))!=null?b:!1}},n=B.useRef("chat"in a?a.chat:new Rt(r));("chat"in a&&a.chat!==n.current||"id"in a&&n.current.id!==a.id)&&(n.current="chat"in a?a.chat:new Rt(r));const o=B.useCallback(h=>n.current["~registerMessagesCallback"](h,t),[t,n.current.id]),c=B.useSyncExternalStore(o,()=>n.current.messages,()=>n.current.messages),l=B.useSyncExternalStore(n.current["~registerStatusCallback"],()=>n.current.status,()=>n.current.status),d=B.useSyncExternalStore(n.current["~registerErrorCallback"],()=>n.current.error,()=>n.current.error),m=B.useCallback(h=>{typeof h=="function"&&(h=h(n.current.messages)),n.current.messages=h},[n]);return B.useEffect(()=>{e&&n.current.resumeStream()},[e,n]),{id:n.current.id,messages:c,setMessages:m,sendMessage:n.current.sendMessage,regenerate:n.current.regenerate,clearError:n.current.clearError,stop:n.current.stop,error:d,resumeStream:n.current.resumeStream,status:l,addToolResult:n.current.addToolOutput,addToolOutput:n.current.addToolOutput,addToolApprovalResponse:n.current.addToolApprovalResponse}}const Tr="You are a helpful assistant.",Cr=t=>new oa({api:`/api/${t}/models/stream`,credentials:"include",prepareSendMessagesRequest:({messages:e,requestMetadata:a})=>({body:{messages:e,stream:!0,...a}})});function dn(t){const e=z.c(37),{threadId:a,systemPrompt:s,gatewayId:r,onError:n,onToolCall:i}=t,{org:o,locator:c}=He(),{slug:l}=o,d=wa(),m=Ea(),[h,f]=B.useState(null),v=Ia(a),b=s||Tr;let y;e[0]!==b?(y={id:"system",role:"system",parts:[{type:"text",text:b}]},e[0]=b,e[1]=y):y=e[1];const N=y;let u;e[2]!==v||e[3]!==N?(u=[N,...v],e[2]=v,e[3]=N,e[4]=u):u=e[4];const T=u,S=`${a}:${b}`;let w;e[5]!==l?(w=Cr(l),e[5]=l,e[6]=w):w=e[6];const I=w;let j;e[7]!==r||e[8]!==c||e[9]!==m||e[10]!==d||e[11]!==a?(j=async L=>{const{finishReason:H,messages:$e,isAbort:fe,isDisconnect:he,isError:ge}=L;if(f(H??null),H!=="stop"||fe||he||ge)return;const re=$e.slice(-2).filter(Boolean);if(re.length!==2){console.warn("[chat] Expected 2 messages, got",re.length);return}m.insertMany.mutate(re);const nt=re.find(jr)?.parts?.find(Rr)?.text.slice(0,100)||"",Ze=await Na(c,a);if(!Ze){const ot=new Date().toISOString(),ua={id:a,title:nt,created_at:ot,updated_at:ot,hidden:!1,gatewayId:r};d.insert.mutate(ua);return}d.update.mutate({id:a,updates:{title:Ze.title||nt,gatewayId:Ze.gatewayId||r,updated_at:new Date().toISOString()}})},e[7]=r,e[8]=c,e[9]=m,e[10]=d,e[11]=a,e[12]=j):j=e[12];const $=j;let D;e[13]!==n?(D=L=>{console.error("[chat] Chat error:",L),n?.(L)},e[13]=n,e[14]=D):D=e[14];let U;e[15]!==T||e[16]!==S||e[17]!==$||e[18]!==i||e[19]!==D||e[20]!==I?(U={id:S,messages:T,transport:I,onFinish:$,onToolCall:i,onError:D},e[15]=T,e[16]=S,e[17]=$,e[18]=i,e[19]=D,e[20]=I,e[21]=U):U=e[21];const C=Sr(U);let te;e[22]!==C?(te=async(L,H)=>{!L?.trim()||C.status==="submitted"||C.status==="streaming"||(f(null),await C.sendMessage({id:crypto.randomUUID(),role:"user",parts:[{type:"text",text:L}],metadata:H},{metadata:H}))},e[22]=C,e[23]=te):te=e[23];const F=te,ae=C.messages[0]?.role==="system"?C.messages.length===1:C.messages.length===0,G=C.messages,se=C.status;let k;e[24]!==C?(k=C.stop.bind(C),e[24]=C,e[25]=k):k=e[25];let X;e[26]===Symbol.for("react.memo_cache_sentinel")?(X=()=>f(null),e[26]=X):X=e[26];let Z;return e[27]!==C.clearError||e[28]!==C.error||e[29]!==C.messages||e[30]!==C.setMessages||e[31]!==C.status||e[32]!==h||e[33]!==ae||e[34]!==F||e[35]!==k?(Z={messages:G,status:se,sendMessage:F,stop:k,setMessages:C.setMessages,isEmpty:ae,error:C.error,clearError:C.clearError,finishReason:h,clearFinishReason:X},e[27]=C.clearError,e[28]=C.error,e[29]=C.messages,e[30]=C.setMessages,e[31]=C.status,e[32]=h,e[33]=ae,e[34]=F,e[35]=k,e[36]=Z):Z=e[36],Z}function Rr(t){return t.type==="text"}function jr(t){return t.parts?.find(Ar)}function Ar(t){return t.type==="text"}function Or(t,e){return t.find(e)??t[0]}function pn(t,e,a,s){const r=z.c(9),n=null,[i,o]=Ca(t,n);let c;r[0]!==a||r[1]!==i?(c=h=>i!==null?a(h,i):!1,r[0]=a,r[1]=i,r[2]=c):c=r[2];let l;r[3]!==e||r[4]!==c?(l=Or(e,c),r[3]=e,r[4]=c,r[5]=l):l=r[5];const d=l;let m;return r[6]!==d||r[7]!==o?(m=[d,o],r[6]=d,r[7]=o,r[8]=m):m=r[8],m}function mn(t){const e=z.c(11);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const s=Ot(a),[r]=Ra(t??void 0);let n;if(e[1]!==t||e[2]!==r||e[3]!==s.collectionName||e[4]!==s.connectionId||e[5]!==s.itemId){n=[],t&&(n.push(`### Selected Agent/Gateway
|
|
12
|
+
- ID: ${t}`),r?.trim()&&n.push(`### Agent Instructions
|
|
13
|
+
${r}`));let i;e[7]!==s.collectionName||e[8]!==s.connectionId||e[9]!==s.itemId?(i=[],s.connectionId&&i.push(`- Connection ID: ${s.connectionId}`),s.collectionName&&i.push(`- Collection: ${s.collectionName}`),s.itemId&&i.push(`- Item ID: ${s.itemId}`),e[7]=s.collectionName,e[8]=s.connectionId,e[9]=s.itemId,e[10]=i):i=e[10],i.length>0&&n.push(`### Current Resource
|
|
14
|
+
The user is viewing the following resource:
|
|
15
|
+
${i.join(`
|
|
16
|
+
`)}
|
|
17
|
+
|
|
18
|
+
Help the user understand and work with this resource.`),e[1]=t,e[2]=r,e[3]=s.collectionName,e[4]=s.connectionId,e[5]=s.itemId,e[6]=n}else n=e[6];return n.join(`
|
|
19
|
+
|
|
20
|
+
`)}const jt=[{border:"border-purple-400",bg:"bg-purple-400",text:"text-white",bgLight:"bg-purple-400/10"},{border:"border-blue-400",bg:"bg-blue-400",text:"text-white",bgLight:"bg-blue-400/10"},{border:"border-indigo-400",bg:"bg-indigo-400",text:"text-white",bgLight:"bg-indigo-400/10"},{border:"border-violet-400",bg:"bg-violet-400",text:"text-white",bgLight:"bg-violet-400/10"},{border:"border-pink-400",bg:"bg-pink-400",text:"text-white",bgLight:"bg-pink-400/10"},{border:"border-fuchsia-400",bg:"bg-fuchsia-400",text:"text-white",bgLight:"bg-fuchsia-400/10"},{border:"border-emerald-400",bg:"bg-emerald-400",text:"text-white",bgLight:"bg-emerald-400/10"},{border:"border-teal-400",bg:"bg-teal-400",text:"text-white",bgLight:"bg-teal-400/10"},{border:"border-cyan-400",bg:"bg-cyan-400",text:"text-white",bgLight:"bg-cyan-400/10"},{border:"border-sky-400",bg:"bg-sky-400",text:"text-white",bgLight:"bg-sky-400/10"},{border:"border-orange-400",bg:"bg-orange-400",text:"text-white",bgLight:"bg-orange-400/10"},{border:"border-amber-400",bg:"bg-amber-400",text:"text-white",bgLight:"bg-amber-400/10"},{border:"border-rose-400",bg:"bg-rose-400",text:"text-white",bgLight:"bg-rose-400/10"},{border:"border-lime-400",bg:"bg-lime-400",text:"text-white",bgLight:"bg-lime-400/10"}];function Mr(t){let e=0;for(let a=0;a<t.length;a++)e=t.charCodeAt(a)+((e<<5)-e);return Math.abs(e)}function la(t){if(t==null)return null;const a=Mr(t)%jt.length;return jt[a]}function Pr(t){const e=z.c(66),{gateway:a,onGatewayChange:s,onReset:r,className:n,disabled:i}=t,o=i===void 0?!1:i,[c,l]=B.useState(!1),d=B.useRef(null),m=Sa(),h=kt(),{org:f}=He();let v,b;if(e[0]!==c?(v=()=>{c&&setTimeout(()=>{d.current?.focus()},0)},b=[c],e[0]=c,e[1]=v,e[2]=b):(v=e[1],b=e[2]),B.useEffect(v,b),!a?.id)return null;let y,x,N,u;if(e[3]!==n||e[4]!==a.id||e[5]!==h||e[6]!==s||e[7]!==r||e[8]!==f.slug){const $e=la(a.id);let fe;e[13]!==r?(fe=re=>{re.stopPropagation(),r()},e[13]=r,e[14]=fe):fe=e[14],N=fe;let he;e[15]!==a.id||e[16]!==h||e[17]!==f.slug?(he=re=>{re.stopPropagation(),h({to:"/$org/gateways/$gatewayId",params:{org:f.slug,gatewayId:a.id}})},e[15]=a.id,e[16]=h,e[17]=f.slug,e[18]=he):he=e[18],y=he;let ge;e[19]!==s?(ge=re=>{s(re),l(!1)},e[19]=s,e[20]=ge):ge=e[20],x=ge,u=J("flex items-center justify-between px-3 py-1.5 rounded-t-xl",$e?.bg,n),e[3]=n,e[4]=a.id,e[5]=h,e[6]=s,e[7]=r,e[8]=f.slug,e[9]=y,e[10]=x,e[11]=N,e[12]=u}else y=e[9],x=e[10],N=e[11],u=e[12];const T=o?"cursor-not-allowed opacity-50":"cursor-pointer";let S;e[21]!==T?(S=J("flex items-center gap-1.5 hover:opacity-80 transition-opacity",T),e[21]=T,e[22]=S):S=e[22];let w;e[23]!==a.fallbackIcon?(w=a.fallbackIcon??p.jsx(Ma,{size:10}),e[23]=a.fallbackIcon,e[24]=w):w=e[24];let I;e[25]!==a.icon||e[26]!==a.title||e[27]!==w?(I=p.jsx(ja,{icon:a.icon,name:a.title,size:"2xs",fallbackIcon:w}),e[25]=a.icon,e[26]=a.title,e[27]=w,e[28]=I):I=e[28];let j;e[29]!==a.title?(j=p.jsx("span",{className:"text-xs text-white font-normal",children:a.title}),e[29]=a.title,e[30]=j):j=e[30];let $;e[31]===Symbol.for("react.memo_cache_sentinel")?($=p.jsx(Oa,{size:14,className:"text-white/50"}),e[31]=$):$=e[31];let D;e[32]!==o||e[33]!==S||e[34]!==I||e[35]!==j?(D=p.jsx(tt,{asChild:!0,children:p.jsxs("button",{type:"button",disabled:o,className:S,children:[I,j,$]})}),e[32]=o,e[33]=S,e[34]=I,e[35]=j,e[36]=D):D=e[36];let U;e[37]!==a.id||e[38]!==m||e[39]!==x?(U=p.jsx(et,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:p.jsx(Ta,{gateways:m,selectedGatewayId:a.id,onGatewayChange:x,searchInputRef:d})}),e[37]=a.id,e[38]=m,e[39]=x,e[40]=U):U=e[40];let C;e[41]!==c||e[42]!==D||e[43]!==U?(C=p.jsxs(at,{open:c,onOpenChange:l,children:[D,U]}),e[41]=c,e[42]=D,e[43]=U,e[44]=C):C=e[44];const te=o?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10";let F;e[45]!==te?(F=J("flex items-center justify-center p-1 rounded-full transition-colors",te),e[45]=te,e[46]=F):F=e[46];let ae;e[47]===Symbol.for("react.memo_cache_sentinel")?(ae=p.jsx(Pa,{size:14,className:"text-white"}),e[47]=ae):ae=e[47];let G;e[48]!==o||e[49]!==y||e[50]!==F?(G=p.jsx("button",{type:"button",onClick:y,disabled:o,className:F,"aria-label":"Edit gateway",children:ae}),e[48]=o,e[49]=y,e[50]=F,e[51]=G):G=e[51];const se=o?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10";let k;e[52]!==se?(k=J("flex items-center justify-center p-1 rounded-full transition-colors",se),e[52]=se,e[53]=k):k=e[53];let X;e[54]===Symbol.for("react.memo_cache_sentinel")?(X=p.jsx($t,{size:14,className:"text-white"}),e[54]=X):X=e[54];let Z;e[55]!==o||e[56]!==N||e[57]!==k?(Z=p.jsx("button",{type:"button",onClick:N,disabled:o,className:k,"aria-label":"Reset to default",children:X}),e[55]=o,e[56]=N,e[57]=k,e[58]=Z):Z=e[58];let L;e[59]!==G||e[60]!==Z?(L=p.jsxs("div",{className:"flex items-center gap-1",children:[G,Z]}),e[59]=G,e[60]=Z,e[61]=L):L=e[61];let H;return e[62]!==C||e[63]!==L||e[64]!==u?(H=p.jsxs("div",{className:u,children:[C,L]}),e[62]=C,e[63]=L,e[64]=u,e[65]=H):H=e[65],H}function kr(t){t(null)}function fn(t){const e=z.c(18),{gateway:a,onGatewayChange:s,children:r,className:n,disabled:i}=t,o=i===void 0?!1:i;let c;if(e[0]!==n||e[1]!==a){const b=a?la(a.id):null;c=J("relative rounded-xl w-full flex flex-col p-0.5",a&&"shadow-sm rounded-xl",b?.bg,n),e[0]=n,e[1]=a,e[2]=c}else c=e[2];let l;e[3]!==o||e[4]!==a||e[5]!==s?(l=a&&p.jsx(Pr,{gateway:a,onGatewayChange:s,onReset:()=>kr(s),disabled:o}),e[3]=o,e[4]=a,e[5]=s,e[6]=l):l=e[6];let d;e[7]!==l?(d=p.jsx("div",{className:"min-h-[32px]",children:l}),e[7]=l,e[8]=d):d=e[8];const m=!a&&"shadow-sm rounded-xl";let h;e[9]!==m?(h=J("bg-background rounded-xl",m),e[9]=m,e[10]=h):h=e[10];let f;e[11]!==r||e[12]!==h?(f=p.jsx("div",{className:h,children:r}),e[11]=r,e[12]=h,e[13]=f):f=e[13];let v;return e[14]!==c||e[15]!==d||e[16]!==f?(v=p.jsxs("div",{className:c,children:[d,f]}),e[14]=c,e[15]=d,e[16]=f,e[17]=v):v=e[17],v}async function Dr(t){const e=`/mcp/gateway/${t}`,a={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const s=await fetch(e,{method:"POST",headers:a,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-chat",version:"1.0.0"}}})});if(!s.ok)return[];if((await s.json()).error)return[];const n=await fetch(e,{method:"POST",headers:a,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!n.ok)return[];const i=await n.json();return i.error?[]:i.result?.prompts||[]}catch{return[]}}function $r(t){const e=z.c(7);let a;e[0]!==t?(a=Mt.gatewayPrompts(t),e[0]=t,e[1]=a):a=e[1];let s;e[2]!==t?(s=()=>Dr(t),e[2]=t,e[3]=s):s=e[3];let r;return e[4]!==a||e[5]!==s?(r={queryKey:a,queryFn:s,staleTime:6e4,retry:!1},e[4]=a,e[5]=s,e[6]=r):r=e[6],xa(r)}const At=3;function Zr(t){const e=z.c(6),{children:a,className:s}=t;let r;e[0]!==s?(r=J("flex flex-wrap items-center justify-center gap-2",s),e[0]=s,e[1]=r):r=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={minHeight:"32px"},e[2]=n):n=e[2];let i;return e[3]!==a||e[4]!==r?(i=p.jsx("div",{className:r,style:n,children:a}),e[3]=a,e[4]=r,e[5]=i):i=e[5],i}function Lr(t){const e=z.c(14),{prompt:a,onSelect:s}=t,r=a.description??a.name;let n;e[0]!==s||e[1]!==a?(n=()=>s(a),e[0]=s,e[1]=a,e[2]=n):n=e[2];const i=a.title??a.name;let o;if(e[3]!==i){let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=/_/g,e[5]=m):m=e[5],o=i.replace(m," "),e[3]=i,e[4]=o}else o=e[4];let c;e[6]!==n||e[7]!==o?(c=p.jsx(Xe,{asChild:!0,children:p.jsx("button",{type:"button",onClick:n,className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:o})}),e[6]=n,e[7]=o,e[8]=c):c=e[8];let l;e[9]!==r?(l=p.jsx(Ke,{side:"bottom",className:"max-w-xs",children:p.jsx("p",{className:"text-xs",children:r})}),e[9]=r,e[10]=l):l=e[10];let d;return e[11]!==c||e[12]!==l?(d=p.jsxs(Qe,{children:[c,l]}),e[11]=c,e[12]=l,e[13]=d):d=e[13],d}function Ur(t){const e=z.c(20),{prompts:a,onSelect:s,className:r}=t;if(a.length===0)return null;let n,i,o,c,l;if(e[0]!==r||e[1]!==s||e[2]!==a){const h=a.slice(0,At),f=a.slice(At),v=f.length>0;n=Dt,l=300,e[8]!==r?(i=J("flex flex-wrap items-center justify-center gap-2",r),e[8]=r,e[9]=i):i=e[9];let b;e[10]!==s?(b=y=>p.jsx(Lr,{prompt:y,onSelect:s},y.name),e[10]=s,e[11]=b):b=e[11],o=h.map(b),c=v&&p.jsxs(at,{children:[p.jsx(tt,{asChild:!0,children:p.jsxs("button",{type:"button",className:"size-7 flex items-center justify-center text-xs text-muted-foreground hover:text-foreground border border-border rounded-full hover:bg-accent/50 transition-colors cursor-pointer",children:["+",f.length]})}),p.jsx(et,{side:"bottom",align:"center",className:"w-auto p-2",children:p.jsx("div",{className:"flex flex-col gap-1",children:f.map(y=>{const x=y.description??y.name;return p.jsxs(Qe,{children:[p.jsx(Xe,{asChild:!0,children:p.jsx("button",{type:"button",onClick:()=>s(y),className:"px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors cursor-pointer text-left",children:(y.title??y.name).replace(/_/g," ")})}),p.jsx(Ke,{side:"right",className:"max-w-xs",children:p.jsx("p",{className:"text-xs",children:x})})]},y.name)})})})]}),e[0]=r,e[1]=s,e[2]=a,e[3]=n,e[4]=i,e[5]=o,e[6]=c,e[7]=l}else n=e[3],i=e[4],o=e[5],c=e[6],l=e[7];let d;e[12]!==i||e[13]!==o||e[14]!==c?(d=p.jsxs("div",{className:i,children:[o,c]}),e[12]=i,e[13]=o,e[14]=c,e[15]=d):d=e[15];let m;return e[16]!==n||e[17]!==l||e[18]!==d?(m=p.jsx(n,{delayDuration:l,children:d}),e[16]=n,e[17]=l,e[18]=d,e[19]=m):m=e[19],m}function Br(t){const e=z.c(6),{className:a}=t;let s;e[0]!==a?(s=J("flex flex-wrap items-center justify-center gap-2",a),e[0]=a,e[1]=s):s=e[1];let r,n;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(lt,{className:"h-6 w-20 rounded-full border border-border"}),n=p.jsx(lt,{className:"h-6 w-24 rounded-full border border-border"}),e[2]=r,e[3]=n):(r=e[2],n=e[3]);let i;return e[4]!==s?(i=p.jsxs("div",{className:s,children:[r,n]}),e[4]=s,e[5]=i):i=e[5],i}function ca(t){const e=z.c(4),{gatewayId:a,onSelect:s,className:r}=t,{data:n}=$r(a);if(n.length===0)return null;let i;return e[0]!==r||e[1]!==s||e[2]!==n?(i=p.jsx(Ur,{prompts:n,onSelect:s,className:r}),e[0]=r,e[1]=s,e[2]=n,e[3]=i):i=e[3],i}ca.Fallback=Br;ca.Container=Zr;function hn({title:t="No model provider connected",description:e="Connect to a model provider to unlock AI-powered features.",orgSlug:a,orgId:s,userId:r,allConnections:n,onInstallMcpServer:i}){const[o,c]=B.useState(!1),l=ka(),d=kt(),m=async()=>{if(!s||!r){ze.error("Not authenticated");return}c(!0);try{const h=n?.find(b=>b.connection_url===$a);if(h){d({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:h.id}});return}const f=Za({id:La("conn")}),v=await l.create.mutateAsync(f);d({to:"/$org/mcps/$connectionId",params:{org:a,connectionId:v.id}})}catch(h){ze.error(`Failed to connect OpenRouter: ${h instanceof Error?h.message:String(h)}`)}finally{c(!1)}};return p.jsx(Aa,{image:p.jsx("img",{src:"/empty-state-openrouter.svg",alt:"",width:336,height:320,"aria-hidden":"true",className:"w-xs h-auto mask-radial-[100%_100%] mask-radial-from-20% mask-radial-to-50% mask-radial-at-center"}),title:t,description:e,actions:p.jsxs(p.Fragment,{children:[p.jsxs(Pe,{variant:"outline",onClick:m,disabled:o,children:[p.jsx("img",{src:Da,alt:"OpenRouter",className:"size-4"}),o?"Installing...":"Install OpenRouter"]}),p.jsx(Pe,{variant:"outline",onClick:i,children:"Install Connection"})]})})}function zr(t){const e=new Date(t),s=new Date().getTime()-e.getTime(),r=Math.floor(s/6e4),n=Math.floor(s/36e5);return r<1?"now":r<60?`${r}m`:`${n}h`}function Fr(t){const e=new Date,a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),s=new Date(a.getTime()-864e5),r=new Date(a.getTime()-7*864e5),n=new Date(a.getTime()-30*864e5),i=[],o=[],c=[],l=[],d=[];for(const h of t){const f=new Date(h.updated_at);f>=a?i.push(h):f>=s?o.push(h):f>=r?c.push(h):f>=n?l.push(h):d.push(h)}const m=[];return i.length>0&&m.push({label:"Today",threads:i,showRelativeTime:!0}),o.length>0&&m.push({label:"Yesterday",threads:o,showRelativeTime:!1}),c.length>0&&m.push({label:"7 days ago",threads:c,showRelativeTime:!1}),l.length>0&&m.push({label:"30 days ago",threads:l,showRelativeTime:!1}),d.length>0&&m.push({label:"Older",threads:d,showRelativeTime:!1}),m}function gn(t){const e=z.c(49),{threads:a,activeThreadId:s,onSelectThread:r,onRemoveThread:n,onOpen:i,variant:o}=t,c=o===void 0?"icon":o,[l,d]=B.useState("");let m,h,f,v,b,y,x,N,u,T,S,w;if(e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==l||e[5]!==a||e[6]!==c){const C=l.trim()?a.filter(k=>(k.title||"New chat").toLowerCase().includes(l.toLowerCase())):a,te=Fr(C);let F;e[19]!==i?(F=k=>{k?i?.():d("")},e[19]=i,e[20]=F):F=e[20];const ae=F;v=Dt,f=Qe,h=at,T=ae,e[21]!==c?(S=p.jsx(Xe,{asChild:!0,children:p.jsx(tt,{asChild:!0,children:c==="outline"?p.jsx(Pe,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input","aria-label":"Chat history",children:p.jsx(it,{size:16})}):p.jsx(Pe,{type:"button",variant:"ghost",size:"icon",className:"size-6 p-1 hover:bg-transparent","aria-label":"Chat history",children:p.jsx(it,{size:16,className:"text-muted-foreground hover:text-foreground transition-colors"})})})}),e[21]=c,e[22]=S):S=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(w=p.jsx(Ke,{children:"Chat history"}),e[23]=w):w=e[23],m=et,x="end",N="w-80 p-0";let G;e[24]===Symbol.for("react.memo_cache_sentinel")?(G=p.jsx(Ua,{size:16,className:"text-muted-foreground shrink-0"}),e[24]=G):G=e[24];let se;e[25]===Symbol.for("react.memo_cache_sentinel")?(se=k=>d(k.target.value),e[25]=se):se=e[25],e[26]!==l?(u=p.jsx("div",{className:"border-b",children:p.jsxs("label",{className:"flex items-center gap-2.5 h-12 px-4 cursor-text",children:[G,p.jsx("input",{type:"text",placeholder:"Search chats...",value:l,onChange:se,className:"flex-1 border-0 shadow-none focus:outline-none px-0 h-full text-sm placeholder:text-muted-foreground/50 bg-transparent"})]})}),e[26]=l,e[27]=u):u=e[27],b="max-h-[300px] overflow-y-auto",y=C.length===0?p.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:l.trim()?"No chats found":"No chats yet"}):te.map((k,X)=>p.jsxs("div",{children:[X>0&&p.jsx("div",{className:"border-t mx-3"}),p.jsx("div",{className:"px-3 py-1",children:p.jsx("span",{className:"text-xs font-medium text-muted-foreground tracking-wide",children:k.label})}),k.threads.map(Z=>{const L=Z.id===s;return p.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 hover:bg-accent cursor-pointer group ${L?"bg-accent/50":""}`,onClick:()=>r(Z.id),children:[p.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[p.jsx("span",{className:"text-sm truncate",children:Z.title||"New chat"}),p.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:L?"current":k.showRelativeTime?zr(Z.updated_at):null})]}),p.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),n(Z.id)},className:"opacity-0 cursor-pointer group/trash group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",title:"Remove chat",children:p.jsx(Ba,{size:14,className:"text-muted-foreground group-hover/trash:text-destructive"})})]},Z.id)})]},k.label)),e[0]=s,e[1]=i,e[2]=n,e[3]=r,e[4]=l,e[5]=a,e[6]=c,e[7]=m,e[8]=h,e[9]=f,e[10]=v,e[11]=b,e[12]=y,e[13]=x,e[14]=N,e[15]=u,e[16]=T,e[17]=S,e[18]=w}else m=e[7],h=e[8],f=e[9],v=e[10],b=e[11],y=e[12],x=e[13],N=e[14],u=e[15],T=e[16],S=e[17],w=e[18];let I;e[28]!==b||e[29]!==y?(I=p.jsx("div",{className:b,children:y}),e[28]=b,e[29]=y,e[30]=I):I=e[30];let j;e[31]!==m||e[32]!==I||e[33]!==x||e[34]!==N||e[35]!==u?(j=p.jsxs(m,{align:x,className:N,children:[u,I]}),e[31]=m,e[32]=I,e[33]=x,e[34]=N,e[35]=u,e[36]=j):j=e[36];let $;e[37]!==h||e[38]!==j||e[39]!==T||e[40]!==S||e[41]!==w?($=p.jsxs(h,{onOpenChange:T,children:[S,w,j]}),e[37]=h,e[38]=j,e[39]=T,e[40]=S,e[41]=w,e[42]=$):$=e[42];let D;e[43]!==f||e[44]!==$?(D=p.jsx(f,{children:$}),e[43]=f,e[44]=$,e[45]=D):D=e[45];let U;return e[46]!==v||e[47]!==D?(U=p.jsx(v,{children:D}),e[46]=v,e[47]=D,e[48]=U):U=e[48],U}export{cn as D,ca as G,hn as N,lt as S,gn as T,mn as a,un as b,dn as c,fn as d,pn as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as v,c as z,j as t}from"./index-DMNk-OUX.js";import{I as F}from"./empty-state-DzS1Zp7m.js";import{C as I}from"./checkbox-2xIaHvS4.js";import{c as T,B as R}from"./input-68J17rBp.js";import{i as A}from"./ArrowLeft-BrsZ2N_5.js";import{u as U}from"./use-connection-DoWszS3j.js";import{C as V}from"./collection-search-CYZk6T6Z.js";const q=v.memo(function(S){const e=z.c(21),{connection:o,isSelected:m,hasToolsEnabled:r,activeToolsCount:h,totalToolsCount:p,onSelect:g,onToggle:x}=S,u=m?"bg-accent/50":"hover:bg-muted/50";let i;e[0]!==u?(i=T("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",u),e[0]=u,e[1]=i):i=e[1];let c;e[2]!==o.icon||e[3]!==o.title?(c=t.jsx(F,{icon:o.icon,name:o.title,size:"xs"}),e[2]=o.icon,e[3]=o.title,e[4]=c):c=e[4];let f;e[5]!==o.title?(f=t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o.title})}),e[5]=o.title,e[6]=f):f=e[6];let n;e[7]!==g||e[8]!==c||e[9]!==f?(n=t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:g,children:[c,f]}),e[7]=g,e[8]=c,e[9]=f,e[10]=n):n=e[10];let a;e[11]!==h||e[12]!==o.tools||e[13]!==r||e[14]!==x||e[15]!==p?(a=o.tools&&o.tools.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[h,"/",p]}),t.jsx(I,{checked:r,onCheckedChange:x,onClick:H})]}),e[11]=h,e[12]=o.tools,e[13]=r,e[14]=x,e[15]=p,e[16]=a):a=e[16];let N;return e[17]!==i||e[18]!==n||e[19]!==a?(N=t.jsxs("div",{className:i,children:[n,a]}),e[17]=i,e[18]=n,e[19]=a,e[20]=N):N=e[20],N}),G=v.memo(function(S){const e=z.c(18),{connectionId:o,tool:m,isSelected:r,onToggle:h}=S,p=`tool-${o}-${m.name}`,g=r?"text-foreground":"text-muted-foreground";let x;e[0]!==g?(x=T("text-sm font-medium",g),e[0]=g,e[1]=x):x=e[1];let u;e[2]!==x||e[3]!==m.name?(u=t.jsx("div",{className:"flex items-center gap-2 mb-1",children:t.jsx("span",{className:x,children:m.name})}),e[2]=x,e[3]=m.name,e[4]=u):u=e[4];let i;e[5]!==m.description?(i=m.description&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:m.description}),e[5]=m.description,e[6]=i):i=e[6];let c;e[7]!==u||e[8]!==i?(c=t.jsxs("div",{className:"flex-1 min-w-0",children:[u,i]}),e[7]=u,e[8]=i,e[9]=c):c=e[9];const f=`tool-${o}-${m.name}`;let n;e[10]!==r||e[11]!==h||e[12]!==f?(n=t.jsx("div",{className:"flex items-center shrink-0",children:t.jsx(I,{id:f,checked:r,onCheckedChange:h,onClick:J})}),e[10]=r,e[11]=h,e[12]=f,e[13]=n):n=e[13];let a;return e[14]!==p||e[15]!==c||e[16]!==n?(a=t.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:p,children:[c,n]}),e[14]=p,e[15]=c,e[16]=n,e[17]=a):a=e[17],a});function ee({toolSet:d,onToolSetChange:S}){const[e,o]=v.useState(""),m=v.useDeferredValue(e),[r,h]=v.useState("all"),[p,g]=v.useState(!1),x=v.useRef(new Set(Object.keys(d))),u=U({searchTerm:m.trim()||void 0}),i=x.current,c=[...i.values()].map(s=>u.find(l=>l.id===s)).filter(s=>s!==void 0),f=u.filter(s=>!i.has(s.id)),n=[...c,...f],a=s=>{const l=d[s];return l!==void 0&&l.length>0},N=n.filter(s=>{if(r==="all")return!0;const l=a(s.id);return r==="selected"?l:r==="unselected"?!l:!0}),[M,$]=v.useState(n[0]?.id??null),b=M?n.find(s=>s.id===M)??null:null,E=b?.tools??[],B=(s,l)=>d[s]?.includes(l)??!1,D=(s,l)=>{const j=d[s]??[],k=j.includes(l),w={...d};if(k){const y=j.filter(C=>C!==l);y.length===0?delete w[s]:w[s]=y}else w[s]=[...j,l];S(w)},O=s=>{const l=n.find(C=>C.id===s);if(!l?.tools)return;const j=d[s]??[],k=l.tools.map(C=>C.name),w=j.length>0&&k.every(C=>j.includes(C)),y={...d};w?delete y[s]:(y[s]=k,$(s)),S(y)},P=s=>{$(s),g(!0)},Q=()=>{g(!1)};return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:T("w-full md:w-80 border-r border-border flex flex-col",p&&"hidden md:flex"),children:[t.jsx(V,{value:e,onChange:o,placeholder:"Search MCP Servers..."}),t.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[t.jsx("button",{onClick:()=>h("all"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),t.jsx("button",{onClick:()=>h("selected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),t.jsx("button",{onClick:()=>h("unselected"),className:T("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",r==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:N.length===0?t.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:e?"No connections found":r==="selected"?"No servers selected":r==="unselected"?"No unselected servers":"No connections available"}):t.jsx("div",{className:"p-2 space-y-1",children:N.map(s=>{const l=s.tools?.length??0,j=d[s.id]?.length??0;return t.jsx(q,{connection:s,isSelected:M===s.id,hasToolsEnabled:a(s.id),activeToolsCount:j,totalToolsCount:l,onSelect:()=>P(s.id),onToggle:()=>O(s.id)},s.id)})})})]}),t.jsx("div",{className:T("flex-1 flex-col",p?"flex":"hidden md:flex"),children:b?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[t.jsx(R,{variant:"ghost",size:"sm",onClick:Q,className:"h-8 w-8 p-0 shrink-0",children:t.jsx(A,{size:20})}),t.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[t.jsx(F,{icon:b.icon,name:b.title,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:b.title}),b.description&&t.jsx("p",{className:"text-sm text-muted-foreground truncate",children:b.description})]})]})]}),t.jsx("div",{className:"flex-1 overflow-auto p-4",children:E.length===0?t.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):t.jsx("div",{className:"space-y-2",children:E.map(s=>t.jsx(G,{connectionId:b.id,tool:s,isSelected:B(b.id,s.name),onToggle:()=>D(b.id,s.name)},s.name))})})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function H(d){return d.stopPropagation()}function J(d){return d.stopPropagation()}export{ee as T};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{K as B,j as t,c as O,f as Q,r as k}from"./index-DMNk-OUX.js";import{b as U}from"./use-connection-DoWszS3j.js";import{i as W}from"./File06-D0TXCuMx.js";import{i as Y}from"./Loading01-NW_f44Lz.js";import{e as J}from"./github-icon-Dp3wHhYE.js";import{C as P}from"./collection-display-button-BGIcja12.js";import{C as X}from"./collection-search-CYZk6T6Z.js";import{C as Z}from"./collection-table-wrapper-D2niE2Ci.js";import{E as z,I as ee}from"./empty-state-DzS1Zp7m.js";import{C as te}from"./card-B3fsloDi.js";import{V as se}from"./layout-Olb4shdE.js";function oe(s){return s.replace(/<a[^>]*class="[^"]*anchor[^"]*"[^>]*>.*?<\/a>/gi,"")}function re(s){return s.replace(/<a\s+([^>]*href="[^"]*"[^>]*)>/gi,(e,i)=>i.includes("target=")?e.replace(/target="[^"]*"/gi,'target="_blank"'):`<a ${i} target="_blank" rel="noopener noreferrer">`)}function ne(s){let e=oe(s);return e=re(e),e}function we({repository:s}){const e=s?J(s):null,{data:i,isLoading:c}=U({queryKey:B.githubReadme(e?.owner,e?.repo),queryFn:async()=>{if(!e)return null;try{const l=await fetch(`https://api.github.com/repos/${e.owner}/${e.repo}/readme`,{headers:{Accept:"application/vnd.github.v3.html"}});if(!l.ok){if(l.status===404)return null;throw new Error(`Failed to fetch README: ${l.statusText}`)}const m=await l.text();return ne(m)}catch(l){return console.error("Error fetching README:",l),null}},enabled:!!e&&!!s,staleTime:3600*1e3,gcTime:1440*60*1e3});return c?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Y,{size:32,className:"animate-spin text-muted-foreground"})}):i?t.jsx("div",{className:"p-5 markdown-body",style:{backgroundColor:"transparent"},dangerouslySetInnerHTML:{__html:i}}):t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-6",children:[t.jsx(W,{size:48,className:"text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"README not found"}),t.jsx("p",{className:"text-muted-foreground max-w-md",children:"This repository doesn't have a README file, or it's not publicly accessible."})]})}function ve(s){const e=O.c(39),{tools:i,connectionId:c,org:l,onToolClick:m,showToolbar:L,emptyMessage:M}=s,D=L===void 0?!0:L,j=M===void 0?"This connection doesn't have any tools yet.":M,I=Q(),[n,$]=k.useState(""),[d,H]=k.useState("table"),[r,A]=k.useState("name"),[a,_]=k.useState("asc");let y;e[0]!==a||e[1]!==r?(y=o=>{r===o?(_(me),a==="desc"&&A(void 0)):(A(o),_("asc"))},e[0]=a,e[1]=r,e[2]=y):y=e[2];const u=y;let N;e[3]!==c||e[4]!==I||e[5]!==m||e[6]!==l?(N=o=>{m?m(o):c&&l&&I({to:"/$org/mcps/$connectionId/$collectionName/$itemId",params:{org:l,connectionId:c,collectionName:"tools",itemId:encodeURIComponent(o.name)}})},e[3]=c,e[4]=I,e[5]=m,e[6]=l,e[7]=N):N=e[7];const w=N;let v;if(e[8]!==n||e[9]!==a||e[10]!==r||e[11]!==i){const o=!i||i.length===0?[]:n.trim()?(()=>{const R=n.toLowerCase();return i.filter(b=>b.name.toLowerCase().includes(R)||b.description&&b.description.toLowerCase().includes(R))})():i;v=!r||!a?o:[...o].sort((R,b)=>{const q=R[r]||"",G=b[r]||"",K=String(q).localeCompare(String(G));return a==="asc"?K:-K}),e[8]=n,e[9]=a,e[10]=r,e[11]=i,e[12]=v}else v=e[12];const g=v;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=[{id:"name",header:"Name",render:ce,sortable:!0},{id:"description",header:"Description",render:le,cellClassName:"flex-1",sortable:!0}],e[13]=C):C=e[13];const V=C;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=V.filter(ie).map(ae),e[14]=S):S=e[14];const F=S;let f;e[15]!==u||e[16]!==D||e[17]!==a||e[18]!==r||e[19]!==d?(f=D&&t.jsx(se,{children:t.jsx(P,{viewMode:d,onViewModeChange:H,sortKey:r,sortDirection:a,onSort:u,sortOptions:F})}),e[15]=u,e[16]=D,e[17]=a,e[18]=r,e[19]=d,e[20]=f):f=e[20];let E;e[21]===Symbol.for("react.memo_cache_sentinel")?(E=o=>{o.key==="Escape"&&($(""),o.target.blur())},e[21]=E):E=e[21];let p;e[22]!==n?(p=t.jsx(X,{value:n,onChange:$,placeholder:"Search tools...",onKeyDown:E}),e[22]=n,e[23]=p):p=e[23];let h;e[24]!==j||e[25]!==u||e[26]!==w||e[27]!==n||e[28]!==a||e[29]!==r||e[30]!==g||e[31]!==d?(h=d==="cards"?t.jsx("div",{className:"flex-1 overflow-auto p-5",children:g.length===0?t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j}):t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:g.map(o=>t.jsx(te,{className:"cursor-pointer transition-colors",onClick:()=>w(o),children:t.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[t.jsx(ee,{icon:null,name:o.name,size:"md",className:"shrink-0 shadow-sm"}),t.jsxs("div",{className:"flex flex-col gap-0",children:[t.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:o.name}),t.jsx("p",{className:"text-base text-muted-foreground line-clamp-2",children:o.description||"No description"})]})]})},o.name))})}):t.jsx(Z,{columns:V,data:g,isLoading:!1,sortKey:r,sortDirection:a,onSort:u,onRowClick:o=>w(o),emptyState:t.jsx(z,{image:null,title:n?"No tools found":"No tools available",description:n?"Try adjusting your search terms":j})}),e[24]=j,e[25]=u,e[26]=w,e[27]=n,e[28]=a,e[29]=r,e[30]=g,e[31]=d,e[32]=h):h=e[32];let x;e[33]!==p||e[34]!==h?(x=t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p,h]}),e[33]=p,e[34]=h,e[35]=x):x=e[35];let T;return e[36]!==x||e[37]!==f?(T=t.jsxs(t.Fragment,{children:[f,x]}),e[36]=x,e[37]=f,e[38]=T):T=e[38],T}function ae(s){return{id:s.id,label:typeof s.header=="string"?s.header:s.id}}function ie(s){return s.sortable}function le(s){return t.jsx("span",{className:"text-sm text-foreground",children:s.description||"—"})}function ce(s){return t.jsx("span",{className:"text-sm font-medium font-mono text-foreground",children:s.name})}function me(s){return s==="asc"?"desc":s==="desc"?null:"asc"}export{we as R,ve as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bi as oe,bj as rs,w as P,M as J,Q as fe,L as yr,V as B,I as sa,H as be,W as te,$ as Pe,bk as it,bl as na,v as A,bm as Jr,bn as ss,bo as aa,bp as Nn,bq as oa,br as ia,bs as ca,a0 as qn,J as Br,X as ye,U as we,bt as ua,bu as la}from"./index-D825aBGT.js";import{C as da,P as fa,a as ha,G as pa,M as G,E as Z,b as ma,L as ya,c as ga,i as ft,d as _a,e as Lr,f as va,R as Xe,g as ba,h as Ur,j as wa,k as Sa,l as $a,T as ns,m as Mn,n as Ea,o as Ta,p as ka,q as Pa,I as Ia,S as Oa,r as bt,s as Ra,t as Ca,u as Na,v as qa,w as Ma,x as ja,y as jn,z as Aa,A as Da,B as La,D as Ua,F as Ha,U as Ne,H as Je,J as lr,K as mt,N as Va}from"./auth-B4yoGafc.js";var Fa=class{apply(t,e){if(!e.type)return;const r=Array.isArray(e.type)?e.type:[e.type],s=new Set(r);if(s.has("string")||(t.string=!1),!s.has("number")&&!s.has("integer")&&(t.number=!1),s.has("boolean")||(t.boolean=!1),s.has("null")||(t.null=!1),s.has("array")||(t.array=!1),s.has("object")||(t.object=!1),s.has("integer")&&t.number!==!1){const a=t.number||J();a instanceof it&&(t.number=a.int())}}},xa=class{apply(t,e){if(e.const===void 0)return;const r=e.const;t.string=!1,t.number=!1,t.boolean=!1,t.null=!1,t.array=!1,t.object=!1,typeof r=="string"?t.string=te(r):typeof r=="number"?t.number=te(r):typeof r=="boolean"?t.boolean=te(r):r===null?t.null=yr():Array.isArray(r)?t.array=void 0:typeof r=="object"&&(t.object=void 0)}},za=class{apply(t,e){if(!e.enum)return;if(e.enum.length===0){e.type||(t.string=!1,t.number=!1,t.boolean=!1,t.null=!1,t.array=!1,t.object=!1);return}const r={string:e.enum.filter(s=>typeof s=="string"),number:e.enum.filter(s=>typeof s=="number"),boolean:e.enum.filter(s=>typeof s=="boolean"),null:e.enum.filter(s=>s===null),array:e.enum.filter(s=>Array.isArray(s)),object:e.enum.filter(s=>typeof s=="object"&&s!==null&&!Array.isArray(s))};t.string=this.createTypeSchema(r.string,"string"),t.number=this.createTypeSchema(r.number,"number"),t.boolean=this.createTypeSchema(r.boolean,"boolean"),t.null=r.null.length>0?yr():!1,t.array=r.array.length>0?void 0:!1,t.object=r.object.length>0?void 0:!1}createTypeSchema(t,e){if(t.length===0)return!1;if(t.length===1)return te(t[0]);if(e==="string")return Pe(t);if(e==="number"){const[r,s,...a]=t;return be([te(r),te(s),...a.map(n=>te(n))])}return e==="boolean"?be([te(!0),te(!1)]):!1}},Ka=class{apply(t,e){const r=e;if(r.type==="string"&&r.format==="binary"&&r.contentEncoding==="binary"){let s=na();r.minLength!==void 0&&(s=s.min(r.minLength)),r.maxLength!==void 0&&(s=s.max(r.maxLength)),r.contentMediaType!==void 0&&(s=s.mime(r.contentMediaType)),t.file=s,t.string=!1}}},Wa=class{apply(t,e){const r=e;e.type===void 0&&(r.minLength!==void 0||r.maxLength!==void 0||r.pattern!==void 0)&&t.string===void 0&&(t.string=P())}},Ga=class{apply(t,e){const r=e;if(r.minLength!==void 0&&t.string!==!1){const s=t.string||P();s instanceof Jr&&(t.string=s.refine(a=>Array.from(a).length>=r.minLength,{message:`String must be at least ${r.minLength} characters long`}))}}},Ja=class{apply(t,e){const r=e;if(r.maxLength!==void 0&&t.string!==!1){const s=t.string||P();s instanceof Jr&&(t.string=s.refine(a=>Array.from(a).length<=r.maxLength,{message:`String must be at most ${r.maxLength} characters long`}))}}},Ba=class{apply(t,e){const r=e;if(r.pattern&&t.string!==!1){const s=t.string||P();if(s instanceof Jr){const a=new RegExp(r.pattern);t.string=s.regex(a)}}}},Qa=class{apply(t,e){const r=e;if(r.minimum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.min(r.minimum))}}},Za=class{apply(t,e){const r=e;if(r.maximum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.max(r.maximum))}}},Xa=class{apply(t,e){const r=e;if(r.exclusiveMinimum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(typeof r.exclusiveMinimum=="number"?t.number=s.gt(r.exclusiveMinimum):t.number=!1)}}},Ya=class{apply(t,e){const r=e;if(r.exclusiveMaximum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(typeof r.exclusiveMaximum=="number"?t.number=s.lt(r.exclusiveMaximum):t.number=!1)}}},eo=class{apply(t,e){const r=e;if(r.multipleOf!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.refine(a=>{if(r.multipleOf===0)return!1;const n=a/r.multipleOf,i=Math.round(n),o=Math.min(Math.abs(a)*Number.EPSILON*10,Math.abs(r.multipleOf)*Number.EPSILON*10);return Math.abs(n-i)<=o/Math.abs(r.multipleOf)},{message:`Must be a multiple of ${r.multipleOf}`}))}}},to=class{apply(t,e){const r=e;e.type===void 0&&(r.minItems!==void 0||r.maxItems!==void 0||r.items!==void 0||r.prefixItems!==void 0)&&t.array===void 0&&(t.array=B(oe()))}},ro=class{apply(t,e){const r=e;r.minItems!==void 0&&t.array!==!1&&(t.array=(t.array||B(oe())).min(r.minItems))}},so=class{apply(t,e){const r=e;r.maxItems!==void 0&&t.array!==!1&&(t.array=(t.array||B(oe())).max(r.maxItems))}},no=class{apply(t,e){const r=e;if(t.array!==!1)if(Array.isArray(r.items))t.array=t.array||B(oe());else if(r.items&&typeof r.items!="boolean"&&!r.prefixItems){const s=de(r.items);let a=B(s);if(t.array&&t.array instanceof aa){const n=t.array._def;n.checks&&n.checks.forEach(i=>{if(i._zod&&i._zod.def){const o=i._zod.def;o.check==="min_length"&&o.minimum!==void 0?a=a.min(o.minimum):o.check==="max_length"&&o.maximum!==void 0&&(a=a.max(o.maximum))}})}t.array=a}else typeof r.items=="boolean"&&r.items===!1?r.prefixItems?t.array=t.array||B(oe()):t.array=B(oe()).max(0):typeof r.items=="boolean"&&r.items===!0?t.array=t.array||B(oe()):r.prefixItems&&(t.array=t.array||B(oe()))}},ao=class{apply(t,e){if(e.type!=="array")return;const r=e;if(!Array.isArray(r.items)||t.array===!1)return;const s=r.items.map(n=>de(n));let a;s.length===0?a=ss([]):a=ss(s),r.minItems!==void 0&&r.minItems>s.length&&(a=!1),r.maxItems!==void 0&&r.maxItems<s.length&&(a=!1),t.tuple=a,t.array=!1}},oo=class{apply(t,e){const r=e;t.object!==!1&&(r.properties||r.required||r.additionalProperties!==void 0)&&(t.object=t.object||A({}).passthrough())}},io=class{apply(t,e){const r=e;e.type===void 0&&(r.maxProperties!==void 0||r.minProperties!==void 0)&&t.object===void 0&&(t.object=A({}).passthrough())}},co=class{apply(t,e){const r=e;if(r.maxProperties!==void 0&&t.object!==!1){const s=t.object||A({}).passthrough();t.object=s.refine(a=>Object.keys(a).length<=r.maxProperties,{message:`Object must have at most ${r.maxProperties} properties`})}}},uo=class{apply(t,e){const r=e;if(r.minProperties!==void 0&&t.object!==!1){const s=t.object||A({}).passthrough();t.object=s.refine(a=>Object.keys(a).length>=r.minProperties,{message:`Object must have at least ${r.minProperties} properties`})}}};function _t(t,e){if(t===e)return!0;if(t==null||e==null)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((r,s)=>_t(r,e[s]));if(typeof t=="object"&&typeof e=="object"){const r=Object.keys(t),s=Object.keys(e);return r.length!==s.length?!1:r.every(a=>s.includes(a)&&_t(t[a],e[a]))}return!1}function lo(){return t=>{if(!Array.isArray(t))return!0;const e=[];return t.every(r=>e.some(a=>_t(r,a))?!1:(e.push(r),!0))}}function dr(t,e){return t.safeParse(e).success}var fo=class{apply(t,e){if(!e.not)return t;const r=de(e.not);return t.refine(s=>!dr(r,s),{message:"Value must not match the 'not' schema"})}},ho=class{apply(t,e){return e.uniqueItems!==!0?t:t.refine(lo(),{message:"Array items must be unique"})}},po=class{apply(t,e){return!e.allOf||e.allOf.length===0?t:e.allOf.map(s=>de(s)).reduce((s,a)=>Nn(s,a),t)}},mo=class{apply(t,e){if(!e.anyOf||e.anyOf.length===0)return t;const r=e.anyOf.length===1?de(e.anyOf[0]):be([de(e.anyOf[0]),de(e.anyOf[1]),...e.anyOf.slice(2).map(s=>de(s))]);return Nn(t,r)}},yo=class{apply(t,e){if(!e.oneOf||e.oneOf.length===0)return t;const r=e.oneOf.map(s=>de(s));return t.refine(s=>{let a=0;for(const n of r)if(n.safeParse(s).success&&(a++,a>1))return!1;return a===1},{message:"Value must match exactly one of the oneOf schemas"})}},go=class{apply(t,e){const r=e;if(r.prefixItems&&Array.isArray(r.prefixItems)){const a=r.prefixItems.map(n=>de(n));return t.refine(n=>{if(!Array.isArray(n))return!0;for(let i=0;i<Math.min(n.length,a.length);i++)if(!dr(a[i],n[i]))return!1;if(n.length>a.length){if(typeof r.items=="boolean"&&r.items===!1)return!1;if(r.items&&typeof r.items=="object"&&!Array.isArray(r.items)){const i=de(r.items);for(let o=a.length;o<n.length;o++)if(!dr(i,n[o]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return t}},_o=class{apply(t,e){const r=e;if(!r.properties&&!r.required&&r.additionalProperties!==!1)return t;if(t instanceof oa||t instanceof ia){const s={};if(r.properties)for(const[a,n]of Object.entries(r.properties))n!==void 0&&(s[a]=de(n));if(r.required&&Array.isArray(r.required)){const a=new Set(r.required);for(const n of Object.keys(s))a.has(n)||(s[n]=s[n].optional())}else for(const a of Object.keys(s))s[a]=s[a].optional();return r.additionalProperties===!1?A(s):A(s).passthrough()}return t.refine(s=>{if(typeof s!="object"||s===null||Array.isArray(s))return!0;if(r.properties){for(const[a,n]of Object.entries(r.properties))if(n!==void 0&&Object.getOwnPropertyDescriptor(s,a)!==void 0&&!de(n).safeParse(s[a]).success)return!1}if(r.required&&Array.isArray(r.required)){for(const a of r.required)if(!(Object.getOwnPropertyDescriptor(s,a)!==void 0))return!1}if(r.additionalProperties===!1&&r.properties){const a=new Set(Object.keys(r.properties));for(const n in s)if(!a.has(n))return!1}return!0},{message:"Object constraints validation failed"})}},vo=class{apply(t,e){if(!e.enum||e.enum.length===0)return t;const r=e.enum.filter(s=>Array.isArray(s)||typeof s=="object"&&s!==null);return r.length===0?t:t.refine(s=>typeof s!="object"||s===null?!0:r.some(a=>_t(s,a)),{message:"Value must match one of the enum values"})}},bo=class{apply(t,e){if(e.const===void 0)return t;const r=e.const;return typeof r!="object"||r===null?t:t.refine(s=>_t(s,r),{message:"Value must equal the const value"})}},wo=class{apply(t,e){return e.description&&(t=t.describe(e.description)),t}},So=class{apply(t,e){var r;const s=e;return!((r=s.required)!=null&&r.includes("__proto__"))||e.type!==void 0?t:oe().refine(a=>this.validateRequired(a,s.required),{message:"Missing required properties"})}validateRequired(t,e){return typeof t!="object"||t===null||Array.isArray(t)?!0:e.every(r=>Object.prototype.hasOwnProperty.call(t,r))}},$o=class{apply(t,e){var r;const s=e;if(s.contains===void 0)return t;const a=de(s.contains),n=(r=s.minContains)!=null?r:1,i=s.maxContains;return t.refine(o=>{if(!Array.isArray(o))return!0;let u=0;for(const m of o)dr(a,m)&&u++;return!(u<n||i!==void 0&&u>i)},{message:"Array must contain required items matching the schema"})}},Eo=class{apply(t,e){const{default:r}=e;return r===void 0||!t.safeParse(r).success?t:t.default(r)}},To=[new xa,new za,new Fa,new Ka,new Wa,new to,new io,new Ga,new Ja,new Ba,new Qa,new Za,new Xa,new Ya,new eo,new ao,new ro,new so,new no,new co,new uo,new oo],ko=[new So,new vo,new bo,new po,new mo,new yo,new go,new _o,new $o,new fo,new ho,new Eo,new wo];function de(t){if(typeof t=="boolean")return t?oe():rs();const e={};for(const a of To)a.apply(e,t);const r=[];if(e.string!==!1&&r.push(e.string||P()),e.number!==!1&&r.push(e.number||J()),e.boolean!==!1&&r.push(e.boolean||fe()),e.null!==!1&&r.push(e.null||yr()),e.array!==!1&&r.push(e.array||B(oe())),e.tuple!==!1&&e.tuple!==void 0&&r.push(e.tuple),e.object!==!1)if(e.object)r.push(e.object);else{const a=sa(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),"Must be an object, not an array");r.push(a)}e.file!==!1&&e.file!==void 0&&r.push(e.file);let s;r.length===0?s=rs():r.length===1?s=r[0]:Object.keys(t).some(n=>n!=="$schema"&&n!=="title"&&n!=="description")?s=be(r):s=oe();for(const a of ko)s=a.apply(s,t);return s}function gr(t){return!!t._zod}function He(t,e){return gr(t)?ca(t,e):t.safeParse(e)}function An(t){if(!t)return;let e;if(gr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Po(t){if(gr(t)){const n=t._zod?.def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}}const r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const s=t.value;if(s!==void 0)return s}function xe(t){return t==="completed"||t==="failed"||t==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function as(t){const r=An(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const s=Po(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function os(t,e){const r=He(t,e);if(!r.success)throw r.error;return r.data}const Io=6e4;class Oo{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(da,r=>{this._oncancel(r)}),this.setNotificationHandler(fa,r=>{this._onprogress(r)}),this.setRequestHandler(ha,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(pa,async(r,s)=>{const a=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!a)throw new G(Z.InvalidParams,"Failed to retrieve task: Task not found");return{...a}}),this.setRequestHandler(ma,async(r,s)=>{const a=async()=>{const n=r.params.taskId;if(this._taskMessageQueue){let o;for(;o=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(o.type==="response"||o.type==="error"){const u=o.message,m=u.id,h=this._requestResolvers.get(m);if(h)if(this._requestResolvers.delete(m),o.type==="response")h(u);else{const $=u,g=new G($.error.code,$.error.message,$.error.data);h(g)}else{const $=o.type==="response"?"Response":"Error";this._onerror(new Error(`${$} handler missing for request ${m}`))}continue}await this._transport?.send(o.message,{relatedRequestId:s.requestId})}}const i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new G(Z.InvalidParams,`Task not found: ${n}`);if(!xe(i.status))return await this._waitForTaskUpdate(n,s.signal),await a();if(xe(i.status)){const o=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...o,_meta:{...o._meta,[Xe]:{taskId:n}}}}return await a()};return await a()}),this.setRequestHandler(ya,async(r,s)=>{try{const{tasks:a,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:a,nextCursor:n,_meta:{}}}catch(a){throw new G(Z.InvalidParams,`Failed to list tasks: ${a instanceof Error?a.message:String(a)}`)}}),this.setRequestHandler(ga,async(r,s)=>{try{const a=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!a)throw new G(Z.InvalidParams,`Task not found: ${r.params.taskId}`);if(xe(a.status))throw new G(Z.InvalidParams,`Cannot cancel task in terminal status: ${a.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);const n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new G(Z.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(a){throw a instanceof G?a:new G(Z.InvalidRequest,`Failed to cancel task: ${a instanceof Error?a.message:String(a)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,a,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(a,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:a})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),G.fromError(Z.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};const a=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{a?.(n,i),ft(n)||_a(n)?this._onresponse(n):Lr(n)?this._onrequest(n,i):va(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=G.fromError(Z.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){const r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,a=this._transport,n=e.params?._meta?.[Xe]?.taskId;if(s===void 0){const h={jsonrpc:"2.0",id:e.id,error:{code:Z.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:h,timestamp:Date.now()},a?.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):a?.send(h).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const o=ba(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,a?.sessionId):void 0,m={signal:i.signal,sessionId:a?.sessionId,_meta:e.params?._meta,sendNotification:async h=>{const $={relatedRequestId:e.id};n&&($.relatedTask={taskId:n}),await this.notification(h,$)},sendRequest:async(h,$,g)=>{const y={...g,relatedRequestId:e.id};n&&!y.relatedTask&&(y.relatedTask={taskId:n});const v=y.relatedTask?.taskId??n;return v&&u&&await u.updateTaskStatus(v,"input_required"),await this.request(h,$,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:u,taskRequestedTtl:o?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,m)).then(async h=>{if(i.signal.aborted)return;const $={result:h,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:$,timestamp:Date.now()},a?.sessionId):await a?.send($)},async h=>{if(i.signal.aborted)return;const $={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:Z.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:$,timestamp:Date.now()},a?.sessionId):await a?.send($)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...s}=e.params,a=Number(r),n=this._progressHandlers.get(a);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(a),o=this._timeoutInfo.get(a);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(a)}catch(u){this._responseHandlers.delete(a),this._progressHandlers.delete(a),this._cleanupTimeout(a),i(u);return}n(s)}_onresponse(e){const r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),ft(e))s(e);else{const i=new G(e.error.code,e.error.message,e.error.data);s(i)}return}const a=this._responseHandlers.get(r);if(a===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(ft(e)&&e.result&&typeof e.result=="object"){const i=e.result;if(i.task&&typeof i.task=="object"){const o=i.task;typeof o.taskId=="string"&&(n=!0,this._taskProgressTokens.set(o.taskId,r))}}if(n||this._progressHandlers.delete(r),ft(e))a(e);else{const i=G.fromError(e.error.code,e.error.message,e.error.data);a(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){const{task:a}=s??{};if(!a){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof G?i:new G(Z.InternalError,String(i))}}return}let n;try{const i=await this.request(e,Ur,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new G(Z.InternalError,"Task creation did not return a task");for(;;){const o=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:o},xe(o.status)){o.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:o.status==="failed"?yield{type:"error",error:new G(Z.InternalError,`Task ${n} failed`)}:o.status==="cancelled"&&(yield{type:"error",error:new G(Z.InternalError,`Task ${n} was cancelled`)});return}if(o.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}const u=o.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(m=>setTimeout(m,u)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof G?i:new G(Z.InternalError,String(i))}}}request(e,r,s){const{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i,task:o,relatedTask:u}=s??{};return new Promise((m,h)=>{const $=c=>{h(c)};if(!this._transport){$(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(c){$(c);return}s?.signal?.throwIfAborted();const g=this._requestMessageId++,y={...e,jsonrpc:"2.0",id:g};s?.onprogress&&(this._progressHandlers.set(g,s.onprogress),y.params={...e.params,_meta:{...e.params?._meta||{},progressToken:g}}),o&&(y.params={...y.params,task:o}),u&&(y.params={...y.params,_meta:{...y.params?._meta||{},[Xe]:u}});const v=c=>{this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(c)}},{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));const d=c instanceof G?c:new G(Z.RequestTimeout,String(c));h(d)};this._responseHandlers.set(g,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return h(c);try{const d=He(r,c.result);d.success?m(d.data):h(d.error)}catch(d){h(d)}}}),s?.signal?.addEventListener("abort",()=>{v(s?.signal?.reason)});const w=s?.timeout??Io,l=()=>v(G.fromError(Z.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(g,w,s?.maxTotalTimeout,l,s?.resetTimeoutOnProgress??!1);const p=u?.taskId;if(p){const c=d=>{const S=this._responseHandlers.get(g);S?S(d):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,c),this._enqueueTaskMessage(p,{type:"request",message:y,timestamp:Date.now()}).catch(d=>{this._cleanupTimeout(g),h(d)})}else this._transport.send(y,{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i}).catch(c=>{this._cleanupTimeout(g),h(c)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},wa,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Sa,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},$a,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=r?.relatedTask?.taskId;if(s){const o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Xe]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:o,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[Xe]:r.relatedTask}}}),this._transport?.send(o,r).catch(u=>this._onerror(u))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Xe]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const s=as(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(a,n)=>{const i=os(e,a);return Promise.resolve(r(i,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const s=as(e);this._notificationHandlers.set(s,a=>{const n=os(e,a);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const a=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,a)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,r);for(const a of s)if(a.type==="request"&&Lr(a.message)){const n=a.message.id,i=this._requestResolvers.get(n);i?(i(new G(Z.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{const a=await this._taskStore?.getTask(e);a?.pollInterval&&(s=a.pollInterval)}catch{}return new Promise((a,n)=>{if(r.aborted){n(new G(Z.InvalidRequest,"Request cancelled"));return}const i=setTimeout(a,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new G(Z.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async a=>{if(!e)throw new Error("No request provided");return await s.createTask(a,e.id,{method:e.method,params:e.params},r)},getTask:async a=>{const n=await s.getTask(a,r);if(!n)throw new G(Z.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(a,n,i)=>{await s.storeTaskResult(a,n,i,r);const o=await s.getTask(a,r);if(o){const u=ns.parse({method:"notifications/tasks/status",params:o});await this.notification(u),xe(o.status)&&this._cleanupTaskProgressHandler(a)}},getTaskResult:a=>s.getTaskResult(a,r),updateTaskStatus:async(a,n,i)=>{const o=await s.getTask(a,r);if(!o)throw new G(Z.InvalidParams,`Task "${a}" not found - it may have been cleaned up`);if(xe(o.status))throw new G(Z.InvalidParams,`Cannot update task "${a}" from terminal status "${o.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(a,n,i,r);const u=await s.getTask(a,r);if(u){const m=ns.parse({method:"notifications/tasks/status",params:u});await this.notification(m),xe(u.status)&&this._cleanupTaskProgressHandler(a)}},listTasks:a=>s.listTasks(a,r)}}}function is(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ro(t,e){const r={...t};for(const s in e){const a=s,n=e[a];if(n===void 0)continue;const i=r[a];is(i)&&is(n)?r[a]={...i,...n}:r[a]=n}return r}var wt={exports:{}},Tr={},Me={},ze={},kr={},Pr={},Ir={},cs;function fr(){return cs||(cs=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(c){if(super(),!t.IDENTIFIER.test(c))throw new Error("CodeGen: name must be a valid identifier");this.str=c}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class s extends e{constructor(c){super(),this._items=typeof c=="string"?[c]:c}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const c=this._items[0];return c===""||c==='""'}get str(){var c;return(c=this._str)!==null&&c!==void 0?c:this._str=this._items.reduce((d,S)=>`${d}${S}`,"")}get names(){var c;return(c=this._names)!==null&&c!==void 0?c:this._names=this._items.reduce((d,S)=>(S instanceof r&&(d[S.str]=(d[S.str]||0)+1),d),{})}}t._Code=s,t.nil=new s("");function a(p,...c){const d=[p[0]];let S=0;for(;S<c.length;)o(d,c[S]),d.push(p[++S]);return new s(d)}t._=a;const n=new s("+");function i(p,...c){const d=[y(p[0])];let S=0;for(;S<c.length;)d.push(n),o(d,c[S]),d.push(n,y(p[++S]));return u(d),new s(d)}t.str=i;function o(p,c){c instanceof s?p.push(...c._items):c instanceof r?p.push(c):p.push($(c))}t.addCodeArg=o;function u(p){let c=1;for(;c<p.length-1;){if(p[c]===n){const d=m(p[c-1],p[c+1]);if(d!==void 0){p.splice(c-1,3,d);continue}p[c++]="+"}c++}}function m(p,c){if(c==='""')return p;if(p==='""')return c;if(typeof p=="string")return c instanceof r||p[p.length-1]!=='"'?void 0:typeof c!="string"?`${p.slice(0,-1)}${c}"`:c[0]==='"'?p.slice(0,-1)+c.slice(1):void 0;if(typeof c=="string"&&c[0]==='"'&&!(p instanceof r))return`"${p}${c.slice(1)}`}function h(p,c){return c.emptyStr()?p:p.emptyStr()?c:i`${p}${c}`}t.strConcat=h;function $(p){return typeof p=="number"||typeof p=="boolean"||p===null?p:y(Array.isArray(p)?p.join(","):p)}function g(p){return new s(y(p))}t.stringify=g;function y(p){return JSON.stringify(p).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=y;function v(p){return typeof p=="string"&&t.IDENTIFIER.test(p)?new s(`.${p}`):a`[${p}]`}t.getProperty=v;function w(p){if(typeof p=="string"&&t.IDENTIFIER.test(p))return new s(`${p}`);throw new Error(`CodeGen: invalid export name: ${p}, use explicit $id name mapping`)}t.getEsmExportName=w;function l(p){return new s(p.toString())}t.regexpCode=l})(Ir)),Ir}var Or={},us;function ls(){return us||(us=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=fr();class r extends Error{constructor(m){super(`CodeGen: "code" for ${m} not defined`),this.value=m.value}}var s;(function(u){u[u.Started=0]="Started",u[u.Completed=1]="Completed"})(s||(t.UsedValueState=s={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class a{constructor({prefixes:m,parent:h}={}){this._names={},this._prefixes=m,this._parent=h}toName(m){return m instanceof e.Name?m:this.name(m)}name(m){return new e.Name(this._newName(m))}_newName(m){const h=this._names[m]||this._nameGroup(m);return`${m}${h.index++}`}_nameGroup(m){var h,$;if(!(($=(h=this._parent)===null||h===void 0?void 0:h._prefixes)===null||$===void 0)&&$.has(m)||this._prefixes&&!this._prefixes.has(m))throw new Error(`CodeGen: prefix "${m}" is not allowed in this scope`);return this._names[m]={prefix:m,index:0}}}t.Scope=a;class n extends e.Name{constructor(m,h){super(h),this.prefix=m}setValue(m,{property:h,itemIndex:$}){this.value=m,this.scopePath=(0,e._)`.${new e.Name(h)}[${$}]`}}t.ValueScopeName=n;const i=(0,e._)`\n`;class o extends a{constructor(m){super(m),this._values={},this._scope=m.scope,this.opts={...m,_n:m.lines?i:e.nil}}get(){return this._scope}name(m){return new n(m,this._newName(m))}value(m,h){var $;if(h.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const g=this.toName(m),{prefix:y}=g,v=($=h.key)!==null&&$!==void 0?$:h.ref;let w=this._values[y];if(w){const c=w.get(v);if(c)return c}else w=this._values[y]=new Map;w.set(v,g);const l=this._scope[y]||(this._scope[y]=[]),p=l.length;return l[p]=h.ref,g.setValue(h,{property:y,itemIndex:p}),g}getValue(m,h){const $=this._values[m];if($)return $.get(h)}scopeRefs(m,h=this._values){return this._reduceValues(h,$=>{if($.scopePath===void 0)throw new Error(`CodeGen: name "${$}" has no value`);return(0,e._)`${m}${$.scopePath}`})}scopeCode(m=this._values,h,$){return this._reduceValues(m,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},h,$)}_reduceValues(m,h,$={},g){let y=e.nil;for(const v in m){const w=m[v];if(!w)continue;const l=$[v]=$[v]||new Map;w.forEach(p=>{if(l.has(p))return;l.set(p,s.Started);let c=h(p);if(c){const d=this.opts.es5?t.varKinds.var:t.varKinds.const;y=(0,e._)`${y}${d} ${p} = ${c};${this.opts._n}`}else if(c=g?.(p))y=(0,e._)`${y}${c}${this.opts._n}`;else throw new r(p);l.set(p,s.Completed)})}return y}}t.ValueScope=o})(Or)),Or}var ds;function X(){return ds||(ds=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=fr(),r=ls();var s=fr();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return s.Name}});var a=ls();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return a.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return a.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return a.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return a.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class n{optimizeNodes(){return this}optimizeNames(_,T){return this}}class i extends n{constructor(_,T,N){super(),this.varKind=_,this.name=T,this.rhs=N}render({es5:_,_n:T}){const N=_?r.varKinds.var:this.varKind,z=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${z};`+T}optimizeNames(_,T){if(_[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,_,T)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends n{constructor(_,T,N){super(),this.lhs=_,this.rhs=T,this.sideEffects=N}render({_n:_}){return`${this.lhs} = ${this.rhs};`+_}optimizeNames(_,T){if(!(this.lhs instanceof e.Name&&!_[this.lhs.str]&&!this.sideEffects))return this.rhs=x(this.rhs,_,T),this}get names(){const _=this.lhs instanceof e.Name?{}:{...this.lhs.names};return F(_,this.rhs)}}class u extends o{constructor(_,T,N,z){super(_,N,z),this.op=T}render({_n:_}){return`${this.lhs} ${this.op}= ${this.rhs};`+_}}class m extends n{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`${this.label}:`+_}}class h extends n{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`break${this.label?` ${this.label}`:""};`+_}}class $ extends n{constructor(_){super(),this.error=_}render({_n:_}){return`throw ${this.error};`+_}get names(){return this.error.names}}class g extends n{constructor(_){super(),this.code=_}render({_n:_}){return`${this.code};`+_}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(_,T){return this.code=x(this.code,_,T),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class y extends n{constructor(_=[]){super(),this.nodes=_}render(_){return this.nodes.reduce((T,N)=>T+N.render(_),"")}optimizeNodes(){const{nodes:_}=this;let T=_.length;for(;T--;){const N=_[T].optimizeNodes();Array.isArray(N)?_.splice(T,1,...N):N?_[T]=N:_.splice(T,1)}return _.length>0?this:void 0}optimizeNames(_,T){const{nodes:N}=this;let z=N.length;for(;z--;){const W=N[z];W.optimizeNames(_,T)||(ae(_,W.names),N.splice(z,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((_,T)=>H(_,T.names),{})}}class v extends y{render(_){return"{"+_._n+super.render(_)+"}"+_._n}}class w extends y{}class l extends v{}l.kind="else";class p extends v{constructor(_,T){super(T),this.condition=_}render(_){let T=`if(${this.condition})`+super.render(_);return this.else&&(T+="else "+this.else.render(_)),T}optimizeNodes(){super.optimizeNodes();const _=this.condition;if(_===!0)return this.nodes;let T=this.else;if(T){const N=T.optimizeNodes();T=this.else=Array.isArray(N)?new l(N):N}if(T)return _===!1?T instanceof p?T:T.nodes:this.nodes.length?this:new p(ge(_),T instanceof p?[T]:T.nodes);if(!(_===!1||!this.nodes.length))return this}optimizeNames(_,T){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(_,T),!!(super.optimizeNames(_,T)||this.else))return this.condition=x(this.condition,_,T),this}get names(){const _=super.names;return F(_,this.condition),this.else&&H(_,this.else.names),_}}p.kind="if";class c extends v{}c.kind="for";class d extends c{constructor(_){super(),this.iteration=_}render(_){return`for(${this.iteration})`+super.render(_)}optimizeNames(_,T){if(super.optimizeNames(_,T))return this.iteration=x(this.iteration,_,T),this}get names(){return H(super.names,this.iteration.names)}}class S extends c{constructor(_,T,N,z){super(),this.varKind=_,this.name=T,this.from=N,this.to=z}render(_){const T=_.es5?r.varKinds.var:this.varKind,{name:N,from:z,to:W}=this;return`for(${T} ${N}=${z}; ${N}<${W}; ${N}++)`+super.render(_)}get names(){const _=F(super.names,this.from);return F(_,this.to)}}class f extends c{constructor(_,T,N,z){super(),this.loop=_,this.varKind=T,this.name=N,this.iterable=z}render(_){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(_)}optimizeNames(_,T){if(super.optimizeNames(_,T))return this.iterable=x(this.iterable,_,T),this}get names(){return H(super.names,this.iterable.names)}}class b extends v{constructor(_,T,N){super(),this.name=_,this.args=T,this.async=N}render(_){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(_)}}b.kind="func";class E extends y{render(_){return"return "+super.render(_)}}E.kind="return";class C extends v{render(_){let T="try"+super.render(_);return this.catch&&(T+=this.catch.render(_)),this.finally&&(T+=this.finally.render(_)),T}optimizeNodes(){var _,T;return super.optimizeNodes(),(_=this.catch)===null||_===void 0||_.optimizeNodes(),(T=this.finally)===null||T===void 0||T.optimizeNodes(),this}optimizeNames(_,T){var N,z;return super.optimizeNames(_,T),(N=this.catch)===null||N===void 0||N.optimizeNames(_,T),(z=this.finally)===null||z===void 0||z.optimizeNames(_,T),this}get names(){const _=super.names;return this.catch&&H(_,this.catch.names),this.finally&&H(_,this.finally.names),_}}class D extends v{constructor(_){super(),this.error=_}render(_){return`catch(${this.error})`+super.render(_)}}D.kind="catch";class V extends v{render(_){return"finally"+super.render(_)}}V.kind="finally";class q{constructor(_,T={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...T,_n:T.lines?`
|
|
1
|
+
import{bi as oe,bj as rs,w as P,M as J,Q as fe,L as yr,V as B,I as sa,H as be,W as te,$ as Pe,bk as it,bl as na,v as A,bm as Jr,bn as ss,bo as aa,bp as Nn,bq as oa,br as ia,bs as ca,a0 as qn,J as Br,X as ye,U as we,bt as ua,bu as la}from"./index-DMNk-OUX.js";import{C as da,P as fa,a as ha,G as pa,M as G,E as Z,b as ma,L as ya,c as ga,i as ft,d as _a,e as Lr,f as va,R as Xe,g as ba,h as Ur,j as wa,k as Sa,l as $a,T as ns,m as Mn,n as Ea,o as Ta,p as ka,q as Pa,I as Ia,S as Oa,r as bt,s as Ra,t as Ca,u as Na,v as qa,w as Ma,x as ja,y as jn,z as Aa,A as Da,B as La,D as Ua,F as Ha,U as Ne,H as Je,J as lr,K as mt,N as Va}from"./auth-C9dSkS_x.js";var Fa=class{apply(t,e){if(!e.type)return;const r=Array.isArray(e.type)?e.type:[e.type],s=new Set(r);if(s.has("string")||(t.string=!1),!s.has("number")&&!s.has("integer")&&(t.number=!1),s.has("boolean")||(t.boolean=!1),s.has("null")||(t.null=!1),s.has("array")||(t.array=!1),s.has("object")||(t.object=!1),s.has("integer")&&t.number!==!1){const a=t.number||J();a instanceof it&&(t.number=a.int())}}},xa=class{apply(t,e){if(e.const===void 0)return;const r=e.const;t.string=!1,t.number=!1,t.boolean=!1,t.null=!1,t.array=!1,t.object=!1,typeof r=="string"?t.string=te(r):typeof r=="number"?t.number=te(r):typeof r=="boolean"?t.boolean=te(r):r===null?t.null=yr():Array.isArray(r)?t.array=void 0:typeof r=="object"&&(t.object=void 0)}},za=class{apply(t,e){if(!e.enum)return;if(e.enum.length===0){e.type||(t.string=!1,t.number=!1,t.boolean=!1,t.null=!1,t.array=!1,t.object=!1);return}const r={string:e.enum.filter(s=>typeof s=="string"),number:e.enum.filter(s=>typeof s=="number"),boolean:e.enum.filter(s=>typeof s=="boolean"),null:e.enum.filter(s=>s===null),array:e.enum.filter(s=>Array.isArray(s)),object:e.enum.filter(s=>typeof s=="object"&&s!==null&&!Array.isArray(s))};t.string=this.createTypeSchema(r.string,"string"),t.number=this.createTypeSchema(r.number,"number"),t.boolean=this.createTypeSchema(r.boolean,"boolean"),t.null=r.null.length>0?yr():!1,t.array=r.array.length>0?void 0:!1,t.object=r.object.length>0?void 0:!1}createTypeSchema(t,e){if(t.length===0)return!1;if(t.length===1)return te(t[0]);if(e==="string")return Pe(t);if(e==="number"){const[r,s,...a]=t;return be([te(r),te(s),...a.map(n=>te(n))])}return e==="boolean"?be([te(!0),te(!1)]):!1}},Ka=class{apply(t,e){const r=e;if(r.type==="string"&&r.format==="binary"&&r.contentEncoding==="binary"){let s=na();r.minLength!==void 0&&(s=s.min(r.minLength)),r.maxLength!==void 0&&(s=s.max(r.maxLength)),r.contentMediaType!==void 0&&(s=s.mime(r.contentMediaType)),t.file=s,t.string=!1}}},Wa=class{apply(t,e){const r=e;e.type===void 0&&(r.minLength!==void 0||r.maxLength!==void 0||r.pattern!==void 0)&&t.string===void 0&&(t.string=P())}},Ga=class{apply(t,e){const r=e;if(r.minLength!==void 0&&t.string!==!1){const s=t.string||P();s instanceof Jr&&(t.string=s.refine(a=>Array.from(a).length>=r.minLength,{message:`String must be at least ${r.minLength} characters long`}))}}},Ja=class{apply(t,e){const r=e;if(r.maxLength!==void 0&&t.string!==!1){const s=t.string||P();s instanceof Jr&&(t.string=s.refine(a=>Array.from(a).length<=r.maxLength,{message:`String must be at most ${r.maxLength} characters long`}))}}},Ba=class{apply(t,e){const r=e;if(r.pattern&&t.string!==!1){const s=t.string||P();if(s instanceof Jr){const a=new RegExp(r.pattern);t.string=s.regex(a)}}}},Qa=class{apply(t,e){const r=e;if(r.minimum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.min(r.minimum))}}},Za=class{apply(t,e){const r=e;if(r.maximum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.max(r.maximum))}}},Xa=class{apply(t,e){const r=e;if(r.exclusiveMinimum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(typeof r.exclusiveMinimum=="number"?t.number=s.gt(r.exclusiveMinimum):t.number=!1)}}},Ya=class{apply(t,e){const r=e;if(r.exclusiveMaximum!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(typeof r.exclusiveMaximum=="number"?t.number=s.lt(r.exclusiveMaximum):t.number=!1)}}},eo=class{apply(t,e){const r=e;if(r.multipleOf!==void 0&&t.number!==!1){const s=t.number||J();s instanceof it&&(t.number=s.refine(a=>{if(r.multipleOf===0)return!1;const n=a/r.multipleOf,i=Math.round(n),o=Math.min(Math.abs(a)*Number.EPSILON*10,Math.abs(r.multipleOf)*Number.EPSILON*10);return Math.abs(n-i)<=o/Math.abs(r.multipleOf)},{message:`Must be a multiple of ${r.multipleOf}`}))}}},to=class{apply(t,e){const r=e;e.type===void 0&&(r.minItems!==void 0||r.maxItems!==void 0||r.items!==void 0||r.prefixItems!==void 0)&&t.array===void 0&&(t.array=B(oe()))}},ro=class{apply(t,e){const r=e;r.minItems!==void 0&&t.array!==!1&&(t.array=(t.array||B(oe())).min(r.minItems))}},so=class{apply(t,e){const r=e;r.maxItems!==void 0&&t.array!==!1&&(t.array=(t.array||B(oe())).max(r.maxItems))}},no=class{apply(t,e){const r=e;if(t.array!==!1)if(Array.isArray(r.items))t.array=t.array||B(oe());else if(r.items&&typeof r.items!="boolean"&&!r.prefixItems){const s=de(r.items);let a=B(s);if(t.array&&t.array instanceof aa){const n=t.array._def;n.checks&&n.checks.forEach(i=>{if(i._zod&&i._zod.def){const o=i._zod.def;o.check==="min_length"&&o.minimum!==void 0?a=a.min(o.minimum):o.check==="max_length"&&o.maximum!==void 0&&(a=a.max(o.maximum))}})}t.array=a}else typeof r.items=="boolean"&&r.items===!1?r.prefixItems?t.array=t.array||B(oe()):t.array=B(oe()).max(0):typeof r.items=="boolean"&&r.items===!0?t.array=t.array||B(oe()):r.prefixItems&&(t.array=t.array||B(oe()))}},ao=class{apply(t,e){if(e.type!=="array")return;const r=e;if(!Array.isArray(r.items)||t.array===!1)return;const s=r.items.map(n=>de(n));let a;s.length===0?a=ss([]):a=ss(s),r.minItems!==void 0&&r.minItems>s.length&&(a=!1),r.maxItems!==void 0&&r.maxItems<s.length&&(a=!1),t.tuple=a,t.array=!1}},oo=class{apply(t,e){const r=e;t.object!==!1&&(r.properties||r.required||r.additionalProperties!==void 0)&&(t.object=t.object||A({}).passthrough())}},io=class{apply(t,e){const r=e;e.type===void 0&&(r.maxProperties!==void 0||r.minProperties!==void 0)&&t.object===void 0&&(t.object=A({}).passthrough())}},co=class{apply(t,e){const r=e;if(r.maxProperties!==void 0&&t.object!==!1){const s=t.object||A({}).passthrough();t.object=s.refine(a=>Object.keys(a).length<=r.maxProperties,{message:`Object must have at most ${r.maxProperties} properties`})}}},uo=class{apply(t,e){const r=e;if(r.minProperties!==void 0&&t.object!==!1){const s=t.object||A({}).passthrough();t.object=s.refine(a=>Object.keys(a).length>=r.minProperties,{message:`Object must have at least ${r.minProperties} properties`})}}};function _t(t,e){if(t===e)return!0;if(t==null||e==null)return t===e;if(typeof t!=typeof e)return!1;if(Array.isArray(t)&&Array.isArray(e))return t.length!==e.length?!1:t.every((r,s)=>_t(r,e[s]));if(typeof t=="object"&&typeof e=="object"){const r=Object.keys(t),s=Object.keys(e);return r.length!==s.length?!1:r.every(a=>s.includes(a)&&_t(t[a],e[a]))}return!1}function lo(){return t=>{if(!Array.isArray(t))return!0;const e=[];return t.every(r=>e.some(a=>_t(r,a))?!1:(e.push(r),!0))}}function dr(t,e){return t.safeParse(e).success}var fo=class{apply(t,e){if(!e.not)return t;const r=de(e.not);return t.refine(s=>!dr(r,s),{message:"Value must not match the 'not' schema"})}},ho=class{apply(t,e){return e.uniqueItems!==!0?t:t.refine(lo(),{message:"Array items must be unique"})}},po=class{apply(t,e){return!e.allOf||e.allOf.length===0?t:e.allOf.map(s=>de(s)).reduce((s,a)=>Nn(s,a),t)}},mo=class{apply(t,e){if(!e.anyOf||e.anyOf.length===0)return t;const r=e.anyOf.length===1?de(e.anyOf[0]):be([de(e.anyOf[0]),de(e.anyOf[1]),...e.anyOf.slice(2).map(s=>de(s))]);return Nn(t,r)}},yo=class{apply(t,e){if(!e.oneOf||e.oneOf.length===0)return t;const r=e.oneOf.map(s=>de(s));return t.refine(s=>{let a=0;for(const n of r)if(n.safeParse(s).success&&(a++,a>1))return!1;return a===1},{message:"Value must match exactly one of the oneOf schemas"})}},go=class{apply(t,e){const r=e;if(r.prefixItems&&Array.isArray(r.prefixItems)){const a=r.prefixItems.map(n=>de(n));return t.refine(n=>{if(!Array.isArray(n))return!0;for(let i=0;i<Math.min(n.length,a.length);i++)if(!dr(a[i],n[i]))return!1;if(n.length>a.length){if(typeof r.items=="boolean"&&r.items===!1)return!1;if(r.items&&typeof r.items=="object"&&!Array.isArray(r.items)){const i=de(r.items);for(let o=a.length;o<n.length;o++)if(!dr(i,n[o]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return t}},_o=class{apply(t,e){const r=e;if(!r.properties&&!r.required&&r.additionalProperties!==!1)return t;if(t instanceof oa||t instanceof ia){const s={};if(r.properties)for(const[a,n]of Object.entries(r.properties))n!==void 0&&(s[a]=de(n));if(r.required&&Array.isArray(r.required)){const a=new Set(r.required);for(const n of Object.keys(s))a.has(n)||(s[n]=s[n].optional())}else for(const a of Object.keys(s))s[a]=s[a].optional();return r.additionalProperties===!1?A(s):A(s).passthrough()}return t.refine(s=>{if(typeof s!="object"||s===null||Array.isArray(s))return!0;if(r.properties){for(const[a,n]of Object.entries(r.properties))if(n!==void 0&&Object.getOwnPropertyDescriptor(s,a)!==void 0&&!de(n).safeParse(s[a]).success)return!1}if(r.required&&Array.isArray(r.required)){for(const a of r.required)if(!(Object.getOwnPropertyDescriptor(s,a)!==void 0))return!1}if(r.additionalProperties===!1&&r.properties){const a=new Set(Object.keys(r.properties));for(const n in s)if(!a.has(n))return!1}return!0},{message:"Object constraints validation failed"})}},vo=class{apply(t,e){if(!e.enum||e.enum.length===0)return t;const r=e.enum.filter(s=>Array.isArray(s)||typeof s=="object"&&s!==null);return r.length===0?t:t.refine(s=>typeof s!="object"||s===null?!0:r.some(a=>_t(s,a)),{message:"Value must match one of the enum values"})}},bo=class{apply(t,e){if(e.const===void 0)return t;const r=e.const;return typeof r!="object"||r===null?t:t.refine(s=>_t(s,r),{message:"Value must equal the const value"})}},wo=class{apply(t,e){return e.description&&(t=t.describe(e.description)),t}},So=class{apply(t,e){var r;const s=e;return!((r=s.required)!=null&&r.includes("__proto__"))||e.type!==void 0?t:oe().refine(a=>this.validateRequired(a,s.required),{message:"Missing required properties"})}validateRequired(t,e){return typeof t!="object"||t===null||Array.isArray(t)?!0:e.every(r=>Object.prototype.hasOwnProperty.call(t,r))}},$o=class{apply(t,e){var r;const s=e;if(s.contains===void 0)return t;const a=de(s.contains),n=(r=s.minContains)!=null?r:1,i=s.maxContains;return t.refine(o=>{if(!Array.isArray(o))return!0;let u=0;for(const m of o)dr(a,m)&&u++;return!(u<n||i!==void 0&&u>i)},{message:"Array must contain required items matching the schema"})}},Eo=class{apply(t,e){const{default:r}=e;return r===void 0||!t.safeParse(r).success?t:t.default(r)}},To=[new xa,new za,new Fa,new Ka,new Wa,new to,new io,new Ga,new Ja,new Ba,new Qa,new Za,new Xa,new Ya,new eo,new ao,new ro,new so,new no,new co,new uo,new oo],ko=[new So,new vo,new bo,new po,new mo,new yo,new go,new _o,new $o,new fo,new ho,new Eo,new wo];function de(t){if(typeof t=="boolean")return t?oe():rs();const e={};for(const a of To)a.apply(e,t);const r=[];if(e.string!==!1&&r.push(e.string||P()),e.number!==!1&&r.push(e.number||J()),e.boolean!==!1&&r.push(e.boolean||fe()),e.null!==!1&&r.push(e.null||yr()),e.array!==!1&&r.push(e.array||B(oe())),e.tuple!==!1&&e.tuple!==void 0&&r.push(e.tuple),e.object!==!1)if(e.object)r.push(e.object);else{const a=sa(n=>typeof n=="object"&&n!==null&&!Array.isArray(n),"Must be an object, not an array");r.push(a)}e.file!==!1&&e.file!==void 0&&r.push(e.file);let s;r.length===0?s=rs():r.length===1?s=r[0]:Object.keys(t).some(n=>n!=="$schema"&&n!=="title"&&n!=="description")?s=be(r):s=oe();for(const a of ko)s=a.apply(s,t);return s}function gr(t){return!!t._zod}function He(t,e){return gr(t)?ca(t,e):t.safeParse(e)}function An(t){if(!t)return;let e;if(gr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Po(t){if(gr(t)){const n=t._zod?.def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}}const r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const s=t.value;if(s!==void 0)return s}function xe(t){return t==="completed"||t==="failed"||t==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function as(t){const r=An(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const s=Po(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function os(t,e){const r=He(t,e);if(!r.success)throw r.error;return r.data}const Io=6e4;class Oo{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(da,r=>{this._oncancel(r)}),this.setNotificationHandler(fa,r=>{this._onprogress(r)}),this.setRequestHandler(ha,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(pa,async(r,s)=>{const a=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!a)throw new G(Z.InvalidParams,"Failed to retrieve task: Task not found");return{...a}}),this.setRequestHandler(ma,async(r,s)=>{const a=async()=>{const n=r.params.taskId;if(this._taskMessageQueue){let o;for(;o=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(o.type==="response"||o.type==="error"){const u=o.message,m=u.id,h=this._requestResolvers.get(m);if(h)if(this._requestResolvers.delete(m),o.type==="response")h(u);else{const $=u,g=new G($.error.code,$.error.message,$.error.data);h(g)}else{const $=o.type==="response"?"Response":"Error";this._onerror(new Error(`${$} handler missing for request ${m}`))}continue}await this._transport?.send(o.message,{relatedRequestId:s.requestId})}}const i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new G(Z.InvalidParams,`Task not found: ${n}`);if(!xe(i.status))return await this._waitForTaskUpdate(n,s.signal),await a();if(xe(i.status)){const o=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...o,_meta:{...o._meta,[Xe]:{taskId:n}}}}return await a()};return await a()}),this.setRequestHandler(ya,async(r,s)=>{try{const{tasks:a,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:a,nextCursor:n,_meta:{}}}catch(a){throw new G(Z.InvalidParams,`Failed to list tasks: ${a instanceof Error?a.message:String(a)}`)}}),this.setRequestHandler(ga,async(r,s)=>{try{const a=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!a)throw new G(Z.InvalidParams,`Task not found: ${r.params.taskId}`);if(xe(a.status))throw new G(Z.InvalidParams,`Cannot cancel task in terminal status: ${a.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);const n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new G(Z.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(a){throw a instanceof G?a:new G(Z.InvalidRequest,`Failed to cancel task: ${a instanceof Error?a.message:String(a)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,a,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(a,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:a})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),G.fromError(Z.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};const a=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{a?.(n,i),ft(n)||_a(n)?this._onresponse(n):Lr(n)?this._onrequest(n,i):va(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=G.fromError(Z.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){const r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,a=this._transport,n=e.params?._meta?.[Xe]?.taskId;if(s===void 0){const h={jsonrpc:"2.0",id:e.id,error:{code:Z.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:h,timestamp:Date.now()},a?.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):a?.send(h).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const o=ba(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,a?.sessionId):void 0,m={signal:i.signal,sessionId:a?.sessionId,_meta:e.params?._meta,sendNotification:async h=>{const $={relatedRequestId:e.id};n&&($.relatedTask={taskId:n}),await this.notification(h,$)},sendRequest:async(h,$,g)=>{const y={...g,relatedRequestId:e.id};n&&!y.relatedTask&&(y.relatedTask={taskId:n});const v=y.relatedTask?.taskId??n;return v&&u&&await u.updateTaskStatus(v,"input_required"),await this.request(h,$,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:u,taskRequestedTtl:o?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,m)).then(async h=>{if(i.signal.aborted)return;const $={result:h,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:$,timestamp:Date.now()},a?.sessionId):await a?.send($)},async h=>{if(i.signal.aborted)return;const $={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:Z.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:$,timestamp:Date.now()},a?.sessionId):await a?.send($)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...s}=e.params,a=Number(r),n=this._progressHandlers.get(a);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(a),o=this._timeoutInfo.get(a);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(a)}catch(u){this._responseHandlers.delete(a),this._progressHandlers.delete(a),this._cleanupTimeout(a),i(u);return}n(s)}_onresponse(e){const r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),ft(e))s(e);else{const i=new G(e.error.code,e.error.message,e.error.data);s(i)}return}const a=this._responseHandlers.get(r);if(a===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(ft(e)&&e.result&&typeof e.result=="object"){const i=e.result;if(i.task&&typeof i.task=="object"){const o=i.task;typeof o.taskId=="string"&&(n=!0,this._taskProgressTokens.set(o.taskId,r))}}if(n||this._progressHandlers.delete(r),ft(e))a(e);else{const i=G.fromError(e.error.code,e.error.message,e.error.data);a(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){const{task:a}=s??{};if(!a){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof G?i:new G(Z.InternalError,String(i))}}return}let n;try{const i=await this.request(e,Ur,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new G(Z.InternalError,"Task creation did not return a task");for(;;){const o=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:o},xe(o.status)){o.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:o.status==="failed"?yield{type:"error",error:new G(Z.InternalError,`Task ${n} failed`)}:o.status==="cancelled"&&(yield{type:"error",error:new G(Z.InternalError,`Task ${n} was cancelled`)});return}if(o.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}const u=o.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(m=>setTimeout(m,u)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof G?i:new G(Z.InternalError,String(i))}}}request(e,r,s){const{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i,task:o,relatedTask:u}=s??{};return new Promise((m,h)=>{const $=c=>{h(c)};if(!this._transport){$(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(c){$(c);return}s?.signal?.throwIfAborted();const g=this._requestMessageId++,y={...e,jsonrpc:"2.0",id:g};s?.onprogress&&(this._progressHandlers.set(g,s.onprogress),y.params={...e.params,_meta:{...e.params?._meta||{},progressToken:g}}),o&&(y.params={...y.params,task:o}),u&&(y.params={...y.params,_meta:{...y.params?._meta||{},[Xe]:u}});const v=c=>{this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(c)}},{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));const d=c instanceof G?c:new G(Z.RequestTimeout,String(c));h(d)};this._responseHandlers.set(g,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return h(c);try{const d=He(r,c.result);d.success?m(d.data):h(d.error)}catch(d){h(d)}}}),s?.signal?.addEventListener("abort",()=>{v(s?.signal?.reason)});const w=s?.timeout??Io,l=()=>v(G.fromError(Z.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(g,w,s?.maxTotalTimeout,l,s?.resetTimeoutOnProgress??!1);const p=u?.taskId;if(p){const c=d=>{const S=this._responseHandlers.get(g);S?S(d):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,c),this._enqueueTaskMessage(p,{type:"request",message:y,timestamp:Date.now()}).catch(d=>{this._cleanupTimeout(g),h(d)})}else this._transport.send(y,{relatedRequestId:a,resumptionToken:n,onresumptiontoken:i}).catch(c=>{this._cleanupTimeout(g),h(c)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},wa,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Sa,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},$a,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=r?.relatedTask?.taskId;if(s){const o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Xe]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:o,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[Xe]:r.relatedTask}}}),this._transport?.send(o,r).catch(u=>this._onerror(u))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Xe]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const s=as(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(a,n)=>{const i=os(e,a);return Promise.resolve(r(i,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const s=as(e);this._notificationHandlers.set(s,a=>{const n=os(e,a);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const a=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,a)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,r);for(const a of s)if(a.type==="request"&&Lr(a.message)){const n=a.message.id,i=this._requestResolvers.get(n);i?(i(new G(Z.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{const a=await this._taskStore?.getTask(e);a?.pollInterval&&(s=a.pollInterval)}catch{}return new Promise((a,n)=>{if(r.aborted){n(new G(Z.InvalidRequest,"Request cancelled"));return}const i=setTimeout(a,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new G(Z.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async a=>{if(!e)throw new Error("No request provided");return await s.createTask(a,e.id,{method:e.method,params:e.params},r)},getTask:async a=>{const n=await s.getTask(a,r);if(!n)throw new G(Z.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(a,n,i)=>{await s.storeTaskResult(a,n,i,r);const o=await s.getTask(a,r);if(o){const u=ns.parse({method:"notifications/tasks/status",params:o});await this.notification(u),xe(o.status)&&this._cleanupTaskProgressHandler(a)}},getTaskResult:a=>s.getTaskResult(a,r),updateTaskStatus:async(a,n,i)=>{const o=await s.getTask(a,r);if(!o)throw new G(Z.InvalidParams,`Task "${a}" not found - it may have been cleaned up`);if(xe(o.status))throw new G(Z.InvalidParams,`Cannot update task "${a}" from terminal status "${o.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(a,n,i,r);const u=await s.getTask(a,r);if(u){const m=ns.parse({method:"notifications/tasks/status",params:u});await this.notification(m),xe(u.status)&&this._cleanupTaskProgressHandler(a)}},listTasks:a=>s.listTasks(a,r)}}}function is(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ro(t,e){const r={...t};for(const s in e){const a=s,n=e[a];if(n===void 0)continue;const i=r[a];is(i)&&is(n)?r[a]={...i,...n}:r[a]=n}return r}var wt={exports:{}},Tr={},Me={},ze={},kr={},Pr={},Ir={},cs;function fr(){return cs||(cs=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(c){if(super(),!t.IDENTIFIER.test(c))throw new Error("CodeGen: name must be a valid identifier");this.str=c}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class s extends e{constructor(c){super(),this._items=typeof c=="string"?[c]:c}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const c=this._items[0];return c===""||c==='""'}get str(){var c;return(c=this._str)!==null&&c!==void 0?c:this._str=this._items.reduce((d,S)=>`${d}${S}`,"")}get names(){var c;return(c=this._names)!==null&&c!==void 0?c:this._names=this._items.reduce((d,S)=>(S instanceof r&&(d[S.str]=(d[S.str]||0)+1),d),{})}}t._Code=s,t.nil=new s("");function a(p,...c){const d=[p[0]];let S=0;for(;S<c.length;)o(d,c[S]),d.push(p[++S]);return new s(d)}t._=a;const n=new s("+");function i(p,...c){const d=[y(p[0])];let S=0;for(;S<c.length;)d.push(n),o(d,c[S]),d.push(n,y(p[++S]));return u(d),new s(d)}t.str=i;function o(p,c){c instanceof s?p.push(...c._items):c instanceof r?p.push(c):p.push($(c))}t.addCodeArg=o;function u(p){let c=1;for(;c<p.length-1;){if(p[c]===n){const d=m(p[c-1],p[c+1]);if(d!==void 0){p.splice(c-1,3,d);continue}p[c++]="+"}c++}}function m(p,c){if(c==='""')return p;if(p==='""')return c;if(typeof p=="string")return c instanceof r||p[p.length-1]!=='"'?void 0:typeof c!="string"?`${p.slice(0,-1)}${c}"`:c[0]==='"'?p.slice(0,-1)+c.slice(1):void 0;if(typeof c=="string"&&c[0]==='"'&&!(p instanceof r))return`"${p}${c.slice(1)}`}function h(p,c){return c.emptyStr()?p:p.emptyStr()?c:i`${p}${c}`}t.strConcat=h;function $(p){return typeof p=="number"||typeof p=="boolean"||p===null?p:y(Array.isArray(p)?p.join(","):p)}function g(p){return new s(y(p))}t.stringify=g;function y(p){return JSON.stringify(p).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=y;function v(p){return typeof p=="string"&&t.IDENTIFIER.test(p)?new s(`.${p}`):a`[${p}]`}t.getProperty=v;function w(p){if(typeof p=="string"&&t.IDENTIFIER.test(p))return new s(`${p}`);throw new Error(`CodeGen: invalid export name: ${p}, use explicit $id name mapping`)}t.getEsmExportName=w;function l(p){return new s(p.toString())}t.regexpCode=l})(Ir)),Ir}var Or={},us;function ls(){return us||(us=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=fr();class r extends Error{constructor(m){super(`CodeGen: "code" for ${m} not defined`),this.value=m.value}}var s;(function(u){u[u.Started=0]="Started",u[u.Completed=1]="Completed"})(s||(t.UsedValueState=s={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class a{constructor({prefixes:m,parent:h}={}){this._names={},this._prefixes=m,this._parent=h}toName(m){return m instanceof e.Name?m:this.name(m)}name(m){return new e.Name(this._newName(m))}_newName(m){const h=this._names[m]||this._nameGroup(m);return`${m}${h.index++}`}_nameGroup(m){var h,$;if(!(($=(h=this._parent)===null||h===void 0?void 0:h._prefixes)===null||$===void 0)&&$.has(m)||this._prefixes&&!this._prefixes.has(m))throw new Error(`CodeGen: prefix "${m}" is not allowed in this scope`);return this._names[m]={prefix:m,index:0}}}t.Scope=a;class n extends e.Name{constructor(m,h){super(h),this.prefix=m}setValue(m,{property:h,itemIndex:$}){this.value=m,this.scopePath=(0,e._)`.${new e.Name(h)}[${$}]`}}t.ValueScopeName=n;const i=(0,e._)`\n`;class o extends a{constructor(m){super(m),this._values={},this._scope=m.scope,this.opts={...m,_n:m.lines?i:e.nil}}get(){return this._scope}name(m){return new n(m,this._newName(m))}value(m,h){var $;if(h.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const g=this.toName(m),{prefix:y}=g,v=($=h.key)!==null&&$!==void 0?$:h.ref;let w=this._values[y];if(w){const c=w.get(v);if(c)return c}else w=this._values[y]=new Map;w.set(v,g);const l=this._scope[y]||(this._scope[y]=[]),p=l.length;return l[p]=h.ref,g.setValue(h,{property:y,itemIndex:p}),g}getValue(m,h){const $=this._values[m];if($)return $.get(h)}scopeRefs(m,h=this._values){return this._reduceValues(h,$=>{if($.scopePath===void 0)throw new Error(`CodeGen: name "${$}" has no value`);return(0,e._)`${m}${$.scopePath}`})}scopeCode(m=this._values,h,$){return this._reduceValues(m,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},h,$)}_reduceValues(m,h,$={},g){let y=e.nil;for(const v in m){const w=m[v];if(!w)continue;const l=$[v]=$[v]||new Map;w.forEach(p=>{if(l.has(p))return;l.set(p,s.Started);let c=h(p);if(c){const d=this.opts.es5?t.varKinds.var:t.varKinds.const;y=(0,e._)`${y}${d} ${p} = ${c};${this.opts._n}`}else if(c=g?.(p))y=(0,e._)`${y}${c}${this.opts._n}`;else throw new r(p);l.set(p,s.Completed)})}return y}}t.ValueScope=o})(Or)),Or}var ds;function X(){return ds||(ds=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=fr(),r=ls();var s=fr();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return s._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return s.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return s.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return s.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return s.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return s.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return s.Name}});var a=ls();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return a.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return a.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return a.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return a.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class n{optimizeNodes(){return this}optimizeNames(_,T){return this}}class i extends n{constructor(_,T,N){super(),this.varKind=_,this.name=T,this.rhs=N}render({es5:_,_n:T}){const N=_?r.varKinds.var:this.varKind,z=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${z};`+T}optimizeNames(_,T){if(_[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,_,T)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends n{constructor(_,T,N){super(),this.lhs=_,this.rhs=T,this.sideEffects=N}render({_n:_}){return`${this.lhs} = ${this.rhs};`+_}optimizeNames(_,T){if(!(this.lhs instanceof e.Name&&!_[this.lhs.str]&&!this.sideEffects))return this.rhs=x(this.rhs,_,T),this}get names(){const _=this.lhs instanceof e.Name?{}:{...this.lhs.names};return F(_,this.rhs)}}class u extends o{constructor(_,T,N,z){super(_,N,z),this.op=T}render({_n:_}){return`${this.lhs} ${this.op}= ${this.rhs};`+_}}class m extends n{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`${this.label}:`+_}}class h extends n{constructor(_){super(),this.label=_,this.names={}}render({_n:_}){return`break${this.label?` ${this.label}`:""};`+_}}class $ extends n{constructor(_){super(),this.error=_}render({_n:_}){return`throw ${this.error};`+_}get names(){return this.error.names}}class g extends n{constructor(_){super(),this.code=_}render({_n:_}){return`${this.code};`+_}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(_,T){return this.code=x(this.code,_,T),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class y extends n{constructor(_=[]){super(),this.nodes=_}render(_){return this.nodes.reduce((T,N)=>T+N.render(_),"")}optimizeNodes(){const{nodes:_}=this;let T=_.length;for(;T--;){const N=_[T].optimizeNodes();Array.isArray(N)?_.splice(T,1,...N):N?_[T]=N:_.splice(T,1)}return _.length>0?this:void 0}optimizeNames(_,T){const{nodes:N}=this;let z=N.length;for(;z--;){const W=N[z];W.optimizeNames(_,T)||(ae(_,W.names),N.splice(z,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce((_,T)=>H(_,T.names),{})}}class v extends y{render(_){return"{"+_._n+super.render(_)+"}"+_._n}}class w extends y{}class l extends v{}l.kind="else";class p extends v{constructor(_,T){super(T),this.condition=_}render(_){let T=`if(${this.condition})`+super.render(_);return this.else&&(T+="else "+this.else.render(_)),T}optimizeNodes(){super.optimizeNodes();const _=this.condition;if(_===!0)return this.nodes;let T=this.else;if(T){const N=T.optimizeNodes();T=this.else=Array.isArray(N)?new l(N):N}if(T)return _===!1?T instanceof p?T:T.nodes:this.nodes.length?this:new p(ge(_),T instanceof p?[T]:T.nodes);if(!(_===!1||!this.nodes.length))return this}optimizeNames(_,T){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames(_,T),!!(super.optimizeNames(_,T)||this.else))return this.condition=x(this.condition,_,T),this}get names(){const _=super.names;return F(_,this.condition),this.else&&H(_,this.else.names),_}}p.kind="if";class c extends v{}c.kind="for";class d extends c{constructor(_){super(),this.iteration=_}render(_){return`for(${this.iteration})`+super.render(_)}optimizeNames(_,T){if(super.optimizeNames(_,T))return this.iteration=x(this.iteration,_,T),this}get names(){return H(super.names,this.iteration.names)}}class S extends c{constructor(_,T,N,z){super(),this.varKind=_,this.name=T,this.from=N,this.to=z}render(_){const T=_.es5?r.varKinds.var:this.varKind,{name:N,from:z,to:W}=this;return`for(${T} ${N}=${z}; ${N}<${W}; ${N}++)`+super.render(_)}get names(){const _=F(super.names,this.from);return F(_,this.to)}}class f extends c{constructor(_,T,N,z){super(),this.loop=_,this.varKind=T,this.name=N,this.iterable=z}render(_){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(_)}optimizeNames(_,T){if(super.optimizeNames(_,T))return this.iterable=x(this.iterable,_,T),this}get names(){return H(super.names,this.iterable.names)}}class b extends v{constructor(_,T,N){super(),this.name=_,this.args=T,this.async=N}render(_){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(_)}}b.kind="func";class E extends y{render(_){return"return "+super.render(_)}}E.kind="return";class C extends v{render(_){let T="try"+super.render(_);return this.catch&&(T+=this.catch.render(_)),this.finally&&(T+=this.finally.render(_)),T}optimizeNodes(){var _,T;return super.optimizeNodes(),(_=this.catch)===null||_===void 0||_.optimizeNodes(),(T=this.finally)===null||T===void 0||T.optimizeNodes(),this}optimizeNames(_,T){var N,z;return super.optimizeNames(_,T),(N=this.catch)===null||N===void 0||N.optimizeNames(_,T),(z=this.finally)===null||z===void 0||z.optimizeNames(_,T),this}get names(){const _=super.names;return this.catch&&H(_,this.catch.names),this.finally&&H(_,this.finally.names),_}}class D extends v{constructor(_){super(),this.error=_}render(_){return`catch(${this.error})`+super.render(_)}}D.kind="catch";class V extends v{render(_){return"finally"+super.render(_)}}V.kind="finally";class q{constructor(_,T={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...T,_n:T.lines?`
|
|
2
2
|
`:""},this._extScope=_,this._scope=new r.Scope({parent:_}),this._nodes=[new w]}toString(){return this._root.render(this.opts)}name(_){return this._scope.name(_)}scopeName(_){return this._extScope.name(_)}scopeValue(_,T){const N=this._extScope.value(_,T);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue(_,T){return this._extScope.getValue(_,T)}scopeRefs(_){return this._extScope.scopeRefs(_,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(_,T,N,z){const W=this._scope.toName(T);return N!==void 0&&z&&(this._constants[W.str]=N),this._leafNode(new i(_,W,N)),W}const(_,T,N){return this._def(r.varKinds.const,_,T,N)}let(_,T,N){return this._def(r.varKinds.let,_,T,N)}var(_,T,N){return this._def(r.varKinds.var,_,T,N)}assign(_,T,N){return this._leafNode(new o(_,T,N))}add(_,T){return this._leafNode(new u(_,t.operators.ADD,T))}code(_){return typeof _=="function"?_():_!==e.nil&&this._leafNode(new g(_)),this}object(..._){const T=["{"];for(const[N,z]of _)T.length>1&&T.push(","),T.push(N),(N!==z||this.opts.es5)&&(T.push(":"),(0,e.addCodeArg)(T,z));return T.push("}"),new e._Code(T)}if(_,T,N){if(this._blockNode(new p(_)),T&&N)this.code(T).else().code(N).endIf();else if(T)this.code(T).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(_){return this._elseNode(new p(_))}else(){return this._elseNode(new l)}endIf(){return this._endBlockNode(p,l)}_for(_,T){return this._blockNode(_),T&&this.code(T).endFor(),this}for(_,T){return this._for(new d(_),T)}forRange(_,T,N,z,W=this.opts.es5?r.varKinds.var:r.varKinds.let){const ne=this._scope.toName(_);return this._for(new S(W,ne,T,N),()=>z(ne))}forOf(_,T,N,z=r.varKinds.const){const W=this._scope.toName(_);if(this.opts.es5){const ne=T instanceof e.Name?T:this.var("_arr",T);return this.forRange("_i",0,(0,e._)`${ne}.length`,re=>{this.var(W,(0,e._)`${ne}[${re}]`),N(W)})}return this._for(new f("of",z,W,T),()=>N(W))}forIn(_,T,N,z=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(_,(0,e._)`Object.keys(${T})`,N);const W=this._scope.toName(_);return this._for(new f("in",z,W,T),()=>N(W))}endFor(){return this._endBlockNode(c)}label(_){return this._leafNode(new m(_))}break(_){return this._leafNode(new h(_))}return(_){const T=new E;if(this._blockNode(T),this.code(_),T.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(_,T,N){if(!T&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const z=new C;if(this._blockNode(z),this.code(_),T){const W=this.name("e");this._currNode=z.catch=new D(W),T(W)}return N&&(this._currNode=z.finally=new V,this.code(N)),this._endBlockNode(D,V)}throw(_){return this._leafNode(new $(_))}block(_,T){return this._blockStarts.push(this._nodes.length),_&&this.code(_).endBlock(T),this}endBlock(_){const T=this._blockStarts.pop();if(T===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-T;if(N<0||_!==void 0&&N!==_)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${_} expected`);return this._nodes.length=T,this}func(_,T=e.nil,N,z){return this._blockNode(new b(_,T,N)),z&&this.code(z).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(_=1){for(;_-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(_){return this._currNode.nodes.push(_),this}_blockNode(_){this._currNode.nodes.push(_),this._nodes.push(_)}_endBlockNode(_,T){const N=this._currNode;if(N instanceof _||T&&N instanceof T)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${T?`${_.kind}/${T.kind}`:_.kind}"`)}_elseNode(_){const T=this._currNode;if(!(T instanceof p))throw new Error('CodeGen: "else" without "if"');return this._currNode=T.else=_,this}get _root(){return this._nodes[0]}get _currNode(){const _=this._nodes;return _[_.length-1]}set _currNode(_){const T=this._nodes;T[T.length-1]=_}}t.CodeGen=q;function H(R,_){for(const T in _)R[T]=(R[T]||0)+(_[T]||0);return R}function F(R,_){return _ instanceof e._CodeOrName?H(R,_.names):R}function x(R,_,T){if(R instanceof e.Name)return N(R);if(!z(R))return R;return new e._Code(R._items.reduce((W,ne)=>(ne instanceof e.Name&&(ne=N(ne)),ne instanceof e._Code?W.push(...ne._items):W.push(ne),W),[]));function N(W){const ne=T[W.str];return ne===void 0||_[W.str]!==1?W:(delete _[W.str],ne)}function z(W){return W instanceof e._Code&&W._items.some(ne=>ne instanceof e.Name&&_[ne.str]===1&&T[ne.str]!==void 0)}}function ae(R,_){for(const T in _)R[T]=(R[T]||0)-(_[T]||0)}function ge(R){return typeof R=="boolean"||typeof R=="number"||R===null?!R:(0,e._)`!${j(R)}`}t.not=ge;const _e=I(t.operators.AND);function ce(...R){return R.reduce(_e)}t.and=ce;const Ie=I(t.operators.OR);function L(...R){return R.reduce(Ie)}t.or=L;function I(R){return(_,T)=>_===e.nil?T:T===e.nil?_:(0,e._)`${j(_)} ${R} ${j(T)}`}function j(R){return R instanceof e.Name?R:(0,e._)`(${R})`}})(Pr)),Pr}var Q={},fs;function se(){if(fs)return Q;fs=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.checkStrictMode=Q.getErrorPath=Q.Type=Q.useFunc=Q.setEvaluated=Q.evaluatedPropsToName=Q.mergeEvaluated=Q.eachItem=Q.unescapeJsonPointer=Q.escapeJsonPointer=Q.escapeFragment=Q.unescapeFragment=Q.schemaRefOrVal=Q.schemaHasRulesButRef=Q.schemaHasRules=Q.checkUnknownRules=Q.alwaysValidSchema=Q.toHash=void 0;const t=X(),e=fr();function r(f){const b={};for(const E of f)b[E]=!0;return b}Q.toHash=r;function s(f,b){return typeof b=="boolean"?b:Object.keys(b).length===0?!0:(a(f,b),!n(b,f.self.RULES.all))}Q.alwaysValidSchema=s;function a(f,b=f.schema){const{opts:E,self:C}=f;if(!E.strictSchema||typeof b=="boolean")return;const D=C.RULES.keywords;for(const V in b)D[V]||S(f,`unknown keyword: "${V}"`)}Q.checkUnknownRules=a;function n(f,b){if(typeof f=="boolean")return!f;for(const E in f)if(b[E])return!0;return!1}Q.schemaHasRules=n;function i(f,b){if(typeof f=="boolean")return!f;for(const E in f)if(E!=="$ref"&&b.all[E])return!0;return!1}Q.schemaHasRulesButRef=i;function o({topSchemaRef:f,schemaPath:b},E,C,D){if(!D){if(typeof E=="number"||typeof E=="boolean")return E;if(typeof E=="string")return(0,t._)`${E}`}return(0,t._)`${f}${b}${(0,t.getProperty)(C)}`}Q.schemaRefOrVal=o;function u(f){return $(decodeURIComponent(f))}Q.unescapeFragment=u;function m(f){return encodeURIComponent(h(f))}Q.escapeFragment=m;function h(f){return typeof f=="number"?`${f}`:f.replace(/~/g,"~0").replace(/\//g,"~1")}Q.escapeJsonPointer=h;function $(f){return f.replace(/~1/g,"/").replace(/~0/g,"~")}Q.unescapeJsonPointer=$;function g(f,b){if(Array.isArray(f))for(const E of f)b(E);else b(f)}Q.eachItem=g;function y({mergeNames:f,mergeToName:b,mergeValues:E,resultToName:C}){return(D,V,q,H)=>{const F=q===void 0?V:q instanceof t.Name?(V instanceof t.Name?f(D,V,q):b(D,V,q),q):V instanceof t.Name?(b(D,q,V),V):E(V,q);return H===t.Name&&!(F instanceof t.Name)?C(D,F):F}}Q.mergeEvaluated={props:y({mergeNames:(f,b,E)=>f.if((0,t._)`${E} !== true && ${b} !== undefined`,()=>{f.if((0,t._)`${b} === true`,()=>f.assign(E,!0),()=>f.assign(E,(0,t._)`${E} || {}`).code((0,t._)`Object.assign(${E}, ${b})`))}),mergeToName:(f,b,E)=>f.if((0,t._)`${E} !== true`,()=>{b===!0?f.assign(E,!0):(f.assign(E,(0,t._)`${E} || {}`),w(f,E,b))}),mergeValues:(f,b)=>f===!0?!0:{...f,...b},resultToName:v}),items:y({mergeNames:(f,b,E)=>f.if((0,t._)`${E} !== true && ${b} !== undefined`,()=>f.assign(E,(0,t._)`${b} === true ? true : ${E} > ${b} ? ${E} : ${b}`)),mergeToName:(f,b,E)=>f.if((0,t._)`${E} !== true`,()=>f.assign(E,b===!0?!0:(0,t._)`${E} > ${b} ? ${E} : ${b}`)),mergeValues:(f,b)=>f===!0?!0:Math.max(f,b),resultToName:(f,b)=>f.var("items",b)})};function v(f,b){if(b===!0)return f.var("props",!0);const E=f.var("props",(0,t._)`{}`);return b!==void 0&&w(f,E,b),E}Q.evaluatedPropsToName=v;function w(f,b,E){Object.keys(E).forEach(C=>f.assign((0,t._)`${b}${(0,t.getProperty)(C)}`,!0))}Q.setEvaluated=w;const l={};function p(f,b){return f.scopeValue("func",{ref:b,code:l[b.code]||(l[b.code]=new e._Code(b.code))})}Q.useFunc=p;var c;(function(f){f[f.Num=0]="Num",f[f.Str=1]="Str"})(c||(Q.Type=c={}));function d(f,b,E){if(f instanceof t.Name){const C=b===c.Num;return E?C?(0,t._)`"[" + ${f} + "]"`:(0,t._)`"['" + ${f} + "']"`:C?(0,t._)`"/" + ${f}`:(0,t._)`"/" + ${f}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return E?(0,t.getProperty)(f).toString():"/"+h(f)}Q.getErrorPath=d;function S(f,b,E=f.opts.strictSchema){if(E){if(b=`strict mode: ${b}`,E===!0)throw new Error(b);f.self.logger.warn(b)}}return Q.checkStrictMode=S,Q}var St={},hs;function Fe(){if(hs)return St;hs=1,Object.defineProperty(St,"__esModule",{value:!0});const t=X(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return St.default=e,St}var ps;function _r(){return ps||(ps=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=X(),r=se(),s=Fe();t.keywordError={message:({keyword:l})=>(0,e.str)`must pass "${l}" keyword validation`},t.keyword$DataError={message:({keyword:l,schemaType:p})=>p?(0,e.str)`"${l}" keyword must be ${p} ($data)`:(0,e.str)`"${l}" keyword is invalid ($data)`};function a(l,p=t.keywordError,c,d){const{it:S}=l,{gen:f,compositeRule:b,allErrors:E}=S,C=$(l,p,c);d??(b||E)?u(f,C):m(S,(0,e._)`[${C}]`)}t.reportError=a;function n(l,p=t.keywordError,c){const{it:d}=l,{gen:S,compositeRule:f,allErrors:b}=d,E=$(l,p,c);u(S,E),f||b||m(d,s.default.vErrors)}t.reportExtraError=n;function i(l,p){l.assign(s.default.errors,p),l.if((0,e._)`${s.default.vErrors} !== null`,()=>l.if(p,()=>l.assign((0,e._)`${s.default.vErrors}.length`,p),()=>l.assign(s.default.vErrors,null)))}t.resetErrorsCount=i;function o({gen:l,keyword:p,schemaValue:c,data:d,errsCount:S,it:f}){if(S===void 0)throw new Error("ajv implementation error");const b=l.name("err");l.forRange("i",S,s.default.errors,E=>{l.const(b,(0,e._)`${s.default.vErrors}[${E}]`),l.if((0,e._)`${b}.instancePath === undefined`,()=>l.assign((0,e._)`${b}.instancePath`,(0,e.strConcat)(s.default.instancePath,f.errorPath))),l.assign((0,e._)`${b}.schemaPath`,(0,e.str)`${f.errSchemaPath}/${p}`),f.opts.verbose&&(l.assign((0,e._)`${b}.schema`,c),l.assign((0,e._)`${b}.data`,d))})}t.extendErrors=o;function u(l,p){const c=l.const("err",p);l.if((0,e._)`${s.default.vErrors} === null`,()=>l.assign(s.default.vErrors,(0,e._)`[${c}]`),(0,e._)`${s.default.vErrors}.push(${c})`),l.code((0,e._)`${s.default.errors}++`)}function m(l,p){const{gen:c,validateName:d,schemaEnv:S}=l;S.$async?c.throw((0,e._)`new ${l.ValidationError}(${p})`):(c.assign((0,e._)`${d}.errors`,p),c.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function $(l,p,c){const{createErrors:d}=l.it;return d===!1?(0,e._)`{}`:g(l,p,c)}function g(l,p,c={}){const{gen:d,it:S}=l,f=[y(S,c),v(l,c)];return w(l,p,f),d.object(...f)}function y({errorPath:l},{instancePath:p}){const c=p?(0,e.str)`${l}${(0,r.getErrorPath)(p,r.Type.Str)}`:l;return[s.default.instancePath,(0,e.strConcat)(s.default.instancePath,c)]}function v({keyword:l,it:{errSchemaPath:p}},{schemaPath:c,parentSchema:d}){let S=d?p:(0,e.str)`${p}/${l}`;return c&&(S=(0,e.str)`${S}${(0,r.getErrorPath)(c,r.Type.Str)}`),[h.schemaPath,S]}function w(l,{params:p,message:c},d){const{keyword:S,data:f,schemaValue:b,it:E}=l,{opts:C,propertyName:D,topSchemaRef:V,schemaPath:q}=E;d.push([h.keyword,S],[h.params,typeof p=="function"?p(l):p||(0,e._)`{}`]),C.messages&&d.push([h.message,typeof c=="function"?c(l):c]),C.verbose&&d.push([h.schema,b],[h.parentSchema,(0,e._)`${V}${q}`],[s.default.data,f]),D&&d.push([h.propertyName,D])}})(kr)),kr}var ms;function Co(){if(ms)return ze;ms=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.boolOrEmptySchema=ze.topBoolOrEmptySchema=void 0;const t=_r(),e=X(),r=Fe(),s={message:"boolean schema is false"};function a(o){const{gen:u,schema:m,validateName:h}=o;m===!1?i(o,!1):typeof m=="object"&&m.$async===!0?u.return(r.default.data):(u.assign((0,e._)`${h}.errors`,null),u.return(!0))}ze.topBoolOrEmptySchema=a;function n(o,u){const{gen:m,schema:h}=o;h===!1?(m.var(u,!1),i(o)):m.var(u,!0)}ze.boolOrEmptySchema=n;function i(o,u){const{gen:m,data:h}=o,$={gen:m,keyword:"false schema",data:h,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:o};(0,t.reportError)($,s,void 0,u)}return ze}var me={},Ke={},ys;function Dn(){if(ys)return Ke;ys=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.getRules=Ke.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(a){return typeof a=="string"&&e.has(a)}Ke.isJSONType=r;function s(){const a={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...a,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},a.number,a.string,a.array,a.object],post:{rules:[]},all:{},keywords:{}}}return Ke.getRules=s,Ke}var je={},gs;function Ln(){if(gs)return je;gs=1,Object.defineProperty(je,"__esModule",{value:!0}),je.shouldUseRule=je.shouldUseGroup=je.schemaHasRulesForType=void 0;function t({schema:s,self:a},n){const i=a.RULES.types[n];return i&&i!==!0&&e(s,i)}je.schemaHasRulesForType=t;function e(s,a){return a.rules.some(n=>r(s,n))}je.shouldUseGroup=e;function r(s,a){var n;return s[a.keyword]!==void 0||((n=a.definition.implements)===null||n===void 0?void 0:n.some(i=>s[i]!==void 0))}return je.shouldUseRule=r,je}var _s;function hr(){if(_s)return me;_s=1,Object.defineProperty(me,"__esModule",{value:!0}),me.reportTypeError=me.checkDataTypes=me.checkDataType=me.coerceAndCheckDataType=me.getJSONTypes=me.getSchemaTypes=me.DataType=void 0;const t=Dn(),e=Ln(),r=_r(),s=X(),a=se();var n;(function(c){c[c.Correct=0]="Correct",c[c.Wrong=1]="Wrong"})(n||(me.DataType=n={}));function i(c){const d=o(c.type);if(d.includes("null")){if(c.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!d.length&&c.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');c.nullable===!0&&d.push("null")}return d}me.getSchemaTypes=i;function o(c){const d=Array.isArray(c)?c:c?[c]:[];if(d.every(t.isJSONType))return d;throw new Error("type must be JSONType or JSONType[]: "+d.join(","))}me.getJSONTypes=o;function u(c,d){const{gen:S,data:f,opts:b}=c,E=h(d,b.coerceTypes),C=d.length>0&&!(E.length===0&&d.length===1&&(0,e.schemaHasRulesForType)(c,d[0]));if(C){const D=v(d,f,b.strictNumbers,n.Wrong);S.if(D,()=>{E.length?$(c,d,E):l(c)})}return C}me.coerceAndCheckDataType=u;const m=new Set(["string","number","integer","boolean","null"]);function h(c,d){return d?c.filter(S=>m.has(S)||d==="array"&&S==="array"):[]}function $(c,d,S){const{gen:f,data:b,opts:E}=c,C=f.let("dataType",(0,s._)`typeof ${b}`),D=f.let("coerced",(0,s._)`undefined`);E.coerceTypes==="array"&&f.if((0,s._)`${C} == 'object' && Array.isArray(${b}) && ${b}.length == 1`,()=>f.assign(b,(0,s._)`${b}[0]`).assign(C,(0,s._)`typeof ${b}`).if(v(d,b,E.strictNumbers),()=>f.assign(D,b))),f.if((0,s._)`${D} !== undefined`);for(const q of S)(m.has(q)||q==="array"&&E.coerceTypes==="array")&&V(q);f.else(),l(c),f.endIf(),f.if((0,s._)`${D} !== undefined`,()=>{f.assign(b,D),g(c,D)});function V(q){switch(q){case"string":f.elseIf((0,s._)`${C} == "number" || ${C} == "boolean"`).assign(D,(0,s._)`"" + ${b}`).elseIf((0,s._)`${b} === null`).assign(D,(0,s._)`""`);return;case"number":f.elseIf((0,s._)`${C} == "boolean" || ${b} === null
|
|
3
3
|
|| (${C} == "string" && ${b} && ${b} == +${b})`).assign(D,(0,s._)`+${b}`);return;case"integer":f.elseIf((0,s._)`${C} === "boolean" || ${b} === null
|
|
4
4
|
|| (${C} === "string" && ${b} && ${b} == +${b} && !(${b} % 1))`).assign(D,(0,s._)`+${b}`);return;case"boolean":f.elseIf((0,s._)`${b} === "false" || ${b} === 0 || ${b} === null`).assign(D,!1).elseIf((0,s._)`${b} === "true" || ${b} === 1`).assign(D,!0);return;case"null":f.elseIf((0,s._)`${b} === "" || ${b} === 0 || ${b} === false`),f.assign(D,null);return;case"array":f.elseIf((0,s._)`${C} === "string" || ${C} === "number"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a1 as u,an as m,c as r}from"./index-DMNk-OUX.js";import{b as C,a as f,u as N,c as l}from"./empty-state-DzS1Zp7m.js";import{u as a}from"./project-context-provider-BJIP5a-U.js";function g(o,e){return u(o,m,e)}function y(o){const e=r.c(3);let t;e[0]!==o?(t=o===void 0?{}:o,e[0]=o,e[1]=t):t=e[1];const s=t,{org:c}=a();let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=l(),e[2]=n):n=e[2];const i=n;return C(c.slug,"CONNECTIONS",i,s)}function S(o){const e=r.c(1),{org:t}=a();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=l(),e[0]=s):s=e[0];const c=s;return N(t.slug,"CONNECTIONS",o,c)}function _(){const o=r.c(1),{org:e}=a();let t;o[0]===Symbol.for("react.memo_cache_sentinel")?(t=l(),o[0]=t):t=o[0];const s=t;return f(e.slug,"CONNECTIONS",s)}export{_ as a,g as b,S as c,y as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as f,K as l}from"./index-
|
|
1
|
+
import{c as f,K as l}from"./index-DMNk-OUX.js";import{u as y}from"./index-Bb8rHnPb.js";async function h(t){const e=`/mcp/${t}`,s={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const o=await fetch(e,{method:"POST",headers:s,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-prompts",version:"1.0.0"}}})});if(!o.ok)return[];if((await o.json()).error)return[];const i=await fetch(e,{method:"POST",headers:s,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"prompts/list",params:{}})});if(!i.ok)return[];const r=await i.json();return r.error?[]:r.result?.prompts||[]}catch{return[]}}function P(t){const e=f.c(13);let s;e[0]!==t?(s=t.map(q),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==s?(o={queries:s},e[2]=s,e[3]=o):o=e[3];const n=y(o);let i,r;if(e[4]!==t||e[5]!==n){r=new Map;let p;e[8]!==n?(p=n.some(j),e[8]=n,e[9]=p):p=e[9],i=p,t.forEach((u,m)=>{const c=n[m];c?.data?r.set(u,c.data.map(d)):r.set(u,[])}),e[4]=t,e[5]=n,e[6]=i,e[7]=r}else i=e[6],r=e[7];let a;return e[10]!==i||e[11]!==r?(a={promptsMap:r,isLoading:i},e[10]=i,e[11]=r,e[12]=a):a=e[12],a}function d(t){return{name:t.name,description:t.description}}function j(t){return t.isLoading}function q(t){return{queryKey:l.connectionPrompts(t),queryFn:()=>h(t),staleTime:6e4,retry:!1}}async function w(t){const e=`/mcp/${t}`,s={"Content-Type":"application/json",Accept:"application/json, text/event-stream"};try{const o=await fetch(e,{method:"POST",headers:s,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mesh-resources",version:"1.0.0"}}})});if(!o.ok)return[];if((await o.json()).error)return[];const i=await fetch(e,{method:"POST",headers:s,body:JSON.stringify({jsonrpc:"2.0",id:2,method:"resources/list",params:{}})});if(!i.ok)return[];const r=await i.json();return r.error?[]:r.result?.resources||[]}catch{return[]}}function $(t){const e=f.c(13);let s;e[0]!==t?(s=t.map(O),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==s?(o={queries:s},e[2]=s,e[3]=o):o=e[3];const n=y(o);let i,r;if(e[4]!==t||e[5]!==n){r=new Map;let p;e[8]!==n?(p=n.some(g),e[8]=n,e[9]=p):p=e[9],i=p,t.forEach((u,m)=>{const c=n[m];c?.data?r.set(u,c.data.map(S)):r.set(u,[])}),e[4]=t,e[5]=n,e[6]=i,e[7]=r}else i=e[6],r=e[7];let a;return e[10]!==i||e[11]!==r?(a={resourcesMap:r,isLoading:i},e[10]=i,e[11]=r,e[12]=a):a=e[12],a}function S(t){return{uri:t.uri,name:t.name,description:t.description}}function g(t){return t.isLoading}function O(t){return{queryKey:l.connectionResources(t),queryFn:()=>w(t),staleTime:6e4,retry:!1}}export{$ as a,P as u};
|