@marimo-team/frontend 0.23.12-dev9 → 0.23.13-dev0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/assets/{CellStatus-BGSEw-sx.js → CellStatus-xkT4Dvj4.js} +1 -1
  2. package/dist/assets/JsonOutput-FFLZqPUK.js +53 -0
  3. package/dist/assets/{MarimoErrorOutput-G8Q8ZYoi.js → MarimoErrorOutput-BQt_FXJL.js} +1 -1
  4. package/dist/assets/{RenderHTML-DXJCvdz4.js → RenderHTML-Cq4mwWYz.js} +1 -1
  5. package/dist/assets/{RunButton-B0ruC_FE.js → RunButton-DdQ4s_KP.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-DWNUMbns.js → add-cell-with-ai-wdY7HT-D.js} +26 -26
  7. package/dist/assets/{add-connection-dialog-CZ2UuO8f.js → add-connection-dialog-C41ThK2T.js} +1 -1
  8. package/dist/assets/{agent-panel-B-_gvxz2.js → agent-panel-q5ey8yNH.js} +1 -1
  9. package/dist/assets/{ai-model-dropdown-BW60s6ul.js → ai-model-dropdown-DQb_CyMN.js} +4 -4
  10. package/dist/assets/{app-config-button-DJaefZBz.js → app-config-button-8FXNdkBs.js} +1 -1
  11. package/dist/assets/{cell-editor-CvLW6KK3.js → cell-editor-CFq9iL3S.js} +1 -1
  12. package/dist/assets/{cell-link-BWqpbaiv.js → cell-link-DgWTiCtG.js} +1 -1
  13. package/dist/assets/{cells-BidbgSuB.js → cells-06TDmJ8V.js} +49 -49
  14. package/dist/assets/{chat-display-BRCFntOw.js → chat-display-DO7nc_uY.js} +1 -1
  15. package/dist/assets/{chat-panel-BGCbxSQx.js → chat-panel-DmUkj42a.js} +1 -1
  16. package/dist/assets/{chat-ui-CceYGzB9.js → chat-ui-Bf7t-NAW.js} +1 -1
  17. package/dist/assets/{column-preview-BbgM2h8n.js → column-preview-oHsVFerC.js} +1 -1
  18. package/dist/assets/{command-palette-Mqu8KKo1.js → command-palette-Bvl7fQ8h.js} +1 -1
  19. package/dist/assets/{common-B94MReIe.js → common-cKvfH0fD.js} +1 -1
  20. package/dist/assets/{components-DoRr7Hf1.js → components-BhmX9dcm.js} +1 -1
  21. package/dist/assets/{datasource-DI-YUWev.js → datasource-mVfTJz3V.js} +1 -1
  22. package/dist/assets/{dependency-graph-panel-B7_LMfP4.js → dependency-graph-panel-D9C_hBQw.js} +1 -1
  23. package/dist/assets/{documentation-panel-BGXFZYSy.js → documentation-panel-C0uXzYri.js} +1 -1
  24. package/dist/assets/{download-DgEarSps.js → download-VxqV5OSK.js} +1 -1
  25. package/dist/assets/{edit-page-DExCsBoE.js → edit-page-CInfJ1ps.js} +6 -6
  26. package/dist/assets/{error-panel-Bd98g_JW.js → error-panel-D2WmJDnT.js} +1 -1
  27. package/dist/assets/{file-explorer-panel-5GiP_o58.js → file-explorer-panel-nn5I1oLj.js} +3 -3
  28. package/dist/assets/{file-icons-BwFX01F6.js → file-icons-BeJWUbBH.js} +1 -1
  29. package/dist/assets/{file-name-input-C_iFa52z.js → file-name-input-Slq_KVFS.js} +1 -1
  30. package/dist/assets/{floating-outline-BDx00oB1.js → floating-outline-3UBj62S1.js} +1 -1
  31. package/dist/assets/{focus-CocfMydm.js → focus-DqhVePQT.js} +1 -1
  32. package/dist/assets/{form-DgnBiuvP.js → form-pEJO4Mq_.js} +1 -1
  33. package/dist/assets/{home-page-BuVWyEpt.js → home-page-CFgoMQu4.js} +1 -1
  34. package/dist/assets/{hooks-dPm1h9aq.js → hooks-NssnE3R8.js} +1 -1
  35. package/dist/assets/{html-to-image-TCtIotr9.js → html-to-image-CbQeOjEJ.js} +1 -1
  36. package/dist/assets/index-BjsskD4V.js +38 -0
  37. package/dist/assets/{index-Bj8QWDiJ.css → index-CaelsqOA.css} +1 -1
  38. package/dist/assets/{kiosk-mode-sfaqwl5N.js → kiosk-mode-CyYnV3_y.js} +1 -1
  39. package/dist/assets/{layout-CVg460UU.js → layout-ChW1-odP.js} +4 -4
  40. package/dist/assets/{logs-panel-Bs7u1Wfd.js → logs-panel-CiP_30S4.js} +1 -1
  41. package/dist/assets/{markdown-renderer-CGZTB2Dx.js → markdown-renderer-C1yypOYF.js} +1 -1
  42. package/dist/assets/{name-cell-input-D4k4IMJD.js → name-cell-input-CIkFEB6-.js} +1 -1
  43. package/dist/assets/{outline-panel-5sRz-QR2.js → outline-panel-BfysapqU.js} +1 -1
  44. package/dist/assets/{packages-panel-DhXpwKjz.js → packages-panel-BYm2thcs.js} +1 -1
  45. package/dist/assets/{panels-C3XyfWZa.js → panels-hLpsLawB.js} +1 -1
  46. package/dist/assets/{process-output-CRIsE74Q.js → process-output-BIlXY0iE.js} +1 -1
  47. package/dist/assets/{radio-group-Czn6pjhm.js → radio-group-BaOG2bSA.js} +1 -1
  48. package/dist/assets/{readonly-python-code-DtUWOxnZ.js → readonly-python-code-CNyK8G1T.js} +1 -1
  49. package/dist/assets/{reveal-component-DDZ2IxNS.js → reveal-component-D0boNLsp.js} +1 -1
  50. package/dist/assets/{run-page-K4C80Bqk.js → run-page-B0OR2l0l.js} +1 -1
  51. package/dist/assets/{scratchpad-panel-Cwl5E8lN.js → scratchpad-panel-Di7uCP6T.js} +1 -1
  52. package/dist/assets/{session-panel-DGjSy-dF.js → session-panel-D6GA7GoC.js} +1 -1
  53. package/dist/assets/{snippets-panel-94zH2JCj.js → snippets-panel-DV2ir7q8.js} +1 -1
  54. package/dist/assets/{state-ClDZE-YW.js → state-B3ypjIx-.js} +1 -1
  55. package/dist/assets/state-DD6m9X2h.js +3 -0
  56. package/dist/assets/{textarea-Dz09niIv.js → textarea-BM7hAwR3.js} +1 -1
  57. package/dist/assets/{tracing-C_GaBGFx.js → tracing-DwjgsPkU.js} +1 -1
  58. package/dist/assets/{tracing-panel-BkzzwM_5.js → tracing-panel-BS9eUNK_.js} +2 -2
  59. package/dist/assets/{tree-actions-CesD4Rcl.js → tree-actions-lVyJAYy7.js} +1 -1
  60. package/dist/assets/{useCellActionButton-DNYd1sgZ.js → useCellActionButton-B88iHApv.js} +1 -1
  61. package/dist/assets/{useDeleteCell-CCCMHD2a.js → useDeleteCell-CXc93le9.js} +1 -1
  62. package/dist/assets/{useDependencyPanelTab-P57LIkal.js → useDependencyPanelTab-9Vnr8-OR.js} +1 -1
  63. package/dist/assets/{useNotebookActions-B8xsvWwy.js → useNotebookActions-DSfevQ7S.js} +1 -1
  64. package/dist/assets/{useRunCells-DFXV3Rm5.js → useRunCells-DNaOKKqW.js} +1 -1
  65. package/dist/assets/{useSplitCell-R-0wFhnd.js → useSplitCell-IsXuVcLF.js} +1 -1
  66. package/dist/index.html +23 -23
  67. package/package.json +1 -1
  68. package/src/components/data-table/TableBottomBar.tsx +4 -1
  69. package/src/components/data-table/data-table.tsx +26 -17
  70. package/src/components/data-table/utils.ts +1 -4
  71. package/src/components/editor/ai/__tests__/completion-utils.test.ts +48 -2
  72. package/src/components/editor/ai/completion-utils.ts +54 -36
  73. package/src/components/editor/app-container.tsx +3 -1
  74. package/src/components/editor/output/ImageOutput.tsx +12 -3
  75. package/src/components/editor/renderers/vertical-layout/vertical-layout-wrapper.tsx +2 -2
  76. package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +67 -0
  77. package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +47 -0
  78. package/src/core/codemirror/go-to-definition/commands.ts +47 -30
  79. package/src/core/codemirror/go-to-definition/utils.ts +0 -1
  80. package/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts +54 -0
  81. package/src/core/codemirror/reactive-references/analyzer.ts +44 -35
  82. package/src/core/islands/__tests__/bridge.test.ts +25 -0
  83. package/src/core/islands/__tests__/parse.test.ts +585 -1
  84. package/src/core/islands/__tests__/test-utils.tsx +10 -1
  85. package/src/core/islands/bridge.ts +6 -1
  86. package/src/core/islands/constants.ts +2 -0
  87. package/src/core/islands/parse.ts +290 -13
  88. package/src/plugins/impl/DataTablePlugin.tsx +20 -1
  89. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +141 -1
  90. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +54 -4
  91. package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +104 -1
  92. package/src/plugins/impl/anywidget/__tests__/model.test.ts +19 -0
  93. package/src/plugins/impl/anywidget/model.ts +15 -0
  94. package/src/utils/__tests__/records.test.ts +27 -0
  95. package/src/utils/records.ts +12 -0
  96. package/dist/assets/JsonOutput-CxKHBYIA.js +0 -53
  97. package/dist/assets/index-CrgYGp5w.js +0 -38
  98. package/dist/assets/state-CzwQl1aE.js +0 -3
