@marimo-team/frontend 0.22.1-dev28 → 0.22.1-dev30

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 (91) hide show
  1. package/dist/assets/{CellStatus-BGwiRnWs.js → CellStatus-DbnxfYhY.js} +1 -1
  2. package/dist/assets/{ConnectedDataExplorerComponent-BKHN9OcM.js → ConnectedDataExplorerComponent-BUc9LHJJ.js} +1 -1
  3. package/dist/assets/{JsonOutput-CZWDOcEq.js → JsonOutput-LeC5h8MP.js} +1 -1
  4. package/dist/assets/{MarimoErrorOutput-CRiWaftE.js → MarimoErrorOutput-Dq9zeSH2.js} +1 -1
  5. package/dist/assets/{RenderHTML-DDQfFfKb.js → RenderHTML-C11kWI2X.js} +1 -1
  6. package/dist/assets/{add-cell-with-ai-Cs0x393c.js → add-cell-with-ai-Dmm_0EEi.js} +1 -1
  7. package/dist/assets/{add-connection-dialog-DaW4MgUH.js → add-connection-dialog-CMjIBIY8.js} +1 -1
  8. package/dist/assets/agent-panel-COS8BLy0.js +287 -0
  9. package/dist/assets/{ai-model-dropdown-qHy-qNhU.js → ai-model-dropdown-DXmwokmr.js} +4 -4
  10. package/dist/assets/{app-config-button-DA9C4E8a.js → app-config-button-CbHcdSN-.js} +1 -1
  11. package/dist/assets/{cell-editor-CHRa0gCL.js → cell-editor-B3xy42eO.js} +1 -1
  12. package/dist/assets/{cell-link-B1eV0G-A.js → cell-link-CVq1Spik.js} +1 -1
  13. package/dist/assets/{cells-DInU2DWF.js → cells-CgztvghI.js} +2 -2
  14. package/dist/assets/{chat-display-BDL9CljU.js → chat-display-DsnXg_ta.js} +1 -1
  15. package/dist/assets/{chat-panel-Du-uAJin.js → chat-panel-B3DihEiS.js} +1 -1
  16. package/dist/assets/{chat-ui-Bp_UmHcl.js → chat-ui-CJ8BkLf3.js} +1 -1
  17. package/dist/assets/{column-preview-DhJUmSOC.js → column-preview-DHqtWPTK.js} +1 -1
  18. package/dist/assets/{command-palette-Bf-iEqbG.js → command-palette-DIRRfZJn.js} +1 -1
  19. package/dist/assets/{common-BqHy8L_A.js → common-C4jQ7Qmf.js} +1 -1
  20. package/dist/assets/{components-EsZEXFgX.js → components-8pybQwj3.js} +1 -1
  21. package/dist/assets/{components-CVd6tsA3.js → components-Cm0Z0WS0.js} +1 -1
  22. package/dist/assets/{config-CWnjHRUp.js → config-CgKiz3_o.js} +1 -1
  23. package/dist/assets/{datasource-BnB1YCgS.js → datasource-BkclstbB.js} +1 -1
  24. package/dist/assets/{dependency-graph-panel-qWHHSaIt.js → dependency-graph-panel-Dcuc_z1H.js} +1 -1
  25. package/dist/assets/{documentation-panel-CfIHwb0z.js → documentation-panel-ClcJVCf2.js} +1 -1
  26. package/dist/assets/{download-GjiUccBq.js → download-t5dlf0C8.js} +1 -1
  27. package/dist/assets/{edit-page-KcjT9CAX.js → edit-page-TFKoKf0h.js} +3 -3
  28. package/dist/assets/{error-panel-CxmkPoke.js → error-panel-BpZDYT0j.js} +1 -1
  29. package/dist/assets/file-explorer-panel-BIxcHuNY.js +26 -0
  30. package/dist/assets/{file-icons-D-wFBwoi.js → file-icons-CH6PLlAQ.js} +1 -1
  31. package/dist/assets/{floating-outline-ZB0d3Gkj.js → floating-outline-C_iFBT1S.js} +1 -1
  32. package/dist/assets/{focus-njOEW9Ho.js → focus-CM-zeepg.js} +1 -1
  33. package/dist/assets/{form-CJ8bXC6w.js → form-BdN-gGnj.js} +1 -1
  34. package/dist/assets/{glide-data-editor-D0XSPCFg.js → glide-data-editor-CoyImave.js} +1 -1
  35. package/dist/assets/{globals-b9yMQzmS.js → globals-DAddhPz5.js} +1 -1
  36. package/dist/assets/{home-page-PcyGT_E-.js → home-page-DBGKQtzB.js} +1 -1
  37. package/dist/assets/{hooks-DVPKK7Uw.js → hooks-BjBV2Ya4.js} +1 -1
  38. package/dist/assets/{html-to-image-CmZyKmue.js → html-to-image-PhtipB5F.js} +1 -1
  39. package/dist/assets/index-BaQAJwyb.css +2 -0
  40. package/dist/assets/{index-D0fMpfEH.js → index-CdVQcrze.js} +6 -6
  41. package/dist/assets/{kiosk-mode-D8VxzEYi.js → kiosk-mode-BIsGB2bz.js} +1 -1
  42. package/dist/assets/{layout-DwUH_Q8_.js → layout-B_WyZpcV.js} +1 -1
  43. package/dist/assets/{logs-panel-BcEljlhw.js → logs-panel-UQ4ATgUR.js} +1 -1
  44. package/dist/assets/{markdown-renderer-BJENzE4w.js → markdown-renderer-CsSEt6xr.js} +1 -1
  45. package/dist/assets/{mermaid-C8G2WDUL.js → mermaid-BQRzyqkQ.js} +1 -1
  46. package/dist/assets/{name-cell-input-Dvwg2j6A.js → name-cell-input-CjhljYZD.js} +1 -1
  47. package/dist/assets/{outline-panel-Vn-LjfXF.js → outline-panel-CeVBezl7.js} +1 -1
  48. package/dist/assets/{packages-panel-1a-wyDvS.js → packages-panel-BIK8BiI8.js} +1 -1
  49. package/dist/assets/{panels-k1Z3DuU0.js → panels-y7fSeKKx.js} +1 -1
  50. package/dist/assets/{process-output-C93ipXYe.js → process-output-CMn_Dy8B.js} +1 -1
  51. package/dist/assets/{readonly-python-code-C0e-zRnF.js → readonly-python-code-CpnBFG08.js} +1 -1
  52. package/dist/assets/{renderShortcut-CsngZZjr.js → renderShortcut-Bjt8kSBs.js} +1 -1
  53. package/dist/assets/{run-page-BXvlyupc.js → run-page-RH8OBSIP.js} +1 -1
  54. package/dist/assets/{scratchpad-panel-D2GRFoGl.js → scratchpad-panel-DpCnByeb.js} +1 -1
  55. package/dist/assets/{session-panel-CgcD2sMA.js → session-panel-CXp7JlL_.js} +1 -1
  56. package/dist/assets/{snippets-panel-DgM0mYlW.js → snippets-panel-BuIAXUdn.js} +1 -1
  57. package/dist/assets/{state-C9NKSTSC.js → state-B8b64ALg.js} +1 -1
  58. package/dist/assets/{state-DZ4kOIAb.js → state-CSzwfw0V.js} +1 -1
  59. package/dist/assets/{switch-CoFOagHR.js → switch-Cojab6Bg.js} +1 -1
  60. package/dist/assets/{terminal-BXtB7lDO.js → terminal-D1Yvu9pO.js} +1 -1
  61. package/dist/assets/{textarea-Bakqk66U.js → textarea-CYczeAo_.js} +1 -1
  62. package/dist/assets/{tracing-CGwuOfDl.js → tracing-B1JBBMQ6.js} +1 -1
  63. package/dist/assets/{tracing-panel-BLeGB-vc.js → tracing-panel-C9D2pbpI.js} +2 -2
  64. package/dist/assets/{useAddCell-CIOpLf6K.js → useAddCell-Dx949Nwo.js} +1 -1
  65. package/dist/assets/{useBoolean-CQRQ8Pqg.js → useBoolean-CLYY2hZr.js} +1 -1
  66. package/dist/assets/{useCellActionButton-DQx9diIX.js → useCellActionButton-Dwv-mN2S.js} +1 -1
  67. package/dist/assets/{useDeleteCell-D1d8RakP.js → useDeleteCell-D77nfE58.js} +1 -1
  68. package/dist/assets/{useDependencyPanelTab-AEOk4Wvo.js → useDependencyPanelTab-CrdJd5fp.js} +1 -1
  69. package/dist/assets/{useHotkey-RegmpKhM.js → useHotkey-C05CMwqk.js} +1 -1
  70. package/dist/assets/{useNotebookActions-DFMHpjN5.js → useNotebookActions-DXMC1QdX.js} +1 -1
  71. package/dist/assets/{useRunCells-CZJZbVK2.js → useRunCells-ClEcKsmt.js} +1 -1
  72. package/dist/assets/{useSplitCell-D63ZxQyE.js → useSplitCell-DMwGtAvj.js} +1 -1
  73. package/dist/assets/{useTheme-CwnJ29E3.js → useTheme-wMq5x3Hi.js} +1 -1
  74. package/dist/assets/utils-DKaC_ndw.js +1 -0
  75. package/dist/assets/{vega-component-DwLjYppo.js → vega-component-BOzdRfM3.js} +1 -1
  76. package/dist/index.html +30 -30
  77. package/package.json +1 -1
  78. package/src/components/ai/ai-provider-icon.tsx +2 -0
  79. package/src/components/app-config/user-config-form.tsx +0 -27
  80. package/src/components/chat/acp/agent-docs.tsx +3 -3
  81. package/src/components/chat/acp/agent-panel.tsx +69 -22
  82. package/src/components/chat/acp/agent-selector.tsx +2 -11
  83. package/src/components/chat/acp/state.ts +14 -2
  84. package/src/components/editor/chrome/panels/file-explorer-panel.tsx +0 -10
  85. package/src/core/config/__tests__/config-schema.test.ts +2 -6
  86. package/src/core/config/config-schema.ts +0 -1
  87. package/src/core/config/feature-flag.tsx +0 -2
  88. package/dist/assets/agent-panel-BZM20s5o.js +0 -287
  89. package/dist/assets/file-explorer-panel-BYhCkFqE.js +0 -26
  90. package/dist/assets/index-DawClVBD.css +0 -2
  91. package/dist/assets/utils-pVkZab2h.js +0 -1
