@agimon-ai/po-cloudflare 0.0.2-alpha.48 → 0.0.2-alpha.49

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 (151) hide show
  1. package/dist/assets/assets/{CodeEditorView-C_mYLn6M.js → CodeEditorView-BHaOMRjc.js} +2 -2
  2. package/dist/assets/assets/{abnfDiagram-WEYOIA3C-DefVXGFV.js → abnfDiagram-WEYOIA3C-CDWx0dCZ.js} +2 -2
  3. package/dist/assets/assets/{architecture-WOLXFQ4H-Ftqji05b.js → architecture-WOLXFQ4H-CVl8TlUa.js} +1 -1
  4. package/dist/assets/assets/{architectureDiagram-ZHVYKT53-D8aOrisO.js → architectureDiagram-ZHVYKT53-B-9U5J2m.js} +2 -2
  5. package/dist/assets/assets/{blockDiagram-RJAE7QA3-COb4aakG.js → blockDiagram-RJAE7QA3-DeAmR8GR.js} +2 -2
  6. package/dist/assets/assets/{c4Diagram-XDPPPE54-B0RBwxgS.js → c4Diagram-XDPPPE54-DH-55ik1.js} +2 -2
  7. package/dist/assets/assets/channel-bSjoaDB4.js +2 -0
  8. package/dist/assets/assets/{chunk-2E7WHVMD-xslt64yZ.js → chunk-2E7WHVMD-CtD9IAQe.js} +2 -2
  9. package/dist/assets/assets/{chunk-4EMNKR2T-f3IpLd1J.js → chunk-4EMNKR2T-BlWBPhJT.js} +2 -2
  10. package/dist/assets/assets/{chunk-55XCU76K-D3q6AZAA.js → chunk-55XCU76K-CLbB5lqy.js} +2 -2
  11. package/dist/assets/assets/{chunk-7S6XSTFO-CaV-HpLf.js → chunk-7S6XSTFO-D33yaufg.js} +2 -2
  12. package/dist/assets/assets/{chunk-AQDTSKZB-DbOv8phx.js → chunk-AQDTSKZB-PRYBX44u.js} +2 -2
  13. package/dist/assets/assets/{chunk-DSNLSHJZ-CGoIJL3I.js → chunk-DSNLSHJZ-CyfThOqM.js} +2 -2
  14. package/dist/assets/assets/{chunk-HAGFOTED-K0-xCmev.js → chunk-HAGFOTED-DzN80Tcl.js} +2 -2
  15. package/dist/assets/assets/{chunk-HNE4Q36P-C3I77Xwt.js → chunk-HNE4Q36P-DKoC-RgY.js} +2 -2
  16. package/dist/assets/assets/{chunk-NQOKRVIF-r8UsQoSM.js → chunk-NQOKRVIF-BLXN1l5s.js} +2 -2
  17. package/dist/assets/assets/{chunk-UHW7PFBP-DWmOTjfa.js → chunk-UHW7PFBP-CtkUl02Z.js} +2 -2
  18. package/dist/assets/assets/{chunk-VQ5W62QI-CJV5dZLW.js → chunk-VQ5W62QI-DcSOZjGK.js} +2 -2
  19. package/dist/assets/assets/{chunk-WQQL4CDK-Bfpg87o7.js → chunk-WQQL4CDK-aN1-PJ3t.js} +2 -2
  20. package/dist/assets/assets/chunk-XXDRQBXY-BIzpIYaa.js +2 -0
  21. package/dist/assets/assets/{chunk-YZO67HFG-Cf0ywi0D.js → chunk-YZO67HFG-DhtQKpcb.js} +2 -2
  22. package/dist/assets/assets/{chunk-ZAUX2LTX-iC5Tn6mf.js → chunk-ZAUX2LTX-BKRwwtRo.js} +2 -2
  23. package/dist/assets/assets/{chunk-ZCHMQSOR-DLvEBxTv.js → chunk-ZCHMQSOR-BZT1wRxe.js} +2 -2
  24. package/dist/assets/assets/{classDiagram-v2-4MYWR3UA-DjsXLyQa.js → classDiagram-v2-4MYWR3UA-CMWkILSY.js} +2 -2
  25. package/dist/assets/assets/{cose-bilkent-JH36ORCC-Dyl7fgJO.js → cose-bilkent-JH36ORCC-Dar4SYjM.js} +2 -2
  26. package/dist/assets/assets/{cynefin-EF2NZ3EQ-CCTTt4il.js → cynefin-EF2NZ3EQ-Dh1r-XyN.js} +1 -1
  27. package/dist/assets/assets/{cynefinDiagram-WF24UDRP-djxzhWm0.js → cynefinDiagram-WF24UDRP-Dv7zKVsq.js} +2 -2
  28. package/dist/assets/assets/{dagre-NK4GIZVX-CIY5ZJbh.js → dagre-NK4GIZVX-Bf9qZfJX.js} +2 -2
  29. package/dist/assets/assets/{diagram-CBK3MWTC-LaFd7Qht.js → diagram-CBK3MWTC-Ca4NIw3-.js} +2 -2
  30. package/dist/assets/assets/{diagram-I5XIIV2D-Dk5ZMZfF.js → diagram-I5XIIV2D-DR1tHQSH.js} +2 -2
  31. package/dist/assets/assets/{diagram-ODIL2UCW-DN26_SkT.js → diagram-ODIL2UCW-Bja9G_fP.js} +2 -2
  32. package/dist/assets/assets/{diagram-PFBEJUXE-DheR717B.js → diagram-PFBEJUXE-CcKrvx7F.js} +2 -2
  33. package/dist/assets/assets/{diagram-RJA3I4VV-DX5eWt50.js → diagram-RJA3I4VV-ChfUAp5c.js} +2 -2
  34. package/dist/assets/assets/{diagram-TYUNFSNR-CzcDrOnS.js → diagram-TYUNFSNR-Z7EIy_Dd.js} +2 -2
  35. package/dist/assets/assets/{dist-DMawibLu.js → dist-C5b3-Ra2.js} +2 -2
  36. package/dist/assets/assets/{dist-BxOg0kfS.js → dist-C8ca3uHq.js} +2 -2
  37. package/dist/assets/assets/{dist-Baxx78b8.js → dist-CB7zR0aj.js} +2 -2
  38. package/dist/assets/assets/{dist-D-4bVX5R.js → dist-CY2drnbW.js} +2 -2
  39. package/dist/assets/assets/{dist-phEYiQPT.js → dist-CeHA3RMV.js} +2 -2
  40. package/dist/assets/assets/{dist-BguOTt2C.js → dist-CnDVRyzg.js} +2 -2
  41. package/dist/assets/assets/{dist-DgyHiiLg.js → dist-D4ABsHNx.js} +2 -2
  42. package/dist/assets/assets/{dist-Fr_cVur6.js → dist-DkzTnMW6.js} +2 -2
  43. package/dist/assets/assets/{dist-BmdHJeNc.js → dist-pvEcNix9.js} +2 -2
  44. package/dist/assets/assets/{ebnfDiagram-V4P3TTPT-CoM013pL.js → ebnfDiagram-V4P3TTPT-Cj7VJ0V4.js} +2 -2
  45. package/dist/assets/assets/{elk-QONTBCTQ-DmGjc9Hh.js → elk-QONTBCTQ-0md1Ryrf.js} +2 -2
  46. package/dist/assets/assets/{erDiagram-KYQIGQAA-Dz3-bYVx.js → erDiagram-KYQIGQAA-DtERkMAJ.js} +2 -2
  47. package/dist/assets/assets/{eventmodeling-K75KTNOO-CLlxLv2A.js → eventmodeling-K75KTNOO-CSIPK-Eo.js} +1 -1
  48. package/dist/assets/assets/flowDiagram-IUGLLWBU-B9oPI3Eh.js +1 -0
  49. package/dist/assets/assets/{ganttDiagram-R7GPNTJY-DnUTi2Lw.js → ganttDiagram-R7GPNTJY-WODJvYlC.js} +2 -2
  50. package/dist/assets/assets/{gitGraph-VSP46ZUC-BKN2dqtq.js → gitGraph-VSP46ZUC-u62VUFlC.js} +1 -1
  51. package/dist/assets/assets/{gitGraphDiagram-PDYL7XHY-DLrrvd0J.js → gitGraphDiagram-PDYL7XHY-nliEw829.js} +2 -2
  52. package/dist/assets/assets/index-BlFg3Cgj.js +200 -0
  53. package/dist/assets/assets/index-CWkfd_A-.css +1 -0
  54. package/dist/assets/assets/{info-OHQRW6UA-BDEgHbYs.js → info-OHQRW6UA-CYikzsdB.js} +1 -1
  55. package/dist/assets/assets/{infoDiagram-MVDRKAX5-C3Nf12JT.js → infoDiagram-MVDRKAX5-CAW8nciZ.js} +2 -2
  56. package/dist/assets/assets/{ishikawaDiagram-HPEHV2GE-fbHmqACp.js → ishikawaDiagram-HPEHV2GE-CfEaOuah.js} +2 -2
  57. package/dist/assets/assets/{journeyDiagram-BOSHW7O7-BFGkRISm.js → journeyDiagram-BOSHW7O7-gQ-SjkNw.js} +2 -2
  58. package/dist/assets/assets/{kanban-definition-FNSA4HC5-CT8LXXjC.js → kanban-definition-FNSA4HC5-DMD23QWj.js} +2 -2
  59. package/dist/assets/assets/{line-DNJRN0fU.js → line-BqPW5Rca.js} +2 -2
  60. package/dist/assets/assets/{linear-o7QEED__.js → linear-Gt3NZtDp.js} +2 -2
  61. package/dist/assets/assets/{mermaid-parser.core-CqEUiMwG.js → mermaid-parser.core-jr9WuLKp.js} +4 -4
  62. package/dist/assets/assets/{mermaid.core-UmrHaJ93.js → mermaid.core-nONZH9ES.js} +5 -5
  63. package/dist/assets/assets/{mindmap-definition-6OY57UG3-1CWvf4XD.js → mindmap-definition-6OY57UG3-P0G1aSZ_.js} +2 -2
  64. package/dist/assets/assets/{packet-JDAUHWVQ-DADADHfZ.js → packet-JDAUHWVQ-BRYh19T9.js} +1 -1
  65. package/dist/assets/assets/{pegDiagram-ECIUJNBX-QahCrnnP.js → pegDiagram-ECIUJNBX-DVXvDw5m.js} +2 -2
  66. package/dist/assets/assets/{pie-XZMESJXO-CcVs8yjR.js → pie-XZMESJXO-C4zblXYs.js} +1 -1
  67. package/dist/assets/assets/{pieDiagram-GNMPY74T-IVVcmoj4.js → pieDiagram-GNMPY74T-DQZMSxzU.js} +2 -2
  68. package/dist/assets/assets/{quadrantDiagram-D57K4MC3-CS7f-VeJ.js → quadrantDiagram-D57K4MC3-CoJW9FbN.js} +2 -2
  69. package/dist/assets/assets/{radar-ABXABTNO-imva_GNF.js → radar-ABXABTNO-C1hflkM-.js} +1 -1
  70. package/dist/assets/assets/{railroad-I3PHUGI6-GitT3taK.js → railroad-I3PHUGI6-BWfPWtIx.js} +1 -1
  71. package/dist/assets/assets/{railroad-abnf-LNEFI6M7-DA9a4ok6.js → railroad-abnf-LNEFI6M7-ZD-V0lbr.js} +1 -1
  72. package/dist/assets/assets/{railroad-ebnf-DWYD2UWJ-2G9UuZV0.js → railroad-ebnf-DWYD2UWJ-101vSltK.js} +1 -1
  73. package/dist/assets/assets/{railroad-peg-JR7BVNR7-KGkhk5i6.js → railroad-peg-JR7BVNR7-C2qdCoeJ.js} +1 -1
  74. package/dist/assets/assets/{railroadDiagram-Y72NRBL7-DRwAClPI.js → railroadDiagram-Y72NRBL7-CVB1kO7b.js} +2 -2
  75. package/dist/assets/assets/{requirementDiagram-EQYSW5RA-CWcrJ4Kd.js → requirementDiagram-EQYSW5RA-D2U3nwPk.js} +2 -2
  76. package/dist/assets/assets/{sankeyDiagram-SY24JHO5-CkMOBlFF.js → sankeyDiagram-SY24JHO5-CKjkT8B_.js} +2 -2
  77. package/dist/assets/assets/{sequenceDiagram-BLEHNHQU-B10XOG3r.js → sequenceDiagram-BLEHNHQU-CwVqG2fG.js} +2 -2
  78. package/dist/assets/assets/{src-BpxERY-4.js → src-bIf72vcz.js} +2 -2
  79. package/dist/assets/assets/{stateDiagram-v2-A6IESKWZ-D50RKXhB.js → stateDiagram-v2-A6IESKWZ-97EIvkg9.js} +2 -2
  80. package/dist/assets/assets/{swimlanes-B3ENRKFQ-DlFQGv2L.js → swimlanes-B3ENRKFQ-D9egyUg3.js} +2 -2
  81. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-BkS3IR0c.js +9 -0
  82. package/dist/assets/assets/{timeline-definition-JXYKGLGB-B3Sb86Ee.js → timeline-definition-JXYKGLGB-CbG0LH-D.js} +2 -2
  83. package/dist/assets/assets/{treeView-D4JQ5SDB-C0RfpNmP.js → treeView-D4JQ5SDB-COfpvikT.js} +1 -1
  84. package/dist/assets/assets/{treemap-SAJKECNS-DEYe7AgT.js → treemap-SAJKECNS-CU-jFNpR.js} +1 -1
  85. package/dist/assets/assets/{usecaseDiagram-WPOLBNNX-D--b6tnm.js → usecaseDiagram-WPOLBNNX-BGnYi9SF.js} +2 -2
  86. package/dist/assets/assets/{vennDiagram-Q3Y3IDCW-D1TkV4xk.js → vennDiagram-Q3Y3IDCW-Cb4zd6ET.js} +2 -2
  87. package/dist/assets/assets/{wardley-7MLQ67FV-BW1rHoM4.js → wardley-7MLQ67FV-ULAC2YGd.js} +1 -1
  88. package/dist/assets/assets/{wardleyDiagram-IVAIDKWA-1eGu-wA2.js → wardleyDiagram-IVAIDKWA-Bi-y7zjP.js} +2 -2
  89. package/dist/assets/assets/{webpack-BxGI2QQO.js → webpack-eZcyXM6S.js} +2 -2
  90. package/dist/assets/assets/{xychartDiagram-4URNHDU4-Brc-3D_H.js → xychartDiagram-4URNHDU4-BvTZJqeU.js} +2 -2
  91. package/dist/assets/bundle-asset-policy.json +1 -1
  92. package/dist/assets/index.html +2 -2
  93. package/dist/assets/plugins/assets/base-Bz0oeehA.css +2 -0
  94. package/dist/assets/plugins/chunks/po-web-runtime-oroB3Znq.js +1 -0
  95. package/dist/assets/plugins/compositions.json +1 -1
  96. package/dist/assets/plugins/slots/approval.72ae703a-DFWTk7Ap.js +2 -0
  97. package/dist/assets/plugins/slots/artifacts.77a5ce89--B-D-lue.js +1 -0
  98. package/dist/assets/plugins/slots/author.1c902d5c--QQ4lLeg.js +93 -0
  99. package/dist/assets/plugins/slots/{autocompact.86aeccf4-CcvIN-cI.js → autocompact.f08b6833-BZ-Hd0ei.js} +1 -1
  100. package/dist/assets/plugins/slots/browse.a8452a8d-DekLuc-Z.js +1 -0
  101. package/dist/assets/plugins/slots/{builtin-tools.0a7f0b8e-kbo97l14.js → builtin-tools.abc3edcc-zeBI1cKp.js} +3 -3
  102. package/dist/assets/plugins/slots/codemode.c68822dc-HLrDhndJ.js +11 -0
  103. package/dist/assets/plugins/slots/domain.d3fc60b5-Dwn3GboM.js +1 -0
  104. package/dist/assets/plugins/slots/{edit.c5b0b072-D5UaJjPf.js → edit.2aa43041-CddVpEel.js} +3 -3
  105. package/dist/assets/plugins/slots/files.c1e584ee-DxOpzqm3.js +2 -0
  106. package/dist/assets/plugins/slots/goal.b1d8b03b-C9tmOreI.js +1 -0
  107. package/dist/assets/plugins/slots/grep.b067b8cb-C4OjbSn9.js +1 -0
  108. package/dist/assets/plugins/slots/help.3b3e56cb-CcgpN98Q.js +3 -0
  109. package/dist/assets/plugins/slots/log.24faf8a0-BtnnodkX.js +4 -0
  110. package/dist/assets/plugins/slots/mcp.a6805ffa-DrBGkASK.js +109 -0
  111. package/dist/assets/plugins/slots/plan.19d1704d-C3Tml2Sz.js +3 -0
  112. package/dist/assets/plugins/slots/profile.1b4aeee4-1K7Wt9AD.js +1 -0
  113. package/dist/assets/plugins/slots/{prompts.2c187969-C4F2-Qgt.js → prompts.a5509377-h93o8dcF.js} +2 -2
  114. package/dist/assets/plugins/slots/read.a43eeb4a-DNoCGY1k.js +1 -0
  115. package/dist/assets/plugins/slots/runner.03b699da-DGs8HywA.js +8 -0
  116. package/dist/assets/plugins/slots/sessions.dc7ce5f8-CwbzOt92.js +1 -0
  117. package/dist/assets/plugins/slots/{skill.f5396fde-DjLYO2JJ.js → skill.2b6ba429-6Lp0cyos.js} +2 -2
  118. package/dist/assets/plugins/slots/subagents.9adbe0d5-tX_I8uwl.js +7 -0
  119. package/dist/assets/plugins/slots/vault.593b32bd-dkDWzchJ.js +1 -0
  120. package/dist/assets/plugins/slots/voice.376a066c-Clktk2zw.js +1 -0
  121. package/dist/{server-D9MvODKo.js → server-D0Pm5Cv2.js} +119 -6
  122. package/dist/worker.js +54 -37
  123. package/package.json +39 -39
  124. package/dist/assets/assets/channel-DNl1jI1M.js +0 -2
  125. package/dist/assets/assets/chunk-XXDRQBXY-3eapdwCn.js +0 -2
  126. package/dist/assets/assets/flowDiagram-IUGLLWBU-BFT5SBcS.js +0 -1
  127. package/dist/assets/assets/index-CcUcRF1S.css +0 -1
  128. package/dist/assets/assets/index-DWONOipn.js +0 -200
  129. package/dist/assets/assets/swimlanesDiagram-AYQRV4AK-BYHWhExM.js +0 -9
  130. package/dist/assets/plugins/assets/base-LmdY6uBA.css +0 -2
  131. package/dist/assets/plugins/chunks/po-web-runtime-DtS_FP_f.js +0 -1
  132. package/dist/assets/plugins/slots/approval.dd60ec90-m-Ra7Ebe.js +0 -2
  133. package/dist/assets/plugins/slots/artifacts.a078f1a5-DTv8TGH0.js +0 -1
  134. package/dist/assets/plugins/slots/author.497633d0-COLvE24q.js +0 -93
  135. package/dist/assets/plugins/slots/browse.5fcf164c-BgK_ibjS.js +0 -1
  136. package/dist/assets/plugins/slots/codemode.ff16ac06-CXHWhJc8.js +0 -11
  137. package/dist/assets/plugins/slots/domain.3ddea842-CvZmPWdh.js +0 -1
  138. package/dist/assets/plugins/slots/files.8ffcdcc0-COYaael1.js +0 -2
  139. package/dist/assets/plugins/slots/goal.423c7a26-nmfrCrdh.js +0 -1
  140. package/dist/assets/plugins/slots/grep.95f470b3-osJU0D9d.js +0 -1
  141. package/dist/assets/plugins/slots/help.03b9ba99-BZU2hmYF.js +0 -3
  142. package/dist/assets/plugins/slots/log.19bda339-Bi7himlR.js +0 -4
  143. package/dist/assets/plugins/slots/mcp.ffbe405a-aEn779DD.js +0 -109
  144. package/dist/assets/plugins/slots/plan.5eac6563-B8M9sD_u.js +0 -3
  145. package/dist/assets/plugins/slots/profile.176710dd-C38rbDGj.js +0 -1
  146. package/dist/assets/plugins/slots/read.1629d556-Bh5_twoW.js +0 -1
  147. package/dist/assets/plugins/slots/runner.962030e5-B4S52R79.js +0 -8
  148. package/dist/assets/plugins/slots/sessions.fc763f42-Dr4py-zv.js +0 -1
  149. package/dist/assets/plugins/slots/subagents.d815a296-Dew0ZskW.js +0 -7
  150. package/dist/assets/plugins/slots/vault.57fd9047-C0rZL_dc.js +0 -1
  151. package/dist/assets/plugins/slots/voice.b709d05c-DonnEXWO.js +0 -1