@@ -1,4 +1,4 @@
1
- var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as ne}from"./chunk-LvLJmgfZ.js";import{u as Ze}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{D as Je,Qn as y,jt as ce}from"./cells-BidbgSuB.js";import{D as M,P as _,R as u,T as D,_ as ae,i as Ye,k as w,m as Xe}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as et}from"./useEventListener-BakX-tnw.js";import{c as tt}from"./utils-Dev6I_Kv.js";import{t as G}from"./cn-X2M2usMq.js";import{t as st}from"./jsx-runtime-PbYoItBR.js";import{a as rt,c as ie,o as le,s as ot}from"./popover-DMNO6Poc.js";import{c as nt,i as ct,n as at,r as it,s as lt,t as dt}from"./select-Cjly7tmx.js";import{a as J,c as de,o as pt,p as ht,r as mt,t as ut}from"./dropdown-menu-DfGLyCbP.js";import{t as Y}from"./button-BF7GSjhW.js";import{l as bt}from"./arrays-DWxvyYxP.js";import{r as U}from"./strings-DvZlHYnD.js";import{t as ft}from"./createLucideIcon-BTp1tQDO.js";import{t as gt}from"./circle-plus-BIy1BGHw.js";import{t as yt}from"./database-zap-DIlSqcdp.js";import{c,o as _t,t as wt,u as St}from"./form-DgnBiuvP.js";import{n as xt}from"./DeferredRequestRegistry-EP9ZArpv.js";import{o as kt,r as vt}from"./input-b2KTOk0X.js";import{a as $t,c as jt,d as Ct,g as At,l as Tt,o as Rt,p as Lt,s as Dt,u as It}from"./textarea-Dz09niIv.js";import{r as Pt}from"./useTheme-CWoNQwFz.js";import{a as qt,c as Nt,l as Ft,n as Et,r as Bt,t as Ot}from"./dialog-Dr_Y1zNi.js";import{n as Mt}from"./ImperativeModal-MQnbMIO2.js";import{t as V}from"./links-DK7te6sJ.js";import{t as Ut}from"./useIframeCapabilities-DuGyzPVb.js";import{r as Kt}from"./html-to-image-TCtIotr9.js";import{o as Ht}from"./focus-CocfMydm.js";import{n as Wt}from"./useAsyncData-CT1LpOBD.js";import{n as zt,t as Gt}from"./azure-B42ls0Ui.js";import{t as Vt}from"./request-registry-unC7eRnq.js";import{n as Zt,t as Qt}from"./write-secret-modal-qfcjtCvk.js";import{t as Jt}from"./github-BQ8If5nZ.js";var X=ft("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Or(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Yt=B(),N=ne(Qe(),1),n=ne(st(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:et.NOOP});const Xt=()=>(0,N.use)(he),es=t=>{let e=(0,Yt.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:r,isPending:d,error:i,refetch:a}=Wt(ns,o),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==i||e[6]!==d||e[7]!==a||e[8]!==l||e[9]!==p?(h={secretKeys:l,providerNames:p,loading:d,error:i,refreshSecrets:a},e[5]=i,e[6]=d,e[7]=a,e[8]=l,e[9]=p,e[10]=h):h=e[10];let f;return e[11]!==s||e[12]!==h?(f=(0,n.jsx)(he,{value:h,children:s}),e[11]=s,e[12]=h,e[13]=f):f=e[13],f},ts={isMatch:t=>{if(t instanceof ae||t instanceof Xe){let{optionRegex:e}=c.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:r,refreshSecrets:d}=Xt(),{openModal:i,closeModal:a}=Mt(),{label:l,description:p,optionRegex:h=""}=c.parse(t.description||""),[f,b]=bt(o,m=>new RegExp(h,"i").test(m));return(0,n.jsx)(jt,{control:e.control,name:s,render:({field:m})=>(0,n.jsxs)(Tt,{children:[(0,n.jsx)(It,{children:l}),(0,n.jsx)(Rt,{children:p}),(0,n.jsx)($t,{children:(0,n.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,n.jsx)(vt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,n.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,n.jsxs)(ut,{children:[(0,n.jsx)(ht,{asChild:!0,children:(0,n.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,n.jsx)(xt,{className:"h-3 w-3"})})}),(0,n.jsxs)(mt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,n.jsxs)(J,{onSelect:()=>{i((0,n.jsx)(Qt,{providerNames:r,onSuccess:g=>{d(),m.onChange(te(g)),a()},onClose:a}))},children:[(0,n.jsx)(gt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(de,{}),(0,n.jsx)(pt,{children:"Recommended"})]}),f.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g)),b.length>0&&(0,n.jsx)(de,{}),b.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g))]})]})]})}),(0,n.jsx)(Ct,{})]})})}};function ss(t){return t.provider!=="env"}function rs(t){return t.name}function os(t){return t.keys}async function ns(){let t=await Vt.request({}),e=Zt(t.secrets).filter(ss).map(rs);return{secretKeys:t.secrets.flatMap(os).toSorted(),providerNames:e}}var H=B(),cs=[ts];const se=t=>{let e=(0,H.c)(2),{children:s}=t,o;return e[0]===s?o=e[1]:(o=(0,n.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=o),o},re=t=>{let e=(0,H.c)(9),{name:s,color:o,icon:r,onSelect:d}=t,i;e[0]===o?i=e[1]:(i={backgroundColor:o},e[0]=o,e[1]=i);let a;e[2]===s?a=e[3]:(a=(0,n.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==a?(l=(0,n.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,a]}),e[4]=r,e[5]=d,e[6]=i,e[7]=a,e[8]=l):l=e[8],l},as=t=>{let e=(0,H.c)(25),{onBack:s,isValid:o,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:a,libraryLabel:l}=t,p=l===void 0?"Preferred library":l,h;e[0]===s?h=e[1]:(h=(0,n.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let f=!o,b;e[2]===f?b=e[3]:(b=(0,n.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==h||e[5]!==b?(m=(0,n.jsxs)("div",{className:"flex gap-2",children:[h,b]}),e[4]=h,e[5]=b,e[6]=m):m=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)(lt,{children:(0,n.jsx)(nt,{placeholder:"Select a library"})}),e[7]=g):g=e[7];let S;e[8]===p?S=e[9]:(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[g,(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let $;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=R=>(0,n.jsx)(ct,{value:R,children:a[R]??R},R),e[13]=a,e[14]=j),$=r.map(j),e[10]=a,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,n.jsx)(at,{children:(0,n.jsx)(it,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==S||e[20]!==x?(v=(0,n.jsx)("div",{children:(0,n.jsxs)(dt,{value:d,onValueChange:i,children:[S,x]})}),e[17]=i,e[18]=d,e[19]=S,e[20]=x,e[21]=v):v=e[21];let C;return e[22]!==v||e[23]!==m?(C=(0,n.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=C):C=e[24],C};function is(){let t=(0,H.c)(4),{createNewCell:e}=Je(),s=Ht(),o=Ze(tt),r;return t[0]!==o||t[1]!==e||t[2]!==s?(r=d=>{/\bmo\./.test(d)&&Kt({autoInstantiate:o,createNewCell:e,fromCellId:s}),e({code:d,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:o,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:a,onSubmit:l,onBack:p}=t,h;e[0]===s?h=e[1]:(h=_t(s),e[0]=s,e[1]=h);let f=h,b;e[2]===s?b=e[3]:(b=Lt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let g=At(m),[S,$]=N.useState(r),x=is(),v;e[7]!==a||e[8]!==x||e[9]!==l||e[10]!==S?(v=ze=>{x(a(ze,S)),l()},e[7]=a,e[8]=x,e[9]=l,e[10]=S,e[11]=v):v=e[11];let C=v,j;e[12]!==g||e[13]!==C?(j=g.handleSubmit(C),e[12]=g,e[13]=C,e[14]=j):j=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=(0,n.jsx)(Dt,{}),e[15]=R):R=e[15];let F;e[16]!==g||e[17]!==s?(F=(0,n.jsx)(es,{children:(0,n.jsx)(wt,{schema:s,form:g,renderers:cs,children:R})}),e[16]=g,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==g.formState.isValid||e[21]!==o||e[22]!==i||e[23]!==p||e[24]!==S?(E=(0,n.jsx)(as,{onBack:p,isValid:g.formState.isValid,libraries:o,preferredLibrary:S,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=g.formState.isValid,e[21]=o,e[22]=i,e[23]=p,e[24]=S,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,n.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=W):W=e[29],W};function I(){return u().optional().describe(c.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(c.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(c.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function oe(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(c.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(c.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function A(){return u().describe(c.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function ls(){return u().describe(c.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function T(){return u().nonempty().describe(c.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Ye().describe(c.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(c.of({label:"Read Only"}))}const be=_({type:w("postgres"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),fe=_({type:w("mysql"),host:L(),port:P(3306),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),ge=_({type:w("sqlite"),database:A().describe(c.of({label:"Database Path"}))}).describe(c.of({direction:"two-columns"})),ye=_({type:w("duckdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),_e=_({type:w("motherduck"),database:A().default("my_db").describe(c.of({label:"Database Name"})),token:Z()}).describe(c.of({direction:"two-columns"})),we=_({type:w("snowflake"),account:u().nonempty().describe(c.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(c.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:A(),schema:u().optional().describe(c.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(c.of({label:"Role"})),authType:M("type",[_({type:w("Password"),username:T(),password:I(),enable_mfa:D().default(!1).describe(c.of({label:"Enable MFA (Duo Push)"}))}),_({type:w("SSO (Browser)"),username:T()}),_({type:w("Key Pair"),username:T(),private_key_path:u().nonempty().describe(c.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(c.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),_({type:w("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(c.of({special:"tabs"}))}).describe(c.of({direction:"two-columns"})),Se=_({type:w("bigquery"),project:u().nonempty().describe(c.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(c.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(c.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(c.of({direction:"two-columns"})),xe=_({type:w("clickhouse_connect"),host:L(),port:P(8123).optional(),username:T(),password:I(),secure:D().default(!1).describe(c.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(c.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(c.of({direction:"two-columns"})),ke=_({type:w("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:T().default("default"),password:I().default("")}).describe(c.of({direction:"two-columns"})),ve=_({type:w("chdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),$e=_({type:w("trino"),host:L(),port:P(8080),database:A(),schema:ls().optional(),username:T(),password:I(),async_support:D().default(!1).describe(c.of({label:"Async Support"}))}).describe(c.of({direction:"two-columns"})),je=_({type:w("iceberg"),name:u().describe(c.of({label:"Catalog Name"})),catalog:M("type",[_({type:w("REST"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),_({type:w("SQL"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),_({type:w("Hive"),warehouse:Q(),uri:oe()}),_({type:w("Glue"),warehouse:Q(),uri:oe()}),_({type:w("DynamoDB"),"dynamodb.profile-name":u().optional().describe(c.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(c.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(c.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(c.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(c.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(c.of({special:"tabs"}))}),Ce=_({type:w("datafusion"),sessionContext:D().optional().describe(c.of({label:"Use Session Context"}))}),Ae=_({type:w("pyspark"),host:L().optional(),port:P().optional()}),Te=_({type:w("redshift"),host:L(),port:P(5439),connectionType:M("type",[_({type:w("IAM credentials"),region:u().describe(c.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(c.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(c.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(c.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),_({type:w("DB credentials"),user:T(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:A()}).describe(c.of({direction:"two-columns"})),Re=_({type:w("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:oe("HTTP Path",!0),catalog:u().optional().describe(c.of({label:"Catalog"})),schema:u().optional().describe(c.of({label:"Schema"}))}).describe(c.of({direction:"two-columns"})),Le=_({type:w("supabase"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),disable_client_pooling:D().default(!1).describe(c.of({label:"Disable Client-Side Pooling"}))}).describe(c.of({direction:"two-columns"})),ds=M("type",[be,fe,ge,ye,_e,we,Se,xe,ke,ve,$e,je,Ce,Ae,Te,Re,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},ps=t=>`_${t}`,hs=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=ps(t),K(e)){let o=pe(e),r=s?`os.environ.get("${o}", "${s}")`:`os.environ.get("${o}")`;return this.secrets[t]=r,t}if(s!=null){let o=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=o,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let o=this.print(t,e,s);return o.startsWith('"')&&o.endsWith('"')?o.slice(1,-1):`{${o}}`}printPassword(t,e,s,o){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(o||"password",t):r(o||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
1
+ var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as ne}from"./chunk-LvLJmgfZ.js";import{u as Ze}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{D as Je,Qn as y,jt as ce}from"./cells-06TDmJ8V.js";import{D as M,P as _,R as u,T as D,_ as ae,i as Ye,k as w,m as Xe}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as et}from"./useEventListener-BakX-tnw.js";import{c as tt}from"./utils-Dev6I_Kv.js";import{t as G}from"./cn-X2M2usMq.js";import{t as st}from"./jsx-runtime-PbYoItBR.js";import{a as rt,c as ie,o as le,s as ot}from"./popover-DMNO6Poc.js";import{c as nt,i as ct,n as at,r as it,s as lt,t as dt}from"./select-Cjly7tmx.js";import{a as J,c as de,o as pt,p as ht,r as mt,t as ut}from"./dropdown-menu-DfGLyCbP.js";import{t as Y}from"./button-BF7GSjhW.js";import{l as bt}from"./arrays-DWxvyYxP.js";import{r as U}from"./strings-DvZlHYnD.js";import{t as ft}from"./createLucideIcon-BTp1tQDO.js";import{t as gt}from"./circle-plus-BIy1BGHw.js";import{t as yt}from"./database-zap-DIlSqcdp.js";import{c,o as _t,t as wt,u as St}from"./form-pEJO4Mq_.js";import{n as xt}from"./DeferredRequestRegistry-EP9ZArpv.js";import{o as kt,r as vt}from"./input-b2KTOk0X.js";import{a as $t,c as jt,d as Ct,g as At,l as Tt,o as Rt,p as Lt,s as Dt,u as It}from"./textarea-BM7hAwR3.js";import{r as Pt}from"./useTheme-CWoNQwFz.js";import{a as qt,c as Nt,l as Ft,n as Et,r as Bt,t as Ot}from"./dialog-Dr_Y1zNi.js";import{n as Mt}from"./ImperativeModal-MQnbMIO2.js";import{t as V}from"./links-DK7te6sJ.js";import{t as Ut}from"./useIframeCapabilities-DuGyzPVb.js";import{r as Kt}from"./html-to-image-CbQeOjEJ.js";import{o as Ht}from"./focus-DqhVePQT.js";import{n as Wt}from"./useAsyncData-CT1LpOBD.js";import{n as zt,t as Gt}from"./azure-B42ls0Ui.js";import{t as Vt}from"./request-registry-unC7eRnq.js";import{n as Zt,t as Qt}from"./write-secret-modal-qfcjtCvk.js";import{t as Jt}from"./github-BQ8If5nZ.js";var X=ft("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Or(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Yt=B(),N=ne(Qe(),1),n=ne(st(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:et.NOOP});const Xt=()=>(0,N.use)(he),es=t=>{let e=(0,Yt.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:r,isPending:d,error:i,refetch:a}=Wt(ns,o),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==i||e[6]!==d||e[7]!==a||e[8]!==l||e[9]!==p?(h={secretKeys:l,providerNames:p,loading:d,error:i,refreshSecrets:a},e[5]=i,e[6]=d,e[7]=a,e[8]=l,e[9]=p,e[10]=h):h=e[10];let f;return e[11]!==s||e[12]!==h?(f=(0,n.jsx)(he,{value:h,children:s}),e[11]=s,e[12]=h,e[13]=f):f=e[13],f},ts={isMatch:t=>{if(t instanceof ae||t instanceof Xe){let{optionRegex:e}=c.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:r,refreshSecrets:d}=Xt(),{openModal:i,closeModal:a}=Mt(),{label:l,description:p,optionRegex:h=""}=c.parse(t.description||""),[f,b]=bt(o,m=>new RegExp(h,"i").test(m));return(0,n.jsx)(jt,{control:e.control,name:s,render:({field:m})=>(0,n.jsxs)(Tt,{children:[(0,n.jsx)(It,{children:l}),(0,n.jsx)(Rt,{children:p}),(0,n.jsx)($t,{children:(0,n.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,n.jsx)(vt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,n.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,n.jsxs)(ut,{children:[(0,n.jsx)(ht,{asChild:!0,children:(0,n.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,n.jsx)(xt,{className:"h-3 w-3"})})}),(0,n.jsxs)(mt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,n.jsxs)(J,{onSelect:()=>{i((0,n.jsx)(Qt,{providerNames:r,onSuccess:g=>{d(),m.onChange(te(g)),a()},onClose:a}))},children:[(0,n.jsx)(gt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(de,{}),(0,n.jsx)(pt,{children:"Recommended"})]}),f.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g)),b.length>0&&(0,n.jsx)(de,{}),b.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g))]})]})]})}),(0,n.jsx)(Ct,{})]})})}};function ss(t){return t.provider!=="env"}function rs(t){return t.name}function os(t){return t.keys}async function ns(){let t=await Vt.request({}),e=Zt(t.secrets).filter(ss).map(rs);return{secretKeys:t.secrets.flatMap(os).toSorted(),providerNames:e}}var H=B(),cs=[ts];const se=t=>{let e=(0,H.c)(2),{children:s}=t,o;return e[0]===s?o=e[1]:(o=(0,n.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=o),o},re=t=>{let e=(0,H.c)(9),{name:s,color:o,icon:r,onSelect:d}=t,i;e[0]===o?i=e[1]:(i={backgroundColor:o},e[0]=o,e[1]=i);let a;e[2]===s?a=e[3]:(a=(0,n.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==a?(l=(0,n.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,a]}),e[4]=r,e[5]=d,e[6]=i,e[7]=a,e[8]=l):l=e[8],l},as=t=>{let e=(0,H.c)(25),{onBack:s,isValid:o,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:a,libraryLabel:l}=t,p=l===void 0?"Preferred library":l,h;e[0]===s?h=e[1]:(h=(0,n.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let f=!o,b;e[2]===f?b=e[3]:(b=(0,n.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==h||e[5]!==b?(m=(0,n.jsxs)("div",{className:"flex gap-2",children:[h,b]}),e[4]=h,e[5]=b,e[6]=m):m=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)(lt,{children:(0,n.jsx)(nt,{placeholder:"Select a library"})}),e[7]=g):g=e[7];let S;e[8]===p?S=e[9]:(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[g,(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let $;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=R=>(0,n.jsx)(ct,{value:R,children:a[R]??R},R),e[13]=a,e[14]=j),$=r.map(j),e[10]=a,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,n.jsx)(at,{children:(0,n.jsx)(it,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==S||e[20]!==x?(v=(0,n.jsx)("div",{children:(0,n.jsxs)(dt,{value:d,onValueChange:i,children:[S,x]})}),e[17]=i,e[18]=d,e[19]=S,e[20]=x,e[21]=v):v=e[21];let C;return e[22]!==v||e[23]!==m?(C=(0,n.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=C):C=e[24],C};function is(){let t=(0,H.c)(4),{createNewCell:e}=Je(),s=Ht(),o=Ze(tt),r;return t[0]!==o||t[1]!==e||t[2]!==s?(r=d=>{/\bmo\./.test(d)&&Kt({autoInstantiate:o,createNewCell:e,fromCellId:s}),e({code:d,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:o,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:a,onSubmit:l,onBack:p}=t,h;e[0]===s?h=e[1]:(h=_t(s),e[0]=s,e[1]=h);let f=h,b;e[2]===s?b=e[3]:(b=Lt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let g=At(m),[S,$]=N.useState(r),x=is(),v;e[7]!==a||e[8]!==x||e[9]!==l||e[10]!==S?(v=ze=>{x(a(ze,S)),l()},e[7]=a,e[8]=x,e[9]=l,e[10]=S,e[11]=v):v=e[11];let C=v,j;e[12]!==g||e[13]!==C?(j=g.handleSubmit(C),e[12]=g,e[13]=C,e[14]=j):j=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=(0,n.jsx)(Dt,{}),e[15]=R):R=e[15];let F;e[16]!==g||e[17]!==s?(F=(0,n.jsx)(es,{children:(0,n.jsx)(wt,{schema:s,form:g,renderers:cs,children:R})}),e[16]=g,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==g.formState.isValid||e[21]!==o||e[22]!==i||e[23]!==p||e[24]!==S?(E=(0,n.jsx)(as,{onBack:p,isValid:g.formState.isValid,libraries:o,preferredLibrary:S,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=g.formState.isValid,e[21]=o,e[22]=i,e[23]=p,e[24]=S,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,n.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=W):W=e[29],W};function I(){return u().optional().describe(c.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(c.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(c.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function oe(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(c.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(c.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function A(){return u().describe(c.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function ls(){return u().describe(c.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function T(){return u().nonempty().describe(c.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Ye().describe(c.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(c.of({label:"Read Only"}))}const be=_({type:w("postgres"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),fe=_({type:w("mysql"),host:L(),port:P(3306),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),ge=_({type:w("sqlite"),database:A().describe(c.of({label:"Database Path"}))}).describe(c.of({direction:"two-columns"})),ye=_({type:w("duckdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),_e=_({type:w("motherduck"),database:A().default("my_db").describe(c.of({label:"Database Name"})),token:Z()}).describe(c.of({direction:"two-columns"})),we=_({type:w("snowflake"),account:u().nonempty().describe(c.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(c.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:A(),schema:u().optional().describe(c.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(c.of({label:"Role"})),authType:M("type",[_({type:w("Password"),username:T(),password:I(),enable_mfa:D().default(!1).describe(c.of({label:"Enable MFA (Duo Push)"}))}),_({type:w("SSO (Browser)"),username:T()}),_({type:w("Key Pair"),username:T(),private_key_path:u().nonempty().describe(c.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(c.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),_({type:w("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(c.of({special:"tabs"}))}).describe(c.of({direction:"two-columns"})),Se=_({type:w("bigquery"),project:u().nonempty().describe(c.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(c.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(c.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(c.of({direction:"two-columns"})),xe=_({type:w("clickhouse_connect"),host:L(),port:P(8123).optional(),username:T(),password:I(),secure:D().default(!1).describe(c.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(c.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(c.of({direction:"two-columns"})),ke=_({type:w("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:T().default("default"),password:I().default("")}).describe(c.of({direction:"two-columns"})),ve=_({type:w("chdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),$e=_({type:w("trino"),host:L(),port:P(8080),database:A(),schema:ls().optional(),username:T(),password:I(),async_support:D().default(!1).describe(c.of({label:"Async Support"}))}).describe(c.of({direction:"two-columns"})),je=_({type:w("iceberg"),name:u().describe(c.of({label:"Catalog Name"})),catalog:M("type",[_({type:w("REST"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),_({type:w("SQL"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),_({type:w("Hive"),warehouse:Q(),uri:oe()}),_({type:w("Glue"),warehouse:Q(),uri:oe()}),_({type:w("DynamoDB"),"dynamodb.profile-name":u().optional().describe(c.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(c.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(c.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(c.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(c.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(c.of({special:"tabs"}))}),Ce=_({type:w("datafusion"),sessionContext:D().optional().describe(c.of({label:"Use Session Context"}))}),Ae=_({type:w("pyspark"),host:L().optional(),port:P().optional()}),Te=_({type:w("redshift"),host:L(),port:P(5439),connectionType:M("type",[_({type:w("IAM credentials"),region:u().describe(c.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(c.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(c.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(c.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),_({type:w("DB credentials"),user:T(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:A()}).describe(c.of({direction:"two-columns"})),Re=_({type:w("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:oe("HTTP Path",!0),catalog:u().optional().describe(c.of({label:"Catalog"})),schema:u().optional().describe(c.of({label:"Schema"}))}).describe(c.of({direction:"two-columns"})),Le=_({type:w("supabase"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),disable_client_pooling:D().default(!1).describe(c.of({label:"Disable Client-Side Pooling"}))}).describe(c.of({direction:"two-columns"})),ds=M("type",[be,fe,ge,ye,_e,we,Se,xe,ke,ve,$e,je,Ce,Ae,Te,Re,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},ps=t=>`_${t}`,hs=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=ps(t),K(e)){let o=pe(e),r=s?`os.environ.get("${o}", "${s}")`:`os.environ.get("${o}")`;return this.secrets[t]=r,t}if(s!=null){let o=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=o,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let o=this.print(t,e,s);return o.startsWith('"')&&o.endsWith('"')?o.slice(1,-1):`{${o}}`}printPassword(t,e,s,o){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(o||"password",t):r(o||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
2
2
  `)}},ms=class extends k{generateImports(){return[]}generateConnectionCode(){let t=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",e=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0);return y(`
3
3
  DATABASE_URL = f"postgresql://${this.secrets.printInFString("username",this.connection.username)}:${e}@${this.secrets.printInFString("host",this.connection.host)}:${this.secrets.printInFString("port",this.connection.port)}/${this.secrets.printInFString("database",this.connection.database)}"
4
4
  engine = ${this.orm}.create_engine(DATABASE_URL${t})
@@ -1,4 +1,4 @@
1
- var mn=Object.defineProperty;var _a=t=>{throw TypeError(t)};var pn=(t,e,a)=>e in t?mn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var B=(t,e,a)=>pn(t,typeof e!="symbol"?e+"":e,a),Dt=(t,e,a)=>e.has(t)||_a("Cannot "+a);var Q=(t,e,a)=>(Dt(t,e,"read from private field"),a?a.call(t):e.get(t)),Re=(t,e,a)=>e.has(t)?_a("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,a),We=(t,e,a,s)=>(Dt(t,e,"write to private field"),s?s.call(t,a):e.set(t,a),a),Se=(t,e,a)=>(Dt(t,e,"access private method"),a);var ba=(t,e,a,s)=>({set _(n){We(t,e,n,a)},get _(){return Q(t,e,s)}});var me,Hs,et,Ft,ct,ut,tt,at,ne,sn,nn,rn,on,ln,dt,Ys;import{s as wa}from"./chunk-LvLJmgfZ.js";import{d as ka,i as st,l as pt,n as oe,p as hn,u as fn}from"./useEvent-D91BmmQi.js";import{t as gn}from"./react-Bj1aDYRI.js";import{Ai as ja,Cr as zt,Fi as yn,In as xn,On as vn,Tn as _n,ji as Na,ur as bn,vr as wn}from"./cells-BidbgSuB.js";import"./react-dom-CSu739Rf.js";import{P as kn,R as Lt}from"./zod-H_cgTO0M.js";import{t as _e}from"./compiler-runtime-B3qBwwSJ.js";import{J as jn,X as Sa,d as ht}from"./ai-model-dropdown-BW60s6ul.js";import{_ as Ke,m as Nn,v as Ca}from"./useEventListener-BakX-tnw.js";import{t as ye}from"./cn-X2M2usMq.js";import{t as Sn}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-BXI8V5i6.js";import{a as Cn,i as In,n as Tn,r as An}from"./multi-map-9ogswH46.js";import{i as Ia,r as Ta,t as Aa}from"./popover-DMNO6Poc.js";import{a as Ra,i as Ma,n as Oa,r as Ea,s as Za,t as Pa}from"./select-Cjly7tmx.js";import{a as Rn,d as Mn,f as On,p as En,r as Zn,s as Pn,t as $n,u as Fn}from"./dropdown-menu-DfGLyCbP.js";import{Y as $a,t as Fa}from"./JsonOutput-CxKHBYIA.js";import"./download-DgEarSps.js";import{i as Dn,t as zn}from"./tooltip-CgQpRVyN.js";import{t as le}from"./button-BF7GSjhW.js";import{st as Ln}from"./dist-Dez1I5M9.js";import{p as Un}from"./arrays-DWxvyYxP.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{i as qn,n as Ut,t as Wn}from"./strings-DvZlHYnD.js";import{r as Vn}from"./requests-KshNNAOp.js";import{t as Je}from"./createLucideIcon-BTp1tQDO.js";import{t as Bn}from"./fileToBase64-Doh9J-g6.js";import{t as ft}from"./bot-message-square-AslRbAeb.js";import{r as Kn,t as Da}from"./x-9vLEgLY6.js";import{t as za}from"./markdown-renderer-CGZTB2Dx.js";import{T as Jn,V as Hn,c as Yn,d as Gn,k as Qn,n as Xn,s as er,u as tr,y as ar}from"./add-cell-with-ai-DWNUMbns.js";import{n as sr,t as nr}from"./file-headphone-CUN2DC78.js";import{t as rr}from"./file-BvoBtS_V.js";import{n as ir,t as qt}from"./spinner-DTBVbtl-.js";import{t as or}from"./refresh-cw-DcEasnos.js";import{t as La}from"./rotate-ccw-CBXqO1Fd.js";import{c as lr}from"./MarimoErrorOutput-G8Q8ZYoi.js";import{c as dr}from"./datasource-DI-YUWev.js";import{t as cr}from"./badge-CFAaMy0O.js";import"./dist-DHMtQYxT.js";import"./dist-Bj9Iedc0.js";import"./dist-D-o1OXc9.js";import"./dist-BZhJ1bTM.js";import"./dist-DnIl7RU-.js";import{t as ur}from"./uuid-BukULOeS.js";import{t as gt}from"./use-toast-BH8bU9Xf.js";import{n as Ua,t as mr}from"./paths-kNeJ8nbe.js";import"./session-B6_8umQX.js";import{r as pr}from"./useTheme-CWoNQwFz.js";import"./purify.es-DdxMtdqK.js";import"./dates-CnrjjcMO.js";import{t as hr}from"./copy-icon-BCIGtBo0.js";import"./utils-BIlJBJIu.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{n as fr}from"./error-banner-C4DZksWV.js";import"./chunk-5FQGJX7Z-C6VN0dQj.js";import"./html-to-image-TCtIotr9.js";import"./react-resizable-panels.browser.esm-CgWOEYeG.js";import{t as gr}from"./esm-DSv-aO_T.js";import{n as yr}from"./dist-BM-OLiKa.js";import{t as qa}from"./empty-state-vKu4k0Y4.js";import{t as xr}from"./state-RnIztwr-.js";var vr=Je("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),_r=Je("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]),br=Je("file-video-camera",[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 17.843 3.033-1.755a.64.64 0 0 1 .967.56v4.704a.65.65 0 0 1-.967.56L10 20.157",key:"17aeo9"}],["rect",{width:"7",height:"6",x:"3",y:"16",rx:"1",key:"s27ndx"}]]),wr=Je("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),nt=Je("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Wt=Je("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),U;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function a(n){throw Error()}t.assertNever=a,t.arrayToEnum=n=>{let i={};for(let r of n)i[r]=r;return i},t.getValidEnumValues=n=>{let i=t.objectKeys(n).filter(l=>typeof n[n[l]]!="number"),r={};for(let l of i)r[l]=n[l];return t.objectValues(r)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&i.push(r);return i},t.find=(n,i)=>{for(let r of n)if(i(r))return r},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,i=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(i)}t.joinValues=s,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(U||(U={}));var kr;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(kr||(kr={}));const N=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$e=t=>{switch(typeof t){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(t)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(t)?N.array:t===null?N.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?N.promise:typeof Map<"u"&&t instanceof Map?N.map:typeof Set<"u"&&t instanceof Set?N.set:typeof Date<"u"&&t instanceof Date?N.date:N.object;default:return N.unknown}},g=U.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"]);var xe=class Gs 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]};let a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){let a=e||function(i){return i.message},s={_errors:[]},n=i=>{for(let r of i.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)s._errors.push(a(r));else{let l=s,d=0;for(;d<r.path.length;){let c=r.path[d];d===r.path.length-1?(l[c]=l[c]||{_errors:[]},l[c]._errors.push(a(r))):l[c]=l[c]||{_errors:[]},l=l[c],d++}}};return n(this),s}static assert(e){if(!(e instanceof Gs))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){let a={},s=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];a[i]=a[i]||[],a[i].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}};xe.create=t=>new xe(t);var rt=(t,e)=>{let a;switch(t.code){case g.invalid_type:a=t.received===N.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case g.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,U.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:a=`Unrecognized key(s) in object: ${U.joinValues(t.keys,", ")}`;break;case g.invalid_union:a="Invalid input";break;case g.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${U.joinValues(t.options)}`;break;case g.invalid_enum_value:a=`Invalid enum value. Expected ${U.joinValues(t.options)}, received '${t.received}'`;break;case g.invalid_arguments:a="Invalid function arguments";break;case g.invalid_return_type:a="Invalid function return type";break;case g.invalid_date:a="Invalid date";break;case g.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:U.assertNever(t.validation):a=t.validation==="regex"?"Invalid":`Invalid ${t.validation}`;break;case g.too_small:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"||t.type==="bigint"?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case g.too_big:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case g.custom:a="Invalid input";break;case g.invalid_intersection_types:a="Intersection results could not be merged";break;case g.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case g.not_finite:a="Number must be finite";break;default:a=e.defaultError,U.assertNever(t)}return{message:a}},jr=rt;function Vt(){return jr}const Bt=t=>{let{data:e,path:a,errorMaps:s,issueData:n}=t,i=[...a,...n.path||[]],r={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let l="",d=s.filter(c=>!!c).slice().reverse();for(let c of d)l=c(r,{data:e,defaultError:l}).message;return{...n,path:i,message:l}};function k(t,e){let a=Vt(),s=Bt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===rt?void 0:rt].filter(n=>!!n)});t.common.issues.push(s)}var ge=class Qs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,a){let s=[];for(let n of a){if(n.status==="aborted")return E;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,a){let s=[];for(let n of a){let i=await n.key,r=await n.value;s.push({key:i,value:r})}return Qs.mergeObjectSync(e,s)}static mergeObjectSync(e,a){let s={};for(let n of a){let{key:i,value:r}=n;if(i.status==="aborted"||r.status==="aborted")return E;i.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(r.value!==void 0||n.alwaysSet)&&(s[i.value]=r.value)}return{status:e.value,value:s}}};const E=Object.freeze({status:"aborted"}),Kt=t=>({status:"dirty",value:t}),ue=t=>({status:"valid",value:t}),Wa=t=>t.status==="aborted",Va=t=>t.status==="dirty",He=t=>t.status==="valid",yt=t=>typeof Promise<"u"&&t instanceof Promise;var T;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(T||(T={}));var Ce=class{constructor(t,e,a,s){this._cachedPath=[],this.parent=t,this.data=e,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ba=(t,e)=>{if(He(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){return this._error||(this._error=new xe(t.common.issues)),this._error}}};function $(t){if(!t)return{};let{errorMap:e,invalid_type_error:a,required_error:s,description:n}=t;if(e&&(a||s))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,r)=>{let{message:l}=t;return i.code==="invalid_enum_value"?{message:l??r.defaultError}:r.data===void 0?{message:l??s??r.defaultError}:i.code==="invalid_type"?{message:l??a??r.defaultError}:{message:r.defaultError}},description:n}}var D=class{get description(){return this._def.description}_getType(t){return $e(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:$e(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ge,ctx:{common:t.parent.common,data:t.data,parsedType:$e(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(yt(e))throw Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let a=this.safeParse(t,e);if(a.success)return a.data;throw a.error}safeParse(t,e){let a={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)};return Ba(a,this._parseSync({data:t,path:a.path,parent:a}))}"~validate"(t){var a,s;let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:e});return He(n)?{value:n.value}:{issues:e.common.issues}}catch(n){(s=(a=n==null?void 0:n.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(n=>He(n)?{value:n.value}:{issues:e.common.issues})}async parseAsync(t,e){let a=await this.safeParseAsync(t,e);if(a.success)return a.data;throw a.error}async safeParseAsync(t,e){let a={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)},s=this._parse({data:t,path:a.path,parent:a});return Ba(a,await(yt(s)?s:Promise.resolve(s)))}refine(t,e){let a=s=>typeof e=="string"||e===void 0?{message:e}:typeof e=="function"?e(s):e;return this._refinement((s,n)=>{let i=t(s),r=()=>n.addIssue({code:g.custom,...a(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(r(),!1)):i?!0:(r(),!1)})}refinement(t,e){return this._refinement((a,s)=>t(a)?!0:(s.addIssue(typeof e=="function"?e(a,s):e),!1))}_refinement(t){return new Me({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Oe.create(this,this._def)}nullable(){return Be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ge.create(this)}promise(){return it.create(this,this._def)}or(t){return bt.create([this,t],this._def)}and(t){return wt.create(this,t,this._def)}transform(t){return new Me({...$(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new Ct({...$(this._def),innerType:this,defaultValue:e,typeName:Z.ZodDefault})}brand(){return new Ga({typeName:Z.ZodBranded,type:this,...$(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new It({...$(this._def),innerType:this,catchValue:e,typeName:Z.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Qa.create(this,t)}readonly(){return Tt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nr=/^c[^\s-]{8,}$/i,Sr=/^[0-9a-z]+$/,Cr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ir=/^[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}$/i,Tr=/^[a-z0-9_-]{21}$/i,Ar=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Or="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ka,Er=/^(?:(?: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])$/,Zr=/^(?:(?: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])$/,Pr=/^(([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]))$/,$r=/^(([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])$/,Fr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ja="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",zr=RegExp(`^${Ja}$`);function Ha(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision??(e=`${e}(\\.\\d+)?`);let a=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${a}`}function Lr(t){return RegExp(`^${Ha(t)}$`)}function Ur(t){let e=`${Ja}T${Ha(t)}`,a=[];return a.push(t.local?"Z?":"Z"),t.offset&&a.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${a.join("|")})`,RegExp(`^${e}$`)}function qr(t,e){return!!((e==="v4"||!e)&&Er.test(t)||(e==="v6"||!e)&&Pr.test(t))}function Wr(t,e){if(!Ar.test(t))return!1;try{let[a]=t.split(".");if(!a)return!1;let s=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||!n||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Vr(t,e){return!!((e==="v4"||!e)&&Zr.test(t)||(e==="v6"||!e)&&$r.test(t))}var xt=class lt extends D{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.string,received:n.parsedType}),E}let a=new ge,s;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if(n.kind==="length"){let i=e.data.length>n.value,r=e.data.length<n.value;(i||r)&&(s=this._getOrReturnCtx(e,s),i?k(s,{code:g.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&k(s,{code:g.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),a.dirty())}else if(n.kind==="email")Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"email",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="emoji")Ka||(Ka=new RegExp(Or,"u")),Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"emoji",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="uuid")Ir.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"uuid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="nanoid")Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"nanoid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="cuid")Nr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cuid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="cuid2")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cuid2",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="ulid")Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"ulid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),k(s,{validation:"url",code:g.invalid_string,message:n.message}),a.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"regex",code:g.invalid_string,message:n.message}),a.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),a.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{startsWith:n.value},message:n.message}),a.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{endsWith:n.value},message:n.message}),a.dirty()):n.kind==="datetime"?Ur(n).test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"datetime",message:n.message}),a.dirty()):n.kind==="date"?zr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"date",message:n.message}),a.dirty()):n.kind==="time"?Lr(n).test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"time",message:n.message}),a.dirty()):n.kind==="duration"?Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"duration",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="ip"?qr(e.data,n.version)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"ip",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="jwt"?Wr(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"jwt",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="cidr"?Vr(e.data,n.version)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cidr",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="base64"?Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"base64",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="base64url"?Dr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"base64url",code:g.invalid_string,message:n.message}),a.dirty()):U.assertNever(n);return{status:a.value,value:e.data}}_regex(e,a,s){return this.refinement(n=>e.test(n),{validation:a,code:g.invalid_string,...T.errToObj(s)})}_addCheck(e){return new lt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...T.errToObj(e)})}url(e){return this._addCheck({kind:"url",...T.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...T.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...T.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...T.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...T.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...T.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...T.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...T.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...T.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...T.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...T.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,...T.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...T.errToObj(e)})}regex(e,a){return this._addCheck({kind:"regex",regex:e,...T.errToObj(a)})}includes(e,a){return this._addCheck({kind:"includes",value:e,position:a==null?void 0:a.position,...T.errToObj(a==null?void 0:a.message)})}startsWith(e,a){return this._addCheck({kind:"startsWith",value:e,...T.errToObj(a)})}endsWith(e,a){return this._addCheck({kind:"endsWith",value:e,...T.errToObj(a)})}min(e,a){return this._addCheck({kind:"min",value:e,...T.errToObj(a)})}max(e,a){return this._addCheck({kind:"max",value:e,...T.errToObj(a)})}length(e,a){return this._addCheck({kind:"length",value:e,...T.errToObj(a)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new lt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxLength(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};xt.create=t=>new xt({checks:[],typeName:Z.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...$(t)});function Br(t,e){let a=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=a>s?a:s;return Number.parseInt(t.toFixed(n).replace(".",""))%Number.parseInt(e.toFixed(n).replace(".",""))/10**n}var Jt=class fa extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.number,received:n.parsedType}),E}let a,s=new ge;for(let n of this._def.checks)n.kind==="int"?U.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),k(a,{code:g.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Br(e.data,n.value)!==0&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_finite,message:n.message}),s.dirty()):U.assertNever(n);return{status:s.value,value:e.data}}gte(e,a){return this.setLimit("min",e,!0,T.toString(a))}gt(e,a){return this.setLimit("min",e,!1,T.toString(a))}lte(e,a){return this.setLimit("max",e,!0,T.toString(a))}lt(e,a){return this.setLimit("max",e,!1,T.toString(a))}setLimit(e,a,s,n){return new fa({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:s,message:T.toString(n)}]})}_addCheck(e){return new fa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:T.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(a)})}finite(e){return this._addCheck({kind:"finite",message:T.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:-(2**53-1),message:T.toString(e)})._addCheck({kind:"max",inclusive:!0,value:2**53-1,message:T.toString(e)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&U.isInteger(e.value))}get isFinite(){let e=null,a=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(a===null||s.value>a)&&(a=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(a)&&Number.isFinite(e)}};Jt.create=t=>new Jt({checks:[],typeName:Z.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...$(t)});var Ht=class ga extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==N.bigint)return this._getInvalidInput(e);let a,s=new ge;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):U.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let a=this._getOrReturnCtx(e);return k(a,{code:g.invalid_type,expected:N.bigint,received:a.parsedType}),E}gte(e,a){return this.setLimit("min",e,!0,T.toString(a))}gt(e,a){return this.setLimit("min",e,!1,T.toString(a))}lte(e,a){return this.setLimit("max",e,!0,T.toString(a))}lt(e,a){return this.setLimit("max",e,!1,T.toString(a))}setLimit(e,a,s,n){return new ga({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:s,message:T.toString(n)}]})}_addCheck(e){return new ga({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(a)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};Ht.create=t=>new Ht({checks:[],typeName:Z.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...$(t)});var Yt=class extends D{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==N.boolean){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.boolean,received:e.parsedType}),E}return ue(t.data)}};Yt.create=t=>new Yt({typeName:Z.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...$(t)});var Gt=class Xs extends D{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.date,received:n.parsedType}),E}if(Number.isNaN(e.data.getTime()))return k(this._getOrReturnCtx(e),{code:g.invalid_date}),E;let a=new ge,s;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),a.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),a.dirty()):U.assertNever(n);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xs({...this._def,checks:[...this._def.checks,e]})}min(e,a){return this._addCheck({kind:"min",value:e.getTime(),message:T.toString(a)})}max(e,a){return this._addCheck({kind:"max",value:e.getTime(),message:T.toString(a)})}get minDate(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e==null?null:new Date(e)}};Gt.create=t=>new Gt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Z.ZodDate,...$(t)});var Qt=class extends D{_parse(t){if(this._getType(t)!==N.symbol){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.symbol,received:e.parsedType}),E}return ue(t.data)}};Qt.create=t=>new Qt({typeName:Z.ZodSymbol,...$(t)});var vt=class extends D{_parse(t){if(this._getType(t)!==N.undefined){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.undefined,received:e.parsedType}),E}return ue(t.data)}};vt.create=t=>new vt({typeName:Z.ZodUndefined,...$(t)});var _t=class extends D{_parse(t){if(this._getType(t)!==N.null){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.null,received:e.parsedType}),E}return ue(t.data)}};_t.create=t=>new _t({typeName:Z.ZodNull,...$(t)});var Xt=class extends D{constructor(){super(...arguments),this._any=!0}_parse(t){return ue(t.data)}};Xt.create=t=>new Xt({typeName:Z.ZodAny,...$(t)});var Ye=class extends D{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ue(t.data)}};Ye.create=t=>new Ye({typeName:Z.ZodUnknown,...$(t)});var Fe=class extends D{_parse(t){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.never,received:e.parsedType}),E}};Fe.create=t=>new Fe({typeName:Z.ZodNever,...$(t)});var ea=class extends D{_parse(t){if(this._getType(t)!==N.undefined){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.void,received:e.parsedType}),E}return ue(t.data)}};ea.create=t=>new ea({typeName:Z.ZodVoid,...$(t)});var Ge=class Pt extends D{_parse(e){let{ctx:a,status:s}=this._processInputParams(e),n=this._def;if(a.parsedType!==N.array)return k(a,{code:g.invalid_type,expected:N.array,received:a.parsedType}),E;if(n.exactLength!==null){let r=a.data.length>n.exactLength.value,l=a.data.length<n.exactLength.value;(r||l)&&(k(a,{code:r?g.too_big:g.too_small,minimum:l?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&a.data.length<n.minLength.value&&(k(a,{code:g.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&a.data.length>n.maxLength.value&&(k(a,{code:g.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),a.common.async)return Promise.all([...a.data].map((r,l)=>n.type._parseAsync(new Ce(a,r,a.path,l)))).then(r=>ge.mergeArray(s,r));let i=[...a.data].map((r,l)=>n.type._parseSync(new Ce(a,r,a.path,l)));return ge.mergeArray(s,i)}get element(){return this._def.type}min(e,a){return new Pt({...this._def,minLength:{value:e,message:T.toString(a)}})}max(e,a){return new Pt({...this._def,maxLength:{value:e,message:T.toString(a)}})}length(e,a){return new Pt({...this._def,exactLength:{value:e,message:T.toString(a)}})}nonempty(e){return this.min(1,e)}};Ge.create=(t,e)=>new Ge({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...$(e)});function Qe(t){if(t instanceof be){let e={};for(let a in t.shape){let s=t.shape[a];e[a]=Oe.create(Qe(s))}return new be({...t._def,shape:()=>e})}else return t instanceof Ge?new Ge({...t._def,type:Qe(t.element)}):t instanceof Oe?Oe.create(Qe(t.unwrap())):t instanceof Be?Be.create(Qe(t.unwrap())):t instanceof Ve?Ve.create(t.items.map(e=>Qe(e))):t}var be=class je extends D{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:U.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==N.object){let d=this._getOrReturnCtx(e);return k(d,{code:g.invalid_type,expected:N.object,received:d.parsedType}),E}let{status:a,ctx:s}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),r=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let d in s.data)i.includes(d)||r.push(d);let l=[];for(let d of i){let c=n[d],u=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Ce(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof Fe){let d=this._def.unknownKeys;if(d==="passthrough")for(let c of r)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(d==="strict")r.length>0&&(k(s,{code:g.unrecognized_keys,keys:r}),a.dirty());else if(d!=="strip")throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let c of r){let u=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Ce(s,u,s.path,c)),alwaysSet:c in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let d=[];for(let c of l){let u=await c.key,m=await c.value;d.push({key:u,value:m,alwaysSet:c.alwaysSet})}return d}).then(d=>ge.mergeObjectSync(a,d)):ge.mergeObjectSync(a,l)}get shape(){return this._def.shape()}strict(e){return T.errToObj,new je({...this._def,unknownKeys:"strict",...e===void 0?{}:{errorMap:(a,s)=>{var i,r;let n=((r=(i=this._def).errorMap)==null?void 0:r.call(i,a,s).message)??s.defaultError;return a.code==="unrecognized_keys"?{message:T.errToObj(e).message??n}:{message:n}}}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,a){return this.augment({[e]:a})}catchall(e){return new je({...this._def,catchall:e})}pick(e){let a={};for(let s of U.objectKeys(e))e[s]&&this.shape[s]&&(a[s]=this.shape[s]);return new je({...this._def,shape:()=>a})}omit(e){let a={};for(let s of U.objectKeys(this.shape))e[s]||(a[s]=this.shape[s]);return new je({...this._def,shape:()=>a})}deepPartial(){return Qe(this)}partial(e){let a={};for(let s of U.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?a[s]=n:a[s]=n.optional()}return new je({...this._def,shape:()=>a})}required(e){let a={};for(let s of U.objectKeys(this.shape))if(e&&!e[s])a[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Oe;)n=n._def.innerType;a[s]=n}return new je({...this._def,shape:()=>a})}keyof(){return Ya(U.objectKeys(this.shape))}};be.create=(t,e)=>new be({shape:()=>t,unknownKeys:"strip",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)}),be.strictCreate=(t,e)=>new be({shape:()=>t,unknownKeys:"strict",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)}),be.lazycreate=(t,e)=>new be({shape:t,unknownKeys:"strip",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)});var bt=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=this._def.options;function s(n){for(let r of n)if(r.result.status==="valid")return r.result;for(let r of n)if(r.result.status==="dirty")return e.common.issues.push(...r.ctx.common.issues),r.result;let i=n.map(r=>new xe(r.ctx.common.issues));return k(e,{code:g.invalid_union,unionErrors:i}),E}if(e.common.async)return Promise.all(a.map(async n=>{let i={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(s);{let n,i=[];for(let l of a){let d={...e,common:{...e.common,issues:[]},parent:null},c=l._parseSync({data:e.data,path:e.path,parent:d});if(c.status==="valid")return c;c.status==="dirty"&&!n&&(n={result:c,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;let r=i.map(l=>new xe(l));return k(e,{code:g.invalid_union,unionErrors:r}),E}}get options(){return this._def.options}};bt.create=(t,e)=>new bt({options:t,typeName:Z.ZodUnion,...$(e)});var De=t=>t instanceof kt?De(t.schema):t instanceof Me?De(t.innerType()):t instanceof jt?[t.value]:t instanceof Nt?t.options:t instanceof St?U.objectValues(t.enum):t instanceof Ct?De(t._def.innerType):t instanceof vt?[void 0]:t instanceof _t?[null]:t instanceof Oe?[void 0,...De(t.unwrap())]:t instanceof Be?[null,...De(t.unwrap())]:t instanceof Ga||t instanceof Tt?De(t.unwrap()):t instanceof It?De(t._def.innerType):[],Kr=class en extends D{_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==N.object)return k(a,{code:g.invalid_type,expected:N.object,received:a.parsedType}),E;let s=this.discriminator,n=a.data[s],i=this.optionsMap.get(n);return i?a.common.async?i._parseAsync({data:a.data,path:a.path,parent:a}):i._parseSync({data:a.data,path:a.path,parent:a}):(k(a,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,a,s){let n=new Map;for(let i of a){let r=De(i.shape[e]);if(!r.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let l of r){if(n.has(l))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);n.set(l,i)}}return new en({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:a,optionsMap:n,...$(s)})}};function ta(t,e){let a=$e(t),s=$e(e);if(t===e)return{valid:!0,data:t};if(a===N.object&&s===N.object){let n=U.objectKeys(e),i=U.objectKeys(t).filter(l=>n.indexOf(l)!==-1),r={...t,...e};for(let l of i){let d=ta(t[l],e[l]);if(!d.valid)return{valid:!1};r[l]=d.data}return{valid:!0,data:r}}else if(a===N.array&&s===N.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let r=t[i],l=e[i],d=ta(r,l);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return a===N.date&&s===N.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var wt=class extends D{_parse(t){let{status:e,ctx:a}=this._processInputParams(t),s=(n,i)=>{if(Wa(n)||Wa(i))return E;let r=ta(n.value,i.value);return r.valid?((Va(n)||Va(i))&&e.dirty(),{status:e.value,value:r.data}):(k(a,{code:g.invalid_intersection_types}),E)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([n,i])=>s(n,i)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};wt.create=(t,e,a)=>new wt({left:t,right:e,typeName:Z.ZodIntersection,...$(a)});var Ve=class tn extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.array)return k(s,{code:g.invalid_type,expected:N.array,received:s.parsedType}),E;if(s.data.length<this._def.items.length)return k(s,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&s.data.length>this._def.items.length&&(k(s,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.dirty());let n=[...s.data].map((i,r)=>{let l=this._def.items[r]||this._def.rest;return l?l._parse(new Ce(s,i,s.path,r)):null}).filter(i=>!!i);return s.common.async?Promise.all(n).then(i=>ge.mergeArray(a,i)):ge.mergeArray(a,n)}get items(){return this._def.items}rest(e){return new tn({...this._def,rest:e})}};Ve.create=(t,e)=>{if(!Array.isArray(t))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ve({items:t,typeName:Z.ZodTuple,rest:null,...$(e)})};var Jr=class ya extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.object)return k(s,{code:g.invalid_type,expected:N.object,received:s.parsedType}),E;let n=[],i=this._def.keyType,r=this._def.valueType;for(let l in s.data)n.push({key:i._parse(new Ce(s,l,s.path,l)),value:r._parse(new Ce(s,s.data[l],s.path,l)),alwaysSet:l in s.data});return s.common.async?ge.mergeObjectAsync(a,n):ge.mergeObjectSync(a,n)}get element(){return this._def.valueType}static create(e,a,s){return a instanceof D?new ya({keyType:e,valueType:a,typeName:Z.ZodRecord,...$(s)}):new ya({keyType:xt.create(),valueType:e,typeName:Z.ZodRecord,...$(a)})}},aa=class extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.map)return k(a,{code:g.invalid_type,expected:N.map,received:a.parsedType}),E;let s=this._def.keyType,n=this._def.valueType,i=[...a.data.entries()].map(([r,l],d)=>({key:s._parse(new Ce(a,r,a.path,[d,"key"])),value:n._parse(new Ce(a,l,a.path,[d,"value"]))}));if(a.common.async){let r=new Map;return Promise.resolve().then(async()=>{for(let l of i){let d=await l.key,c=await l.value;if(d.status==="aborted"||c.status==="aborted")return E;(d.status==="dirty"||c.status==="dirty")&&e.dirty(),r.set(d.value,c.value)}return{status:e.value,value:r}})}else{let r=new Map;for(let l of i){let d=l.key,c=l.value;if(d.status==="aborted"||c.status==="aborted")return E;(d.status==="dirty"||c.status==="dirty")&&e.dirty(),r.set(d.value,c.value)}return{status:e.value,value:r}}}};aa.create=(t,e,a)=>new aa({valueType:e,keyType:t,typeName:Z.ZodMap,...$(a)});var sa=class xa extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.set)return k(s,{code:g.invalid_type,expected:N.set,received:s.parsedType}),E;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(k(s,{code:g.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),a.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(k(s,{code:g.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),a.dirty());let i=this._def.valueType;function r(d){let c=new Set;for(let u of d){if(u.status==="aborted")return E;u.status==="dirty"&&a.dirty(),c.add(u.value)}return{status:a.value,value:c}}let l=[...s.data.values()].map((d,c)=>i._parse(new Ce(s,d,s.path,c)));return s.common.async?Promise.all(l).then(d=>r(d)):r(l)}min(e,a){return new xa({...this._def,minSize:{value:e,message:T.toString(a)}})}max(e,a){return new xa({...this._def,maxSize:{value:e,message:T.toString(a)}})}size(e,a){return this.min(e,a).max(e,a)}nonempty(e){return this.min(1,e)}};sa.create=(t,e)=>new sa({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...$(e)});var Hr=class $t extends D{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==N.function)return k(a,{code:g.invalid_type,expected:N.function,received:a.parsedType}),E;function s(l,d){return Bt({data:l,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Vt(),rt].filter(c=>!!c),issueData:{code:g.invalid_arguments,argumentsError:d}})}function n(l,d){return Bt({data:l,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Vt(),rt].filter(c=>!!c),issueData:{code:g.invalid_return_type,returnTypeError:d}})}let i={errorMap:a.common.contextualErrorMap},r=a.data;if(this._def.returns instanceof it){let l=this;return ue(async function(...d){let c=new xe([]),u=await l._def.args.parseAsync(d,i).catch(h=>{throw c.addIssue(s(d,h)),c}),m=await Reflect.apply(r,this,u);return await l._def.returns._def.type.parseAsync(m,i).catch(h=>{throw c.addIssue(n(m,h)),c})})}else{let l=this;return ue(function(...d){let c=l._def.args.safeParse(d,i);if(!c.success)throw new xe([s(d,c.error)]);let u=Reflect.apply(r,this,c.data),m=l._def.returns.safeParse(u,i);if(!m.success)throw new xe([n(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $t({...this._def,args:Ve.create(e).rest(Ye.create())})}returns(e){return new $t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,a,s){return new $t({args:e||Ve.create([]).rest(Ye.create()),returns:a||Ye.create(),typeName:Z.ZodFunction,...$(s)})}},kt=class extends D{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};kt.create=(t,e)=>new kt({getter:t,typeName:Z.ZodLazy,...$(e)});var jt=class extends D{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return k(e,{received:e.data,code:g.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:t.data}}get value(){return this._def.value}};jt.create=(t,e)=>new jt({value:t,typeName:Z.ZodLiteral,...$(e)});function Ya(t,e){return new Nt({values:t,typeName:Z.ZodEnum,...$(e)})}var Nt=class va extends D{_parse(e){if(typeof e.data!="string"){let a=this._getOrReturnCtx(e),s=this._def.values;return k(a,{expected:U.joinValues(s),received:a.parsedType,code:g.invalid_type}),E}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let a=this._getOrReturnCtx(e),s=this._def.values;return k(a,{received:a.data,code:g.invalid_enum_value,options:s}),E}return ue(e.data)}get options(){return this._def.values}get enum(){let e={};for(let a of this._def.values)e[a]=a;return e}get Values(){let e={};for(let a of this._def.values)e[a]=a;return e}get Enum(){let e={};for(let a of this._def.values)e[a]=a;return e}extract(e,a=this._def){return va.create(e,{...this._def,...a})}exclude(e,a=this._def){return va.create(this.options.filter(s=>!e.includes(s)),{...this._def,...a})}};Nt.create=Ya;var St=class extends D{_parse(t){let e=U.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==N.string&&a.parsedType!==N.number){let s=U.objectValues(e);return k(a,{expected:U.joinValues(s),received:a.parsedType,code:g.invalid_type}),E}if(this._cache||(this._cache=new Set(U.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=U.objectValues(e);return k(a,{received:a.data,code:g.invalid_enum_value,options:s}),E}return ue(t.data)}get enum(){return this._def.values}};St.create=(t,e)=>new St({values:t,typeName:Z.ZodNativeEnum,...$(e)});var it=class extends D{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);return e.parsedType!==N.promise&&e.common.async===!1?(k(e,{code:g.invalid_type,expected:N.promise,received:e.parsedType}),E):ue((e.parsedType===N.promise?e.data:Promise.resolve(e.data)).then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}};it.create=(t,e)=>new it({type:t,typeName:Z.ZodPromise,...$(e)});var Me=class extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:a}=this._processInputParams(t),s=this._def.effect||null,n={addIssue:i=>{k(a,i),i.fatal?e.abort():e.dirty()},get path(){return a.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){let i=s.transform(a.data,n);if(a.common.async)return Promise.resolve(i).then(async r=>{if(e.value==="aborted")return E;let l=await this._def.schema._parseAsync({data:r,path:a.path,parent:a});return l.status==="aborted"?E:l.status==="dirty"||e.value==="dirty"?Kt(l.value):l});{if(e.value==="aborted")return E;let r=this._def.schema._parseSync({data:i,path:a.path,parent:a});return r.status==="aborted"?E:r.status==="dirty"||e.value==="dirty"?Kt(r.value):r}}if(s.type==="refinement"){let i=r=>{let l=s.refinement(r,n);if(a.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return r};if(a.common.async===!1){let r=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?E:(r.status==="dirty"&&e.dirty(),i(r.value),{status:e.value,value:r.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(r=>r.status==="aborted"?E:(r.status==="dirty"&&e.dirty(),i(r.value).then(()=>({status:e.value,value:r.value}))))}if(s.type==="transform")if(a.common.async===!1){let i=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!He(i))return E;let r=s.transform(i.value,n);if(r instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:r}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(i=>He(i)?Promise.resolve(s.transform(i.value,n)).then(r=>({status:e.value,value:r})):E);U.assertNever(s)}};Me.create=(t,e,a)=>new Me({schema:t,typeName:Z.ZodEffects,effect:e,...$(a)}),Me.createWithPreprocess=(t,e,a)=>new Me({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...$(a)});var Oe=class extends D{_parse(t){return this._getType(t)===N.undefined?ue(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Oe.create=(t,e)=>new Oe({innerType:t,typeName:Z.ZodOptional,...$(e)});var Be=class extends D{_parse(t){return this._getType(t)===N.null?ue(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Be.create=(t,e)=>new Be({innerType:t,typeName:Z.ZodNullable,...$(e)});var Ct=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return e.parsedType===N.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};Ct.create=(t,e)=>new Ct({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});var It=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a={...e,common:{...e.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return yt(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new xe(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xe(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};It.create=(t,e)=>new It({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});var na=class extends D{_parse(t){if(this._getType(t)!==N.nan){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.nan,received:e.parsedType}),E}return{status:"valid",value:t.data}}};na.create=t=>new na({typeName:Z.ZodNaN,...$(t)});var Ga=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return this._def.type._parse({data:a,path:e.path,parent:e})}unwrap(){return this._def.type}},Qa=class an extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?E:n.status==="dirty"?(a.dirty(),Kt(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?E:n.status==="dirty"?(a.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,a){return new an({in:e,out:a,typeName:Z.ZodPipeline})}},Tt=class extends D{_parse(t){let e=this._def.innerType._parse(t),a=s=>(He(s)&&(s.value=Object.freeze(s.value)),s);return yt(e)?e.then(s=>a(s)):a(e)}unwrap(){return this._def.innerType}};Tt.create=(t,e)=>new Tt({innerType:t,typeName:Z.ZodReadonly,...$(e)}),be.lazycreate;var Z;(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"})(Z||(Z={}));var f=xt.create,we=Jt.create;na.create,Ht.create;var Ie=Yt.create;Gt.create,Qt.create,vt.create,_t.create,Xt.create;var b=Ye.create;Fe.create,ea.create;var H=Ge.create,_=be.create;be.strictCreate;var K=bt.create;Kr.create,wt.create,Ve.create;var w=Jr.create;aa.create,sa.create,Hr.create,kt.create;var j=jt.create;Nt.create,St.create,it.create,Me.create,Oe.create,Be.create,Me.createWithPreprocess,Qa.create;const ze={authenticate:"authenticate",initialize:"initialize",session_cancel:"session/cancel",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Ee={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},Xa=_({_meta:w(b()).optional(),content:f(),path:f(),sessionId:f()}),es=_({_meta:w(b()).optional(),limit:we().optional().nullable(),line:we().optional().nullable(),path:f(),sessionId:f()}),ts=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),as=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),ss=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),ns=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),Yr=w(b()),Gr=K([j("assistant"),j("user")]),Qr=_({_meta:w(b()).optional(),mimeType:f().optional().nullable(),text:f(),uri:f()}),Xr=_({_meta:w(b()).optional(),blob:f(),mimeType:f().optional().nullable(),uri:f()}),rs=K([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]),is=K([j("pending"),j("in_progress"),j("completed"),j("failed")]),ei=_({_meta:w(b()).optional()}),ti=_({_meta:w(b()).optional(),content:f()}),ai=_({_meta:w(b()).optional(),outcome:K([_({outcome:j("cancelled")}),_({optionId:f(),outcome:j("selected")})])}),si=_({_meta:w(b()).optional(),terminalId:f()}),ni=_({_meta:w(b()).optional()}),ri=_({_meta:w(b()).optional(),exitCode:we().optional().nullable(),signal:f().optional().nullable()}),ii=_({_meta:w(b()).optional()}),oi=w(b()),li=_({_meta:w(b()).optional(),sessionId:f()}),di=w(b()),ci=_({_meta:w(b()).optional(),methodId:f()}),ui=_({_meta:w(b()).optional(),modeId:f(),sessionId:f()}),mi=_({_meta:w(b()).optional(),modelId:f(),sessionId:f()}),pi=w(b()),os=_({_meta:w(b()).optional(),name:f(),value:f()}),Te=_({_meta:w(b()).optional(),audience:H(Gr).optional().nullable(),lastModified:f().optional().nullable(),priority:we().optional().nullable()}),ls=K([Qr,Xr]),hi=_({_meta:w(b()).optional()}),fi=_({meta:b().optional()}),gi=_({_meta:w(b()).optional(),stopReason:K([j("end_turn"),j("max_tokens"),j("max_turn_requests"),j("refusal"),j("cancelled")])}),yi=_({_meta:w(b()).optional()}),xi=w(b()),ds=f(),vi=w(b()),_i=_({hint:f()}),bi=_({_meta:w(b()).optional(),kind:K([j("allow_once"),j("allow_always"),j("reject_once"),j("reject_always")]),name:f(),optionId:f()}),ra=K([_({content:K([_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),text:f(),type:j("text")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("image"),uri:f().optional().nullable()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("audio")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),description:f().optional().nullable(),mimeType:f().optional().nullable(),name:f(),size:we().optional().nullable(),title:f().optional().nullable(),type:j("resource_link"),uri:f()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),resource:ls,type:j("resource")})]),type:j("content")}),_({_meta:w(b()).optional(),newText:f(),oldText:f().optional().nullable(),path:f(),type:j("diff")}),_({terminalId:f(),type:j("terminal")})]),ia=_({_meta:w(b()).optional(),line:we().optional().nullable(),path:f()}),cs=_({_meta:w(b()).optional(),name:f(),value:f()}),wi=_({_meta:w(b()).optional(),exitCode:we().optional().nullable(),signal:f().optional().nullable()}),ki=_({_meta:w(b()).optional(),readTextFile:Ie().optional(),writeTextFile:Ie().optional()}),ji=_({args:H(f()),command:f(),env:H(cs),name:f()}),us=K([_({headers:H(os),name:f(),type:j("http"),url:f()}),_({headers:H(os),name:f(),type:j("sse"),url:f()}),ji]),At=K([_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),text:f(),type:j("text")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("image"),uri:f().optional().nullable()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("audio")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),description:f().optional().nullable(),mimeType:f().optional().nullable(),name:f(),size:we().optional().nullable(),title:f().optional().nullable(),type:j("resource_link"),uri:f()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),resource:ls,type:j("resource")})]),Ni=_({_meta:w(b()).optional(),description:f().optional().nullable(),id:f(),name:f()}),Si=_({_meta:w(b()).optional(),http:Ie().optional(),sse:Ie().optional()}),Ci=_({_meta:w(b()).optional(),audio:Ie().optional(),embeddedContext:Ie().optional(),image:Ie().optional()}),Ii=_({_meta:w(b()).optional(),description:f().optional().nullable(),modelId:f(),name:f()}),Ti=_({_meta:w(b()).optional(),description:f().optional().nullable(),id:ds,name:f()}),ms=_({_meta:w(b()).optional(),availableModels:H(Ii),currentModelId:f()}),ps=_({_meta:w(b()).optional(),availableModes:H(Ti),currentModeId:f()}),Ai=_({_meta:w(b()).optional(),content:f(),priority:K([j("high"),j("medium"),j("low")]),status:K([j("pending"),j("in_progress"),j("completed")])}),Ri=_i,Mi=K([li,di]),hs=_({_meta:w(b()).optional(),args:H(f()).optional(),command:f(),cwd:f().optional().nullable(),env:H(cs).optional(),outputByteLimit:we().optional().nullable(),sessionId:f()}),Oi=_({_meta:w(b()).optional(),exitStatus:wi.optional().nullable(),output:f(),truncated:Ie()}),Ei=_({_meta:w(b()).optional(),cwd:f(),mcpServers:H(us)}),Zi=_({_meta:w(b()).optional(),cwd:f(),mcpServers:H(us),sessionId:f()}),Pi=_({_meta:w(b()).optional(),prompt:H(At),sessionId:f()}),$i=_({_meta:w(b()).optional(),models:ms.optional().nullable(),modes:ps.optional().nullable(),sessionId:f()}),Fi=_({_meta:w(b()).optional(),models:ms.optional().nullable(),modes:ps.optional().nullable()}),Di=_({_meta:w(b()).optional(),content:H(ra).optional().nullable(),kind:rs.optional().nullable(),locations:H(ia).optional().nullable(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),status:is.optional().nullable(),title:f().optional().nullable(),toolCallId:f()}),zi=_({_meta:w(b()).optional(),fs:ki.optional(),terminal:Ie().optional()}),Li=_({_meta:w(b()).optional(),loadSession:Ie().optional(),mcpCapabilities:Si.optional(),promptCapabilities:Ci.optional()}),Ui=_({_meta:w(b()).optional(),description:f(),input:Ri.optional().nullable(),name:f()}),qi=K([ei,ti,ai,si,Oi,ni,ri,ii,oi]),fs=_({_meta:w(b()).optional(),options:H(bi),sessionId:f(),toolCall:Di}),Wi=_({_meta:w(b()).optional(),clientCapabilities:zi.optional(),protocolVersion:we()}),Vi=_({_meta:w(b()).optional(),agentCapabilities:Li.optional(),authMethods:H(Ni).optional(),protocolVersion:we()}),gs=_({_meta:w(b()).optional(),sessionId:f(),update:K([_({content:At,sessionUpdate:j("user_message_chunk")}),_({content:At,sessionUpdate:j("agent_message_chunk")}),_({content:At,sessionUpdate:j("agent_thought_chunk")}),_({_meta:w(b()).optional(),content:H(ra).optional(),kind:K([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]).optional(),locations:H(ia).optional(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),sessionUpdate:j("tool_call"),status:K([j("pending"),j("in_progress"),j("completed"),j("failed")]).optional(),title:f(),toolCallId:f()}),_({_meta:w(b()).optional(),content:H(ra).optional().nullable(),kind:rs.optional().nullable(),locations:H(ia).optional().nullable(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),sessionUpdate:j("tool_call_update"),status:is.optional().nullable(),title:f().optional().nullable(),toolCallId:f()}),_({_meta:w(b()).optional(),entries:H(Ai),sessionUpdate:j("plan")}),_({availableCommands:H(Ui),sessionUpdate:j("available_commands_update")}),_({currentModeId:ds,sessionUpdate:j("current_mode_update")})])});K([K([Xa,es,fs,hs,ts,as,ss,ns,Yr]),qi,Mi,K([Wi,ci,Ei,Zi,ui,Pi,mi,pi]),K([Vi,hi,$i,Fi,fi,gi,yi,xi]),K([gs,vi])]);function Bi(t,e){let a=new TextEncoder,s=new TextDecoder;return{readable:new ReadableStream({async start(n){let i="",r=e.getReader();try{for(;;){let{value:l,done:d}=await r.read();if(d)break;if(!l)continue;i+=s.decode(l,{stream:!0});let c=i.split(`
1
+ var mn=Object.defineProperty;var _a=t=>{throw TypeError(t)};var pn=(t,e,a)=>e in t?mn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var B=(t,e,a)=>pn(t,typeof e!="symbol"?e+"":e,a),Dt=(t,e,a)=>e.has(t)||_a("Cannot "+a);var Q=(t,e,a)=>(Dt(t,e,"read from private field"),a?a.call(t):e.get(t)),Re=(t,e,a)=>e.has(t)?_a("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,a),We=(t,e,a,s)=>(Dt(t,e,"write to private field"),s?s.call(t,a):e.set(t,a),a),Se=(t,e,a)=>(Dt(t,e,"access private method"),a);var ba=(t,e,a,s)=>({set _(n){We(t,e,n,a)},get _(){return Q(t,e,s)}});var me,Hs,et,Ft,ct,ut,tt,at,ne,sn,nn,rn,on,ln,dt,Ys;import{s as wa}from"./chunk-LvLJmgfZ.js";import{d as ka,i as st,l as pt,n as oe,p as hn,u as fn}from"./useEvent-D91BmmQi.js";import{t as gn}from"./react-Bj1aDYRI.js";import{Ai as ja,Cr as zt,Fi as yn,In as xn,On as vn,Tn as _n,ji as Na,ur as bn,vr as wn}from"./cells-06TDmJ8V.js";import"./react-dom-CSu739Rf.js";import{P as kn,R as Lt}from"./zod-H_cgTO0M.js";import{t as _e}from"./compiler-runtime-B3qBwwSJ.js";import{J as jn,X as Sa,d as ht}from"./ai-model-dropdown-DQb_CyMN.js";import{_ as Ke,m as Nn,v as Ca}from"./useEventListener-BakX-tnw.js";import{t as ye}from"./cn-X2M2usMq.js";import{t as Sn}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-BXI8V5i6.js";import{a as Cn,i as In,n as Tn,r as An}from"./multi-map-9ogswH46.js";import{i as Ia,r as Ta,t as Aa}from"./popover-DMNO6Poc.js";import{a as Ra,i as Ma,n as Oa,r as Ea,s as Za,t as Pa}from"./select-Cjly7tmx.js";import{a as Rn,d as Mn,f as On,p as En,r as Zn,s as Pn,t as $n,u as Fn}from"./dropdown-menu-DfGLyCbP.js";import{Y as $a,t as Fa}from"./JsonOutput-FFLZqPUK.js";import"./download-VxqV5OSK.js";import{i as Dn,t as zn}from"./tooltip-CgQpRVyN.js";import{t as le}from"./button-BF7GSjhW.js";import{st as Ln}from"./dist-Dez1I5M9.js";import{p as Un}from"./arrays-DWxvyYxP.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{i as qn,n as Ut,t as Wn}from"./strings-DvZlHYnD.js";import{r as Vn}from"./requests-KshNNAOp.js";import{t as Je}from"./createLucideIcon-BTp1tQDO.js";import{t as Bn}from"./fileToBase64-Doh9J-g6.js";import{t as ft}from"./bot-message-square-AslRbAeb.js";import{r as Kn,t as Da}from"./x-9vLEgLY6.js";import{t as za}from"./markdown-renderer-C1yypOYF.js";import{T as Jn,V as Hn,c as Yn,d as Gn,k as Qn,n as Xn,s as er,u as tr,y as ar}from"./add-cell-with-ai-wdY7HT-D.js";import{n as sr,t as nr}from"./file-headphone-CUN2DC78.js";import{t as rr}from"./file-BvoBtS_V.js";import{n as ir,t as qt}from"./spinner-DTBVbtl-.js";import{t as or}from"./refresh-cw-DcEasnos.js";import{t as La}from"./rotate-ccw-CBXqO1Fd.js";import{c as lr}from"./MarimoErrorOutput-BQt_FXJL.js";import{c as dr}from"./datasource-mVfTJz3V.js";import{t as cr}from"./badge-CFAaMy0O.js";import"./dist-DHMtQYxT.js";import"./dist-Bj9Iedc0.js";import"./dist-D-o1OXc9.js";import"./dist-BZhJ1bTM.js";import"./dist-DnIl7RU-.js";import{t as ur}from"./uuid-BukULOeS.js";import{t as gt}from"./use-toast-BH8bU9Xf.js";import{n as Ua,t as mr}from"./paths-kNeJ8nbe.js";import"./session-B6_8umQX.js";import{r as pr}from"./useTheme-CWoNQwFz.js";import"./purify.es-DdxMtdqK.js";import"./dates-CnrjjcMO.js";import{t as hr}from"./copy-icon-BCIGtBo0.js";import"./utils-BIlJBJIu.js";import"./vega-loader.browser-BJ9oKrvH.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{n as fr}from"./error-banner-C4DZksWV.js";import"./chunk-5FQGJX7Z-C6VN0dQj.js";import"./html-to-image-CbQeOjEJ.js";import"./react-resizable-panels.browser.esm-CgWOEYeG.js";import{t as gr}from"./esm-DSv-aO_T.js";import{n as yr}from"./dist-BM-OLiKa.js";import{t as qa}from"./empty-state-vKu4k0Y4.js";import{t as xr}from"./state-RnIztwr-.js";var vr=Je("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),_r=Je("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]),br=Je("file-video-camera",[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 17.843 3.033-1.755a.64.64 0 0 1 .967.56v4.704a.65.65 0 0 1-.967.56L10 20.157",key:"17aeo9"}],["rect",{width:"7",height:"6",x:"3",y:"16",rx:"1",key:"s27ndx"}]]),wr=Je("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),nt=Je("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Wt=Je("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),U;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function a(n){throw Error()}t.assertNever=a,t.arrayToEnum=n=>{let i={};for(let r of n)i[r]=r;return i},t.getValidEnumValues=n=>{let i=t.objectKeys(n).filter(l=>typeof n[n[l]]!="number"),r={};for(let l of i)r[l]=n[l];return t.objectValues(r)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&i.push(r);return i},t.find=(n,i)=>{for(let r of n)if(i(r))return r},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,i=" | "){return n.map(r=>typeof r=="string"?`'${r}'`:r).join(i)}t.joinValues=s,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(U||(U={}));var kr;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(kr||(kr={}));const N=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$e=t=>{switch(typeof t){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(t)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(t)?N.array:t===null?N.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?N.promise:typeof Map<"u"&&t instanceof Map?N.map:typeof Set<"u"&&t instanceof Set?N.set:typeof Date<"u"&&t instanceof Date?N.date:N.object;default:return N.unknown}},g=U.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"]);var xe=class Gs 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]};let a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){let a=e||function(i){return i.message},s={_errors:[]},n=i=>{for(let r of i.issues)if(r.code==="invalid_union")r.unionErrors.map(n);else if(r.code==="invalid_return_type")n(r.returnTypeError);else if(r.code==="invalid_arguments")n(r.argumentsError);else if(r.path.length===0)s._errors.push(a(r));else{let l=s,d=0;for(;d<r.path.length;){let c=r.path[d];d===r.path.length-1?(l[c]=l[c]||{_errors:[]},l[c]._errors.push(a(r))):l[c]=l[c]||{_errors:[]},l=l[c],d++}}};return n(this),s}static assert(e){if(!(e instanceof Gs))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){let a={},s=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];a[i]=a[i]||[],a[i].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}};xe.create=t=>new xe(t);var rt=(t,e)=>{let a;switch(t.code){case g.invalid_type:a=t.received===N.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case g.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(t.expected,U.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:a=`Unrecognized key(s) in object: ${U.joinValues(t.keys,", ")}`;break;case g.invalid_union:a="Invalid input";break;case g.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${U.joinValues(t.options)}`;break;case g.invalid_enum_value:a=`Invalid enum value. Expected ${U.joinValues(t.options)}, received '${t.received}'`;break;case g.invalid_arguments:a="Invalid function arguments";break;case g.invalid_return_type:a="Invalid function return type";break;case g.invalid_date:a="Invalid date";break;case g.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(a=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(a=`${a} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?a=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?a=`Invalid input: must end with "${t.validation.endsWith}"`:U.assertNever(t.validation):a=t.validation==="regex"?"Invalid":`Invalid ${t.validation}`;break;case g.too_small:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"||t.type==="bigint"?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case g.too_big:a=t.type==="array"?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case g.custom:a="Invalid input";break;case g.invalid_intersection_types:a="Intersection results could not be merged";break;case g.not_multiple_of:a=`Number must be a multiple of ${t.multipleOf}`;break;case g.not_finite:a="Number must be finite";break;default:a=e.defaultError,U.assertNever(t)}return{message:a}},jr=rt;function Vt(){return jr}const Bt=t=>{let{data:e,path:a,errorMaps:s,issueData:n}=t,i=[...a,...n.path||[]],r={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let l="",d=s.filter(c=>!!c).slice().reverse();for(let c of d)l=c(r,{data:e,defaultError:l}).message;return{...n,path:i,message:l}};function k(t,e){let a=Vt(),s=Bt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===rt?void 0:rt].filter(n=>!!n)});t.common.issues.push(s)}var ge=class Qs{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,a){let s=[];for(let n of a){if(n.status==="aborted")return E;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,a){let s=[];for(let n of a){let i=await n.key,r=await n.value;s.push({key:i,value:r})}return Qs.mergeObjectSync(e,s)}static mergeObjectSync(e,a){let s={};for(let n of a){let{key:i,value:r}=n;if(i.status==="aborted"||r.status==="aborted")return E;i.status==="dirty"&&e.dirty(),r.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(r.value!==void 0||n.alwaysSet)&&(s[i.value]=r.value)}return{status:e.value,value:s}}};const E=Object.freeze({status:"aborted"}),Kt=t=>({status:"dirty",value:t}),ue=t=>({status:"valid",value:t}),Wa=t=>t.status==="aborted",Va=t=>t.status==="dirty",He=t=>t.status==="valid",yt=t=>typeof Promise<"u"&&t instanceof Promise;var T;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(T||(T={}));var Ce=class{constructor(t,e,a,s){this._cachedPath=[],this.parent=t,this.data=e,this._path=a,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ba=(t,e)=>{if(He(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){return this._error||(this._error=new xe(t.common.issues)),this._error}}};function $(t){if(!t)return{};let{errorMap:e,invalid_type_error:a,required_error:s,description:n}=t;if(e&&(a||s))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,r)=>{let{message:l}=t;return i.code==="invalid_enum_value"?{message:l??r.defaultError}:r.data===void 0?{message:l??s??r.defaultError}:i.code==="invalid_type"?{message:l??a??r.defaultError}:{message:r.defaultError}},description:n}}var D=class{get description(){return this._def.description}_getType(t){return $e(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:$e(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ge,ctx:{common:t.parent.common,data:t.data,parsedType:$e(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(yt(e))throw Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let a=this.safeParse(t,e);if(a.success)return a.data;throw a.error}safeParse(t,e){let a={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)};return Ba(a,this._parseSync({data:t,path:a.path,parent:a}))}"~validate"(t){var a,s;let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:e});return He(n)?{value:n.value}:{issues:e.common.issues}}catch(n){(s=(a=n==null?void 0:n.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(n=>He(n)?{value:n.value}:{issues:e.common.issues})}async parseAsync(t,e){let a=await this.safeParseAsync(t,e);if(a.success)return a.data;throw a.error}async safeParseAsync(t,e){let a={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:$e(t)},s=this._parse({data:t,path:a.path,parent:a});return Ba(a,await(yt(s)?s:Promise.resolve(s)))}refine(t,e){let a=s=>typeof e=="string"||e===void 0?{message:e}:typeof e=="function"?e(s):e;return this._refinement((s,n)=>{let i=t(s),r=()=>n.addIssue({code:g.custom,...a(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(r(),!1)):i?!0:(r(),!1)})}refinement(t,e){return this._refinement((a,s)=>t(a)?!0:(s.addIssue(typeof e=="function"?e(a,s):e),!1))}_refinement(t){return new Me({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Oe.create(this,this._def)}nullable(){return Be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ge.create(this)}promise(){return it.create(this,this._def)}or(t){return bt.create([this,t],this._def)}and(t){return wt.create(this,t,this._def)}transform(t){return new Me({...$(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new Ct({...$(this._def),innerType:this,defaultValue:e,typeName:Z.ZodDefault})}brand(){return new Ga({typeName:Z.ZodBranded,type:this,...$(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new It({...$(this._def),innerType:this,catchValue:e,typeName:Z.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Qa.create(this,t)}readonly(){return Tt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nr=/^c[^\s-]{8,}$/i,Sr=/^[0-9a-z]+$/,Cr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ir=/^[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}$/i,Tr=/^[a-z0-9_-]{21}$/i,Ar=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Or="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ka,Er=/^(?:(?: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])$/,Zr=/^(?:(?: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])$/,Pr=/^(([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]))$/,$r=/^(([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])$/,Fr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ja="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",zr=RegExp(`^${Ja}$`);function Ha(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision??(e=`${e}(\\.\\d+)?`);let a=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${a}`}function Lr(t){return RegExp(`^${Ha(t)}$`)}function Ur(t){let e=`${Ja}T${Ha(t)}`,a=[];return a.push(t.local?"Z?":"Z"),t.offset&&a.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${a.join("|")})`,RegExp(`^${e}$`)}function qr(t,e){return!!((e==="v4"||!e)&&Er.test(t)||(e==="v6"||!e)&&Pr.test(t))}function Wr(t,e){if(!Ar.test(t))return!1;try{let[a]=t.split(".");if(!a)return!1;let s=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||!n||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Vr(t,e){return!!((e==="v4"||!e)&&Zr.test(t)||(e==="v6"||!e)&&$r.test(t))}var xt=class lt extends D{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.string,received:n.parsedType}),E}let a=new ge,s;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),a.dirty());else if(n.kind==="length"){let i=e.data.length>n.value,r=e.data.length<n.value;(i||r)&&(s=this._getOrReturnCtx(e,s),i?k(s,{code:g.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&k(s,{code:g.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),a.dirty())}else if(n.kind==="email")Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"email",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="emoji")Ka||(Ka=new RegExp(Or,"u")),Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"emoji",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="uuid")Ir.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"uuid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="nanoid")Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"nanoid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="cuid")Nr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cuid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="cuid2")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cuid2",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="ulid")Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"ulid",code:g.invalid_string,message:n.message}),a.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),k(s,{validation:"url",code:g.invalid_string,message:n.message}),a.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"regex",code:g.invalid_string,message:n.message}),a.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),a.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{startsWith:n.value},message:n.message}),a.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:{endsWith:n.value},message:n.message}),a.dirty()):n.kind==="datetime"?Ur(n).test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"datetime",message:n.message}),a.dirty()):n.kind==="date"?zr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"date",message:n.message}),a.dirty()):n.kind==="time"?Lr(n).test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{code:g.invalid_string,validation:"time",message:n.message}),a.dirty()):n.kind==="duration"?Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"duration",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="ip"?qr(e.data,n.version)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"ip",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="jwt"?Wr(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"jwt",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="cidr"?Vr(e.data,n.version)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"cidr",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="base64"?Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"base64",code:g.invalid_string,message:n.message}),a.dirty()):n.kind==="base64url"?Dr.test(e.data)||(s=this._getOrReturnCtx(e,s),k(s,{validation:"base64url",code:g.invalid_string,message:n.message}),a.dirty()):U.assertNever(n);return{status:a.value,value:e.data}}_regex(e,a,s){return this.refinement(n=>e.test(n),{validation:a,code:g.invalid_string,...T.errToObj(s)})}_addCheck(e){return new lt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...T.errToObj(e)})}url(e){return this._addCheck({kind:"url",...T.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...T.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...T.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...T.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...T.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...T.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...T.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...T.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...T.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...T.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...T.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:(e==null?void 0:e.precision)===void 0?null:e==null?void 0:e.precision,...T.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...T.errToObj(e)})}regex(e,a){return this._addCheck({kind:"regex",regex:e,...T.errToObj(a)})}includes(e,a){return this._addCheck({kind:"includes",value:e,position:a==null?void 0:a.position,...T.errToObj(a==null?void 0:a.message)})}startsWith(e,a){return this._addCheck({kind:"startsWith",value:e,...T.errToObj(a)})}endsWith(e,a){return this._addCheck({kind:"endsWith",value:e,...T.errToObj(a)})}min(e,a){return this._addCheck({kind:"min",value:e,...T.errToObj(a)})}max(e,a){return this._addCheck({kind:"max",value:e,...T.errToObj(a)})}length(e,a){return this._addCheck({kind:"length",value:e,...T.errToObj(a)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new lt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxLength(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};xt.create=t=>new xt({checks:[],typeName:Z.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...$(t)});function Br(t,e){let a=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=a>s?a:s;return Number.parseInt(t.toFixed(n).replace(".",""))%Number.parseInt(e.toFixed(n).replace(".",""))/10**n}var Jt=class fa extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.number,received:n.parsedType}),E}let a,s=new ge;for(let n of this._def.checks)n.kind==="int"?U.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),k(a,{code:g.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Br(e.data,n.value)!==0&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_finite,message:n.message}),s.dirty()):U.assertNever(n);return{status:s.value,value:e.data}}gte(e,a){return this.setLimit("min",e,!0,T.toString(a))}gt(e,a){return this.setLimit("min",e,!1,T.toString(a))}lte(e,a){return this.setLimit("max",e,!0,T.toString(a))}lt(e,a){return this.setLimit("max",e,!1,T.toString(a))}setLimit(e,a,s,n){return new fa({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:s,message:T.toString(n)}]})}_addCheck(e){return new fa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:T.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(a)})}finite(e){return this._addCheck({kind:"finite",message:T.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:-(2**53-1),message:T.toString(e)})._addCheck({kind:"max",inclusive:!0,value:2**53-1,message:T.toString(e)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&U.isInteger(e.value))}get isFinite(){let e=null,a=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(a===null||s.value>a)&&(a=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(a)&&Number.isFinite(e)}};Jt.create=t=>new Jt({checks:[],typeName:Z.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...$(t)});var Ht=class ga extends D{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==N.bigint)return this._getInvalidInput(e);let a,s=new ge;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),k(a,{code:g.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):U.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let a=this._getOrReturnCtx(e);return k(a,{code:g.invalid_type,expected:N.bigint,received:a.parsedType}),E}gte(e,a){return this.setLimit("min",e,!0,T.toString(a))}gt(e,a){return this.setLimit("min",e,!1,T.toString(a))}lte(e,a){return this.setLimit("max",e,!0,T.toString(a))}lt(e,a){return this.setLimit("max",e,!1,T.toString(a))}setLimit(e,a,s,n){return new ga({...this._def,checks:[...this._def.checks,{kind:e,value:a,inclusive:s,message:T.toString(n)}]})}_addCheck(e){return new ga({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,a){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(a)})}get minValue(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e}get maxValue(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e}};Ht.create=t=>new Ht({checks:[],typeName:Z.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...$(t)});var Yt=class extends D{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==N.boolean){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.boolean,received:e.parsedType}),E}return ue(t.data)}};Yt.create=t=>new Yt({typeName:Z.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...$(t)});var Gt=class Xs extends D{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let n=this._getOrReturnCtx(e);return k(n,{code:g.invalid_type,expected:N.date,received:n.parsedType}),E}if(Number.isNaN(e.data.getTime()))return k(this._getOrReturnCtx(e),{code:g.invalid_date}),E;let a=new ge,s;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),a.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),k(s,{code:g.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),a.dirty()):U.assertNever(n);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xs({...this._def,checks:[...this._def.checks,e]})}min(e,a){return this._addCheck({kind:"min",value:e.getTime(),message:T.toString(a)})}max(e,a){return this._addCheck({kind:"max",value:e.getTime(),message:T.toString(a)})}get minDate(){let e=null;for(let a of this._def.checks)a.kind==="min"&&(e===null||a.value>e)&&(e=a.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let a of this._def.checks)a.kind==="max"&&(e===null||a.value<e)&&(e=a.value);return e==null?null:new Date(e)}};Gt.create=t=>new Gt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Z.ZodDate,...$(t)});var Qt=class extends D{_parse(t){if(this._getType(t)!==N.symbol){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.symbol,received:e.parsedType}),E}return ue(t.data)}};Qt.create=t=>new Qt({typeName:Z.ZodSymbol,...$(t)});var vt=class extends D{_parse(t){if(this._getType(t)!==N.undefined){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.undefined,received:e.parsedType}),E}return ue(t.data)}};vt.create=t=>new vt({typeName:Z.ZodUndefined,...$(t)});var _t=class extends D{_parse(t){if(this._getType(t)!==N.null){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.null,received:e.parsedType}),E}return ue(t.data)}};_t.create=t=>new _t({typeName:Z.ZodNull,...$(t)});var Xt=class extends D{constructor(){super(...arguments),this._any=!0}_parse(t){return ue(t.data)}};Xt.create=t=>new Xt({typeName:Z.ZodAny,...$(t)});var Ye=class extends D{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ue(t.data)}};Ye.create=t=>new Ye({typeName:Z.ZodUnknown,...$(t)});var Fe=class extends D{_parse(t){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.never,received:e.parsedType}),E}};Fe.create=t=>new Fe({typeName:Z.ZodNever,...$(t)});var ea=class extends D{_parse(t){if(this._getType(t)!==N.undefined){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.void,received:e.parsedType}),E}return ue(t.data)}};ea.create=t=>new ea({typeName:Z.ZodVoid,...$(t)});var Ge=class Pt extends D{_parse(e){let{ctx:a,status:s}=this._processInputParams(e),n=this._def;if(a.parsedType!==N.array)return k(a,{code:g.invalid_type,expected:N.array,received:a.parsedType}),E;if(n.exactLength!==null){let r=a.data.length>n.exactLength.value,l=a.data.length<n.exactLength.value;(r||l)&&(k(a,{code:r?g.too_big:g.too_small,minimum:l?n.exactLength.value:void 0,maximum:r?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&a.data.length<n.minLength.value&&(k(a,{code:g.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&a.data.length>n.maxLength.value&&(k(a,{code:g.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),a.common.async)return Promise.all([...a.data].map((r,l)=>n.type._parseAsync(new Ce(a,r,a.path,l)))).then(r=>ge.mergeArray(s,r));let i=[...a.data].map((r,l)=>n.type._parseSync(new Ce(a,r,a.path,l)));return ge.mergeArray(s,i)}get element(){return this._def.type}min(e,a){return new Pt({...this._def,minLength:{value:e,message:T.toString(a)}})}max(e,a){return new Pt({...this._def,maxLength:{value:e,message:T.toString(a)}})}length(e,a){return new Pt({...this._def,exactLength:{value:e,message:T.toString(a)}})}nonempty(e){return this.min(1,e)}};Ge.create=(t,e)=>new Ge({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...$(e)});function Qe(t){if(t instanceof be){let e={};for(let a in t.shape){let s=t.shape[a];e[a]=Oe.create(Qe(s))}return new be({...t._def,shape:()=>e})}else return t instanceof Ge?new Ge({...t._def,type:Qe(t.element)}):t instanceof Oe?Oe.create(Qe(t.unwrap())):t instanceof Be?Be.create(Qe(t.unwrap())):t instanceof Ve?Ve.create(t.items.map(e=>Qe(e))):t}var be=class je extends D{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:U.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==N.object){let d=this._getOrReturnCtx(e);return k(d,{code:g.invalid_type,expected:N.object,received:d.parsedType}),E}let{status:a,ctx:s}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),r=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let d in s.data)i.includes(d)||r.push(d);let l=[];for(let d of i){let c=n[d],u=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Ce(s,u,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof Fe){let d=this._def.unknownKeys;if(d==="passthrough")for(let c of r)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(d==="strict")r.length>0&&(k(s,{code:g.unrecognized_keys,keys:r}),a.dirty());else if(d!=="strip")throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let c of r){let u=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Ce(s,u,s.path,c)),alwaysSet:c in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let d=[];for(let c of l){let u=await c.key,m=await c.value;d.push({key:u,value:m,alwaysSet:c.alwaysSet})}return d}).then(d=>ge.mergeObjectSync(a,d)):ge.mergeObjectSync(a,l)}get shape(){return this._def.shape()}strict(e){return T.errToObj,new je({...this._def,unknownKeys:"strict",...e===void 0?{}:{errorMap:(a,s)=>{var i,r;let n=((r=(i=this._def).errorMap)==null?void 0:r.call(i,a,s).message)??s.defaultError;return a.code==="unrecognized_keys"?{message:T.errToObj(e).message??n}:{message:n}}}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,a){return this.augment({[e]:a})}catchall(e){return new je({...this._def,catchall:e})}pick(e){let a={};for(let s of U.objectKeys(e))e[s]&&this.shape[s]&&(a[s]=this.shape[s]);return new je({...this._def,shape:()=>a})}omit(e){let a={};for(let s of U.objectKeys(this.shape))e[s]||(a[s]=this.shape[s]);return new je({...this._def,shape:()=>a})}deepPartial(){return Qe(this)}partial(e){let a={};for(let s of U.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?a[s]=n:a[s]=n.optional()}return new je({...this._def,shape:()=>a})}required(e){let a={};for(let s of U.objectKeys(this.shape))if(e&&!e[s])a[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Oe;)n=n._def.innerType;a[s]=n}return new je({...this._def,shape:()=>a})}keyof(){return Ya(U.objectKeys(this.shape))}};be.create=(t,e)=>new be({shape:()=>t,unknownKeys:"strip",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)}),be.strictCreate=(t,e)=>new be({shape:()=>t,unknownKeys:"strict",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)}),be.lazycreate=(t,e)=>new be({shape:t,unknownKeys:"strip",catchall:Fe.create(),typeName:Z.ZodObject,...$(e)});var bt=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=this._def.options;function s(n){for(let r of n)if(r.result.status==="valid")return r.result;for(let r of n)if(r.result.status==="dirty")return e.common.issues.push(...r.ctx.common.issues),r.result;let i=n.map(r=>new xe(r.ctx.common.issues));return k(e,{code:g.invalid_union,unionErrors:i}),E}if(e.common.async)return Promise.all(a.map(async n=>{let i={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:i}),ctx:i}})).then(s);{let n,i=[];for(let l of a){let d={...e,common:{...e.common,issues:[]},parent:null},c=l._parseSync({data:e.data,path:e.path,parent:d});if(c.status==="valid")return c;c.status==="dirty"&&!n&&(n={result:c,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;let r=i.map(l=>new xe(l));return k(e,{code:g.invalid_union,unionErrors:r}),E}}get options(){return this._def.options}};bt.create=(t,e)=>new bt({options:t,typeName:Z.ZodUnion,...$(e)});var De=t=>t instanceof kt?De(t.schema):t instanceof Me?De(t.innerType()):t instanceof jt?[t.value]:t instanceof Nt?t.options:t instanceof St?U.objectValues(t.enum):t instanceof Ct?De(t._def.innerType):t instanceof vt?[void 0]:t instanceof _t?[null]:t instanceof Oe?[void 0,...De(t.unwrap())]:t instanceof Be?[null,...De(t.unwrap())]:t instanceof Ga||t instanceof Tt?De(t.unwrap()):t instanceof It?De(t._def.innerType):[],Kr=class en extends D{_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==N.object)return k(a,{code:g.invalid_type,expected:N.object,received:a.parsedType}),E;let s=this.discriminator,n=a.data[s],i=this.optionsMap.get(n);return i?a.common.async?i._parseAsync({data:a.data,path:a.path,parent:a}):i._parseSync({data:a.data,path:a.path,parent:a}):(k(a,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,a,s){let n=new Map;for(let i of a){let r=De(i.shape[e]);if(!r.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let l of r){if(n.has(l))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);n.set(l,i)}}return new en({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:a,optionsMap:n,...$(s)})}};function ta(t,e){let a=$e(t),s=$e(e);if(t===e)return{valid:!0,data:t};if(a===N.object&&s===N.object){let n=U.objectKeys(e),i=U.objectKeys(t).filter(l=>n.indexOf(l)!==-1),r={...t,...e};for(let l of i){let d=ta(t[l],e[l]);if(!d.valid)return{valid:!1};r[l]=d.data}return{valid:!0,data:r}}else if(a===N.array&&s===N.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let r=t[i],l=e[i],d=ta(r,l);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return a===N.date&&s===N.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var wt=class extends D{_parse(t){let{status:e,ctx:a}=this._processInputParams(t),s=(n,i)=>{if(Wa(n)||Wa(i))return E;let r=ta(n.value,i.value);return r.valid?((Va(n)||Va(i))&&e.dirty(),{status:e.value,value:r.data}):(k(a,{code:g.invalid_intersection_types}),E)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([n,i])=>s(n,i)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};wt.create=(t,e,a)=>new wt({left:t,right:e,typeName:Z.ZodIntersection,...$(a)});var Ve=class tn extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.array)return k(s,{code:g.invalid_type,expected:N.array,received:s.parsedType}),E;if(s.data.length<this._def.items.length)return k(s,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&s.data.length>this._def.items.length&&(k(s,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),a.dirty());let n=[...s.data].map((i,r)=>{let l=this._def.items[r]||this._def.rest;return l?l._parse(new Ce(s,i,s.path,r)):null}).filter(i=>!!i);return s.common.async?Promise.all(n).then(i=>ge.mergeArray(a,i)):ge.mergeArray(a,n)}get items(){return this._def.items}rest(e){return new tn({...this._def,rest:e})}};Ve.create=(t,e)=>{if(!Array.isArray(t))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ve({items:t,typeName:Z.ZodTuple,rest:null,...$(e)})};var Jr=class ya extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.object)return k(s,{code:g.invalid_type,expected:N.object,received:s.parsedType}),E;let n=[],i=this._def.keyType,r=this._def.valueType;for(let l in s.data)n.push({key:i._parse(new Ce(s,l,s.path,l)),value:r._parse(new Ce(s,s.data[l],s.path,l)),alwaysSet:l in s.data});return s.common.async?ge.mergeObjectAsync(a,n):ge.mergeObjectSync(a,n)}get element(){return this._def.valueType}static create(e,a,s){return a instanceof D?new ya({keyType:e,valueType:a,typeName:Z.ZodRecord,...$(s)}):new ya({keyType:xt.create(),valueType:e,typeName:Z.ZodRecord,...$(a)})}},aa=class extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.map)return k(a,{code:g.invalid_type,expected:N.map,received:a.parsedType}),E;let s=this._def.keyType,n=this._def.valueType,i=[...a.data.entries()].map(([r,l],d)=>({key:s._parse(new Ce(a,r,a.path,[d,"key"])),value:n._parse(new Ce(a,l,a.path,[d,"value"]))}));if(a.common.async){let r=new Map;return Promise.resolve().then(async()=>{for(let l of i){let d=await l.key,c=await l.value;if(d.status==="aborted"||c.status==="aborted")return E;(d.status==="dirty"||c.status==="dirty")&&e.dirty(),r.set(d.value,c.value)}return{status:e.value,value:r}})}else{let r=new Map;for(let l of i){let d=l.key,c=l.value;if(d.status==="aborted"||c.status==="aborted")return E;(d.status==="dirty"||c.status==="dirty")&&e.dirty(),r.set(d.value,c.value)}return{status:e.value,value:r}}}};aa.create=(t,e,a)=>new aa({valueType:e,keyType:t,typeName:Z.ZodMap,...$(a)});var sa=class xa extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.set)return k(s,{code:g.invalid_type,expected:N.set,received:s.parsedType}),E;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(k(s,{code:g.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),a.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(k(s,{code:g.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),a.dirty());let i=this._def.valueType;function r(d){let c=new Set;for(let u of d){if(u.status==="aborted")return E;u.status==="dirty"&&a.dirty(),c.add(u.value)}return{status:a.value,value:c}}let l=[...s.data.values()].map((d,c)=>i._parse(new Ce(s,d,s.path,c)));return s.common.async?Promise.all(l).then(d=>r(d)):r(l)}min(e,a){return new xa({...this._def,minSize:{value:e,message:T.toString(a)}})}max(e,a){return new xa({...this._def,maxSize:{value:e,message:T.toString(a)}})}size(e,a){return this.min(e,a).max(e,a)}nonempty(e){return this.min(1,e)}};sa.create=(t,e)=>new sa({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...$(e)});var Hr=class $t extends D{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:a}=this._processInputParams(e);if(a.parsedType!==N.function)return k(a,{code:g.invalid_type,expected:N.function,received:a.parsedType}),E;function s(l,d){return Bt({data:l,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Vt(),rt].filter(c=>!!c),issueData:{code:g.invalid_arguments,argumentsError:d}})}function n(l,d){return Bt({data:l,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,Vt(),rt].filter(c=>!!c),issueData:{code:g.invalid_return_type,returnTypeError:d}})}let i={errorMap:a.common.contextualErrorMap},r=a.data;if(this._def.returns instanceof it){let l=this;return ue(async function(...d){let c=new xe([]),u=await l._def.args.parseAsync(d,i).catch(h=>{throw c.addIssue(s(d,h)),c}),m=await Reflect.apply(r,this,u);return await l._def.returns._def.type.parseAsync(m,i).catch(h=>{throw c.addIssue(n(m,h)),c})})}else{let l=this;return ue(function(...d){let c=l._def.args.safeParse(d,i);if(!c.success)throw new xe([s(d,c.error)]);let u=Reflect.apply(r,this,c.data),m=l._def.returns.safeParse(u,i);if(!m.success)throw new xe([n(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $t({...this._def,args:Ve.create(e).rest(Ye.create())})}returns(e){return new $t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,a,s){return new $t({args:e||Ve.create([]).rest(Ye.create()),returns:a||Ye.create(),typeName:Z.ZodFunction,...$(s)})}},kt=class extends D{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};kt.create=(t,e)=>new kt({getter:t,typeName:Z.ZodLazy,...$(e)});var jt=class extends D{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return k(e,{received:e.data,code:g.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:t.data}}get value(){return this._def.value}};jt.create=(t,e)=>new jt({value:t,typeName:Z.ZodLiteral,...$(e)});function Ya(t,e){return new Nt({values:t,typeName:Z.ZodEnum,...$(e)})}var Nt=class va extends D{_parse(e){if(typeof e.data!="string"){let a=this._getOrReturnCtx(e),s=this._def.values;return k(a,{expected:U.joinValues(s),received:a.parsedType,code:g.invalid_type}),E}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let a=this._getOrReturnCtx(e),s=this._def.values;return k(a,{received:a.data,code:g.invalid_enum_value,options:s}),E}return ue(e.data)}get options(){return this._def.values}get enum(){let e={};for(let a of this._def.values)e[a]=a;return e}get Values(){let e={};for(let a of this._def.values)e[a]=a;return e}get Enum(){let e={};for(let a of this._def.values)e[a]=a;return e}extract(e,a=this._def){return va.create(e,{...this._def,...a})}exclude(e,a=this._def){return va.create(this.options.filter(s=>!e.includes(s)),{...this._def,...a})}};Nt.create=Ya;var St=class extends D{_parse(t){let e=U.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==N.string&&a.parsedType!==N.number){let s=U.objectValues(e);return k(a,{expected:U.joinValues(s),received:a.parsedType,code:g.invalid_type}),E}if(this._cache||(this._cache=new Set(U.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=U.objectValues(e);return k(a,{received:a.data,code:g.invalid_enum_value,options:s}),E}return ue(t.data)}get enum(){return this._def.values}};St.create=(t,e)=>new St({values:t,typeName:Z.ZodNativeEnum,...$(e)});var it=class extends D{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);return e.parsedType!==N.promise&&e.common.async===!1?(k(e,{code:g.invalid_type,expected:N.promise,received:e.parsedType}),E):ue((e.parsedType===N.promise?e.data:Promise.resolve(e.data)).then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}};it.create=(t,e)=>new it({type:t,typeName:Z.ZodPromise,...$(e)});var Me=class extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:a}=this._processInputParams(t),s=this._def.effect||null,n={addIssue:i=>{k(a,i),i.fatal?e.abort():e.dirty()},get path(){return a.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){let i=s.transform(a.data,n);if(a.common.async)return Promise.resolve(i).then(async r=>{if(e.value==="aborted")return E;let l=await this._def.schema._parseAsync({data:r,path:a.path,parent:a});return l.status==="aborted"?E:l.status==="dirty"||e.value==="dirty"?Kt(l.value):l});{if(e.value==="aborted")return E;let r=this._def.schema._parseSync({data:i,path:a.path,parent:a});return r.status==="aborted"?E:r.status==="dirty"||e.value==="dirty"?Kt(r.value):r}}if(s.type==="refinement"){let i=r=>{let l=s.refinement(r,n);if(a.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return r};if(a.common.async===!1){let r=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?E:(r.status==="dirty"&&e.dirty(),i(r.value),{status:e.value,value:r.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(r=>r.status==="aborted"?E:(r.status==="dirty"&&e.dirty(),i(r.value).then(()=>({status:e.value,value:r.value}))))}if(s.type==="transform")if(a.common.async===!1){let i=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!He(i))return E;let r=s.transform(i.value,n);if(r instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:r}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(i=>He(i)?Promise.resolve(s.transform(i.value,n)).then(r=>({status:e.value,value:r})):E);U.assertNever(s)}};Me.create=(t,e,a)=>new Me({schema:t,typeName:Z.ZodEffects,effect:e,...$(a)}),Me.createWithPreprocess=(t,e,a)=>new Me({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...$(a)});var Oe=class extends D{_parse(t){return this._getType(t)===N.undefined?ue(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Oe.create=(t,e)=>new Oe({innerType:t,typeName:Z.ZodOptional,...$(e)});var Be=class extends D{_parse(t){return this._getType(t)===N.null?ue(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Be.create=(t,e)=>new Be({innerType:t,typeName:Z.ZodNullable,...$(e)});var Ct=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return e.parsedType===N.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};Ct.create=(t,e)=>new Ct({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});var It=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a={...e,common:{...e.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return yt(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new xe(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xe(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};It.create=(t,e)=>new It({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});var na=class extends D{_parse(t){if(this._getType(t)!==N.nan){let e=this._getOrReturnCtx(t);return k(e,{code:g.invalid_type,expected:N.nan,received:e.parsedType}),E}return{status:"valid",value:t.data}}};na.create=t=>new na({typeName:Z.ZodNaN,...$(t)});var Ga=class extends D{_parse(t){let{ctx:e}=this._processInputParams(t),a=e.data;return this._def.type._parse({data:a,path:e.path,parent:e})}unwrap(){return this._def.type}},Qa=class an extends D{_parse(e){let{status:a,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?E:n.status==="dirty"?(a.dirty(),Kt(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?E:n.status==="dirty"?(a.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,a){return new an({in:e,out:a,typeName:Z.ZodPipeline})}},Tt=class extends D{_parse(t){let e=this._def.innerType._parse(t),a=s=>(He(s)&&(s.value=Object.freeze(s.value)),s);return yt(e)?e.then(s=>a(s)):a(e)}unwrap(){return this._def.innerType}};Tt.create=(t,e)=>new Tt({innerType:t,typeName:Z.ZodReadonly,...$(e)}),be.lazycreate;var Z;(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"})(Z||(Z={}));var f=xt.create,we=Jt.create;na.create,Ht.create;var Ie=Yt.create;Gt.create,Qt.create,vt.create,_t.create,Xt.create;var b=Ye.create;Fe.create,ea.create;var H=Ge.create,_=be.create;be.strictCreate;var K=bt.create;Kr.create,wt.create,Ve.create;var w=Jr.create;aa.create,sa.create,Hr.create,kt.create;var j=jt.create;Nt.create,St.create,it.create,Me.create,Oe.create,Be.create,Me.createWithPreprocess,Qa.create;const ze={authenticate:"authenticate",initialize:"initialize",session_cancel:"session/cancel",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Ee={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},Xa=_({_meta:w(b()).optional(),content:f(),path:f(),sessionId:f()}),es=_({_meta:w(b()).optional(),limit:we().optional().nullable(),line:we().optional().nullable(),path:f(),sessionId:f()}),ts=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),as=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),ss=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),ns=_({_meta:w(b()).optional(),sessionId:f(),terminalId:f()}),Yr=w(b()),Gr=K([j("assistant"),j("user")]),Qr=_({_meta:w(b()).optional(),mimeType:f().optional().nullable(),text:f(),uri:f()}),Xr=_({_meta:w(b()).optional(),blob:f(),mimeType:f().optional().nullable(),uri:f()}),rs=K([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]),is=K([j("pending"),j("in_progress"),j("completed"),j("failed")]),ei=_({_meta:w(b()).optional()}),ti=_({_meta:w(b()).optional(),content:f()}),ai=_({_meta:w(b()).optional(),outcome:K([_({outcome:j("cancelled")}),_({optionId:f(),outcome:j("selected")})])}),si=_({_meta:w(b()).optional(),terminalId:f()}),ni=_({_meta:w(b()).optional()}),ri=_({_meta:w(b()).optional(),exitCode:we().optional().nullable(),signal:f().optional().nullable()}),ii=_({_meta:w(b()).optional()}),oi=w(b()),li=_({_meta:w(b()).optional(),sessionId:f()}),di=w(b()),ci=_({_meta:w(b()).optional(),methodId:f()}),ui=_({_meta:w(b()).optional(),modeId:f(),sessionId:f()}),mi=_({_meta:w(b()).optional(),modelId:f(),sessionId:f()}),pi=w(b()),os=_({_meta:w(b()).optional(),name:f(),value:f()}),Te=_({_meta:w(b()).optional(),audience:H(Gr).optional().nullable(),lastModified:f().optional().nullable(),priority:we().optional().nullable()}),ls=K([Qr,Xr]),hi=_({_meta:w(b()).optional()}),fi=_({meta:b().optional()}),gi=_({_meta:w(b()).optional(),stopReason:K([j("end_turn"),j("max_tokens"),j("max_turn_requests"),j("refusal"),j("cancelled")])}),yi=_({_meta:w(b()).optional()}),xi=w(b()),ds=f(),vi=w(b()),_i=_({hint:f()}),bi=_({_meta:w(b()).optional(),kind:K([j("allow_once"),j("allow_always"),j("reject_once"),j("reject_always")]),name:f(),optionId:f()}),ra=K([_({content:K([_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),text:f(),type:j("text")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("image"),uri:f().optional().nullable()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("audio")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),description:f().optional().nullable(),mimeType:f().optional().nullable(),name:f(),size:we().optional().nullable(),title:f().optional().nullable(),type:j("resource_link"),uri:f()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),resource:ls,type:j("resource")})]),type:j("content")}),_({_meta:w(b()).optional(),newText:f(),oldText:f().optional().nullable(),path:f(),type:j("diff")}),_({terminalId:f(),type:j("terminal")})]),ia=_({_meta:w(b()).optional(),line:we().optional().nullable(),path:f()}),cs=_({_meta:w(b()).optional(),name:f(),value:f()}),wi=_({_meta:w(b()).optional(),exitCode:we().optional().nullable(),signal:f().optional().nullable()}),ki=_({_meta:w(b()).optional(),readTextFile:Ie().optional(),writeTextFile:Ie().optional()}),ji=_({args:H(f()),command:f(),env:H(cs),name:f()}),us=K([_({headers:H(os),name:f(),type:j("http"),url:f()}),_({headers:H(os),name:f(),type:j("sse"),url:f()}),ji]),At=K([_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),text:f(),type:j("text")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("image"),uri:f().optional().nullable()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),data:f(),mimeType:f(),type:j("audio")}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),description:f().optional().nullable(),mimeType:f().optional().nullable(),name:f(),size:we().optional().nullable(),title:f().optional().nullable(),type:j("resource_link"),uri:f()}),_({_meta:w(b()).optional(),annotations:Te.optional().nullable(),resource:ls,type:j("resource")})]),Ni=_({_meta:w(b()).optional(),description:f().optional().nullable(),id:f(),name:f()}),Si=_({_meta:w(b()).optional(),http:Ie().optional(),sse:Ie().optional()}),Ci=_({_meta:w(b()).optional(),audio:Ie().optional(),embeddedContext:Ie().optional(),image:Ie().optional()}),Ii=_({_meta:w(b()).optional(),description:f().optional().nullable(),modelId:f(),name:f()}),Ti=_({_meta:w(b()).optional(),description:f().optional().nullable(),id:ds,name:f()}),ms=_({_meta:w(b()).optional(),availableModels:H(Ii),currentModelId:f()}),ps=_({_meta:w(b()).optional(),availableModes:H(Ti),currentModeId:f()}),Ai=_({_meta:w(b()).optional(),content:f(),priority:K([j("high"),j("medium"),j("low")]),status:K([j("pending"),j("in_progress"),j("completed")])}),Ri=_i,Mi=K([li,di]),hs=_({_meta:w(b()).optional(),args:H(f()).optional(),command:f(),cwd:f().optional().nullable(),env:H(cs).optional(),outputByteLimit:we().optional().nullable(),sessionId:f()}),Oi=_({_meta:w(b()).optional(),exitStatus:wi.optional().nullable(),output:f(),truncated:Ie()}),Ei=_({_meta:w(b()).optional(),cwd:f(),mcpServers:H(us)}),Zi=_({_meta:w(b()).optional(),cwd:f(),mcpServers:H(us),sessionId:f()}),Pi=_({_meta:w(b()).optional(),prompt:H(At),sessionId:f()}),$i=_({_meta:w(b()).optional(),models:ms.optional().nullable(),modes:ps.optional().nullable(),sessionId:f()}),Fi=_({_meta:w(b()).optional(),models:ms.optional().nullable(),modes:ps.optional().nullable()}),Di=_({_meta:w(b()).optional(),content:H(ra).optional().nullable(),kind:rs.optional().nullable(),locations:H(ia).optional().nullable(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),status:is.optional().nullable(),title:f().optional().nullable(),toolCallId:f()}),zi=_({_meta:w(b()).optional(),fs:ki.optional(),terminal:Ie().optional()}),Li=_({_meta:w(b()).optional(),loadSession:Ie().optional(),mcpCapabilities:Si.optional(),promptCapabilities:Ci.optional()}),Ui=_({_meta:w(b()).optional(),description:f(),input:Ri.optional().nullable(),name:f()}),qi=K([ei,ti,ai,si,Oi,ni,ri,ii,oi]),fs=_({_meta:w(b()).optional(),options:H(bi),sessionId:f(),toolCall:Di}),Wi=_({_meta:w(b()).optional(),clientCapabilities:zi.optional(),protocolVersion:we()}),Vi=_({_meta:w(b()).optional(),agentCapabilities:Li.optional(),authMethods:H(Ni).optional(),protocolVersion:we()}),gs=_({_meta:w(b()).optional(),sessionId:f(),update:K([_({content:At,sessionUpdate:j("user_message_chunk")}),_({content:At,sessionUpdate:j("agent_message_chunk")}),_({content:At,sessionUpdate:j("agent_thought_chunk")}),_({_meta:w(b()).optional(),content:H(ra).optional(),kind:K([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]).optional(),locations:H(ia).optional(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),sessionUpdate:j("tool_call"),status:K([j("pending"),j("in_progress"),j("completed"),j("failed")]).optional(),title:f(),toolCallId:f()}),_({_meta:w(b()).optional(),content:H(ra).optional().nullable(),kind:rs.optional().nullable(),locations:H(ia).optional().nullable(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),sessionUpdate:j("tool_call_update"),status:is.optional().nullable(),title:f().optional().nullable(),toolCallId:f()}),_({_meta:w(b()).optional(),entries:H(Ai),sessionUpdate:j("plan")}),_({availableCommands:H(Ui),sessionUpdate:j("available_commands_update")}),_({currentModeId:ds,sessionUpdate:j("current_mode_update")})])});K([K([Xa,es,fs,hs,ts,as,ss,ns,Yr]),qi,Mi,K([Wi,ci,Ei,Zi,ui,Pi,mi,pi]),K([Vi,hi,$i,Fi,fi,gi,yi,xi]),K([gs,vi])]);function Bi(t,e){let a=new TextEncoder,s=new TextDecoder;return{readable:new ReadableStream({async start(n){let i="",r=e.getReader();try{for(;;){let{value:l,done:d}=await r.read();if(d)break;if(!l)continue;i+=s.decode(l,{stream:!0});let c=i.split(`
2
2
  `);i=c.pop()||"";for(let u of c){let m=u.trim();if(m)try{let h=JSON.parse(m);n.enqueue(h)}catch(h){console.error("Failed to parse JSON message:",m,h)}}}}finally{r.releaseLock(),n.close()}}}),writable:new WritableStream({async write(n){let i=JSON.stringify(n)+`
3
3
  `,r=t.getWriter();try{await r.write(a.encode(i))}finally{r.releaseLock()}}})}}var Ki=(Hs=class{constructor(t,e){Re(this,me);let a=t(this);We(this,me,new Ji(async(s,n)=>{var i,r,l,d,c,u,m;switch(s){case Ee.fs_write_text_file:{let h=Xa.parse(n);return(i=a.writeTextFile)==null?void 0:i.call(a,h)}case Ee.fs_read_text_file:{let h=es.parse(n);return(r=a.readTextFile)==null?void 0:r.call(a,h)}case Ee.session_request_permission:{let h=fs.parse(n);return a.requestPermission(h)}case Ee.terminal_create:{let h=hs.parse(n);return(l=a.createTerminal)==null?void 0:l.call(a,h)}case Ee.terminal_output:{let h=ts.parse(n);return(d=a.terminalOutput)==null?void 0:d.call(a,h)}case Ee.terminal_release:{let h=as.parse(n);return await((c=a.releaseTerminal)==null?void 0:c.call(a,h))??{}}case Ee.terminal_wait_for_exit:{let h=ss.parse(n);return(u=a.waitForTerminalExit)==null?void 0:u.call(a,h)}case Ee.terminal_kill:{let h=ns.parse(n);return await((m=a.killTerminal)==null?void 0:m.call(a,h))??{}}default:if(s.startsWith("_")){let h=s.substring(1);if(!a.extMethod)throw ke.methodNotFound(s);return a.extMethod(h,n)}throw ke.methodNotFound(s)}},async(s,n)=>{switch(s){case Ee.session_update:{let i=gs.parse(n);return a.sessionUpdate(i)}default:if(s.startsWith("_")){let i=s.substring(1);return a.extNotification?a.extNotification(i,n):void 0}throw ke.methodNotFound(s)}},e))}async initialize(t){return await Q(this,me).sendRequest(ze.initialize,t)}async newSession(t){return await Q(this,me).sendRequest(ze.session_new,t)}async loadSession(t){return await Q(this,me).sendRequest(ze.session_load,t)??{}}async setSessionMode(t){return await Q(this,me).sendRequest(ze.session_set_mode,t)??{}}async setSessionModel(t){return await Q(this,me).sendRequest(ze.session_set_model,t)??{}}async authenticate(t){return await Q(this,me).sendRequest(ze.authenticate,t)??{}}async prompt(t){return await Q(this,me).sendRequest(ze.session_prompt,t)}async cancel(t){return await Q(this,me).sendNotification(ze.session_cancel,t)}async extMethod(t,e){return await Q(this,me).sendRequest(`_${t}`,e)}async extNotification(t,e){return await Q(this,me).sendNotification(`_${t}`,e)}},me=new WeakMap,Hs),Ji=(Ys=class{constructor(t,e,a){Re(this,ne);Re(this,et,new Map);Re(this,Ft,0);Re(this,ct);Re(this,ut);Re(this,tt);Re(this,at,Promise.resolve());We(this,ct,t),We(this,ut,e),We(this,tt,a),Se(this,ne,sn).call(this)}async sendRequest(t,e){let a=ba(this,Ft)._++,s=new Promise((n,i)=>{Q(this,et).set(a,{resolve:n,reject:i})});return await Se(this,ne,dt).call(this,{jsonrpc:"2.0",id:a,method:t,params:e}),s}async sendNotification(t,e){await Se(this,ne,dt).call(this,{jsonrpc:"2.0",method:t,params:e})}},et=new WeakMap,Ft=new WeakMap,ct=new WeakMap,ut=new WeakMap,tt=new WeakMap,at=new WeakMap,ne=new WeakSet,sn=async function(){let t=Q(this,tt).readable.getReader();try{for(;;){let{value:e,done:a}=await t.read();if(a)break;if(e)try{Se(this,ne,nn).call(this,e)}catch(s){console.error("Unexpected error during message processing:",e,s),"id"in e&&e.id!==void 0&&Se(this,ne,dt).call(this,{jsonrpc:"2.0",id:e.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}},nn=async function(t){if("method"in t&&"id"in t){let e=await Se(this,ne,rn).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await Se(this,ne,dt).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){let e=await Se(this,ne,on).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?Se(this,ne,ln).call(this,t):console.error("Invalid message",{message:t})},rn=async function(t,e){try{return{result:await Q(this,ct).call(this,t,e)??null}}catch(a){if(a instanceof ke)return a.toResult();if(a instanceof xe)return ke.invalidParams(a.format()).toResult();let s;(a instanceof Error||typeof a=="object"&&a&&"message"in a&&typeof a.message=="string")&&(s=a.message);try{return ke.internalError(s?JSON.parse(s):{}).toResult()}catch{return ke.internalError({details:s}).toResult()}}},on=async function(t,e){try{return await Q(this,ut).call(this,t,e),{result:null}}catch(a){if(a instanceof ke)return a.toResult();if(a instanceof xe)return ke.invalidParams(a.format()).toResult();let s;(a instanceof Error||typeof a=="object"&&a&&"message"in a&&typeof a.message=="string")&&(s=a.message);try{return ke.internalError(s?JSON.parse(s):{}).toResult()}catch{return ke.internalError({details:s}).toResult()}}},ln=function(t){let e=Q(this,et).get(t.id);e?("result"in t?e.resolve(t.result):"error"in t&&e.reject(t.error),Q(this,et).delete(t.id)):console.error("Got response to unknown request",t.id)},dt=async function(t){return We(this,at,Q(this,at).then(async()=>{let e=Q(this,tt).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{console.error("ACP write error:",e)})),Q(this,at)},Ys),ke=class qe extends Error{constructor(a,s,n){super(s);B(this,"code");B(this,"data");this.code=a,this.name="RequestError",this.data=n}static parseError(a){return new qe(-32700,"Parse error",a)}static invalidRequest(a){return new qe(-32600,"Invalid request",a)}static methodNotFound(a){return new qe(-32601,"Method not found",{method:a})}static invalidParams(a){return new qe(-32602,"Invalid params",a)}static internalError(a){return new qe(-32603,"Internal error",a)}static authRequired(a){return new qe(-32e3,"Authentication required",a)}static resourceNotFound(a){return new qe(-32002,"Resource not found",a&&{uri:a})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}},Hi=class{constructor(){B(this,"promise");B(this,"resolve");B(this,"reject");this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}},Xe=class dn extends Error{constructor(a,s){super(a.message);B(this,"code");B(this,"data");B(this,"id");this.name="JsonRpcError",this.code=a.code,this.data=a.data,this.id=s}static isJsonRpcError(a){return a instanceof dn}toJSON(){return{jsonrpc:"2.0",id:this.id??null,error:{code:this.code,message:this.message,data:this.data}}}};const Yi={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603};var Gi=class{constructor(t,e){B(this,"agent");B(this,"options");B(this,"pendingPermissions",new Map);this.agent=t,this.options=e}async sessionUpdate(t){this.options.onSessionNotification(t)}async writeTextFile(t){if(this.options.writeTextFile)return this.options.writeTextFile(t);throw Error("Write text file handler not implemented")}async readTextFile(t){if(this.options.readTextFile)return this.options.readTextFile(t);throw Error("Read text file handler not implemented")}async requestPermission(t){let e=`${Date.now()}-${Math.random()}`,a=new Hi;return this.pendingPermissions.set(e,a),this.options.onRequestPermission({...t,deferredId:e}),a.promise}resolvePermission(t,e){let a=this.pendingPermissions.get(t);a&&(this.pendingPermissions.delete(t),a.resolve(e))}rejectPermission(t,e){let a=this.pendingPermissions.get(t);a&&(this.pendingPermissions.delete(t),a.reject(e))}};function Qi(t){if(t instanceof Xe)return t;if(t instanceof Error)return new Xe({code:Yi.INTERNAL_ERROR,message:t.message,data:t.stack});if(t&&typeof t=="object"&&"code"in t&&"message"in t&&typeof t.code=="number"&&typeof t.message=="string"){let e=t;return new Xe({code:e.code,message:e.message,data:e.data},void 0)}return null}var Xi=class{constructor(t,e){B(this,"agent");B(this,"callbacks");this.agent=t,this.callbacks=e}handleCatchRpcError(t){return e=>{var s,n;let a=Qi(e);throw a?(console.error(`[acp] JSON-RPC error in ${t}:`,a),(n=(s=this.callbacks).on_rpc_error)==null||n.call(s,a),a):e}}extMethod(t,e){return this.agent.extMethod?this.agent.extMethod(t,e):Promise.resolve({})}extNotification(t,e){return this.agent.extNotification?this.agent.extNotification(t,e):Promise.resolve()}async setSessionMode(t){var a,s,n,i,r,l;(s=(a=this.callbacks).on_setSessionMode_start)==null||s.call(a,t);let e=await((i=(n=this.agent).setSessionMode)==null?void 0:i.call(n,t).catch(this.handleCatchRpcError("setSessionMode")));return(l=(r=this.callbacks).on_setSessionMode_response)==null||l.call(r,e,t),e}async setSessionModel(t){var a,s,n,i,r,l;(s=(a=this.callbacks).on_setSessionModel_start)==null||s.call(a,t);let e=await((i=(n=this.agent).setSessionModel)==null?void 0:i.call(n,t).catch(this.handleCatchRpcError("setSessionModel")));return(l=(r=this.callbacks).on_setSessionModel_response)==null||l.call(r,e,t),e}async initialize(t){var a,s,n,i;(s=(a=this.callbacks).on_initialize_start)==null||s.call(a,t);let e=await this.agent.initialize(t).catch(this.handleCatchRpcError("initialize"));return(i=(n=this.callbacks).on_initialize_response)==null||i.call(n,e,t),e}async newSession(t){var a,s,n,i;(s=(a=this.callbacks).on_newSession_start)==null||s.call(a,t);let e=await this.agent.newSession(t).catch(this.handleCatchRpcError("newSession"));return(i=(n=this.callbacks).on_newSession_response)==null||i.call(n,e,t),e}async loadSession(t){var e,a,s,n;if((a=(e=this.callbacks).on_loadSession_start)==null||a.call(e,t),this.agent.loadSession){let i=await this.agent.loadSession(t).catch(this.handleCatchRpcError("loadSession"));return(n=(s=this.callbacks).on_loadSession_response)==null||n.call(s,i,t),i}throw Error("Agent does not support loadSession capability")}async authenticate(t){var e,a,s,n;(a=(e=this.callbacks).on_authenticate_start)==null||a.call(e,t),await this.agent.authenticate(t).catch(this.handleCatchRpcError("authenticate")),(n=(s=this.callbacks).on_authenticate_response)==null||n.call(s,void 0,t)}async prompt(t){var a,s,n,i;(s=(a=this.callbacks).on_prompt_start)==null||s.call(a,t);let e=await this.agent.prompt(t).catch(this.handleCatchRpcError("prompt"));return(i=(n=this.callbacks).on_prompt_response)==null||i.call(n,e,t),e}async cancel(t){var e,a,s,n;(a=(e=this.callbacks).on_cancel_start)==null||a.call(e,t),await this.agent.cancel(t).catch(this.handleCatchRpcError("cancel")),(n=(s=this.callbacks).on_cancel_response)==null||n.call(s,void 0,t)}};const eo=globalThis.ReadableStream,to=globalThis.WritableStream;function ao(){return globalThis.ReadableStream!==void 0&&globalThis.WritableStream!==void 0}function so(t){return new to({write(e){t.readyState===WebSocket.OPEN&&t.send(e)},close(){t.close()},abort(){t.close()}})}function no(t){let e=new eo({start(s){t.onmessage=n=>{if(n.data instanceof ArrayBuffer)s.enqueue(new Uint8Array(n.data));else if(n.data instanceof Uint8Array)s.enqueue(n.data);else{let i=new TextEncoder;s.enqueue(i.encode(`${n.data}
4
4
  `))}},t.onclose=()=>{s.close()},t.onerror=n=>{s.error(n)}},cancel(){t.close()}}),a=async function*(){let s=e.getReader();try{for(;;){let{value:n,done:i}=await s.read();if(i)break;yield n}}finally{s.releaseLock()}return void 0};return e.values=a,e[Symbol.asyncIterator]=a,e}ao()||console.warn("Streams API not supported in this browser. Consider using a polyfill.");var ro=class{constructor(t){B(this,"managers",new Map);B(this,"options");B(this,"currentUrl",null);this.options=t}async connect(t){this.currentUrl=t;let e=this.managers.get(t);if(e){if(e.getConnectionState()==="connected"){let a=e.getStreams();if(a)return a}}else e=new io({url:t,onConnectionStateChange:a=>this.options.onConnectionStateChange(a,t),onError:a=>this.options.onError(a,t),reconnectAttempts:this.options.reconnectAttempts,reconnectDelay:this.options.reconnectDelay}),this.managers.set(t,e);return await e.connect()}disconnect(t){if(t){let e=this.managers.get(t);e&&(e.disconnect(),this.managers.delete(t))}else{for(let[e,a]of this.managers.entries())a.disconnect(),this.managers.delete(e);this.currentUrl=null}}getCurrentUrl(){return this.currentUrl}getConnectionState(t){let e=t||this.currentUrl;if(!e)return"disconnected";let a=this.managers.get(e);return a?a.getConnectionState():"disconnected"}getActiveConnections(){return Array.from(this.managers.keys()).filter(t=>{var e;return((e=this.managers.get(t))==null?void 0:e.getConnectionState())==="connected"})}},io=class{constructor(t){B(this,"ws",null);B(this,"options");B(this,"reconnectCount",0);B(this,"reconnectTimer",null);B(this,"readableStream",null);B(this,"writableStream",null);this.options={reconnectAttempts:3,reconnectDelay:1e3,...t}}async connect(){this.updateConnectionState({status:"connecting",url:this.options.url});try{return this.ws=new WebSocket(this.options.url),new Promise((t,e)=>{if(!this.ws){e(Error("WebSocket not initialized"));return}this.ws.onopen=()=>{this.reconnectCount=0,this.updateConnectionState({status:"connected",url:this.options.url}),this.ws&&(this.readableStream=no(this.ws),this.writableStream=so(this.ws),t({readable:this.readableStream,writable:this.writableStream}))},this.ws.onerror=a=>{let s=Error("WebSocket connection error");this.options.onError(s),this.updateConnectionState({status:"error",error:s.message,url:this.options.url}),e(s)},this.ws.onclose=()=>{this.updateConnectionState({status:"disconnected",url:this.options.url}),this.attemptReconnect()}})}catch(t){let e=t instanceof Error?t:Error(String(t));throw this.options.onError(e),this.updateConnectionState({status:"error",error:e.message,url:this.options.url}),e}}disconnect(){this.reconnectTimer&&(this.reconnectTimer=(clearTimeout(this.reconnectTimer),null)),this.ws&&(this.ws=(this.ws.close(),null)),this.readableStream=null,this.writableStream=null,this.updateConnectionState({status:"disconnected"})}attemptReconnect(){let t=this.options.reconnectAttempts??3;this.reconnectCount<t&&(this.reconnectCount++,this.reconnectTimer=setTimeout(async()=>{try{await this.connect()}catch{}},this.options.reconnectDelay))}updateConnectionState(t){this.options.onConnectionStateChange(t)}getConnectionState(){if(!this.ws)return"disconnected";switch(this.ws.readyState){case WebSocket.CONNECTING:return"connecting";case WebSocket.OPEN:return"connected";case WebSocket.CLOSING:case WebSocket.CLOSED:return"disconnected";default:return"error"}}getStreams(){return this.readableStream&&this.writableStream?{readable:this.readableStream,writable:this.writableStream}:null}},ys=t=>{let e,a=new Set,s=(l,d)=>{let c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){let u=e;e=d??(typeof c!="object"||!c)?c:Object.assign({},e,c),a.forEach(m=>m(e,u))}},n=()=>e,i={setState:s,getState:n,getInitialState:()=>r,subscribe:l=>(a.add(l),()=>a.delete(l))},r=e=t(s,n,i);return i},oo=(t=>t?ys(t):ys),R=wa(gn(),1),lo=t=>t;function co(t,e=lo){let a=R.useSyncExternalStore(t.subscribe,R.useCallback(()=>e(t.getState()),[t,e]),R.useCallback(()=>e(t.getInitialState()),[t,e]));return R.useDebugValue(a),a}var xs=t=>{let e=oo(t),a=s=>co(e,s);return Object.assign(a,e),a};const uo=(t=>t?xs(t):xs)((t,e)=>({connections:{},activeConnectionUrl:null,connectionState:{status:"disconnected"},agentCapabilities:null,activeSessionId:null,notifications:{},sessionModes:{},setConnection:(a,s,n)=>{t(i=>{var r,l;return{connections:{...i.connections,[a]:{url:a,state:s,capabilities:n??((r=i.connections[a])==null?void 0:r.capabilities)??null}},...i.activeConnectionUrl===a&&{connectionState:s,agentCapabilities:n??((l=i.connections[a])==null?void 0:l.capabilities)??null}}})},setActiveConnection:a=>{t(s=>{let n=a?s.connections[a]:null;return{activeConnectionUrl:a,connectionState:(n==null?void 0:n.state)??{status:"disconnected"},agentCapabilities:(n==null?void 0:n.capabilities)??null}})},removeConnection:a=>{t(s=>{let n={...s.connections};delete n[a];let i=s.activeConnectionUrl===a?null:s.activeConnectionUrl,r=i?n[i]:null;return{connections:n,activeConnectionUrl:i,connectionState:(r==null?void 0:r.state)??{status:"disconnected"},agentCapabilities:(r==null?void 0:r.capabilities)??null}})},setConnectionState:a=>{t({connectionState:a});let{activeConnectionUrl:s}=e();s&&e().setConnection(s,a)},setAgentCapabilities:a=>{t({agentCapabilities:a});let{activeConnectionUrl:s}=e();s&&e().setConnection(s,e().connectionState,a)},setActiveSessionId:a=>{t({activeSessionId:a})},setActiveModeId:(a,s)=>{t(n=>{let i=n.sessionModes[a];return{sessionModes:{...n.sessionModes,[a]:{...i,currentModeId:s}}}})},setModeState:(a,s)=>{t(n=>({sessionModes:{...n.sessionModes,[a]:s}}))},addNotification:a=>{var l;let s=e().notifications,n;if(n=a.type==="session_notification"&&((l=a.data)!=null&&l.sessionId)?a.data.sessionId:e().activeSessionId,!n)return;let i={...a,id:`${Date.now()}-${Math.random()}`,timestamp:Date.now()},r=s[n]||[];t({notifications:{...s,[n]:[...r,i]}})},clearNotifications:a=>{if(a){let s={...e().notifications};delete s[a],t({notifications:s})}else t({notifications:{}})},getActiveNotifications:()=>{let{activeSessionId:a,notifications:s}=e();return a&&s[a]||[]},getActiveConnection:()=>{let{activeConnectionUrl:a,connections:s}=e();return a&&s[a]||null},getConnection:a=>{let{connections:s}=e();return s[a]||{url:a,state:{status:"disconnected"},capabilities:null}}}));var mo=typeof window<"u"?R.useLayoutEffect:R.useEffect;function Le(t){let e=(0,R.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return mo(()=>{e.current=t},[t]),(0,R.useCallback)((...a)=>{var s;return(s=e.current)==null?void 0:s.call(e,...a)},[e])}function po(t){let{wsUrl:e,autoConnect:a=!0,reconnectAttempts:s=3,reconnectDelay:n=2e3,clientOptions:i={}}=t,{getConnection:r,notifications:l,activeSessionId:d,agentCapabilities:c,sessionModes:u,setActiveModeId:m,setModeState:h,setActiveSessionId:p,setConnection:x,setActiveConnection:y,addNotification:v,clearNotifications:S}=uo(),[C,I]=(0,R.useState)(null),[A,O]=(0,R.useState)(null),[F,q]=(0,R.useState)(!1),[Y,re]=(0,R.useState)([]),G=(0,R.useRef)(null),ee=(0,R.useRef)(null),se=(0,R.useRef)(null),z=(0,R.useRef)(!1),P=Le((W,X)=>{x(X,W),v({type:"connection_change",data:W})}),de=Le((W,X)=>{v({type:"error",data:W})}),ie=Le(W=>{v({type:"session_notification",data:W}),W.update.sessionUpdate==="available_commands_update"&&re(W.update.availableCommands)}),pe=Le(W=>{I(W)}),Ae=Le(async()=>{G.current||(G.current=new ro({onConnectionStateChange:P,onError:de,reconnectAttempts:s,reconnectDelay:n})),y(e);let{readable:W,writable:X}=await G.current.connect(e);O(new Xi(new Ki(V=>{let J=new Gi(V,{...i,onRequestPermission:he=>{var M;(M=i==null?void 0:i.onRequestPermission)==null||M.call(i,he),pe(he)},onSessionNotification:he=>{var M;(M=i==null?void 0:i.onSessionNotification)==null||M.call(i,he),ie(he)},onRpcError:he=>{var M;(M=i==null?void 0:i.onRpcError)==null||M.call(i,he),de(he,e)}});return ee.current=J,J},Bi(X,W)),{on_initialize_response:V=>{let J=V.agentCapabilities;console.log("[acp] Agent capabilities",J),x(e,r(e).state,J)},on_newSession_response:V=>{console.log("[acp] New session created",V);let J=V.sessionId;p(J),h(J,V.modes)},on_loadSession_response:(V,J)=>{console.log("[acp] Session resumed",J);let he=J.sessionId;p(he),h(he,V.modes)},on_prompt_start:V=>{for(let J of V.prompt)v({type:"session_notification",data:{sessionId:V.sessionId,update:{sessionUpdate:"user_message_chunk",content:J}}})},on_setSessionMode_start:V=>{console.log("[acp] Session mode set",V);let J=V.sessionId;m(J,V.modeId)},on_rpc_error:V=>de(V,e)}))}),ce=Le(W=>{let X=W||e;G.current&&(W?G.current.disconnect(W):(G.current.disconnect(X),G.current=null,ee.current=null,O(null))),W||(I(null),re([]),z.current=!1,se.current=null,q(!1))}),Ne=Le(W=>{if(C&&ee.current){let X=C.deferredId;X&&ee.current.resolvePermission(X,W)}I(null)}),ve=Le(W=>{if(C&&ee.current){let X=C.deferredId;X&&ee.current.rejectPermission(X,W)}I(null)});return(0,R.useEffect)(()=>(p(null),a&&Ae().catch(console.error),()=>{ce()}),[a,e]),{connect:Ae,disconnect:ce,connectionState:r(e).state,activeSessionId:d,notifications:d&&l[d]||[],isSessionLoading:F,clearNotifications:S,pendingPermission:C,setActiveSessionId:p,resolvePermission:Ne,rejectPermission:ve,agent:A,agentCapabilities:c,sessionMode:d?u[d]:null,availableCommands:Y}}function ho(t,e){if(!t)throw Error(e)}function fo(t){let e=[];for(let a of t){let s=e[e.length-1];s&&go(s.at(0),a)?s.push(a):e.push([a])}return e}var vs=["tool_call","tool_call_update"];function go(t,e){return t?t.type==="session_notification"&&e.type==="session_notification"?vs.includes(t.data.update.sessionUpdate)&&vs.includes(e.data.update.sessionUpdate)?!0:t.data.update.sessionUpdate===e.data.update.sessionUpdate:t.type===e.type:!1}function yo(t){var a;let e=new Map;for(let s of t)e.has(s.toolCallId)||e.set(s.toolCallId,[]),(a=e.get(s.toolCallId))==null||a.push(s);return Array.from(e.values()).map(s=>{var i;let n=s.at(0);return ho(!!(n!=null&&n.toolCallId),"Tool call ID is required"),{...n,toolCallId:n.toolCallId,status:(i=s.at(-1))==null?void 0:i.status,rawOutput:Object.assign({},...s.map(r=>r.rawOutput)),locations:s.flatMap(r=>r.locations||[]),content:s.flatMap(r=>r.content||[])}})}var xo=_e(),o=wa(Sn(),1);const _s=(0,R.memo)(t=>{let e=(0,xo.c)(10),{theme:a}=pr(),s;e[0]===t.original?s=e[1]:(s=yr({original:t.original,mergeControls:!1,collapseUnchanged:{margin:3,minSize:4}}),e[0]=t.original,e[1]=s);let n;e[2]===s?n=e[3]:(n=[Ln.lineWrapping,s],e[2]=s,e[3]=n);let i=n,r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={"--marimo-code-editor-font-size":"10px"},e[4]=r):r=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l={lineNumbers:!1,foldGutter:!1,dropCursor:!1,highlightActiveLineGutter:!1,allowMultipleSelections:!1,indentOnInput:!1,bracketMatching:!1,closeBrackets:!1,autocompletion:!1},e[5]=l):l=e[5];let d=a==="dark"?"dark":"light",c;return e[6]!==i||e[7]!==t.modified||e[8]!==d?(c=(0,o.jsx)(gr,{className:"cm font-mono",style:r,extensions:i,readOnly:!0,basicSetup:l,theme:d,value:t.modified}),e[6]=i,e[7]=t.modified,e[8]=d,e[9]=c):c=e[9],c});_s.displayName="ReadonlyDiff";function vo(t){let e=t[0];return e.sessionUpdate==="tool_call"||e.sessionUpdate==="tool_call_update"}function _o(t){return t[0].sessionUpdate==="agent_thought_chunk"}function bo(t){return t[0].sessionUpdate==="user_message_chunk"}function wo(t){return t[0].sessionUpdate==="agent_message_chunk"}function ko(t){return t[0].sessionUpdate==="plan"}var te=_e();function jo(t){if(t.length===0)return t;let e=[],a=null;for(let s of t)s.type==="text"?a===null?a=s.text:a+=s.text:(a!==null&&(e.push({type:"text",text:a}),a=null),e.push(s));return a!==null&&e.push({type:"text",text:a}),e}const No=t=>{let e=(0,te.c)(14),a=t.data,s=t.data.message;if(s.includes("WebSocket"))return null;a instanceof Xe&&(s=`${typeof a.data=="string"?a.data:JSON.stringify(a.data)} (code: ${a.code})`);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)("div",{className:"shrink-0",children:(0,o.jsx)(zt,{className:"h-5 w-5 text-(--red-11)"})}),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)("div",{className:"flex items-center gap-2 mb-2",children:(0,o.jsx)("h4",{className:"text-sm font-medium text-(--red-11)",children:"Agent Error"})}),e[1]=i):i=e[1];let r;e[2]===s?r=e[3]:(r=(0,o.jsx)("div",{className:"text-sm text-(--red-11) leading-relaxed mb-3",children:s}),e[2]=s,e[3]=r);let l;e[4]===t.onRetry?l=e[5]:(l=t.onRetry&&(0,o.jsxs)(le,{size:"xs",variant:"outline",onClick:t.onRetry,className:"text-(--red-11) border-(--red-6) hover:bg-(--red-3)",children:[(0,o.jsx)(La,{className:"h-3 w-3 mr-1"}),"Retry"]}),e[4]=t.onRetry,e[5]=l);let d;e[6]===t.onDismiss?d=e[7]:(d=t.onDismiss&&(0,o.jsxs)(le,{size:"xs",variant:"ghost",onClick:t.onDismiss,className:"text-(--red-10) hover:bg-(--red-3)",children:[(0,o.jsx)(Da,{className:"h-3 w-3 mr-1"}),"Dismiss"]}),e[6]=t.onDismiss,e[7]=d);let c;e[8]!==l||e[9]!==d?(c=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[l,d]}),e[8]=l,e[9]=d,e[10]=c):c=e[10];let u;return e[11]!==r||e[12]!==c?(u=(0,o.jsx)("div",{className:"border border-(--red-6) bg-(--red-2) rounded-lg p-4 my-2","data-block-type":"error",children:(0,o.jsxs)("div",{className:"flex items-start gap-3",children:[n,(0,o.jsxs)("div",{className:"flex-1 min-w-0",children:[i,r,c]})]})}),e[11]=r,e[12]=c,e[13]=u):u=e[13],u},oa=()=>{let t=(0,te.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("div",{className:"flex-1 flex items-center justify-center h-full min-h-[200px] flex-col",children:(0,o.jsxs)("div",{className:"text-center space-y-3",children:[(0,o.jsx)("div",{className:"w-12 h-12 mx-auto rounded-full bg-(--blue-3) flex items-center justify-center",children:(0,o.jsx)(ft,{className:"h-6 w-6 text-(--blue-10)"})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("h3",{className:"text-lg font-medium text-foreground mb-1",children:"Agent is connected"}),(0,o.jsx)("p",{className:"text-sm text-muted-foreground",children:"You can start chatting with your agent now"})]})]})}),t[0]=e):e=t[0],e},So=t=>{let e=(0,te.c)(34),{status:a}=t.data;if(t.isConnected&&t.isOnlyBlock){let I;return e[0]===Symbol.for("react.memo_cache_sentinel")?(I=(0,o.jsx)(oa,{}),e[0]=I):I=e[0],I}let s;e[1]===a?s=e[2]:(s=(()=>{switch(a){case"connected":return{icon:(0,o.jsx)(Wt,{className:"h-4 w-4"}),title:"Connected to Agent",message:"Successfully established connection with the AI agent",bgColor:"bg-(--blue-2)",borderColor:"border-(--blue-6)",textColor:"text-(--blue-11)",iconColor:"text-(--blue-10)"};case"disconnected":return{icon:(0,o.jsx)(nt,{className:"h-4 w-4"}),title:"Disconnected from Agent",message:"Connection to the AI agent has been lost",bgColor:"bg-(--amber-2)",borderColor:"border-(--amber-6)",textColor:"text-(--amber-11)",iconColor:"text-(--amber-10)"};case"connecting":return{icon:(0,o.jsx)(Wt,{className:"h-4 w-4 animate-pulse"}),title:"Connecting to Agent",message:"Establishing connection with the AI agent...",bgColor:"bg-(--gray-2)",borderColor:"border-(--gray-6)",textColor:"text-(--gray-11)",iconColor:"text-(--gray-10)"};case"error":return{icon:(0,o.jsx)(nt,{className:"h-4 w-4"}),title:"Connection Error",message:"Failed to connect to the AI agent",bgColor:"bg-(--red-2)",borderColor:"border-(--red-6)",textColor:"text-(--red-11)",iconColor:"text-(--red-10)"};default:return{icon:(0,o.jsx)(nt,{className:"h-4 w-4"}),title:"Connection Status Changed",message:`Agent connection status: ${a}`,bgColor:"bg-(--gray-2)",borderColor:"border-(--gray-6)",textColor:"text-(--gray-11)",iconColor:"text-(--gray-10)"}}})(),e[1]=a,e[2]=s);let n=s,i=a==="disconnected"||a==="error",r=`border ${n.borderColor} ${n.bgColor} rounded-lg p-3 my-2`,l=`shrink-0 ${n.iconColor}`,d;e[3]!==n.icon||e[4]!==l?(d=(0,o.jsx)("div",{className:l,children:n.icon}),e[3]=n.icon,e[4]=l,e[5]=d):d=e[5];let c=`text-sm font-medium ${n.textColor}`,u;e[6]!==n.title||e[7]!==c?(u=(0,o.jsx)("h4",{className:c,children:n.title}),e[6]=n.title,e[7]=c,e[8]=u):u=e[8];let m;e[9]===t.timestamp?m=e[10]:(m=t.timestamp&&(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(t.timestamp).toLocaleTimeString()}),e[9]=t.timestamp,e[10]=m);let h;e[11]!==u||e[12]!==m?(h=(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[u,m]}),e[11]=u,e[12]=m,e[13]=h):h=e[13];let p=`text-sm ${n.textColor} opacity-90 mb-2`,x;e[14]!==n.message||e[15]!==p?(x=(0,o.jsx)("div",{className:p,children:n.message}),e[14]=n.message,e[15]=p,e[16]=x):x=e[16];let y;e[17]!==n.bgColor||e[18]!==n.borderColor||e[19]!==n.textColor||e[20]!==t.onRetry||e[21]!==i?(y=i&&t.onRetry&&(0,o.jsxs)(le,{size:"xs",variant:"outline",onClick:t.onRetry,className:`${n.textColor} ${n.borderColor} hover:${n.bgColor}`,children:[(0,o.jsx)(La,{className:"h-3 w-3 mr-1"}),"Retry Connection"]}),e[17]=n.bgColor,e[18]=n.borderColor,e[19]=n.textColor,e[20]=t.onRetry,e[21]=i,e[22]=y):y=e[22];let v;e[23]!==y||e[24]!==h||e[25]!==x?(v=(0,o.jsxs)("div",{className:"flex-1 min-w-0",children:[h,x,y]}),e[23]=y,e[24]=h,e[25]=x,e[26]=v):v=e[26];let S;e[27]!==v||e[28]!==d?(S=(0,o.jsxs)("div",{className:"flex items-start gap-3",children:[d,v]}),e[27]=v,e[28]=d,e[29]=S):S=e[29];let C;return e[30]!==a||e[31]!==r||e[32]!==S?(C=(0,o.jsx)("div",{className:r,"data-block-type":"connection-change","data-status":a,children:S}),e[30]=a,e[31]=r,e[32]=S,e[33]=C):C=e[33],C},Co=t=>{let e=(0,te.c)(7),a=t.startTimestamp/1e3,s=t.endTimestamp/1e3,n=`Thought for ${Math.round(s-a)||"1"}s`,i;e[0]===t.data?i=e[1]:(i=t.data.map(Uo),e[0]=t.data,e[1]=i);let r;e[2]===i?r=e[3]:(r=(0,o.jsx)("div",{className:"flex flex-col gap-2 text-muted-foreground",children:(0,o.jsx)(Rt,{data:i})}),e[2]=i,e[3]=r);let l;return e[4]!==n||e[5]!==r?(l=(0,o.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,o.jsx)(ca,{title:n,children:r})}),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},Io=t=>{let e=(0,te.c)(14),a,s,n,i;if(e[0]!==t.data){let d=t.data.flatMap(qo);d=Un(d,Wo),n="rounded-lg border bg-background p-2 text-xs";let c=(0,o.jsxs)("span",{className:"font-medium text-muted-foreground",children:["To-dos"," ",(0,o.jsx)("span",{className:"font-normal text-muted-foreground",children:d.length})]});e[5]===c?i=e[6]:(i=(0,o.jsx)("div",{className:"flex items-center justify-between mb-2",children:c}),e[5]=c,e[6]=i),a="flex flex-col gap-1",s=d.map(Vo),e[0]=t.data,e[1]=a,e[2]=s,e[3]=n,e[4]=i}else a=e[1],s=e[2],n=e[3],i=e[4];let r;e[7]!==a||e[8]!==s?(r=(0,o.jsx)("ul",{className:a,children:s}),e[7]=a,e[8]=s,e[9]=r):r=e[9];let l;return e[10]!==n||e[11]!==i||e[12]!==r?(l=(0,o.jsxs)("div",{className:n,children:[i,r]}),e[10]=n,e[11]=i,e[12]=r,e[13]=l):l=e[13],l},To=t=>{let e=(0,te.c)(4),a;e[0]===t.data?a=e[1]:(a=t.data.map(Bo),e[0]=t.data,e[1]=a);let s;return e[2]===a?s=e[3]:(s=(0,o.jsx)("div",{className:"flex flex-col gap-2 text-muted-foreground border p-2 bg-background rounded wrap-break-word overflow-x-hidden",children:(0,o.jsx)(Rt,{data:a})}),e[2]=a,e[3]=s),s},Ao=t=>{let e=(0,te.c)(4),a;e[0]===t.data?a=e[1]:(a=jo(t.data.map(Ko)),e[0]=t.data,e[1]=a);let s=a,n;return e[2]===s?n=e[3]:(n=(0,o.jsx)("div",{className:"flex flex-col gap-2",children:(0,o.jsx)(Rt,{data:s})}),e[2]=s,e[3]=n),n},Rt=t=>{let e=(0,te.c)(5),a=Jo,s;if(e[0]!==t.data){let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(r,l)=>(0,o.jsx)(R.Fragment,{children:a(r)},`${r.type}-${l}`),e[2]=i):i=e[2],s=t.data.map(i),e[0]=t.data,e[1]=s}else s=e[1];let n;return e[3]===s?n=e[4]:(n=(0,o.jsx)("div",{children:s}),e[3]=s,e[4]=n),n},Ro=t=>{let e=(0,te.c)(3),a=`data:${t.data.mimeType};base64,${t.data.data}`,s=t.data.uri??"",n;return e[0]!==a||e[1]!==s?(n=(0,o.jsx)("img",{src:a,alt:s}),e[0]=a,e[1]=s,e[2]=n):n=e[2],n},Mo=t=>{let e=(0,te.c)(3),a=`data:${t.data.mimeType};base64,${t.data.data}`,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)("track",{kind:"captions"}),e[0]=s):s=e[0];let n;return e[1]===a?n=e[2]:(n=(0,o.jsx)("audio",{src:a,controls:!0,children:s}),e[1]=a,e[2]=n),n},Oo=t=>{let e=(0,te.c)(12);if("text"in t.data.resource){let a;e[0]===t.data.resource.mimeType?a=e[1]:(a=t.data.resource.mimeType&&(0,o.jsx)(la,{mimeType:t.data.resource.mimeType}),e[0]=t.data.resource.mimeType,e[1]=a);let s;e[2]!==t.data.resource.uri||e[3]!==a?(s=(0,o.jsx)(Ia,{children:(0,o.jsxs)("span",{className:"flex items-center gap-1 hover:bg-muted rounded-md px-1",children:[a,t.data.resource.uri]})}),e[2]=t.data.resource.uri,e[3]=a,e[4]=s):s=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)("span",{className:"text-muted-foreground text-xs mb-1 italic",children:"Formatted for agents, not humans."}),e[5]=n):n=e[5];let i;e[6]!==t.data.resource.mimeType||e[7]!==t.data.resource.text?(i=(0,o.jsxs)(Ta,{className:"max-h-96 overflow-y-auto scrollbar-thin whitespace-pre-wrap w-full max-w-[500px]",children:[n,t.data.resource.mimeType==="text/plain"?(0,o.jsx)("pre",{className:"text-xs whitespace-pre-wrap p-2 bg-muted rounded-md wrap-break-word",children:t.data.resource.text}):(0,o.jsx)(za,{content:t.data.resource.text})]}),e[6]=t.data.resource.mimeType,e[7]=t.data.resource.text,e[8]=i):i=e[8];let r;return e[9]!==s||e[10]!==i?(r=(0,o.jsxs)(Aa,{children:[s,i]}),e[9]=s,e[10]=i,e[11]=r):r=e[11],r}},Eo=t=>{var i;let e=(0,te.c)(19);if(t.data.uri.startsWith("http")){let r;return e[0]!==t.data.name||e[1]!==t.data.uri?(r=(0,o.jsx)("a",{href:t.data.uri,target:"_blank",rel:"noopener noreferrer",className:"text-link hover:underline px-1",children:t.data.name}),e[0]=t.data.name,e[1]=t.data.uri,e[2]=r):r=e[2],r}if((i=t.data.mimeType)!=null&&i.startsWith("image/")){let r;e[3]===t.data.mimeType?r=e[4]:(r=(0,o.jsx)(la,{mimeType:t.data.mimeType}),e[3]=t.data.mimeType,e[4]=r);let l=t.data.name||t.data.title||t.data.uri,d;e[5]!==r||e[6]!==l?(d=(0,o.jsx)(Ia,{children:(0,o.jsxs)("span",{className:"flex items-center gap-1 hover:bg-muted rounded-md px-1 cursor-pointer",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=d):d=e[7];let c=t.data.name||t.data.title||"Image",u;e[8]!==t.data.uri||e[9]!==c?(u=(0,o.jsx)(Ta,{className:"w-auto max-w-[500px] p-2",children:(0,o.jsx)("img",{src:t.data.uri,alt:c,className:"max-w-full max-h-96 object-contain"})}),e[8]=t.data.uri,e[9]=c,e[10]=u):u=e[10];let m;return e[11]!==d||e[12]!==u?(m=(0,o.jsx)("div",{children:(0,o.jsxs)(Aa,{children:[d,u]})}),e[11]=d,e[12]=u,e[13]=m):m=e[13],m}let a;e[14]===t.data.mimeType?a=e[15]:(a=t.data.mimeType&&(0,o.jsx)(la,{mimeType:t.data.mimeType}),e[14]=t.data.mimeType,e[15]=a);let s=t.data.name||t.data.title||t.data.uri,n;return e[16]!==a||e[17]!==s?(n=(0,o.jsxs)("span",{className:"flex items-center gap-1 px-1",children:[a,s]}),e[16]=a,e[17]=s,e[18]=n):n=e[18],n},la=t=>{let e=(0,te.c)(6);if(t.mimeType.startsWith("image/")){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(_r,{className:"h-2 w-2 shrink-0"}),e[0]=s):s=e[0],s}if(t.mimeType.startsWith("audio/")){let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(nr,{className:"h-2 w-2 shrink-0"}),e[1]=s):s=e[1],s}if(t.mimeType.startsWith("video/")){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(br,{className:"h-2 w-2 shrink-0"}),e[2]=s):s=e[2],s}if(t.mimeType.startsWith("text/")){let s;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(wn,{className:"h-2 w-2 shrink-0"}),e[3]=s):s=e[3],s}if(t.mimeType.startsWith("application/")){let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsx)(sr,{className:"h-2 w-2 shrink-0"}),e[4]=s):s=e[4],s}let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,o.jsx)(rr,{className:"h-2 w-2 shrink-0"}),e[5]=a):a=e[5],a},Zo=t=>{let e=(0,te.c)(11);if(t.data.length===0)return null;let a=t.data[0].sessionUpdate,s;e[0]!==a||e[1]!==t.endTimestamp||e[2]!==t.isLastBlock||e[3]!==t.startTimestamp?(s=l=>{if(vo(l))return(0,o.jsx)($o,{data:l,isLastBlock:t.isLastBlock});if(_o(l))return(0,o.jsx)(Co,{startTimestamp:t.startTimestamp,endTimestamp:t.endTimestamp,data:l});if(bo(l))return(0,o.jsx)(To,{data:l});if(wo(l))return(0,o.jsx)(Ao,{data:l});if(ko(l))return(0,o.jsx)(Io,{data:l});if(a==="available_commands_update")return null;if(a==="current_mode_update"){let d=l.at(-1);return(d==null?void 0:d.sessionUpdate)==="current_mode_update"?(0,o.jsx)(Po,{data:d}):null}return(0,o.jsx)(ca,{title:l[0].sessionUpdate,children:(0,o.jsx)(Fa,{data:l,format:"tree",className:"max-h-64"})})},e[0]=a,e[1]=t.endTimestamp,e[2]=t.isLastBlock,e[3]=t.startTimestamp,e[4]=s):s=e[4];let n=s,i;e[5]!==t.data||e[6]!==n?(i=n(t.data),e[5]=t.data,e[6]=n,e[7]=i):i=e[7];let r;return e[8]!==a||e[9]!==i?(r=(0,o.jsx)("div",{className:"flex flex-col text-sm gap-2","data-block-type":a,children:i}),e[8]=a,e[9]=i,e[10]=r):r=e[10],r},Po=t=>{let e=(0,te.c)(2),{currentModeId:a}=t.data,s;return e[0]===a?s=e[1]:(s=(0,o.jsxs)("div",{children:["Mode: ",a]}),e[0]=a,e[1]=s),s},$o=t=>{let e=(0,te.c)(9),a,s;if(e[0]!==t.data||e[1]!==t.isLastBlock){let i=yo(t.data);a="flex flex-col text-muted-foreground overflow-x-hidden";let r;e[4]===t.isLastBlock?r=e[5]:(r=l=>(0,o.jsx)(ca,{status:l.status==="completed"?"success":l.status==="failed"?"error":(l.status==="in_progress"||l.status==="pending")&&!t.isLastBlock?"loading":void 0,title:(0,o.jsx)("span",{"data-tool-data":JSON.stringify(l),children:Do(Fo(l))}),defaultIcon:(0,o.jsx)(dr,{className:"h-3 w-3"}),children:(0,o.jsx)(ws,{data:l})},l.toolCallId),e[4]=t.isLastBlock,e[5]=r),s=i.map(r),e[0]=t.data,e[1]=t.isLastBlock,e[2]=a,e[3]=s}else a=e[2],s=e[3];let n;return e[6]!==a||e[7]!==s?(n=(0,o.jsx)("div",{className:a,children:s}),e[6]=a,e[7]=s,e[8]=n):n=e[8],n},bs=t=>{let e=(0,te.c)(4),a;e[0]===t.data?a=e[1]:(a=t.data.map(Ho),e[0]=t.data,e[1]=a);let s;return e[2]===a?s=e[3]:(s=(0,o.jsx)("div",{className:"flex flex-col gap-2 text-muted-foreground",children:a}),e[2]=a,e[3]=s),s};function Fo(t){var n;let e=t.title;e==='"undefined"'&&(e=void 0);let a=e||Wn.startCase(t.kind||"")||"Tool call",s=(n=t.locations)==null?void 0:n[0];return s&&!a.includes(s.path)?`${a}: ${s.path}`:a}function Do(t){return t.startsWith("`")&&t.endsWith("`")?(0,o.jsx)("i",{children:t.slice(1,-1)}):t}const zo=t=>{let e=(0,te.c)(6);if(t.data.length<=1)return null;let a,s;if(e[0]!==t.data){let i=t.data.map(Yo);a="flex flex-col gap-2",s=i.join(`