@@ -0,0 +1,287 @@
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 K=(t,e,a)=>pn(t,typeof e!="symbol"?e+"":e,a),Dt=(t,e,a)=>e.has(t)||_a("Cannot "+a);var X=(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 X(t,e,s)}});var me,Hs,et,Ft,ct,ut,tt,at,re,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{Jn as vn,Tn as xn,_n as yn,ai as ja,li as _n,mn as bn,oi as Na,or as zt,tr as wn}from"./cells-CgztvghI.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{Y as Sa,d as ht,q as jn}from"./ai-model-dropdown-DXmwokmr.js";import{_ as Ke,m as Nn,v as Ca}from"./useEventListener-DGjKht0c.js";import{t as ve}from"./cn-DYvqRARy.js";import{t as Sn}from"./jsx-runtime-Blw4afVn.js";import"./fullscreen-k58KVlT-.js";import{a as Cn,i as In,n as Tn,r as An}from"./multi-map-MSuUqmbC.js";import{i as Ia,r as Ta,t as Aa}from"./popover-AtoFZ7i4.js";import{a as Ra,i as Ma,n as Oa,r as Ea,s as Za,t as Pa}from"./select--zcABebs.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-DrHAuMTb.js";import{N as $a,t as Fa}from"./JsonOutput-LeC5h8MP.js";import"./download-t5dlf0C8.js";import{i as Dn,t as zn}from"./tooltip-DmqhBBs6.js";import{t as le}from"./button-BKVLeSTX.js";import{at as Ln}from"./dist-VwkX7yeV.js";import{p as Un}from"./arrays-B5sjidyq.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{i as qn,n as Ut,t as Wn}from"./strings-pfr2N700.js";import{r as Vn}from"./requests-9-v2bhoi.js";import{t as Je}from"./createLucideIcon-w-Qo9n0R.js";import{t as Bn}from"./fileToBase64-D7Ur9Qxq.js";import{t as ft}from"./bot-message-square-BbnE8Q1J.js";import{r as Kn,t as Da}from"./x-Bv2rCglF.js";import{t as za}from"./markdown-renderer-CsSEt6xr.js";import{D as Jn,F as Hn,T as Yn,c as Gn,d as Qn,n as Xn,s as er,u as tr,y as ar}from"./add-cell-with-ai-Dmm_0EEi.js";import{n as sr,t as nr}from"./file-headphone-5_PGMxRL.js";import{t as rr}from"./file-DaJ4JeZH.js";import{n as ir,t as qt}from"./spinner-AR54Ic3-.js";import{a as or}from"./MarimoErrorOutput-Dq9zeSH2.js";import{t as lr}from"./refresh-cw-CoFbRtMK.js";import{t as La}from"./rotate-ccw-FoUzS5fy.js";import{c as dr}from"./datasource-BkclstbB.js";import{t as cr}from"./badge-CufG8W4J.js";import"./dist-IM-Yi8zQ.js";import"./dist-C68iXRWB.js";import"./dist-BY7nTlwr.js";import"./dist-1CqkOLet.js";import"./dist-Bna8Uthk.js";import{t as ur}from"./uuid-DercMavo.js";import{t as gt}from"./use-toast-T0_cQDma.js";import{n as Ua,t as mr}from"./paths-Dfii2bN8.js";import"./session-DDorezMU.js";import{r as pr}from"./useTheme-wMq5x3Hi.js";import"./purify.es-D5ZyGDwc.js";import"./dates-CU9x8xLB.js";import"./utils-COwZ1qVI.js";import"./vega-loader.browser-CRZ52CKf.js";import"./defaultLocale-D_rSvXvJ.js";import"./defaultLocale-C92Rrpmf.js";import{t as hr}from"./copy-icon-CG2ao3lW.js";import{n as fr}from"./error-banner-B3Vr5jH0.js";import"./chunk-5FQGJX7Z-OcP0iC1i.js";import"./html-to-image-PhtipB5F.js";import"./react-resizable-panels.browser.esm-D0qmuH5W.js";import{t as gr}from"./esm-BV1ClmM0.js";import{n as vr}from"./dist-LTKJJMvn.js";import{t as qa}from"./empty-state-CzKMYdaQ.js";import{t as xr}from"./state-CXlAr4-P.js";var yr=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",vt=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(vt(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(vt(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 yt=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)}};yt.create=t=>new yt({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 yt?[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 va 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 va({keyType:e,valueType:a,typeName:Z.ZodRecord,...$(s)}):new va({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 ya 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 ya.create(e,{...this._def,...a})}exclude(e,a=this._def){return ya.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 vt(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 vt(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,yt.create,_t.create,Xt.create;var b=Ye.create;Fe.create,ea.create;var Y=Ge.create,_=be.create;be.strictCreate;var J=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=J([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=J([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]),is=J([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:J([_({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:Y(Gr).optional().nullable(),lastModified:f().optional().nullable(),priority:we().optional().nullable()}),ls=J([Qr,Xr]),hi=_({_meta:w(b()).optional()}),fi=_({meta:b().optional()}),gi=_({_meta:w(b()).optional(),stopReason:J([j("end_turn"),j("max_tokens"),j("max_turn_requests"),j("refusal"),j("cancelled")])}),vi=_({_meta:w(b()).optional()}),xi=w(b()),ds=f(),yi=w(b()),_i=_({hint:f()}),bi=_({_meta:w(b()).optional(),kind:J([j("allow_once"),j("allow_always"),j("reject_once"),j("reject_always")]),name:f(),optionId:f()}),ra=J([_({content:J([_({_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:Y(f()),command:f(),env:Y(cs),name:f()}),us=J([_({headers:Y(os),name:f(),type:j("http"),url:f()}),_({headers:Y(os),name:f(),type:j("sse"),url:f()}),ji]),At=J([_({_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:Y(Ii),currentModelId:f()}),ps=_({_meta:w(b()).optional(),availableModes:Y(Ti),currentModeId:f()}),Ai=_({_meta:w(b()).optional(),content:f(),priority:J([j("high"),j("medium"),j("low")]),status:J([j("pending"),j("in_progress"),j("completed")])}),Ri=_i,Mi=J([li,di]),hs=_({_meta:w(b()).optional(),args:Y(f()).optional(),command:f(),cwd:f().optional().nullable(),env:Y(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:Y(us)}),Zi=_({_meta:w(b()).optional(),cwd:f(),mcpServers:Y(us),sessionId:f()}),Pi=_({_meta:w(b()).optional(),prompt:Y(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:Y(ra).optional().nullable(),kind:rs.optional().nullable(),locations:Y(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=J([ei,ti,ai,si,Oi,ni,ri,ii,oi]),fs=_({_meta:w(b()).optional(),options:Y(bi),sessionId:f(),toolCall:Di}),Wi=_({_meta:w(b()).optional(),clientCapabilities:zi.optional(),protocolVersion:we()}),Vi=_({_meta:w(b()).optional(),agentCapabilities:Li.optional(),authMethods:Y(Ni).optional(),protocolVersion:we()}),gs=_({_meta:w(b()).optional(),sessionId:f(),update:J([_({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:Y(ra).optional(),kind:J([j("read"),j("edit"),j("delete"),j("move"),j("search"),j("execute"),j("think"),j("fetch"),j("switch_mode"),j("other")]).optional(),locations:Y(ia).optional(),rawInput:w(b()).optional(),rawOutput:w(b()).optional(),sessionUpdate:j("tool_call"),status:J([j("pending"),j("in_progress"),j("completed"),j("failed")]).optional(),title:f(),toolCallId:f()}),_({_meta:w(b()).optional(),content:Y(ra).optional().nullable(),kind:rs.optional().nullable(),locations:Y(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:Y(Ai),sessionUpdate:j("plan")}),_({availableCommands:Y(Ui),sessionUpdate:j("available_commands_update")}),_({currentModeId:ds,sessionUpdate:j("current_mode_update")})])});J([J([Xa,es,fs,hs,ts,as,ss,ns,Yr]),qi,Mi,J([Wi,ci,Ei,Zi,ui,Pi,mi,pi]),J([Vi,hi,$i,Fi,fi,gi,vi,xi]),J([gs,yi])]);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
+ `);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
+ `,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 X(this,me).sendRequest(ze.initialize,t)}async newSession(t){return await X(this,me).sendRequest(ze.session_new,t)}async loadSession(t){return await X(this,me).sendRequest(ze.session_load,t)??{}}async setSessionMode(t){return await X(this,me).sendRequest(ze.session_set_mode,t)??{}}async setSessionModel(t){return await X(this,me).sendRequest(ze.session_set_model,t)??{}}async authenticate(t){return await X(this,me).sendRequest(ze.authenticate,t)??{}}async prompt(t){return await X(this,me).sendRequest(ze.session_prompt,t)}async cancel(t){return await X(this,me).sendNotification(ze.session_cancel,t)}async extMethod(t,e){return await X(this,me).sendRequest(`_${t}`,e)}async extNotification(t,e){return await X(this,me).sendNotification(`_${t}`,e)}},me=new WeakMap,Hs),Ji=(Ys=class{constructor(t,e,a){Re(this,re);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,re,sn).call(this)}async sendRequest(t,e){let a=ba(this,Ft)._++,s=new Promise((n,i)=>{X(this,et).set(a,{resolve:n,reject:i})});return await Se(this,re,dt).call(this,{jsonrpc:"2.0",id:a,method:t,params:e}),s}async sendNotification(t,e){await Se(this,re,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,re=new WeakSet,sn=async function(){let t=X(this,tt).readable.getReader();try{for(;;){let{value:e,done:a}=await t.read();if(a)break;if(e)try{Se(this,re,nn).call(this,e)}catch(s){console.error("Unexpected error during message processing:",e,s),"id"in e&&e.id!==void 0&&Se(this,re,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,re,rn).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await Se(this,re,dt).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){let e=await Se(this,re,on).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?Se(this,re,ln).call(this,t):console.error("Invalid message",{message:t})},rn=async function(t,e){try{return{result:await X(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 X(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=X(this,et).get(t.id);e?("result"in t?e.resolve(t.result):"error"in t&&e.reject(t.error),X(this,et).delete(t.id)):console.error("Got response to unknown request",t.id)},dt=async function(t){return We(this,at,X(this,at).then(async()=>{let e=X(this,tt).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{console.error("ACP write error:",e)})),X(this,at)},Ys),ke=class qe extends Error{constructor(a,s,n){super(s);K(this,"code");K(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(){K(this,"promise");K(this,"resolve");K(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);K(this,"code");K(this,"data");K(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){K(this,"agent");K(this,"options");K(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){K(this,"agent");K(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
+ `))}},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){K(this,"managers",new Map);K(this,"options");K(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){K(this,"ws",null);K(this,"options");K(this,"reconnectCount",0);K(this,"reconnectTimer",null);K(this,"readableStream",null);K(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}},vs=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?vs(t):vs),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:v,addNotification:y,clearNotifications:S}=uo(),[C,I]=(0,R.useState)(null),[A,O]=(0,R.useState)(null),[F,q]=(0,R.useState)(!1),[B,G]=(0,R.useState)([]),Q=(0,R.useRef)(null),te=(0,R.useRef)(null),ne=(0,R.useRef)(null),z=(0,R.useRef)(!1),P=Le((W,ee)=>{x(ee,W),y({type:"connection_change",data:W})}),de=Le((W,ee)=>{y({type:"error",data:W})}),ie=Le(W=>{y({type:"session_notification",data:W}),W.update.sessionUpdate==="available_commands_update"&&G(W.update.availableCommands)}),pe=Le(W=>{I(W)}),Ae=Le(async()=>{Q.current||(Q.current=new ro({onConnectionStateChange:P,onError:de,reconnectAttempts:s,reconnectDelay:n})),v(e);let{readable:W,writable:ee}=await Q.current.connect(e);O(new Xi(new Ki(V=>{let H=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 te.current=H,H},Bi(ee,W)),{on_initialize_response:V=>{let H=V.agentCapabilities;console.log("[acp] Agent capabilities",H),x(e,r(e).state,H)},on_newSession_response:V=>{console.log("[acp] New session created",V);let H=V.sessionId;p(H),h(H,V.modes)},on_loadSession_response:(V,H)=>{console.log("[acp] Session resumed",H);let he=H.sessionId;p(he),h(he,V.modes)},on_prompt_start:V=>{for(let H of V.prompt)y({type:"session_notification",data:{sessionId:V.sessionId,update:{sessionUpdate:"user_message_chunk",content:H}}})},on_setSessionMode_start:V=>{console.log("[acp] Session mode set",V);let H=V.sessionId;m(H,V.modeId)},on_rpc_error:V=>de(V,e)}))}),ce=Le(W=>{let ee=W||e;Q.current&&(W?Q.current.disconnect(W):(Q.current.disconnect(ee),Q.current=null,te.current=null,O(null))),W||(I(null),G([]),z.current=!1,ne.current=null,q(!1))}),Ne=Le(W=>{if(C&&te.current){let ee=C.deferredId;ee&&te.current.resolvePermission(ee,W)}I(null)}),ye=Le(W=>{if(C&&te.current){let ee=C.deferredId;ee&&te.current.rejectPermission(ee,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:ye,agent:A,agentCapabilities:c,sessionMode:d?u[d]:null,availableCommands:B}}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 ys=["tool_call","tool_call_update"];function go(t,e){return t?t.type==="session_notification"&&e.type==="session_notification"?ys.includes(t.data.update.sessionUpdate)&&ys.includes(e.data.update.sessionUpdate)?!0:t.data.update.sessionUpdate===e.data.update.sessionUpdate:t.type===e.type:!1}function vo(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=vr({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 yo(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 ae=_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,ae.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:"flex-shrink-0",children:(0,o.jsx)(zt,{className:"h-5 w-5 text-[var(--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-[var(--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-[var(--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-[var(--red-11)] border-[var(--red-6)] hover:bg-[var(--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-[var(--red-10)] hover:bg-[var(--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-[var(--red-6)] bg-[var(--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,ae.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-[var(--blue-3)] flex items-center justify-center",children:(0,o.jsx)(ft,{className:"h-6 w-6 text-[var(--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,ae.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-[var(--blue-2)]",borderColor:"border-[var(--blue-6)]",textColor:"text-[var(--blue-11)]",iconColor:"text-[var(--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-[var(--amber-2)]",borderColor:"border-[var(--amber-6)]",textColor:"text-[var(--amber-11)]",iconColor:"text-[var(--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-[var(--gray-2)]",borderColor:"border-[var(--gray-6)]",textColor:"text-[var(--gray-11)]",iconColor:"text-[var(--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-[var(--red-2)]",borderColor:"border-[var(--red-6)]",textColor:"text-[var(--red-11)]",iconColor:"text-[var(--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-[var(--gray-2)]",borderColor:"border-[var(--gray-6)]",textColor:"text-[var(--gray-11)]",iconColor:"text-[var(--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=`flex-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 v;e[17]!==n.bgColor||e[18]!==n.borderColor||e[19]!==n.textColor||e[20]!==t.onRetry||e[21]!==i?(v=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]=v):v=e[22];let y;e[23]!==v||e[24]!==h||e[25]!==x?(y=(0,o.jsxs)("div",{className:"flex-1 min-w-0",children:[h,x,v]}),e[23]=v,e[24]=h,e[25]=x,e[26]=y):y=e[26];let S;e[27]!==y||e[28]!==d?(S=(0,o.jsxs)("div",{className:"flex items-start gap-3",children:[d,y]}),e[27]=y,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,ae.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,ae.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,ae.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 break-words overflow-x-hidden",children:(0,o.jsx)(Rt,{data:a})}),e[2]=a,e[3]=s),s},Ao=t=>{let e=(0,ae.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,ae.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,ae.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,ae.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,ae.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 break-words",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,ae.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,ae.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 flex-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 flex-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 flex-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 flex-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 flex-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 flex-shrink-0"}),e[5]=a):a=e[5],a},Zo=t=>{let e=(0,ae.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(yo(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,ae.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,ae.c)(9),a,s;if(e[0]!==t.data||e[1]!==t.isLastBlock){let i=vo(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,ae.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,ae.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(`
5
+ `),e[0]=t.data,e[1]=a,e[2]=s}else a=e[1],s=e[2];let n;return e[3]!==a||e[4]!==s?(n=(0,o.jsx)("div",{className:a,children:s}),e[3]=a,e[4]=s,e[5]=n):n=e[5],n},ws=t=>{let e=(0,ae.c)(30),{content:a,locations:s,status:n,kind:i,rawInput:r}=t.data,l;e[0]===a?l=e[1]:(l=a==null?void 0:a.filter(Go).map(Qo),e[0]=a,e[1]=l);let d=l,c;e[2]===a?c=e[3]:(c=a==null?void 0:a.filter(Xo),e[2]=a,e[3]=c);let u=c,m=n==="failed",h=s&&s.length>0;if(!a&&!h&&r){let I;e[4]===r?I=e[5]:(I=Lo.safeParse(r),e[4]=r,e[5]=I);let A=I;if(A.success){let F;return e[6]!==A.data.abs_path||e[7]!==A.data.new_string||e[8]!==A.data.old_string?(F=(0,o.jsx)(bs,{data:[{type:"diff",oldText:A.data.old_string,newText:A.data.new_string,path:A.data.abs_path}]}),e[6]=A.data.abs_path,e[7]=A.data.new_string,e[8]=A.data.old_string,e[9]=F):F=e[9],F}let O;return e[10]===r?O=e[11]:(O=(0,o.jsx)("pre",{className:"bg-[var(--slate-2)] p-1 text-muted-foreground border border-[var(--slate-4)] rounded text-xs overflow-auto scrollbar-thin max-h-64",children:(0,o.jsx)(Fa,{data:r,format:"tree"})}),e[10]=r,e[11]=O),O}let p=!d||d.length===0,x=!u||u.length===0;if(p&&x&&h){let I=i||"",A;e[12]===I?A=e[13]:(A=Ut(I),e[12]=I,e[13]=A);let O;e[14]===s?O=e[15]:(O=s==null?void 0:s.map(el).join(", "),e[14]=s,e[15]=O);let F;return e[16]!==A||e[17]!==O?(F=(0,o.jsx)("div",{className:"flex flex-col gap-2 pr-2",children:(0,o.jsxs)("span",{className:"text-xs text-muted-foreground",children:[A," ",O]})}),e[16]=A,e[17]=O,e[18]=F):F=e[18],F}let v;e[19]===s?v=e[20]:(v=s&&(0,o.jsx)(zo,{data:s}),e[19]=s,e[20]=v);let y;e[21]===d?y=e[22]:(y=d&&(0,o.jsx)(Rt,{data:d}),e[21]=d,e[22]=y);let S;e[23]!==u||e[24]!==m?(S=u&&!m&&(0,o.jsx)(bs,{data:u}),e[23]=u,e[24]=m,e[25]=S):S=e[25];let C;return e[26]!==v||e[27]!==y||e[28]!==S?(C=(0,o.jsxs)("div",{className:"flex flex-col gap-2 pr-2",children:[v,y,S]}),e[26]=v,e[27]=y,e[28]=S,e[29]=C):C=e[29],C};var Lo=kn({abs_path:Lt(),old_string:Lt(),new_string:Lt()});function Uo(t){return t.content}function qo(t){return t.entries}function Wo(t){return t.content}function Vo(t,e){return(0,o.jsxs)("li",{className:`
6
+ flex items-center gap-2 px-2 py-1 rounded
7
+ `,children:[(0,o.jsx)("input",{type:"checkbox",checked:t.status==="completed",readOnly:!0,className:"accent-primary h-4 w-4 rounded border border-muted-foreground/30",tabIndex:-1}),(0,o.jsx)("span",{className:ve("text-xs",t.status==="completed"&&"line-through text-muted-foreground"),children:t.content})]},`${t.status}-${e}`)}function Bo(t){return t.content}function Ko(t){return t.content}function Jo(t){return t.type==="text"?(0,o.jsx)(za,{content:t.text}):t.type==="image"?(0,o.jsx)(Ro,{data:t}):t.type==="audio"?(0,o.jsx)(Mo,{data:t}):t.type==="resource"?(0,o.jsx)(Oo,{data:t}):t.type==="resource_link"?(0,o.jsx)(Eo,{data:t}):(qn(t),null)}function Ho(t){return(0,o.jsxs)("div",{className:"border rounded-md overflow-hidden bg-[var(--gray-2)] overflow-y-auto scrollbar-thin max-h-64",children:[(0,o.jsx)("div",{className:"px-2 py-1 bg-[var(--gray-2)] border-b text-xs font-medium text-[var(--gray-11)]",children:t.path}),(0,o.jsx)(_s,{original:t.oldText||"",modified:t.newText||""})]},t.path)}function Yo(t){return t.line?`${t.path}:${t.line}`:t.path}function Go(t){return t.type==="content"}function Qo(t){return t.content}function Xo(t){return t.type==="diff"}function el(t){return t.path}var da=_e();const ca=t=>{let e=(0,da.c)(31),{title:a,children:s,status:n,index:i,defaultIcon:r}=t,l=i===void 0?0:i,d;e[0]!==r||e[1]!==n?(d=()=>{switch(n){case"loading":return(0,o.jsx)(ir,{className:"h-3 w-3 animate-spin"});case"error":return(0,o.jsx)(zt,{className:"h-3 w-3 text-destructive"});case"success":return(0,o.jsx)(Sa,{className:"h-3 w-3 text-[var(--blue-9)]"});default:return r}},e[0]=r,e[1]=n,e[2]=d):d=e[2];let c=d,u=`tool-${l}`,m=n==="error"&&"text-destructive/80",h=n==="success"&&"text-[var(--blue-8)]",p;e[3]!==m||e[4]!==h?(p=ve("py-1 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180",m,h),e[3]=m,e[4]=h,e[5]=p):p=e[5];let x;e[6]===c?x=e[7]:(x=c(),e[6]=c,e[7]=x);let v;e[8]===a?v=e[9]:(v=(0,o.jsx)("code",{className:"font-mono text-xs truncate",children:a}),e[8]=a,e[9]=v);let y;e[10]!==x||e[11]!==v?(y=(0,o.jsxs)("span",{className:"flex items-center gap-1",children:[x,v]}),e[10]=x,e[11]=v,e[12]=y):y=e[12];let S;e[13]!==p||e[14]!==y?(S=(0,o.jsx)(Cn,{className:p,children:y}),e[13]=p,e[14]=y,e[15]=S):S=e[15];let C;e[16]!==s||e[17]!==n?(C=n!=="error"&&(0,o.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:s}),e[16]=s,e[17]=n,e[18]=C):C=e[18];let I;e[19]!==s||e[20]!==n?(I=n==="error"&&(0,o.jsx)("div",{className:"bg-destructive/10 border border-destructive/20 rounded-md p-3 text-xs text-destructive",children:s}),e[19]=s,e[20]=n,e[21]=I):I=e[21];let A;e[22]!==C||e[23]!==I?(A=(0,o.jsx)(An,{className:"p-2",children:(0,o.jsxs)("div",{className:"space-y-3 max-h-64 overflow-y-auto scrollbar-thin",children:[C,I]})}),e[22]=C,e[23]=I,e[24]=A):A=e[24];let O;e[25]!==S||e[26]!==A?(O=(0,o.jsxs)(In,{value:"tool-call",className:"border-0",children:[S,A]}),e[25]=S,e[26]=A,e[27]=O):O=e[27];let F;return e[28]!==O||e[29]!==u?(F=(0,o.jsx)(Tn,{type:"single",collapsible:!0,className:"w-full",children:O},u),e[28]=O,e[29]=u,e[30]=F):F=e[30],F},ks=(0,R.memo)(t=>{let e=(0,da.c)(16),{status:a,className:s}=t,n;e[0]===a?n=e[1]:(n=()=>{switch(a){case"connected":return{icon:(0,o.jsx)(Wt,{className:"h-3 w-3"}),label:"Connected",variant:"default",className:"bg-[var(--blue-3)] text-[var(--blue-11)] border-[var(--blue-5)]"};case"connecting":return{icon:(0,o.jsx)(jn,{className:"h-3 w-3 animate-pulse"}),label:"Connecting",variant:"secondary",className:"bg-[var(--yellow-3)] text-[var(--yellow-11)] border-[var(--yellow-5)]"};case"disconnected":return{icon:(0,o.jsx)(nt,{className:"h-3 w-3"}),label:"Disconnected",variant:"outline",className:"bg-[var(--red-3)] text-[var(--red-11)] border-[var(--red-5)]"};default:return{icon:(0,o.jsx)(nt,{className:"h-3 w-3"}),label:a||"Unknown",variant:"outline",className:"bg-[var(--gray-3)] text-[var(--gray-11)] border-[var(--gray-5)]"}}},e[0]=a,e[1]=n);let i=n,r,l,d,c;e[2]!==s||e[3]!==i?(l=i(),r=cr,d=l.variant,c=ve(l.className,s),e[2]=s,e[3]=i,e[4]=r,e[5]=l,e[6]=d,e[7]=c):(r=e[4],l=e[5],d=e[6],c=e[7]);let u;e[8]===l.label?u=e[9]:(u=(0,o.jsx)("span",{className:"ml-1 text-xs font-medium",children:l.label}),e[8]=l.label,e[9]=u);let m;return e[10]!==r||e[11]!==l.icon||e[12]!==d||e[13]!==c||e[14]!==u?(m=(0,o.jsxs)(r,{variant:d,className:c,children:[l.icon,u]}),e[10]=r,e[11]=l.icon,e[12]=d,e[13]=c,e[14]=u,e[15]=m):m=e[15],m});ks.displayName="ConnectionStatus";const js=(0,R.memo)(t=>{let e=(0,da.c)(14),{permission:a,onResolve:s}=t,n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,o.jsx)(wr,{className:"h-4 w-4 text-[var(--amber-11)]"}),(0,o.jsx)("h3",{className:"text-sm font-medium text-[var(--amber-11)]",children:"Permission Request"})]}),i=(0,o.jsx)("p",{className:"text-sm text-[var(--amber-11)] mb-3",children:"The AI agent is requesting permission to proceed:"}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let r;e[2]===a.toolCall?r=e[3]:(r=(0,o.jsx)(ws,{data:a.toolCall}),e[2]=a.toolCall,e[3]=r);let l;if(e[4]!==s||e[5]!==a.options){let u;e[7]===s?u=e[8]:(u=m=>(0,o.jsxs)(le,{size:"xs",variant:"text",className:m.kind.startsWith("allow")?"text-[var(--blue-10)]":"text-[var(--red-10)]",onClick:()=>s({outcome:{outcome:"selected",optionId:m.optionId}}),children:[m.kind.startsWith("allow")&&(0,o.jsx)(Sa,{className:"h-3 w-3 mr-1"}),m.kind.startsWith("reject")&&(0,o.jsx)(zt,{className:"h-3 w-3 mr-1"}),m.name]},m.optionId),e[7]=s,e[8]=u),l=a.options.map(u),e[4]=s,e[5]=a.options,e[6]=l}else l=e[6];let d;e[9]===l?d=e[10]:(d=(0,o.jsx)("div",{className:"flex gap-2",children:l}),e[9]=l,e[10]=d);let c;return e[11]!==r||e[12]!==d?(c=(0,o.jsxs)("div",{className:"border border-[var(--amber-8)] bg-[var(--amber-2)] rounded-lg p-2",children:[n,i,r,d]}),e[11]=r,e[12]=d,e[13]=c):c=e[13],c});js.displayName="PermissionRequest";var tl=_e();function al(){let t=(0,tl.c)(3),{addCommand:e}=xr(),{openApplication:a}=yn(),s;return t[0]!==e||t[1]!==a?(s={sendCommand:n=>{a("terminal"),e(n)}},t[0]=e,t[1]=a,t[2]=s):s=t[2],s}var Ns=1;const ot=_n("marimo:acp:sessions:v1",{sessions:[],activeTabId:null},xn),ua=hn(t=>{let e=t(ot);return e.activeTabId&&e.sessions.find(a=>a.tabId===e.activeTabId)||null},(t,e,a)=>{e(ot,s=>({...s,activeTabId:a}))});function sl(){return`tab_${ur()}`}function Ss(t,e=20){return t.length<=e?t:`${t.slice(0,e-3)}...`}function nl(t,e){let a=Is(e.agentId),s=Date.now(),n=e.firstMessage?Ss(e.firstMessage.trim()):`New ${e.agentId} session`,i=sl();if(a==="single"){let r=t.sessions.filter(d=>d.agentId===e.agentId),l=t.sessions.filter(d=>d.agentId!==e.agentId);if(r.length>0){let d=r[0],c={agentId:e.agentId,title:n,createdAt:s,lastUsedAt:s,tabId:d.tabId,externalAgentSessionId:null,selectedModel:e.model??d.selectedModel??null};return{...t,sessions:[...l.slice(0,Ns-1),c],activeTabId:c.tabId}}}return{...t,sessions:[...t.sessions.slice(0,Ns-1),{agentId:e.agentId,tabId:i,title:n,createdAt:s,lastUsedAt:s,externalAgentSessionId:null,selectedModel:e.model??null}],activeTabId:i}}function rl(t,e){let a=t.sessions.filter(s=>s.tabId!==e);return{sessions:a,activeTabId:t.activeTabId===e?a.length>0?a[a.length-1].tabId:null:t.activeTabId}}function il(t,e){let a=t.activeTabId;return a?{...t,sessions:t.sessions.map(s=>s.tabId===a?{...s,title:Ss(e)}:s)}:t}function ol(t,e){return{...t,sessions:t.sessions.map(a=>a.tabId===e?{...a,lastUsedAt:Date.now()}:a)}}function Cs(t,e){let a=t.activeTabId;return a?{...t,sessions:t.sessions.map(s=>s.tabId===a?{...s,externalAgentSessionId:e,lastUsedAt:Date.now()}:s)}:t}function ll(){return["claude","gemini","codex","opencode","cursor"]}function dl(t){return Ut(t)}function cl(t){let e=Mt[t].port,a=window.location.hostname;return`${window.location.protocol==="https:"?"wss:":"ws:"}//${a}:${e}/message`}var Mt={claude:{port:3017,command:"npx @zed-industries/claude-code-acp",sessionSupport:"single"},gemini:{port:3019,command:"npx @google/gemini-cli --experimental-acp",sessionSupport:"single"},codex:{port:3021,command:"npx @zed-industries/codex-acp",sessionSupport:"single"},opencode:{port:3023,command:"npx opencode-ai acp",sessionSupport:"single"},cursor:{port:3025,command:"agent acp",sessionSupport:"single"}};function Is(t){return Mt[t].sessionSupport}function ul(t){let e=Mt[t].port,a=Mt[t].command;return`npx stdio-to-ws "${Nn()?`cmd /c ${a}`:a}" --port ${e}`}var Ts=_e(),ml=new Set(["opencode"]),As=(0,R.memo)(t=>{let e=(0,Ts.c)(38),{agentId:a,showCopy:s,className:n}=t,i=s===void 0?!0:s,r;e[0]===a?r=e[1]:(r=ul(a),e[0]=a,e[1]=r);let l=r,d;e[2]===a?d=e[3]:(d=dl(a),e[2]=a,e[3]=d);let c=d,u=fn(bn),{sendCommand:m}=al(),h;e[4]!==l||e[5]!==m?(h=()=>{m(l)},e[4]=l,e[5]=m,e[6]=h):h=e[6];let p=h,x;e[7]===n?x=e[8]:(x=ve("space-y-2",n),e[7]=n,e[8]=x);let v;e[9]===a?v=e[10]:(v=(0,o.jsx)(ht,{provider:a,className:"h-4 w-4"}),e[9]=a,e[10]=v);let y;e[11]===a?y=e[12]:(y=ml.has(a)&&(0,o.jsx)("span",{className:"text-muted-foreground ml-1",children:"(beta)"}),e[11]=a,e[12]=y);let S;e[13]!==c||e[14]!==y?(S=(0,o.jsxs)("span",{className:"font-medium text-sm",children:[c,y]}),e[13]=c,e[14]=y,e[15]=S):S=e[15];let C;e[16]!==v||e[17]!==S?(C=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[v,S]}),e[16]=v,e[17]=S,e[18]=C):C=e[18];let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=(0,o.jsx)(or,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),e[19]=I):I=e[19];let A;e[20]===l?A=e[21]:(A=(0,o.jsx)("code",{className:"text-xs font-mono wrap-break-word flex-1 whitespace-pre-wrap",children:l}),e[20]=l,e[21]=A);let O;e[22]!==l||e[23]!==i?(O=i&&(0,o.jsx)(le,{size:"xs",variant:"outline",className:"border",children:(0,o.jsx)(hr,{value:l,className:"h-3 w-3"})}),e[22]=l,e[23]=i,e[24]=O):O=e[24];let F;e[25]!==u.terminal||e[26]!==p?(F=u.terminal&&(0,o.jsx)(zn,{content:"Run in terminal",delayDuration:100,children:(0,o.jsx)(le,{onClick:p,title:"Send to terminal",size:"xs",variant:"outline",children:(0,o.jsx)(vn,{className:"h-3 w-3"})})}),e[25]=u.terminal,e[26]=p,e[27]=F):F=e[27];let q;e[28]!==O||e[29]!==F?(q=(0,o.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[O,F]}),e[28]=O,e[29]=F,e[30]=q):q=e[30];let B;e[31]!==A||e[32]!==q?(B=(0,o.jsx)("div",{className:"bg-muted/50 rounded-md p-2 border",children:(0,o.jsxs)("div",{className:"flex items-start gap-2 text-xs",children:[I,A,q]})}),e[31]=A,e[32]=q,e[33]=B):B=e[33];let G;return e[34]!==B||e[35]!==x||e[36]!==C?(G=(0,o.jsxs)("div",{className:x,children:[C,B]}),e[34]=B,e[35]=x,e[36]=C,e[37]=G):G=e[37],G});As.displayName="AgentDocItem";const Ot=(0,R.memo)(t=>{let e=(0,Ts.c)(22),{title:a,description:s,agents:n,showCopy:i,className:r}=t,l;e[0]===n?l=e[1]:(l=n===void 0?ll():n,e[0]=n,e[1]=l);let d=l,c=i===void 0?!0:i,u;e[2]===r?u=e[3]:(u=ve("space-y-4",r),e[2]=r,e[3]=u);let m;e[4]===a?m=e[5]:(m=(0,o.jsx)("h3",{className:"font-medium text-sm",children:a}),e[4]=a,e[5]=m);let h;e[6]===s?h=e[7]:(h=(0,o.jsx)("p",{className:"text-xs text-muted-foreground",children:s}),e[6]=s,e[7]=h);let p;e[8]!==m||e[9]!==h?(p=(0,o.jsxs)("div",{className:"space-y-2",children:[m,h]}),e[8]=m,e[9]=h,e[10]=p):p=e[10];let x;if(e[11]!==d||e[12]!==c){let S;e[14]===c?S=e[15]:(S=C=>(0,o.jsx)(As,{agentId:C,showCopy:c},C),e[14]=c,e[15]=S),x=d.map(S),e[11]=d,e[12]=c,e[13]=x}else x=e[13];let v;e[16]===x?v=e[17]:(v=(0,o.jsx)("div",{className:"space-y-3",children:x}),e[16]=x,e[17]=v);let y;return e[18]!==u||e[19]!==p||e[20]!==v?(y=(0,o.jsxs)("div",{className:u,children:[p,v]}),e[18]=u,e[19]=p,e[20]=v,e[21]=y):y=e[21],y});Ot.displayName="AgentDocs";var Rs=_e(),pl=[{id:"claude",displayName:"Claude",iconId:"anthropic"},{id:"gemini",displayName:"Gemini",iconId:"google"},{id:"codex",displayName:"Codex",iconId:"openai"},{id:"opencode",displayName:"OpenCode",iconId:"opencode"},{id:"cursor",displayName:"Cursor",iconId:"cursor"}],Ms=(0,R.memo)(t=>{let e=(0,Rs.c)(36),{agent:a,onSelect:s,existingSessions:n}=t,i=Is(a.id),r=n.some(C=>C.agentId===a.id),l=i==="single"&&r,d=l?`Reset ${a.displayName} session`:`New ${a.displayName} session`;if(l){let C;e[0]!==a.id||e[1]!==s?(C=()=>s(a.id),e[0]=a.id,e[1]=s,e[2]=C):C=e[2];let I;e[3]===a.iconId?I=e[4]:(I=(0,o.jsx)(ht,{provider:a.iconId,className:"h-3 w-3 mr-2"}),e[3]=a.iconId,e[4]=I);let A;e[5]===d?A=e[6]:(A=(0,o.jsx)("span",{children:d}),e[5]=d,e[6]=A);let O;e[7]!==I||e[8]!==A?(O=(0,o.jsxs)("div",{className:"flex items-center w-full",children:[I,A]}),e[7]=I,e[8]=A,e[9]=O):O=e[9];let F;return e[10]!==C||e[11]!==O?(F=(0,o.jsx)(Rn,{onClick:C,className:"cursor-pointer",children:O}),e[10]=C,e[11]=O,e[12]=F):F=e[12],F}let c;e[13]!==a.id||e[14]!==s?(c=()=>s(a.id),e[13]=a.id,e[14]=s,e[15]=c):c=e[15];let u;e[16]===a.iconId?u=e[17]:(u=(0,o.jsx)(ht,{provider:a.iconId,className:"h-3 w-3 mr-2"}),e[16]=a.iconId,e[17]=u);let m;e[18]===d?m=e[19]:(m=(0,o.jsx)("span",{children:d}),e[18]=d,e[19]=m);let h;e[20]!==u||e[21]!==m?(h=(0,o.jsxs)("div",{className:"flex items-center w-full",children:[u,m]}),e[20]=u,e[21]=m,e[22]=h):h=e[22];let p;e[23]!==c||e[24]!==h?(p=(0,o.jsx)(On,{showChevron:!1,className:"cursor-pointer",onClick:c,children:h}),e[23]=c,e[24]=h,e[25]=p):p=e[25];let x;e[26]===a.displayName?x=e[27]:(x=(0,o.jsxs)("div",{className:"text-xs font-medium text-muted-foreground mb-3",children:["To start a ",a.displayName," agent, run the following command in your terminal."]}),e[26]=a.displayName,e[27]=x);let v;e[28]===a.id?v=e[29]:(v=(0,o.jsx)(Ot,{agents:[a.id],showCopy:!0}),e[28]=a.id,e[29]=v);let y;e[30]!==x||e[31]!==v?(y=(0,o.jsx)(Pn,{children:(0,o.jsx)(Mn,{className:"w-120",children:(0,o.jsxs)("div",{className:"px-2 py-2",children:[x,v]})})}),e[30]=x,e[31]=v,e[32]=y):y=e[32];let S;return e[33]!==p||e[34]!==y?(S=(0,o.jsxs)(Fn,{children:[p,y]}),e[33]=p,e[34]=y,e[35]=S):S=e[35],S});Ms.displayName="AgentMenuItem";const Et=(0,R.memo)(t=>{let e=(0,Rs.c)(20),{onSessionCreated:a,className:s}=t,[n,i]=pt(ot),r=ka(ua),[l,d]=(0,R.useState)(!1),c;e[0]!==a||e[1]!==n||e[2]!==r||e[3]!==i?(c=async C=>{let I=nl(n,{agentId:C});i(I),r(I.activeTabId),d(!1),a==null||a(C)},e[0]=a,e[1]=n,e[2]=r,e[3]=i,e[4]=c):c=e[4];let u=oe(c),m;e[5]===s?m=e[6]:(m=ve("h-6 gap-1 px-2 text-xs bg-muted/30 hover:bg-muted/50 border border-border border-y-0 rounded-none focus-visible:ring-0",s),e[5]=s,e[6]=m);let h,p;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=(0,o.jsx)("span",{children:"New session"}),p=(0,o.jsx)(Kn,{className:"h-3 w-3"}),e[7]=h,e[8]=p):(h=e[7],p=e[8]);let x;e[9]===m?x=e[10]:(x=(0,o.jsx)(En,{asChild:!0,children:(0,o.jsxs)(le,{variant:"ghost",size:"sm",className:m,children:[h,p]})}),e[9]=m,e[10]=x);let v;e[11]!==u||e[12]!==n?(v=pl.map(C=>(0,o.jsx)(Ms,{agent:C,onSelect:u,existingSessions:n.sessions},C.id)),e[11]=u,e[12]=n,e[13]=v):v=e[13];let y;e[14]===v?y=e[15]:(y=(0,o.jsx)(Zn,{align:"start",className:"w-fit",children:v}),e[14]=v,e[15]=y);let S;return e[16]!==l||e[17]!==x||e[18]!==y?(S=(0,o.jsxs)($n,{open:l,onOpenChange:d,children:[x,y]}),e[16]=l,e[17]=x,e[18]=y,e[19]=S):S=e[19],S});Et.displayName="AgentSelector";var hl=_e();const Os=(0,R.memo)(t=>{let e=(0,hl.c)(18),{sessionModels:a,onModelChange:s,disabled:n}=t;if(!a||a.availableModels.length===0)return null;let{availableModels:i,currentModelId:r}=a,l;if(e[0]!==i||e[1]!==r){let x;e[3]===r?x=e[4]:(x=v=>v.modelId===r,e[3]=r,e[4]=x),l=i.find(x),e[0]=i,e[1]=r,e[2]=l}else l=e[2];let d=(l==null?void 0:l.name)??r,c;e[5]===d?c=e[6]:(c=(0,o.jsx)(Za,{className:"h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1",children:d}),e[5]=d,e[6]=c);let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,o.jsx)(Ra,{children:"Model"}),e[7]=u):u=e[7];let m;e[8]===i?m=e[9]:(m=i.map(fl),e[8]=i,e[9]=m);let h;e[10]===m?h=e[11]:(h=(0,o.jsx)(Oa,{children:(0,o.jsxs)(Ea,{children:[u,m]})}),e[10]=m,e[11]=h);let p;return e[12]!==r||e[13]!==n||e[14]!==s||e[15]!==c||e[16]!==h?(p=(0,o.jsxs)(Pa,{value:r,onValueChange:s,disabled:n,children:[c,h]}),e[12]=r,e[13]=n,e[14]=s,e[15]=c,e[16]=h,e[17]=p):p=e[17],p});Os.displayName="ModelSelector";function fl(t,e){return(0,o.jsx)(Ma,{value:t.modelId,className:"text-xs",children:(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsxs)("span",{children:[t.name,e===0&&(0,o.jsx)("span",{className:"text-muted-foreground ml-1",children:"(default)"})]}),t.description&&(0,o.jsx)("span",{className:"text-muted-foreground text-xs pt-1 block",children:t.description})]})},t.modelId)}var gl=_e(),Es=(0,R.memo)(t=>{let e=(0,gl.c)(10),{isVisible:a,onScrollToBottom:s,className:n}=t;if(!a)return null;let i;e[0]===n?i=e[1]:(i=ve("absolute bottom-2 right-6 z-10 animate-in fade-in-0 zoom-in-95 duration-200",n),e[0]=n,e[1]=i);let r,l,d;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=ve("h-8 w-8 p-0 rounded-full","bg-background/90 backdrop-blur-sm","border border-border/50","shadow-md shadow-black/10","hover:bg-background hover:shadow-black/15","transition-all duration-200","focus:outline-none focus:ring-2 focus:ring-primary/50"),l=(0,o.jsx)(yr,{className:"h-4 w-4"}),d=(0,o.jsx)("span",{className:"sr-only",children:"Scroll to bottom"}),e[2]=r,e[3]=l,e[4]=d):(r=e[2],l=e[3],d=e[4]);let c;e[5]===s?c=e[6]:(c=(0,o.jsxs)(le,{variant:"secondary",size:"sm",onClick:s,className:r,children:[l,d]}),e[5]=s,e[6]=c);let u;return e[7]!==i||e[8]!==c?(u=(0,o.jsx)("div",{className:i,children:c}),e[7]=i,e[8]=c,e[9]=u):u=e[9],u});Es.displayName="ScrollToBottomButton";var vl=Es,Zt=_e(),Zs=(0,R.memo)(t=>{let e=(0,Zt.c)(23),{session:a,isActive:s,onSelect:n,onClose:i}=t,r=s&&"bg-background border-b-0 relative z-1",l;e[0]===r?l=e[1]:(l=ve("flex items-center gap-1 px-2 py-1 text-xs border-r border-border bg-muted/30 hover:bg-muted/50 cursor-pointer min-w-0",r),e[0]=r,e[1]=l);let d;e[2]!==n||e[3]!==a.tabId?(d=()=>n(a.tabId),e[2]=n,e[3]=a.tabId,e[4]=d):d=e[4];let c;e[5]===a.agentId?c=e[6]:(c=(0,o.jsx)("span",{className:"text-muted-foreground text-[10px] font-medium",children:(0,o.jsx)(ht,{provider:a.agentId,className:"h-3 w-3"})}),e[5]=a.agentId,e[6]=c);let u;e[7]===a.title?u=e[8]:(u=(0,o.jsx)("span",{className:"truncate",title:a.title,children:a.title}),e[7]=a.title,e[8]=u);let m;e[9]!==c||e[10]!==u?(m=(0,o.jsxs)("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[c,u]}),e[9]=c,e[10]=u,e[11]=m):m=e[11];let h;e[12]!==i||e[13]!==a.tabId?(h=y=>{y.stopPropagation(),i(a.tabId)},e[12]=i,e[13]=a.tabId,e[14]=h):h=e[14];let p;e[15]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsx)(Da,{className:"h-3 w-3"}),e[15]=p):p=e[15];let x;e[16]===h?x=e[17]:(x=(0,o.jsx)(le,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 hover:bg-destructive/20 hover:text-destructive flex-shrink-0",onClick:h,children:p}),e[16]=h,e[17]=x);let v;return e[18]!==l||e[19]!==d||e[20]!==m||e[21]!==x?(v=(0,o.jsxs)("div",{className:l,onClick:d,children:[m,x]}),e[18]=l,e[19]=d,e[20]=m,e[21]=x,e[22]=v):v=e[22],v});Zs.displayName="SessionTab";var Ps=(0,R.memo)(t=>{let e=(0,Zt.c)(11),{sessions:a,activeTabId:s,onSelectSession:n,onCloseSession:i}=t,r;if(e[0]!==s||e[1]!==i||e[2]!==n||e[3]!==a){let d;e[5]!==s||e[6]!==i||e[7]!==n?(d=c=>(0,o.jsx)(Zs,{session:c,isActive:c.tabId===s,onSelect:n,onClose:i},c.tabId),e[5]=s,e[6]=i,e[7]=n,e[8]=d):d=e[8],r=a.map(d),e[0]=s,e[1]=i,e[2]=n,e[3]=a,e[4]=r}else r=e[4];let l;return e[9]===r?l=e[10]:(l=(0,o.jsx)("div",{className:"flex min-w-0 flex-1 overflow-x-auto",children:r}),e[9]=r,e[10]=l),l});Ps.displayName="SessionList";var $s=(0,R.memo)(t=>{let e=(0,Zt.c)(5),{className:a}=t,s;e[0]===a?s=e[1]:(s=ve("flex items-center border-b bg-muted/20",a),e[0]=a,e[1]=s);let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(Et,{className:"h-6"}),e[2]=n):n=e[2];let i;return e[3]===s?i=e[4]:(i=(0,o.jsx)("div",{className:s,children:n}),e[3]=s,e[4]=i),i});$s.displayName="EmptySessionTabs";const ma=(0,R.memo)(t=>{let e=(0,Zt.c)(18),{className:a}=t,[s,n]=pt(ot),i=ka(ua),r;e[0]!==i||e[1]!==n?(r=y=>{i(y),n(S=>ol(S,y))},e[0]=i,e[1]=n,e[2]=r):r=e[2];let l=oe(r),d;e[3]===n?d=e[4]:(d=y=>{n(S=>rl(S,y))},e[3]=n,e[4]=d);let c=oe(d),{sessions:u,activeTabId:m}=s;if(u.length===0){let y;return e[5]===a?y=e[6]:(y=(0,o.jsx)($s,{className:a}),e[5]=a,e[6]=y),y}let h;e[7]===a?h=e[8]:(h=ve("flex items-center border-b bg-muted/20 overflow-hidden",a),e[7]=a,e[8]=h);let p;e[9]!==m||e[10]!==c||e[11]!==l||e[12]!==u?(p=(0,o.jsx)(Ps,{sessions:u,activeTabId:m,onSelectSession:l,onCloseSession:c}),e[9]=m,e[10]=c,e[11]=l,e[12]=u,e[13]=p):p=e[13];let x;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=(0,o.jsx)(Et,{className:"h-6 flex-shrink-0"}),e[14]=x):x=e[14];let v;return e[15]!==h||e[16]!==p?(v=(0,o.jsxs)("div",{className:h,children:[p,x]}),e[15]=h,e[16]=p,e[17]=v):v=e[17],v});ma.displayName="SessionTabs";var xl=_e();const yl=t=>{let e=(0,xl.c)(14),{notifications:a,isConnected:s,onRetryConnection:n,onRetryLastAction:i,onDismissError:r}=t,l,d,c;if(e[0]!==s||e[1]!==a||e[2]!==r||e[3]!==n||e[4]!==i){l=fo(a),l=l.filter((p,x)=>Ds(p)&&p[0].data.update.sessionUpdate==="available_commands_update"?!1:x===l.length-1?!0:!Fs(p));let h=(p,x)=>{if(p.length===0)return null;if(_l(p)){let v=p[p.length-1];return(0,o.jsx)(No,{data:v.data,onRetry:i,onDismiss:r?()=>r(v.id):void 0},v.id)}if(Fs(p)){let v=p[p.length-1];return(0,o.jsx)(So,{data:v.data,isConnected:s,isOnlyBlock:l.length===1,onRetry:n,timestamp:v.timestamp},v.id)}if(Ds(p)){let v=p[0].timestamp,y=p[p.length-1].timestamp;return(0,o.jsx)(Zo,{data:p.map(bl),startTimestamp:v,endTimestamp:y,isLastBlock:x})}return"Unknown notification type"};d="flex flex-col gap-4 px-2 pb-10 flex-1",c=l.map((p,x)=>(0,o.jsx)(R.Fragment,{children:h(p,x===l.length-1)},p[0].id)),e[0]=s,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=l,e[6]=d,e[7]=c}else l=e[5],d=e[6],c=e[7];let u;e[8]===l.length?u=e[9]:(u=l.length===0&&(0,o.jsx)(oa,{}),e[8]=l.length,e[9]=u);let m;return e[10]!==d||e[11]!==c||e[12]!==u?(m=(0,o.jsxs)("div",{className:d,children:[c,u]}),e[10]=d,e[11]=c,e[12]=u,e[13]=m):m=e[13],m};function _l(t){return t[0].type==="error"}function Fs(t){return t[0].type==="connection_change"}function Ds(t){return t[0].type==="session_notification"}function bl(t){return t.data.update}async function wl(t){let e=[];for(let a of t)try{let s=await Bn(a,"dataUrl");e.push({type:"resource_link",uri:s,mimeType:a.type,name:a.name})}catch(s){Ke.error("Error converting file to resource link",{fileName:a.name,error:s})}return e}async function kl(t){let e=[];for(let a of t)e.push({type:"resource_link",uri:a.url,mimeType:a.mediaType,name:a.filename??a.url});return e}async function jl(t){let e=[],a=[];if(!t.includes("@"))return{contextBlocks:e,attachmentBlocks:a};try{let s=Jn(st),n=s.parseAllContextIds(t);if(n.length===0)return{contextBlocks:e,attachmentBlocks:a};let i=s.formatContextForAI(n);i.trim()&&e.push({type:"resource",resource:{uri:"context.md",mimeType:"text/plain",text:i}});try{let r=await s.getAttachmentsForContext(n);if(r.length>0){let l=await kl(r);a.push(...l),Ke.debug("Added AI context attachments",{count:r.length})}}catch(r){Ke.error("Error getting AI context attachments",{error:r})}Ke.debug("Parsed context for agent",{contextIds:n,contextLength:i.length,attachmentCount:a.length})}catch(s){Ke.error("Error parsing context for agent",{error:s})}return{contextBlocks:e,attachmentBlocks:a}}function Nl(t){return`
8
+ I am currently editing a marimo notebook.
9
+ You can read or write to the notebook at ${t}
10
+
11
+ If you make edits to the notebook, only edit the contents inside the function decorator with @app.cell.
12
+ marimo will automatically handle adding the parameters and return statement of the function. For example,
13
+ for each edit, just return:
14
+
15
+ \`\`\`
16
+ @app.cell
17
+ def _():
18
+ <your code here>
19
+ return
20
+ \`\`\`
21
+
22
+ ## Marimo fundamentals
23
+
24
+ Marimo is a reactive notebook that differs from traditional notebooks in key ways:
25
+
26
+ - Cells execute automatically when their dependencies change
27
+ - Variables cannot be redeclared across cells
28
+ - The notebook forms a directed acyclic graph (DAG)
29
+ - The last expression in a cell is automatically displayed
30
+ - UI elements are reactive and update the notebook automatically
31
+
32
+ ## Code Requirements
33
+
34
+ 1. All code must be complete and runnable
35
+ 2. Follow consistent coding style throughout
36
+ 3. Include descriptive variable names and helpful comments
37
+ 4. Import all modules in the first cell, always including \`import marimo as mo\`
38
+ 5. Never redeclare variables across cells
39
+ 6. Ensure no cycles in notebook dependency graph
40
+ 7. The last expression in a cell is automatically displayed, just like in Jupyter notebooks.
41
+ 8. Don't include comments in markdown cells
42
+ 9. Don't include comments in SQL cells
43
+ 10. Never define anything using \`global\`.
44
+
45
+ ## Reactivity
46
+
47
+ Marimo's reactivity means:
48
+
49
+ - When a variable changes, all cells that use that variable automatically re-execute
50
+ - UI elements trigger updates when their values change without explicit callbacks
51
+ - UI element values are accessed through \`.value\` attribute
52
+ - You cannot access a UI element's value in the same cell where it's defined
53
+ - Cells prefixed with an underscore (e.g. _my_var) are local to the cell and cannot be accessed by other cells
54
+
55
+ ## Best Practices
56
+
57
+ <data_handling>
58
+ - Use polars for data manipulation
59
+ - Implement proper data validation
60
+ - Handle missing values appropriately
61
+ - Use efficient data structures
62
+ - A variable in the last expression of a cell is automatically displayed as a table
63
+ </data_handling>
64
+
65
+ <visualization>
66
+ - For matplotlib: use plt.gca() as the last expression instead of plt.show()
67
+ - For plotly: return the figure object directly
68
+ - For altair: return the chart object directly. Add tooltips where appropriate. You can pass polars dataframes directly to altair.
69
+ - Include proper labels, titles, and color schemes
70
+ - Make visualizations interactive where appropriate
71
+ </visualization>
72
+
73
+ <ui_elements>
74
+ - Access UI element values with .value attribute (e.g., slider.value)
75
+ - Create UI elements in one cell and reference them in later cells
76
+ - Create intuitive layouts with mo.hstack(), mo.vstack(), and mo.tabs()
77
+ - Prefer reactive updates over callbacks (marimo handles reactivity automatically)
78
+ - Group related UI elements for better organization
79
+ </ui_elements>
80
+
81
+ <sql>
82
+ - When writing duckdb, prefer using marimo's SQL cells, which start with df = mo.sql(f"""<your query>""") for DuckDB, or df = mo.sql(f"""<your query>""", engine=engine) for other SQL engines.
83
+ - See the SQL with duckdb example for an example on how to do this
84
+ - Don't add comments in cells that use mo.sql()
85
+ - Consider using \`vega_datasets\` for common example datasets
86
+ </sql>
87
+
88
+ ## Troubleshooting
89
+
90
+ Common issues and solutions:
91
+ - Circular dependencies: Reorganize code to remove cycles in the dependency graph
92
+ - UI element value access: Move access to a separate cell from definition
93
+ - Visualization not showing: Ensure the visualization object is the last expression
94
+
95
+ ## Available UI elements
96
+
97
+ - \`mo.ui.altair_chart(altair_chart)\`
98
+ - \`mo.ui.button(value=None, kind='primary')\`
99
+ - \`mo.ui.run_button(label=None, tooltip=None, kind='primary')\`
100
+ - \`mo.ui.checkbox(label='', value=False)\`
101
+ - \`mo.ui.date(value=None, label=None, full_width=False)\`
102
+ - \`mo.ui.dropdown(options, value=None, label=None, full_width=False)\`
103
+ - \`mo.ui.file(label='', multiple=False, full_width=False)\`
104
+ - \`mo.ui.number(value=None, label=None, full_width=False)\`
105
+ - \`mo.ui.radio(options, value=None, label=None, full_width=False)\`
106
+ - \`mo.ui.refresh(options: List[str], default_interval: str)\`
107
+ - \`mo.ui.slider(start, stop, value=None, label=None, full_width=False, step=None)\`
108
+ - \`mo.ui.range_slider(start, stop, value=None, label=None, full_width=False, step=None)\`
109
+ - \`mo.ui.table(data, columns=None, on_select=None, sortable=True, filterable=True)\`
110
+ - \`mo.ui.text(value='', label=None, full_width=False)\`
111
+ - \`mo.ui.text_area(value='', label=None, full_width=False)\`
112
+ - \`mo.ui.data_explorer(df)\`
113
+ - \`mo.ui.dataframe(df)\`
114
+ - \`mo.ui.plotly(plotly_figure)\`
115
+ - \`mo.ui.tabs(elements: dict[str, mo.ui.Element])\`
116
+ - \`mo.ui.array(elements: list[mo.ui.Element])\`
117
+ - \`mo.ui.form(element: mo.ui.Element, label='', bordered=True)\`
118
+
119
+ ## Layout and utility functions
120
+
121
+ - \`mo.md(text)\` - display markdown
122
+ - \`mo.stop(predicate, output=None)\` - stop execution conditionally
123
+ - \`mo.output.append(value)\` - append to the output when it is not the last expression
124
+ - \`mo.output.replace(value)\` - replace the output when it is not the last expression
125
+ - \`mo.Html(html)\` - display HTML
126
+ - \`mo.image(image)\` - display an image
127
+ - \`mo.hstack(elements)\` - stack elements horizontally
128
+ - \`mo.vstack(elements)\` - stack elements vertically
129
+ - \`mo.tabs(elements)\` - create a tabbed interface
130
+
131
+
132
+
133
+ ## Examples
134
+
135
+ <example title="Markdown ccell">
136
+ ${Ue([`
137
+ mo.md("""
138
+ # Hello world
139
+ This is a _markdown_ **cell**.
140
+ """)
141
+ `])}
142
+ </example>
143
+
144
+ <example title="Basic UI with reactivity">
145
+ ${Ue([`
146
+ import marimo as mo
147
+ import altair as alt
148
+ import polars as pl
149
+ import numpy as np
150
+ `,`
151
+ n_points = mo.ui.slider(10, 100, value=50, label="Number of points")
152
+ n_points
153
+ `,`
154
+ x = np.random.rand(n_points.value)
155
+ y = np.random.rand(n_points.value)
156
+
157
+ df = pl.DataFrame({"x": x, "y": y})
158
+
159
+ chart = alt.Chart(df).mark_circle(opacity=0.7).encode(
160
+ x=alt.X('x', title='X axis'),
161
+ y=alt.Y('y', title='Y axis')
162
+ ).properties(
163
+ title=f"Scatter plot with {n_points.value} points",
164
+ width=400,
165
+ height=300
166
+ )
167
+
168
+ chart
169
+ `])}
170
+ </example>
171
+
172
+ <example title="Data explorer">
173
+ ${Ue([`
174
+ import marimo as mo
175
+ import polars as pl
176
+ from vega_datasets import data
177
+ `,`
178
+ cars_df = pl.DataFrame(data.cars())
179
+ mo.ui.data_explorer(cars_df)
180
+ `])}
181
+ </example>
182
+
183
+ <example title="Multiple UI elements">
184
+ ${Ue([`
185
+ import marimo as mo
186
+ import polars as pl
187
+ import altair as alt
188
+ `,`
189
+ iris = pl.read_csv("hf://datasets/scikit-learn/iris/Iris.csv")
190
+ `,`
191
+ species_selector = mo.ui.dropdown(
192
+ options=["All"] + iris["Species"].unique().to_list(),
193
+ value="All",
194
+ label="Species",
195
+ )
196
+ x_feature = mo.ui.dropdown(
197
+ options=iris.select(pl.col(pl.Float64, pl.Int64)).columns,
198
+ value="SepalLengthCm",
199
+ label="X Feature",
200
+ )
201
+ y_feature = mo.ui.dropdown(
202
+ options=iris.select(pl.col(pl.Float64, pl.Int64)).columns,
203
+ value="SepalWidthCm",
204
+ label="Y Feature",
205
+ )
206
+ mo.hstack([species_selector, x_feature, y_feature])
207
+ `,`
208
+ filtered_data = iris if species_selector.value == "All" else iris.filter(pl.col("Species") == species_selector.value)
209
+
210
+ chart = alt.Chart(filtered_data).mark_circle().encode(
211
+ x=alt.X(x_feature.value, title=x_feature.value),
212
+ y=alt.Y(y_feature.value, title=y_feature.value),
213
+ color='Species'
214
+ ).properties(
215
+ title=f"{y_feature.value} vs {x_feature.value}",
216
+ width=500,
217
+ height=400
218
+ )
219
+
220
+ chart
221
+ `])}
222
+ </example>
223
+
224
+ <example title="Conditional Outputs">
225
+ ${Ue([`
226
+ mo.stop(not data.value, mo.md("No data to display"))
227
+
228
+ if mode.value == "scatter":
229
+ mo.output.replace(render_scatter(data.value))
230
+ else:
231
+ mo.output.replace(render_bar_chart(data.value))
232
+ `])}
233
+ </example>
234
+
235
+ <example title="Interactive chart with Altair">
236
+ ${Ue([`
237
+ import marimo as mo
238
+ import altair as alt
239
+ import polars as pl
240
+ `,`# Load dataset
241
+ weather = pl.read_csv("https://raw.githubusercontent.com/vega/vega-datasets/refs/heads/main/data/weather.csv")
242
+ weather_dates = weather.with_columns(
243
+ pl.col("date").str.strptime(pl.Date, format="%Y-%m-%d")
244
+ )
245
+ _chart = (
246
+ alt.Chart(weather_dates)
247
+ .mark_point()
248
+ .encode(
249
+ x="date:T",
250
+ y="temp_max",
251
+ color="location",
252
+ )
253
+ )
254
+ `,`chart = mo.ui.altair_chart(_chart)
255
+ chart`,`
256
+ # Display the selection
257
+ chart.value`])}
258
+ </example>
259
+
260
+ <example title="Run Button Example">
261
+ ${Ue(["import marimo as mo",`
262
+ first_button = mo.ui.run_button(label="Option 1")
263
+ second_button = mo.ui.run_button(label="Option 2")
264
+ [first_button, second_button]`,`
265
+ if first_button.value:
266
+ print("You chose option 1!")
267
+ elif second_button.value:
268
+ print("You chose option 2!")
269
+ else:
270
+ print("Click a button!")`])}
271
+ </example>
272
+
273
+ <example title="SQL with duckdb">
274
+ ${Ue([`import marimo as mo
275
+ import polars as pl`,"weather = pl.read_csv('https://raw.githubusercontent.com/vega/vega-datasets/refs/heads/main/data/weather.csv')",`seattle_weather_df = mo.sql(
276
+ f"""
277
+ SELECT * FROM weather WHERE location = 'Seattle';
278
+ """
279
+ )`])}
280
+ </example>`}function Ue(t){let e=a=>a.trim().split(`
281
+ `).map(s=>(" "+s).trimEnd()).join(`
282
+ `);return t.map(a=>`
283
+ @app.cell
284
+ def _():
285
+ ${e(a)}
286
+ return
287
+ `).join("")}var Ze=_e(),se=Ke.get("agents"),zs=(0,R.memo)(t=>{let e=(0,Ze.c)(4),{currentAgentId:a}=t,s=a??"",n;e[0]===s?n=e[1]:(n=Ut(s),e[0]=s,e[1]=n);let i;return e[2]===n?i=e[3]:(i=(0,o.jsx)("span",{className:"text-sm font-medium",children:n}),e[2]=n,e[3]=i),i});zs.displayName="AgentTitle";var Ls=(0,R.memo)(t=>{let e=(0,Ze.c)(4),{connectionState:a,onConnect:s,onDisconnect:n}=t,i=a.status==="connected",r=i?n:s,l=a.status==="connecting",d=i?"Disconnect":"Connect",c;return e[0]!==r||e[1]!==l||e[2]!==d?(c=(0,o.jsx)(le,{variant:"outline",size:"xs",onClick:r,disabled:l,children:d}),e[0]=r,e[1]=l,e[2]=d,e[3]=c):c=e[3],c});Ls.displayName="ConnectionControl";var Us=(0,R.memo)(t=>{let e=(0,Ze.c)(9),{currentAgentId:a,connectionStatus:s,shouldShowConnectionControl:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)(ft,{className:"h-4 w-4 text-muted-foreground"}),e[0]=i):i=e[0];let r;e[1]===a?r=e[2]:(r=a&&(0,o.jsx)(zs,{currentAgentId:a}),e[1]=a,e[2]=r);let l;e[3]!==s||e[4]!==n?(l=n&&(0,o.jsx)(ks,{status:s}),e[3]=s,e[4]=n,e[5]=l):l=e[5];let d;return e[6]!==r||e[7]!==l?(d=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[i,r,l]}),e[6]=r,e[7]=l,e[8]=d):d=e[8],d});Us.displayName="HeaderInfo";var pa=(0,R.memo)(t=>{let e=(0,Ze.c)(19),{connectionState:a,currentAgentId:s,onConnect:n,onDisconnect:i,onRestartThread:r,hasActiveSession:l,shouldShowConnectionControl:d}=t,c;e[0]!==a.status||e[1]!==s||e[2]!==d?(c=(0,o.jsx)(Us,{currentAgentId:s,connectionStatus:a.status,shouldShowConnectionControl:d}),e[0]=a.status,e[1]=s,e[2]=d,e[3]=c):c=e[3];let u;e[4]!==a.status||e[5]!==l||e[6]!==r?(u=l&&a.status==="connected"&&r&&(0,o.jsxs)(le,{variant:"outline",size:"xs",onClick:r,title:"Restart thread (create new session)",children:[(0,o.jsx)(lr,{className:"h-3 w-3 mr-1"}),"Restart"]}),e[4]=a.status,e[5]=l,e[6]=r,e[7]=u):u=e[7];let m;e[8]!==a||e[9]!==n||e[10]!==i||e[11]!==d?(m=d&&(0,o.jsx)(Ls,{connectionState:a,onConnect:n,onDisconnect:i}),e[8]=a,e[9]=n,e[10]=i,e[11]=d,e[12]=m):m=e[12];let h;e[13]!==u||e[14]!==m?(h=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[u,m]}),e[13]=u,e[14]=m,e[15]=h):h=e[15];let p;return e[16]!==c||e[17]!==h?(p=(0,o.jsxs)("div",{className:"flex border-b px-3 py-2 justify-between shrink-0 items-center",children:[c,h]}),e[16]=c,e[17]=h,e[18]=p):p=e[18],p});pa.displayName="AgentPanelHeader";var qs=(0,R.memo)(t=>{let e=(0,Ze.c)(14),{currentAgentId:a,connectionState:s,onConnect:n,onDisconnect:i}=t,r;e[0]!==s||e[1]!==a||e[2]!==n||e[3]!==i?(r=(0,o.jsx)(pa,{connectionState:s,currentAgentId:a,onConnect:n,onDisconnect:i,hasActiveSession:!1}),e[0]=s,e[1]=a,e[2]=n,e[3]=i,e[4]=r):r=e[4];let l;e[5]===Symbol.for("react.memo_cache_sentinel")?(l=(0,o.jsx)(ma,{}),e[5]=l):l=e[5];let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,o.jsx)(qa,{title:"No Agent Sessions",description:"Create a new session to start a conversation",action:(0,o.jsx)(Et,{className:"border-y rounded"}),icon:(0,o.jsx)(ft,{})}),e[6]=d):d=e[6];let c;e[7]===s.status?c=e[8]:(c=s.status==="disconnected"&&(0,o.jsx)(Ot,{className:"border-t pt-6",title:"Connect to an agent",description:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{children:"Start agents by running these commands in your terminal."}),(0,o.jsx)("br",{}),(0,o.jsx)("span",{children:"Authenticate with the agent before starting a session."})]})}),e[7]=s.status,e[8]=c);let u;e[9]===c?u=e[10]:(u=(0,o.jsx)("div",{className:"flex-1 flex items-center justify-center p-6",children:(0,o.jsxs)("div",{className:"max-w-md w-full space-y-6",children:[d,c]})}),e[9]=c,e[10]=u);let m;return e[11]!==r||e[12]!==u?(m=(0,o.jsxs)("div",{className:"flex flex-col h-full",children:[r,l,u]}),e[11]=r,e[12]=u,e[13]=m):m=e[13],m});qs.displayName="EmptyState";var Ws=(0,R.memo)(t=>{let e=(0,Ze.c)(10),{isLoading:a,isRequestingPermission:s,onStop:n}=t;if(!a)return null;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,o.jsx)(qt,{size:"small",className:"text-primary"}),e[0]=i):i=e[0];let r;e[1]===s?r=e[2]:(r=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[i,s?(0,o.jsx)("span",{children:"Waiting for permission to continue..."}):(0,o.jsx)("span",{children:"Agent is working..."})]}),e[1]=s,e[2]=r);let l,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,o.jsx)(Hn,{className:"h-3 w-3 mr-1"}),d=(0,o.jsx)("span",{className:"text-xs",children:"Stop"}),e[3]=l,e[4]=d):(l=e[3],d=e[4]);let c;e[5]===n?c=e[6]:(c=(0,o.jsx)("div",{className:"flex items-center gap-2",children:(0,o.jsxs)(le,{size:"sm",variant:"outline",onClick:n,className:"h-6 px-2",children:[l,d]})}),e[5]=n,e[6]=c);let u;return e[7]!==r||e[8]!==c?(u=(0,o.jsx)("div",{className:"px-3 py-2 border-t bg-muted/30 flex-shrink-0",children:(0,o.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[r,c]})}),e[7]=r,e[8]=c,e[9]=u):u=e[9],u});Ws.displayName="LoadingIndicator";var Vs=(0,R.memo)(t=>{let e=(0,Ze.c)(55),{isLoading:a,activeSessionId:s,promptValue:n,commands:i,onPromptValueChange:r,onPromptSubmit:l,onAddFiles:d,onStop:c,fileInputRef:u,sessionMode:m,onModeChange:h,sessionModels:p,onModelChange:x}=t,v=(0,R.useRef)(null),y;e:{if(!i){y=void 0;break e}let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee=/^\/(\w+)?/,e[0]=ee):ee=e[0];let V;e[1]===i?V=e[2]:(V=i.map(Al),e[1]=i,e[2]=V);let H;e[3]===V?H=e[4]:(H={triggerCompletionRegex:ee,completions:V},e[3]=V,e[4]=H),y=H}let S=y,C;e[5]!==l||e[6]!==n?(C=()=>{n.trim()&&l(void 0,n)},e[5]=l,e[6]=n,e[7]=C):C=e[7];let I=oe(C),A;e[8]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{Yn(v)},e[8]=A):A=e[8];let O=oe(A),F=(a||!s)&&"opacity-50 pointer-events-none",q;e[9]===F?q=e[10]:(q=ve("px-3 py-2 min-h-[80px]",F),e[9]=F,e[10]=q);let B=a?Ca.NOOP:r,G=a?"Processing...":"Ask anything, @ to include context about tables or dataframes",Q=a?"opacity-50 pointer-events-none":"",te;e[11]!==d||e[12]!==l||e[13]!==S||e[14]!==n||e[15]!==B||e[16]!==G||e[17]!==Q?(te=(0,o.jsx)(Xn,{inputRef:v,value:n,onChange:B,onSubmit:l,additionalCompletions:S,onClose:Ca.NOOP,onAddFiles:d,placeholder:G,className:Q,maxHeight:"120px"}),e[11]=d,e[12]=l,e[13]=S,e[14]=n,e[15]=B,e[16]=G,e[17]=Q,e[18]=te):te=e[18];let ne;e[19]!==q||e[20]!==te?(ne=(0,o.jsx)("div",{className:q,children:te}),e[19]=q,e[20]=te,e[21]=ne):ne=e[21];let z;e[22]!==h||e[23]!==m?(z=m&&h&&(0,o.jsx)(Bs,{sessionMode:m,onModeChange:h}),e[22]=h,e[23]=m,e[24]=z):z=e[24];let P;e[25]!==s||e[26]!==a||e[27]!==x||e[28]!==p?(P=p&&x&&s&&(0,o.jsx)(Os,{sessionModels:p,onModelChange:x,disabled:a}),e[25]=s,e[26]=a,e[27]=x,e[28]=p,e[29]=P):P=e[29];let de;e[30]!==z||e[31]!==P?(de=(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[z,P]}),e[30]=z,e[31]=P,e[32]=de):de=e[32];let ie;e[33]!==O||e[34]!==a?(ie=(0,o.jsx)(er,{handleAddContext:O,isLoading:a}),e[33]=O,e[34]=a,e[35]=ie):ie=e[35];let pe;e[36]!==u||e[37]!==a||e[38]!==d?(pe=(0,o.jsx)(Gn,{fileInputRef:u,isLoading:a,onAddFiles:d}),e[36]=u,e[37]=a,e[38]=d,e[39]=pe):pe=e[39];let Ae=!n.trim(),ce;e[40]!==I||e[41]!==a||e[42]!==c||e[43]!==Ae?(ce=(0,o.jsx)(Qn,{isLoading:a,onStop:c,onSendClick:I,isEmpty:Ae}),e[40]=I,e[41]=a,e[42]=c,e[43]=Ae,e[44]=ce):ce=e[44];let Ne;e[45]!==ie||e[46]!==pe||e[47]!==ce?(Ne=(0,o.jsxs)("div",{className:"flex flex-row",children:[ie,pe,ce]}),e[45]=ie,e[46]=pe,e[47]=ce,e[48]=Ne):Ne=e[48];let ye;e[49]!==de||e[50]!==Ne?(ye=(0,o.jsx)(Dn,{children:(0,o.jsxs)("div",{className:"px-3 py-2 border-t border-border/20 flex flex-row items-center justify-between",children:[de,Ne]})}),e[49]=de,e[50]=Ne,e[51]=ye):ye=e[51];let W;return e[52]!==ne||e[53]!==ye?(W=(0,o.jsxs)("div",{className:"border-t bg-background flex-shrink-0",children:[ne,ye]}),e[52]=ne,e[53]=ye,e[54]=W):W=e[54],W});Vs.displayName="PromptArea";var Bs=(0,R.memo)(t=>{let e=(0,Ze.c)(28),{sessionMode:a,onModeChange:s}=t,n,i,r,l,d,c,u,m,h;if(e[0]!==s||e[1]!==(a==null?void 0:a.availableModes)||e[2]!==(a==null?void 0:a.currentModeId)){h=Symbol.for("react.early_return_sentinel");e:{let y=(a==null?void 0:a.availableModes)||[],S=a==null?void 0:a.currentModeId;if(y.length===0){h=null;break e}let C=y.map(Rl),I;e[12]===S?I=e[13]:(I=O=>O.value===S,e[12]=S,e[13]=I);let A=C.find(I);r=Pa,c=S,u=s,m=(0,o.jsx)(Za,{className:"h-6 text-xs border-border shadow-none! ring-0! bg-muted hover:bg-muted/30 py-0 px-2 gap-1 capitalize",children:(A==null?void 0:A.label)??S}),i=Oa,n=Ea,e[14]===Symbol.for("react.memo_cache_sentinel")?(l=(0,o.jsx)(Ra,{children:"Agent Mode"}),e[14]=l):l=e[14],d=C.map(Ml)}e[0]=s,e[1]=a==null?void 0:a.availableModes,e[2]=a==null?void 0:a.currentModeId,e[3]=n,e[4]=i,e[5]=r,e[6]=l,e[7]=d,e[8]=c,e[9]=u,e[10]=m,e[11]=h}else n=e[3],i=e[4],r=e[5],l=e[6],d=e[7],c=e[8],u=e[9],m=e[10],h=e[11];if(h!==Symbol.for("react.early_return_sentinel"))return h;let p;e[15]!==n||e[16]!==l||e[17]!==d?(p=(0,o.jsxs)(n,{children:[l,d]}),e[15]=n,e[16]=l,e[17]=d,e[18]=p):p=e[18];let x;e[19]!==i||e[20]!==p?(x=(0,o.jsx)(i,{children:p}),e[19]=i,e[20]=p,e[21]=x):x=e[21];let v;return e[22]!==r||e[23]!==c||e[24]!==u||e[25]!==m||e[26]!==x?(v=(0,o.jsxs)(r,{value:c,onValueChange:u,children:[m,x]}),e[22]=r,e[23]=c,e[24]=u,e[25]=m,e[26]=x,e[27]=v):v=e[27],v});Bs.displayName="ModeSelector";var Ks=(0,R.memo)(t=>{let e=(0,Ze.c)(33),{hasNotifications:a,agentId:s,connectionState:n,notifications:i,pendingPermission:r,onResolvePermission:l,onRetryConnection:d,onRetryLastAction:c,sessionId:u}=t,[m,h]=(0,R.useState)(!0),p=(0,R.useRef)(null),x=n.status==="disconnected",v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{let P=p.current;if(!P)return;let{scrollTop:de,scrollHeight:ie,clientHeight:pe}=P;h(ie>pe?Math.abs(ie-pe-de)<5:!0)},e[0]=v):v=e[0];let y=oe(v),S;e[1]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{let P=p.current;P&&P.scrollTo({top:P.scrollHeight,behavior:"smooth"})},e[1]=S):S=e[1];let C=oe(S),I,A;e[2]!==m||e[3]!==i.length||e[4]!==C?(I=()=>{if(m&&i.length>0){let P=setTimeout(C,100);return()=>clearTimeout(P)}},A=[i.length,m,C],e[2]=m,e[3]=i.length,e[4]=C,e[5]=I,e[6]=A):(I=e[5],A=e[6]),(0,R.useEffect)(I,A);let O;e[7]!==s||e[8]!==n.status||e[9]!==a||e[10]!==x||e[11]!==i||e[12]!==d||e[13]!==c?(O=()=>a?(0,o.jsx)(yl,{isConnected:n.status==="connected",notifications:i,onRetryConnection:d,onRetryLastAction:c}):n.status==="connected"?(0,o.jsx)(oa,{}):(0,o.jsxs)("div",{className:"flex items-center justify-center h-full min-h-[200px] flex-col",children:[(0,o.jsx)(qa,{title:"Waiting for agent",description:"Your AI agent will appear here when active",icon:(0,o.jsx)(ft,{})}),x&&s&&(0,o.jsx)(Ot,{className:"border-t pt-6 px-5",title:"Make sure you're connected to an agent",description:"Run this command in your terminal:",agents:[s]}),x&&(0,o.jsx)(le,{variant:"outline",onClick:d,type:"button",className:"mt-4",children:"Retry"})]}),e[7]=s,e[8]=n.status,e[9]=a,e[10]=x,e[11]=i,e[12]=d,e[13]=c,e[14]=O):O=e[14];let F=O,q;e[15]!==l||e[16]!==r?(q=r&&(0,o.jsx)("div",{className:"p-3 border-b",children:(0,o.jsx)(js,{permission:r,onResolve:l})}),e[15]=l,e[16]=r,e[17]=q):q=e[17];let B;e[18]===u?B=e[19]:(B=u&&(0,o.jsxs)("div",{className:"text-xs text-muted-foreground mb-2 px-2",children:["Session ID: ",u]}),e[18]=u,e[19]=B);let G;e[20]===F?G=e[21]:(G=F(),e[20]=F,e[21]=G);let Q;e[22]!==y||e[23]!==B||e[24]!==G?(Q=(0,o.jsxs)("div",{ref:p,className:"flex-1 bg-muted/20 w-full flex flex-col overflow-y-auto p-2",onScroll:y,children:[B,G]}),e[22]=y,e[23]=B,e[24]=G,e[25]=Q):Q=e[25];let te=!m&&a,ne;e[26]!==C||e[27]!==te?(ne=(0,o.jsx)(vl,{isVisible:te,onScrollToBottom:C}),e[26]=C,e[27]=te,e[28]=ne):ne=e[28];let z;return e[29]!==ne||e[30]!==q||e[31]!==Q?(z=(0,o.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden flex-shrink-0 relative",children:[q,Q,ne]}),e[29]=ne,e[30]=q,e[31]=Q,e[32]=z):z=e[32],z});Ks.displayName="ChatContent";var ha="_skip_auto_connect_",Sl=-32e3;function Cl(t){if(typeof t=="object"&&t&&"message"in t){let e=t.message;return typeof e=="string"?e:void 0}}function Js(){let t=st.get(ja);if(t)return t;let e=st.get(Na);if(!e)throw Error("Please save the notebook and refresh the browser to use the agent");return Ua.dirname(e)}function Il(){let t=st.get(Na);if(!t)throw Error("Please save the notebook and refresh the browser to use the agent");let e=st.get(ja);return e?mr.guessDeliminator(e).join(e,String(Ua.basename(t))):t}var Tl=()=>{let[t,e]=(0,R.useState)(!1),[a,s]=(0,R.useState)(null),[n,i]=(0,R.useState)(""),{files:r,addFiles:l,clearFiles:d,removeFile:c}=ar(),[u,m]=(0,R.useState)(null),h=(0,R.useRef)(null),[p]=pt(ua),[x,v]=pt(ot),y=p?cl(p.agentId):ha,{sendUpdateFile:S,sendFileDetails:C}=Vn(),I=(0,R.useRef)(!1),{connect:A,disconnect:O,setActiveSessionId:F,connectionState:q,notifications:B,pendingPermission:G,availableCommands:Q,resolvePermission:te,sessionMode:ne,activeSessionId:z,agent:P,clearNotifications:de}=po({wsUrl:y,clientOptions:{readTextFile:M=>(se.debug("Agent requesting file read",{path:M.path}),C({path:M.path}).then(L=>({content:L.contents||""}))),writeTextFile:M=>(se.debug("Agent requesting file write",{path:M.path,contentLength:M.content.length}),S({path:M.path,contents:M.content}).then(()=>({})))},autoConnect:!1});(0,R.useEffect)(()=>{P&&(async()=>{var L;let M=(L=await P.initialize({protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}}))==null?void 0:L.authMethods;M&&M.length>0&&await P.authenticate({methodId:M[0].id})})().catch(M=>{se.error("Failed to initialize/authenticate agent",{error:M})})},[P]),(0,R.useEffect)(()=>{if(F(null),y!==ha)return se.debug("Auto-connecting to agent",{sessionId:z}),A().catch(M=>{se.error("Failed to connect to agent",{error:M})}),()=>{}},[y]);let ie=oe(async()=>{if(P){I.current=!0;try{z&&(await P.cancel({sessionId:z}).catch(fe=>{se.error("Failed to cancel active session",{error:fe})}),de(z),F(null));let M=(p==null?void 0:p.selectedModel)??null;se.debug("Creating new agent session",{model:M});let L=await P.newSession({cwd:Js(),mcpServers:[],_meta:M?{model:M}:void 0});L.models&&(se.debug("Session models received",{models:L.models}),m(L.models)),v(fe=>Cs(fe,L.sessionId))}finally{I.current=!1}}}),pe=oe(async M=>{if(P){if(se.debug("Resuming agent session",{sessionId:M}),!P.loadSession)throw Error("Agent does not support loading sessions");I.current=!0;try{let L=await P.loadSession({sessionId:M,cwd:Js(),mcpServers:[]});L!=null&&L.models&&(se.debug("Session models received",{models:L.models}),m(L.models)),v(fe=>Cs(fe,M))}finally{I.current=!1}}}),Ae=q.status==="connected",ce=p==null?void 0:p.externalAgentSessionId;(0,R.useEffect)(()=>{!Ae||!p||!P||z&&ce||I.current||(async()=>{let M=ce??z;try{if(M)try{await pe(M)}catch(L){se.error("Failed to resume session",{sessionId:M,error:L}),await ie()}else await ie();s(null)}catch(L){se.error("Failed to create or resume session:",L),s(L instanceof Error?L:String(L))}})()},[Ae,P,ce,z]);let Ne=oe(async(M,L)=>{if(!z||!P||t)return;se.debug("Submitting prompt to agent",{sessionId:z}),e(!0),i(""),d(),p!=null&&p.title.startsWith("New ")&&v(Pe=>il(Pe,L));let fe;try{fe=Il()}catch{gt({title:"Notebook must be named",description:"Please name the notebook to use the agent",variant:"danger"});return}let mt=[{type:"text",text:L}],{contextBlocks:cn,attachmentBlocks:un}=await jl(L);if(mt.push(...cn,...un),r&&r.length>0){let Pe=await wl(r);mt.push(...Pe)}B.some(Pe=>Pe.type==="session_notification"&&Pe.data.update.sessionUpdate==="user_message_chunk")||mt.push({type:"resource_link",uri:fe,mimeType:"text/x-python",name:fe},{type:"resource",resource:{uri:"marimo_rules.md",mimeType:"text/plain",text:Nl(fe)}});try{await P.prompt({sessionId:z,prompt:mt})}catch(Pe){se.error("Failed to send prompt",{error:Pe})}finally{e(!1)}}),ye=oe(async()=>{!z||!P||(await P.cancel({sessionId:z}),e(!1))}),W=oe(()=>{se.debug("Manual connect requested",{currentStatus:q.status}),A()}),ee=oe(()=>{se.debug("Manual disconnect requested",{sessionId:z,currentStatus:q.status}),O()}),V=oe(M=>{var L;if(se.debug("Model change requested",{modelId:M,sessionId:z}),!P||!z){gt({title:"Cannot change model",description:"Please connect to an agent with an active session first",variant:"danger"});return}(L=P.setSessionModel)==null||L.call(P,{sessionId:z,modelId:M}),m(fe=>fe?{...fe,currentModelId:M}:null)}),H=oe(M=>{var L;if(se.debug("Mode change requested",{sessionId:z,mode:M}),!P){gt({title:"Agent not connected",description:"Please connect to an agent to change the mode",variant:"danger"});return}if(!P.setSessionMode){gt({title:"Mode change not supported",description:"The agent does not support mode changes",variant:"danger"});return}(L=P.setSessionMode)==null||L.call(P,{sessionId:z,modeId:M})}),he=B.length>0;return x.sessions.length>0?(0,o.jsxs)("div",{className:"flex flex-col flex-1 overflow-hidden mo-agent-panel",children:[(0,o.jsx)(pa,{connectionState:q,currentAgentId:p==null?void 0:p.agentId,onConnect:W,onDisconnect:ee,onRestartThread:ie,hasActiveSession:!0,shouldShowConnectionControl:y!==ha}),(0,o.jsx)(ma,{}),(()=>{if(a){let M=a instanceof Xe&&a.code===Sl,L=a instanceof Xe?Cl(a.data):void 0;return(0,o.jsx)(fr,{className:"w-3/4 mx-auto mt-10",error:L?Error(L):a,action:M?(0,o.jsx)(le,{variant:"linkDestructive",size:"sm",onClick:()=>{s(null),ie()},children:"Restart session"}):(0,o.jsx)(le,{variant:"linkDestructive",size:"sm",onClick:()=>s(null),children:"Dismiss"})})}return q.status==="connecting"?(0,o.jsx)($a,{milliseconds:200,children:(0,o.jsxs)("div",{className:"flex items-center justify-center h-full min-h-[200px] flex-col",children:[(0,o.jsx)(qt,{size:"medium",className:"text-primary"}),(0,o.jsx)("span",{className:"text-sm text-muted-foreground",children:"Connecting to the agent..."})]})}):ce==null&&q.status==="connected"?(0,o.jsx)($a,{milliseconds:200,children:(0,o.jsxs)("div",{className:"flex items-center justify-center h-full min-h-[200px] flex-col",children:[(0,o.jsx)(qt,{size:"medium",className:"text-primary"}),(0,o.jsx)("span",{className:"text-sm text-muted-foreground",children:"Creating a new session..."})]})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Ks,{agentId:p==null?void 0:p.agentId,sessionId:(p==null?void 0:p.externalAgentSessionId)??null,hasNotifications:he,connectionState:q,notifications:B,pendingPermission:G,onResolvePermission:M=>{se.debug("Resolving permission request",{sessionId:z,option:M}),te(M)},onRetryConnection:W},z),(0,o.jsx)(Ws,{isLoading:t,isRequestingPermission:!!G,onStop:ye}),r&&r.length>0&&(0,o.jsx)("div",{className:"flex flex-row gap-1 flex-wrap p-3 border-t",children:r.map(M=>(0,o.jsx)(tr,{file:M,onRemove:()=>c(M)},M.name))}),(0,o.jsx)(Vs,{isLoading:t,activeSessionId:z,promptValue:n,onPromptValueChange:i,onPromptSubmit:Ne,onAddFiles:l,onStop:ye,fileInputRef:h,commands:Q,sessionMode:ne,onModeChange:H,sessionModels:u,onModelChange:V})]})})()]}):(0,o.jsx)(qs,{currentAgentId:p==null?void 0:p.agentId,connectionState:q,onConnect:W,onDisconnect:ee})};function Al(t){return{label:`/${t.name}`,info:t.description}}function Rl(t){return{value:t.id,label:t.name,subtitle:t.description??""}}function Ml(t){return(0,o.jsx)(Ma,{value:t.value,className:"text-xs",children:(0,o.jsxs)("div",{className:"flex flex-col",children:[t.label,t.subtitle&&(0,o.jsx)("div",{className:"text-muted-foreground text-xs pt-1 block",children:t.subtitle})]})},t.value)}export{Tl as default};