@@ -0,0 +1,109 @@
1
+ import{$t as e,An as t,Ar as n,Bn as r,Br as i,Cn as a,Cr as o,Ct as s,Dr as c,Fn as l,Gn as u,Gt as d,Ht as f,In as p,Ir as m,Kn as h,Ln as g,Lr as _,M as v,N as y,P as b,Pr as ee,Qn as te,Rn as x,S,Tn as ne,Vn as re,Vt as ie,Wt as ae,Yt as oe,_n as C,_t as w,a as se,at as ce,bt as le,c as ue,ct as de,d as T,dt as fe,er as pe,f as me,g as E,gr as he,gt as ge,h as _e,i as ve,ir as ye,it as be,j as xe,jn as Se,kn as Ce,kr as we,l as Te,mn as Ee,mt as De,n as Oe,o as D,ot as ke,pr as Ae,qn as je,rn as Me,s as O,st as Ne,t as Pe,tn as Fe,ut as Ie,vt as Le,wt as Re,x as ze,xt as Be,yt as Ve,zn as He,zt as Ue}from"../chunks/po-web-runtime-oroB3Znq.js";var We=/^(localhost|127(\.\d{1,3}){3}|\[::1\])$/u;function Ge(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Ke(e,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>64)throw Error(`Invalid widget CSP domains`);return e.map(e=>{if(typeof e!=`string`||e.length>2048)throw Error(`Invalid widget CSP domain`);let n=new URL(e),r=n.hostname.replace(/^%2a\./iu,`*.`),i=r.startsWith(`*.`),a=new URL(t),o=We.test(n.hostname),s=o?We.test(a.hostname)&&n.port===a.port:r===a.hostname||i&&a.hostname.endsWith(r.slice(1));if(!(o?[`http:`,`https:`,`ws:`,`wss:`]:[`https:`,`wss:`]).includes(n.protocol)||n.username||n.password||n.pathname!==`/`||n.search||n.hash||s||n.hostname.startsWith(`0.`)||/[\s;'"<>]/u.test(e))throw Error(`Unsafe widget CSP domain`);return`${n.protocol}//${r}${n.port?`:${n.port}`:``}`})}function qe(e,t){let n=Ge(e),r=Ge(n?.ui);if(n?.ui!==void 0&&r===void 0)throw Error(`Invalid widget UI metadata`);let i=r!==void 0&&`csp`in r,a=i?r.csp:n?.[`openai/widgetCSP`],o=a===void 0?{}:Ge(a);if(o===void 0)throw Error(`Invalid widget CSP`);let s=Ke(o[i?`resourceDomains`:`resource_domains`],t).join(` `),c=Ke(o[i?`connectDomains`:`connect_domains`],t).join(` `),l=Ke(o[i?`frameDomains`:`frame_domains`],t).join(` `);return[`default-src 'none'`,`script-src 'unsafe-inline' ${s}`,`style-src 'unsafe-inline' ${s}`,`img-src data: blob: ${s}`,`font-src data: ${s}`,`media-src blob: ${s}`,`connect-src ${c||`'none'`}`,`frame-src ${l||`'none'`}`,`child-src ${l||`'none'`}`,`worker-src 'none'`,`object-src 'none'`,`base-uri 'none'`,`form-action 'none'`].join(`; `)}function Je(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`"`,`&quot;`).replaceAll(`<`,`&lt;`)}function Ye(e){let t=e,n=t?.channel===`po.openai`?t.globals?.theme:t?.jsonrpc===`2.0`&&t.method===`ui/notifications/host-context-changed`?t.params?.theme:void 0;return n===`light`||n===`dark`?n:void 0}function Xe(e,t){let n=document.documentElement,r=t,i=!1,a=()=>{!n.classList.contains(`light`)&&!n.classList.contains(`dark`)&&n.classList.add(r),n.getAttribute(`data-theme`)===null&&n.setAttribute(`data-theme`,r)},o=()=>{n.classList.remove(`light`,`dark`),n.classList.add(r);let e=n.getAttribute(`data-theme`);(e===null||e===`light`||e===`dark`)&&n.setAttribute(`data-theme`,r),n.style.colorScheme=r};window.addEventListener(`message`,t=>{let n=t.source===parent?e(t.data):void 0;n!==void 0&&(r=n,i=!0,document.readyState!==`loading`&&o())}),document.readyState===`loading`?document.addEventListener(`readystatechange`,()=>{document.readyState===`interactive`&&(i?o():a())}):a()}function Ze(e){let t=!1,n=t=>{let n=e(t);n!==void 0&&(document.documentElement.style.colorScheme=n)};window.addEventListener(`message`,e=>{if(e.source!==parent||t||e.ports.length!==1)return;let r=e.data;if(typeof r?.html!=`string`||typeof r.policy!=`string`)return;t=!0;let i=e.ports[0],a=document.createElement(`iframe`);a.title=`MCP App content`,a.setAttribute(`sandbox`,`allow-scripts`),r.policy.includes(`frame-src 'none'`)&&a.setAttribute(`csp`,r.policy),a.setAttribute(`allow`,`camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'`),a.style.cssText=`width:100%;height:100%;border:0;display:block`;let o=!1,s=!1,c=()=>{s||(s=!0,a.remove(),i.postMessage({type:`revoked`}),i.close())};a.addEventListener(`load`,()=>{o&&c(),o=!0});let l=Date.now(),u=0;window.addEventListener(`message`,e=>{if(s||e.source!==a.contentWindow)return;try{let t=JSON.stringify(e.data);if(t===void 0||new TextEncoder().encode(t).byteLength>65536)return c();let n=Date.now();if(n-l>=1e3&&(l=n,u=0),++u>128)return c()}catch{return c()}let t=e.data?.channel===`po.openai`;r.protocol===`mcp`&&!t?parent.postMessage(e.data,`*`):i.postMessage({type:`legacy`,data:e.data})}),i.onmessage=e=>{s||(n(e.data),a.contentWindow?.postMessage(e.data,`*`))},window.addEventListener(`message`,e=>{if(!s&&e.source===parent&&r.protocol===`mcp`){let t=e.data;if(t?.jsonrpc!==`2.0`)return;n(t),a.contentWindow?.postMessage(t,`*`)}}),i.start(),a.srcdoc=r.html,document.body.append(a),i.postMessage({type:`ready`})})}function Qe(e,t=`light`){return`<!doctype html><html style="color-scheme:${t}"><meta http-equiv="Content-Security-Policy" content="${Je(e.replace(/\b(frame|child)-src ([^;]*)/gu,(e,t,n)=>n===`'none'`?`${t}-src about:`:`${t}-src about: ${n}`))}"><style>html,body{margin:0;height:100%;overflow:hidden}</style><script>(${Ze.toString()})(${Ye.toString()})<\/script>`}function $e(e,t,n=``,r=`light`){let i=`<script>(${Xe.toString()})(${Ye.toString()}, ${JSON.stringify(r)})<\/script>`;return`<!doctype html><meta http-equiv="Content-Security-Policy" content="${Je(t)}"><meta name="color-scheme" content="${r}">${i}${n}${e}`}function et(e){return`csp`in(`createElement`in e?e.createElement(`iframe`):e)}function tt(e){let t=`po.openai`,n=new Map,r=0,i=e,a=e=>{i={...i,...e},window.dispatchEvent(new CustomEvent(`openai:set_globals`,{detail:{globals:e}}))},o=(e,i)=>{if(n.size>=32)return Promise.reject(Error(`Too many pending widget requests`));let a=++r;return new Promise((r,o)=>{let s=window.setTimeout(()=>{n.delete(a),o(Error(`Widget request timed out`))},6e4);n.set(a,{resolve:r,reject:o,timer:s}),parent.postMessage({channel:t,id:a,method:e,input:i},`*`)})};Object.defineProperty(window,"openai",{value:Object.freeze({get toolInput(){return i.toolInput},get toolOutput(){return i.toolOutput},get toolResponseMetadata(){return i.toolResponseMetadata},get widgetState(){return i.widgetState},get theme(){return i.theme},get locale(){return i.locale},get displayMode(){return i.displayMode},get maxHeight(){return i.maxHeight},get safeArea(){return i.safeArea},get userAgent(){return i.userAgent},callTool:(e,t={})=>o(`callTool`,{name:e,arguments:t}),setWidgetState:e=>(a({widgetState:e}),o(`setState`,{state:e})),sendFollowUpMessage:e=>o(`followUp`,e),requestDisplayMode:()=>Promise.resolve({mode:`inline`}),openExternal:e=>o(`openLink`,{url:e.href}),requestClose:()=>o(`close`,{}),notifyIntrinsicHeight:e=>o(`height`,{height:e})}),configurable:!1,writable:!1}),window.addEventListener(`message`,e=>{if(e.source!==parent)return;let r=e.data;if(r?.channel!==t||(r.globals!==void 0&&a(r.globals),r.id===void 0))return;let i=n.get(r.id);i!==void 0&&(n.delete(r.id),clearTimeout(i.timer),typeof r.error==`string`?i.reject(Error(r.error)):i.resolve(r.result))}),parent.postMessage({channel:t,method:`initialized`,input:{}},`*`),document.addEventListener(`DOMContentLoaded`,()=>{a(i);let e=new ResizeObserver(()=>{let e=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);parent.postMessage({channel:t,method:`height`,input:{height:e}},`*`)});e.observe(document.body),window.addEventListener(`pagehide`,()=>e.disconnect(),{once:!0})},{once:!0})}function nt(e){let t=JSON.stringify(e).replaceAll(`<`,`\\u003c`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`);return`<script>(${tt.toString()})(${t})<\/script>`}var rt=Object.defineProperty,it=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),at=(e,t)=>{let n={};for(var r in e)rt(n,r,{get:e[r],enumerable:!0});return t&&rt(n,Symbol.toStringTag,{value:`Module`}),n},ot=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]);function st(e){return typeof e==`string`&&ot.has(e.replace(/#$/,``))}function ct(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function lt(e,t=`|`){return e.map(e=>It(e)).join(t)}function ut(e,t){return typeof t==`bigint`?t.toString():t}var dt=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function ft(e){return new dt(e)}function pt(e){return e==null}function mt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ht(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var gt=Symbol(`evaluating`);function _t(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==gt)return r===void 0&&(r=gt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function vt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function yt(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function bt(e){return yt(e._zod.def)??e._zod.def.shape}function xt(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return vt(this,t,e),e},enumerable:!0,configurable:!0})}function St(e,t,n){t in e?vt(e,t,n):e[t]=n}function Ct(e,t,n,r){let i=bt(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?xt(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):St(e,a,r?r(n.value,a):n.value))}}function wt(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?xt(e,n,()=>t[n]):St(e,n,r.value))}}function Tt(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Et(e){return JSON.stringify(e)}function Dt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ot=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var At=ft(()=>{if(En.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function jt(e){if(kt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return kt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Mt(e){return jt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Nt=new Set([`string`,`number`,`symbol`]);function Pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ft(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function k(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function It(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Lt(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Rt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},zt={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Bt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Ct(i,e,Vt(e,t)),Ft(e,Tt(n,{shape:i,checks:[]}))}function Vt(e,t){let n=bt(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Ht(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Vt(e,t)),a={};return Ct(a,e,Reflect.ownKeys(bt(e)).filter(e=>!i.has(e))),Ft(e,Tt(n,{shape:a,checks:[]}))}function Ut(e,t){if(!jt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=bt(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ft(e,Tt(e._zod.def,{shape:Wt(e,t)}))}function Wt(e,t){let n={};return Ct(n,e,Reflect.ownKeys(bt(e))),wt(n,t),n}function Gt(e,t){if(!jt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ft(e,Tt(e._zod.def,{shape:Wt(e,t)}))}function Kt(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Ct(n,e,Reflect.ownKeys(bt(e))),Ct(n,t,Reflect.ownKeys(bt(t))),Ft(e,Tt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function qt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Vt(t,n)):void 0,o={};return Ct(o,t,Reflect.ownKeys(bt(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Ft(t,Tt(t._zod.def,{shape:o,checks:[]}))}function Jt(e,t,n){let r=n?new Set(Vt(t,n)):void 0,i={};return Ct(i,t,Reflect.ownKeys(bt(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Ft(t,Tt(t._zod.def,{shape:i}))}function Yt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Xt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Zt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Qt(e){return typeof e==`string`?e:e?.message}function $t(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function en(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function A(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Qt(e.inst?._zod.def?.error?.(e))??Qt(a?.(e))??Qt(t?.error?.(e))??Qt(n.customError?.(e))??Qt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var tn=/[\uD800-\uDBFF]/;function nn(e){let t=e.length;if(!tn.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function rn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function an(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function on(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function sn(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):dn(e,n,r.value)}}function cn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function ln(e,t,n){return cn(e,t,n,!1)}function un(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return cn(this,n,r(this))},set(e){cn(this,n,e)}})}return t}function dn(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:cn(this,t,n.bind(this))},set(e){cn(this,t,e)}})}function fn(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var pn,mn=!1,hn={configurable:!0,get(){mn=!0}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&pn!==e._zod?pn=void 0:(pn=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,hn);let e=mn;mn=!1;try{let r=n(this);return mn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),mn||=e,r}catch(n){throw delete this[t],mn||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function gn(e,t,n,r){let i=fn(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var _n=`~constantCatch`;function vn(e){let t=()=>e;return t[_n]=!0,t}var yn,bn=Object.freeze({status:`aborted`}),xn={value:void 0,enumerable:!1},Sn=`captureStackTrace`in Error?Error:null;function Cn(e){let t=Sn;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Sn=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function M(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){xn.value=new a(r);try{Object.defineProperty(n,"_zod",xn)}finally{xn.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),sn(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Cn(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var wn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Tn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(yn=globalThis).__zod_globalConfig??(yn.__zod_globalConfig={});var En=globalThis.__zod_globalConfig;function Dn(e){return e&&Object.assign(En,e),En}function On(){let e=this._zod;return e.message??=JSON.stringify(e.def,ut,2),e.message}function kn(e){this._zod.message=e}var An={get:On,set:kn,enumerable:!0,configurable:!0},jn={value:void 0,enumerable:!1},Mn=new WeakSet([Object.prototype,Error.prototype]),Nn=M(`$ZodError`,(e,t)=>{e.name=`$ZodError`,jn.value=t,Object.defineProperty(e,"issues",jn),jn.value=void 0,Object.defineProperty(e,"message",An);let n=Object.getPrototypeOf(e);Mn.has(n)||(Mn.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Pn(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Fn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Pn(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function In(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Ln(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Rn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new wn;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>A(e,o,Dn())));throw Ot(n,a?.callee??t),n}return s.value};return t},zn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>A(e,o,Dn())));throw Ot(n,a?.callee??t),n}return s.value};return t},Bn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new wn;return a.issues.length?Vn(e,a.issues,i):{success:!0,data:a.value}};function Vn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>A(e,n,Dn()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Hn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Vn(e,a.issues,i):{success:!0,data:a.value}},Un=Symbol.for(`zod.compile.invalid`),Wn=Symbol.for(`zod.compile.fallback`),Gn=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Un)return!0;if(r.definite===!0&&n===void 0)return!1}return Kn(e,t,n)});function Kn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Wn]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new wn;return a.issues.length===0}var qn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Jn=e=>{let t=Rn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ln(n,a))};return n},Yn=e=>{let t=Rn(e),n=(e,r,i,a)=>t(e,r,i,Ln(n,a));return n},Xn=e=>{let t=zn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ln(n,a))};return n},Zn=e=>{let t=zn(e),n=async(e,r,i,a)=>await t(e,r,i,Ln(n,a));return n},Qn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Bn(e)(t,n,i)},$n=e=>(t,n,r)=>Bn(e)(t,n,r),er=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Hn(e)(t,n,i)},tr=e=>async(t,n,r)=>Hn(e)(t,n,r),nr=/^[cC][0-9a-z]{6,}$/,rr=/^[0-9a-z]+$/,ir=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ar=/^[0-9a-vA-V]{20}$/,or=/^[A-Za-z0-9]{27}$/,sr=/^[a-zA-Z0-9_-]{21}$/;function cr(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var lr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ur=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,dr=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,fr=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,pr=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function mr(){return new RegExp(pr,`u`)}var hr=/^(?:(?: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])$/,gr=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,_r=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,vr=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,br=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,xr=/^https?$/,Sr=/^\+[1-9]\d{6,14}$/,Cr=`(?:(?:\\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])))`;function wr(e){return RegExp(`^${e}$`)}var Tr=wr(Cr);function Er(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Dr(e){return RegExp(`^${Er(e)}$`)}function Or(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Er({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Er({precision:e.precision})}`:n;return RegExp(`^${Cr}T(?:${r})$`)}var kr=/^[\s\S]{0,}$/,Ar=/^-?\d+$/,jr=/^-?\d+(?:\.\d+)?$/,Mr=/^(?:true|false)$/i,Nr=/^null$/i,Pr=/^undefined$/i,Fr=/^[^A-Z]*$/,Ir=/^[^a-z]*$/,Lr=M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Rr=e=>{let t=e.value;return!pt(t)&&t.length!==void 0},zr={number:`number`,bigint:`bigint`,object:`date`},Br=M(`$ZodCheckLessThan`,(e,t)=>{Lr.init(e,t);let n=zr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:zr[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vr=M(`$ZodCheckGreaterThan`,(e,t)=>{Lr.init(e,t);let n=zr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:zr[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hr=M(`$ZodCheckMultipleOf`,(e,t)=>{Lr.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ht(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ur=M(`$ZodCheckNumberFormat`,(e,t)=>{Lr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Rt[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Wr=M(`$ZodCheckMaxLength`,(e,t)=>{var n;Lr.init(e,t),(n=e._zod.def).when??(n.when=Rr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?nn(r):i)<=t.maximum)return;let a=rn(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Gr=M(`$ZodCheckMinLength`,(e,t)=>{var n;Lr.init(e,t),(n=e._zod.def).when??(n.when=Rr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?nn(r):i)>=t.minimum)return;let a=rn(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Kr=M(`$ZodCheckLengthEquals`,(e,t)=>{var n;Lr.init(e,t),(n=e._zod.def).when??(n.when=Rr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?nn(r):i;if(a===t.length)return;let o=rn(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),qr=M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Lr.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Jr=M(`$ZodCheckRegex`,(e,t)=>{qr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yr=M(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Fr,qr.init(e,t)}),Xr=M(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ir,qr.init(e,t)}),Zr=M(`$ZodCheckIncludes`,(e,t)=>{Lr.init(e,t);let n=Pt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qr=M(`$ZodCheckStartsWith`,(e,t)=>{Lr.init(e,t);let n=RegExp(`^${Pt(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$r=M(`$ZodCheckEndsWith`,(e,t)=>{Lr.init(e,t);let n=RegExp(`.*${Pt(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ei=M(`$ZodCheckOverwrite`,(e,t)=>{Lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ti=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
3
+ `)}\n};`)(...Object.values(this.closed))}},ni={major:4,minor:6,patch:7},N=M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ni;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Yt(t),a;for(let o of n){if(o._zod.def.when){if(Xt(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new wn;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(en(t.issues,n,e),i||=Yt(t,n))});else{if(t.issues.length===n)continue;en(t.issues,n,e),i||=Yt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Yt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new wn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new wn;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return ln(this,`~standard`,ai(this))},set"~standard"(e){cn(this,`~standard`,e)}}),ri=(e,t)=>e.issues.length?{issues:e.issues.map(e=>A(e,t,Dn()))}:{value:e.value};async function ii(e,t){let n={async:!0};return ri(await e._zod.run({value:t,issues:[]},n),n)}function ai(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return ri(r,n)}catch{}return ii(e,t)},vendor:`zod`,version:1}}var oi=M(`$ZodString`,(e,t)=>{N.init(e,t),e._zod.pattern=t.pattern??kr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),P=M(`$ZodStringFormat`,(e,t)=>{qr.init(e,t),oi.init(e,t)}),si=M(`$ZodGUID`,(e,t)=>{t.pattern??=ur,P.init(e,t)}),ci=M(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=dr(e)}else t.pattern??=dr();P.init(e,t)}),li=M(`$ZodEmail`,(e,t)=>{t.pattern??=fr,P.init(e,t)});function ui(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function di(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?ui(e)||2:fi(e,t)}function fi(e,t){if(!t.normalize&&t.protocol?.source===xr.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var pi=/[\t\n\r]/g;function mi(e){return e.replace(pi,``)}function hi(e,t){return t.lastIndex=0,t.test(e.hostname)}function gi(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var _i=M(`$ZodURL`,(e,t)=>{P.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=di(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=mi(r);return}t.hostname&&!hi(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!gi(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:mi(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),vi=M(`$ZodEmoji`,(e,t)=>{t.pattern??=mr(),P.init(e,t)}),yi=M(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?sr:cr(t.length),P.init(e,t)}),bi=M(`$ZodCUID`,(e,t)=>{t.pattern??=nr,P.init(e,t)}),xi=M(`$ZodCUID2`,(e,t)=>{t.pattern??=rr,P.init(e,t)}),Si=M(`$ZodULID`,(e,t)=>{t.pattern??=ir,P.init(e,t)}),Ci=M(`$ZodXID`,(e,t)=>{t.pattern??=ar,P.init(e,t)}),wi=M(`$ZodKSUID`,(e,t)=>{t.pattern??=or,P.init(e,t)}),Ti=M(`$ZodISODateTime`,(e,t)=>{t.pattern??=Or(t),P.init(e,t)}),Ei=M(`$ZodISODate`,(e,t)=>{t.pattern??=Tr,P.init(e,t)}),Di=M(`$ZodISOTime`,(e,t)=>{t.pattern??=Dr(t),P.init(e,t)}),Oi=M(`$ZodISODuration`,(e,t)=>{t.pattern??=lr,P.init(e,t)}),ki=M(`$ZodIPv4`,(e,t)=>{t.pattern??=hr,P.init(e,t)}),Ai=/^[0-9a-fA-F:.]+$/;function ji(e){return Ai.test(e)?ui(`http://[${e}]`):!1}var Mi=M(`$ZodIPv6`,(e,t)=>{t.pattern??=gr,P.init(e,t),e._zod.check=n=>{ji(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Ni=M(`$ZodCIDRv4`,(e,t)=>{t.pattern??=_r,P.init(e,t)});function Pi(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:ji(n)}var Fi=M(`$ZodCIDRv6`,(e,t)=>{t.pattern??=vr,P.init(e,t),e._zod.check=n=>{Pi(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Ii(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Li=/^[0-9a-zA-Z+/]*={0,2}$/,Ri=M(`$ZodBase64`,(e,t)=>{t.pattern??=Li,P.init(e,t),e._zod.check=n=>{Ii(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),zi=/^[A-Za-z0-9_-]*$/;function Bi(e){if(!zi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ii(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Vi=M(`$ZodBase64URL`,(e,t)=>{t.pattern??=zi,P.init(e,t),e._zod.check=n=>{Bi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Hi=M(`$ZodE164`,(e,t)=>{t.pattern??=Sr,P.init(e,t)});function Ui(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Wi=M(`$ZodJWT`,(e,t)=>{P.init(e,t),e._zod.check=n=>{Ui(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Gi=M(`$ZodNumber`,(e,t)=>{N.init(e,t),e._zod.pattern=jr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ki=M(`$ZodNumberFormat`,(e,t)=>{Ur.init(e,t),Gi.init(e,t)}),qi=M(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=Mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ji=M(`$ZodUndefined`,(e,t)=>{N.init(e,t),e._zod.pattern=Pr,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),Yi=M(`$ZodNull`,(e,t)=>{N.init(e,t),e._zod.pattern=Nr,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Xi=M(`$ZodAny`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Zi=M(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Qi=M(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function $i(e,t){let n=$t(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of $t(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,en(n.issues,t,e),n}}return i(n,a)}}var ea=e=>Array.isArray(e)?e.length:-1;function ta(e,t,n){e.issues.length&&t.issues.push(...Zt(n,e.issues)),t.value[n]=e.value}var na=M(`$ZodArray`,(e,t)=>{N.init(e,t);let n=En.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>ta(t,r,e)));else if(ta(c,r,e),s&&c.issues.length!==0&&Yt(c))break}return o.length?Promise.all(o).then(()=>r):r},$i(e,ea)});function ra(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Zt(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var ia=[];function aa(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ia,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Lt(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function oa(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Yt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ra(e,n,i,t,d,f))):ra(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var sa=M(`$ZodObject`,(e,t)=>{N.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=ft(()=>aa(t));j(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||vt(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=kt,o=t.catchall,s,c=En.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Yt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>ra(n,t,e,r,a,o))):ra(s,t,e,r,a,o)}return o?oa(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),ca=M(`$ZodObjectJIT`,(e,t)=>{sa.init(e,t);let n=e._zod.parse,r=ft(()=>aa(t)),i=En.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ti([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
4
+ let ${e}_ab = false;
5
+ for (let i = 0; i < ${e}.issues.length; i++) {
6
+ const iss = ${e}.issues[i];
7
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
8
+ payload.issues.push(iss);
9
+ if (iss.continue !== true) ${e}_ab = true;
10
+ }
11
+ if (${e}_ab && ctx && ctx.abortEarly) {
12
+ payload.value = newResult;
13
+ return payload;
14
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Et(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
15
+ const ${n}_present = ${i};
16
+ if (!${n}.issues.length || ${n}_present) {
17
+ if (${n}.issues.length) {${c(n,r)}
18
+ }
19
+
20
+ if (${e}) {
21
+ newResult[${r}] = ${n}.value;
22
+ }
23
+ }
24
+
25
+ `)}else f?(o.write(`
26
+ if (${n}.issues.length) {${c(n,r)}
27
+ }
28
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
29
+ if (${n}.value !== undefined || ${i}) {
30
+ newResult[${r}] = ${n}.value;
31
+ }
32
+ `)):o.write(`
33
+ const ${n}_present = ${i};
34
+ if (${n}.issues.length) {${c(n,r)}
35
+ }
36
+ if (!${n}_present && !${n}.issues.length) {
37
+ payload.issues.push({
38
+ code: "invalid_type",
39
+ expected: "nonoptional",
40
+ input: undefined,
41
+ path: [${r}]
42
+ });
43
+ if (ctx && ctx.abortEarly) {
44
+ payload.value = newResult;
45
+ return payload;
46
+ }
47
+ }
48
+
49
+ if (${n}_present) {
50
+ newResult[${r}] = ${n}.value;
51
+ }
52
+
53
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=kt,c=!En.jitless,l=c&&At.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?oa([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function la(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Yt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>A(e,r,Dn())))}),t)}var ua=M(`$ZodUnion`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),j(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),j(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>mt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>la(t,r,e,i)):la(o,r,e,i)}});function da(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var fa=M(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ua.init(e,t);let n=e._zod.parse;j(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||vt(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=yt(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ft(()=>da(t));e._zod.parse=(i,a)=>{let o=i.value;if(!kt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),pa=M(`$ZodIntersection`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>ha(e,t,n)):ha(e,i,a)}});function ma(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(jt(e)&&jt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=ma(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=ma(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ha(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=ma(t.value,n.value);if(!c.valid){if(Yt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var ga=M(`$ZodRecord`,(e,t)=>{N.init(e,t);let n=En.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!jt(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>A(e,i,Dn())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Zt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Zt(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&jr.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>A(e,i,Dn())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Zt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Zt(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),_a=M(`$ZodEnum`,(e,t)=>{N.init(e,t);let n=ct(t.entries),r=new Set(n);e._zod.values=r,j(e,`pattern`,e=>{let t=ct(e.def.entries).filter(e=>Nt.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Pt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),va=M(`$ZodLiteral`,(e,t)=>{N.init(e,t);let n=new Set(t.values);e._zod.values=n,j(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Pt(e):e?Pt(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ya=M(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,En.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new wn;return n.value=i,n}});function ba(e,t){return e.value=t.issues.length?void 0:t.value,e}var xa=M(`$ZodOptional`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mt(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ba(e,t)):ba(e,r)}return t.innerType._zod.run(e,n)}}),Sa=M(`$ZodExactOptional`,(e,t)=>{xa.init(e,t),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ca=M(`$ZodNullable`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${mt(t.source)}|null)$`):void 0}),j(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wa=M(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ta(e,t)):Ta(r,t)}});function Ta(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ea=M(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Da=M(`$ZodNonOptional`,(e,t)=>{N.init(e,t),j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Oa(t,e)):Oa(i,e)}});function Oa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function ka(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>A(e,r,Dn()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Aa=M(`$ZodCatch`,(e,t)=>{N.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>ka(e,r,t,n)):ka(e,r,t,n)}}),ja=M(`$ZodPipe`,(e,t)=>{N.init(e,t),j(e,`values`,e=>e.def.in._zod.values),j(e,`optin`,e=>e.def.in._zod.optin),j(e,`optout`,e=>e.def.out._zod.optout),j(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ma(e,t.in,n)):Ma(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ma(e,t.out,n)):Ma(r,t.out,n)}});function Ma(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Na=M(`$ZodPreprocess`,(e,t)=>{ja.init(e,t)}),Pa=M(`$ZodReadonly`,(e,t)=>{N.init(e,t),j(e,`propValues`,e=>e.def.innerType._zod.propValues),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`optin`,e=>e.def.innerType?._zod?.optin),j(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Fa):Fa(r)}});function Fa(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ia=M(`$ZodLazy`,(e,t)=>{N.init(e,t),_t(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),j(e,`pattern`,e=>e.innerType?._zod?.pattern),j(e,`propValues`,e=>e.innerType?._zod?.propValues),j(e,`optin`,e=>e.innerType?._zod?.optin??void 0),j(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),La=M(`$ZodCustom`,(e,t)=>{Lr.init(e,t),N.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Ra(t,n,r,e));Ra(i,n,r,e)}});function Ra(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(on(e))}}var za=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Ba=`~memo`,Va=[];function Ha(e){return typeof e==`object`&&!!e}function Ua(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Wa=new WeakMap,Ga=0,Ka=1,qa=2;function Ja(e,t,n){let r=Wa.get(e);if(r!==void 0)return r?qa:Ga;if(t.has(e))return qa;t.add(e);let i=Ga,a=e=>{if(i!==qa&&e?._zod){let r=Ja(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Ga;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Ka:o.value?._zod?Ja(o.value,t,n):Ga;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=yt(c);s(e?o(e,!0):Ka),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ja(r,t,!1):Ka);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Ya(e,i)}function Ya(e,t){return t!==Ka&&Wa.set(e,t===qa),t}function Xa(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Za,Qa=[],$a={alloc(e,t,n){let r=Za;if(!r)return n;Za=void 0;let i={value:n,issues:null};return r.set(t.value,i),Qa.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&to(n,e.value))throw new za;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ja(e,new Set,!1);if(i===Ga)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===qa||r?n=!0:r=!0}let l=s.value;if(!Ha(l))return t(s,c);let u=c[Ba];u||(u={buckets:new WeakMap,backEdges:void 0},c[Ba]=u);let d;i===c?d=a:(d=Xa(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Ua(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Za=d;let p=Qa.length,m=t(s,c);Za=void 0;let h=Qa.length>p?Qa.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Ua(e.issues):Va),e)):(h&&(h.issues=m.issues.length?Ua(m.issues):Va),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function eo(){return $a}function to(e,t){let n=e[Ba]?.backEdges;return n!==void 0&&Ha(t)&&n.has(t)}var no=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(an(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${It(e.values[0])}`:`Invalid option: expected one of ${lt(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${lt(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ro(){return{localeError:no()}}var io,ao=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function oo(){return new ao}(io=globalThis).__zod_globalRegistry??(io.__zod_globalRegistry=oo());var so=globalThis.__zod_globalRegistry;function co(e){return e.checks&&=[...e.checks],e}function lo(e,t){return new e(co({type:`string`,...k(t)}))}function uo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function fo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function po(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function mo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function ho(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function go(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function _o(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function vo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function yo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function bo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function xo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function So(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function Co(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function wo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function To(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function Eo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function Do(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function Oo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function ko(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function Ao(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function jo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function Mo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function No(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function Po(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function Fo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function Io(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Lo(e,t){return new e(co({type:`number`,checks:[],...k(t)}))}function Ro(e,t){return new e(co({type:`number`,coerce:!0,checks:[],...k(t)}))}function zo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function Bo(e,t){return new e({type:`boolean`,...k(t)})}function Vo(e,t){return new e({type:`undefined`,...k(t)})}function Ho(e,t){return new e({type:`null`,...k(t)})}function Uo(e){return new e({type:`any`})}function Wo(e){return new e({type:`unknown`})}function Go(e,t){return new e({type:`never`,...k(t)})}function Ko(e,t){return new Br({check:`less_than`,...k(t),value:e,inclusive:!1})}function qo(e,t){return new Br({check:`less_than`,...k(t),value:e,inclusive:!0})}function Jo(e,t){return new Vr({check:`greater_than`,...k(t),value:e,inclusive:!1})}function Yo(e,t){return new Vr({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Xo(e,t){return new Hr({check:`multiple_of`,...k(t),value:e})}function Zo(e,t){return new Wr({check:`max_length`,...k(t),maximum:e})}function Qo(e,t){return new Gr({check:`min_length`,...k(t),minimum:e})}function $o(e,t){return new Kr({check:`length_equals`,...k(t),length:e})}function es(e,t){return new Jr({check:`string_format`,format:`regex`,...k(t),pattern:e})}function ts(e){return new Yr({check:`string_format`,format:`lowercase`,...k(e)})}function ns(e){return new Xr({check:`string_format`,format:`uppercase`,...k(e)})}function rs(e,t){return new Zr({check:`string_format`,format:`includes`,...k(t),includes:e})}function is(e,t){return new Qr({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function as(e,t){return new $r({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function os(e){return new ei({check:`overwrite`,tx:e})}function ss(e){return os(t=>t.normalize(e))}function cs(){return os(e=>e.trim())}function ls(){return os(e=>e.toLowerCase())}function us(){return os(e=>e.toUpperCase())}function ds(){return os(e=>Dt(e))}function fs(e,t,n){return new e({type:`array`,element:t,...k(n)})}function ps(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...k(n)})}function ms(e,t){let n=hs(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(on(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(on(r))}},e(t.value,t)),t);return n}function hs(e,t){let n=new Lr({check:`custom`,...k(t)});return n._zod.check=e,n}function gs(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&vt(e,t,n[t]);return e}function _s(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??so,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function vs(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function F(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,F(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&gs(o.schema,c),t.io===`input`&&Os(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ys(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function bs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${ys(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ys(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
54
+
55
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function xs(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;xs(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Ss=new Set([`type`,`properties`,`required`,`additionalProperties`]),Cs=[`oneOf`,`anyOf`];function ws(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Ts(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Ss.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??ws(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}vt(n,r,e.length===1?e[0]:Ts(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=ws(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Es(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Ss)if(t in e)return;let n=t.filter(e=>Cs.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Ts(t);else{let e=n[0],i=Cs.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Ts([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,gs(e,r))}function Ds(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):gs(i,s),gs(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())xs(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Es(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}gs(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,vt(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:As(t,`input`,e.processors),output:As(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Os(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Os(r.element,n);if(r.type===`set`)return Os(r.valueType,n);if(r.type===`lazy`)return Os(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Os(r.innerType,n);if(r.type===`intersection`)return Os(r.left,n)||Os(r.right,n);if(r.type===`record`||r.type===`map`)return Os(r.keyType,n)||Os(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Os(r.in,n)||Os(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Os(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Os(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Os(e,n))return!0;return!!(r.rest&&Os(r.rest,n))}return!1}var ks=(e,t={})=>n=>{let r=_s({...n,processors:t});return F(e,r),bs(r,e),Ds(r,e)},As=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=_s({...i??{},target:a,io:t,processors:n});return F(e,o),bs(o,e),Ds(o,e)},js=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ms=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ns=(e,t)=>{js(e,`minimum`,t),Ms(e,`maximum`,t)},Ps=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Fs=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Is=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ls=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Rs=(e,t)=>js(e,`minimum`,t.minimum),zs=(e,t)=>Ms(e,`maximum`,t.maximum),Bs=e=>(t,n)=>{Ls(t,n.format);let[r,i]=e[n.format];js(t,`minimum`,r),Ms(t,`maximum`,i)},Vs={greater_than:(e,t)=>js(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ms(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ps(e,t.value),number_format:Bs(Rt),bigint_format:Bs(zt),min_length:Rs,max_length:zs,length_equals:(e,t)=>Ns(e,t.length),min_size:Rs,max_size:zs,size_equals:(e,t)=>Ns(e,t.size),string_format:(e,t)=>{Ls(e,t.format),t.pattern&&Fs(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Is(e,t.mime)};function Hs(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Vs[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&js(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&js(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ms(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ms(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ps(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Is(t,i.mime);for(let e of i.patterns??[])Fs(t,e);return t}var Us={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ws=new Map([[Li,yr],[zi,br]]),Gs=e=>Ws.get(e)??e,Ks=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Hs(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Us[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Gs);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},qs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Hs(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):vs(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Js=(e,t,n,r)=>{n.type=`boolean`},Ys=(e,t,n,r)=>{vs(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},Xs=(e,t,n,r)=>{vs(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},Zs=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Qs=(e,t,n,r)=>{vs(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},$s=(e,t,n,r)=>{vs(e,t,n,r,`Void cannot be represented in JSON Schema`)},ec=(e,t,n,r)=>{n.not={}},tc=(e,t,n,r)=>{},nc=(e,t,n,r)=>{},rc=(e,t,n,r)=>{vs(e,t,n,r,`Date cannot be represented in JSON Schema`)},ic=(e,t,n,r)=>{let i=e._zod.def,a=ct(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},ac=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(vs(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(vs(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},oc=(e,t,n,r)=>{vs(e,t,n,r,`NaN cannot be represented in JSON Schema`)},sc=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},cc=(e,t,n,r)=>{let i=n;i.type=`string`,i.format=`binary`,i.contentEncoding=`binary`;let{minimum:a,maximum:o,mime:s}=Hs(e);a!==void 0&&(i.minLength=a),o!==void 0&&(i.maxLength=o),s&&(s.length===0?i.not={}:s.length===1?i.contentMediaType=s[0]:i.anyOf=s.map(e=>({contentMediaType:e})))},lc=(e,t,n,r)=>{n.type=`boolean`},uc=(e,t,n,r)=>{vs(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},dc=(e,t,n,r)=>{vs(e,t,n,r,`Function types cannot be represented in JSON Schema`)},fc=(e,t,n,r)=>{vs(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},pc=(e,t,n,r)=>{vs(e,t,n,r,`Map cannot be represented in JSON Schema`)},mc=(e,t,n,r)=>{vs(e,t,n,r,`Set cannot be represented in JSON Schema`)},hc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Hs(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=F(a.element,t,{...r,path:[...r.path,`items`]})};function gc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?gc(t.out):t.type===`catch`?gc(t.innerType):e._zod.optin}var _c=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&vs(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)vt(i.properties,e,F(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?gc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=F(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},vc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>F(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},yc=(e,t,n,r)=>{let i=e._zod.def,a=F(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=F(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},bc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>F(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?F(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?gc(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=Hs(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function xc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=xc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>xc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?jr:Ar).source)),p}var Sc=new WeakMap;function Cc(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Sc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=xc(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var wc=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Hs(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=F(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)vt(i.patternProperties,Gs(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=F(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Sc.get(t);n||(n=[],Sc.set(t,n),t.deferred.push(()=>Cc(t))),n.push(e)}i.additionalProperties=F(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&gc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Tc=(e,t,n,r)=>{let i=e._zod.def,a=F(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ec=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Dc=Symbol();function Oc(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(vs(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Dc):JSON.parse(o)}var kc=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Oc(i.defaultValue,e,t,n,r);o!==Dc&&(n.default=o)},Ac=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Oc(i.defaultValue,e,t,n,r);o!==Dc&&(n._prefault=o)},jc=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{vs(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Mc=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;F(o,t,r);let s=t.seen.get(e);s.ref=o},Nc=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Pc=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Fc=(e,t,n,r)=>{let i=e._zod.def;F(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ic=(e,t,n,r)=>{let i=e._zod.innerType;F(i,t,r);let a=t.seen.get(e);a.ref=i},Lc={string:Ks,number:qs,boolean:Js,bigint:Ys,symbol:Xs,null:Zs,undefined:Qs,void:$s,never:ec,any:tc,unknown:nc,date:rc,enum:ic,literal:ac,nan:oc,template_literal:sc,file:cc,success:lc,custom:uc,function:dc,transform:fc,map:pc,set:mc,array:hc,object:_c,union:vc,intersection:yc,tuple:bc,record:wc,nullable:Tc,nonoptional:Ec,default:kc,prefault:Ac,catch:jc,pipe:Mc,readonly:Nc,promise:Pc,optional:Fc,lazy:Ic};function Rc(e,t){if(`_idmap`in e){let n=e,r=_s({...t,processors:Lc}),i={};for(let e of n._idmap.entries()){let[t,n]=e;F(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;bs(r,n),vt(a,t,Ds(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=_s({...t,processors:Lc});return F(e,n),bs(n,e),Ds(n,e)}var zc=new WeakSet([Object.prototype,Error.prototype]);function Bc(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Vc=M(`ZodError`,(e,t)=>{Nn.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);zc.has(n)||(zc.add(n),Bc(n,`format`,e=>t=>In(e,t)),Bc(n,`flatten`,e=>t=>Fn(e,t)),Bc(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ut,2)}),Bc(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ut,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Hc=Rn(Vc),Uc=zn(Vc),Wc=Bn(Vc),Gc=Hn(Vc),Kc=Jn(Vc),qc=Yn(Vc),Jc=Xn(Vc),Yc=Zn(Vc),Xc=Qn(Vc),Zc=$n(Vc),Qc=er(Vc),$c=tr(Vc);function el(){En.localeError||Dn(ro())}function tl(){En.memoizer||Dn({memoizer:eo()})}var I=M(`ZodType`,(e,t)=>(el(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Tt(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ft(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(xu(e,t))},superRefine(e,t){return this.check(Su(e,t))},overwrite(e){return this.check(os(e))},optional(){return Y(this)},exactOptional(){return nu(this)},nullable(){return iu(this)},nullish(){return Y(iu(this))},nonoptional(e){return uu(this,e)},array(){return H(this)},or(e){return G([this,e])},and(e){return Jl(this,e)},transform(e){return mu(this,$l(e))},default(e){return ou(this,e)},prefault(e){return cu(this,e)},catch(e){return fu(this,e)},pipe(e){return mu(this,e)},readonly(){return _u(this)},describe(e){let t=this.clone();return so.add(t,{description:e}),t},meta(...e){if(e.length===0)return so.get(this);let t=this.clone();return so.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return ln(this,`~standard`,{...ai(this),jsonSchema:{input:As(this,`input`),output:As(this,`output`)}})},set"~standard"(e){cn(this,`~standard`,e)},parse:function e(t,n){return Hc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Uc(this,t,n,{callee:e})},safeParse(e,t){return Wc(this,e,t)},async safeParseAsync(e,t){return Gc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){cn(this,`spa`,e)},validate(e,t){return Gn(this,e,t)},validateAsync(e,t){return qn(this,e,t)},encode:function e(t,n){return Kc(this,t,n,{callee:e})},decode:function e(t,n){return qc(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Jc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Yc(this,t,n,{callee:e})},safeEncode(e,t){return Xc(this,e,t)},safeDecode(e,t){return Zc(this,e,t)},async safeEncodeAsync(e,t){return Qc(this,e,t)},async safeDecodeAsync(e,t){return $c(this,e,t)},toJSONSchema(e){return ks(this,{})(e)},get description(){return so.get(this)?.description},get _def(){return this._zod.def}}),nl=M(`_ZodString`,(e,t)=>{oi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r)},un({format:e=>Hs(e).format??null,minLength:e=>Hs(e).minimum??null,maxLength:e=>Hs(e).maximum??null},{regex(...e){return this.check(es(...e))},includes(...e){return this.check(rs(...e))},startsWith(...e){return this.check(is(...e))},endsWith(...e){return this.check(as(...e))},min(...e){return this.check(Qo(...e))},max(...e){return this.check(Zo(...e))},length(...e){return this.check($o(...e))},nonempty(...e){return this.check(Qo(1,...e))},lowercase(e){return this.check(ts(e))},uppercase(e){return this.check(ns(e))},trim(){return this.check(cs())},normalize(...e){return this.check(ss(...e))},toLowerCase(){return this.check(ls())},toUpperCase(){return this.check(us())},slugify(){return this.check(ds())}})),rl=M(`ZodString`,(e,t)=>{oi.init(e,t),nl.init(e,t)},{email(e){return this.check(uo(cl,e))},url(e){return this.check(_o(fl,e))},jwt(e){return this.check(Mo(Ol,e))},emoji(e){return this.check(vo(ml,e))},guid(e){return this.check(fo(ul,e))},uuid(e){return this.check(po(dl,e))},uuidv4(e){return this.check(mo(dl,e))},uuidv6(e){return this.check(ho(dl,e))},uuidv7(e){return this.check(go(dl,e))},nanoid(e){return this.check(yo(hl,e))},cuid(e){return this.check(bo(gl,e))},cuid2(e){return this.check(xo(_l,e))},ulid(e){return this.check(So(vl,e))},base64(e){return this.check(ko(Tl,e))},base64url(e){return this.check(Ao(El,e))},xid(e){return this.check(Co(yl,e))},ksuid(e){return this.check(wo(bl,e))},ipv4(e){return this.check(To(xl,e))},ipv6(e){return this.check(Eo(Sl,e))},cidrv4(e){return this.check(Do(Cl,e))},cidrv6(e){return this.check(Oo(wl,e))},e164(e){return this.check(jo(Dl,e))},datetime(e){return this.check(No(il,e))},date(e){return this.check(Po(al,e))},time(e){return this.check(Fo(ol,e))},duration(e){return this.check(Io(sl,e))}});function L(e){return lo(rl,e)}var R=M(`ZodStringFormat`,(e,t)=>{P.init(e,t),nl.init(e,t)}),il=M(`ZodISODateTime`,(e,t)=>{Ti.init(e,t),R.init(e,t)}),al=M(`ZodISODate`,(e,t)=>{Ei.init(e,t),R.init(e,t)}),ol=M(`ZodISOTime`,(e,t)=>{Di.init(e,t),R.init(e,t)}),sl=M(`ZodISODuration`,(e,t)=>{Oi.init(e,t),R.init(e,t)}),cl=M(`ZodEmail`,(e,t)=>{li.init(e,t),R.init(e,t)});function ll(e){return uo(cl,e)}var ul=M(`ZodGUID`,(e,t)=>{si.init(e,t),R.init(e,t)}),dl=M(`ZodUUID`,(e,t)=>{ci.init(e,t),R.init(e,t)}),fl=M(`ZodURL`,(e,t)=>{_i.init(e,t),R.init(e,t)});function pl(e){return _o(fl,e)}var ml=M(`ZodEmoji`,(e,t)=>{vi.init(e,t),R.init(e,t)}),hl=M(`ZodNanoID`,(e,t)=>{yi.init(e,t),R.init(e,t)}),gl=M(`ZodCUID`,(e,t)=>{bi.init(e,t),R.init(e,t)}),_l=M(`ZodCUID2`,(e,t)=>{xi.init(e,t),R.init(e,t)}),vl=M(`ZodULID`,(e,t)=>{Si.init(e,t),R.init(e,t)}),yl=M(`ZodXID`,(e,t)=>{Ci.init(e,t),R.init(e,t)}),bl=M(`ZodKSUID`,(e,t)=>{wi.init(e,t),R.init(e,t)}),xl=M(`ZodIPv4`,(e,t)=>{ki.init(e,t),R.init(e,t)}),Sl=M(`ZodIPv6`,(e,t)=>{Mi.init(e,t),R.init(e,t)}),Cl=M(`ZodCIDRv4`,(e,t)=>{Ni.init(e,t),R.init(e,t)}),wl=M(`ZodCIDRv6`,(e,t)=>{Fi.init(e,t),R.init(e,t)}),Tl=M(`ZodBase64`,(e,t)=>{Ri.init(e,t),R.init(e,t)}),El=M(`ZodBase64URL`,(e,t)=>{Vi.init(e,t),R.init(e,t)}),Dl=M(`ZodE164`,(e,t)=>{Hi.init(e,t),R.init(e,t)}),Ol=M(`ZodJWT`,(e,t)=>{Wi.init(e,t),R.init(e,t)}),kl=M(`ZodNumber`,(e,t)=>{Gi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.isFinite=!0},un({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Hs(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Hs(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Hs(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Hs(e).format??null},{gt(e,t){return this.check(Jo(e,t))},gte(e,t){return this.check(Yo(e,t))},min(e,t){return this.check(Yo(e,t))},lt(e,t){return this.check(Ko(e,t))},lte(e,t){return this.check(qo(e,t))},max(e,t){return this.check(qo(e,t))},int(e){return this.check(jl(e))},safe(e){return this.check(jl(e))},positive(e){return this.check(Jo(0,e))},nonnegative(e){return this.check(Yo(0,e))},negative(e){return this.check(Ko(0,e))},nonpositive(e){return this.check(qo(0,e))},multipleOf(e,t){return this.check(Xo(e,t))},step(e,t){return this.check(Xo(e,t))},finite(){return this}}));function z(e){return Lo(kl,e)}var Al=M(`ZodNumberFormat`,(e,t)=>{Ki.init(e,t),kl.init(e,t)});function jl(e){return zo(Al,e)}var Ml=M(`ZodBoolean`,(e,t)=>{qi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r)});function B(e){return Bo(Ml,e)}var Nl=M(`ZodUndefined`,(e,t)=>{Ji.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r)});function Pl(e){return Vo(Nl,e)}var Fl=M(`ZodNull`,(e,t)=>{Yi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zs(e,t,n,r)});function Il(e){return Ho(Fl,e)}var Ll=M(`ZodAny`,(e,t)=>{Xi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Rl(){return Uo(Ll)}var zl=M(`ZodUnknown`,(e,t)=>{Zi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function V(){return Wo(zl)}var Bl=M(`ZodNever`,(e,t)=>{Qi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ec(e,t,n,r)});function Vl(e){return Go(Bl,e)}var Hl=M(`ZodArray`,(e,t)=>{tl(),na.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Qo(e,t))},nonempty(e){return this.check(Qo(1,e))},max(e,t){return this.check(Zo(e,t))},length(e,t){return this.check($o(e,t))},unwrap(){return this.element}});function H(e,t){return fs(Hl,e,t)}var Ul=M(`ZodObject`,(e,t)=>{tl(),ca.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_c(e,t,n,r),gn(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Tt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Tt(this._zod.def,{catchall:V()}))},loose(){return this.clone(Tt(this._zod.def,{catchall:V()}))},strict(){return this.clone(Tt(this._zod.def,{catchall:Vl()}))},strip(){return this.clone(Tt(this._zod.def,{catchall:void 0}))},extend(e){return Ut(this,e)},safeExtend(e){return Gt(this,e)},merge(e){return Kt(this,e)},pick(e){return Bt(this,e)},omit(e){return Ht(this,e)},partial(...e){return qt(eu,this,e[0])},exactPartial(...e){return qt(tu,this,e[0],`exactPartial`)},required(...e){return Jt(lu,this,e[0])}});function U(e,t){return new Ul({type:`object`,shape:e??{},...k(t)})}function W(e,t){return new Ul({type:`object`,shape:e,catchall:V(),...k(t)})}var Wl=M(`ZodUnion`,(e,t)=>{ua.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vc(e,t,n,r),e.options=t.options});function G(e,t){return new Wl({type:`union`,options:e,...k(t)})}var Gl=M(`ZodDiscriminatedUnion`,(e,t)=>{Wl.init(e,t),fa.init(e,t)});function Kl(e,t,n){return new Gl({type:`union`,options:t,discriminator:e,...k(n)})}var ql=M(`ZodIntersection`,(e,t)=>{pa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yc(e,t,n,r)});function Jl(e,t){return new ql({type:`intersection`,left:e,right:t})}var Yl=M(`ZodRecord`,(e,t)=>{tl(),ga.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wc(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,n){return!t||!t._zod?new Yl({type:`record`,keyType:L(),valueType:e,...k(t)}):new Yl({type:`record`,keyType:e,valueType:t,...k(n)})}var Xl=M(`ZodEnum`,(e,t)=>{_a.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ic(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Xl({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Xl({...t,checks:[],...k(r),entries:i})}});function q(e,t){return new Xl({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}var Zl=M(`ZodLiteral`,(e,t)=>{va.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ac(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function J(e,t){return new Zl({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}var Ql=M(`ZodTransform`,(e,t)=>{tl(),ya.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(on(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(on(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function $l(e){return new Ql({type:`transform`,transform:e})}var eu=M(`ZodOptional`,(e,t)=>{xa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Y(e){return new eu({type:`optional`,innerType:e})}var tu=M(`ZodExactOptional`,(e,t)=>{Sa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nu(e){return new tu({type:`optional`,innerType:e})}var ru=M(`ZodNullable`,(e,t)=>{Ca.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function iu(e){return new ru({type:`nullable`,innerType:e})}var au=M(`ZodDefault`,(e,t)=>{wa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ou(e,t){return new au({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Mt(t)}})}var su=M(`ZodPrefault`,(e,t)=>{Ea.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ac(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cu(e,t){return new su({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Mt(t)}})}var lu=M(`ZodNonOptional`,(e,t)=>{Da.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ec(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uu(e,t){return new lu({type:`nonoptional`,innerType:e,...k(t)})}var du=M(`ZodCatch`,(e,t)=>{Aa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fu(e,t){return new du({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:vn(t)})}var pu=M(`ZodPipe`,(e,t)=>{ja.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mc(e,t,n,r),e.in=t.in,e.out=t.out});function mu(e,t){return new pu({type:`pipe`,in:e,out:t})}var hu=M(`ZodPreprocess`,(e,t)=>{pu.init(e,t),Na.init(e,t)}),gu=M(`ZodReadonly`,(e,t)=>{Pa.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nc(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _u(e){return new gu({type:`readonly`,innerType:e})}var vu=M(`ZodLazy`,(e,t)=>{Ia.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ic(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function yu(e){return new vu({type:`lazy`,getter:e})}var bu=M(`ZodCustom`,(e,t)=>{La.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uc(e,t,n,r)});function xu(e,t={}){return ps(bu,e,t)}function Su(e,t){return ms(e,t)}function Cu(e,t){return new hu({type:`pipe`,in:$l(e),out:t})}var wu={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},Tu;Tu||={};function Eu(e){return No(il,e)}function Du(e){return Po(al,e)}function Ou(e){return Ro(kl,e)}var ku=[`2025-11-25`,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Au=`io.modelcontextprotocol/related-task`,ju=`io.modelcontextprotocol/protocolVersion`,Mu=`io.modelcontextprotocol/clientInfo`,Nu=`io.modelcontextprotocol/serverInfo`,Pu=`io.modelcontextprotocol/clientCapabilities`,Fu=`io.modelcontextprotocol/subscriptionId`,Iu=`io.modelcontextprotocol/logLevel`,Lu=yu(()=>G([L(),z(),B(),Il(),K(L(),Lu),H(Lu)])),X=K(L(),Lu),Ru=H(Lu),zu=G([L(),z().int()]),Bu=L(),Vu=U({ttl:z().optional()}),Hu=U({taskId:L()}),Uu=W({progressToken:zu.optional(),[Au]:Hu.optional()}),Wu=U({_meta:Uu.optional()}),Gu=Wu.extend({task:Vu.optional()}),Z=U({method:L(),params:Wu.loose().optional()}),Ku=U({_meta:Uu.optional()}),qu=U({method:L(),params:Ku.loose().optional()}),Ju=W({get[Nu](){return cd.optional().catch(void 0)}}),Q=W({_meta:Ju.optional()}),Yu=G([L(),z().int()]),Xu=U({jsonrpc:J(`2.0`),id:Yu,...Z.shape}).strict(),Zu=U({jsonrpc:J(`2.0`),...qu.shape}).strict(),Qu=U({jsonrpc:J(`2.0`),id:Yu,result:Q}).strict(),$u=U({jsonrpc:J(`2.0`),id:Yu.optional(),error:U({code:z().int(),message:L(),data:V().optional()})}).strict(),ed=G([Xu,Zu,Qu,$u]),td=G([Qu,$u]),nd=Q.strict(),rd=Ku.extend({requestId:Yu.optional(),reason:L().optional()}),id=qu.extend({method:J(`notifications/cancelled`),params:rd}),ad=U({src:L(),mimeType:L().optional(),sizes:H(L()).optional(),theme:q([`light`,`dark`]).optional()}),od=U({icons:H(ad).optional()}),sd=U({name:L(),title:L().optional()}),cd=sd.extend({...sd.shape,...od.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),ld=Cu(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jl(U({form:Jl(U({applyDefaults:B().optional()}),X).optional(),url:X.optional()}),X.optional())),ud=W({list:X.optional(),cancel:X.optional(),requests:W({sampling:W({createMessage:X.optional()}).optional(),elicitation:W({create:X.optional()}).optional()}).optional()}),dd=W({list:X.optional(),cancel:X.optional(),requests:W({tools:W({call:X.optional()}).optional()}).optional()}),fd=U({experimental:K(L(),X).optional(),sampling:U({context:X.optional(),tools:X.optional()}).optional(),elicitation:ld.optional(),roots:U({listChanged:B().optional()}).optional(),tasks:ud.optional(),extensions:K(L(),X).optional()}),pd=Wu.extend({protocolVersion:L(),capabilities:fd,clientInfo:cd}),md=Z.extend({method:J(`initialize`),params:pd}),hd=U({experimental:K(L(),X).optional(),logging:X.optional(),completions:X.optional(),prompts:U({listChanged:B().optional()}).optional(),resources:U({subscribe:B().optional(),listChanged:B().optional()}).optional(),tools:U({listChanged:B().optional()}).optional(),tasks:dd.optional(),extensions:K(L(),X).optional()}),gd=Q.extend({protocolVersion:L(),capabilities:hd,serverInfo:cd,instructions:L().optional()}),_d=qu.extend({method:J(`notifications/initialized`),params:Ku.optional()}),vd=Z.extend({method:J(`server/discover`),params:Wu.optional()}),yd=Q.extend({supportedVersions:H(L()),capabilities:hd,instructions:L().optional()}),bd=Z.extend({method:J(`ping`),params:Wu.optional()}),xd=U({progress:z(),total:Y(z()),message:Y(L())}),Sd=U({...Ku.shape,...xd.shape,progressToken:zu}),Cd=qu.extend({method:J(`notifications/progress`),params:Sd}),wd=Wu.extend({cursor:Bu.optional()}),Td=Z.extend({params:wd.optional()}),Ed=Q.extend({nextCursor:Bu.optional()}),Dd=U({uri:L(),mimeType:Y(L()),_meta:K(L(),V()).optional()}),Od=Dd.extend({text:L()}),kd=L().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ad=Dd.extend({blob:kd}),jd=q([`user`,`assistant`]),Md=U({audience:H(jd).optional(),priority:z().min(0).max(1).optional(),lastModified:Eu({offset:!0}).optional()}),Nd=U({...sd.shape,...od.shape,uri:L(),description:Y(L()),mimeType:Y(L()),size:Y(z()),annotations:Md.optional(),_meta:Y(W({}))}),Pd=U({...sd.shape,...od.shape,uriTemplate:L(),description:Y(L()),mimeType:Y(L()),annotations:Md.optional(),_meta:Y(W({}))}),Fd=Td.extend({method:J(`resources/list`)}),Id=Ed.extend({resources:H(Nd)}),Ld=Td.extend({method:J(`resources/templates/list`)}),Rd=Ed.extend({resourceTemplates:H(Pd)}),zd=Wu.extend({uri:L()}),Bd=zd,Vd=Z.extend({method:J(`resources/read`),params:Bd}),Hd=Q.extend({contents:H(G([Od,Ad]))}),Ud=qu.extend({method:J(`notifications/resources/list_changed`),params:Ku.optional()}),Wd=zd,Gd=Z.extend({method:J(`resources/subscribe`),params:Wd}),Kd=zd,qd=Z.extend({method:J(`resources/unsubscribe`),params:Kd}),Jd=U({toolsListChanged:B().optional(),promptsListChanged:B().optional(),resourcesListChanged:B().optional(),resourceSubscriptions:H(L()).optional()}),Yd=Wu.extend({notifications:Jd}),Xd=Z.extend({method:J(`subscriptions/listen`),params:Yd}),Zd=Ku.extend({notifications:Jd}),Qd=qu.extend({method:J(`notifications/subscriptions/acknowledged`),params:Zd}),$d=Ju.extend({[Fu]:Yu}),ef=Q.extend({_meta:$d}),tf=Ku.extend({uri:L()}),nf=qu.extend({method:J(`notifications/resources/updated`),params:tf}),rf=U({name:L(),description:Y(L()),required:Y(B())}),af=U({...sd.shape,...od.shape,description:Y(L()),arguments:Y(H(rf)),_meta:Y(W({}))}),of=Td.extend({method:J(`prompts/list`)}),sf=Ed.extend({prompts:H(af)}),cf=Wu.extend({name:L(),arguments:K(L(),L()).optional()}),lf=Z.extend({method:J(`prompts/get`),params:cf}),uf=U({type:J(`text`),text:L(),annotations:Md.optional(),_meta:K(L(),V()).optional()}),df=U({type:J(`image`),data:kd,mimeType:L(),annotations:Md.optional(),_meta:K(L(),V()).optional()}),ff=U({type:J(`audio`),data:kd,mimeType:L(),annotations:Md.optional(),_meta:K(L(),V()).optional()}),pf=U({type:J(`tool_use`),name:L(),id:L(),input:K(L(),V()),_meta:K(L(),V()).optional()}),mf=U({type:J(`resource`),resource:G([Od,Ad]),annotations:Md.optional(),_meta:K(L(),V()).optional()}),hf=Nd.extend({type:J(`resource_link`)}),gf=G([uf,df,ff,hf,mf]),_f=U({role:jd,content:gf}),vf=Q.extend({description:L().optional(),messages:H(_f)}),yf=qu.extend({method:J(`notifications/prompts/list_changed`),params:Ku.optional()}),bf=U({title:L().optional(),readOnlyHint:B().optional(),destructiveHint:B().optional(),idempotentHint:B().optional(),openWorldHint:B().optional()}),xf=U({taskSupport:q([`required`,`optional`,`forbidden`]).optional()}),Sf=U({...sd.shape,...od.shape,description:L().optional(),inputSchema:U({type:J(`object`),properties:K(L(),Lu).optional(),required:H(L()).optional()}).catchall(V()),outputSchema:W({$schema:L().optional()}).optional(),annotations:bf.optional(),execution:xf.optional(),_meta:K(L(),V()).optional()}),Cf=Td.extend({method:J(`tools/list`)}),wf=Ed.extend({tools:H(Sf)}),Tf=Q.extend({content:H(gf).default([]),structuredContent:V().optional(),isError:B().optional()}),Ef=Tf.or(Q.extend({toolResult:V()})),Df=Gu.extend({name:L(),arguments:K(L(),V()).optional()}),Of=Z.extend({method:J(`tools/call`),params:Df}),kf=qu.extend({method:J(`notifications/tools/list_changed`),params:Ku.optional()}),Af=U({autoRefresh:B().default(!0),debounceMs:z().int().nonnegative().default(300)}),jf=q([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Mf=Wu.extend({level:jf}),Nf=Z.extend({method:J(`logging/setLevel`),params:Mf}),Pf=Ku.extend({level:jf,logger:L().optional(),data:V()}),Ff=qu.extend({method:J(`notifications/message`),params:Pf}),If=U({name:L().optional()}),Lf=U({hints:H(If).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),Rf=U({mode:q([`auto`,`required`,`none`]).optional()}),zf=U({type:J(`tool_result`),toolUseId:L().describe(`The unique identifier for the corresponding tool call.`),content:H(gf),structuredContent:V().optional(),isError:B().optional(),_meta:K(L(),V()).optional()}),Bf=Kl(`type`,[uf,df,ff]),Vf=Kl(`type`,[uf,df,ff,pf,zf]),Hf=U({role:jd,content:G([Vf,H(Vf)]),_meta:K(L(),V()).optional()}),Uf=Gu.extend({messages:H(Hf),modelPreferences:Lf.optional(),systemPrompt:L().optional(),includeContext:q([`none`,`thisServer`,`allServers`]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:H(L()).optional(),metadata:X.optional(),tools:H(Sf).optional(),toolChoice:Rf.optional()}),Wf=Z.extend({method:J(`sampling/createMessage`),params:Uf}),Gf=Q.extend({model:L(),stopReason:Y(q([`endTurn`,`stopSequence`,`maxTokens`]).or(L())),role:jd,content:Bf}),Kf=Q.extend({model:L(),stopReason:Y(q([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(L())),role:jd,content:G([Vf,H(Vf)])}),qf=U({type:J(`boolean`),title:L().optional(),description:L().optional(),default:B().optional()}),Jf=U({type:J(`string`),title:L().optional(),description:L().optional(),minLength:z().optional(),maxLength:z().optional(),format:q([`email`,`uri`,`date`,`date-time`]).optional(),default:L().optional()}),Yf=U({type:q([`number`,`integer`]),title:L().optional(),description:L().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),Xf=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),default:L().optional()}),Zf=U({type:J(`string`),title:L().optional(),description:L().optional(),oneOf:H(U({const:L(),title:L()})),default:L().optional()}),Qf=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),enumNames:H(L()).optional(),default:L().optional()}),$f=G([Xf,Zf]),ep=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({type:J(`string`),enum:H(L())}),default:H(L()).optional()}),tp=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({anyOf:H(U({const:L(),title:L()}))}),default:H(L()).optional()}),np=G([ep,tp]),rp=G([Qf,$f,np]),ip=G([rp,qf,Jf,Yf]),ap=Gu.extend({mode:J(`form`).optional(),message:L(),requestedSchema:U({type:J(`object`),properties:K(L(),ip),required:H(L()).optional()}).catchall(V())}),op=Gu.extend({mode:J(`url`),message:L(),elicitationId:L(),url:L().url()}),sp=G([ap,op]),cp=Z.extend({method:J(`elicitation/create`),params:sp}),lp=Ku.extend({elicitationId:L()}),up=qu.extend({method:J(`notifications/elicitation/complete`),params:lp}),dp=Q.extend({action:q([`accept`,`decline`,`cancel`]),content:Cu(e=>e===null?void 0:e,K(L(),G([L(),z(),B(),H(L())])).optional())}),fp=U({type:J(`ref/resource`),uri:L()}),pp=U({type:J(`ref/prompt`),name:L()}),mp=Wu.extend({ref:G([pp,fp]),argument:U({name:L(),value:L()}),context:U({arguments:K(L(),L()).optional()}).optional()}),hp=Z.extend({method:J(`completion/complete`),params:mp}),gp=Q.extend({completion:W({values:H(L()).max(100),total:Y(z().int()),hasMore:Y(B())})}),_p=U({uri:L().startsWith(`file://`),name:L().optional(),_meta:K(L(),V()).optional()}),vp=Z.extend({method:J(`roots/list`),params:Wu.optional()}),yp=Q.extend({roots:H(_p)}),bp=qu.extend({method:J(`notifications/roots/list_changed`),params:Ku.optional()}),xp=W({ttl:z().optional(),pollInterval:z().optional()}),Sp=q([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Cp=U({taskId:L(),status:Sp,ttl:G([z(),Il()]),createdAt:L(),lastUpdatedAt:L(),pollInterval:Y(z()),statusMessage:Y(L())}),wp=Q.extend({task:Cp}),Tp=Ku.merge(Cp),Ep=qu.extend({method:J(`notifications/tasks/status`),params:Tp}),Dp=Z.extend({method:J(`tasks/get`),params:Wu.extend({taskId:L()})}),Op=Q.merge(Cp),kp=Z.extend({method:J(`tasks/result`),params:Wu.extend({taskId:L()})}),Ap=Q.loose(),jp=Td.extend({method:J(`tasks/list`)}),Mp=Ed.extend({tasks:H(Cp)}),Np=Z.extend({method:J(`tasks/cancel`),params:Wu.extend({taskId:L()})}),Pp=Q.merge(Cp),Fp=G([bd,md,vd,hp,Nf,lf,of,Fd,Ld,Vd,Gd,qd,Xd,Of,Cf]),Ip=G([id,Cd,_d,bp]),Lp=G([nd,Gf,Kf,dp,yp]),Rp=G([bd,Wf,cp,vp]),zp=G([id,Cd,Ff,nf,Ud,kf,yf,Qd,up]),Bp=G([nd,gd,yd,gp,vf,sf,Id,Rd,Hd,Tf,wf,ef]),Vp=pl().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:wu.custom,message:`URL must be parseable`,fatal:!0}),bn}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Hp=W({resource:L().url(),authorization_servers:H(Vp).optional(),jwks_uri:L().url().optional(),scopes_supported:H(L()).optional(),bearer_methods_supported:H(L()).optional(),resource_signing_alg_values_supported:H(L()).optional(),resource_name:L().optional(),resource_documentation:L().optional(),resource_policy_uri:L().url().optional(),resource_tos_uri:L().url().optional(),tls_client_certificate_bound_access_tokens:B().optional(),authorization_details_types_supported:H(L()).optional(),dpop_signing_alg_values_supported:H(L()).optional(),dpop_bound_access_tokens_required:B().optional()}),Up=W({issuer:L(),authorization_endpoint:Vp,token_endpoint:Vp,registration_endpoint:Vp.optional(),scopes_supported:H(L()).optional(),response_types_supported:H(L()),response_modes_supported:H(L()).optional(),grant_types_supported:H(L()).optional(),token_endpoint_auth_methods_supported:H(L()).optional(),token_endpoint_auth_signing_alg_values_supported:H(L()).optional(),service_documentation:Vp.optional(),revocation_endpoint:Vp.optional(),revocation_endpoint_auth_methods_supported:H(L()).optional(),revocation_endpoint_auth_signing_alg_values_supported:H(L()).optional(),introspection_endpoint:L().optional(),introspection_endpoint_auth_methods_supported:H(L()).optional(),introspection_endpoint_auth_signing_alg_values_supported:H(L()).optional(),code_challenge_methods_supported:H(L()).optional(),client_id_metadata_document_supported:B().optional(),authorization_response_iss_parameter_supported:B().optional().catch(void 0),dpop_signing_alg_values_supported:H(L()).optional()}),Wp=W({issuer:L(),authorization_endpoint:Vp,token_endpoint:Vp,userinfo_endpoint:Vp.optional(),jwks_uri:Vp,registration_endpoint:Vp.optional(),scopes_supported:H(L()).optional(),response_types_supported:H(L()),response_modes_supported:H(L()).optional(),grant_types_supported:H(L()).optional(),acr_values_supported:H(L()).optional(),subject_types_supported:H(L()),id_token_signing_alg_values_supported:H(L()),id_token_encryption_alg_values_supported:H(L()).optional(),id_token_encryption_enc_values_supported:H(L()).optional(),userinfo_signing_alg_values_supported:H(L()).optional(),userinfo_encryption_alg_values_supported:H(L()).optional(),userinfo_encryption_enc_values_supported:H(L()).optional(),request_object_signing_alg_values_supported:H(L()).optional(),request_object_encryption_alg_values_supported:H(L()).optional(),request_object_encryption_enc_values_supported:H(L()).optional(),token_endpoint_auth_methods_supported:H(L()).optional(),token_endpoint_auth_signing_alg_values_supported:H(L()).optional(),display_values_supported:H(L()).optional(),claim_types_supported:H(L()).optional(),claims_supported:H(L()).optional(),service_documentation:L().optional(),claims_locales_supported:H(L()).optional(),ui_locales_supported:H(L()).optional(),claims_parameter_supported:B().optional(),request_parameter_supported:B().optional(),request_uri_parameter_supported:B().optional(),require_request_uri_registration:B().optional(),op_policy_uri:Vp.optional(),op_tos_uri:Vp.optional(),client_id_metadata_document_supported:B().optional(),authorization_response_iss_parameter_supported:B().optional().catch(void 0)}),Gp=U({...Wp.shape,...Up.pick({code_challenge_methods_supported:!0}).shape}),Kp=U({access_token:L(),id_token:L().optional(),token_type:L(),expires_in:Ou().optional(),scope:L().optional(),refresh_token:L().optional(),issuer:L().optional().catch(void 0)}).strip(),qp=U({issued_token_type:J(`urn:ietf:params:oauth:token-type:id-jag`),access_token:L(),token_type:L().optional(),expires_in:z().optional(),scope:L().optional()}).strip(),Jp=U({error:L(),error_description:L().optional(),error_uri:L().optional()}),Yp=Vp.optional().or(J(``).transform(()=>void 0)),Xp=U({redirect_uris:H(Vp),token_endpoint_auth_method:L().optional(),grant_types:H(L()).optional(),response_types:H(L()).optional(),application_type:L().optional(),client_name:L().optional(),client_uri:Vp.optional(),logo_uri:Yp,scope:L().optional(),contacts:H(L()).optional(),tos_uri:Yp,policy_uri:L().optional(),jwks_uri:Vp.optional(),jwks:Rl().optional(),software_id:L().optional(),software_version:L().optional(),software_statement:L().optional()}).strip(),Zp=U({client_id:L(),client_secret:L().optional(),client_id_issued_at:z().optional(),client_secret_expires_at:z().optional(),issuer:L().optional().catch(void 0)}).strip(),Qp=Xp.merge(Zp),$p=U({error:L(),error_description:L().optional()}).strip(),em=U({token:L(),token_type_hint:L().optional()}).strip(),tm=Symbol.for(`mcp.sdk.errorBrands`);function nm(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,tm,{value:n,enumerable:!1,configurable:!0})}function rm(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,tm)){let n=t[tm];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}(class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,nm(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}});var im=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),am=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,nm(this,new.target)}};(class extends am{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}});var om=`2026-07-28`;function sm(e){return e>=om}function cm(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var lm=[`task`,`inputRequests`,`requestState`];function um(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||lm.some(t=>t in e)?e:{...e,content:[]}}function dm(){let e=yu(()=>G([L(),z(),B(),Il(),K(L(),e),H(e)])),t=K(L(),e),n=G([L(),z().int()]),r=L(),i=U({ttl:z().optional()}),a=U({taskId:L()}),o=W({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=U({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=U({method:L(),params:s.loose().optional()}),u=U({_meta:o.optional()}),d=U({method:L(),params:u.loose().optional()}),f=W({_meta:o.optional()}),p=G([L(),z().int()]),m=f.strict(),h=u.extend({requestId:p.optional(),reason:L().optional()}),g=d.extend({method:J(`notifications/cancelled`),params:h}),_=U({src:L(),mimeType:L().optional(),sizes:H(L()).optional(),theme:q([`light`,`dark`]).optional()}),v=U({icons:H(_).optional()}),y=U({name:L(),title:L().optional()}),b=y.extend({...y.shape,...v.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),ee=Cu(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jl(U({form:Jl(U({applyDefaults:B().optional()}),t).optional(),url:t.optional()}),t.optional())),te=W({list:t.optional(),cancel:t.optional(),requests:W({sampling:W({createMessage:t.optional()}).optional(),elicitation:W({create:t.optional()}).optional()}).optional()}),x=W({list:t.optional(),cancel:t.optional(),requests:W({tools:W({call:t.optional()}).optional()}).optional()}),S=U({experimental:K(L(),t).optional(),sampling:U({context:t.optional(),tools:t.optional()}).optional(),elicitation:ee.optional(),roots:U({listChanged:B().optional()}).optional(),tasks:te.optional(),extensions:K(L(),t).optional()}),ne=s.extend({protocolVersion:L(),capabilities:S,clientInfo:b}),re=l.extend({method:J(`initialize`),params:ne}),ie=U({experimental:K(L(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:U({listChanged:B().optional()}).optional(),resources:U({subscribe:B().optional(),listChanged:B().optional()}).optional(),tools:U({listChanged:B().optional()}).optional(),tasks:x.optional(),extensions:K(L(),t).optional()}),ae=f.extend({protocolVersion:L(),capabilities:ie,serverInfo:b,instructions:L().optional()}),oe=d.extend({method:J(`notifications/initialized`),params:u.optional()}),C=l.extend({method:J(`ping`),params:s.optional()}),w=U({progress:z(),total:Y(z()),message:Y(L())}),se=U({...u.shape,...w.shape,progressToken:n}),ce=d.extend({method:J(`notifications/progress`),params:se}),le=s.extend({cursor:r.optional()}),ue=l.extend({params:le.optional()}),de=f.extend({nextCursor:r.optional()}),T=U({uri:L(),mimeType:Y(L()),_meta:K(L(),V()).optional()}),fe=T.extend({text:L()}),pe=L().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),me=T.extend({blob:pe}),E=q([`user`,`assistant`]),he=U({audience:H(E).optional(),priority:z().min(0).max(1).optional(),lastModified:Eu({offset:!0}).optional()}),ge=U({...y.shape,...v.shape,uri:L(),description:Y(L()),mimeType:Y(L()),size:Y(z()),annotations:he.optional(),_meta:Y(W({}))}),_e=U({...y.shape,...v.shape,uriTemplate:L(),description:Y(L()),mimeType:Y(L()),annotations:he.optional(),_meta:Y(W({}))}),ve=ue.extend({method:J(`resources/list`)}),ye=de.extend({resources:H(ge)}),be=ue.extend({method:J(`resources/templates/list`)}),xe=de.extend({resourceTemplates:H(_e)}),Se=s.extend({uri:L()}),Ce=Se,we=l.extend({method:J(`resources/read`),params:Ce}),Te=f.extend({contents:H(G([fe,me]))}),Ee=d.extend({method:J(`notifications/resources/list_changed`),params:u.optional()}),De=Se,Oe=l.extend({method:J(`resources/subscribe`),params:De}),D=Se,ke=l.extend({method:J(`resources/unsubscribe`),params:D}),Ae=u.extend({uri:L()}),je=d.extend({method:J(`notifications/resources/updated`),params:Ae}),Me=U({name:L(),description:Y(L()),required:Y(B())}),O=U({...y.shape,...v.shape,description:Y(L()),arguments:Y(H(Me)),_meta:Y(W({}))}),Ne=ue.extend({method:J(`prompts/list`)}),Pe=de.extend({prompts:H(O)}),Fe=s.extend({name:L(),arguments:K(L(),L()).optional()}),Ie=l.extend({method:J(`prompts/get`),params:Fe}),Le=U({type:J(`text`),text:L(),annotations:he.optional(),_meta:K(L(),V()).optional()}),Re=U({type:J(`image`),data:pe,mimeType:L(),annotations:he.optional(),_meta:K(L(),V()).optional()}),ze=U({type:J(`audio`),data:pe,mimeType:L(),annotations:he.optional(),_meta:K(L(),V()).optional()}),Be=U({type:J(`tool_use`),name:L(),id:L(),input:K(L(),V()),_meta:K(L(),V()).optional()}),Ve=U({type:J(`resource`),resource:G([fe,me]),annotations:he.optional(),_meta:K(L(),V()).optional()}),He=ge.extend({type:J(`resource_link`)}),Ue=G([Le,Re,ze,He,Ve]),We=U({role:E,content:Ue}),Ge=f.extend({description:L().optional(),messages:H(We)}),Ke=d.extend({method:J(`notifications/prompts/list_changed`),params:u.optional()}),qe=U({title:L().optional(),readOnlyHint:B().optional(),destructiveHint:B().optional(),idempotentHint:B().optional(),openWorldHint:B().optional()}),Je=U({taskSupport:q([`required`,`optional`,`forbidden`]).optional()}),Ye=U({...y.shape,...v.shape,description:L().optional(),inputSchema:U({type:J(`object`),properties:K(L(),e).optional(),required:H(L()).optional()}).catchall(V()),outputSchema:U({type:J(`object`),properties:K(L(),e).optional(),required:H(L()).optional()}).catchall(V()).optional(),annotations:qe.optional(),execution:Je.optional(),_meta:K(L(),V()).optional()}),Xe=ue.extend({method:J(`tools/list`)}),Ze=de.extend({tools:H(Ye)}),Qe=f.extend({content:H(Ue),structuredContent:K(L(),V()).optional(),isError:B().optional()}),$e=c.extend({name:L(),arguments:K(L(),V()).optional()}),et=l.extend({method:J(`tools/call`),params:$e}),tt=d.extend({method:J(`notifications/tools/list_changed`),params:u.optional()}),nt=q([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),rt=s.extend({level:nt}),it=l.extend({method:J(`logging/setLevel`),params:rt}),at=u.extend({level:nt,logger:L().optional(),data:V()}),ot=d.extend({method:J(`notifications/message`),params:at}),st=U({name:L().optional()}),ct=U({hints:H(st).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),lt=U({mode:q([`auto`,`required`,`none`]).optional()}),ut=U({type:J(`tool_result`),toolUseId:L().describe(`The unique identifier for the corresponding tool call.`),content:H(Ue),structuredContent:U({}).loose().optional(),isError:B().optional(),_meta:K(L(),V()).optional()}),dt=Kl(`type`,[Le,Re,ze]),ft=Kl(`type`,[Le,Re,ze,Be,ut]),pt=U({role:E,content:G([ft,H(ft)]),_meta:K(L(),V()).optional()}),mt=c.extend({messages:H(pt),modelPreferences:ct.optional(),systemPrompt:L().optional(),includeContext:q([`none`,`thisServer`,`allServers`]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:H(L()).optional(),metadata:t.optional(),tools:H(Ye).optional(),toolChoice:lt.optional()}),ht=l.extend({method:J(`sampling/createMessage`),params:mt}),gt=f.extend({model:L(),stopReason:Y(q([`endTurn`,`stopSequence`,`maxTokens`]).or(L())),role:E,content:dt}),_t=f.extend({model:L(),stopReason:Y(q([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(L())),role:E,content:G([ft,H(ft)])}),vt=U({type:J(`boolean`),title:L().optional(),description:L().optional(),default:B().optional()}),yt=U({type:J(`string`),title:L().optional(),description:L().optional(),minLength:z().optional(),maxLength:z().optional(),format:q([`email`,`uri`,`date`,`date-time`]).optional(),default:L().optional()}),bt=U({type:q([`number`,`integer`]),title:L().optional(),description:L().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),xt=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),default:L().optional()}),St=U({type:J(`string`),title:L().optional(),description:L().optional(),oneOf:H(U({const:L(),title:L()})),default:L().optional()}),Ct=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),enumNames:H(L()).optional(),default:L().optional()}),wt=G([xt,St]),Tt=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({type:J(`string`),enum:H(L())}),default:H(L()).optional()}),Et=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({anyOf:H(U({const:L(),title:L()}))}),default:H(L()).optional()}),Dt=G([Tt,Et]),Ot=G([Ct,wt,Dt]),kt=G([Ot,vt,yt,bt]),At=c.extend({mode:J(`form`).optional(),message:L(),requestedSchema:U({type:J(`object`),properties:K(L(),kt),required:H(L()).optional()}).catchall(V())}),jt=c.extend({mode:J(`url`),message:L(),elicitationId:L(),url:L().url()}),Mt=G([At,jt]),Nt=l.extend({method:J(`elicitation/create`),params:Mt}),Pt=u.extend({elicitationId:L()}),Ft=d.extend({method:J(`notifications/elicitation/complete`),params:Pt}),k=f.extend({action:q([`accept`,`decline`,`cancel`]),content:Cu(e=>e===null?void 0:e,K(L(),G([L(),z(),B(),H(L())])).optional())}),It=U({type:J(`ref/resource`),uri:L()}),Lt=U({type:J(`ref/prompt`),name:L()}),Rt=s.extend({ref:G([Lt,It]),argument:U({name:L(),value:L()}),context:U({arguments:K(L(),L()).optional()}).optional()}),zt=l.extend({method:J(`completion/complete`),params:Rt}),Bt=f.extend({completion:W({values:H(L()).max(100),total:Y(z().int()),hasMore:Y(B())})}),Vt=U({uri:L().startsWith(`file://`),name:L().optional(),_meta:K(L(),V()).optional()}),Ht=l.extend({method:J(`roots/list`),params:s.optional()}),Ut=f.extend({roots:H(Vt)}),Wt=d.extend({method:J(`notifications/roots/list_changed`),params:u.optional()}),Gt=W({ttl:z().optional(),pollInterval:z().optional()}),Kt=q([`working`,`input_required`,`completed`,`failed`,`cancelled`]),qt=U({taskId:L(),status:Kt,ttl:G([z(),Il()]),createdAt:L(),lastUpdatedAt:L(),pollInterval:Y(z()),statusMessage:Y(L())}),Jt=f.extend({task:qt}),Yt=u.merge(qt),Xt=d.extend({method:J(`notifications/tasks/status`),params:Yt}),Zt=l.extend({method:J(`tasks/get`),params:s.extend({taskId:L()})}),Qt=f.merge(qt),$t=l.extend({method:J(`tasks/result`),params:s.extend({taskId:L()})}),en=f.loose(),A=ue.extend({method:J(`tasks/list`)}),tn=de.extend({tasks:H(qt)}),nn=l.extend({method:J(`tasks/cancel`),params:s.extend({taskId:L()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:m,CancelledNotificationParamsSchema:h,CancelledNotificationSchema:g,IconSchema:_,IconsSchema:v,BaseMetadataSchema:y,ImplementationSchema:b,ClientTasksCapabilitySchema:te,ServerTasksCapabilitySchema:x,ClientCapabilitiesSchema:S,InitializeRequestParamsSchema:ne,InitializeRequestSchema:re,ServerCapabilitiesSchema:ie,InitializeResultSchema:ae,InitializedNotificationSchema:oe,PingRequestSchema:C,ProgressSchema:w,ProgressNotificationParamsSchema:se,ProgressNotificationSchema:ce,PaginatedRequestParamsSchema:le,PaginatedRequestSchema:ue,PaginatedResultSchema:de,ResourceContentsSchema:T,TextResourceContentsSchema:fe,BlobResourceContentsSchema:me,RoleSchema:E,AnnotationsSchema:he,ResourceSchema:ge,ResourceTemplateSchema:_e,ListResourcesRequestSchema:ve,ListResourcesResultSchema:ye,ListResourceTemplatesRequestSchema:be,ListResourceTemplatesResultSchema:xe,ResourceRequestParamsSchema:Se,ReadResourceRequestParamsSchema:Ce,ReadResourceRequestSchema:we,ReadResourceResultSchema:Te,ResourceListChangedNotificationSchema:Ee,SubscribeRequestParamsSchema:De,SubscribeRequestSchema:Oe,UnsubscribeRequestParamsSchema:D,UnsubscribeRequestSchema:ke,ResourceUpdatedNotificationParamsSchema:Ae,ResourceUpdatedNotificationSchema:je,PromptArgumentSchema:Me,PromptSchema:O,ListPromptsRequestSchema:Ne,ListPromptsResultSchema:Pe,GetPromptRequestParamsSchema:Fe,GetPromptRequestSchema:Ie,TextContentSchema:Le,ImageContentSchema:Re,AudioContentSchema:ze,ToolUseContentSchema:Be,EmbeddedResourceSchema:Ve,ResourceLinkSchema:He,ContentBlockSchema:Ue,PromptMessageSchema:We,GetPromptResultSchema:Ge,PromptListChangedNotificationSchema:Ke,ToolAnnotationsSchema:qe,ToolExecutionSchema:Je,ToolSchema:Ye,ListToolsRequestSchema:Xe,ListToolsResultSchema:Ze,CallToolResultSchema:Qe,CallToolRequestParamsSchema:$e,CallToolRequestSchema:et,ToolListChangedNotificationSchema:tt,LoggingLevelSchema:nt,SetLevelRequestParamsSchema:rt,SetLevelRequestSchema:it,LoggingMessageNotificationParamsSchema:at,LoggingMessageNotificationSchema:ot,ModelHintSchema:st,ModelPreferencesSchema:ct,ToolChoiceSchema:lt,ToolResultContentSchema:ut,SamplingContentSchema:dt,SamplingMessageContentBlockSchema:ft,SamplingMessageSchema:pt,CreateMessageRequestParamsSchema:mt,CreateMessageRequestSchema:ht,CreateMessageResultSchema:gt,CreateMessageResultWithToolsSchema:_t,BooleanSchemaSchema:vt,StringSchemaSchema:yt,NumberSchemaSchema:bt,UntitledSingleSelectEnumSchemaSchema:xt,TitledSingleSelectEnumSchemaSchema:St,LegacyTitledEnumSchemaSchema:Ct,SingleSelectEnumSchemaSchema:wt,UntitledMultiSelectEnumSchemaSchema:Tt,TitledMultiSelectEnumSchemaSchema:Et,MultiSelectEnumSchemaSchema:Dt,EnumSchemaSchema:Ot,PrimitiveSchemaDefinitionSchema:kt,ElicitRequestFormParamsSchema:At,ElicitRequestURLParamsSchema:jt,ElicitRequestParamsSchema:Mt,ElicitRequestSchema:Nt,ElicitationCompleteNotificationParamsSchema:Pt,ElicitationCompleteNotificationSchema:Ft,ElicitResultSchema:k,ResourceTemplateReferenceSchema:It,PromptReferenceSchema:Lt,CompleteRequestParamsSchema:Rt,CompleteRequestSchema:zt,CompleteResultSchema:Bt,RootSchema:Vt,ListRootsRequestSchema:Ht,ListRootsResultSchema:Ut,RootsListChangedNotificationSchema:Wt,TaskCreationParamsSchema:Gt,TaskStatusSchema:Kt,TaskSchema:qt,CreateTaskResultSchema:Jt,TaskStatusNotificationParamsSchema:Yt,TaskStatusNotificationSchema:Xt,GetTaskRequestSchema:Zt,GetTaskResultSchema:Qt,GetTaskPayloadRequestSchema:$t,GetTaskPayloadResultSchema:en,ListTasksRequestSchema:A,ListTasksResultSchema:tn,CancelTaskRequestSchema:nn,CancelTaskResultSchema:f.merge(qt),ClientRequestSchema:G([C,re,zt,it,Ie,Ne,ve,be,we,Oe,ke,et,Xe,Zt,$t,A,nn]),ClientNotificationSchema:G([g,ce,oe,Wt,Xt]),ClientResultSchema:G([m,gt,_t,k,Ut,Qt,tn,Jt]),ServerRequestSchema:G([C,ht,Nt,Ht,Zt,$t,A,nn]),ServerNotificationSchema:G([g,ce,ot,je,Ee,tt,Ke,Xt,Ft]),ServerResultSchema:G([m,ae,Bt,Ge,Pe,ye,xe,Te,Qe,Ze,Qt,tn,Jt]),CallToolResultWireSchema:V().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of lm)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(um).pipe(Qe)}}var fm;function pm(){return fm??=dm()}function mm(e){return e.type!==`object`}var hm=new Set([`const`,`enum`,`default`,`examples`]),gm=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function _m(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function vm(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(_m(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=st(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&_m(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=hm.has(o)?s:gm.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var ym={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},bm={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},xm={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Sm;function Cm(){if(Sm)return Sm;let e=pm();return Sm={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Sm}function wm(e){return Object.prototype.hasOwnProperty.call(ym,e)}function Tm(e){return Object.prototype.hasOwnProperty.call(bm,e)}function Em(e){return Object.prototype.hasOwnProperty.call(xm,e)}function Dm(e){return Em(e)?Cm().resultSchemas[e]:void 0}function Om(e){return wm(e)?Cm().requestSchemas[e]:void 0}function km(e){return Tm(e)?Cm().notificationSchemas[e]:void 0}Object.keys(ym),Object.keys(bm);function Am(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jm(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Mm={ok:!1,reason:`not-in-era`};function Nm(e){return Am(e)&&Am(e.outputSchema)&&mm(e.outputSchema)}function Pm(e){return e}var Fm={era:`2025-11-25`,hasRequestMethod:wm,hasNotificationMethod:Tm,validateRequest:(e,t)=>jm(Om(e),t),validateResult:(e,t)=>jm(Dm(e),t),validateNotification:(e,t)=>jm(km(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Mm,validateInputResponse:()=>Mm,samplingResultVariant:((e,t)=>{let n=pm();return jm(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=cm(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&mm(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Am(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Pm(e)}}return{kind:`complete`,result:Pm(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Nm(e))?t:{...t,tools:n.map(e=>Nm(e)?{...e,outputSchema:vm(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function Im(){let e=yu(()=>G([L(),z(),B(),Il(),K(L(),e),H(e)])),t=K(L(),e),n=G([L(),z().int()]),r=L(),i=G([L(),z().int()]),a=q([`user`,`assistant`]),o=q([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=L().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=U({ttl:z().optional()}),l=U({taskId:L()}),u=W({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=U({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=U({_meta:u.optional()}),m=U({method:L(),params:p.loose().optional()}),h=U({src:L(),mimeType:L().optional(),sizes:H(L()).optional(),theme:q([`light`,`dark`]).optional()}),g=U({icons:H(h).optional()}),_=U({name:L(),title:L().optional()}),v=_.extend({..._.shape,...g.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),y=Cu(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Jl(U({form:Jl(U({applyDefaults:B().optional()}),t).optional(),url:t.optional()}),t.optional())),b=W({list:t.optional(),cancel:t.optional(),requests:W({sampling:W({createMessage:t.optional()}).optional(),elicitation:W({create:t.optional()}).optional()}).optional()}),ee=W({list:t.optional(),cancel:t.optional(),requests:W({tools:W({call:t.optional()}).optional()}).optional()}),te=U({experimental:K(L(),t).optional(),sampling:U({context:t.optional(),tools:t.optional()}).optional(),elicitation:y.optional(),roots:U({listChanged:B().optional()}).optional(),tasks:b.optional(),extensions:K(L(),t).optional()}),x=U({experimental:K(L(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:U({listChanged:B().optional()}).optional(),resources:U({subscribe:B().optional(),listChanged:B().optional()}).optional(),tools:U({listChanged:B().optional()}).optional(),tasks:ee.optional(),extensions:K(L(),t).optional()}),S=U({progress:z(),total:Y(z()),message:Y(L())}),ne=U({...p.shape,...S.shape,progressToken:n}),re=m.extend({method:J(`notifications/progress`),params:ne}),ie=p.extend({level:o,logger:L().optional(),data:V()}),ae=m.extend({method:J(`notifications/message`),params:ie}),oe=U({uri:L(),mimeType:Y(L()),_meta:K(L(),V()).optional()}),C=oe.extend({text:L()}),w=oe.extend({blob:s}),se=U({audience:H(a).optional(),priority:z().min(0).max(1).optional(),lastModified:Eu({offset:!0}).optional()}),ce=U({..._.shape,...g.shape,uri:L(),description:Y(L()),mimeType:Y(L()),size:Y(z()),annotations:se.optional(),_meta:Y(W({}))}),le=U({..._.shape,...g.shape,uriTemplate:L(),description:Y(L()),mimeType:Y(L()),annotations:se.optional(),_meta:Y(W({}))}),ue=m.extend({method:J(`notifications/resources/list_changed`),params:p.optional()}),de=p.extend({uri:L()}),T=m.extend({method:J(`notifications/resources/updated`),params:de}),fe=U({name:L(),description:Y(L()),required:Y(B())}),pe=U({..._.shape,...g.shape,description:Y(L()),arguments:Y(H(fe)),_meta:Y(W({}))}),me=m.extend({method:J(`notifications/prompts/list_changed`),params:p.optional()}),E=U({type:J(`text`),text:L(),annotations:se.optional(),_meta:K(L(),V()).optional()}),he=U({type:J(`image`),data:s,mimeType:L(),annotations:se.optional(),_meta:K(L(),V()).optional()}),ge=U({type:J(`audio`),data:s,mimeType:L(),annotations:se.optional(),_meta:K(L(),V()).optional()}),_e=U({type:J(`tool_use`),name:L(),id:L(),input:K(L(),V()),_meta:K(L(),V()).optional()}),ve=U({type:J(`resource`),resource:G([C,w]),annotations:se.optional(),_meta:K(L(),V()).optional()}),ye=ce.extend({type:J(`resource_link`)}),be=G([E,he,ge,ye,ve]),xe=U({role:a,content:be}),Se=U({title:L().optional(),readOnlyHint:B().optional(),destructiveHint:B().optional(),idempotentHint:B().optional(),openWorldHint:B().optional()}),Ce=m.extend({method:J(`notifications/tools/list_changed`),params:p.optional()}),we=U({name:L().optional()}),Te=U({hints:H(we).optional(),costPriority:z().min(0).max(1).optional(),speedPriority:z().min(0).max(1).optional(),intelligencePriority:z().min(0).max(1).optional()}),Ee=U({mode:q([`auto`,`required`,`none`]).optional()}),De=U({type:J(`boolean`),title:L().optional(),description:L().optional(),default:B().optional()}),Oe=U({type:J(`string`),title:L().optional(),description:L().optional(),minLength:z().optional(),maxLength:z().optional(),format:q([`email`,`uri`,`date`,`date-time`]).optional(),default:L().optional()}),D=U({type:q([`number`,`integer`]),title:L().optional(),description:L().optional(),minimum:z().optional(),maximum:z().optional(),default:z().optional()}),ke=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),default:L().optional()}),Ae=U({type:J(`string`),title:L().optional(),description:L().optional(),oneOf:H(U({const:L(),title:L()})),default:L().optional()}),je=U({type:J(`string`),title:L().optional(),description:L().optional(),enum:H(L()),enumNames:H(L()).optional(),default:L().optional()}),Me=G([ke,Ae]),O=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({type:J(`string`),enum:H(L())}),default:H(L()).optional()}),Ne=U({type:J(`array`),title:L().optional(),description:L().optional(),minItems:z().optional(),maxItems:z().optional(),items:U({anyOf:H(U({const:L(),title:L()}))}),default:H(L()).optional()}),Pe=G([O,Ne]),Fe=G([je,Me,Pe]),Ie=G([Fe,De,Oe,D]),Le=f.extend({mode:J(`form`).optional(),message:L(),requestedSchema:U({type:J(`object`),properties:K(L(),Ie),required:H(L()).optional()}).catchall(V())}),Re=U({type:J(`ref/resource`),uri:L()}),ze=U({type:J(`ref/prompt`),name:L()}),Be=U({uri:L().startsWith(`file://`),name:L().optional(),_meta:K(L(),V()).optional()}),Ve=te.shape,He=U({experimental:Ve.experimental,sampling:Ve.sampling,elicitation:Ve.elicitation,roots:Ve.roots,extensions:Ve.extensions}),Ue=x.shape,We=U({experimental:Ue.experimental,logging:Ue.logging,completions:Ue.completions,prompts:Ue.prompts,resources:Ue.resources,tools:Ue.tools,extensions:Ue.extensions}),Ge=W({progressToken:n.optional(),[ju]:L(),[Mu]:v.optional(),[Pu]:He,[Iu]:o.optional()}),Ke=U({..._.shape,...g.shape,description:L().optional(),inputSchema:W({$schema:L().optional(),type:J(`object`)}),outputSchema:W({$schema:L().optional()}).optional(),annotations:Se.optional(),_meta:K(L(),V()).optional()}),qe=U({type:J(`tool_result`),toolUseId:L(),content:H(be),structuredContent:V().optional(),isError:B().optional(),_meta:K(L(),V()).optional()}),Je=G([E,he,ge,_e,qe]),Ye=U({role:a,content:G([Je,H(Je)]),_meta:K(L(),V()).optional()}),Xe=L(),Ze=W({[Nu]:v.optional().catch(void 0)}),Qe=Ze.optional();function $e(e){return W({_meta:Qe,resultType:Xe.default(`complete`),...e})}let et=$e({}),tt=$e({nextCursor:r.optional()}),nt=$e({content:H(be),structuredContent:V().optional(),isError:B().optional()}),rt=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),tools:H(Ke),nextCursor:r.optional()}),it=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),prompts:H(pe),nextCursor:r.optional()}),at=$e({description:L().optional(),messages:H(xe)}),ot=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),resources:H(ce),nextCursor:r.optional()}),st=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),resourceTemplates:H(le),nextCursor:r.optional()}),ct=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),contents:H(G([C,w]))}),lt=$e({completion:U({values:H(L()).max(100),total:z().int().optional(),hasMore:B().optional()}).loose()}),ut=$e({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`])}),dt=$e({ttlMs:z().int().min(0).catch(0),cacheScope:q([`public`,`private`]).catch(`private`),supportedVersions:H(L()),capabilities:We,instructions:L().optional()}),ft=U({messages:H(Ye),modelPreferences:Te.optional(),systemPrompt:L().optional(),includeContext:q([`none`,`thisServer`,`allServers`]).optional(),temperature:z().optional(),maxTokens:z().int(),stopSequences:H(L()).optional(),metadata:t.optional(),tools:H(Ke).optional(),toolChoice:Ee.optional()}),pt=U({method:J(`sampling/createMessage`),params:ft}),mt=U({method:J(`roots/list`),params:U({_meta:K(L(),V()).optional()}).optional()}),ht=U({...Ye.shape,model:L(),stopReason:L().optional()}),gt=U({roots:H(Be)}),_t=U({action:q([`accept`,`decline`,`cancel`]),content:K(L(),G([L(),z(),B(),H(L())])).optional()}),vt=U({mode:J(`url`),message:L(),url:L().url()}),yt=G([Le,vt]),bt=U({method:J(`elicitation/create`),params:yt}),xt=G([pt,mt,bt]),St=G([ht,gt,_t]),Ct=K(L(),xt),wt=K(L(),St),Tt=$e({inputRequests:Ct.optional(),requestState:L().optional()}),Et={inputResponses:wt.optional(),requestState:L().optional()},Dt=U({_meta:Ge,...Et}),Ot=W({progressToken:n.optional()});function kt(e,t){return U({method:J(e),params:U({_meta:Ge,...t})})}function At(e,t){return U({method:J(e),params:U({_meta:Ot.optional(),...t}).optional()})}let jt={name:L(),arguments:K(L(),V()).optional(),...Et},Mt={cursor:r.optional()},Nt=kt(`tools/call`,jt),Pt=kt(`tools/list`,Mt),Ft=kt(`prompts/list`,Mt),k=kt(`prompts/get`,{name:L(),arguments:K(L(),L()).optional(),...Et}),It=kt(`resources/list`,Mt),Lt=kt(`resources/templates/list`,Mt),Rt=kt(`resources/read`,{uri:L(),...Et}),zt={ref:G([ze,Re]),argument:U({name:L(),value:L()}),context:U({arguments:K(L(),L()).optional()}).optional()},Bt=kt(`completion/complete`,zt),Vt=kt(`server/discover`,{}),Ht=U({toolsListChanged:B().optional(),promptsListChanged:B().optional(),resourcesListChanged:B().optional(),resourceSubscriptions:H(L()).optional()}),Ut={notifications:Ht},Wt=kt(`subscriptions/listen`,Ut),Gt=Ze.extend({"io.modelcontextprotocol/subscriptionId":i}),Kt=W({_meta:Gt,resultType:Xe.default(`complete`)}),qt={"tools/call":At(`tools/call`,jt),"tools/list":At(`tools/list`,Mt),"prompts/get":At(`prompts/get`,{name:L(),arguments:K(L(),L()).optional()}),"prompts/list":At(`prompts/list`,Mt),"resources/list":At(`resources/list`,Mt),"resources/templates/list":At(`resources/templates/list`,Mt),"resources/read":At(`resources/read`,{uri:L()}),"completion/complete":At(`completion/complete`,zt),"server/discover":At(`server/discover`,{}),"subscriptions/listen":At(`subscriptions/listen`,Ut)};function Jt(e){return W({_meta:Qe,...e})}let Yt={"tools/call":Jt({content:H(be),structuredContent:V().optional(),isError:B().optional()}),"tools/list":Jt({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),tools:H(Ke),nextCursor:r.optional()}),"prompts/get":Jt({description:L().optional(),messages:H(xe)}),"prompts/list":Jt({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),prompts:H(pe),nextCursor:r.optional()}),"resources/list":Jt({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),resources:H(ce),nextCursor:r.optional()}),"resources/templates/list":Jt({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),resourceTemplates:H(le),nextCursor:r.optional()}),"resources/read":Jt({ttlMs:z().int().min(0),cacheScope:q([`public`,`private`]),contents:H(G([C,w]))}),"completion/complete":Jt({completion:U({values:H(L()).max(100),total:z().int().optional(),hasMore:B().optional()}).loose()}),"server/discover":Jt({ttlMs:z().int().min(0).catch(0),cacheScope:q([`public`,`private`]).catch(`private`),supportedVersions:H(L()),capabilities:We,instructions:L().optional()}),"subscriptions/listen":Jt({})},Xt=W({"io.modelcontextprotocol/subscriptionId":i.optional()}),Zt=U({method:J(`notifications/subscriptions/acknowledged`),params:U({_meta:Xt.optional(),notifications:Ht})}),Qt=U({_meta:Xt.optional(),requestId:i,reason:L().optional()}),$t=U({method:J(`notifications/cancelled`),params:Qt}),en={"notifications/cancelled":$t,"notifications/progress":re,"notifications/message":ae,"notifications/resources/updated":T,"notifications/resources/list_changed":ue,"notifications/tools/list_changed":Ce,"notifications/prompts/list_changed":me,"notifications/subscriptions/acknowledged":Zt},A=e=>U({jsonrpc:J(`2.0`),id:G([L(),z().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:m,IconSchema:h,IconsSchema:g,BaseMetadataSchema:_,ImplementationSchema:v,ClientTasksCapabilitySchema:b,ServerTasksCapabilitySchema:ee,ClientCapabilitiesSchema:te,ServerCapabilitiesSchema:x,ProgressSchema:S,ProgressNotificationParamsSchema:ne,ProgressNotificationSchema:re,LoggingMessageNotificationParamsSchema:ie,LoggingMessageNotificationSchema:ae,ResourceContentsSchema:oe,TextResourceContentsSchema:C,BlobResourceContentsSchema:w,AnnotationsSchema:se,ResourceSchema:ce,ResourceTemplateSchema:le,ResourceListChangedNotificationSchema:ue,ResourceUpdatedNotificationParamsSchema:de,ResourceUpdatedNotificationSchema:T,PromptArgumentSchema:fe,PromptSchema:pe,PromptListChangedNotificationSchema:me,TextContentSchema:E,ImageContentSchema:he,AudioContentSchema:ge,ToolUseContentSchema:_e,EmbeddedResourceSchema:ve,ResourceLinkSchema:ye,ContentBlockSchema:be,PromptMessageSchema:xe,ToolAnnotationsSchema:Se,ToolListChangedNotificationSchema:Ce,ModelHintSchema:we,ModelPreferencesSchema:Te,ToolChoiceSchema:Ee,BooleanSchemaSchema:De,StringSchemaSchema:Oe,NumberSchemaSchema:D,UntitledSingleSelectEnumSchemaSchema:ke,TitledSingleSelectEnumSchemaSchema:Ae,LegacyTitledEnumSchemaSchema:je,SingleSelectEnumSchemaSchema:Me,UntitledMultiSelectEnumSchemaSchema:O,TitledMultiSelectEnumSchemaSchema:Ne,MultiSelectEnumSchemaSchema:Pe,EnumSchemaSchema:Fe,PrimitiveSchemaDefinitionSchema:Ie,ElicitRequestFormParamsSchema:Le,ResourceTemplateReferenceSchema:Re,PromptReferenceSchema:ze,RootSchema:Be,ClientCapabilities2026Schema:He,ServerCapabilities2026Schema:We,RequestMetaEnvelopeSchema:Ge,ToolSchema:Ke,ToolResultContentSchema:qe,SamplingMessageContentBlockSchema:Je,SamplingMessageSchema:Ye,ResultTypeSchema:Xe,ResultMetaSchema:Ze,ResultSchema:et,PaginatedResultSchema:tt,CallToolResultSchema:nt,ListToolsResultSchema:rt,ListPromptsResultSchema:it,GetPromptResultSchema:at,ListResourcesResultSchema:ot,ListResourceTemplatesResultSchema:st,ReadResourceResultSchema:ct,CompleteResultSchema:lt,CacheableResultSchema:ut,DiscoverResultSchema:dt,CreateMessageRequestParamsSchema:ft,CreateMessageRequestSchema:pt,ListRootsRequestSchema:mt,CreateMessageResultSchema:ht,ListRootsResultSchema:gt,ElicitResultSchema:_t,ElicitRequestURLParamsSchema:vt,ElicitRequestParamsSchema:yt,ElicitRequestSchema:bt,InputRequestSchema:xt,InputResponseSchema:St,InputRequestsSchema:Ct,InputResponsesSchema:wt,InputRequiredResultSchema:Tt,InputResponseRequestParamsSchema:Dt,CallToolRequestSchema:Nt,ListToolsRequestSchema:Pt,ListPromptsRequestSchema:Ft,GetPromptRequestSchema:k,ListResourcesRequestSchema:It,ListResourceTemplatesRequestSchema:Lt,ReadResourceRequestSchema:Rt,CompleteRequestSchema:Bt,DiscoverRequestSchema:Vt,SubscriptionFilterSchema:Ht,SubscriptionsListenRequestSchema:Wt,SubscriptionsListenResultMetaSchema:Gt,SubscriptionsListenResultSchema:Kt,dispatchRequestSchemas:qt,dispatchResultSchemas:Yt,NotificationMetaSchema:Xt,SubscriptionsAcknowledgedNotificationSchema:Zt,CancelledNotificationParamsSchema:Qt,CancelledNotificationSchema:$t,notificationSchemas2026:en,JSONRPCResultResponseSchema:A(et),CallToolResultResponseSchema:A(G([nt,Tt])),ListToolsResultResponseSchema:A(rt),ListPromptsResultResponseSchema:A(it),GetPromptResultResponseSchema:A(G([at,Tt])),ListResourcesResultResponseSchema:A(ot),ListResourceTemplatesResultResponseSchema:A(st),ReadResourceResultResponseSchema:A(G([ct,Tt])),CompleteResultResponseSchema:A(lt),DiscoverResultResponseSchema:A(dt),SubscriptionsListenResultResponseSchema:A(Kt)}}var Lm;function Rm(){return Lm??=Im()}var zm=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Bm(e){return zm.includes(e)}var Vm=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Hm(e){return e[Vm]}function Um(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function Wm(e){return e===`public`||e===`private`}var $=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Gm=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,nm(this,new.target)}static fromError(t,n,r){if(t===$.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new qm(e.elicitations,n)}if(t===$.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Jm({supported:e.supported,requested:e.requested},n)}if(t===$.InvalidParams||t===$.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===$.ResourceNotFound||Object.keys(e).length===1))return new Km(e.uri,n)}if(t===$.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Ym({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Km=class extends Gm{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super($.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},qm=class extends Gm{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super($.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Jm=class extends Gm{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super($.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Ym=class extends Gm{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super($.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Xm=0,Zm=`private`,Qm=[`tools/call`,`prompts/get`,`resources/read`];function $m(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||Qm.includes(e))return t;throw new Gm($.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function eh(e,t){let n=Hm(t);if(t.resultType!==`complete`||!Bm(e))return n===void 0?t:ah(t);let r=t,i=Um(r.ttlMs)?r.ttlMs:rh(n),a=Wm(r.cacheScope)?r.cacheScope:ih(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Vm],o}function th(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nh(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Nu]:t}}:!th(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Nu]:t}}}function rh(e){return e!==void 0&&Um(e.ttlMs)?e.ttlMs:Xm}function ih(e){return e!==void 0&&Wm(e.cacheScope)?e.cacheScope:Zm}function ah(e){let t={...e};return delete t[Vm],t}var oh=[`elicitation/create`,`sampling/createMessage`,`roots/list`],sh;function ch(){if(sh)return sh;let e=Rm();return sh={request:{"elicitation/create":U({method:J(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":U({method:J(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":U({method:J(`roots/list`),params:W({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},sh}function lh(e){return oh.includes(e)}function uh(e){return lh(e)?ch().request[e]:void 0}function dh(e){return lh(e)?ch().response[e]:void 0}var fh={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},ph={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function mh(e){return Object.prototype.hasOwnProperty.call(fh,e)}function hh(e){return Object.prototype.hasOwnProperty.call(ph,e)}function gh(e){return Object.prototype.hasOwnProperty.call(fh,e)}function _h(e){return mh(e)?Rm().dispatchRequestSchemas[e]:void 0}function vh(e){return gh(e)?Rm().dispatchResultSchemas[e]:void 0}function yh(e){return hh(e)?Rm().notificationSchemas2026[e]:void 0}Object.keys(fh),Object.keys(ph);function bh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xh(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Sh={ok:!1,reason:`not-in-era`},Ch=[ju,Pu];function wh(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>bh(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!bh(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(bh(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Th={era:`2026-07-28`,hasRequestMethod:mh,hasNotificationMethod:hh,hasInputRequestMethod:e=>uh(e)!==void 0,validateRequest:(e,t)=>xh(_h(e),t),validateResult:(e,t)=>xh(vh(e),t),validateNotification:(e,t)=>xh(yh(e),t),validateInputRequest:(e,t)=>xh(uh(e),t),validateInputResponse:(e,t)=>xh(dh(e),t),samplingResultVariant:()=>Sh,outboundEnvelope(e){return{[ju]:e.protocolVersion,[Mu]:e.clientInfo,[Pu]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Ch)n in e||t.push({key:n,problem:`missing`});let n=Rm().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>cm(e),inputRequestSchema:uh,decodeResult(e,t){if(!bh(t))return{kind:`invalid`,error:new am(im.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new am(im.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new am(im.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=bh(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:Rm().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new am(im.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new am(im.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=Dh(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new am(im.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return nh(eh(e,$m(e,wh(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=Rm().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Eh;function Dh(){if(Eh)return Eh;let e=Rm();return Eh={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Eh}var Oh=`2026-07-28`;function kh(e){return e!==void 0&&sm(e)?Th:Fm}function Ah(e){return e.revision===void 0?e.era===`modern`?Th.era:Fm.era:kh(e.revision).era}function jh(e){return Ph.some(t=>t.hasRequestMethod(e))}function Mh(e){return Ph.some(t=>t.hasNotificationMethod(e))}function Nh(e){return e===`tasks/get`||e===`tasks/cancel`}var Ph=[Fm,Th],Fh=at({AnnotationsSchema:()=>Md,AudioContentSchema:()=>ff,BaseMetadataSchema:()=>sd,BaseRequestParamsSchema:()=>Wu,BlobResourceContentsSchema:()=>Ad,BooleanSchemaSchema:()=>qf,CallToolRequestParamsSchema:()=>Df,CallToolRequestSchema:()=>Of,CallToolResultSchema:()=>Tf,CancelTaskRequestSchema:()=>Np,CancelTaskResultSchema:()=>Pp,CancelledNotificationParamsSchema:()=>rd,CancelledNotificationSchema:()=>id,ClientCapabilitiesSchema:()=>fd,ClientNotificationSchema:()=>Ip,ClientRequestSchema:()=>Fp,ClientResultSchema:()=>Lp,ClientTasksCapabilitySchema:()=>ud,CompatibilityCallToolResultSchema:()=>Ef,CompleteRequestParamsSchema:()=>mp,CompleteRequestSchema:()=>hp,CompleteResultSchema:()=>gp,ContentBlockSchema:()=>gf,CreateMessageRequestParamsSchema:()=>Uf,CreateMessageRequestSchema:()=>Wf,CreateMessageResultSchema:()=>Gf,CreateMessageResultWithToolsSchema:()=>Kf,CreateTaskResultSchema:()=>wp,CursorSchema:()=>Bu,DiscoverRequestSchema:()=>vd,DiscoverResultSchema:()=>yd,ElicitRequestFormParamsSchema:()=>ap,ElicitRequestParamsSchema:()=>sp,ElicitRequestSchema:()=>cp,ElicitRequestURLParamsSchema:()=>op,ElicitResultSchema:()=>dp,ElicitationCompleteNotificationParamsSchema:()=>lp,ElicitationCompleteNotificationSchema:()=>up,EmbeddedResourceSchema:()=>mf,EmptyResultSchema:()=>nd,EnumSchemaSchema:()=>rp,GetPromptRequestParamsSchema:()=>cf,GetPromptRequestSchema:()=>lf,GetPromptResultSchema:()=>vf,GetTaskPayloadRequestSchema:()=>kp,GetTaskPayloadResultSchema:()=>Ap,GetTaskRequestSchema:()=>Dp,GetTaskResultSchema:()=>Op,IconSchema:()=>ad,IconsSchema:()=>od,ImageContentSchema:()=>df,ImplementationSchema:()=>cd,InitializeRequestParamsSchema:()=>pd,InitializeRequestSchema:()=>md,InitializeResultSchema:()=>gd,InitializedNotificationSchema:()=>_d,JSONArraySchema:()=>Ru,JSONObjectSchema:()=>X,JSONRPCErrorResponseSchema:()=>$u,JSONRPCMessageSchema:()=>ed,JSONRPCNotificationSchema:()=>Zu,JSONRPCRequestSchema:()=>Xu,JSONRPCResponseSchema:()=>td,JSONRPCResultResponseSchema:()=>Qu,JSONValueSchema:()=>Lu,LegacyTitledEnumSchemaSchema:()=>Qf,ListChangedOptionsBaseSchema:()=>Af,ListPromptsRequestSchema:()=>of,ListPromptsResultSchema:()=>sf,ListResourceTemplatesRequestSchema:()=>Ld,ListResourceTemplatesResultSchema:()=>Rd,ListResourcesRequestSchema:()=>Fd,ListResourcesResultSchema:()=>Id,ListRootsRequestSchema:()=>vp,ListRootsResultSchema:()=>yp,ListTasksRequestSchema:()=>jp,ListTasksResultSchema:()=>Mp,ListToolsRequestSchema:()=>Cf,ListToolsResultSchema:()=>wf,LoggingLevelSchema:()=>jf,LoggingMessageNotificationParamsSchema:()=>Pf,LoggingMessageNotificationSchema:()=>Ff,ModelHintSchema:()=>If,ModelPreferencesSchema:()=>Lf,MultiSelectEnumSchemaSchema:()=>np,NotificationSchema:()=>qu,NotificationsParamsSchema:()=>Ku,NumberSchemaSchema:()=>Yf,PaginatedRequestParamsSchema:()=>wd,PaginatedRequestSchema:()=>Td,PaginatedResultSchema:()=>Ed,PingRequestSchema:()=>bd,PrimitiveSchemaDefinitionSchema:()=>ip,ProgressNotificationParamsSchema:()=>Sd,ProgressNotificationSchema:()=>Cd,ProgressSchema:()=>xd,ProgressTokenSchema:()=>zu,PromptArgumentSchema:()=>rf,PromptListChangedNotificationSchema:()=>yf,PromptMessageSchema:()=>_f,PromptReferenceSchema:()=>pp,PromptSchema:()=>af,ReadResourceRequestParamsSchema:()=>Bd,ReadResourceRequestSchema:()=>Vd,ReadResourceResultSchema:()=>Hd,RelatedTaskMetadataSchema:()=>Hu,RequestIdSchema:()=>Yu,RequestMetaSchema:()=>Uu,RequestSchema:()=>Z,ResourceContentsSchema:()=>Dd,ResourceLinkSchema:()=>hf,ResourceListChangedNotificationSchema:()=>Ud,ResourceRequestParamsSchema:()=>zd,ResourceSchema:()=>Nd,ResourceTemplateReferenceSchema:()=>fp,ResourceTemplateSchema:()=>Pd,ResourceUpdatedNotificationParamsSchema:()=>tf,ResourceUpdatedNotificationSchema:()=>nf,ResultMetaObjectSchema:()=>Ju,ResultSchema:()=>Q,RoleSchema:()=>jd,RootSchema:()=>_p,RootsListChangedNotificationSchema:()=>bp,SamplingContentSchema:()=>Bf,SamplingMessageContentBlockSchema:()=>Vf,SamplingMessageSchema:()=>Hf,ServerCapabilitiesSchema:()=>hd,ServerNotificationSchema:()=>zp,ServerRequestSchema:()=>Rp,ServerResultSchema:()=>Bp,ServerTasksCapabilitySchema:()=>dd,SetLevelRequestParamsSchema:()=>Mf,SetLevelRequestSchema:()=>Nf,SingleSelectEnumSchemaSchema:()=>$f,StringSchemaSchema:()=>Jf,SubscribeRequestParamsSchema:()=>Wd,SubscribeRequestSchema:()=>Gd,SubscriptionFilterSchema:()=>Jd,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Zd,SubscriptionsAcknowledgedNotificationSchema:()=>Qd,SubscriptionsListenRequestParamsSchema:()=>Yd,SubscriptionsListenRequestSchema:()=>Xd,SubscriptionsListenResultMetaSchema:()=>$d,SubscriptionsListenResultSchema:()=>ef,TaskAugmentedRequestParamsSchema:()=>Gu,TaskCreationParamsSchema:()=>xp,TaskMetadataSchema:()=>Vu,TaskSchema:()=>Cp,TaskStatusNotificationParamsSchema:()=>Tp,TaskStatusNotificationSchema:()=>Ep,TaskStatusSchema:()=>Sp,TextContentSchema:()=>uf,TextResourceContentsSchema:()=>Od,TitledMultiSelectEnumSchemaSchema:()=>tp,TitledSingleSelectEnumSchemaSchema:()=>Zf,ToolAnnotationsSchema:()=>bf,ToolChoiceSchema:()=>Rf,ToolExecutionSchema:()=>xf,ToolListChangedNotificationSchema:()=>kf,ToolResultContentSchema:()=>zf,ToolSchema:()=>Sf,ToolUseContentSchema:()=>pf,UnsubscribeRequestParamsSchema:()=>Kd,UnsubscribeRequestSchema:()=>qd,UntitledMultiSelectEnumSchemaSchema:()=>ep,UntitledSingleSelectEnumSchemaSchema:()=>Xf}),Ih=e=>Xu.safeParse(e).success,Lh=e=>Zu.safeParse(e).success,Rh=e=>Qu.safeParse(e).success,zh=e=>$u.safeParse(e).success;$.InvalidRequest,$.UnsupportedProtocolVersion,$.InvalidParams,$.MethodNotFound,$.InvalidParams,$.MissingRequiredClientCapability,$.ParseError,$.InvalidRequest,$.MethodNotFound,$.UnsupportedProtocolVersion,$.MissingRequiredClientCapability;function Bh(e,t){return Wc(e,t)}function Vh(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function Hh(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var Uh=!1,Wh=`draft-2020-12`;function Gh(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:Wh});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);Uh||(Uh=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=Rc(e,{target:Wh,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&Kh(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function Kh(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||Kh(e)))}return!1}function qh(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function Jh(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>qh(e)).join(`, `)}:{success:!0,data:n.value}}function Yh(e){let t=Rc(e,{target:Wh,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var Xh=/\\\.\\d\{(\d+)\}/;function Zh(e){let t=Xh.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>Eu({local:e,offset:t,precision:n}))))}function Qh(e,t){let n;switch(e){case`email`:n=[ll()];break;case`uri`:n=[pl()];break;case`date`:n=[Du()];break;case`date-time`:n=Zh(t)}return new Set(n.map(e=>Yh(e)).filter(e=>e!==void 0))}function $h(e,t,n){return n!==`zod`||Qh(e,t).has(t)}function eg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tg(e){try{return Gh(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Gm($.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var ng=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function rg(e){return ng.has(e)||e.startsWith(`x-`)}var ig=new Set([`$schema`,...Object.keys(ap.shape.requestedSchema.shape)]),ag={string:Vh([Jf,Xf,Zf,Qf]),number:Vh([Yf]),integer:Vh([Yf]),boolean:Vh([qf]),array:Vh([ep,tp])},og=new Set(Jf.shape.format.unwrap().options);function sg(e,t,n,r){if(!eg(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(ag,e.type)?ag[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||rg(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?og.has(e.format)?(typeof s!=`string`||!$h(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function cg(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&eg(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,sg(n,`properties.${e}`,t,r)])):ig.has(i)?n[i]=a:rg(i)||r.push(i);if(r.length>0)throw new Gm($.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function lg(e,t){if(!eg(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!Bh(ip,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function ug(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>ug(e,t[r],`${n}[${r}]`)):!eg(e)||!eg(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?ug(r,t[e],i):rg(e)?[]:[i]})}function dg(e){if(!Hh(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=cg(tg(e.requestedSchema),t),r=Bh(ap.shape.requestedSchema,n);if(!r.success)throw new Gm($.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${lg(n,r.error.message)}`);let i=ug(n,r.data);if(i.length>0)throw new Gm($.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Gm($.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function fg(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(fg,{elicit(e){try{return{method:`elicitation/create`,params:dg(e)}}catch(e){throw e instanceof Gm?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var pg=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),mg={IdJagTokenExchangeResponseSchema:qp,OAuthClientInformationFullSchema:Qp,OAuthClientInformationSchema:Zp,OAuthClientMetadataSchema:Xp,OAuthClientRegistrationErrorSchema:$p,OAuthErrorResponseSchema:Jp,OAuthMetadataSchema:Up,OAuthProtectedResourceMetadataSchema:Hp,OAuthTokenRevocationRequestSchema:em,OAuthTokensSchema:Kp,OpenIdProviderDiscoveryMetadataSchema:Gp,OpenIdProviderMetadataSchema:Wp},hg={},gg={};function _g(e,t){let n=e.slice(0,-6);hg[n]=t,gg[n]=e=>t.safeParse(e).success}for(let e of pg)_g(e,Fh[e]);for(let[e,t]of Object.entries(mg))_g(e,t);Object.freeze(hg),Object.freeze(gg);function vg(e){switch(e){case`initialize`:case`notifications/initialized`:return kh(void 0);case`server/discover`:return kh(Oh);default:return}}var yg=[ju,Mu,Pu,Iu],bg=[`inputResponses`,`requestState`];function xg(e,t){let n=e.params;if(!Eg(n))return{message:e,lifted:{}};let r=n._meta,i=Eg(r)?yg.filter(e=>e in r):[],a=t===`request`?bg.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&Eg(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function Sg(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function Cg(e){return()=>e}var wg=Cg(void 0),Tg=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??ku,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new am(im.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new am(im.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Rh(e)||zh(e)?this._onresponse(e):Ih(e)?this._onrequest(e,t):Lh(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new am(im.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=xg(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Ah(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(Mh(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=xg(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=Ah(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o($.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(jh(n.method)&&!i.hasRequestMethod(n.method)&&!(Nh(n.method)&&this._customSchemaRequestMethods.has(n.method))){o($.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o($.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o($.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:Og(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?wg:Cg(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),Hh(t))return u(e,t,n);let i=Sg(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o($.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:$.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);n===void 0?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Rh(e)?n(e):n(Gm.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(Hh(t))return Nh(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=Sg(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return kh(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=vg(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(jh(t)&&!e.hasRequestMethod(t))throw new am(im.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof am?e:new am(im.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof am?e:new am(im.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(kg(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;Jh(n,o).then(e=>{e.success?d(e.data):f(new am(im.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new am(im.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new am(im.NotConnected,`Not connected`);if(Mh(t.method)&&!e.hasNotificationMethod(t.method))throw new am(im.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))})}else await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!jh(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Gm($.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await Jh(t.params,{...r.params});if(!a.success)throw new Gm($.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Mh(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Gm($.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))})}else{if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await Jh(t.params,{...r.params});if(!i.success)throw new Gm($.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Eg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Dg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Og(e){let t={},n=[];if(!Dg(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e))!Dg(i)||`method`in i||`result`in i?n.push(r):t[r]=i;return{accepted:t,droppedKeys:n}}function kg(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}it((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);var Ag=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,jg=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Mg=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Ng=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Pg=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Fg=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Ig=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Lg=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Rg=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,zg=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Bg=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;function Vg(e){return e.test.bind(e)}Hg.bind(void 0,!1),Vg(Mg),Vg(Ng),Vg(Pg),Vg(jg),Vg(zg),Vg(Bg),Vg(Fg),Vg(Ig),Vg(Lg),Vg(Rg);function Hg(e,t){let n=t.match(Ag);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}globalThis.crypto;var Ug=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthClientFlowError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e){super(e),this.name=new.target.name,nm(this,new.target)}};(class extends Ug{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.IssuerMismatchError`})}kind;expected;received;constructor(e,t,n){super(`Issuer mismatch in ${e===`metadata`?`authorization server metadata (RFC 8414 §3.3)`:`authorization response (RFC 9207)`}: expected ${JSON.stringify(t)}, received ${JSON.stringify(n)}`),this.kind=e,this.expected=t,this.received=n}}),class extends Ug{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.RegistrationRejectedError`})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},class extends Ug{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.InsecureTokenEndpointError`})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},class extends Ug{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.AuthorizationServerMismatchError`})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`),this.recordedIssuer=e,this.currentIssuer=t}},class extends Ug{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.InsufficientScopeError`})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:``}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}},class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnauthorizedError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e){super(e??`Unauthorized`),this.name=`UnauthorizedError`,nm(this,new.target)}},class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SseError`})}static[Symbol.hasInstance](e){return rm(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return rm(this,e)}constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n,nm(this,new.target)}};var Wg=class{_eventSlots=new Map;setHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}dispatch(e,t){let n=this._eventSlots.get(e);if(n){n.onHandler?.(t);for(let e of[...n.listeners])e(t)}}_ensureEventSlot(e){let t=this._eventSlots.get(e);return t||(t={listeners:[]},this._eventSlots.set(e,t)),t}},Gg=class{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}},Kg=new Set;function qg(e,t){let[n,r]=t,i=n?.shape;if(typeof i?.method?.value!=`string`)return;let a=i.method.value,o=e===`request`?`setRequestHandler`:`setNotificationHandler`;Kg.has(o)||(Kg.add(o),console.warn(`[ext-apps] ${o}(Schema, handler) is deprecated; use ${o}("${a}", { params: Schema.shape.params }, handler).`));let s=r;return[a,{params:i.params},e===`request`?(e,t)=>s({method:a,params:e},Jg(t)):e=>s({method:a,params:e})]}function Jg(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var Yg=`2026-01-26`,Xg=G([J(`light`),J(`dark`)]).describe(`Color theme preference for the host environment.`),Zg=G([J(`inline`),J(`fullscreen`),J(`pip`)]).describe(`Display mode for UI presentation.`),Qg=K(G([J(`--color-background-primary`),J(`--color-background-secondary`),J(`--color-background-tertiary`),J(`--color-background-inverse`),J(`--color-background-ghost`),J(`--color-background-info`),J(`--color-background-danger`),J(`--color-background-success`),J(`--color-background-warning`),J(`--color-background-disabled`),J(`--color-text-primary`),J(`--color-text-secondary`),J(`--color-text-tertiary`),J(`--color-text-inverse`),J(`--color-text-ghost`),J(`--color-text-info`),J(`--color-text-danger`),J(`--color-text-success`),J(`--color-text-warning`),J(`--color-text-disabled`),J(`--color-border-primary`),J(`--color-border-secondary`),J(`--color-border-tertiary`),J(`--color-border-inverse`),J(`--color-border-ghost`),J(`--color-border-info`),J(`--color-border-danger`),J(`--color-border-success`),J(`--color-border-warning`),J(`--color-border-disabled`),J(`--color-ring-primary`),J(`--color-ring-secondary`),J(`--color-ring-inverse`),J(`--color-ring-info`),J(`--color-ring-danger`),J(`--color-ring-success`),J(`--color-ring-warning`),J(`--font-sans`),J(`--font-mono`),J(`--font-weight-normal`),J(`--font-weight-medium`),J(`--font-weight-semibold`),J(`--font-weight-bold`),J(`--font-text-xs-size`),J(`--font-text-sm-size`),J(`--font-text-md-size`),J(`--font-text-lg-size`),J(`--font-heading-xs-size`),J(`--font-heading-sm-size`),J(`--font-heading-md-size`),J(`--font-heading-lg-size`),J(`--font-heading-xl-size`),J(`--font-heading-2xl-size`),J(`--font-heading-3xl-size`),J(`--font-text-xs-line-height`),J(`--font-text-sm-line-height`),J(`--font-text-md-line-height`),J(`--font-text-lg-line-height`),J(`--font-heading-xs-line-height`),J(`--font-heading-sm-line-height`),J(`--font-heading-md-line-height`),J(`--font-heading-lg-line-height`),J(`--font-heading-xl-line-height`),J(`--font-heading-2xl-line-height`),J(`--font-heading-3xl-line-height`),J(`--border-radius-xs`),J(`--border-radius-sm`),J(`--border-radius-md`),J(`--border-radius-lg`),J(`--border-radius-xl`),J(`--border-radius-full`),J(`--border-width-regular`),J(`--shadow-hairline`),J(`--shadow-sm`),J(`--shadow-md`),J(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
56
+
57
+ Individual style keys are optional - hosts may provide any subset of these values.
58
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
59
+
60
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
61
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),G([L(),Pl()]).describe(`Style variables for theming MCP apps.
62
+
63
+ Individual style keys are optional - hosts may provide any subset of these values.
64
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
65
+
66
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
67
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
68
+
69
+ Individual style keys are optional - hosts may provide any subset of these values.
70
+ Values are strings containing CSS values (colors, sizes, font stacks, etc.).
71
+
72
+ Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
73
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),$g=U({method:J(`ui/open-link`),params:U({url:L().describe(`URL to open in the host's browser`)})}),e_=U({isError:B().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),t_=U({isError:B().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),n_=U({isError:B().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough(),r_=U({method:J(`ui/notifications/sandbox-proxy-ready`),params:U({})}),i_=U({connectDomains:H(L()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
74
+
75
+ - Maps to CSP \`connect-src\` directive
76
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:H(L()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:H(L()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:H(L()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),a_=U({camera:U({}).optional().describe(`Request camera access.
77
+
78
+ Maps to Permission Policy \`camera\` feature.`),microphone:U({}).optional().describe(`Request microphone access.
79
+
80
+ Maps to Permission Policy \`microphone\` feature.`),geolocation:U({}).optional().describe(`Request geolocation access.
81
+
82
+ Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:U({}).optional().describe(`Request clipboard write access.
83
+
84
+ Maps to Permission Policy \`clipboard-write\` feature.`)}),o_=U({method:J(`ui/notifications/size-changed`),params:U({width:z().optional().describe(`New width in pixels.`),height:z().optional().describe(`New height in pixels.`)})});U({method:J(`ui/notifications/tool-input`),params:U({arguments:K(L(),V().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),U({method:J(`ui/notifications/tool-input-partial`),params:U({arguments:K(L(),V().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),U({method:J(`ui/notifications/tool-cancelled`),params:U({reason:L().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var s_=U({fonts:L().optional()}),c_=U({variables:Qg.optional().describe(`CSS variables for theming the app.`),css:s_.optional().describe(`CSS blocks that apps can inject.`)});U({method:J(`ui/resource-teardown`),params:U({})});var l_=K(L(),V()),u_=U({text:U({}).optional().describe(`Host supports text content blocks.`),image:U({}).optional().describe(`Host supports image content blocks.`),audio:U({}).optional().describe(`Host supports audio content blocks.`),resource:U({}).optional().describe(`Host supports resource content blocks.`),resourceLink:U({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:U({}).optional().describe(`Host supports structured content.`)}),d_=U({method:J(`ui/notifications/request-teardown`),params:U({}).optional()}),f_=U({experimental:K(L(),K(L(),Rl()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),openLinks:U({}).optional().describe(`Host supports opening external URLs.`),downloadFile:U({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:U({listChanged:B().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:U({listChanged:B().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:U({}).optional().describe(`Host accepts log messages.`),sandbox:U({permissions:a_.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:i_.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:u_.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:u_.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:U({tools:U({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),p_=U({experimental:K(L(),K(L(),Rl()).describe(`Experimental features keyed by identifier.`)).optional().describe(`Experimental features keyed by identifier.`),tools:U({listChanged:B().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:H(Zg).optional().describe(`Display modes the app supports.`)}),m_=U({method:J(`ui/notifications/initialized`),params:U({}).optional()});U({csp:i_.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:a_.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:L().optional().describe(`Dedicated origin for view sandbox.
85
+
86
+ Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
87
+
88
+ **Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
89
+ - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
90
+ - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
91
+
92
+ If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:B().optional().describe(`Visual boundary preference - true if view prefers a visible border.
93
+
94
+ Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
95
+
96
+ - \`true\`: request visible border + background
97
+ - \`false\`: request no visible border + background
98
+ - omitted: host decides border`)});var h_=U({method:J(`ui/request-display-mode`),params:U({mode:Zg.describe(`The display mode being requested.`)})}),g_=U({mode:Zg.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),__=G([J(`model`),J(`app`)]).describe(`Tool visibility scope - who can access the tool.`);U({resourceUri:L().optional(),visibility:H(__).optional().describe(`Who can access this tool. Default: ["model", "app"]
99
+ - "model": Tool visible to and callable by the agent
100
+ - "app": Tool callable by the app from this server only`),csp:Vl().optional(),permissions:Vl().optional()}),U({mimeTypes:H(L()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var v_=U({method:J(`ui/download-file`),params:U({contents:H(G([mf,hf])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),y_=U({method:J(`ui/message`),params:U({role:J(`user`).describe(`Message role, currently only "user" is supported.`),content:H(gf).describe(`Message content blocks (text, image, etc.).`)})});U({method:J(`ui/notifications/sandbox-resource-ready`),params:U({html:L().describe(`HTML content to load into the inner iframe.`),sandbox:L().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:i_.optional().describe(`CSP configuration from resource metadata.`),permissions:a_.optional().describe(`Sandbox permissions from resource metadata.`)})}),U({method:J(`ui/notifications/tool-result`),params:Tf.describe(`Standard MCP tool execution result.`)});var b_=U({toolInfo:U({id:Yu.optional().describe(`JSON-RPC id of the tools/call request.`),tool:Sf.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Xg.optional().describe(`Current color theme preference.`),styles:c_.optional().describe(`Style configuration for theming the app.`),displayMode:Zg.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:H(Zg).optional().describe(`Display modes the host supports.`),containerDimensions:G([U({height:z().describe(`Fixed container height in pixels.`)}),U({maxHeight:G([z(),Pl()]).optional().describe(`Maximum container height in pixels.`)})]).and(G([U({width:z().describe(`Fixed container width in pixels.`)}),U({maxWidth:G([z(),Pl()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
101
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:L().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:L().optional().describe(`User's timezone in IANA format.`),userAgent:L().optional().describe(`Host application identifier.`),platform:G([J(`web`),J(`desktop`),J(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:U({touch:B().optional().describe(`Whether the device supports touch input.`),hover:B().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:U({top:z().describe(`Top safe area inset in pixels.`),right:z().describe(`Right safe area inset in pixels.`),bottom:z().describe(`Bottom safe area inset in pixels.`),left:z().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();U({method:J(`ui/notifications/host-context-changed`),params:b_.describe(`Partial context update containing only changed fields.`)});var x_=U({method:J(`ui/update-model-context`),params:U({content:H(gf).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:K(L(),V().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),S_=U({method:J(`ui/initialize`),params:U({appInfo:cd.describe(`App identification (name and version).`),appCapabilities:p_.describe(`Features and capabilities this app provides.`),protocolVersion:L().describe(`Protocol version this app supports.`)})}),C_=U({protocolVersion:L().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:cd.describe(`Host application identification and version.`),hostCapabilities:f_.describe(`Features and capabilities provided by the host.`),hostContext:b_.describe(`Rich context about the host environment.`)}).passthrough(),w_=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=ed.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},T_=[Yg],E_=class extends Tg{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Wg;_methods=new Gg;setRequestHandler=(...e)=>{let[t,...n]=qg(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=qg(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_wrapHandler(e,t){let n=super._wrapHandler(e,t);return e===`ui/initialize`||e===`ping`?n:async(t,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(t,r))}eventSchemas={sizechange:o_,sandboxready:r_,initialized:m_,requestteardown:d_,loggingmessage:Ff};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let n=t=>{e===`initialized`&&(this._initializedReceived=!0),this._events.dispatch(e,t)};e===`loggingmessage`?this.setNotificationHandler(`notifications/message`,e=>{n(e.params)}):this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},e=>n(e)),this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._hostCapabilities=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),this._ensureEventSlot(`initialized`),this._hostContext=r?.hostContext||{},this.replaceRequestHandler(`ui/initialize`,{params:S_.shape.params,result:C_},e=>this._onAppsInitialize(e)),this.replaceRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(`ui/request-display-mode`,{params:h_.shape.params,result:g_},()=>({mode:this._hostContext.displayMode??`inline`}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(`ui/message`,{params:y_.shape.params,result:n_},async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(`ui/open-link`,{params:$g.shape.params,result:e_},async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(`ui/download-file`,{params:v_.shape.params,result:t_},async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(`ui/request-display-mode`,{params:h_.shape.params,result:g_},async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(`ui/update-model-context`,{params:x_.shape.params,result:nd},async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(e){this.warnIfRequestHandlerReplaced(`oncreatesamplingmessage`,this._oncreatesamplingmessage,e),this._oncreatesamplingmessage=e,this.replaceRequestHandler(`sampling/createMessage`,async(e,t)=>{if(!this._oncreatesamplingmessage)throw Error(`No oncreatesamplingmessage handler set`);return this._oncreatesamplingmessage(e.params,t)})}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(`resources/list`,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(`resources/templates/list`,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(`resources/read`,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(`prompts/list`,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:T_.includes(t)?t:Yg,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];D_(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},l_,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},t)}listTools(e,t){return this.request({method:`tools/list`,params:e},t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},{signal:t.mcpReq.signal}),e.tools.listChanged&&this._client.setNotificationHandler(`notifications/tools/list_changed`,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},{signal:t.mcpReq.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},{signal:t.mcpReq.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},{signal:t.mcpReq.signal}),e.resources.listChanged&&this._client.setNotificationHandler(`notifications/resources/list_changed`,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},{signal:t.mcpReq.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(`notifications/prompts/list_changed`,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function D_(e,t){return JSON.stringify(e)===JSON.stringify(t)}var O_=1200,k_=`po.openai`;function A_(e){return e instanceof Error?e.message:`The MCP App could not complete this request`}function j_(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`Invalid App request`);return e}function M_(e,t){if(e.contentWindow===null)throw Error(`MCP App frame is not mounted`);let{data:n}=t,r=!0,i,a=new MessageChannel,o=(e,n)=>r?t.request(e,n):Promise.reject(Error(`MCP App is closed`)),s=e=>{typeof e==`number`&&Number.isFinite(e)&&t.resize(Math.min(O_,Math.max(80,Math.ceil(e))))},c=n=>{r&&(t.fail(A_(n)),r=!1,e.srcdoc=``,l().catch(e=>{t.fail(`${A_(n)}. Closing the App lease failed: ${A_(e)}`)}))},l=()=>t.request(`close`,{}),u=setTimeout(()=>c(Error(`MCP App initialization timed out`)),15e3),d=()=>{r&&(clearTimeout(u),t.ready())},f=async(e,t)=>{if(n.readOnly)throw Error(`Enable interactions in the conversation before calling tools`);if(typeof e!=`string`)throw Error(`Invalid App tool name`);return await o(`callTool`,{name:e,arguments:j_(t??{})})},p=async e=>(await o(`setState`,{state:e}),t.saveState(e),{}),m=async e=>{if(n.readOnly)throw Error(`Enable interactions in the conversation before sending a follow-up`);if(typeof e!=`string`)throw Error(`Invalid App follow-up`);return await o(`followUp`,{prompt:e}),{}},h=async()=>(await o(`close`,{}),t.close(),{}),g=t.theme,_=g,v={toolInput:n.args,toolOutput:n.result.structuredContent??null,toolResponseMetadata:n.result._meta??{},widgetState:t.savedState,theme:g,locale:t.locale,displayMode:`inline`,maxHeight:O_,safeArea:{insets:{top:0,right:0,bottom:0,left:0}},userAgent:{device:{type:t.device},capabilities:{hover:t.hover??!1,touch:t.touch??!1}}};try{let o=qe(n.resourceMeta,t.hostOrigin);n.protocol===`mcp`&&(i=new E_(null,{name:`Po`,version:`1`},{...n.readOnly?{}:{serverTools:{},message:{text:{}}},openLinks:{}},{hostContext:{theme:g,locale:t.locale,displayMode:`inline`,availableDisplayModes:[`inline`],toolInfo:{id:t.toolCallId,tool:n.tool}}}),i.oncalltool=({name:e,arguments:t})=>f(e,t),i.onmessage=async({content:e})=>{if(e.some(e=>e.type!==`text`))throw Error(`Only text follow-ups are supported`);return m(e.map(e=>e.type===`text`?e.text:``).join(`
102
+ `))},i.onopenlink=({url:e})=>t.openLink(e),i.onsizechange=({height:e})=>s(e),i.onrequestdisplaymode=async()=>({mode:`inline`}),i.onrequestteardown=()=>{h().catch(c)},i.oninitialized=()=>{(async()=>{await i.sendToolInput({arguments:n.args}),await i.sendToolResult(n.result),d()})().catch(c)},i.connect(new w_(e.contentWindow,e.contentWindow)).catch(c)),a.port1.onmessage=e=>{if(!r)return;let i=e.data;if(i?.type===`revoked`){c(Error(`MCP App navigation was blocked; reopen it to continue`));return}if(i?.type!==`legacy`)return;let o=i.data;o?.channel===k_&&(async()=>{let e=j_(o.input??{});switch(o.method){case`initialized`:{d();let e=_;return e!==g&&a.port1.postMessage({channel:k_,globals:{theme:e}}),{}}case`height`:return s(e.height),{};case`callTool`:return f(e.name,e.arguments);case`setState`:return p(e.state);case`followUp`:return m(e.prompt);case`openLink`:return t.openLink(e.url);case`close`:return h();default:throw Error(`Unsupported ChatGPT widget method`)}})().then(e=>{if(!r||o.id===void 0)return;let t=o.method===`callTool`&&n.protocol===`openai`?e:void 0;a.port1.postMessage({channel:k_,id:o.id,result:e,...t===void 0?{}:{globals:{toolOutput:t.structuredContent??null,toolResponseMetadata:t._meta??{}}}})},e=>{r&&o.id!==void 0&&a.port1.postMessage({channel:k_,id:o.id,error:A_(e)})})},a.port1.start();let l=()=>{e.contentWindow?.postMessage({html:$e(n.html,o,nt(v),g),policy:o,protocol:n.protocol},`*`,[a.port2])};return e.addEventListener(`load`,l,{once:!0}),e.srcdoc=Qe(o,g),{setTheme:e=>{_=e,i?.setHostContext({theme:e}),a.port1.postMessage({channel:k_,globals:{theme:e}})},dispose:()=>{r=!1,clearTimeout(u),e.removeEventListener(`load`,l),a.port1.close(),a.port2.close(),i!==void 0&&i.close().catch(e=>t.fail(A_(e))),e.srcdoc=``}}}catch(e){return c(e),{setTheme:()=>{},dispose:()=>{clearTimeout(u),a.port1.close(),a.port2.close()}}}}var N_=`po-mcp-session-approval`;function P_(e){if(e===void 0||e.trim()===``)return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t,r=Object.keys(n).sort();if(r.length===2&&r[0]===`host`&&r[1]===`session`&&typeof n.host==`boolean`&&typeof n.session==`boolean`)return{host:n.host,session:n.session}}var F_=RegExp(`\x1B\\[[0-?]*[ -/]*[@-~]`,`gu`),I_=128,L_=8192,R_=512,z_=256,B_=64,V_=/^[A-Za-z0-9._-]{1,64}$/u,H_=[`not-connected`,`connecting`,`connected`,`degraded`,`needs-auth`,`failed`,`closed`,`disabled`];function U_(e){return H_.some(t=>t===e)}var W_=`/tool`,G_=`server`,K_=`tool`,q_=`/secrets`;function J_(e){if(e!==void 0&&e.trim()!==``)try{let t=JSON.parse(e.replace(F_,``));if(!Array.isArray(t)||t.length===0||t.length>I_)return;let n=new Set;for(let e of t){if(!nv(e)||n.has(e.name))return;n.add(e.name)}return t}catch{return}}function Y_(e){for(let t of e){let e=t.codePointAt(0);if(e!==void 0&&(e<32||e>=127&&e<=159))return!0}return!1}function X_(e){if(typeof e!=`string`||e.length>L_||Y_(e))return!1;try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.username===``&&t.password===``}catch{return!1}}function Z_(e){return typeof e==`string`&&e.trim()!==``&&e.length<=z_&&!Y_(e)}function Q_(e){return typeof e==`string`&&V_.test(e)}function $_(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0}function ev(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(e=>e===`name`||e===`piName`||e===`tokens`)&&Z_(t.name)&&(!(`piName`in t)||Z_(t.piName))&&(!(`tokens`in t)||$_(t.tokens))}function tv(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(e=>[`owner`,`canEdit`,`canRemove`,`revision`,`target`,`kind`].includes(e))&&[`host`,`repository`,`read-only`].includes(String(t.owner))&&typeof t.canEdit==`boolean`&&typeof t.canRemove==`boolean`&&(!(`revision`in t)||typeof t.revision==`string`&&/^[a-f0-9]{64}$/u.test(t.revision))&&(!(`target`in t)||typeof t.target==`string`&&t.target.length<=2048&&!Y_(t.target))&&(!(`kind`in t)||t.kind===`local`||t.kind===`remote`)&&(!(t.canEdit||t.canRemove)||t.owner!==`read-only`&&typeof t.revision==`string`)}function nv(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return Object.keys(t).every(e=>e===`management`||e===`name`||e===`state`||e===`authorizationUrl`||e===`tools`||e===`missingSecrets`||e===`oauthEligible`||e===`oauthAuthorized`)&&(!(`management`in t)||tv(t.management))&&(!(`oauthEligible`in t)||typeof t.oauthEligible==`boolean`)&&(!(`oauthAuthorized`in t)||typeof t.oauthAuthorized==`boolean`)&&(!(`missingSecrets`in t)||Array.isArray(t.missingSecrets)&&t.missingSecrets.length<=B_&&t.missingSecrets.every(Q_))&&(!(`authorizationUrl`in t)||X_(t.authorizationUrl))&&(!(`tools`in t)||Array.isArray(t.tools)&&t.tools.length<=R_&&t.tools.every(ev))&&typeof t.name==`string`&&t.name.trim()!==``&&!Y_(t.name)&&U_(t.state)}var rv=`/repository`,iv=`/repository/discover`,av=`/repository/authorize`,ov=`repositoryId`,sv=`flowId`,cv=`/servers`,lv=`/servers/host`,uv=`/settings`;function dv(e){return e}var fv=`${av}/:${sv}`,pv={catalog:{method:`GET`,path:rv,query:[ov],response:void 0},discover:{method:`POST`,path:iv,response:void 0},authorize:{method:`POST`,path:av,response:void 0},readAuthorization:{method:`GET`,path:fv,query:[ov],response:void 0},cancelAuthorization:{method:`DELETE`,path:fv,query:[ov],response:void 0},addServer:{method:`POST`,path:cv,response:void 0},editServer:{method:`PATCH`,path:cv,response:void 0},removeServer:{method:`DELETE`,path:cv,response:void 0},hostServers:{method:`GET`,path:lv,response:void 0},readSettings:{method:`GET`,path:uv,response:void 0},saveSettings:{method:`PUT`,path:uv,response:void 0},sessionTool:{method:`GET`,path:W_,query:[G_,K_],response:void 0},sessionSecret:{method:`POST`,path:q_,response:void 0}},mv=he(pv,{scopes:[`host`,`workspace`,`session`],basePath:`mcp`,transport:(e,t)=>Oe.fetch(e,t),sessionAddress:i}),hv=he(pv,{scopes:[`session`],basePath:`mcp-session`,transport:(e,t)=>Oe.fetch(e,t),sessionAddress:i}),gv={"content-type":`application/json`};function _v(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function vv(e,t){let n;try{n=await e.json()}catch{n=void 0}return e.ok?{value:n}:{error:_v(n)&&typeof n.error==`string`?n.error:t}}async function yv(e,t){let n=mv.workspace(t).catalog;return await vv(await e(n.url({query:{[ov]:t}})),`The synced MCP catalog could not be read.`)}async function bv(e,t){let n=mv.workspace(t).discover;return await vv(await e(n.url(),{method:n.spec.method,headers:gv,body:JSON.stringify({repositoryId:t})}),`MCP discovery could not be completed.`)}async function xv(e,t,n){let r=mv.workspace(t).authorize;return await vv(await e(r.url(),{method:r.spec.method,headers:gv,body:JSON.stringify({repositoryId:t,serverName:n})}),`MCP authorization could not be started.`)}async function Sv(e,t,n){let r=mv.workspace(t).readAuthorization;return await vv(await e(r.url({params:{[sv]:n},query:{[ov]:t}})),`The authorization state could not be read.`)}async function Cv(e,t,n){let r=mv.workspace(t).cancelAuthorization;return await vv(await e(r.url({params:{[sv]:n},query:{[ov]:t}}),{method:r.spec.method}),`The authorization flow could not be cancelled.`)}async function wv(e,t){let n=t.scope===`repository`&&t.repositoryId?mv.workspace(t.repositoryId).addServer:mv.host.addServer;return await vv(await e(n.url(),{method:n.spec.method,headers:gv,body:JSON.stringify({...t,scope:dv(t.scope)})}),`The server could not be added.`)}async function Tv(e,t,n){let r=n.repositoryId?mv.workspace(n.repositoryId):mv.host,i=t===`edit`?r.editServer:r.removeServer;return await vv(await e(i.url(),{method:i.spec.method,headers:gv,body:JSON.stringify({...n,scope:dv(n.scope)})}),`The saved definition could not be changed.`)}async function Ev(e){let t=mv.host.hostServers;return await vv(await e(t.url()),`Your MCP servers could not be read.`)}async function Dv(e){let t=mv.host.readSettings;return await vv(await e(t.url()),`Your MCP settings could not be read.`)}async function Ov(e,t){let n=mv.host.saveSettings;return await vv(await e(n.url(),{method:n.spec.method,headers:gv,body:JSON.stringify(t)}),`Your MCP settings could not be saved.`)}var kv={kind:`repository`},Av=`repository`,jv=`plugin:`;function Mv(e){switch(e.kind){case`repository`:return`Workspace (.mcp.json)`;case`host`:return`Your personal config (~/.po/mcp.json)`;case`plugin`:return`Plugin ${e.pluginName} (.mcp.json)`;case`upstream`:return`Upstream (mcp-config.yaml)`}}function Nv(e){if(!e?.source)return;let t=Mv(e.source);return e.owner===`read-only`?e.readOnlyReason?`${t}, read-only: ${e.readOnlyReason}`:`${t}, read-only.`:`${t}.`}function Pv(e){return[kv,...(e??[]).filter(e=>e.kind===`plugin`)]}function Fv(e){return e.kind===`repository`?`This workspace (.mcp.json)`:`Plugin ${e.pluginName} (.mcp.json)`}function Iv(e){return e.kind===`repository`?Av:`${jv}${e.pluginId}`}function Lv(e,t){return e.find(e=>Iv(e)===t)}function Rv(e){return e.owner===`plugin`&&e.source?.kind===`plugin`?{kind:`plugin`,pluginId:e.source.pluginId}:void 0}var zv=/^[A-Za-z0-9_-]+$/,Bv=/key|token|secret/i;function Vv(e){return e.toLowerCase()===`authorization`||Bv.test(e)}function Hv(e){return e.kind===`repository`?Uv.repository:`Sessions that load the ${e.pluginName} plugin can use it after you add it. It's saved to that plugin's .mcp.json in this repository.`}var Uv={repository:`Sessions in this repository can use it after you add it. It's saved to .mcp.json in this repository.`,host:`Sessions in every repository can use it after you add it. It's saved to your personal config, ~/.po/mcp.json.`};function Wv(e,t){let n=e.split(`
103
+ `).map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.indexOf(t);return n>0?[e.slice(0,n).trim(),e.slice(n+1).trim()]:[e,``]});return n.length>0?Object.fromEntries(n):void 0}function Gv(e){try{let t=new URL(e).protocol;return t===`https:`||t===`http:`}catch{return!1}}function Kv({open:n,onOpenChange:i,onCloseAutoFocus:a,scope:o,targets:s,existingNames:c,onSubmit:u,pending:m=!1,error:h,defaultValues:_={}}){let v=o===`repository`?Pv(s):[],[y,b]=E(_.target??Iv({kind:`repository`})),ee=Lv(v,y)??v[0],te=ee?.kind===`plugin`?{kind:`plugin`,pluginId:ee.pluginId}:void 0,[ie,w]=E(_.kind??`remote`),[le,ue]=E(_.name??``),[T,fe]=E(_.url??``),[pe,me]=E(_.headers??``),[he,ge]=E(_.command??``),[_e,ve]=E(_.args??``),[ye,xe]=E(_.env??``),[we,Te]=E(_.trusted??!1),[Ee,De]=E(_.vault??{}),Oe=e=>Ee[e]??Vv(e),je=e=>Object.entries(e??{}).filter(([e,t])=>t!==``&&Oe(e)).map(([e])=>e),Me=le.trim(),Pe=Me===``?void 0:zv.test(Me)?c.includes(Me)?`A server named ${Me} already exists here.`:void 0:`Use letters, numbers, dashes or underscores.`,Fe=T.trim()!==``&&!Gv(T.trim())?`Enter an http or https address.`:void 0,Ie=Me!==``&&Pe===void 0&&(ie===`remote`?T.trim()!==``&&Fe===void 0:he.trim()!==``&&we),Le=()=>{if(Ie&&!m){if(ie===`remote`){let e=Wv(pe,`:`);u({name:Me,entry:{type:`http`,url:T.trim(),...e?{headers:e}:{}},trusted:!1,secretFields:je(e),...te?{target:te}:{}})}else{let e=Wv(ye,`=`);u({name:Me,entry:{command:he.trim(),args:_e.split(`
104
+ `).map(e=>e.trim()).filter(Boolean),...e?{env:e}:{}},trusted:we,secretFields:je(e),...te?{target:te}:{}})}}};return D(l,{open:n,onOpenChange:i,children:O(g,{"data-testid":`mcp-add-server-dialog`,onCloseAutoFocus:a,children:[D(r,{className:`items-start px-4 py-4 sm:px-5`,dismissible:!0,children:O(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[D(re,{children:`Add an MCP server`}),D(x,{children:ee?Hv(ee):Uv[o]})]})}),O(`form`,{onSubmit:e=>{e.preventDefault(),Le()},children:[O(p,{className:`gap-4 px-4 py-4 sm:px-5 sm:py-5`,children:[v.length>1?O(`div`,{className:`flex flex-col gap-1.5`,children:[D(S,{htmlFor:`mcp-add-target`,children:`Save to`}),O(be,{value:ee?Iv(ee):y,onValueChange:b,children:[D(Ne,{id:`mcp-add-target`,"data-testid":`mcp-add-target`,children:D(de,{})}),D(ce,{children:v.map(e=>D(ke,{value:Iv(e),children:Fv(e)},Iv(e)))})]})]}):null,D(f,{value:ie,onValueChange:e=>w(e===`local`?`local`:`remote`),children:O(ae,{"aria-label":`Server kind`,children:[D(d,{value:`remote`,children:`Remote (URL)`}),D(d,{value:`local`,children:`Local command`})]})}),O(`div`,{className:`flex flex-col gap-1.5`,children:[D(S,{htmlFor:`mcp-add-name`,children:`Name`}),D(Ae,{id:`mcp-add-name`,className:`font-mono`,value:le,placeholder:`linear`,"aria-invalid":Pe!==void 0,"aria-describedby":`mcp-add-name-hint`,onChange:e=>ue(e.target.value)}),D(`p`,{id:`mcp-add-name-hint`,className:`text-sm ${Pe?`text-po-red`:`text-po-dim`}`,children:Pe??(Me?`Tools appear as ${Me.replace(/[^A-Za-z0-9]/g,`_`)}_tool_name.`:`Tools appear with this name in front.`)})]}),ie===`remote`?O(se,{children:[O(`div`,{className:`flex flex-col gap-1.5`,children:[D(S,{htmlFor:`mcp-add-url`,children:`Server URL`}),D(Ae,{id:`mcp-add-url`,type:`url`,className:`font-mono`,value:T,placeholder:`https://mcp.example.com/mcp`,"aria-invalid":Fe!==void 0,onChange:e=>fe(e.target.value)}),Fe?D(`p`,{className:`text-sm text-po-red`,children:Fe}):null]}),O(Ce,{className:`flex flex-col gap-1.5`,defaultOpen:pe!==``,children:[D(Se,{asChild:!0,children:O(e,{type:`button`,variant:`ghost`,size:`sm`,className:`group self-start gap-1.5`,children:[D(ne,{className:`size-3 transition-transform group-data-[state=open]:rotate-90`}),`Headers (optional)`]})}),O(t,{className:`flex flex-col gap-1.5`,children:[D(oe,{"aria-label":`Headers`,className:`font-mono`,rows:3,value:pe,placeholder:`Authorization: Bearer ...`,onChange:e=>me(e.target.value)}),D(`p`,{className:`text-sm text-po-dim`,children:`One header per line, as Name: value.`}),D(qv,{serverName:Me,fields:Object.keys(Wv(pe,`:`)??{}),keepsInVault:Oe,onChange:(e,t)=>De(n=>({...n,[e]:t}))})]})]}),D(`p`,{className:`text-sm text-po-dim`,children:`If the server uses sign-in, you can authorize it right after adding.`})]}):O(se,{children:[O(`div`,{className:`flex flex-col gap-1.5`,children:[D(S,{htmlFor:`mcp-add-command`,children:`Command`}),D(Ae,{id:`mcp-add-command`,className:`font-mono`,value:he,placeholder:`npx`,onChange:e=>ge(e.target.value)})]}),O(`div`,{className:`flex flex-col gap-1.5`,children:[D(S,{htmlFor:`mcp-add-args`,children:`Arguments`}),D(oe,{id:`mcp-add-args`,className:`font-mono`,rows:3,value:_e,placeholder:`-y
105
+ @modelcontextprotocol/server-filesystem
106
+ .`,onChange:e=>ve(e.target.value)}),D(`p`,{className:`text-sm text-po-dim`,children:`One argument per line, so paths with spaces stay whole.`})]}),O(Ce,{className:`flex flex-col gap-1.5`,defaultOpen:ye!==``,children:[D(Se,{asChild:!0,children:O(e,{type:`button`,variant:`ghost`,size:`sm`,className:`group self-start gap-1.5`,children:[D(ne,{className:`size-3 transition-transform group-data-[state=open]:rotate-90`}),`Environment variables (optional)`]})}),O(t,{className:`flex flex-col gap-1.5`,children:[D(oe,{"aria-label":`Environment variables`,className:`font-mono`,rows:3,value:ye,placeholder:`API_KEY=...`,onChange:e=>xe(e.target.value)}),D(`p`,{className:`text-sm text-po-dim`,children:`One variable per line, as KEY=value.`}),D(qv,{serverName:Me,fields:Object.keys(Wv(ye,`=`)??{}),keepsInVault:Oe,onChange:(e,t)=>De(n=>({...n,[e]:t}))})]})]}),O(`div`,{className:`flex flex-col gap-2 rounded-md border border-po-edge-magenta bg-po-tint-magenta px-3 py-3`,children:[D(`p`,{className:`text-base font-semibold text-po-hi`,children:`This runs on your machine`}),D(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Po starts this command with your user's permissions whenever a session uses it. Only add commands you trust.`}),O(`div`,{className:`flex items-center gap-2`,children:[D(C,{id:`mcp-add-trust`,checked:we,onCheckedChange:e=>Te(e===!0)}),D(S,{htmlFor:`mcp-add-trust`,children:`I trust this command`})]})]})]}),h?D(`p`,{role:`alert`,className:`text-sm text-po-red`,children:h}):null]}),O(He,{className:`border-t border-po-border-soft px-4 py-3 sm:px-5`,children:[D(e,{type:`button`,variant:`ghost`,size:`md`,onClick:()=>i(!1),children:`Cancel`}),D(e,{type:`submit`,variant:`primary`,size:`md`,disabled:!Ie||m,children:m?`Adding...`:`Add server`})]})]})]})})}function qv({serverName:e,fields:t,keepsInVault:n,onChange:r}){if(t.length===0)return null;let i=(t.find(n)??t[0]??``).replace(/[^A-Za-z0-9._-]/g,`_`),a=`\${vault:${e||`server`}-${i}}`;return O(`div`,{className:`flex flex-col gap-1.5`,children:[D(`ul`,{"aria-label":`Keep in vault`,className:`flex flex-col divide-y divide-po-border-soft rounded-md border border-po-border-soft`,children:t.map((e,t)=>{let i=`mcp-add-vault-${t}`;return O(`li`,{className:`flex min-w-0 items-center gap-2 px-3 py-1.5`,children:[D(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm text-po-text`,children:e}),D(C,{id:i,checked:n(e),onCheckedChange:t=>r(e,t===!0)}),D(S,{htmlFor:i,children:`Keep in vault`})]},e)})}),O(`p`,{className:`text-sm text-po-dim`,children:[`Kept values stay in Po's vault on this machine. The config only gets a reference, such as`,` `,D(`span`,{className:`font-mono`,children:a}),`.`]})]})}function Jv({scope:t,repositoryId:n,targets:r,existingNames:i,requestWithStepUp:a,disabled:o=!1,onAdded:s,renderTrigger:c,onCloseAutoFocus:l}){let u=_e(null),[d,f]=E(!1),[p,m]=E(!1),[h,g]=E(),_=()=>{o||(g(void 0),f(!0))};return O(se,{children:[c?c(_):D(e,{ref:u,variant:`outline`,size:`sm`,disabled:o,"data-testid":`mcp-add-server`,onClick:_,children:`Add server`}),d?D(Kv,{open:!0,onOpenChange:e=>{p||f(e)},onCloseAutoFocus:l??(e=>{e.preventDefault(),u.current?.focus()}),scope:t,targets:r,existingNames:i,pending:p,error:h,onSubmit:({name:e,entry:r,trusted:i,secretFields:o,target:c})=>{m(!0),g(void 0),wv(a,{scope:t,...n?{repositoryId:n}:{},...t===`repository`&&c?{target:c}:{},name:e,entry:r,trusted:i,...o.length>0?{secretFields:o}:{}}).then(t=>{m(!1),`error`in t?g(t.error):(f(!1),s(e))})}}):null]})}function Yv({action:t,name:n,management:i,pending:a,error:o,onClose:s,onCloseAutoFocus:c,onSubmit:u}){let d=me(),[f,m]=E(``),[h,_]=E(!1),[v,y]=E(),b=i.kind===`local`;return D(l,{open:!0,onOpenChange:e=>{!e&&!a&&s()},children:O(g,{onCloseAutoFocus:c,children:[D(r,{children:O(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[O(re,{children:[t===`edit`?`Edit`:`Remove`,` `,n]}),D(x,{children:t===`edit`?`Update headers or environment only. Existing values are retained unless overwritten. Values cannot be deleted here. Saved OAuth credentials are retained.`:`Remove this saved definition? Live connections and credentials are retained. A lower-priority definition may appear. This does not reconnect any session.`})]})}),O(p,{className:`space-y-4`,children:[O(`p`,{className:`break-all text-sm text-po-dim`,children:[i.source?Mv(i.source):i.owner,` ·`,` `,b?`Local command`:`Remote`,` · `,i.target]}),t===`edit`?O(se,{children:[D(`p`,{className:`text-sm text-po-dim`,children:`Name, endpoint, transport, command and arguments are fixed. Updates are saved directly in the configuration file, not the vault. Existing values are not shown. Do not enter redacted placeholders or vault references.`}),O(`div`,{className:`space-y-2`,children:[O(S,{htmlFor:d,children:[b?`Environment updates`:`Header updates`,` (one NAME=value per line)`]}),D(oe,{id:d,className:`min-h-24 w-full`,value:f,disabled:a,onChange:e=>m(e.target.value),autoComplete:`off`})]}),b?O(S,{className:`flex items-center gap-2`,children:[D(C,{checked:h,disabled:a,onCheckedChange:e=>_(e===!0)}),`I trust this command to run with my permissions.`]}):null]}):null,o||v?D(`p`,{role:`alert`,className:`text-sm text-po-red`,children:o??v}):null]}),O(He,{className:`border-t border-po-border-soft px-4 py-3`,children:[D(e,{variant:`ghost`,disabled:a,onClick:s,children:`Cancel`}),D(e,{variant:t===`remove`?`danger`:`primary`,loading:a,disabled:a||t===`edit`&&(!f.trim()||b&&!h),onClick:()=>{let e=[];for(let t of f.split(`
107
+ `).filter(e=>e.trim())){let n=t.indexOf(`=`);if(n<1||!t.slice(0,n).trim()||t.includes("${vault:")){y(`Use NAME=value on each line. Vault references cannot be edited here.`);return}e.push([t.slice(0,n).trim(),t.slice(n+1)])}y(void 0),u(Object.fromEntries(e),h)},children:t===`edit`?`Save updates`:`Remove saved definition`})]})]})})}function Xv({name:t,management:n,repositoryId:r,requestWithStepUp:i,disabled:a,onChanged:o,onAuthorize:s,authorizeDisabled:c}){let l=_e(null),[d,f]=E(),[p,m]=E(),[g,_]=E(!1),[v,y]=E(),b=n&&n.owner!==`read-only`&&n.revision,ee=!!(b&&n.canEdit&&n.target&&n.kind),x=!!(b&&n.canRemove);return O(se,{children:[O(u,{children:[D(pe,{asChild:!0,children:D(e,{ref:l,variant:`ghost`,size:`icon`,"aria-label":`Actions for ${t}`,disabled:a||g,children:D(ze,{"aria-hidden":!0,className:`size-4`})})}),O(h,{align:`end`,children:[s?D(je,{disabled:a||c,onSelect:s,children:`Authorize`}):null,D(je,{disabled:!ee,onSelect:()=>{y(void 0),ee&&n&&(m({...n,name:t,repositoryId:r}),f(`edit`))},children:`Edit`}),D(te,{}),D(je,{disabled:!x,onSelect:()=>{y(void 0),x&&n&&(m({...n,name:t,repositoryId:r}),f(`remove`))},children:`Remove`})]})]}),d&&p?D(Yv,{action:d,name:p.name,management:p,pending:g,error:v,onClose:()=>f(void 0),onCloseAutoFocus:e=>{e.preventDefault(),l.current?.focus()},onSubmit:async(e,n)=>{if(p.name!==t||p.repositoryId!==r)y(`The selected repository or server changed. Close this dialog and try again.`);else if(!(g||!p.revision||p.owner===`read-only`||(d===`edit`?!ee:!x))){_(!0),y(void 0);try{let a=Rv(p),s=await Tv(i,d,{scope:p.owner===`host`?`host`:`repository`,repositoryId:r,...a?{target:a}:{},name:t,revision:p.revision,...d===`edit`?{trusted:n,entry:p.kind===`local`?{command:p.target,env:e}:{type:`http`,url:p.target,headers:e}}:{}});if(`error`in s){y(s.error);return}f(void 0);let c=s.value;o(`${d===`remove`?`Saved definition removed.`:`Saved definition updated.`} Live connections and credentials retained.${c.syncRequired?` Run po sync, then refresh.`:``} ${c.shadowedDefinition===`present`?`A lower-priority definition is now visible.`:c.shadowedDefinition===`possible`?`A lower-priority definition may appear.`:`No lower-priority definition was reported.`}`,d===`remove`)}catch(e){y(e instanceof Error?e.message:`The saved definition could not be changed.`)}finally{_(!1)}}}}):null]})}var Zv=`mcp-auto-approve`,Qv=`mcp-auto-approve-help`;function $v({checked:t,busy:n,error:r,onCheckedChange:i,onRetry:a}){return O(le,{"data-testid":`mcp-approval-settings`,children:[D(s,{children:D(Re,{children:`Approval`})}),D(Be,{children:`Po asks before running an MCP tool that could change your data. Tools a server marks read-only always run straight away.`}),D(fe,{children:O(ge,{changed:t,children:[O(Le,{children:[D(Ve,{children:D(`label`,{htmlFor:Zv,children:`Run tools that change data without asking`})}),D(w,{id:Qv,children:t?`On for every session, including ones already open. Turn it off to be asked again.`:`Applies to every session at once. Subagents and background work never ask.`}),r?D(w,{role:`alert`,className:`text-po-red`,children:r}):null]}),r&&a?D(e,{variant:`outline`,size:`sm`,onClick:a,children:`Try again`}):null,D(Ue,{id:Zv,"data-testid":`mcp-auto-approve-switch`,"aria-describedby":Qv,checked:t,disabled:n,"aria-busy":n||void 0,onCheckedChange:i})]})})]})}function ey({request:e,requestWithStepUp:t}){let[n,r]=E({status:`loading`}),i=Te(async()=>{let t=await Dv(e);r(`error`in t?{status:`load-failed`}:{status:`ready`,checked:t.value.autoApproveDestructiveTools})},[e]);T(()=>{i()},[i]);let a=Te(async(e,n)=>{r({status:`ready`,checked:e,saving:!0});let i=await Ov(t,{autoApproveDestructiveTools:e});r(`error`in i?{status:`ready`,checked:n,failedTarget:e}:{status:`ready`,checked:i.value.autoApproveDestructiveTools})},[t]);if(n.status!==`ready`)return D($v,{checked:!1,busy:!0,error:n.status===`load-failed`?`Po couldn't read this setting just now.`:void 0,onRetry:()=>void i()});let{checked:o,saving:s,failedTarget:c}=n;return D($v,{checked:o,busy:s,error:c===void 0?void 0:c?`Po couldn't save this just now, so sessions still ask first.`:`Po couldn't save this just now, so sessions still run these tools without asking.`,onCheckedChange:e=>void a(e,o),onRetry:c===void 0?void 0:()=>void a(c,o)})}function ty({request:t,requestWithStepUp:n}){let r=_e(null),[i,a]=E(),[o,c]=E({status:`loading`}),l=Te(async()=>{let e=await Ev(t);c(`error`in e?{status:`error`,error:e.error}:{status:`ready`,servers:e.value.servers})},[t]);T(()=>{l()},[l]);let u=o.status===`ready`?o.servers:[];return O(le,{ref:r,tabIndex:-1,"data-testid":`mcp-host-settings`,children:[O(s,{children:[D(Re,{children:`Servers`}),D(Ie,{children:D(Jv,{scope:`host`,existingNames:u.map(e=>e.name),requestWithStepUp:n,disabled:o.status===`loading`,onAdded:()=>void l()})})]}),i?D(`output`,{className:`text-sm text-po-dim`,children:i}):null,D(fe,{asChild:!0,children:D(`ul`,{children:o.status===`error`?D(ge,{asChild:!0,role:`alert`,children:O(`li`,{children:[O(Le,{children:[D(Ve,{children:`Po couldn't read your servers just now`}),D(w,{children:o.error})]}),D(e,{variant:`outline`,size:`sm`,onClick:()=>void l(),children:`Try again`})]})}):u.length===0?D(ge,{asChild:!0,children:D(`li`,{children:O(Le,{children:[D(Ve,{children:o.status===`loading`?`Reading your servers`:`No servers yet`}),D(w,{children:o.status===`loading`?`This takes a moment.`:`Servers you add here are available in every repository.`})]})})}):u.map(e=>D(ge,{asChild:!0,children:O(`li`,{"data-testid":`mcp-host-server-${e.name}`,children:[O(Le,{children:[D(Ve,{className:`font-mono first-letter:normal-case`,children:e.name}),O(w,{className:`truncate`,children:[e.kind===`remote`?`Remote`:`Local command`,` · `,e.target]})]}),D(Xv,{name:e.name,management:e.management,requestWithStepUp:n,onChanged:(e,t)=>{a(e),l().then(()=>{t&&r.current?.focus()})}})]})},e.name))})})]})}function ny(e){return O(`div`,{className:`flex flex-col gap-8`,children:[D(ey,{...e}),D(ty,{...e})]})}var ry=n({label:`MCP servers`,detail:`Your own MCP servers, available in every repository. A repository server with the same name wins.`,icon:Me,component:ny}),iy=new Pe({repositoryId:void 0,catalog:void 0,authorization:void 0,busy:void 0,error:void 0});function ay(e){iy.state.repositoryId!==e&&iy.setState(()=>({repositoryId:e,catalog:void 0,authorization:void 0,busy:void 0,error:void 0}))}function oy(e,t){iy.state.repositoryId===e&&iy.setState(t)}async function sy(e,t){ay(t),iy.setState(e=>({...e,busy:`loading`,error:void 0}));try{let n=await yv(e,t);oy(t,e=>`error`in n?{...e,busy:void 0,error:n.error}:{...e,busy:void 0,catalog:n.value,error:void 0})}catch{oy(t,e=>({...e,busy:void 0,error:`The cockpit hub is unreachable.`}))}}async function cy(e,t){ay(t),iy.setState(e=>({...e,busy:`discovering`,error:void 0}));try{let n=await bv(e,t);oy(t,e=>`error`in n?{...e,busy:void 0,error:n.error}:{...e,busy:void 0,catalog:n.value,error:void 0})}catch{oy(t,e=>({...e,busy:void 0,error:`The cockpit hub is unreachable.`}))}}async function ly(e,t,n){ay(t),iy.setState(e=>({...e,busy:`authorizing`,error:void 0}));try{let r=await xv(e,t,n);oy(t,e=>`error`in r?{...e,busy:void 0,error:r.error}:{...e,busy:void 0,authorization:r.value,error:void 0})}catch{oy(t,e=>({...e,busy:void 0,error:`The cockpit hub is unreachable.`}))}}function uy(e,t,n,r){let i=!1,a,o=async()=>{if(!i)try{let s=await Sv(e,t,n);if(i)return;if(`error`in s){oy(t,e=>({...e,error:s.error}));return}if(oy(t,e=>({...e,authorization:s.value,error:void 0})),s.value.status===`completed`){r();return}if([`failed`,`cancelled`,`expired`].includes(s.value.status))return;a=setTimeout(()=>void o(),1e3)}catch{oy(t,e=>({...e,error:`The authorization status could not be refreshed.`}))}};return o(),()=>{i=!0,a&&clearTimeout(a)}}async function dy(e,t,n){iy.setState(e=>({...e,busy:`cancelling`,error:void 0}));try{let r=await Cv(e,t,n);oy(t,e=>`error`in r?{...e,busy:void 0,error:r.error}:{...e,busy:void 0,authorization:r.value,error:void 0})}catch{oy(t,e=>({...e,busy:void 0,error:`The cockpit hub is unreachable.`}))}}var fy=new Set([`completed`,`failed`,`cancelled`,`expired`]),py={"never-synced":`this repository has never been synced`,"configuration-changed":`the configuration changed since the last sync`,"cockpit-bundle-missing":`the cockpit bundle is missing`,"package-apis-missing":`package APIs are missing`},my={"not-connected":`Not connected`,connecting:`Connecting`,connected:`Connected`,degraded:`Degraded`,"needs-auth":`Needs sign-in`,failed:`Failed`,closed:`Closed`},hy={starting:`Starting sign-in.`,waiting:`Waiting for you to finish signing in.`,completed:`Signed in.`,failed:`Sign-in didn't finish.`,cancelled:`Sign-in was cancelled.`,expired:`Sign-in expired before it finished.`};function gy(e){return`${e.map(e=>py[e]??e).join(`, `)||`the last sync is out of date`}. Run po sync, then refresh.`}function _y({server:t,busy:n,canAct:r,confirming:i,onAuthorize:a,repositoryId:o,requestWithStepUp:s,onChanged:c,onConfirm:l,onCancel:u}){let d=t.tools.length,f=Nv(t.management);return D(ge,{asChild:!0,className:`items-start`,children:O(`li`,{"data-testid":`mcp-server-${t.name}`,children:[O(Le,{children:[D(Ve,{className:`font-mono first-letter:normal-case`,children:t.name}),O(w,{children:[my[t.state],`. `,t.credentialPresent?`Credential saved.`:`No credential saved.`]}),f===void 0?null:D(w,{"data-testid":`mcp-server-source-${t.name}`,children:f}),t.error===void 0?null:D(w,{className:`text-po-red`,children:t.error})]}),i?null:D(Xv,{name:t.name,management:t.management,repositoryId:o,requestWithStepUp:s,disabled:n,onChanged:c,onAuthorize:a,authorizeDisabled:!r}),i?O(`div`,{className:`flex basis-full flex-wrap items-center gap-x-4 gap-y-2 rounded-md bg-po-bg px-4 py-3`,children:[O(`span`,{className:`min-w-0 flex-1 text-base leading-relaxed text-po-text`,children:[`Start a short OAuth sign-in for `,t.name,`? A passkey may be required.`]}),O(Ie,{children:[D(e,{variant:`primary`,size:`sm`,disabled:n,onClick:l,children:`Continue`}),D(e,{variant:`ghost`,size:`sm`,onClick:u,children:`Cancel`})]})]}):null,O(`details`,{className:`group basis-full`,children:[O(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1 text-base font-medium text-po-text hover:text-po-hi [&::-webkit-details-marker]:hidden`,children:[D(ne,{"aria-hidden":!0,className:`size-3.5 transition-transform group-open:rotate-90`}),d===1?`1 tool`:`${String(d)} tools`,`, `,t.source]}),D(`ul`,{className:`mt-3 flex flex-col gap-1.5 border-l border-po-border-soft pl-4`,children:d===0?D(`li`,{className:`text-sm text-po-dim`,children:`Run discovery to see what this server offers.`}):t.tools.map(e=>O(`li`,{className:`flex min-w-0 items-baseline gap-3 text-base`,children:[D(`code`,{title:e.piName,className:`min-w-0 shrink-0 truncate font-mono text-po-hi`,children:e.piName}),D(`span`,{className:`min-w-0 truncate text-po-dim`,children:e.description??``})]},e.piName))})]})]})})}function vy({repository:t,request:n,requestWithStepUp:r}){let i=ve(iy),[a,o]=E(),c=_e(null),[l,d]=E(!1),[f,p]=E(),m=t?.id;T(()=>{d(!1),p(void 0),o(void 0),m&&sy(n,m)},[m,n]);let g=i.repositoryId===m?i.authorization:void 0,_=g?.id,v=g?.status;if(T(()=>{if(m&&_!==void 0&&!(v!==void 0&&fy.has(v)))return uy(n,m,_,()=>{sy(n,m)})},[_,v,m,n]),!t)return D(fe,{"data-testid":`mcp-repository-settings`,children:D(ge,{children:O(Le,{children:[D(Ve,{children:`No repository picked`}),D(w,{children:`Pick a repository above to see its MCP servers.`})]})})});let y=i.repositoryId===t.id?i.catalog:void 0,b=i.repositoryId===t.id?i.busy:void 0,ee=i.repositoryId===t.id?i.error:void 0,te=y?.sync.fresh===!0,x=y?.servers??[],S=y?.droppedServers??[];return O(`div`,{className:`flex min-w-0 flex-col gap-10`,"data-testid":`mcp-repository-settings`,children:[O(le,{children:[D(s,{children:D(Re,{children:`Catalog`})}),O(fe,{children:[O(ge,{children:[O(Le,{children:[D(Ve,{children:te?`Up to date`:y?`Needs a sync`:`Reading the catalog`}),D(w,{children:te?`Po reads the cached catalog on this machine. Discovery contacts each configured server.`:y?gy(y.sync.reasons):`Reading what the last sync recorded.`})]}),D(Jv,{scope:`repository`,repositoryId:t.id,targets:y?.targets,existingNames:x.map(e=>e.name),requestWithStepUp:r,disabled:b!==void 0,onAdded:()=>void sy(n,t.id),onCloseAutoFocus:e=>{e.preventDefault(),c.current?.focus()},renderTrigger:r=>O(u,{children:[D(pe,{asChild:!0,children:D(e,{ref:c,variant:`ghost`,size:`icon`,"aria-label":`Catalog actions`,title:`Catalog actions`,disabled:b!==void 0,children:D(ze,{"aria-hidden":!0,className:`size-4`})})}),O(h,{align:`end`,children:[D(je,{disabled:b!==void 0,onSelect:()=>void sy(n,t.id),children:`Refresh`}),D(je,{disabled:b!==void 0||!te||l,onSelect:()=>d(!0),children:`Discover servers`}),D(je,{disabled:b!==void 0,onSelect:r,children:`Add server`})]})]})})]}),l?O(ge,{children:[O(Le,{children:[D(Ve,{children:`Discover servers now?`}),D(w,{children:`Discovery starts the configured processes and contacts remote MCP servers.`})]}),O(Ie,{children:[D(e,{variant:`primary`,size:`sm`,disabled:b!==void 0,onClick:()=>{d(!1),cy(r,t.id)},children:`Discover`}),D(e,{variant:`ghost`,size:`sm`,onClick:()=>d(!1),children:`Cancel`})]})]}):null,ee===void 0?null:O(ge,{role:`alert`,children:[O(Le,{children:[D(Ve,{children:`Po couldn't finish that just now`}),D(w,{children:ee})]}),D(e,{variant:`outline`,size:`sm`,disabled:b!==void 0,onClick:()=>void sy(n,t.id),children:`Try again`})]})]})]}),g?O(le,{children:[D(s,{children:D(Re,{children:`Sign-in`})}),D(fe,{children:O(ge,{children:[O(Le,{children:[D(Ve,{className:`font-mono first-letter:normal-case`,children:g.serverName}),D(w,{children:hy[g.status]}),g.error?D(w,{className:`text-po-red`,children:g.error}):null]}),O(Ie,{children:[g.authorizationUrl?D(e,{variant:`primary`,size:`sm`,asChild:!0,children:O(`a`,{href:g.authorizationUrl,target:`_blank`,rel:`noreferrer noopener`,children:[`Open sign-in page`,D(ye,{"aria-hidden":!0,className:`size-3.5`})]})}):null,fy.has(g.status)?null:D(e,{variant:`ghost`,size:`sm`,loading:b===`cancelling`,disabled:b!==void 0,onClick:()=>void dy(r,t.id,g.id),children:`Cancel`})]})]})})]}):null,O(le,{children:[a?D(`output`,{className:`text-sm text-po-dim`,children:a}):null,O(s,{children:[D(Re,{children:`Servers`}),x.length===0?null:D(`span`,{className:`text-sm text-po-dim`,children:x.length===1?`1 server`:`${String(x.length)} servers`})]}),D(fe,{asChild:!0,children:D(`ul`,{children:x.length===0?D(ge,{asChild:!0,children:D(`li`,{children:O(Le,{children:[D(Ve,{children:b===`loading`?`Reading the catalog`:`No servers yet`}),D(w,{children:b===`loading`?`This takes a moment.`:`None are enabled in this repository's last sync.`})]})})}):x.map(e=>D(_y,{server:e,repositoryId:t.id,requestWithStepUp:r,onChanged:(e,r)=>{o(e),sy(n,t.id).then(()=>{r&&c.current?.focus()})},busy:b!==void 0,canAct:te,confirming:f===e.name,onAuthorize:()=>p(e.name),onConfirm:()=>{p(void 0),ly(r,t.id,e.name)},onCancel:()=>p(void 0)},e.name))})}),S.length===0?null:D(De,{children:`Left out by policy: ${S.join(`, `)}.`}),y?.diagnostics.map(e=>D(De,{className:`text-po-red`,children:e},e))]})]})}var yy=c({label:`MCP servers`,detail:`The MCP servers this repository's sessions can use, what each one offers, and where to sign in.`,order:100,component:vy});function by(e,t,n){e(t,{type:`prompt`,message:`/mcp auth ${n}`})}function xy(e,t,n){e(t,{type:`prompt`,message:`/mcp disconnect ${n}`})}function Sy(e,t,n){e(t,{type:`prompt`,message:`/mcp unauthorize ${n}`})}function Cy(e,t,n){e(t,{type:`prompt`,message:`/mcp approve ${n?`on`:`off`}`})}async function wy(e,t){let n=await hv.session(e).sessionSecret({body:t});return n.ok?{ok:!0}:n.status===0?{ok:!1,error:`The session is unreachable.`}:{ok:!1,error:n.error===``?`Po could not save that secret.`:n.error}}function Ty({server:t,name:n,disabled:r=!1,pending:i=!1,error:a,onSubmit:o}){let[s,c]=E(``),l=`mcp-secret-${t}-${n}`,u=`${l}-hint`;return O(`form`,{"data-testid":`context-mcp-secret-${t}-${n}`,className:`flex flex-col gap-1.5 rounded-md border border-po-edge-magenta bg-po-tint-magenta px-2.5 py-2`,onSubmit:e=>{e.preventDefault(),!(s===``||r||i)&&(o(s),c(``))},children:[O(`label`,{htmlFor:l,className:`text-sm text-po-text`,children:[D(`span`,{className:`font-semibold text-po-magenta`,children:`Needs secret`}),` `,D(`span`,{className:`font-mono text-po-hi`,children:n})]}),O(`div`,{className:`flex min-w-0 items-center gap-2`,children:[D(Ae,{id:l,type:`password`,size:`xs`,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1`,value:s,placeholder:`Paste the value`,"aria-describedby":u,"aria-invalid":a!==void 0,disabled:r||i,onChange:e=>c(e.target.value)}),D(e,{type:`submit`,variant:`outline`,size:`xs`,disabled:s===``||r||i,children:i?`saving...`:`save`})]}),D(`p`,{id:u,className:`text-sm ${a?`text-po-red`:`text-po-dim`}`,children:a??`Po keeps it in the vault, never shows it again, and reconnects ${t}.`})]})}var Ey=`mcp-session-auto-approve`,Dy=`mcp-session-auto-approve-help`;function Oy({status:e,disabled:t,onCheckedChange:n}){return D(`section`,{"data-testid":`context-mcp-approval`,className:`flex flex-col gap-2 border-b border-po-border px-3 py-3`,children:O(`div`,{className:`flex min-w-0 items-start gap-3 px-1`,children:[O(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[D(`label`,{htmlFor:Ey,className:`text-sm font-semibold text-po-hi`,children:`Run tools that change data without asking`}),D(`p`,{id:Dy,className:`text-sm leading-relaxed text-po-dim`,children:e.host?`On for every session in MCP settings. Turn it off there to be asked again.`:e.session?`This session only. It stays on when the session restarts.`:`Po asks before each one, here and on Home. Read-only tools run straight away.`})]}),D(Ue,{id:Ey,"data-testid":`context-mcp-approval-switch`,"aria-describedby":Dy,checked:e.host||e.session,disabled:t||e.host,onCheckedChange:n})]})})}async function ky(e,t,n){let r=await hv.session(e).sessionTool({query:{[G_]:t,[K_]:n}});return r.ok?{ok:!0,detail:r.data}:r.status===0?{ok:!1,error:`The session is unreachable.`}:{ok:!1,error:r.error===``?`The session answered ${r.status}.`:r.error}}function Ay(e){return`${e.sessionId}\u0000${e.server}\u0000${e.tool}`}function jy({target:e,onClose:t}){let[n,i]=E(null);T(()=>{if(e===null)return;let t=!0,n=Ay(e);return ky(e.sessionId,e.server,e.tool).then(e=>{t&&i(e.ok?{key:n,detail:e.detail}:{key:n,error:e.error})}),()=>{t=!1}},[e]);let a=e!==null&&n?.key===Ay(e)?n:null,o=a?.detail;return D(l,{open:e!==null,onOpenChange:e=>{e||t()},children:O(g,{"data-testid":`mcp-tool-detail-dialog`,children:[D(r,{className:`items-start px-4 py-4 sm:px-5`,children:O(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[D(re,{className:`break-words leading-snug`,children:o?.piName??e?.piName??(e===null?``:`${e.server} · ${e.tool}`)}),O(x,{children:[e===null?``:`${e.server} / ${e.tool}. `,e?.inContext===!1?`Not in the model context. `:``,o===void 0?`Description and complete input schema.`:`Estimated schema cost: ~${o.tokens.toLocaleString()} tokens.`]})]})}),O(p,{className:`flex flex-col gap-3 px-4 py-4 sm:px-5 sm:py-5`,children:[a===null?D(`output`,{className:`text-sm text-po-dim`,children:`Loading the tool...`}):null,a?.error===void 0?null:D(`output`,{className:`text-sm text-po-dim`,children:a.error}),o===void 0?null:O(se,{children:[O(`section`,{className:`flex flex-col gap-1`,children:[D(`p`,{className:`text-sm font-semibold text-po-dim`,children:`description`}),D(`p`,{className:`whitespace-pre-wrap text-base text-po-text`,children:o.description??`No description.`})]}),o.warnings?.length?D(`section`,{"aria-label":`Tool warnings`,className:`flex flex-col gap-1 text-base text-po-yellow`,children:o.warnings.map(e=>O(`p`,{children:[e.source,` `,e.path,`: `,e.message]},`${e.source}:${e.path}:${e.message}`))}):null,O(`section`,{className:`flex min-h-0 flex-col gap-1`,children:[D(`p`,{className:`text-sm font-semibold text-po-dim`,children:`input schema`}),D(`pre`,{"data-testid":`mcp-tool-detail-schema`,className:`max-h-96 overflow-auto rounded border border-po-border-soft p-2 font-mono text-sm text-po-text`,children:JSON.stringify(o.inputSchema,null,2)})]})]})]})]})})}function My(e,t,n){return`${e}\u0000${t}\u0000${n}`}function Ny(e){return e===null?`-`:`~${e.toLocaleString()}`}function Py({sessionId:t,statuses:n,sendSessionFrame:i,contextInventory:a=[]}){let o=J_(n[`po-mcp-session-auth`])??[],s=P_(n[N_]),[c,d]=E(null),[f,m]=E(null),_=_e(null),[v,y]=E(``),[b,ee]=E(!1),[te,S]=E(null),[ne,ie]=E({}),ae=_e(null),oe=_e(void 0),C=c?.sessionId===t?c:null,w=o.find(e=>e.name===C?.name),ce=w?.authorizationUrl,le=f?.sessionId===t?o.find(e=>e.name===f.name):void 0,ue=()=>{ae.current?.close(),ae.current=null};T(()=>{let e=ae.current;C&&ce&&e&&!e.closed&&(e.location.replace(ce),ae.current=null)},[C,ce]),T(()=>()=>{ae.current?.close(),ae.current=null},[t]),T(()=>{let e=w?.state;e!==oe.current&&(oe.current=e,(e===`failed`||e===`closed`||e===`connected`)&&(ae.current?.close(),ae.current=null))},[w?.state]);let de=e=>{if(t===null)return;let n=o.find(t=>t.name===e);if(oe.current=n?.state,!n||n.state===`disabled`||!(n.oauthEligible||n.state===`needs-auth`||n.authorizationUrl))return;ue(),d({sessionId:t,name:e}),y(``);let r=window.open(`about:blank`,`_blank`);ee(r===null),r&&(r.opener=null,n?.authorizationUrl?r.location.replace(n.authorizationUrl):(r.document.title=`MCP authorization`,r.document.body.textContent=`Preparing authorization. Return to Po for progress or manual sign-in.`,ae.current=r)),!n?.authorizationUrl&&n?.state!==`connecting`&&by(i,t,e)},fe=(e,n,r)=>{if(t===null)return;let i=My(t,e,n);ie(e=>({...e,[i]:{pending:!0}})),wy(t,{server:e,name:n,value:r}).then(e=>{ie(t=>({...t,[i]:e.ok?{pending:!1}:{pending:!1,error:e.error}}))})},me=async()=>{if(ce)try{await navigator.clipboard.writeText(ce),y(`Link copied.`)}catch{y(`Clipboard unavailable. Select the link above and copy it manually.`)}};return O(se,{children:[o.length===0?null:O(`section`,{"data-testid":`context-mcp-auth`,className:`flex flex-col gap-2 border-b border-po-border px-3 py-3`,children:[O(`div`,{className:`flex flex-col gap-0.5`,children:[D(`p`,{className:`text-sm font-semibold text-po-dim`,children:`MCP servers`}),D(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Open sign-in in a new tab, or copy the link from the authorization dialog.`})]}),D(`ul`,{"aria-label":`MCP servers`,className:`flex flex-col gap-2`,children:o.map(n=>{let r=a.filter(e=>e.source===`mcp`&&e.owner===n.name),o=n.tools??[],s=n.missingSecrets??[],c=s.length>0&&n.state!==`connected`;return O(`li`,{className:`flex min-w-0 flex-col gap-1 px-1 py-0.5`,children:[O(`div`,{className:`flex min-w-0 items-center gap-2`,children:[D(`span`,{className:`min-w-0 flex-1 truncate text-base font-semibold text-po-hi`,children:n.name}),c?D(`span`,{className:`text-sm font-semibold text-po-magenta`,children:`needs secret`}):D(`span`,{className:`text-sm font-semibold text-po-dim`,children:n.state.replace(/-/g,` `)}),n.oauthAuthorized===!0&&n.state===`connected`?O(`span`,{className:`flex items-center gap-1 text-sm text-po-green`,children:[D(Ee,{"aria-hidden":!0,className:`size-4`}),` Authorized`]}):null,!c&&n.state===`needs-auth`?D(e,{variant:`subtle`,size:`xs`,"aria-label":`Authorize ${n.name}`,disabled:t===null,onFocus:e=>{_.current=e.currentTarget},onClick:()=>de(n.name),children:`Authorize`}):null,c?null:O(u,{children:[D(pe,{asChild:!0,children:D(e,{variant:`ghost`,size:`icon`,"aria-label":`Actions for ${n.name}`,disabled:t===null||n.state===`disabled`,onPointerDownCapture:e=>{_.current=e.currentTarget},onFocus:e=>{_.current=e.currentTarget},children:D(ze,{"aria-hidden":!0,className:`size-4`})})}),O(h,{align:`end`,children:[n.oauthEligible||n.state===`needs-auth`||n.authorizationUrl?D(je,{onSelect:()=>de(n.name),children:n.oauthAuthorized?`Reauthorize`:`Authorize`}):null,n.oauthEligible&&n.oauthAuthorized?D(je,{onSelect:()=>{t!==null&&m({sessionId:t,name:n.name})},children:`Unauthorize`}):null,n.state===`connected`?D(je,{onSelect:()=>{t!==null&&xy(i,t,n.name)},children:`Disconnect`}):null,!(n.oauthEligible||n.state===`needs-auth`||n.authorizationUrl)&&n.state!==`connected`?D(je,{disabled:!0,children:`Authorization unavailable`}):null]})]})]}),(c?s:[]).map(e=>{let r=t===null?void 0:ne[My(t,n.name,e)];return D(Ty,{server:n.name,name:e,disabled:t===null,pending:r?.pending??!1,...r?.error?{error:r.error}:{},onSubmit:t=>fe(n.name,e,t)},e)}),r.length>0?D(`ul`,{"aria-label":`${n.name} tools and skills`,className:`flex flex-col`,children:r.map(r=>{let i=o.find(e=>e.piName===r.name);return O(`li`,{"data-active":r.active,className:`flex min-w-0 items-center gap-2 py-px pl-3`,children:[D(`abbr`,{title:r.itemKind,className:`w-3 shrink-0 text-2xs font-semibold no-underline ${r.active?`text-po-violet`:`text-po-dim`}`,children:r.itemKind===`skill`?`S`:`T`}),r.itemKind===`tool`?D(e,{variant:`ghost`,size:`card`,"aria-label":`Open schema for ${r.name}`,"data-testid":`context-mcp-tool-${r.name}`,disabled:t===null||i===void 0,onClick:()=>{t!==null&&i!==void 0&&S({sessionId:t,server:n.name,tool:i.name,piName:i.piName,inContext:r.active})},className:`min-w-0 flex-1 truncate rounded-none py-0 text-left text-base ${r.active?`text-po-hi`:`text-po-dim`}`,children:r.name}):D(`span`,{className:`min-w-0 flex-1 truncate text-base text-po-dim`,children:r.name}),D(`span`,{className:`w-14 shrink-0 text-right text-sm ${r.active?`text-po-text`:`text-po-dim`}`,children:r.active?Ny(r.tokens):`(${Ny(r.tokens)})`})]},`${r.itemKind}:${r.name}`)})}):o.length>0?O(`div`,{className:`flex flex-col`,children:[D(`p`,{className:`pl-3 text-sm text-po-dim`,children:`${o.length} available ${o.length===1?`tool`:`tools`}, not in context`}),D(`ul`,{"aria-label":`${n.name} reachable tools`,className:`flex flex-col`,children:o.map(r=>D(`li`,{className:`flex min-w-0`,children:O(e,{variant:`ghost`,size:`card`,"data-testid":`context-mcp-reachable-${n.name}-${r.name}`,title:`open the tool's description and schema`,disabled:t===null,onClick:()=>{t!==null&&S({sessionId:t,server:n.name,tool:r.name,piName:r.piName,inContext:!1})},className:`min-w-0 flex-1 flex-row items-center gap-2 rounded-none py-px pr-0 pl-3`,children:[D(`abbr`,{title:`tool`,className:`w-3 shrink-0 text-2xs font-semibold text-po-violet no-underline`,children:`T`}),D(`span`,{className:`min-w-0 flex-1 truncate text-left text-base text-po-text`,children:r.piName??r.name}),D(`span`,{title:`what the schema would cost if added to context directly`,className:`w-14 shrink-0 text-right text-sm text-po-dim`,children:r.tokens===void 0?`(-)`:`(~${r.tokens.toLocaleString()})`})]})},r.name))})]}):c?null:D(`p`,{className:`pl-3 text-sm text-po-dim`,children:`no tools or skills reported`})]},n.name)})})]}),o.length===0||s===void 0?null:D(Oy,{status:s,disabled:t===null,onCheckedChange:e=>{t!==null&&Cy(i,t,e)}}),D(jy,{target:te,onClose:()=>S(null)}),D(l,{open:le!==void 0,onOpenChange:e=>{e||m(null)},children:O(g,{onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:[D(r,{dismissible:!0,children:O(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[O(re,{children:[`Unauthorize `,f?.name,`?`]}),D(x,{children:`Disconnect this session and clear the saved authorization. The server stays configured.`})]})}),D(p,{children:D(`p`,{className:`text-base leading-relaxed text-po-dim`,children:`The saved credential is shared. Other sessions stay connected, but may need to sign in again when they reconnect. This does not revoke access at the provider.`})}),O(He,{className:`border-t border-po-border-soft px-4 py-3`,children:[D(e,{variant:`ghost`,onClick:()=>m(null),children:`Cancel`}),D(e,{variant:`danger`,disabled:!le?.oauthEligible,onClick:()=>{f&&le?.oauthEligible&&f.sessionId===t&&(Sy(i,f.sessionId,f.name),m(null))},children:`Unauthorize`})]})]})}),D(l,{open:C!==null,onOpenChange:e=>{e||(ue(),d(null))},children:O(g,{"data-testid":`mcp-authorization-dialog`,onInteractOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:[D(r,{className:`items-start px-4 py-4 sm:px-5`,children:O(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[O(re,{className:`break-words leading-snug`,children:[w?.oauthAuthorized?`Authorized`:`Authorize`,` `,C?.name]}),D(x,{className:`max-w-2xl`,children:w?.oauthAuthorized?`You can now use this server in Po.`:`Finish signing in in the provider tab Po opened. If it did not open, use the link below.`})]})}),O(p,{className:`px-4 py-4 sm:px-5 sm:py-5`,children:[D(`output`,{className:`text-sm text-po-dim`,children:w?.oauthAuthorized?`Authorization complete.`:w?.state===`connected`?`Connected. OAuth authorization has not been confirmed.`:w?.state===`closed`?`Disconnected from this session.`:ce?`Waiting for you to complete authorization.`:w?.state===`failed`?`Connection failed. Retry authorization; details are in the session transcript.`:w?`Preparing the authorization link...`:`This server is no longer available in the session.`}),b?D(`p`,{className:`text-sm text-po-dim`,children:`The browser blocked the new tab. Open the link below when it is ready.`}):null,ce?O(`div`,{className:`flex flex-col gap-2`,children:[D(Ae,{"aria-label":`OAuth authorization URL`,readOnly:!0,value:ce,onFocus:e=>e.currentTarget.select()}),D(`a`,{href:ce,target:`_blank`,rel:`noopener noreferrer`,className:`text-base font-medium text-po-blue underline underline-offset-2`,children:`open authorization page`}),D(e,{variant:`outline`,size:`xs`,onClick:()=>void me(),children:`copy link`})]}):null,v?D(`output`,{className:`text-sm text-po-dim`,children:v}):null]}),O(He,{className:`flex-wrap justify-end border-t border-po-border-soft px-4 py-3 sm:px-5`,children:[w?.state===`connected`&&C?D(e,{variant:`outline`,size:`md`,onClick:()=>{ue(),y(``),ee(!1),xy(i,C.sessionId,C.name)},children:`disconnect`}):null,(w?.state===`failed`||w?.state===`closed`)&&w.oauthEligible&&C?D(e,{size:`md`,onClick:()=>de(C.name),children:w.state===`failed`?`retry authorization`:`reauthorize`}):null,D(e,{variant:`ghost`,size:`md`,onClick:()=>{ue(),d(null)},children:`close`})]})]})})]})}var Fy=o({component:Py}),Iy=we({runtime:null});function Ly(e){let t=e.mount;if(t?.scope!==`session`)throw Error(`MCP Apps require a session runtime mount`);return Iy.update(t.sessionId,()=>({runtime:e})),()=>{Iy.select(Iy.store.state,t.sessionId).runtime===e&&Iy.drop(t.sessionId)}}var Ry=320;function zy(){let e=document.documentElement.style.colorScheme;return e===`light`||e===`dark`?e:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function By(e){return e instanceof Error?e.message:`The MCP App could not complete this request`}function Vy(e,t,n,r){return e.invokeServerMethod({mount:{scope:`session`,sessionId:t},service:`mcp.apps`,method:n,input:r})}async function Hy(e){if(typeof e!=`string`)throw Error(`Invalid external link`);let t=new URL(e);if(t.protocol!==`https:`||t.username||t.password)throw Error(`Only HTTPS external links are supported`);if(!window.confirm(`Open this external link?\n${t.href}`))throw Error(`Opening the link was declined`);let n=window.open(t.href,`_blank`,`noopener,noreferrer`);return n!==null&&(n.opener=null),{}}function Uy({runtime:e,sessionId:t,toolCallId:n,data:r,savedState:i,saveState:a,onClose:o}){let s=_e(null),[c,l]=E(Ry),[u,d]=E(null),[f,p]=E(!1),[m]=E(()=>i);return T(()=>{let i=s.current;if(i===null||i.contentWindow===null)return;let c=M_(i,{data:r,toolCallId:n,savedState:m,request:(n,i)=>Vy(e,t,n,{...i,leaseId:r.leaseId}),openLink:Hy,theme:zy(),locale:navigator.language,device:window.matchMedia(`(pointer: coarse)`).matches?`mobile`:`desktop`,hover:window.matchMedia(`(hover: hover)`).matches,touch:navigator.maxTouchPoints>0,hostOrigin:location.origin,resize:l,ready:()=>p(!0),fail:d,close:o,saveState:a}),u=new MutationObserver(()=>c.setTheme(zy()));return u.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`style`]}),()=>{u.disconnect(),c.dispose()}},[e,t,n,r,m,a,o]),O(`div`,{className:`overflow-hidden rounded border border-po-border-soft`,"data-testid":`mcp-inline-app`,children:[u===null?null:D(`p`,{role:`alert`,className:`p-3 text-po-dim`,children:u}),!f&&u===null?D(`output`,{className:`p-3 text-po-faint`,children:`Loading MCP App…`}):null,D(`iframe`,{ref:s,title:`${r.tool.name} MCP App`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,allow:`camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'`,className:u===null?`block w-full border-0`:`hidden`,style:{height:c}})]})}function Wy({sessionId:e,toolCallId:t}){let n=ve(Iy.store,t=>Iy.select(t,e).runtime),[r,i]=E(null),[a,o]=E(null),[s,c]=E(!1),[l,u]=E(null),[d,f]=E(!1),[p,m]=E(null),h=Te(e=>m(e),[]),g=Te(()=>f(!0),[]);return T(()=>{if(n===null||e===null||!et(document))return;let r=!0,a;return Vy(n,e,`open`,{toolCallId:t}).then(t=>{let o=t;if(a=o.leaseId,!r)return Vy(n,e,`close`,{leaseId:a});m(o.state),i(o)}).catch(e=>{r&&o(By(e))}),()=>{r=!1,a!==void 0&&Vy(n,e,`close`,{leaseId:a}).catch(e=>o(By(e)))}},[n,e,t]),d?D(`p`,{className:`text-po-faint`,children:`MCP App closed. Expand the card to view the tool result.`}):et(document)?a===null?n===null||e===null?D(`p`,{className:`text-po-faint`,children:`The interactive MCP App is unavailable in this view. Expand the card to view the tool result.`}):r===null?D(`output`,{className:`text-po-faint`,children:`Loading MCP App…`}):O(`div`,{className:`flex flex-col gap-2`,children:[O(`div`,{className:`flex items-center justify-between gap-2 text-po-faint`,children:[D(`span`,{children:r.readOnly?`Read-only MCP App`:`MCP App interactions enabled`}),r.readOnly?D(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),u(null),Vy(n,e,`activate`,{leaseId:r.leaseId}).then(()=>{i({...r,readOnly:!1})}).catch(e=>u(By(e))).finally(()=>c(!1))},className:`rounded border border-po-border-soft px-2 py-1 text-po-blue disabled:opacity-50`,children:s?`Enabling…`:`Enable interactions`}):null]}),l===null?null:D(`p`,{role:`alert`,className:`text-po-dim`,children:l}),D(Uy,{runtime:n,sessionId:e,toolCallId:t,data:r,savedState:p,saveState:h,onClose:g},`${r.leaseId}-${String(r.readOnly)}`)]}):O(`p`,{role:`alert`,className:`text-po-dim`,children:[`MCP App unavailable: `,a]}):D(`p`,{className:`text-po-faint`,children:`This browser cannot securely display MCP Apps. Expand the card to view the tool result.`})}var Gy=m(e=>{let t=Ly(e),n=e.mount?.scope===`session`?e.mount.sessionId:null,r=e.registerMcpAppRenderer?.(({key:e,toolCallId:t})=>ue(Wy,{key:e,sessionId:n,toolCallId:t}));return()=>{r?.(),t()}}),Ky=`po-mcp`,qy=`,`,Jy=`_`,Yy=3,Xy=12;function Zy(e){let t=e[Ky];return t===void 0?[]:t.split(qy).map(e=>e.trim()).filter(e=>e.length>0)}function Qy(e,t){let n=null;for(let r of Zy(t)){let t=`${r}${Jy}`;e.startsWith(t)&&e.length!==t.length&&(n===null||r.length>n.server.length)&&(n={server:r,tool:e.slice(t.length)})}return n}function $y(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.server!=`string`||typeof t.tool!=`string`?null:{server:t.server,tool:t.tool}}function eb(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):e===null?`null`:Array.isArray(e)?`[${e.length}]`:`{…}`}function tb(e){let t=Object.entries(e),n=t.slice(0,Yy).map(([e,t])=>`${e}=${eb(t)}`);return t.length>n.length&&n.push(`+${t.length-n.length}`),n.join(` · `)}function nb(e){let t=e.output.split(`
108
+ `);for(;t.length>0&&t.at(-1)?.trim()===``;)t.pop();let n=e.expanded?t:t.slice(0,Xy);return e.isPartial?{lines:n,status:{glyph:`◐`,tone:`running`,text:`running`}}:e.isError?{lines:n,status:{glyph:`✗`,tone:`error`,text:`failed`}}:!e.expanded&&t.length>n.length?{lines:n,status:{glyph:`…`,tone:`hint`,text:`${t.length-n.length} more line(s)`}}:n.length===0?{lines:n,status:{glyph:`✓`,tone:`ok`,text:`done`}}:{lines:n,status:null}}function rb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ib=512;function ab(e,t){let n=rb(e)?e.appInvocation:void 0;return typeof n==`string`&&n.length>0&&n.length<=ib?n:t}function ob(e){if(!rb(e))return null;let t=t=>typeof e[t]==`string`?e[t]:void 0;switch(e.type){case`audio`:{let e=t(`data`),n=t(`mimeType`);return e!==void 0&&n!==void 0?{type:`audio`,data:e,mimeType:n}:null}case`resource_link`:{let e=t(`uri`),n=t(`name`);if(e===void 0||n===void 0)return null;let r=t(`title`),i=t(`description`),a=t(`mimeType`);return{type:`resource_link`,uri:e,name:n,...r===void 0?{}:{title:r},...i===void 0?{}:{description:i},...a===void 0?{}:{mimeType:a}}}case`resource`:{let e=t(`uri`);if(e===void 0)return null;let n=t(`mimeType`),r=t(`text`),i=t(`blob`);return{type:`resource`,uri:e,...n===void 0?{}:{mimeType:n},...r===void 0?{}:{text:r},...i===void 0?{}:{blob:i}}}case`structured`:return rb(e.value)?{type:`structured`,value:e.value}:null;default:return null}}function sb(e){return!rb(e)||!Array.isArray(e.blocks)?[]:e.blocks.flatMap(e=>{let t=ob(e);return t===null?[]:[t]})}function cb(e){return e.flatMap(e=>!rb(e)||e.type!==`image`?[]:typeof e.data==`string`&&typeof e.mimeType==`string`?[{data:e.data,mimeType:e.mimeType}]:[])}var lb={running:`running`,ok:`ok`,error:`error`,hint:`neutral`};function ub(e){let t=e.indexOf(`_`);return t<=0?{server:e,tool:``}:{server:e.slice(0,t),tool:e.slice(t+1)}}function db({block:e}){switch(e.type){case`resource_link`:return D(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,"data-testid":`tool-result-mcp-link`,className:`truncate text-po-blue hover:underline`,title:e.description??e.uri,children:e.title??e.name});case`resource`:return e.text===void 0?O(`span`,{"data-testid":`tool-result-mcp-resource`,className:`truncate text-po-dim`,children:[`binary `,e.mimeType??`resource`,` · `,e.uri]}):D(ie,{"data-testid":`tool-result-mcp-resource`,className:`text-po-dim`,text:e.text});case`structured`:return D(ie,{"data-testid":`tool-result-mcp-structured`,className:`text-po-dim`,grammar:`json`,text:JSON.stringify(e.value,null,2)});case`audio`:return O(`span`,{"data-testid":`tool-result-mcp-audio`,className:`text-po-dim`,children:[`audio · `,e.mimeType]})}}function fb({sessionId:e,toolCallId:t,toolName:n,args:r,result:i,output:o,running:s,isError:c,statuses:l,suppressOutputs:u,renderMcpApp:d}){let f=$y(i?.details)??Qy(n,l)??ub(n),p=tb(r),m=cb(i?.content??[]),h=sb(i?.details),g=i?.details,_=!s&&typeof g==`object`&&g&&`app`in g?g.app:void 0,ee=typeof _==`object`&&!!_&&`version`in _&&_.version===1&&`resourceUri`in _&&typeof _.resourceUri==`string`,te=ab(g,t),x=Object.keys(r).length>0,S=nb({output:o,expanded:!0,isPartial:s,isError:c}),ne=S.status?.tone===`hint`,re=S.lines.length>0||S.status!==null||m.length>0||h.length>0;return D(xe,{tone:a({running:s,isError:c}),expandable:x||re,children:({expanded:t})=>O(se,{children:[D(y,{title:`mcp`,children:O(`span`,{"data-testid":`tool-call-mcp`,className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[D(`span`,{className:`shrink-0 text-po-dim`,children:f.server}),D(`span`,{className:`shrink-0 text-po-faint`,children:`/`}),D(`span`,{className:`shrink-0 text-po-blue`,children:f.tool}),p?O(`span`,{className:`min-w-0 flex-1 truncate text-po-dim`,children:[`· `,p]}):null]})}),ee&&!u?D(v,{children:d?d({key:`${e}:${te}`,toolCallId:te}):D(Wy,{sessionId:e,toolCallId:te},`${e}:${te}`)}):null,t&&x?O(v,{"data-testid":`tool-input-mcp`,className:`flex flex-col gap-1`,children:[D(`span`,{className:`text-sm text-po-dim`,children:`Input`}),D(ie,{className:`text-po-dim`,grammar:`json`,text:JSON.stringify(r,null,2)})]}):null,t&&re?O(v,{"data-testid":`tool-result-mcp`,"data-mcp-server":f.server,className:`flex flex-col gap-1`,children:[x?D(`span`,{className:`text-sm text-po-dim`,children:`Output`}):null,S.lines.length>0?D(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-po-dim`,children:S.lines.join(`
109
+ `)}):null,!u&&m.map((e,t)=>D(Fe,{"data-testid":`tool-result-mcp-image`,src:`data:${e.mimeType};base64,${e.data}`,alt:`${f.tool} result ${String(t+1)}`,className:`max-h-60 max-w-full rounded border border-po-border-soft`},`${String(t)}-${e.mimeType}`)),!u&&h.map((e,t)=>D(db,{block:e},`${String(t)}-${e.type}`)),S.status?D(b,{"data-testid":`tool-result-mcp-status`,tone:lb[S.status.tone],glyph:S.status.glyph,expands:ne,children:S.status.text}):null]}):null]})})}function pb(e){let{result:t,running:n,toolCallId:r,toolName:i,sessionId:a,renderMcpApp:o}=e,s=t?.details,c=!n&&typeof s==`object`&&s&&`app`in s?s.app:void 0,l=[];if(typeof c==`object`&&c&&`version`in c&&c.version===1&&`resourceUri`in c&&typeof c.resourceUri==`string`){let e=ab(s,r);l.push({id:`app`,title:`${i} MCP App`,content:o?o({key:`${a}:${e}`,toolCallId:e}):D(Wy,{sessionId:a,toolCallId:e},`${a}:${e}`)})}for(let[e,n]of(t?.content??[]).entries()){if(typeof n!=`object`||!n||!(`type`in n)||n.type!==`image`)continue;let t=cb([n])[0];l.push({id:`image:${String(e)}`,title:`${i} image ${String(e+1)}`,content:t?D(Fe,{src:`data:${t.mimeType};base64,${t.data}`,alt:`${i} result`}):null})}return sb(s).forEach((e,t)=>l.push({id:`block:${String(t)}`,title:`${i} ${e.type}`,content:D(db,{block:e})})),l}var mb=ee({tools:[],matches:(e,t,n)=>$y(n)!==null||Qy(e,t)!==null,message:fb,outputs:pb}),hb=(e,t)=>t===void 0?void 0:{...e,...t},gb=_({id:`mcp`,host:{get settingsPanels(){return[hb({id:`mcp-servers`},ry)]}},workspace:{get repositorySettingsPanel(){return yy}},session:{get fills(){return[hb({slot:`context`,id:`mcp-auth`},Fy)]},get start(){return Gy},get toolRenderers(){return[hb({tools:[`mcp`]},mb)]}}});export{gb as webPlugin};