@lobu/runtime-server 20.1.0 → 21.0.0

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 (260) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/connectors/README.md +15 -16
  3. package/dist/connectors/chat-user-identity.ts +41 -0
  4. package/dist/connectors/github.ts +15 -9
  5. package/dist/connectors/google-identity.ts +11 -0
  6. package/dist/connectors/google_calendar.ts +21 -31
  7. package/dist/connectors/google_drive.ts +106 -131
  8. package/dist/connectors/google_gmail.ts +53 -30
  9. package/dist/connectors/hackernews.ts +2 -5
  10. package/dist/connectors/jira.ts +62 -27
  11. package/dist/connectors/linear.ts +55 -21
  12. package/dist/connectors/microsoft_outlook.ts +151 -110
  13. package/dist/connectors/postgres.ts +19 -11
  14. package/dist/connectors/producthunt.ts +8 -6
  15. package/dist/connectors/reddit.ts +2 -2
  16. package/dist/connectors/rss.ts +2 -2
  17. package/dist/connectors/slack-identity.ts +19 -0
  18. package/dist/connectors/whatsapp_web.ts +5 -4
  19. package/dist/connectors/x.ts +32 -17
  20. package/dist/connectors/youtube.ts +18 -5
  21. package/dist/db/migrations/20260915030000_owner_dm_delivery_request_platform.sql +51 -0
  22. package/dist/db/migrations/20260917000000_views.sql +271 -0
  23. package/dist/db/migrations/20260917000001_views_attach_index.sql +14 -0
  24. package/dist/db/migrations/20260918000000_runs_turn_tool_event_uniq.sql +51 -0
  25. package/dist/db/migrations/20260923230000_runs_connector_artifact_hash.sql +32 -0
  26. package/dist/db/migrations/20260924000000_resource_source_files.sql +17 -0
  27. package/dist/dependencies.bun.lock +122 -113
  28. package/dist/guest.bundle.js +78 -10
  29. package/dist/owletto/dist/assets/_-CwFknmeA.js +1 -0
  30. package/dist/owletto/dist/assets/_-DrcppoWh.js +2 -0
  31. package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +1 -0
  32. package/dist/owletto/dist/assets/_agentId-HNcmgH56.js +1 -0
  33. package/dist/owletto/dist/assets/_automationId-BCfrLnUS.js +1 -0
  34. package/dist/owletto/dist/assets/{_connectorKey._connectionId-NQf43Ew3.js → _connectorKey._connectionId-126-iG9w.js} +1 -1
  35. package/dist/owletto/dist/assets/{_connectorKey.index-D-0ZNsgM.js → _connectorKey.index-CywE9A3N.js} +1 -1
  36. package/dist/owletto/dist/assets/_conversationId-CNETA_rY.js +1 -0
  37. package/dist/owletto/dist/assets/_deploymentId-CAVpXf8s.js +1 -0
  38. package/dist/owletto/dist/assets/_name-BP7OlVxL.js +1 -0
  39. package/dist/owletto/dist/assets/_owner-D2eh4R90.js +1 -0
  40. package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +1 -0
  41. package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +1 -0
  42. package/dist/owletto/dist/assets/_slug-DoIaJBbh.js +1 -0
  43. package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +1 -0
  44. package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +1 -0
  45. package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +1 -0
  46. package/dist/owletto/dist/assets/accept-invitation-BWRiEUsd.js +1 -0
  47. package/dist/owletto/dist/assets/activity-route-view-rVdTeVXN.js +1 -0
  48. package/dist/owletto/dist/assets/{agent-card-controls-VJgcB5-0.js → agent-card-controls-JubkhcHt.js} +1 -1
  49. package/dist/owletto/dist/assets/{agent-client-setup-list-C5KRNRw3.js → agent-client-setup-list-Btcy4Cu1.js} +1 -1
  50. package/dist/owletto/dist/assets/{agent-connect-pages-BFSb6vmW.js → agent-connect-pages-Chfqn8iL.js} +1 -1
  51. package/dist/owletto/dist/assets/{agent-editor-form-CajEehVn.js → agent-editor-form-BrOkwfg8.js} +1 -1
  52. package/dist/owletto/dist/assets/{agent-guardrails-route-CZ_rXj-3.js → agent-guardrails-route-CHM7JbIl.js} +1 -1
  53. package/dist/owletto/dist/assets/{agent-loading-shells-Dczhk067.js → agent-loading-shells-DsiGx1fn.js} +1 -1
  54. package/dist/owletto/dist/assets/{agent-permissions-matrix-DIVHvpZG.js → agent-permissions-matrix-L_gFvSu1.js} +1 -1
  55. package/dist/owletto/dist/assets/{agent-skill-context-CxglCznW.js → agent-skill-context-D7tOJ8Pb.js} +1 -1
  56. package/dist/owletto/dist/assets/{agent-skills-route-CatU8soC.js → agent-skills-route-AylS-B9v.js} +1 -1
  57. package/dist/owletto/dist/assets/{agent-subpage-shell-DVSUdIBn.js → agent-subpage-shell-B7tCQ9zd.js} +1 -1
  58. package/dist/owletto/dist/assets/agent-thread-DOYh7WLW.js +8 -0
  59. package/dist/owletto/dist/assets/agents-0ncYwbz6.js +1 -0
  60. package/dist/owletto/dist/assets/agents-workbench-DOwn78eL.js +1 -0
  61. package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +127 -0
  62. package/dist/owletto/dist/assets/{app._appId-BXmITXO7.js → app._appId-fJ_RRn1Z.js} +1 -1
  63. package/dist/owletto/dist/assets/automation-detail-content-CMprQht5.js +1 -0
  64. package/dist/owletto/dist/assets/automations-0ncYwbz6.js +1 -0
  65. package/dist/owletto/dist/assets/{calendar-taCoBmAh.js → calendar-BbD1N97u.js} +1 -1
  66. package/dist/owletto/dist/assets/{callback-CJxC8u_x.js → callback-PELM84Lh.js} +1 -1
  67. package/dist/owletto/dist/assets/{card-kpw3EaKC.js → card-DpLjEqIc.js} +1 -1
  68. package/dist/owletto/dist/assets/{claim-DLHRN0bA.js → claim-BLLvLOBM.js} +1 -1
  69. package/dist/owletto/dist/assets/clients-Bd8WpHSV.js +1 -0
  70. package/dist/owletto/dist/assets/{code-editor-D3X0yQdI.js → code-editor-DGJQDoHD.js} +1 -1
  71. package/dist/owletto/dist/assets/connect-Cx49f4J0.js +1 -0
  72. package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +1 -0
  73. package/dist/owletto/dist/assets/connected._clientId-BYGmFRCF.js +1 -0
  74. package/dist/owletto/dist/assets/{connection-DdBkXNbX.js → connection-B0O8OZuK.js} +1 -1
  75. package/dist/owletto/dist/assets/{connection-feed-detail-DF93zx0A.js → connection-feed-detail-DZjtoEfm.js} +1 -1
  76. package/dist/owletto/dist/assets/{connector-provenance-N3sc0nbo.js → connector-provenance-D_g9gGXU.js} +1 -1
  77. package/dist/owletto/dist/assets/{connectors-Ckn_aoNE.js → connectors-BiMMm_QQ.js} +1 -1
  78. package/dist/owletto/dist/assets/{consent-Bi6KCVtT.js → consent-CIzW-960.js} +1 -1
  79. package/dist/owletto/dist/assets/{core.esm-CFYXLQXH.js → core.esm-Ds4Nuq9d.js} +1 -1
  80. package/dist/owletto/dist/assets/create--fsxroj2.js +1 -0
  81. package/dist/owletto/dist/assets/create-BqL-ahEf.js +1 -0
  82. package/dist/owletto/dist/assets/{create-BiHpu2f4.js → create-BvCaqhwK.js} +1 -1
  83. package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +2 -0
  84. package/dist/owletto/dist/assets/{create._connectorKey-Qynix_hA.js → create._connectorKey--qDi1h6S.js} +1 -1
  85. package/dist/owletto/dist/assets/{cronstrue-D7xlYtGk.js → cronstrue-h8_zIyZD.js} +1 -1
  86. package/dist/owletto/dist/assets/deployments-BROg1Te8.js +1 -0
  87. package/dist/owletto/dist/assets/deployments-ICDss7yS.js +1 -0
  88. package/dist/owletto/dist/assets/deployments-body-DulCUAMt.js +1 -0
  89. package/dist/owletto/dist/assets/device-kTL2l_cz.js +1 -0
  90. package/dist/owletto/dist/assets/{device-pin-tombstone-DrTJYNKG.js → device-pin-tombstone-BmD4pv_e.js} +1 -1
  91. package/dist/owletto/dist/assets/device-rows-BqudjhFu.js +1 -0
  92. package/dist/owletto/dist/assets/{device._deviceId-CIe7taim.js → device._deviceId-CsLJJ6jv.js} +1 -1
  93. package/dist/owletto/dist/assets/entity-options-ErxYvMDH.js +1 -0
  94. package/dist/owletto/dist/assets/entity-page-CYRAwUGO.js +1 -0
  95. package/dist/owletto/dist/assets/entity-type-page-BlAizGlz.js +1 -0
  96. package/dist/owletto/dist/assets/event-page-DTXPxc-E.js +1 -0
  97. package/dist/owletto/dist/assets/events-feed-L3c-LLiJ.js +1 -0
  98. package/dist/owletto/dist/assets/{full-page-spinner-DTSqneUO.js → full-page-spinner-BxcYpJXx.js} +1 -1
  99. package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +1 -0
  100. package/dist/owletto/dist/assets/identity-B8lKn0je.js +1 -0
  101. package/dist/owletto/dist/assets/{index-jGZeANLE.js → index--lEHrFE4.js} +1 -1
  102. package/dist/owletto/dist/assets/{index-CMOHHdFH.js → index-13rywWam.js} +1 -1
  103. package/dist/owletto/dist/assets/{index-Bq4m-sK0.js → index-BRvT0VV9.js} +1 -1
  104. package/dist/owletto/dist/assets/index-BUp24ZJr.js +1 -0
  105. package/dist/owletto/dist/assets/index-B_-MLsof.js +1 -0
  106. package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +1 -0
  107. package/dist/owletto/dist/assets/index-C8CR2-Ck.css +1 -0
  108. package/dist/owletto/dist/assets/{index-OUb5Mlez.js → index-CDz3-ieP.js} +10 -10
  109. package/dist/owletto/dist/assets/index-CFkj9iR_.js +1 -0
  110. package/dist/owletto/dist/assets/index-CgBgOElA.js +1 -0
  111. package/dist/owletto/dist/assets/{index-DkKALC2l.js → index-CheCJomo.js} +1 -1
  112. package/dist/owletto/dist/assets/index-CpiW66xK.js +1 -0
  113. package/dist/owletto/dist/assets/index-DAv5S2aK.js +1 -0
  114. package/dist/owletto/dist/assets/index-DBi2Xr3i.js +1 -0
  115. package/dist/owletto/dist/assets/index-DHOha5OJ.js +1 -0
  116. package/dist/owletto/dist/assets/index-DdGjY1Hb.js +7898 -0
  117. package/dist/owletto/dist/assets/index-Dkyl7l6E.js +1 -0
  118. package/dist/owletto/dist/assets/{index-DYe_DVHa.js → index-QcHQZI87.js} +1 -1
  119. package/dist/owletto/dist/assets/index-kq4537-S.js +1 -0
  120. package/dist/owletto/dist/assets/{json-diff-CANZD4MQ.js → json-diff-BV2STDGj.js} +2 -2
  121. package/dist/owletto/dist/assets/{list-skeleton-DZTUxpBx.js → list-skeleton-CT5n4ND_.js} +1 -1
  122. package/dist/owletto/dist/assets/login-DKsgABYt.js +1 -0
  123. package/dist/owletto/dist/assets/logout-D_CP-emw.js +1 -0
  124. package/dist/owletto/dist/assets/member-scope-gate-BTgmlfFJ.js +1 -0
  125. package/dist/owletto/dist/assets/memory-browse-page-FHaJC3ML.js +101 -0
  126. package/dist/owletto/dist/assets/missing-view-Bve6pJP-.js +1 -0
  127. package/dist/owletto/dist/assets/{model-selector-CvU3VP90.js → model-selector-BLCEahny.js} +1 -1
  128. package/dist/owletto/dist/assets/models-C4N7LQAW.js +1 -0
  129. package/dist/owletto/dist/assets/new-BAIGSdfp.js +1 -0
  130. package/dist/owletto/dist/assets/{new-DIjOVXrQ.js → new-CirOK0Sw.js} +1 -1
  131. package/dist/owletto/dist/assets/new-DzapH2sV.js +1 -0
  132. package/dist/owletto/dist/assets/{oauth-workspace-access-DWfiekRz.js → oauth-workspace-access-BF7jaswv.js} +1 -1
  133. package/dist/owletto/dist/assets/{organization-DHEC7kDq.js → organization-D9RPsWG-.js} +1 -1
  134. package/dist/owletto/dist/assets/{permissions-i7iwnE1a.js → permissions-BlRONw-u.js} +1 -1
  135. package/dist/owletto/dist/assets/{proposal-review-shell-C_LcyUEF.js → proposal-review-shell-uskeFIUr.js} +1 -1
  136. package/dist/owletto/dist/assets/{recent-By19_Buq.js → recent-CmJ4Is6V.js} +1 -1
  137. package/dist/owletto/dist/assets/{renderer-B1UThnk2.js → renderer-Dyf4t8kR.js} +2 -2
  138. package/dist/owletto/dist/assets/{reset-password-Dsz5-Xeo.js → reset-password-BVIeE1Zm.js} +1 -1
  139. package/dist/owletto/dist/assets/runs-CzBeUzlQ.js +1 -0
  140. package/dist/owletto/dist/assets/{runs-panel-wkV1aGD9.js → runs-panel-D7l1uLGm.js} +1 -1
  141. package/dist/owletto/dist/assets/runs-table-dATyiBg2.js +1 -0
  142. package/dist/owletto/dist/assets/{schema-value-normalization--DhnhJNf.js → schema-value-normalization-DgMkyVVE.js} +1 -1
  143. package/dist/owletto/dist/assets/settings-BK1GHmzb.js +1 -0
  144. package/dist/owletto/dist/assets/{settings-Bu239SXe.js → settings-Co1wj_m6.js} +1 -1
  145. package/dist/owletto/dist/assets/skills-DF53JcYt.js +1 -0
  146. package/dist/owletto/dist/assets/{switch-CCKllS7w.js → switch-DDkPrV3p.js} +1 -1
  147. package/dist/owletto/dist/assets/use-applied-views-DELwQQh7.js +1 -0
  148. package/dist/owletto/dist/assets/{use-mention-search-CldNZTiT.js → use-mention-search-CGA3AaKm.js} +1 -1
  149. package/dist/owletto/dist/assets/view-frame-DDr-Xtet.js +1 -0
  150. package/dist/owletto/dist/index.html +2 -2
  151. package/dist/server-main.bundle.mjs +16460 -12976
  152. package/npm-shrinkwrap.json +593 -559
  153. package/package.json +5 -2
  154. package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
  155. package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
  156. package/vendor/connector-sdk/dist/connector-types.d.ts +28 -13
  157. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
  158. package/vendor/connector-sdk/dist/define-connector.js +4 -1
  159. package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
  160. package/vendor/connector-sdk/dist/http-client.js +15 -13
  161. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  162. package/vendor/connector-sdk/dist/retry.d.ts +15 -3
  163. package/vendor/connector-sdk/dist/retry.js +40 -64
  164. package/vendor/connector-sdk/package.json +1 -1
  165. package/vendor/core/dist/agent-policy.js +3 -0
  166. package/vendor/core/dist/connector-query-errors.d.ts +3 -3
  167. package/vendor/core/dist/connector-query-errors.js +8 -3
  168. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +24 -0
  169. package/vendor/core/dist/contracts/tools/manage-connections.js +13 -0
  170. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +15 -25
  171. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +3 -5
  172. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +11 -0
  173. package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
  174. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
  175. package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
  176. package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
  177. package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
  178. package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
  179. package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
  180. package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
  181. package/vendor/core/dist/contracts/tools/source-files.js +55 -0
  182. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
  183. package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
  184. package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
  185. package/vendor/core/dist/contracts/tools/view-path.js +24 -0
  186. package/vendor/core/dist/contracts/worker/protocol.d.ts +73 -8
  187. package/vendor/core/dist/contracts/worker/protocol.js +58 -9
  188. package/vendor/core/dist/credentials.d.ts +16 -1
  189. package/vendor/core/dist/credentials.js +10 -1
  190. package/vendor/core/dist/reserved.d.ts +3 -3
  191. package/vendor/core/dist/reserved.js +9 -1
  192. package/vendor/core/dist/utils/secret-redaction.js +2 -0
  193. package/vendor/core/package.json +25 -5
  194. package/vendor/views/dist/api.d.ts +179 -0
  195. package/vendor/views/dist/api.js +406 -0
  196. package/vendor/views/dist/bridge.d.ts +141 -0
  197. package/vendor/views/dist/bridge.js +330 -0
  198. package/vendor/views/dist/index.d.ts +12 -0
  199. package/vendor/views/dist/index.js +10 -0
  200. package/vendor/views/package.json +35 -0
  201. package/dist/owletto/dist/assets/_-CfcfHJO8.js +0 -1
  202. package/dist/owletto/dist/assets/_-DdvHIadV.js +0 -2
  203. package/dist/owletto/dist/assets/_agentId-BTmFhpb6.js +0 -1
  204. package/dist/owletto/dist/assets/_agentId-DbTBU4KZ.js +0 -1
  205. package/dist/owletto/dist/assets/_automationId-C7dZzg6X.js +0 -1
  206. package/dist/owletto/dist/assets/_conversationId-F5YmyLV9.js +0 -1
  207. package/dist/owletto/dist/assets/_deploymentId-3LTMi0ZT.js +0 -1
  208. package/dist/owletto/dist/assets/_name-BKeZbc-h.js +0 -1
  209. package/dist/owletto/dist/assets/_owner-DglbbDEx.js +0 -1
  210. package/dist/owletto/dist/assets/_skillKey-DhiGYYFq.js +0 -1
  211. package/dist/owletto/dist/assets/_slug-CnQDfsCE.js +0 -1
  212. package/dist/owletto/dist/assets/accept-invitation-Dgoyublh.js +0 -1
  213. package/dist/owletto/dist/assets/activity-route-view-BNzKO6aD.js +0 -1
  214. package/dist/owletto/dist/assets/agent-thread-DnLUOzXk.js +0 -134
  215. package/dist/owletto/dist/assets/agents-OLmcj-qM.js +0 -1
  216. package/dist/owletto/dist/assets/agents-workbench-BOKifKIO.js +0 -1
  217. package/dist/owletto/dist/assets/automation-detail-content-wJC9hhmA.js +0 -1
  218. package/dist/owletto/dist/assets/automations-OLmcj-qM.js +0 -1
  219. package/dist/owletto/dist/assets/clients-R4JsT_Fz.js +0 -1
  220. package/dist/owletto/dist/assets/connect-1ysEq9l0.js +0 -1
  221. package/dist/owletto/dist/assets/connect._clientId-BbMPs6l3.js +0 -1
  222. package/dist/owletto/dist/assets/connected._clientId-ByH4etku.js +0 -1
  223. package/dist/owletto/dist/assets/create-C37QtjbJ.js +0 -1
  224. package/dist/owletto/dist/assets/create-automation-form-Cv2RHsQ6.js +0 -1
  225. package/dist/owletto/dist/assets/create-kAQa5_Q7.js +0 -1
  226. package/dist/owletto/dist/assets/deployments-C5kSeowq.js +0 -1
  227. package/dist/owletto/dist/assets/deployments-body-BPCALbQe.js +0 -1
  228. package/dist/owletto/dist/assets/device-DToHXxDM.js +0 -1
  229. package/dist/owletto/dist/assets/device-rows-fVm-zAiU.js +0 -1
  230. package/dist/owletto/dist/assets/entity-options-DOGD_EyZ.js +0 -1
  231. package/dist/owletto/dist/assets/entity-page-C8oDszRY.js +0 -1
  232. package/dist/owletto/dist/assets/entity-type-page-BfxIgJLq.js +0 -1
  233. package/dist/owletto/dist/assets/events-feed-B9OqmSBy.js +0 -1
  234. package/dist/owletto/dist/assets/guardrails-9Mr6avxk.js +0 -1
  235. package/dist/owletto/dist/assets/identity-DMfCjdBz.js +0 -1
  236. package/dist/owletto/dist/assets/index-Bfux0kHb.js +0 -7898
  237. package/dist/owletto/dist/assets/index-CK2-iHcz.js +0 -1
  238. package/dist/owletto/dist/assets/index-COgBJ_ab.js +0 -1
  239. package/dist/owletto/dist/assets/index-ChcQMdod.css +0 -1
  240. package/dist/owletto/dist/assets/index-CkwwaMrx.js +0 -1
  241. package/dist/owletto/dist/assets/index-D0lZrXrY.js +0 -1
  242. package/dist/owletto/dist/assets/index-DZadnZpq.js +0 -1
  243. package/dist/owletto/dist/assets/index-DcWyuLQS.js +0 -1
  244. package/dist/owletto/dist/assets/index-DlqjyZKQ.js +0 -1
  245. package/dist/owletto/dist/assets/index-Dv0huHrO.js +0 -1
  246. package/dist/owletto/dist/assets/index-DxIDxgPJ.js +0 -1
  247. package/dist/owletto/dist/assets/index-bKUccXCc.js +0 -1
  248. package/dist/owletto/dist/assets/login-D53geSP7.js +0 -1
  249. package/dist/owletto/dist/assets/logout-DKQS25qd.js +0 -1
  250. package/dist/owletto/dist/assets/member-scope-gate-C4QyRm2Q.js +0 -1
  251. package/dist/owletto/dist/assets/memory-browse-page-DOpV3vht.js +0 -101
  252. package/dist/owletto/dist/assets/models-ooBIWFuB.js +0 -1
  253. package/dist/owletto/dist/assets/new-B8_sRMYD.js +0 -1
  254. package/dist/owletto/dist/assets/new-Df1q7GEj.js +0 -1
  255. package/dist/owletto/dist/assets/runs-BQ11PAQT.js +0 -1
  256. package/dist/owletto/dist/assets/runs-table-DzSWYkaf.js +0 -1
  257. package/dist/owletto/dist/assets/settings-FxbIvOhH.js +0 -1
  258. package/dist/owletto/dist/assets/skills-MBZ5ilDK.js +0 -1
  259. package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
  260. package/vendor/core/dist/contracts/tools/manage-view-templates.js +0 -130
@@ -1,134 +0,0 @@
1
- import{j as d,r as m,eY as wa,cU as ka,eZ as $a,ex as Sa,an as Qn,ag as Bn,ao as to,d2 as xa,e_ as no,e$ as Ra,L as ls,aj as he,dr as za,dz as ds,dB as Ta,f0 as Ia,cP as Ea,dC as Pa,f1 as Ca,B as ot,f2 as Na,f3 as Za,f4 as Xn,X as Oa,s as Aa,dA as ja,aS as Kt,f5 as Ma,ci as La,cj as Da,f6 as Ua,ck as qa,bI as Fa,f7 as Ha,f8 as Va,eM as Ba,bF as Ja,ef as Wa,eg as Ka}from"./index-Bfux0kHb.js";import{A as Ga,a as Ya,b as Qa,c as hr,d as ps,e as Xa}from"./agent-loading-shells-Dczhk067.js";import{t as ec}from"./pending-seed-CPbfgnLX.js";import{h as tc,t as nc,R as rc,i as oc,u as sc,b as ic,f as ac}from"./use-mention-search-CldNZTiT.js";var ro;function _(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){const h=l[p];h in a||(a[h]=u[h].bind(a))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}let Rt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};class hs extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ro=globalThis).__zod_globalConfig??(ro.__zod_globalConfig={});const fr=globalThis.__zod_globalConfig;function Ye(e){return fr}function fs(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function er(e,t){return typeof t=="bigint"?t.toString():t}function An(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function mr(e){return e==null}function gr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function cc(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const oo=Symbol("evaluating");function B(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==oo)return r===void 0&&(r=oo,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function _t(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function at(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function so(e){return JSON.stringify(e)}function uc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ms="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const lc=An(()=>{if(fr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function zt(e){if(Ut(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ut(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function gs(e){return zt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const dc=new Set(["string","number","symbol"]);function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function T(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 pc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const hc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function fc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=at(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return _t(this,"shape",i),i},checks:[]});return ct(e,s)}function mc(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=at(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return _t(this,"shape",i),i},checks:[]});return ct(e,s)}function gc(e,t){if(!zt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=at(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return _t(this,"shape",s),s}});return ct(e,o)}function _c(e,t){if(!zt(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=at(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return _t(this,"shape",r),r}});return ct(e,n)}function vc(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=at(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return _t(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ct(e,n)}function bc(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=at(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return _t(this,"shape",c),c},checks:[]});return ct(t,i)}function yc(e,t,n){const r=at(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return _t(this,"shape",s),s}});return ct(t,r)}function St(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 wc(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 xt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function mn(e){return typeof e=="string"?e:e?.message}function Qe(e,t,n){const r=e.message?e.message:mn(e.inst?._zod.def?.error?.(e))??mn(t?.error?.(e))??mn(n.customError?.(e))??mn(n.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=i),a}function _r(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function qt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const _s=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,er,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vs=_("$ZodError",_s),bs=_("$ZodError",_s,{Parent:Error});function kc(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function $c(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{const a=[...s,...i.path];if(a.length===0)n._errors.push(t(i));else{let c=n,u=0;for(;u<a.length;){const l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(t(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return r(e),n}const vr=e=>(t,n,r,o)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Rt;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>Qe(c,s,Ye())));throw ms(a,o?.callee),a}return i.value},br=e=>async(t,n,r,o)=>{const s=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>Qe(c,s,Ye())));throw ms(a,o?.callee),a}return i.value},jn=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Rt;return s.issues.length?{success:!1,error:new(e??vs)(s.issues.map(i=>Qe(i,o,Ye())))}:{success:!0,data:s.value}},ys=jn(bs),Mn=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Qe(i,o,Ye())))}:{success:!0,data:s.value}},Sc=Mn(bs),xc=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return vr(e)(t,n,o)},Rc=e=>(t,n,r)=>vr(e)(t,n,r),zc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return br(e)(t,n,o)},Tc=e=>async(t,n,r)=>br(e)(t,n,r),Ic=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return jn(e)(t,n,o)},Ec=e=>(t,n,r)=>jn(e)(t,n,r),Pc=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mn(e)(t,n,o)},Cc=e=>async(t,n,r)=>Mn(e)(t,n,r),Nc=/^[cC][0-9a-z]{6,}$/,Zc=/^[0-9a-z]+$/,Oc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ac=/^[0-9a-vA-V]{20}$/,jc=/^[A-Za-z0-9]{27}$/,Mc=/^[a-zA-Z0-9_-]{21}$/,Lc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dc=/^([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})$/,io=e=>e?new 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)$/,Uc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,qc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fc(){return new RegExp(qc,"u")}const Hc=/^(?:(?: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])$/,Vc=/^(([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}|:))$/,Bc=/^((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])$/,Jc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ws=/^[A-Za-z0-9_-]*$/,Kc=/^https?$/,Gc=/^\+[1-9]\d{6,14}$/,ks="(?:(?:\\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])))",Yc=new RegExp(`^${ks}$`);function $s(e){const 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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Qc(e){return new RegExp(`^${$s(e)}$`)}function Xc(e){const t=$s({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ks}T(?:${r})$`)}const eu=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},tu=/^-?\d+$/,Ss=/^-?\d+(?:\.\d+)?$/,nu=/^(?:true|false)$/i,ru=/^null$/i,ou=/^[^A-Z]*$/,su=/^[^a-z]*$/,Ze=_("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),xs={number:"number",bigint:"bigint",object:"date"},Rs=_("$ZodCheckLessThan",(e,t)=>{Ze.init(e,t);const n=xs[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin: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})}}),zs=_("$ZodCheckGreaterThan",(e,t)=>{Ze.init(e,t);const n=xs[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin: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})}}),iu=_("$ZodCheckMultipleOf",(e,t)=>{Ze.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):cc(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})}}),au=_("$ZodCheckNumberFormat",(e,t)=>{Ze.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=hc[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=tu)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),cu=_("$ZodCheckMaxLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!mr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=_r(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),uu=_("$ZodCheckMinLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!mr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=_r(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),lu=_("$ZodCheckLengthEquals",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!mr(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=_r(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ln=_("$ZodCheckStringFormat",(e,t)=>{var n,r;Ze.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),du=_("$ZodCheckRegex",(e,t)=>{Ln.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})}}),pu=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ou),Ln.init(e,t)}),hu=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=su),Ln.init(e,t)}),fu=_("$ZodCheckIncludes",(e,t)=>{Ze.init(e,t);const n=Tt(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),mu=_("$ZodCheckStartsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),gu=_("$ZodCheckEndsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),_u=_("$ZodCheckOverwrite",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});let vu=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
2
- `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
3
- `))}};const bu={major:4,minor:4,patch:3},ne=_("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bu;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,a,c)=>{let u=St(i),l;for(const p of a){if(p._zod.def.when){if(wc(i)||!p._zod.def.when(i))continue}else if(u)continue;const h=i.issues.length,f=p._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new Rt;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,i.issues.length!==h&&(u||(u=St(i,h)))});else{if(i.issues.length===h)continue;u||(u=St(i,h))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(St(i))return i.aborted=!0,i;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new Rt;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Rt;return c.then(u=>o(u,r,a))}return o(c,r,a)}}B(e,"~standard",()=>({validate:o=>{try{const s=ys(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Sc(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),yr=_("$ZodString",(e,t)=>{ne.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??eu(e._zod.bag),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}}),re=_("$ZodStringFormat",(e,t)=>{Ln.init(e,t),yr.init(e,t)}),yu=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Dc),re.init(e,t)}),wu=_("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=io(r))}else t.pattern??(t.pattern=io());re.init(e,t)}),ku=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Uc),re.init(e,t)}),$u=_("$ZodURL",(e,t)=>{re.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kc.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Su=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fc()),re.init(e,t)}),xu=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Mc),re.init(e,t)}),Ru=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Nc),re.init(e,t)}),zu=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zc),re.init(e,t)}),Tu=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Oc),re.init(e,t)}),Iu=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ac),re.init(e,t)}),Eu=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=jc),re.init(e,t)}),Pu=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xc(t)),re.init(e,t)}),Cu=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Yc),re.init(e,t)}),Nu=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Qc(t)),re.init(e,t)}),Zu=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Lc),re.init(e,t)}),Ou=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Hc),re.init(e,t),e._zod.bag.format="ipv4"}),Au=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vc),re.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ju=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Bc),re.init(e,t)}),Mu=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jc),re.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ts(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Lu=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Wc),re.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ts(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Du(e){if(!ws.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ts(n)}const Uu=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ws),re.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Du(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),qu=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Gc),re.init(e,t)});function Fu(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Hu=_("$ZodJWT",(e,t)=>{re.init(e,t),e._zod.check=n=>{Fu(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Is=_("$ZodNumber",(e,t)=>{ne.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ss,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),Vu=_("$ZodNumberFormat",(e,t)=>{au.init(e,t),Is.init(e,t)}),Bu=_("$ZodBoolean",(e,t)=>{ne.init(e,t),e._zod.pattern=nu,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ju=_("$ZodNull",(e,t)=>{ne.init(e,t),e._zod.pattern=ru,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),Wu=_("$ZodUnknown",(e,t)=>{ne.init(e,t),e._zod.parse=n=>n}),Ku=_("$ZodNever",(e,t)=>{ne.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ao(e,t,n){e.issues.length&&t.issues.push(...xt(n,e.issues)),t.value[n]=e.value}const Gu=_("$ZodArray",(e,t)=>{ne.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>ao(u,n,i))):ao(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Sn(e,t,n,r,o,s){const i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...xt(n,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?i&&(t.value[n]=void 0):t.value[n]=e.value}function Es(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=pc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ps(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",p=c.optout==="optional";for(const h in t){if(h==="__proto__"||a.has(h))continue;if(u==="never"){i.push(h);continue}const f=c.run({value:t[h],issues:[]},r);f instanceof Promise?e.push(f.then(y=>Sn(y,n,h,t,l,p))):Sn(f,n,h,t,l,p)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Yu=_("$ZodObject",(e,t)=>{if(ne.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=An(()=>Es(t));B(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(const p of l.values)c[u].add(p)}}return c});const o=Ut,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=r.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const l=[],p=i.shape;for(const h of i.keys){const f=p[h],y=f._zod.optin==="optional",Z=f._zod.optout==="optional",x=f._zod.run({value:u[h],issues:[]},c);x instanceof Promise?l.push(x.then(j=>Sn(j,a,h,u,y,Z))):Sn(x,a,h,u,y,Z)}return s?Ps(l,u,a,c,r.value,e):l.length?Promise.all(l).then(()=>a):a}}),Qu=_("$ZodObjectJIT",(e,t)=>{Yu.init(e,t);const n=e._zod.parse,r=An(()=>Es(t)),o=h=>{const f=new vu(["shape","payload","ctx"]),y=r.value,Z=w=>{const $=so(w);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};f.write("const input = payload.value;");const x=Object.create(null);let j=0;for(const w of y.keys)x[w]=`key_${j++}`;f.write("const newResult = {};");for(const w of y.keys){const $=x[w],A=so(w),M=h[w],W=M?._zod?.optin==="optional",$e=M?._zod?.optout==="optional";f.write(`const ${$} = ${Z(w)};`),W&&$e?f.write(`
4
- if (${$}.issues.length) {
5
- if (${A} in input) {
6
- payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
7
- ...iss,
8
- path: iss.path ? [${A}, ...iss.path] : [${A}]
9
- })));
10
- }
11
- }
12
-
13
- if (${$}.value === undefined) {
14
- if (${A} in input) {
15
- newResult[${A}] = undefined;
16
- }
17
- } else {
18
- newResult[${A}] = ${$}.value;
19
- }
20
-
21
- `):W?f.write(`
22
- if (${$}.issues.length) {
23
- payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
24
- ...iss,
25
- path: iss.path ? [${A}, ...iss.path] : [${A}]
26
- })));
27
- }
28
-
29
- if (${$}.value === undefined) {
30
- if (${A} in input) {
31
- newResult[${A}] = undefined;
32
- }
33
- } else {
34
- newResult[${A}] = ${$}.value;
35
- }
36
-
37
- `):f.write(`
38
- const ${$}_present = ${A} in input;
39
- if (${$}.issues.length) {
40
- payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
41
- ...iss,
42
- path: iss.path ? [${A}, ...iss.path] : [${A}]
43
- })));
44
- }
45
- if (!${$}_present && !${$}.issues.length) {
46
- payload.issues.push({
47
- code: "invalid_type",
48
- expected: "nonoptional",
49
- input: undefined,
50
- path: [${A}]
51
- });
52
- }
53
-
54
- if (${$}_present) {
55
- if (${$}.value === undefined) {
56
- newResult[${A}] = undefined;
57
- } else {
58
- newResult[${A}] = ${$}.value;
59
- }
60
- }
61
-
62
- `)}f.write("payload.value = newResult;"),f.write("return payload;");const z=f.compile();return(w,$)=>z(h,w,$)};let s;const i=Ut,a=!fr.jitless,u=a&&lc.value,l=t.catchall;let p;e._zod.parse=(h,f)=>{p??(p=r.value);const y=h.value;return i(y)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(t.shape)),h=s(h,f),l?Ps([],y,h,f,p,e):h):n(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h)}});function co(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!St(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>Qe(i,r,Ye())))}),t)}const Cs=_("$ZodUnion",(e,t)=>{ne.init(e,t),B(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),B(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),B(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),B(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>gr(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const i=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>co(a,r,e,o)):co(i,r,e,o)}}),Xu=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Cs.init(e,t);const n=e._zod.parse;B(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const u of c)o[a].add(u)}}return o});const r=An(()=>{const o=t.options,s=new Map;for(const i of o){const a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!Ut(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),o)}}),el=_("$ZodIntersection",(e,t)=>{ne.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>uo(n,c,u)):uo(n,s,i)}});function tr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(zt(e)&&zt(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=tr(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=tr(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function uo(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&e.issues.push({...o,keys:s}),St(e))return e;const i=tr(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const tl=_("$ZodRecord",(e,t)=>{ne.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!zt(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const l=t.keyType._zod.run({value:u,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>Qe(f,r,Ye())),input:u,path:[u],inst:e});continue}const p=l.value,h=t.valueType._zod.run({value:o[u],issues:[]},r);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&n.issues.push(...xt(u,f.issues)),n.value[p]=f.value})):(h.issues.length&&n.issues.push(...xt(u,h.issues)),n.value[p]=h.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Ss.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Qe(p,r,Ye())),input:a,path:[a],inst:e});continue}const l=t.valueType._zod.run({value:o[a],issues:[]},r);l instanceof Promise?s.push(l.then(p=>{p.issues.length&&n.issues.push(...xt(a,p.issues)),n.value[c.value]=p.value})):(l.issues.length&&n.issues.push(...xt(a,l.issues)),n.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>n):n}}),nl=_("$ZodEnum",(e,t)=>{ne.init(e,t);const n=fs(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>dc.has(typeof o)).map(o=>typeof o=="string"?Tt(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),rl=_("$ZodLiteral",(e,t)=>{if(ne.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Tt(r):r?Tt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),ol=_("$ZodTransform",(e,t)=>{ne.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hs(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new Rt;return n.value=o,n.fallback=!0,n}});function lo(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Ns=_("$ZodOptional",(e,t)=>{ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",B(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${gr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>lo(i,o)):lo(s,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),sl=_("$ZodExactOptional",(e,t)=>{Ns.init(e,t),B(e._zod,"values",()=>t.innerType._zod.values),B(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),il=_("$ZodNullable",(e,t)=>{ne.init(e,t),B(e._zod,"optin",()=>t.innerType._zod.optin),B(e._zod,"optout",()=>t.innerType._zod.optout),B(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${gr(n.source)}|null)$`):void 0}),B(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),al=_("$ZodDefault",(e,t)=>{ne.init(e,t),e._zod.optin="optional",B(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>po(s,t)):po(o,t)}});function po(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const cl=_("$ZodPrefault",(e,t)=>{ne.init(e,t),e._zod.optin="optional",B(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),ul=_("$ZodNonOptional",(e,t)=>{ne.init(e,t),B(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ho(s,e)):ho(o,e)}});function ho(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const ll=_("$ZodCatch",(e,t)=>{ne.init(e,t),e._zod.optin="optional",B(e._zod,"optout",()=>t.innerType._zod.optout),B(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Qe(i,r,Ye()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>Qe(s,r,Ye()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Zs=_("$ZodPipe",(e,t)=>{ne.init(e,t),B(e._zod,"values",()=>t.in._zod.values),B(e._zod,"optin",()=>t.in._zod.optin),B(e._zod,"optout",()=>t.out._zod.optout),B(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>gn(i,t.in,r)):gn(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>gn(s,t.out,r)):gn(o,t.out,r)}});function gn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const dl=_("$ZodPreprocess",(e,t)=>{Zs.init(e,t)}),pl=_("$ZodReadonly",(e,t)=>{ne.init(e,t),B(e._zod,"propValues",()=>t.innerType._zod.propValues),B(e._zod,"values",()=>t.innerType._zod.values),B(e._zod,"optin",()=>t.innerType?._zod?.optin),B(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(fo):fo(o)}});function fo(e){return e.value=Object.freeze(e.value),e}const hl=_("$ZodCustom",(e,t)=>{Ze.init(e,t),ne.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>mo(s,n,r,e));mo(o,n,r,e)}});function mo(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(qt(o))}}var go;let fl=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function ml(){return new fl}(go=globalThis).__zod_globalRegistry??(go.__zod_globalRegistry=ml());const Lt=globalThis.__zod_globalRegistry;function gl(e,t){return new e({type:"string",...T(t)})}function _l(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function _o(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function yl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function wl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function kl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function $l(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function Sl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function xl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function Rl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function zl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function Tl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function Il(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function El(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function Pl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function Cl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function Nl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function Zl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function Ol(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function Al(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function jl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function Ml(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function Ll(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function Dl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function Ul(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function ql(e,t){return new e({type:"number",checks:[],...T(t)})}function Fl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Hl(e,t){return new e({type:"boolean",...T(t)})}function Vl(e,t){return new e({type:"null",...T(t)})}function Bl(e){return new e({type:"unknown"})}function Jl(e,t){return new e({type:"never",...T(t)})}function vo(e,t){return new Rs({check:"less_than",...T(t),value:e,inclusive:!1})}function Jn(e,t){return new Rs({check:"less_than",...T(t),value:e,inclusive:!0})}function bo(e,t){return new zs({check:"greater_than",...T(t),value:e,inclusive:!1})}function Wn(e,t){return new zs({check:"greater_than",...T(t),value:e,inclusive:!0})}function yo(e,t){return new iu({check:"multiple_of",...T(t),value:e})}function Os(e,t){return new cu({check:"max_length",...T(t),maximum:e})}function xn(e,t){return new uu({check:"min_length",...T(t),minimum:e})}function As(e,t){return new lu({check:"length_equals",...T(t),length:e})}function Wl(e,t){return new du({check:"string_format",format:"regex",...T(t),pattern:e})}function Kl(e){return new pu({check:"string_format",format:"lowercase",...T(e)})}function Gl(e){return new hu({check:"string_format",format:"uppercase",...T(e)})}function Yl(e,t){return new fu({check:"string_format",format:"includes",...T(t),includes:e})}function Ql(e,t){return new mu({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Xl(e,t){return new gu({check:"string_format",format:"ends_with",...T(t),suffix:e})}function Pt(e){return new _u({check:"overwrite",tx:e})}function ed(e){return Pt(t=>t.normalize(e))}function td(){return Pt(e=>e.trim())}function nd(){return Pt(e=>e.toLowerCase())}function rd(){return Pt(e=>e.toUpperCase())}function od(){return Pt(e=>uc(e))}function sd(e,t,n){return new e({type:"array",element:t,...T(n)})}function id(e,t,n){const r=T(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function ad(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}function cd(e,t){const n=ud(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(qt(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(qt(s))}},e(r.value,r)),t);return n}function ud(e,t){const n=new Ze({check:"custom",...T(t)});return n._zod.check=e,n}function js(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??Lt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ge(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{const h=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,h,l)}const p=e._zod.parent;p&&(i.ref||(i.ref=p),ge(p,t,l),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&Ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Ms(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=r.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(i[0])?.id,h=e.external.uri??(y=>y);if(p)return{ref:h(p)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
-
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function Ls(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){r(p);const f=e.seen.get(p),y=f.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):Object.assign(u,y),Object.assign(u,l),a._zod.parent===p)for(const x in u)x==="$ref"||x==="allOf"||x in l||delete u[x];if(y.$ref&&f.def)for(const x in u)x==="$ref"||x==="allOf"||x in f.def&&JSON.stringify(u[x])===JSON.stringify(f.def[x])&&delete u[x]}const h=a._zod.parent;if(h&&h!==p){r(h);const f=e.seen.get(h);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(const y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;const i=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rn(t,"input",e.processors),output:Rn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ee(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Ee(r.element,n);if(r.type==="set")return Ee(r.valueType,n);if(r.type==="lazy")return Ee(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")return Ee(r.innerType,n);if(r.type==="intersection")return Ee(r.left,n)||Ee(r.right,n);if(r.type==="record"||r.type==="map")return Ee(r.keyType,n)||Ee(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ee(r.in,n)||Ee(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Ee(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Ee(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Ee(o,n))return!0;return!!(r.rest&&Ee(r.rest,n))}return!1}const ld=(e,t={})=>n=>{const r=js({...n,processors:t});return ge(e,r),Ms(r,e),Ls(r,e)},Rn=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=js({...o??{},target:s,io:t,processors:n});return ge(e,i),Ms(i,e),Ls(i,e)},dd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pd=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=dd[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},hd=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";const p=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),h=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";p?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),h?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},fd=(e,t,n,r)=>{n.type="boolean"},md=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},gd=(e,t,n,r)=>{n.not={}},_d=(e,t,n,r)=>{},vd=(e,t,n,r)=>{const o=e._zod.def,s=fs(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},bd=(e,t,n,r)=>{const o=e._zod.def,s=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},yd=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wd=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kd=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ge(s.element,t,{...r,path:[...r.path,"items"]})},$d=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=ge(i[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const l=s.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ge(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Sd=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ge(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},xd=(e,t,n,r)=>{const o=e._zod.def,s=ge(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=ge(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},Rd=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){const l=ge(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const p of c)o.patternProperties[p.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=ge(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=ge(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=i._zod.values;if(u){const l=[...u].filter(p=>typeof p=="string"||typeof p=="number");l.length>0&&(o.required=l)}},zd=(e,t,n,r)=>{const o=e._zod.def,s=ge(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Td=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Id=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ed=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Pd=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},Cd=(e,t,n,r)=>{const o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ge(i,t,r);const a=t.seen.get(e);a.ref=i},Nd=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},Ds=(e,t,n,r)=>{const o=e._zod.def;ge(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Zd=_("ZodISODateTime",(e,t)=>{Pu.init(e,t),de.init(e,t)});function Us(e){return Ml(Zd,e)}const Od=_("ZodISODate",(e,t)=>{Cu.init(e,t),de.init(e,t)});function Ad(e){return Ll(Od,e)}const jd=_("ZodISOTime",(e,t)=>{Nu.init(e,t),de.init(e,t)});function Md(e){return Dl(jd,e)}const Ld=_("ZodISODuration",(e,t)=>{Zu.init(e,t),de.init(e,t)});function Dd(e){return Ul(Ld,e)}const Ud=(e,t)=>{vs.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>$c(e,n)},flatten:{value:n=>kc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,er,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,er,2)}},isEmpty:{get(){return e.issues.length===0}}})},Fe=_("ZodError",Ud,{Parent:Error}),qd=vr(Fe),Fd=br(Fe),Hd=jn(Fe),Vd=Mn(Fe),Bd=xc(Fe),Jd=Rc(Fe),Wd=zc(Fe),Kd=Tc(Fe),Gd=Ic(Fe),Yd=Ec(Fe),Qd=Pc(Fe),Xd=Cc(Fe),wo=new WeakMap;function Gt(e,t,n){const r=Object.getPrototypeOf(e);let o=wo.get(r);if(o||(o=new Set,wo.set(r,o)),!o.has(t)){o.add(t);for(const s in n){const i=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){const a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const oe=_("ZodType",(e,t)=>(ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Rn(e,"input"),output:Rn(e,"output")}}),e.toJSONSchema=ld(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>qd(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Hd(e,n,r),e.parseAsync=async(n,r)=>Fd(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Vd(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Bd(e,n,r),e.decode=(n,r)=>Jd(e,n,r),e.encodeAsync=async(n,r)=>Wd(e,n,r),e.decodeAsync=async(n,r)=>Kd(e,n,r),e.safeEncode=(n,r)=>Gd(e,n,r),e.safeDecode=(n,r)=>Yd(e,n,r),e.safeEncodeAsync=async(n,r)=>Qd(e,n,r),e.safeDecodeAsync=async(n,r)=>Xd(e,n,r),Gt(e,"ZodType",{check(...n){const r=this.def;return this.clone(at(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ct(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(Hp(n,r))},superRefine(n,r){return this.check(Vp(n,r))},overwrite(n){return this.check(Pt(n))},optional(){return ue(this)},exactOptional(){return Pp(this)},nullable(){return xo(this)},nullish(){return ue(xo(this))},nonoptional(n){return jp(this,n)},array(){return U(this)},or(n){return se([this,n])},and(n){return wr(this,n)},transform(n){return Ro(this,Js(n))},default(n){return Zp(this,n)},prefault(n){return Ap(this,n)},catch(n){return Lp(this,n)},pipe(n){return Ro(this,n)},readonly(){return qp(this)},describe(n){const r=this.clone();return Lt.add(r,{description:n}),r},meta(...n){if(n.length===0)return Lt.get(this);const r=this.clone();return Lt.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Lt.get(e)?.description},configurable:!0}),e)),qs=_("_ZodString",(e,t)=>{yr.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(r,o,s)=>pd(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Gt(e,"_ZodString",{regex(...r){return this.check(Wl(...r))},includes(...r){return this.check(Yl(...r))},startsWith(...r){return this.check(Ql(...r))},endsWith(...r){return this.check(Xl(...r))},min(...r){return this.check(xn(...r))},max(...r){return this.check(Os(...r))},length(...r){return this.check(As(...r))},nonempty(...r){return this.check(xn(1,...r))},lowercase(r){return this.check(Kl(r))},uppercase(r){return this.check(Gl(r))},trim(){return this.check(td())},normalize(...r){return this.check(ed(...r))},toLowerCase(){return this.check(nd())},toUpperCase(){return this.check(rd())},slugify(){return this.check(od())}})}),ep=_("ZodString",(e,t)=>{yr.init(e,t),qs.init(e,t),e.email=n=>e.check(_l(tp,n)),e.url=n=>e.check(kl(np,n)),e.jwt=n=>e.check(jl(_p,n)),e.emoji=n=>e.check($l(rp,n)),e.guid=n=>e.check(_o(ko,n)),e.uuid=n=>e.check(vl(_n,n)),e.uuidv4=n=>e.check(bl(_n,n)),e.uuidv6=n=>e.check(yl(_n,n)),e.uuidv7=n=>e.check(wl(_n,n)),e.nanoid=n=>e.check(Sl(op,n)),e.guid=n=>e.check(_o(ko,n)),e.cuid=n=>e.check(xl(sp,n)),e.cuid2=n=>e.check(Rl(ip,n)),e.ulid=n=>e.check(zl(ap,n)),e.base64=n=>e.check(Zl(fp,n)),e.base64url=n=>e.check(Ol(mp,n)),e.xid=n=>e.check(Tl(cp,n)),e.ksuid=n=>e.check(Il(up,n)),e.ipv4=n=>e.check(El(lp,n)),e.ipv6=n=>e.check(Pl(dp,n)),e.cidrv4=n=>e.check(Cl(pp,n)),e.cidrv6=n=>e.check(Nl(hp,n)),e.e164=n=>e.check(Al(gp,n)),e.datetime=n=>e.check(Us(n)),e.date=n=>e.check(Ad(n)),e.time=n=>e.check(Md(n)),e.duration=n=>e.check(Dd(n))});function g(e){return gl(ep,e)}const de=_("ZodStringFormat",(e,t)=>{re.init(e,t),qs.init(e,t)}),tp=_("ZodEmail",(e,t)=>{ku.init(e,t),de.init(e,t)}),ko=_("ZodGUID",(e,t)=>{yu.init(e,t),de.init(e,t)}),_n=_("ZodUUID",(e,t)=>{wu.init(e,t),de.init(e,t)}),np=_("ZodURL",(e,t)=>{$u.init(e,t),de.init(e,t)}),rp=_("ZodEmoji",(e,t)=>{Su.init(e,t),de.init(e,t)}),op=_("ZodNanoID",(e,t)=>{xu.init(e,t),de.init(e,t)}),sp=_("ZodCUID",(e,t)=>{Ru.init(e,t),de.init(e,t)}),ip=_("ZodCUID2",(e,t)=>{zu.init(e,t),de.init(e,t)}),ap=_("ZodULID",(e,t)=>{Tu.init(e,t),de.init(e,t)}),cp=_("ZodXID",(e,t)=>{Iu.init(e,t),de.init(e,t)}),up=_("ZodKSUID",(e,t)=>{Eu.init(e,t),de.init(e,t)}),lp=_("ZodIPv4",(e,t)=>{Ou.init(e,t),de.init(e,t)}),dp=_("ZodIPv6",(e,t)=>{Au.init(e,t),de.init(e,t)}),pp=_("ZodCIDRv4",(e,t)=>{ju.init(e,t),de.init(e,t)}),hp=_("ZodCIDRv6",(e,t)=>{Mu.init(e,t),de.init(e,t)}),fp=_("ZodBase64",(e,t)=>{Lu.init(e,t),de.init(e,t)}),mp=_("ZodBase64URL",(e,t)=>{Uu.init(e,t),de.init(e,t)}),gp=_("ZodE164",(e,t)=>{qu.init(e,t),de.init(e,t)}),_p=_("ZodJWT",(e,t)=>{Hu.init(e,t),de.init(e,t)}),Fs=_("ZodNumber",(e,t)=>{Is.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(r,o,s)=>hd(e,r,o),Gt(e,"ZodNumber",{gt(r,o){return this.check(bo(r,o))},gte(r,o){return this.check(Wn(r,o))},min(r,o){return this.check(Wn(r,o))},lt(r,o){return this.check(vo(r,o))},lte(r,o){return this.check(Jn(r,o))},max(r,o){return this.check(Jn(r,o))},int(r){return this.check($o(r))},safe(r){return this.check($o(r))},positive(r){return this.check(bo(0,r))},nonnegative(r){return this.check(Wn(0,r))},negative(r){return this.check(vo(0,r))},nonpositive(r){return this.check(Jn(0,r))},multipleOf(r,o){return this.check(yo(r,o))},step(r,o){return this.check(yo(r,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function J(e){return ql(Fs,e)}const vp=_("ZodNumberFormat",(e,t)=>{Vu.init(e,t),Fs.init(e,t)});function $o(e){return Fl(vp,e)}const bp=_("ZodBoolean",(e,t)=>{Bu.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fd(e,n,r)});function Se(e){return Hl(bp,e)}const yp=_("ZodNull",(e,t)=>{Ju.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>md(e,n,r)});function wp(e){return Vl(yp,e)}const kp=_("ZodUnknown",(e,t)=>{Wu.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_d()});function le(){return Bl(kp)}const $p=_("ZodNever",(e,t)=>{Ku.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gd(e,n,r)});function Sp(e){return Jl($p,e)}const xp=_("ZodArray",(e,t)=>{Gu.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kd(e,n,r,o),e.element=t.element,Gt(e,"ZodArray",{min(n,r){return this.check(xn(n,r))},nonempty(n){return this.check(xn(1,n))},max(n,r){return this.check(Os(n,r))},length(n,r){return this.check(As(n,r))},unwrap(){return this.element}})});function U(e,t){return sd(xp,e,t)}const Hs=_("ZodObject",(e,t)=>{Qu.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$d(e,n,r,o),B(e,"shape",()=>t.shape),Gt(e,"ZodObject",{keyof(){return je(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:le()})},loose(){return this.clone({...this._zod.def,catchall:le()})},strict(){return this.clone({...this._zod.def,catchall:Sp()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return gc(this,n)},safeExtend(n){return _c(this,n)},merge(n){return vc(this,n)},pick(n){return fc(this,n)},omit(n){return mc(this,n)},partial(...n){return bc(Ws,this,n[0])},required(...n){return yc(Ks,this,n[0])}})});function R(e,t){const n={type:"object",shape:e??{},...T(t)};return new Hs(n)}function Ne(e,t){return new Hs({type:"object",shape:e,catchall:le(),...T(t)})}const Vs=_("ZodUnion",(e,t)=>{Cs.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sd(e,n,r,o),e.options=t.options});function se(e,t){return new Vs({type:"union",options:e,...T(t)})}const Rp=_("ZodDiscriminatedUnion",(e,t)=>{Vs.init(e,t),Xu.init(e,t)});function Bs(e,t,n){return new Rp({type:"union",options:t,discriminator:e,...T(n)})}const zp=_("ZodIntersection",(e,t)=>{el.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xd(e,n,r,o)});function wr(e,t){return new zp({type:"intersection",left:e,right:t})}const So=_("ZodRecord",(e,t)=>{tl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rd(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function ee(e,t,n){return!t||!t._zod?new So({type:"record",keyType:g(),valueType:e,...T(t)}):new So({type:"record",keyType:e,valueType:t,...T(n)})}const nr=_("ZodEnum",(e,t)=>{nl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(r,o,s)=>vd(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new nr({...t,checks:[],...T(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new nr({...t,checks:[],...T(o),entries:s})}});function je(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new nr({type:"enum",entries:n,...T(t)})}const Tp=_("ZodLiteral",(e,t)=>{rl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bd(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function I(e,t){return new Tp({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}const Ip=_("ZodTransform",(e,t)=>{ol.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wd(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hs(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(qt(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(qt(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Js(e){return new Ip({type:"transform",transform:e})}const Ws=_("ZodOptional",(e,t)=>{Ns.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ds(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ue(e){return new Ws({type:"optional",innerType:e})}const Ep=_("ZodExactOptional",(e,t)=>{sl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ds(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new Ep({type:"optional",innerType:e})}const Cp=_("ZodNullable",(e,t)=>{il.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xo(e){return new Cp({type:"nullable",innerType:e})}const Np=_("ZodDefault",(e,t)=>{al.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Id(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Zp(e,t){return new Np({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():gs(t)}})}const Op=_("ZodPrefault",(e,t)=>{cl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ed(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ap(e,t){return new Op({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():gs(t)}})}const Ks=_("ZodNonOptional",(e,t)=>{ul.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Td(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function jp(e,t){return new Ks({type:"nonoptional",innerType:e,...T(t)})}const Mp=_("ZodCatch",(e,t)=>{ll.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lp(e,t){return new Mp({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Gs=_("ZodPipe",(e,t)=>{Zs.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cd(e,n,r,o),e.in=t.in,e.out=t.out});function Ro(e,t){return new Gs({type:"pipe",in:e,out:t})}const Dp=_("ZodPreprocess",(e,t)=>{Gs.init(e,t),dl.init(e,t)}),Up=_("ZodReadonly",(e,t)=>{pl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nd(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qp(e){return new Up({type:"readonly",innerType:e})}const Ys=_("ZodCustom",(e,t)=>{hl.init(e,t),oe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yd(e,n)});function Fp(e,t){return id(Ys,e??(()=>!0),t)}function Hp(e,t={}){return ad(Ys,e,t)}function Vp(e,t){return cd(e,t)}function Qs(e,t){return new Dp({type:"pipe",in:Js(e),out:t})}const mt="io.modelcontextprotocol/related-task",Dn="2.0",ye=Fp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Xs=se([g(),J().int()]),ei=g();Ne({ttl:J().optional(),pollInterval:J().optional()});const Bp=R({ttl:J().optional()}),Jp=R({taskId:g()}),kr=Ne({progressToken:Xs.optional(),[mt]:Jp.optional()}),Me=R({_meta:kr.optional()}),Yt=Me.extend({task:Bp.optional()}),Wp=e=>Yt.safeParse(e).success,xe=R({method:g(),params:Me.loose().optional()}),He=R({_meta:kr.optional()}),Ve=R({method:g(),params:He.loose().optional()}),Re=Ne({_meta:kr.optional()}),Qt=se([g(),J().int()]),ti=R({jsonrpc:I(Dn),id:Qt,...xe.shape}).strict(),zo=e=>ti.safeParse(e).success,ni=R({jsonrpc:I(Dn),...Ve.shape}).strict(),Kp=e=>ni.safeParse(e).success,$r=R({jsonrpc:I(Dn),id:Qt,result:Re}).strict(),vn=e=>$r.safeParse(e).success;var V;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",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.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(V||(V={}));const Sr=R({jsonrpc:I(Dn),id:Qt.optional(),error:R({code:J().int(),message:g(),data:le().optional()})}).strict(),Gp=e=>Sr.safeParse(e).success,Yp=se([ti,ni,$r,Sr]);se([$r,Sr]);const ri=Re.strict(),Qp=He.extend({requestId:Qt.optional(),reason:g().optional()}),xr=Ve.extend({method:I("notifications/cancelled"),params:Qp}),Xp=R({src:g(),mimeType:g().optional(),sizes:U(g()).optional(),theme:je(["light","dark"]).optional()}),Xt=R({icons:U(Xp).optional()}),It=R({name:g(),title:g().optional()}),Un=It.extend({...It.shape,...Xt.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),eh=wr(R({applyDefaults:Se().optional()}),ee(g(),le())),th=Qs(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,wr(R({form:eh.optional(),url:ye.optional()}),ee(g(),le()).optional())),nh=Ne({list:ye.optional(),cancel:ye.optional(),requests:Ne({sampling:Ne({createMessage:ye.optional()}).optional(),elicitation:Ne({create:ye.optional()}).optional()}).optional()}),rh=Ne({list:ye.optional(),cancel:ye.optional(),requests:Ne({tools:Ne({call:ye.optional()}).optional()}).optional()}),oh=R({experimental:ee(g(),ye).optional(),sampling:R({context:ye.optional(),tools:ye.optional()}).optional(),elicitation:th.optional(),roots:R({listChanged:Se().optional()}).optional(),tasks:nh.optional(),extensions:ee(g(),ye).optional()}),sh=Me.extend({protocolVersion:g(),capabilities:oh,clientInfo:Un}),ih=xe.extend({method:I("initialize"),params:sh}),ah=R({experimental:ee(g(),ye).optional(),logging:ye.optional(),completions:ye.optional(),prompts:R({listChanged:Se().optional()}).optional(),resources:R({subscribe:Se().optional(),listChanged:Se().optional()}).optional(),tools:R({listChanged:Se().optional()}).optional(),tasks:rh.optional(),extensions:ee(g(),ye).optional()}),ch=Re.extend({protocolVersion:g(),capabilities:ah,serverInfo:Un,instructions:g().optional()}),uh=Ve.extend({method:I("notifications/initialized"),params:He.optional()}),qn=xe.extend({method:I("ping"),params:Me.optional()}),lh=R({progress:J(),total:ue(J()),message:ue(g())}),dh=R({...He.shape,...lh.shape,progressToken:Xs}),Rr=Ve.extend({method:I("notifications/progress"),params:dh}),ph=Me.extend({cursor:ei.optional()}),en=xe.extend({params:ph.optional()}),tn=Re.extend({nextCursor:ei.optional()}),hh=je(["working","input_required","completed","failed","cancelled"]),nn=R({taskId:g(),status:hh,ttl:se([J(),wp()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:ue(J()),statusMessage:ue(g())}),zr=Re.extend({task:nn}),fh=He.merge(nn),zn=Ve.extend({method:I("notifications/tasks/status"),params:fh}),Tr=xe.extend({method:I("tasks/get"),params:Me.extend({taskId:g()})}),Ir=Re.merge(nn),Er=xe.extend({method:I("tasks/result"),params:Me.extend({taskId:g()})});Re.loose();const Pr=en.extend({method:I("tasks/list")}),Cr=tn.extend({tasks:U(nn)}),Nr=xe.extend({method:I("tasks/cancel"),params:Me.extend({taskId:g()})}),mh=Re.merge(nn),oi=R({uri:g(),mimeType:ue(g()),_meta:ee(g(),le()).optional()}),si=oi.extend({text:g()}),Zr=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ii=oi.extend({blob:Zr}),rn=je(["user","assistant"]),Ct=R({audience:U(rn).optional(),priority:J().min(0).max(1).optional(),lastModified:Us({offset:!0}).optional()}),ai=R({...It.shape,...Xt.shape,uri:g(),description:ue(g()),mimeType:ue(g()),size:ue(J()),annotations:Ct.optional(),_meta:ue(Ne({}))}),gh=R({...It.shape,...Xt.shape,uriTemplate:g(),description:ue(g()),mimeType:ue(g()),annotations:Ct.optional(),_meta:ue(Ne({}))}),ci=en.extend({method:I("resources/list")}),ui=tn.extend({resources:U(ai)}),li=en.extend({method:I("resources/templates/list")}),di=tn.extend({resourceTemplates:U(gh)}),Or=Me.extend({uri:g()}),_h=Or,pi=xe.extend({method:I("resources/read"),params:_h}),hi=Re.extend({contents:U(se([si,ii]))}),fi=Ve.extend({method:I("notifications/resources/list_changed"),params:He.optional()}),vh=Or,bh=xe.extend({method:I("resources/subscribe"),params:vh}),yh=Or,wh=xe.extend({method:I("resources/unsubscribe"),params:yh}),kh=He.extend({uri:g()}),$h=Ve.extend({method:I("notifications/resources/updated"),params:kh}),Sh=R({name:g(),description:ue(g()),required:ue(Se())}),xh=R({...It.shape,...Xt.shape,description:ue(g()),arguments:ue(U(Sh)),_meta:ue(Ne({}))}),mi=en.extend({method:I("prompts/list")}),gi=tn.extend({prompts:U(xh)}),Rh=Me.extend({name:g(),arguments:ee(g(),g()).optional()}),zh=xe.extend({method:I("prompts/get"),params:Rh}),Ar=R({type:I("text"),text:g(),annotations:Ct.optional(),_meta:ee(g(),le()).optional()}),jr=R({type:I("image"),data:Zr,mimeType:g(),annotations:Ct.optional(),_meta:ee(g(),le()).optional()}),Mr=R({type:I("audio"),data:Zr,mimeType:g(),annotations:Ct.optional(),_meta:ee(g(),le()).optional()}),Th=R({type:I("tool_use"),name:g(),id:g(),input:ee(g(),le()),_meta:ee(g(),le()).optional()}),_i=R({type:I("resource"),resource:se([si,ii]),annotations:Ct.optional(),_meta:ee(g(),le()).optional()}),vi=ai.extend({type:I("resource_link")}),on=se([Ar,jr,Mr,vi,_i]),Ih=R({role:rn,content:on}),Eh=Re.extend({description:g().optional(),messages:U(Ih)}),bi=Ve.extend({method:I("notifications/prompts/list_changed"),params:He.optional()}),Ph=R({title:g().optional(),readOnlyHint:Se().optional(),destructiveHint:Se().optional(),idempotentHint:Se().optional(),openWorldHint:Se().optional()}),Ch=R({taskSupport:je(["required","optional","forbidden"]).optional()}),Lr=R({...It.shape,...Xt.shape,description:g().optional(),inputSchema:R({type:I("object"),properties:ee(g(),ye).optional(),required:U(g()).optional()}).catchall(le()),outputSchema:R({type:I("object"),properties:ee(g(),ye).optional(),required:U(g()).optional()}).catchall(le()).optional(),annotations:Ph.optional(),execution:Ch.optional(),_meta:ee(g(),le()).optional()}),Nh=en.extend({method:I("tools/list")}),yi=tn.extend({tools:U(Lr)}),Ft=Re.extend({content:U(on).default([]),structuredContent:ee(g(),le()).optional(),isError:Se().optional()});Ft.or(Re.extend({toolResult:le()}));const Zh=Yt.extend({name:g(),arguments:ee(g(),le()).optional()}),wi=xe.extend({method:I("tools/call"),params:Zh}),ki=Ve.extend({method:I("notifications/tools/list_changed"),params:He.optional()});R({autoRefresh:Se().default(!0),debounceMs:J().int().nonnegative().default(300)});const $i=je(["debug","info","notice","warning","error","critical","alert","emergency"]),Oh=Me.extend({level:$i}),Ah=xe.extend({method:I("logging/setLevel"),params:Oh}),jh=He.extend({level:$i,logger:g().optional(),data:le()}),Si=Ve.extend({method:I("notifications/message"),params:jh}),Mh=R({name:g().optional()}),Lh=R({hints:U(Mh).optional(),costPriority:J().min(0).max(1).optional(),speedPriority:J().min(0).max(1).optional(),intelligencePriority:J().min(0).max(1).optional()}),Dh=R({mode:je(["auto","required","none"]).optional()}),Uh=R({type:I("tool_result"),toolUseId:g().describe("The unique identifier for the corresponding tool call."),content:U(on).default([]),structuredContent:R({}).loose().optional(),isError:Se().optional(),_meta:ee(g(),le()).optional()}),qh=Bs("type",[Ar,jr,Mr]),Tn=Bs("type",[Ar,jr,Mr,Th,Uh]),Fh=R({role:rn,content:se([Tn,U(Tn)]),_meta:ee(g(),le()).optional()}),Hh=Yt.extend({messages:U(Fh),modelPreferences:Lh.optional(),systemPrompt:g().optional(),includeContext:je(["none","thisServer","allServers"]).optional(),temperature:J().optional(),maxTokens:J().int(),stopSequences:U(g()).optional(),metadata:ye.optional(),tools:U(Lr).optional(),toolChoice:Dh.optional()}),xi=xe.extend({method:I("sampling/createMessage"),params:Hh}),Vh=Re.extend({model:g(),stopReason:ue(je(["endTurn","stopSequence","maxTokens"]).or(g())),role:rn,content:qh}),Bh=Re.extend({model:g(),stopReason:ue(je(["endTurn","stopSequence","maxTokens","toolUse"]).or(g())),role:rn,content:se([Tn,U(Tn)])}),Jh=R({type:I("boolean"),title:g().optional(),description:g().optional(),default:Se().optional()}),Wh=R({type:I("string"),title:g().optional(),description:g().optional(),minLength:J().optional(),maxLength:J().optional(),format:je(["email","uri","date","date-time"]).optional(),default:g().optional()}),Kh=R({type:je(["number","integer"]),title:g().optional(),description:g().optional(),minimum:J().optional(),maximum:J().optional(),default:J().optional()}),Gh=R({type:I("string"),title:g().optional(),description:g().optional(),enum:U(g()),default:g().optional()}),Yh=R({type:I("string"),title:g().optional(),description:g().optional(),oneOf:U(R({const:g(),title:g()})),default:g().optional()}),Qh=R({type:I("string"),title:g().optional(),description:g().optional(),enum:U(g()),enumNames:U(g()).optional(),default:g().optional()}),Xh=se([Gh,Yh]),ef=R({type:I("array"),title:g().optional(),description:g().optional(),minItems:J().optional(),maxItems:J().optional(),items:R({type:I("string"),enum:U(g())}),default:U(g()).optional()}),tf=R({type:I("array"),title:g().optional(),description:g().optional(),minItems:J().optional(),maxItems:J().optional(),items:R({anyOf:U(R({const:g(),title:g()}))}),default:U(g()).optional()}),nf=se([ef,tf]),rf=se([Qh,Xh,nf]),of=se([rf,Jh,Wh,Kh]),sf=Yt.extend({mode:I("form").optional(),message:g(),requestedSchema:R({type:I("object"),properties:ee(g(),of),required:U(g()).optional()})}),af=Yt.extend({mode:I("url"),message:g(),elicitationId:g(),url:g().url()}),cf=se([sf,af]),uf=xe.extend({method:I("elicitation/create"),params:cf}),lf=He.extend({elicitationId:g()}),df=Ve.extend({method:I("notifications/elicitation/complete"),params:lf}),pf=Re.extend({action:je(["accept","decline","cancel"]),content:Qs(e=>e===null?void 0:e,ee(g(),se([g(),J(),Se(),U(g())])).optional())}),hf=R({type:I("ref/resource"),uri:g()}),ff=R({type:I("ref/prompt"),name:g()}),mf=Me.extend({ref:se([ff,hf]),argument:R({name:g(),value:g()}),context:R({arguments:ee(g(),g()).optional()}).optional()}),gf=xe.extend({method:I("completion/complete"),params:mf}),_f=Re.extend({completion:Ne({values:U(g()).max(100),total:ue(J().int()),hasMore:ue(Se())})}),vf=R({uri:g().startsWith("file://"),name:g().optional(),_meta:ee(g(),le()).optional()}),bf=xe.extend({method:I("roots/list"),params:Me.optional()}),yf=Re.extend({roots:U(vf)}),wf=Ve.extend({method:I("notifications/roots/list_changed"),params:He.optional()});se([qn,ih,gf,Ah,zh,mi,ci,li,pi,bh,wh,wi,Nh,Tr,Er,Pr,Nr]);se([xr,Rr,uh,wf,zn]);se([ri,Vh,Bh,pf,yf,Ir,Cr,zr]);se([qn,xi,uf,bf,Tr,Er,Pr,Nr]);se([xr,Rr,Si,$h,fi,ki,bi,zn,df]);se([ri,ch,_f,Eh,gi,ui,di,hi,Ft,yi,Ir,Cr,zr]);class q extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===V.UrlElicitationRequired&&r){const o=r;if(o.elicitations)return new kf(o.elicitations,n)}return new q(t,n,r)}}class kf extends q{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(V.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Dr(e){return!!e._zod}function Ri(e,t){return Dr(e)?ys(e,t):e.safeParse(t)}function $f(e){if(!e)return;let t;if(Dr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Sf(e){if(Dr(e)){const s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}function ht(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function To(e){const n=$f(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=Sf(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Io(e,t){const n=Ri(e,t);if(!n.success)throw n.error;return n.data}const xf=6e4;class Rf{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(xr,n=>{this._oncancel(n)}),this.setNotificationHandler(Rr,n=>{this._onprogress(n)}),this.setRequestHandler(qn,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Tr,async(n,r)=>{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new q(V.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Er,async(n,r)=>{const o=async()=>{const s=n.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,r.sessionId);){if(a.type==="response"||a.type==="error"){const c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{const p=c,h=new q(p.error.code,p.error.message,p.error.data);l(h)}else{const p=a.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const i=await this._taskStore.getTask(s,r.sessionId);if(!i)throw new q(V.InvalidParams,`Task not found: ${s}`);if(!ht(i.status))return await this._waitForTaskUpdate(s,r.signal),await o();if(ht(i.status)){const a=await this._taskStore.getTaskResult(s,r.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[mt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Pr,async(n,r)=>{try{const{tasks:o,nextCursor:s}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new q(V.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Nr,async(n,r)=>{try{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new q(V.InvalidParams,`Task not found: ${n.params.taskId}`);if(ht(o.status))throw new q(V.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId);const s=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!s)throw new q(V.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof q?o:new q(V.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),q.fromError(V.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=s=>{r?.(s),this._onerror(s)};const o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),vn(s)||Gp(s)?this._onresponse(s):zo(s)?this._onrequest(s,i):Kp(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=q.fromError(V.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[mt]?.taskId;if(r===void 0){const l={jsonrpc:"2.0",id:t.id,error:{code:V.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):o?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const a=Wp(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;const p={relatedRequestId:t.id};s&&(p.relatedTask={taskId:s}),await this.notification(l,p)},sendRequest:async(l,p,h)=>{if(i.signal.aborted)throw new q(V.ConnectionClosed,"Request was cancelled");const f={...h,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});const y=f.relatedTask?.taskId??s;return y&&c&&await c.updateTaskStatus(y,"input_required"),await this.request(l,p,f)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,u)).then(async l=>{if(i.signal.aborted)return;const p={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)},async l=>{if(i.signal.aborted)return;const p={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:V.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,o=Number(n),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),vn(t))r(t);else{const i=new q(t.error.code,t.error.message,t.error.data);r(i)}return}const o=this._responseHandlers.get(n);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(vn(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),vn(t))o(t);else{const i=q.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:o}=r??{};if(!o){try{yield{type:"result",result:await this.request(t,n,r)}}catch(i){yield{type:"error",error:i instanceof q?i:new q(V.InternalError,String(i))}}return}let s;try{const i=await this.request(t,zr,r);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new q(V.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:s},r);if(yield{type:"taskStatus",task:a},ht(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)}:a.status==="failed"?yield{type:"error",error:new q(V.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new q(V.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),r?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof q?i:new q(V.InternalError,String(i))}}}request(t,n,r){const{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=r??{};return new Promise((u,l)=>{const p=z=>{l(z)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(z){p(z);return}r?.signal?.throwIfAborted();const h=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:h}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[mt]:c}});const y=z=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(z)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));const w=z instanceof q?z:new q(V.RequestTimeout,String(z));l(w)};this._responseHandlers.set(h,z=>{if(!r?.signal?.aborted){if(z instanceof Error)return l(z);try{const w=Ri(n,z.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),r?.signal?.addEventListener("abort",()=>{y(r?.signal?.reason)});const Z=r?.timeout??xf,x=()=>y(q.fromError(V.RequestTimeout,"Request timed out",{timeout:Z}));this._setupTimeout(h,Z,r?.maxTotalTimeout,x,r?.resetTimeoutOnProgress??!1);const j=c?.taskId;if(j){const z=w=>{const $=this._responseHandlers.get(h);$?$(w):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,z),this._enqueueTaskMessage(j,{type:"request",message:f,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(h),l(w)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(z=>{this._cleanupTimeout(h),l(z)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Ir,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Cr,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},mh,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[mt]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[mt]:n.relatedTask}}}),this._transport?.send(a,n).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};n?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[mt]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(t,n){const r=To(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(o,s)=>{const i=Io(t,o);return Promise.resolve(n(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=To(t);this._notificationHandlers.set(r,o=>{const s=Io(t,o);return Promise.resolve(n(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r,o)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const o of r)if(o.type==="request"&&zo(o.message)){const s=o.message.id,i=this._requestResolvers.get(s);i?(i(new q(V.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){let r=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t);o?.pollInterval&&(r=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new q(V.InvalidRequest,"Request cancelled"));return}const i=setTimeout(o,r);n.addEventListener("abort",()=>{clearTimeout(i),s(new q(V.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await r.createTask(o,t.id,{method:t.method,params:t.params},n)},getTask:async o=>{const s=await r.getTask(o,n);if(!s)throw new q(V.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await r.storeTaskResult(o,s,i,n);const a=await r.getTask(o,n);if(a){const c=zn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),ht(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>r.getTaskResult(o,n),updateTaskStatus:async(o,s,i)=>{const a=await r.getTask(o,n);if(!a)throw new q(V.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(ht(a.status))throw new q(V.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(o,s,i,n);const c=await r.getTask(o,n);if(c){const u=zn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),ht(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>r.listTasks(o,n)}}}function v(e,t,n){function r(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(e),t(a,c);for(const l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Ht extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const zi={};function st(e){return zi}function zf(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Tf(e,t){return typeof t=="bigint"?t.toString():t}function Ti(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ur(e){return e==null}function qr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function If(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function te(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Fr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Mt(e){return JSON.stringify(e)}const Ii=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ef=Ti(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function In(e){if(rr(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(rr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const Pf=new Set(["string","number","symbol"]);function sn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vt(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function E(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 Cf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Nf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Zf(e,t){const n={},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(n[o]=r.shape[o])}return vt(e,{...e._zod.def,shape:n,checks:[]})}function Of(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete n[o]}return vt(e,{...e._zod.def,shape:n,checks:[]})}function Af(e,t){if(!In(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return Fr(this,"shape",r),r},checks:[]};return vt(e,n)}function jf(e,t){return vt(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Fr(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}function Mf(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)o[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return vt(t,{...t._zod.def,shape:o,checks:[]})}function Lf(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return vt(t,{...t._zod.def,shape:o,checks:[]})}function Dt(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function gt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function bn(e){return typeof e=="string"?e:e?.message}function it(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=bn(e.inst?._zod.def?.error?.(e))??bn(t?.error?.(e))??bn(n.customError?.(e))??bn(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Hr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Vt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ei=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Tf,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Pi=v("$ZodError",Ei),Ci=v("$ZodError",Ei,{Parent:Error});function Df(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Uf(e,t){const n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(e),r}const qf=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Ht;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>it(c,s,st())));throw Ii(a,o?.callee),a}return i.value},Ff=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>it(c,s,st())));throw Ii(a,o?.callee),a}return i.value},Ni=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Ht;return s.issues.length?{success:!1,error:new(e??Pi)(s.issues.map(i=>it(i,o,st())))}:{success:!0,data:s.value}},Hf=Ni(Ci),Zi=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>it(i,o,st())))}:{success:!0,data:s.value}},Vf=Zi(Ci),Bf=/^[cC][^\s-]{8,}$/,Jf=/^[0-9a-z]+$/,Wf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Kf=/^[0-9a-vA-V]{20}$/,Gf=/^[A-Za-z0-9]{27}$/,Yf=/^[a-zA-Z0-9_-]{21}$/,Qf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xf=/^([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})$/,Eo=e=>e?new 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)$/,em=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function nm(){return new RegExp(tm,"u")}const rm=/^(?:(?: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])$/,om=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,sm=/^((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])$/,im=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,am=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Oi=/^[A-Za-z0-9_-]*$/,cm=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,um=/^\+(?:[0-9]){6,14}[0-9]$/,Ai="(?:(?:\\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])))",lm=new RegExp(`^${Ai}$`);function ji(e){const 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}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function dm(e){return new RegExp(`^${ji(e)}$`)}function pm(e){const t=ji({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ai}T(?:${r})$`)}const hm=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},fm=/^\d+$/,mm=/^-?\d+(?:\.\d+)?/i,gm=/true|false/i,_m=/undefined/i,vm=/^[^A-Z]*$/,bm=/^[^a-z]*$/,Oe=v("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Mi={number:"number",bigint:"bigint",object:"date"},Li=v("$ZodCheckLessThan",(e,t)=>{Oe.init(e,t);const n=Mi[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Di=v("$ZodCheckGreaterThan",(e,t)=>{Oe.init(e,t);const n=Mi[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ym=v("$ZodCheckMultipleOf",(e,t)=>{Oe.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):If(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})}}),wm=v("$ZodCheckNumberFormat",(e,t)=>{Oe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Nf[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=fm)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}}),km=v("$ZodCheckMaxLength",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ur(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Hr(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$m=v("$ZodCheckMinLength",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ur(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Hr(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Sm=v("$ZodCheckLengthEquals",(e,t)=>{var n;Oe.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Ur(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=Hr(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Fn=v("$ZodCheckStringFormat",(e,t)=>{var n,r;Oe.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xm=v("$ZodCheckRegex",(e,t)=>{Fn.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})}}),Rm=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vm),Fn.init(e,t)}),zm=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bm),Fn.init(e,t)}),Tm=v("$ZodCheckIncludes",(e,t)=>{Oe.init(e,t);const n=sn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Im=v("$ZodCheckStartsWith",(e,t)=>{Oe.init(e,t);const n=new RegExp(`^${sn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Em=v("$ZodCheckEndsWith",(e,t)=>{Oe.init(e,t);const n=new RegExp(`.*${sn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Pm=v("$ZodCheckOverwrite",(e,t)=>{Oe.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Cm{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
65
- `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
66
- `))}}const Nm={major:4,minor:0,patch:0},Q=v("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nm;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,i,a)=>{let c=Dt(s),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;const p=s.issues.length,h=l._zod.check(s);if(h instanceof Promise&&a?.async===!1)throw new Ht;if(u||h instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await h,s.issues.length!==p&&(c||(c=Dt(s,p)))});else{if(s.issues.length===p)continue;c||(c=Dt(s,p))}}return u?u.then(()=>s):s};e._zod.run=(s,i)=>{const a=e._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new Ht;return a.then(c=>o(c,r,i))}return o(a,r,i)}}e["~standard"]={validate:o=>{try{const s=Hf(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Vf(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Vr=v("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??hm(e._zod.bag),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}}),ie=v("$ZodStringFormat",(e,t)=>{Fn.init(e,t),Vr.init(e,t)}),Zm=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Xf),ie.init(e,t)}),Om=v("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Eo(r))}else t.pattern??(t.pattern=Eo());ie.init(e,t)}),Am=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=em),ie.init(e,t)}),jm=v("$ZodURL",(e,t)=>{ie.init(e,t),e._zod.check=n=>{try{const r=n.value,o=new URL(r),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:cm.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith("/")&&s.endsWith("/")?n.value=s.slice(0,-1):n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Mm=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=nm()),ie.init(e,t)}),Lm=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Yf),ie.init(e,t)}),Dm=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bf),ie.init(e,t)}),Um=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jf),ie.init(e,t)}),qm=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wf),ie.init(e,t)}),Fm=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Kf),ie.init(e,t)}),Hm=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Gf),ie.init(e,t)}),Vm=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pm(t)),ie.init(e,t)}),Bm=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lm),ie.init(e,t)}),Jm=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=dm(t)),ie.init(e,t)}),Wm=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qf),ie.init(e,t)}),Km=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=rm),ie.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),Gm=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=om),ie.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Ym=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=sm),ie.init(e,t)}),Qm=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=im),ie.init(e,t),e._zod.check=n=>{const[r,o]=n.value.split("/");try{if(!o)throw new Error;const s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ui(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Xm=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=am),ie.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{Ui(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eg(e){if(!Oi.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ui(n)}const tg=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Oi),ie.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{eg(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ng=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=um),ie.init(e,t)});function rg(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const og=v("$ZodJWT",(e,t)=>{ie.init(e,t),e._zod.check=n=>{rg(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),qi=v("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??mm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),sg=v("$ZodNumber",(e,t)=>{wm.init(e,t),qi.init(e,t)}),ig=v("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=gm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),ag=v("$ZodUndefined",(e,t)=>{Q.init(e,t),e._zod.pattern=_m,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),cg=v("$ZodAny",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),ug=v("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),lg=v("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Po(e,t,n){e.issues.length&&t.issues.push(...gt(n,e.issues)),t.value[n]=e.value}const dg=v("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Po(u,n,i))):Po(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function yn(e,t,n){e.issues.length&&t.issues.push(...gt(n,e.issues)),t.value[n]=e.value}function Co(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...gt(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const pg=v("$ZodObject",(e,t)=>{Q.init(e,t);const n=Ti(()=>{const p=Object.keys(t.shape);for(const f of p)if(!(t.shape[f]instanceof Q))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);const h=Cf(t.shape);return{shape:t.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(h)}});te(e._zod,"propValues",()=>{const p=t.shape,h={};for(const f in p){const y=p[f]._zod;if(y.values){h[f]??(h[f]=new Set);for(const Z of y.values)h[f].add(Z)}}return h});const r=p=>{const h=new Cm(["shape","payload","ctx"]),f=n.value,y=z=>{const w=Mt(z);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};h.write("const input = payload.value;");const Z=Object.create(null);let x=0;for(const z of f.keys)Z[z]=`key_${x++}`;h.write("const newResult = {}");for(const z of f.keys)if(f.optionalKeys.has(z)){const w=Z[z];h.write(`const ${w} = ${y(z)};`);const $=Mt(z);h.write(`
67
- if (${w}.issues.length) {
68
- if (input[${$}] === undefined) {
69
- if (${$} in input) {
70
- newResult[${$}] = undefined;
71
- }
72
- } else {
73
- payload.issues = payload.issues.concat(
74
- ${w}.issues.map((iss) => ({
75
- ...iss,
76
- path: iss.path ? [${$}, ...iss.path] : [${$}],
77
- }))
78
- );
79
- }
80
- } else if (${w}.value === undefined) {
81
- if (${$} in input) newResult[${$}] = undefined;
82
- } else {
83
- newResult[${$}] = ${w}.value;
84
- }
85
- `)}else{const w=Z[z];h.write(`const ${w} = ${y(z)};`),h.write(`
86
- if (${w}.issues.length) payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
87
- ...iss,
88
- path: iss.path ? [${Mt(z)}, ...iss.path] : [${Mt(z)}]
89
- })));`),h.write(`newResult[${Mt(z)}] = ${w}.value`)}h.write("payload.value = newResult;"),h.write("return payload;");const j=h.compile();return(z,w)=>j(p,z,w)};let o;const s=rr,i=!zi.jitless,c=i&&Ef.value,u=t.catchall;let l;e._zod.parse=(p,h)=>{l??(l=n.value);const f=p.value;if(!s(f))return p.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),p;const y=[];if(i&&c&&h?.async===!1&&h.jitless!==!0)o||(o=r(t.shape)),p=o(p,h);else{p.value={};const w=l.shape;for(const $ of l.keys){const A=w[$],M=A._zod.run({value:f[$],issues:[]},h),W=A._zod.optin==="optional"&&A._zod.optout==="optional";M instanceof Promise?y.push(M.then($e=>W?Co($e,p,$,f):yn($e,p,$))):W?Co(M,p,$,f):yn(M,p,$)}}if(!u)return y.length?Promise.all(y).then(()=>p):p;const Z=[],x=l.keySet,j=u._zod,z=j.def.type;for(const w of Object.keys(f)){if(x.has(w))continue;if(z==="never"){Z.push(w);continue}const $=j.run({value:f[w],issues:[]},h);$ instanceof Promise?y.push($.then(A=>yn(A,p,w))):yn($,p,w)}return Z.length&&p.issues.push({code:"unrecognized_keys",keys:Z,input:f,inst:e}),y.length?Promise.all(y).then(()=>p):p}});function No(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>it(s,r,st())))}),t}const hg=v("$ZodUnion",(e,t)=>{Q.init(e,t),te(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),te(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),te(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),te(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>qr(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>No(i,n,e,r)):No(s,n,e,r)}}),fg=v("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Zo(n,c,u)):Zo(n,s,i)}});function or(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(In(e)&&In(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=or(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=or(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zo(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Dt(e))return e;const r=or(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const mg=v("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!In(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;n.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=t.valueType._zod.run({value:o[c],issues:[]},r);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&n.issues.push(...gt(c,l.issues)),n.value[c]=l.value})):(u.issues.length&&n.issues.push(...gt(c,u.issues)),n.value[c]=u.value)}let a;for(const c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(o)){if(i==="__proto__")continue;const a=t.keyType._zod.run({value:i,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>it(u,r,st())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:o[i],issues:[]},r);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&n.issues.push(...gt(i,u.issues)),n.value[a.value]=u.value})):(c.issues.length&&n.issues.push(...gt(i,c.issues)),n.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>n):n}}),gg=v("$ZodEnum",(e,t)=>{Q.init(e,t);const n=zf(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>Pf.has(typeof r)).map(r=>typeof r=="string"?sn(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),_g=v("$ZodLiteral",(e,t)=>{Q.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?sn(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),vg=v("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(n,r)=>{const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Ht;return n.value=o,n}}),bg=v("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${qr(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),yg=v("$ZodNullable",(e,t)=>{Q.init(e,t),te(e._zod,"optin",()=>t.innerType._zod.optin),te(e._zod,"optout",()=>t.innerType._zod.optout),te(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${qr(n.source)}|null)$`):void 0}),te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),wg=v("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Oo(s,t)):Oo(o,t)}});function Oo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const kg=v("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$g=v("$ZodNonOptional",(e,t)=>{Q.init(e,t),te(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ao(s,e)):Ao(o,e)}});function Ao(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Sg=v("$ZodCatch",(e,t)=>{Q.init(e,t),e._zod.optin="optional",te(e._zod,"optout",()=>t.innerType._zod.optout),te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>it(i,r,st()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>it(s,r,st()))},input:n.value}),n.issues=[]),n)}}),xg=v("$ZodPipe",(e,t)=>{Q.init(e,t),te(e._zod,"values",()=>t.in._zod.values),te(e._zod,"optin",()=>t.in._zod.optin),te(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>jo(s,t,r)):jo(o,t,r)}});function jo(e,t,n){return Dt(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Rg=v("$ZodReadonly",(e,t)=>{Q.init(e,t),te(e._zod,"propValues",()=>t.innerType._zod.propValues),te(e._zod,"values",()=>t.innerType._zod.values),te(e._zod,"optin",()=>t.innerType._zod.optin),te(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Mo):Mo(o)}});function Mo(e){return e.value=Object.freeze(e.value),e}const zg=v("$ZodCustom",(e,t)=>{Oe.init(e,t),Q.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Lo(s,n,r,e));Lo(o,n,r,e)}});function Lo(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Vt(o))}}class Tg{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function Ig(){return new Tg}const wn=Ig();function Eg(e,t){return new e({type:"string",...E(t)})}function Pg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function Do(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Cg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function Ng(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function Zg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function Og(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function Ag(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function jg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function Mg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function Lg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function Dg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function Ug(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function qg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function Fg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function Hg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function Vg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function Bg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function Jg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function Wg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function Kg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function Gg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function Yg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}function Qg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function Xg(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function e_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function t_(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function n_(e,t){return new e({type:"number",checks:[],...E(t)})}function r_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function o_(e,t){return new e({type:"boolean",...E(t)})}function s_(e,t){return new e({type:"undefined",...E(t)})}function i_(e){return new e({type:"any"})}function a_(e){return new e({type:"unknown"})}function c_(e,t){return new e({type:"never",...E(t)})}function Uo(e,t){return new Li({check:"less_than",...E(t),value:e,inclusive:!1})}function Kn(e,t){return new Li({check:"less_than",...E(t),value:e,inclusive:!0})}function qo(e,t){return new Di({check:"greater_than",...E(t),value:e,inclusive:!1})}function Gn(e,t){return new Di({check:"greater_than",...E(t),value:e,inclusive:!0})}function Fo(e,t){return new ym({check:"multiple_of",...E(t),value:e})}function Fi(e,t){return new km({check:"max_length",...E(t),maximum:e})}function En(e,t){return new $m({check:"min_length",...E(t),minimum:e})}function Hi(e,t){return new Sm({check:"length_equals",...E(t),length:e})}function u_(e,t){return new xm({check:"string_format",format:"regex",...E(t),pattern:e})}function l_(e){return new Rm({check:"string_format",format:"lowercase",...E(e)})}function d_(e){return new zm({check:"string_format",format:"uppercase",...E(e)})}function p_(e,t){return new Tm({check:"string_format",format:"includes",...E(t),includes:e})}function h_(e,t){return new Im({check:"string_format",format:"starts_with",...E(t),prefix:e})}function f_(e,t){return new Em({check:"string_format",format:"ends_with",...E(t),suffix:e})}function an(e){return new Pm({check:"overwrite",tx:e})}function m_(e){return an(t=>t.normalize(e))}function g_(){return an(e=>e.trim())}function __(){return an(e=>e.toLowerCase())}function v_(){return an(e=>e.toUpperCase())}function b_(e,t,n){return new e({type:"array",element:t,...E(n)})}function y_(e,t,n){return new e({type:"custom",check:"custom",fn:t,...E(n)})}const w_=v("ZodISODateTime",(e,t)=>{Vm.init(e,t),pe.init(e,t)});function k_(e){return Qg(w_,e)}const $_=v("ZodISODate",(e,t)=>{Bm.init(e,t),pe.init(e,t)});function S_(e){return Xg($_,e)}const x_=v("ZodISOTime",(e,t)=>{Jm.init(e,t),pe.init(e,t)});function R_(e){return e_(x_,e)}const z_=v("ZodISODuration",(e,t)=>{Wm.init(e,t),pe.init(e,t)});function T_(e){return t_(z_,e)}const I_=(e,t)=>{Pi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Uf(e,n)},flatten:{value:n=>Df(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},Hn=v("ZodError",I_,{Parent:Error}),E_=qf(Hn),P_=Ff(Hn),C_=Ni(Hn),N_=Zi(Hn),ae=v("ZodType",(e,t)=>(Q.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>vt(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>E_(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>C_(e,n,r),e.parseAsync=async(n,r)=>P_(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>N_(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(zv(n,r)),e.superRefine=n=>e.check(Tv(n)),e.overwrite=n=>e.check(an(n)),e.optional=()=>Bo(e),e.nullable=()=>Jo(e),e.nullish=()=>Bo(Jo(e)),e.nonoptional=n=>bv(e,n),e.array=()=>qe(e),e.or=n=>Ue([e,n]),e.and=n=>cv(e,n),e.transform=n=>Wo(e,hv(n)),e.default=n=>gv(e,n),e.prefault=n=>vv(e,n),e.catch=n=>wv(e,n),e.pipe=n=>Wo(e,n),e.readonly=()=>Sv(e),e.describe=n=>{const r=e.clone();return wn.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return wn.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return wn.get(e);const r=e.clone();return wn.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Vi=v("_ZodString",(e,t)=>{Vr.init(e,t),ae.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(u_(...r)),e.includes=(...r)=>e.check(p_(...r)),e.startsWith=(...r)=>e.check(h_(...r)),e.endsWith=(...r)=>e.check(f_(...r)),e.min=(...r)=>e.check(En(...r)),e.max=(...r)=>e.check(Fi(...r)),e.length=(...r)=>e.check(Hi(...r)),e.nonempty=(...r)=>e.check(En(1,...r)),e.lowercase=r=>e.check(l_(r)),e.uppercase=r=>e.check(d_(r)),e.trim=()=>e.check(g_()),e.normalize=(...r)=>e.check(m_(...r)),e.toLowerCase=()=>e.check(__()),e.toUpperCase=()=>e.check(v_())}),Z_=v("ZodString",(e,t)=>{Vr.init(e,t),Vi.init(e,t),e.email=n=>e.check(Pg(O_,n)),e.url=n=>e.check(Ag(A_,n)),e.jwt=n=>e.check(Yg(Y_,n)),e.emoji=n=>e.check(jg(j_,n)),e.guid=n=>e.check(Do(Ho,n)),e.uuid=n=>e.check(Cg(kn,n)),e.uuidv4=n=>e.check(Ng(kn,n)),e.uuidv6=n=>e.check(Zg(kn,n)),e.uuidv7=n=>e.check(Og(kn,n)),e.nanoid=n=>e.check(Mg(M_,n)),e.guid=n=>e.check(Do(Ho,n)),e.cuid=n=>e.check(Lg(L_,n)),e.cuid2=n=>e.check(Dg(D_,n)),e.ulid=n=>e.check(Ug(U_,n)),e.base64=n=>e.check(Wg(W_,n)),e.base64url=n=>e.check(Kg(K_,n)),e.xid=n=>e.check(qg(q_,n)),e.ksuid=n=>e.check(Fg(F_,n)),e.ipv4=n=>e.check(Hg(H_,n)),e.ipv6=n=>e.check(Vg(V_,n)),e.cidrv4=n=>e.check(Bg(B_,n)),e.cidrv6=n=>e.check(Jg(J_,n)),e.e164=n=>e.check(Gg(G_,n)),e.datetime=n=>e.check(k_(n)),e.date=n=>e.check(S_(n)),e.time=n=>e.check(R_(n)),e.duration=n=>e.check(T_(n))});function Y(e){return Eg(Z_,e)}const pe=v("ZodStringFormat",(e,t)=>{ie.init(e,t),Vi.init(e,t)}),O_=v("ZodEmail",(e,t)=>{Am.init(e,t),pe.init(e,t)}),Ho=v("ZodGUID",(e,t)=>{Zm.init(e,t),pe.init(e,t)}),kn=v("ZodUUID",(e,t)=>{Om.init(e,t),pe.init(e,t)}),A_=v("ZodURL",(e,t)=>{jm.init(e,t),pe.init(e,t)}),j_=v("ZodEmoji",(e,t)=>{Mm.init(e,t),pe.init(e,t)}),M_=v("ZodNanoID",(e,t)=>{Lm.init(e,t),pe.init(e,t)}),L_=v("ZodCUID",(e,t)=>{Dm.init(e,t),pe.init(e,t)}),D_=v("ZodCUID2",(e,t)=>{Um.init(e,t),pe.init(e,t)}),U_=v("ZodULID",(e,t)=>{qm.init(e,t),pe.init(e,t)}),q_=v("ZodXID",(e,t)=>{Fm.init(e,t),pe.init(e,t)}),F_=v("ZodKSUID",(e,t)=>{Hm.init(e,t),pe.init(e,t)}),H_=v("ZodIPv4",(e,t)=>{Km.init(e,t),pe.init(e,t)}),V_=v("ZodIPv6",(e,t)=>{Gm.init(e,t),pe.init(e,t)}),B_=v("ZodCIDRv4",(e,t)=>{Ym.init(e,t),pe.init(e,t)}),J_=v("ZodCIDRv6",(e,t)=>{Qm.init(e,t),pe.init(e,t)}),W_=v("ZodBase64",(e,t)=>{Xm.init(e,t),pe.init(e,t)}),K_=v("ZodBase64URL",(e,t)=>{tg.init(e,t),pe.init(e,t)}),G_=v("ZodE164",(e,t)=>{ng.init(e,t),pe.init(e,t)}),Y_=v("ZodJWT",(e,t)=>{og.init(e,t),pe.init(e,t)}),Bi=v("ZodNumber",(e,t)=>{qi.init(e,t),ae.init(e,t),e.gt=(r,o)=>e.check(qo(r,o)),e.gte=(r,o)=>e.check(Gn(r,o)),e.min=(r,o)=>e.check(Gn(r,o)),e.lt=(r,o)=>e.check(Uo(r,o)),e.lte=(r,o)=>e.check(Kn(r,o)),e.max=(r,o)=>e.check(Kn(r,o)),e.int=r=>e.check(Vo(r)),e.safe=r=>e.check(Vo(r)),e.positive=r=>e.check(qo(0,r)),e.nonnegative=r=>e.check(Gn(0,r)),e.negative=r=>e.check(Uo(0,r)),e.nonpositive=r=>e.check(Kn(0,r)),e.multipleOf=(r,o)=>e.check(Fo(r,o)),e.step=(r,o)=>e.check(Fo(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function We(e){return n_(Bi,e)}const Q_=v("ZodNumberFormat",(e,t)=>{sg.init(e,t),Bi.init(e,t)});function Vo(e){return r_(Q_,e)}const X_=v("ZodBoolean",(e,t)=>{ig.init(e,t),ae.init(e,t)});function Xe(e){return o_(X_,e)}const ev=v("ZodUndefined",(e,t)=>{ag.init(e,t),ae.init(e,t)});function sr(e){return s_(ev,e)}const tv=v("ZodAny",(e,t)=>{cg.init(e,t),ae.init(e,t)});function Ji(){return i_(tv)}const nv=v("ZodUnknown",(e,t)=>{ug.init(e,t),ae.init(e,t)});function Et(){return a_(nv)}const rv=v("ZodNever",(e,t)=>{lg.init(e,t),ae.init(e,t)});function ir(e){return c_(rv,e)}const ov=v("ZodArray",(e,t)=>{dg.init(e,t),ae.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(En(n,r)),e.nonempty=n=>e.check(En(1,n)),e.max=(n,r)=>e.check(Fi(n,r)),e.length=(n,r)=>e.check(Hi(n,r)),e.unwrap=()=>e.element});function qe(e,t){return b_(ov,e,t)}const sv=v("ZodObject",(e,t)=>{pg.init(e,t),ae.init(e,t),te(e,"shape",()=>t.shape),e.keyof=()=>lv(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Et()}),e.loose=()=>e.clone({...e._zod.def,catchall:Et()}),e.strict=()=>e.clone({...e._zod.def,catchall:ir()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Af(e,n),e.merge=n=>jf(e,n),e.pick=n=>Zf(e,n),e.omit=n=>Of(e,n),e.partial=(...n)=>Mf(Wi,e,n[0]),e.required=(...n)=>Lf(Ki,e,n[0])});function S(e,t){const n={type:"object",get shape(){return Fr(this,"shape",{...e}),this.shape},...E(t)};return new sv(n)}const iv=v("ZodUnion",(e,t)=>{hg.init(e,t),ae.init(e,t),e.options=t.options});function Ue(e,t){return new iv({type:"union",options:e,...E(t)})}const av=v("ZodIntersection",(e,t)=>{fg.init(e,t),ae.init(e,t)});function cv(e,t){return new av({type:"intersection",left:e,right:t})}const uv=v("ZodRecord",(e,t)=>{mg.init(e,t),ae.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function et(e,t,n){return new uv({type:"record",keyType:e,valueType:t,...E(n)})}const ar=v("ZodEnum",(e,t)=>{gg.init(e,t),ae.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ar({...t,checks:[],...E(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ar({...t,checks:[],...E(o),entries:s})}});function lv(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ar({type:"enum",entries:n,...E(t)})}const dv=v("ZodLiteral",(e,t)=>{_g.init(e,t),ae.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function b(e,t){return new dv({type:"literal",values:Array.isArray(e)?e:[e],...E(t)})}const pv=v("ZodTransform",(e,t)=>{vg.init(e,t),ae.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=s=>{if(typeof s=="string")n.issues.push(Vt(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),n.issues.push(Vt(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function hv(e){return new pv({type:"transform",transform:e})}const Wi=v("ZodOptional",(e,t)=>{bg.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Bo(e){return new Wi({type:"optional",innerType:e})}const fv=v("ZodNullable",(e,t)=>{yg.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Jo(e){return new fv({type:"nullable",innerType:e})}const mv=v("ZodDefault",(e,t)=>{wg.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function gv(e,t){return new mv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const _v=v("ZodPrefault",(e,t)=>{kg.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType});function vv(e,t){return new _v({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Ki=v("ZodNonOptional",(e,t)=>{$g.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType});function bv(e,t){return new Ki({type:"nonoptional",innerType:e,...E(t)})}const yv=v("ZodCatch",(e,t)=>{Sg.init(e,t),ae.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wv(e,t){return new yv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const kv=v("ZodPipe",(e,t)=>{xg.init(e,t),ae.init(e,t),e.in=t.in,e.out=t.out});function Wo(e,t){return new kv({type:"pipe",in:e,out:t})}const $v=v("ZodReadonly",(e,t)=>{Rg.init(e,t),ae.init(e,t)});function Sv(e){return new $v({type:"readonly",innerType:e})}const xv=v("ZodCustom",(e,t)=>{zg.init(e,t),ae.init(e,t)});function Rv(e){const t=new Oe({check:"custom"});return t._zod.check=e,t}function zv(e,t={}){return y_(xv,e,t)}function Tv(e){const t=Rv(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(Vt(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(Vt(o))}},e(n.value,n)));return t}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class Iv extends Rf{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let o=r.shape.method.value;this._registeredMethods.add(o);let s=n;super.setNotificationHandler(r,i=>{let a=i.params;this.onEventDispatch(t,a),s.onHandler?.(a);for(let c of[...s.listeners])c(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let o=r.listeners.indexOf(n);o!==-1&&r.listeners.splice(o,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var Gi="2026-01-26",Ev="ui/notifications/tool-input-partial",Pv=Ue([b("light"),b("dark")]).describe("Color theme preference for the host environment."),Bt=Ue([b("inline"),b("fullscreen"),b("pip")]).describe("Display mode for UI presentation."),Cv=Ue([b("--color-background-primary"),b("--color-background-secondary"),b("--color-background-tertiary"),b("--color-background-inverse"),b("--color-background-ghost"),b("--color-background-info"),b("--color-background-danger"),b("--color-background-success"),b("--color-background-warning"),b("--color-background-disabled"),b("--color-text-primary"),b("--color-text-secondary"),b("--color-text-tertiary"),b("--color-text-inverse"),b("--color-text-ghost"),b("--color-text-info"),b("--color-text-danger"),b("--color-text-success"),b("--color-text-warning"),b("--color-text-disabled"),b("--color-border-primary"),b("--color-border-secondary"),b("--color-border-tertiary"),b("--color-border-inverse"),b("--color-border-ghost"),b("--color-border-info"),b("--color-border-danger"),b("--color-border-success"),b("--color-border-warning"),b("--color-border-disabled"),b("--color-ring-primary"),b("--color-ring-secondary"),b("--color-ring-inverse"),b("--color-ring-info"),b("--color-ring-danger"),b("--color-ring-success"),b("--color-ring-warning"),b("--font-sans"),b("--font-mono"),b("--font-weight-normal"),b("--font-weight-medium"),b("--font-weight-semibold"),b("--font-weight-bold"),b("--font-text-xs-size"),b("--font-text-sm-size"),b("--font-text-md-size"),b("--font-text-lg-size"),b("--font-heading-xs-size"),b("--font-heading-sm-size"),b("--font-heading-md-size"),b("--font-heading-lg-size"),b("--font-heading-xl-size"),b("--font-heading-2xl-size"),b("--font-heading-3xl-size"),b("--font-text-xs-line-height"),b("--font-text-sm-line-height"),b("--font-text-md-line-height"),b("--font-text-lg-line-height"),b("--font-heading-xs-line-height"),b("--font-heading-sm-line-height"),b("--font-heading-md-line-height"),b("--font-heading-lg-line-height"),b("--font-heading-xl-line-height"),b("--font-heading-2xl-line-height"),b("--font-heading-3xl-line-height"),b("--border-radius-xs"),b("--border-radius-sm"),b("--border-radius-md"),b("--border-radius-lg"),b("--border-radius-xl"),b("--border-radius-full"),b("--border-width-regular"),b("--shadow-hairline"),b("--shadow-sm"),b("--shadow-md"),b("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Nv=et(Cv.describe(`Style variables for theming MCP apps.
90
-
91
- Individual style keys are optional - hosts may provide any subset of these values.
92
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
93
-
94
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
95
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Ue([Y(),sr()]).describe(`Style variables for theming MCP apps.
96
-
97
- Individual style keys are optional - hosts may provide any subset of these values.
98
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
99
-
100
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
101
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
102
-
103
- Individual style keys are optional - hosts may provide any subset of these values.
104
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
105
-
106
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
107
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Zv=S({method:b("ui/open-link"),params:S({url:Y().describe("URL to open in the host's browser")})});S({isError:Xe().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();S({isError:Xe().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();S({isError:Xe().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var Ov=S({method:b("ui/notifications/sandbox-proxy-ready"),params:S({})}),Br=S({connectDomains:qe(Y()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
108
-
109
- - Maps to CSP \`connect-src\` directive
110
- - Empty or omitted → no network connections (secure default)`),resourceDomains:qe(Y()).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:qe(Y()).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:qe(Y()).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'`)")}),Jr=S({camera:S({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:S({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:S({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:S({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Av=S({method:b("ui/notifications/size-changed"),params:S({width:We().optional().describe("New width in pixels."),height:We().optional().describe("New height in pixels.")})});S({method:b("ui/notifications/tool-input"),params:S({arguments:et(Y(),Et().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});S({method:b("ui/notifications/tool-input-partial"),params:S({arguments:et(Y(),Et().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});S({method:b("ui/notifications/tool-cancelled"),params:S({reason:Y().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var jv=S({fonts:Y().optional()}),Mv=S({variables:Nv.optional().describe("CSS variables for theming the app."),css:jv.optional().describe("CSS blocks that apps can inject.")});S({method:b("ui/resource-teardown"),params:S({})});var Lv=et(Y(),Et()),Ko=S({text:S({}).optional().describe("Host supports text content blocks."),image:S({}).optional().describe("Host supports image content blocks."),audio:S({}).optional().describe("Host supports audio content blocks."),resource:S({}).optional().describe("Host supports resource content blocks."),resourceLink:S({}).optional().describe("Host supports resource link content blocks."),structuredContent:S({}).optional().describe("Host supports structured content.")}),Dv=S({method:b("ui/notifications/request-teardown"),params:S({}).optional()}),Uv=S({experimental:et(Y(),et(Y(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:S({}).optional().describe("Host supports opening external URLs."),downloadFile:S({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:S({listChanged:Xe().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:S({listChanged:Xe().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:S({}).optional().describe("Host accepts log messages."),sandbox:S({permissions:Jr.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Br.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Ko.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Ko.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:S({tools:S({}).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.")}),qv=S({experimental:et(Y(),et(Y(),Ji()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:S({listChanged:Xe().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:qe(Bt).optional().describe("Display modes the app supports.")}),Fv=S({method:b("ui/notifications/initialized"),params:S({}).optional()});S({csp:Br.optional().describe("Content Security Policy configuration for UI resources."),permissions:Jr.optional().describe("Sandbox permissions requested by the UI resource."),domain:Y().optional().describe(`Dedicated origin for view sandbox.
111
-
112
- Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
113
-
114
- **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:
115
- - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
116
- - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
117
-
118
- If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:Xe().optional().describe(`Visual boundary preference - true if view prefers a visible border.
119
-
120
- 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.
121
-
122
- - \`true\`: request visible border + background
123
- - \`false\`: request no visible border + background
124
- - omitted: host decides border`)});var Go=S({method:b("ui/request-display-mode"),params:S({mode:Bt.describe("The display mode being requested.")})});S({mode:Bt.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Hv=Ue([b("model"),b("app")]).describe("Tool visibility scope - who can access the tool.");S({resourceUri:Y().optional(),visibility:qe(Hv).optional().describe(`Who can access this tool. Default: ["model", "app"]
125
- - "model": Tool visible to and callable by the agent
126
- - "app": Tool callable by the app from this server only`),csp:ir().optional(),permissions:ir().optional()});S({mimeTypes:qe(Y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Vv=S({method:b("ui/download-file"),params:S({contents:qe(Ue([_i,vi])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Bv=S({method:b("ui/message"),params:S({role:b("user").describe('Message role, currently only "user" is supported.'),content:qe(on).describe("Message content blocks (text, image, etc.).")})});S({method:b("ui/notifications/sandbox-resource-ready"),params:S({html:Y().describe("HTML content to load into the inner iframe."),sandbox:Y().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Br.optional().describe("CSP configuration from resource metadata."),permissions:Jr.optional().describe("Sandbox permissions from resource metadata.")})});S({method:b("ui/notifications/tool-result"),params:Ft.describe("Standard MCP tool execution result.")});var Yi=S({toolInfo:S({id:Qt.optional().describe("JSON-RPC id of the tools/call request."),tool:Lr.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Pv.optional().describe("Current color theme preference."),styles:Mv.optional().describe("Style configuration for theming the app."),displayMode:Bt.optional().describe("How the UI is currently displayed."),availableDisplayModes:qe(Bt).optional().describe("Display modes the host supports."),containerDimensions:Ue([S({height:We().describe("Fixed container height in pixels.")}),S({maxHeight:Ue([We(),sr()]).optional().describe("Maximum container height in pixels.")})]).and(Ue([S({width:We().describe("Fixed container width in pixels.")}),S({maxWidth:Ue([We(),sr()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
127
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:Y().optional().describe("User's timezone in IANA format."),userAgent:Y().optional().describe("Host application identifier."),platform:Ue([b("web"),b("desktop"),b("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:S({touch:Xe().optional().describe("Whether the device supports touch input."),hover:Xe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:S({top:We().describe("Top safe area inset in pixels."),right:We().describe("Right safe area inset in pixels."),bottom:We().describe("Bottom safe area inset in pixels."),left:We().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();S({method:b("ui/notifications/host-context-changed"),params:Yi.describe("Partial context update containing only changed fields.")});var Jv=S({method:b("ui/update-model-context"),params:S({content:qe(on).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:et(Y(),Et().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Wv=S({method:b("ui/initialize"),params:S({appInfo:Un.describe("App identification (name and version)."),appCapabilities:qv.describe("Features and capabilities this app provides."),protocolVersion:Y().describe("Protocol version this app supports.")})});S({protocolVersion:Y().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Un.describe("Host application identification and version."),hostCapabilities:Uv.describe("Features and capabilities provided by the host."),hostContext:Yi.describe("Rich context about the host environment.")}).passthrough();class Kv{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let o=Yp.safeParse(r.data);o.success?(console.debug("Parsed message",o.data),this.onmessage?.(o.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",o.error.message,r):(console.error("Failed to parse message",o.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==Ev&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Gv=[Gi];class Yv extends Iv{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(t,n)=>{this._baseReplaceRequestHandler(t,(r,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${r.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(r,o)))};eventSchemas={sizechange:Av,sandboxready:Ov,initialized:Fv,requestteardown:Dv,loggingmessage:Si};constructor(t,n,r,o){super(o),this._client=t,this._hostInfo=n,this._capabilities=r,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=o?.hostContext||{},this.setRequestHandler(Wv,s=>this._oninitialize(s)),this.setRequestHandler(qn,(s,i)=>(this.onping?.(s.params,i),{})),this.replaceRequestHandler(Go,s=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler(Bv,async(n,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(n.params,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler(Zv,async(n,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(n.params,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler(Vv,async(n,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(n.params,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler(Go,async(n,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(n.params,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler(Jv,async(n,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(wi,async(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}set oncreatesamplingmessage(t){this.setRequestHandler(xi,async(n,r)=>t(n.params,r))}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler(ci,async(n,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(n.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler(li,async(n,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(n.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler(pi,async(n,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler(mi,async(n,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(t){let n=t.params.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=t.params.appCapabilities,this._appInfo=t.params.appInfo,{protocolVersion:Gv.includes(n)?n:Gi,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let n={},r=!1;for(let o of Object.keys(t)){let s=this._hostContext[o],i=t[o];Qv(s,i)||(n[o]=i,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(n))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,n){return this.request({method:"ui/resource-teardown",params:t},Lv,n)}sendResourceTeardown=this.teardownResource;callTool(t,n){return this.request({method:"tools/call",params:t},Ft,n)}listTools(t,n){return this.request({method:"tools/list",params:t},yi,n)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let n=this._client.getServerCapabilities();if(!n)throw Error("Client server capabilities not available");n.tools&&(this.oncalltool=async(r,o)=>this._client.request({method:"tools/call",params:r},Ft,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(ki,r=>this.sendToolListChanged(r.params))),n.resources&&(this.onlistresources=async(r,o)=>this._client.request({method:"resources/list",params:r},ui,{signal:o.signal}),this.onlistresourcetemplates=async(r,o)=>this._client.request({method:"resources/templates/list",params:r},di,{signal:o.signal}),this.onreadresource=async(r,o)=>this._client.request({method:"resources/read",params:r},hi,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(fi,r=>this.sendResourceListChanged(r.params))),n.prompts&&(this.onlistprompts=async(r,o)=>this._client.request({method:"prompts/list",params:r},gi,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(bi,r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}}function Qv(e,t){return JSON.stringify(e)===JSON.stringify(t)}const Qi=m.createContext(null);function Xv({extension:e,children:t}){return d.jsx(Qi.Provider,{value:e??null,children:t})}function Wr(){return m.useContext(Qi)}var Kr=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Kr||{});const eb={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function tb(e){if(typeof e=="string")return Object.values(Kr).includes(e)?e:void 0}const nb=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:eb,AgentErrorCode:Kr,toAgentErrorCode:tb},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:rb,toAgentErrorCode:ob}=nb;function Yo(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function Xi(e,t){const n=ob(e);if(!n)return null;const r=rb[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${wa}${t.provider}`)}`:`/${o}/connectors`,a=Yo(i,t.webOrigin);if(!a)return null;const c=new URL(a);return t.provider&&t.model&&c.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:c.toString()}}if(!t.agentId)return null;const s=Yo(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return s?{label:r.ctaLabel??"Open settings",href:s}:null}function ea(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const Qo=new Set(["localhost","127.0.0.1","::1","[::1]"]);function sb(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function Xo(e,t){const n=sb(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function es(e,t,n){try{const r=new URL(t),o=new URL(e,t),s=Qo.has(o.hostname)&&Qo.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&Xo(o.hostname,n)&&Xo(r.hostname,n);return o.origin!==r.origin&&(s||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const ib=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,ta=new Set(["suggest_actions"]),Pn="Thinking…";function ab(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,s=[];n===Pn&&s.push({type:"reasoning"}),r&&s.push({type:"error",text:r});let i=t;return n&&n!==Pn&&(i=t?`${t}
128
-
129
- ${n}`:n),i&&s.push({type:"text",text:i}),s.push(...o),s}const Gr=m.createContext(null);function cn(){const e=m.useContext(Gr);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function tw({messages:e,children:t}){const n=m.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:null,currentSuggestions:null}),[e]);return d.jsx(Gr.Provider,{value:n,children:t})}const na=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function ts(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(na,"").replace(/\n{3,}/g,`
130
-
131
- `).trim()}function cb(e){const t=[];for(const n of e.matchAll(na)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function ub(e,t={}){if(typeof e=="string"){const r=ts(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const s=ts(o.text);s&&n.push({type:"text",text:s})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!ta.has(o.name)&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{}})}return n}function lb(e){const t=[],n=r=>{for(const{name:o,url:s}of cb(r))t.push({id:`file-${t.length}`,name:o,url:s,isImage:ib.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const s=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${s};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function db(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:ub(e.content,t),attachments:lb(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const pb=[],hb=[];function fb(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function mb(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=Xi(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null,requestId:null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const gb=3e4,_b=3*gb,vb=15e3;function ns(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const ft=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function rs(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:s}=r;if(typeof o!="string"||typeof s!="string")continue;const i=o.trim(),a=s.trim();if(i.length===0||a.length===0)continue;const c=`${i}\0${a}`;n.has(c)||(n.add(c),t.push({title:i,message:a}))}return t.length>0?t:null}function nw({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:s,children:i,initialDraft:a}){const c=ka(),u=m.useRef(null),l=m.useRef(null),p=m.useRef(!1),h=m.useRef(o),f=m.useRef(void 0),[y,Z]=m.useState(void 0),x=m.useRef(!1),j=m.useRef(null);h.current=o;const{data:z,isLoading:w}=$a(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),$=z?.messages??pb,A=z?.interactions??hb,{data:M}=Sa(e,{enabled:!!e}),W=!!(M?.showToolCalls??M?.settings?.showToolCalls),[$e,Be]=m.useState([]),[we,Pe]=m.useState(!1),[ze,O]=m.useState([]);m.useEffect(()=>{y&&O([])},[y]);const[L,F]=m.useState(null),X=m.useRef(!1);X.current=we;const G=m.useMemo(()=>$.map(H=>db(H,{showToolCalls:W})).filter(H=>H!==null),[$,W]),Le=m.useRef(!1);m.useEffect(()=>{if(Le.current||w||X.current)return;Le.current=!0;const H=mb(A,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});Be(H?[...G,H]:G),F(fb(A))},[e,w,G,A,t]);const Ce=m.useCallback(()=>{c.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),c.invalidateQueries({queryKey:["agent-threads",t,e]})},[c,t,e,n]),Je=m.useCallback(async()=>{if(u.current)return u.current;if(l.current)return l.current;if(!e)throw new Error("No agent selected");const H=(async()=>{const D=await Qn(`${Bn}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n,...f.current?{executionTarget:f.current}:{}}),timeoutMs:2e4});if(!D.ok)throw await to(D);const _e=await D.json(),ke=xa(),ve={sessionId:_e.agentId,sseUrl:es(_e.sseUrl,Bn,ke),messagesUrl:es(_e.messagesUrl,Bn,ke),executionTarget:_e.executionTarget};return f.current=_e.executionTarget,Z(_e.executionTarget),u.current=ve,ve})();l.current=H;try{return await H}catch(D){throw u.current=null,D}finally{l.current=null}},[e,t,n]),Ge=m.useCallback(async(H,D,_e)=>{const ke=new AbortController;j.current=ke;const ve=k=>{Be(P=>P.map(N=>N.id===_e?{...N,parts:k}:N))};let Te;try{Te=await Je()}catch(k){ve([{type:"text",text:`Error: ${k instanceof Error?k.message:"Could not start a session."}`}]);return}let be=await no(Te.sseUrl,{throwOnFailure:!0});const nt=[];let bt=null;const Ot=()=>{const k=bt;bt=null,k?.()},yt=k=>{nt.push(k),Ot()};let wt=!1,At=null;const dn=new Promise(k=>{At=k});let dt=0,kt=Date.now();const pt=k=>{kt=Date.now();const P=Number(k.lastEventId);Number.isFinite(P)&&P>dt&&(dt=P)},pn=["output","status","complete","closed","agent-error","question","suggestion","link-button","tool-approval","tool_use"],jt=k=>{k.addEventListener("open",()=>{wt=!0,At?.()}),k.addEventListener("connected",N=>{pt(N),wt||(wt=!0,At?.())}),k.addEventListener("ping",pt);const P=N=>ce=>{pt(ce);const De=ce;typeof De.data=="string"&&yt({kind:N,payload:ns(De)})};for(const N of pn)k.addEventListener(N,P(N));k.addEventListener("error",N=>{const ce=N;if(typeof ce.data=="string"&&ce.data){pt(N),yt({kind:"error",payload:ns(ce)});return}k.readyState===EventSource.CLOSED&&yt({kind:"error",payload:{error:"Connection closed"}})})};jt(be);const hn=async()=>{be.close();let k=Te.sseUrl;if(dt){const P=new URL(Te.sseUrl,window.location.origin);P.searchParams.set("since",String(dt)),k=P.toString()}be=await no(k,{throwOnFailure:!1}),jt(be),kt=Date.now()};await Promise.race([dn,new Promise(k=>setTimeout(k,1500))]);const fn=()=>{be.close(),Ot()};ke.signal.addEventListener("abort",fn,{once:!0});try{const k=h.current?.trim(),P=!!k&&!x.current;P&&(x.current=!0);let N;if(D.length>0){const C=new FormData;C.set("content",H),P&&k&&C.set("ephemeralContext",k);for(const K of D)C.append("files",K,K.name);N={method:"POST",credentials:"include",body:C,timeoutMs:12e4}}else{const C={content:H};P&&k&&(C.ephemeralContext=k),N={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(C),timeoutMs:2e4}}const ce=await Qn(Te.messagesUrl,N);if(!ce.ok)throw u.current=null,await to(ce);let De="",me=Pn,eo=null;const $t=[],rt=()=>ab({textOut:De,statusLine:me,errorText:eo,toolCalls:$t});for(ve(rt());!ke.signal.aborted;){if(nt.length===0){let K;const Ie=await Promise.race([new Promise(Vn=>{bt=()=>Vn(!0)}),new Promise(Vn=>{K=setTimeout(()=>Vn(!1),vb)})]);K&&clearTimeout(K),!Ie&&Date.now()-kt>=_b&&(await hn(),Ce());continue}const C=nt.shift();if(C){if(C.kind==="output")me=null,De+=String(C.payload.content??"");else if(C.kind==="status")me=Pn;else if(C.kind==="complete"){me=null;const K=C.payload.finalText;typeof K=="string"&&K.length>0&&(De=K);const Ie=C.payload.suggestions;Ie!==void 0&&F(Array.isArray(Ie)?rs(Ie):null),Ce(),ve(rt());return}else if(C.kind==="closed"){u.current=null;const K=C.payload.reason;me=`Session ended${K?`: ${K}`:""}.`,Ce(),ve(rt());return}else if(C.kind==="error"||C.kind==="agent-error"){me=null,eo=typeof C.payload.error=="string"&&C.payload.error?C.payload.error:"Agent reported an error.";const K=C.payload.errorContext&&typeof C.payload.errorContext=="object"?C.payload.errorContext:void 0,Ie=Xi(C.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof K?.provider=="string"?K.provider:void 0,model:typeof K?.model=="string"?K.model:void 0});Ie&&$t.push({type:"tool-call",toolCallId:ft("l"),toolName:"link-button",args:{label:Ie.label,url:Ie.href}}),Ce(),ve(rt());return}else if(C.kind==="question")$t.push({type:"tool-call",toolCallId:ft("q"),toolName:"question",args:{question:C.payload.question??"",options:C.payload.options??[]}});else if(C.kind==="tool_use"){if(me=null,ta.has(C.payload.name??"")){ve(rt());continue}const K=C.payload.result_summary,Ie=ea(K);if(!W&&!Ie){ve(rt());continue}$t.push({type:"tool-call",toolCallId:C.payload.toolCallId??ft("t"),toolName:W?C.payload.name??"tool":"subscription-candidate",args:W?C.payload.input??{}:null,result:K,isError:C.payload.isError})}else if(C.kind==="suggestion"){const K=C.payload.prompts;K!==void 0&&(F(Array.isArray(K)?rs(K):null),ve(rt()))}else if(C.kind==="link-button")$t.push({type:"tool-call",toolCallId:ft("l"),toolName:"link-button",args:{label:C.payload.label??"Open link",url:C.payload.url??""}});else if(C.kind==="tool-approval"){const K=Te.messagesUrl.replace(/\/agents\/[^/]+\/messages$/,"/agents/approve"),Ie=C.payload.runId;$t.push({type:"tool-call",toolCallId:C.payload.requestId??(Ie!=null?`run-${Ie}`:ft("a")),toolName:"tool-approval",args:{requestId:C.payload.requestId??null,tool:C.payload.toolName??"a tool",args:C.payload.args??null,durationOptions:C.payload.durationOptions??["1h","24h","always"],approveUrl:K,orgSlug:t??null,runId:Ie??null,action:C.payload.action??null,proposal:C.payload.proposal??null,current:C.payload.current??null,fields:C.payload.fields??null,attribution:C.payload.attribution??null,resourceKind:C.payload.resourceKind??null}})}ve(rt())}}}catch(k){ve([{type:"text",text:`Error: ${k instanceof Error?k.message:"Send failed."}`}])}finally{ke.signal.removeEventListener("abort",fn),be.close()}},[e,Je,Ce,W,t]),ut=m.useCallback(H=>{const D=H.trim(),_e=ze.map(be=>be.file);if(!D&&_e.length===0||X.current||!e)return;p.current||(p.current=!0,s?.(D||_e[0]?.name||""));const ke={id:ft("u"),role:"user",parts:D?[{type:"text",text:D}]:[],attachments:ze.map(be=>({id:be.id,name:be.name,isImage:be.isImage,imageDataUrl:be.isImage?URL.createObjectURL(be.file):void 0})),createdAt:Date.now()},ve=ft("asst"),Te={id:ve,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};Be(be=>[...be,ke,Te]),O([]),Pe(!0),X.current=!0,Ge(D,_e,ve).finally(()=>{Pe(!1),X.current=!1,j.current=null})},[e,s,ze,Ge]),Ae=m.useCallback(()=>{j.current?.abort()},[]),tt=m.useCallback(H=>{const D=Array.from(H);O(_e=>[..._e,...D.map(ke=>({id:crypto.randomUUID(),name:ke.name,file:ke,isImage:ke.type.startsWith("image/")}))])},[]),fe=m.useCallback(H=>{O(D=>D.filter(_e=>_e.id!==H))},[]),lt=m.useRef(!1);m.useEffect(()=>{if(lt.current)return;const H=ec(n);H&&(lt.current=!0,f.current=H.executionTarget,Z(H.executionTarget),ut(H.text))},[n,ut]),m.useEffect(()=>{w||G.length===0||Je().catch(()=>{})},[Je,G.length,w]);const ln=m.useMemo(()=>({messages:$e,running:we,append:ut,cancel:Ae,pendingAttachments:ze,addAttachments:tt,removeAttachment:fe,initialDraft:a,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:L,executionTarget:y}),[$e,we,ut,Ae,ze,tt,fe,a,e,n,t,L,y]);return r&&w?d.jsx(Ga,{}):d.jsx(Gr.Provider,{value:ln,children:i})}const os="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function bb({refItem:e}){const t=rc[e.kind]??Ra;return oc(e.path)?d.jsxs("span",{className:os,children:[d.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):d.jsxs(ls,{to:e.path,className:he(os,"hover:bg-accent/80"),children:[d.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Yr=({text:e,renderText:t})=>tc(e)?d.jsx(d.Fragment,{children:nc(e).map((n,r)=>n.type==="ref"?d.jsx(bb,{refItem:n.ref},`r${r}`):d.jsx("span",{children:t(n.text)},`t${r}`))}):d.jsx(d.Fragment,{children:t(e)}),yb=({label:e="Thinking"})=>d.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),ra=m.createContext(null),oa=()=>{const e=m.useContext(ra);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},sa=m.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...s})=>{const[i,a]=za({prop:t,defaultProp:n,onChange:r}),c=m.useMemo(()=>({isOpen:i,setIsOpen:a}),[i,a]);return d.jsx(ra.Provider,{value:c,children:d.jsx("div",{className:he("not-prose max-w-prose space-y-4",e),...s,children:o})})}),ia=m.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=oa();return d.jsx(ds,{onOpenChange:o,open:r,children:d.jsxs(Ta,{className:he("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[d.jsx(Ia,{className:"size-4"}),d.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),d.jsx(Ea,{className:he("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),aa=m.memo(({className:e,icon:t=Ca,label:n,description:r,status:o="complete",children:s,...i})=>{const a={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return d.jsxs("div",{className:he("flex gap-2 text-sm",a[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[d.jsxs("div",{className:"relative mt-0.5",children:[d.jsx(t,{className:"size-4"}),d.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),d.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[d.jsx("div",{children:n}),r&&d.jsx("div",{className:"text-muted-foreground text-xs",children:r}),s]})]})}),ca=m.memo(({className:e,children:t,...n})=>{const{isOpen:r}=oa();return d.jsx(ds,{open:r,children:d.jsx(Pa,{className:he("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});sa.displayName="ChainOfThought";ia.displayName="ChainOfThoughtHeader";aa.displayName="ChainOfThoughtStep";ca.displayName="ChainOfThoughtContent";function wb(e){const t=e.current?.loser??{};return{duplicates:Array.isArray(e.current?.duplicates)?e.current.duplicates:[t],winner:e.current?.winner??{}}}function ua(e,t){if(e.length===0)return"No deterministic identity match details are available for these records.";if(e.length===1&&t===2){const[n]=e;return`Both records have the same ${String(n?.kind??"identity")}: ${String(n?.identifier??"")}.`}return`Recorded match evidence:
132
- ${e.map(n=>`• ${String(n.kind??"Identity")}: ${String(n.identifier??"")}`).join(`
133
- `)}`}function Cn(e,t,n){const r=String(t.id??e.toLowerCase());let o;const s=[],i=new Set;typeof t.href=="string"&&(n.add(t.href),o={id:`entity-${r}`,label:"Open record",variant:"ghost",icon:"external",terminal:!1,tool:"open_review_link",args:{url:t.href}});const a=new Set;for(const c of Array.isArray(t.identities)?t.identities:[]){const u=String(c.connection_name??c.source_connector??"Unknown source");a.add(`${u} · ${String(c.namespace??"identity")}: ${String(c.identifier??"")}`),!(typeof c.connection_href!="string"||i.has(c.connection_href))&&(i.add(c.connection_href),n.add(c.connection_href),s.push({id:`connection-${String(c.id??c.connection_href)}`,label:`Open source: ${u}`,variant:"ghost",icon:"external",terminal:!1,tool:"open_review_link",args:{url:c.connection_href}}))}return{type:"entity",id:r,label:e,name:String(t.name??`Entity ${r}`),details:[...a],recordLink:o,sourceLinks:s}}function Qr(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}function ss(e){return`${String(e.kind??"Identity")}: ${String(e.identifier??"")}`}function is(e){if(!Array.isArray(e))return null;const t=Qr(e);return t.length===e.length&&t.every(n=>typeof n.kind=="string"&&n.kind.trim().length>0&&typeof n.identifier=="string"&&n.identifier.trim().length>0)?t:null}function kb(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=is(t.dropped),r=is(t.gained);if(!n||!r)return null;const o=[];for(const s of n)o.push(`− No longer proven — ${ss(s)}`);for(const s of r)o.push(`+ Newly proven — ${ss(s)}`);return{weakened:n.length>0,block:{type:"text",label:n.length>0?"What changed since you reviewed this":r.length>0?"What the re-check newly found":"What changed since you reviewed this",value:o.length>0?o.join(`
134
- `):"The recorded match evidence did not change."}}}function $b(e){const{duplicates:t,winner:n}=wb(e),r=Qr(e.proposal?.evidence),o=new Set,s=typeof e.status=="string"?e.status:"pending",i=s==="pending",a=s==="rejected"?"Kept separate":s==="failed"?"Failed":"Approved",c=typeof e.reason=="string"?e.reason:typeof e.proposal?.reason=="string"?e.proposal.reason:null,u=[{type:"text",label:"Why Lobu thinks they match",value:ua(r,t.length+1)}];c&&u.push({type:"text",label:"Why this needs review",value:c,muted:!0});const l=kb(e.proposal?.evidence_change);l&&u.push(l.block),u.push(...t.map(h=>Cn("Duplicate",h,o)),Cn("Canonical",n,o),{type:"text",value:i?`If approved, ${t.length===1?"the":"each"} duplicate's relationships and aliases will move to the canonical record.`:typeof e.reviewedByName=="string"?`${a} by ${e.reviewedByName}.`:`${a}.`,muted:!0});const p=i?[{id:"approve",label:l?"Approve again to apply":"Approve merge",variant:"primary",icon:"check",...l?.weakened?{confirm:!0,confirmPrompt:"The evidence for this merge no longer holds. Merge these records anyway?"}:{},tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Merge approved and is being applied."},{id:"reject",label:"Keep separate",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Keep these entities separate?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"The entities were kept separate."}]:[];return{view:{title:`Merge ${t.length} duplicate ${t.length===1?"record":"records"}${i?"":` · ${a}`}`,icon:"entity",impact:i?{level:"high",reason:"This combines duplicate records into the selected winner."}:{level:"normal"},tone:i||s==="failed"?"warning":"default",blocks:u,actions:p},reviewUrls:o}}function rw(e){const t=e.loser&&typeof e.loser=="object"&&!Array.isArray(e.loser)?{...e.loser}:{},n=e.winner&&typeof e.winner=="object"&&!Array.isArray(e.winner)?{...e.winner}:{};typeof e.loserHref=="string"&&(t.href=e.loserHref),typeof e.winnerHref=="string"&&(n.href=e.winnerHref);const r=Qr(e.evidence),o=new Set,s=e.status==="active",a=s&&e.canUndo===!0?[{id:"undo",label:"Undo merge",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Undo this automatic merge?",tool:"manage_entity",args:{action:"unmerge"},resolvedLabel:"Merge undone."}]:[];return{view:{title:s?"Merged automatically":"Automatic merge undone",icon:"entity",impact:{level:"normal"},tone:s?"default":"warning",blocks:[{type:"text",label:"Why Lobu merged them",value:ua(r,2)},Cn("Duplicate",t,o),Cn("Canonical",n,o),{type:"text",value:s?"The entity type's deterministic identity rule applied this merge without human review.":"This automatic merge was undone.",muted:!0}],actions:a},reviewUrls:o}}function Sb({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let s=cr(xb(r,o),t);if(!n)return m.createElement(e,s);if(typeof n=="function")return n(s,r);if(!m.isValidElement(n))return null;let i=n.props,a={...cr(s,i),ref:un(s.ref,i.ref)};return m.cloneElement(n,a)}function cr(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let s=r[o];if(s===void 0)continue;let i=t[o];o==="className"?t[o]=[i,s].filter(Boolean).join(" "):o==="style"?t[o]={...i,...s}:o==="ref"?t[o]=un(i,s):zb(o)&&typeof i=="function"&&typeof s=="function"?t[o]=Rb(s,i):t[o]=s}}return t}function xb(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],s=t?.[r]?.(o);if(s){Object.assign(n,s);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function Rb(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function zb(e){return/^on[A-Z]/.test(e)}function un(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var Tb=8,Ib=64,Eb=0,Nn=.5,Pb=180,Cb=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),la={start:!1,end:!1},Nb=[],Zn={currentAnchorId:null,visibleMessageIds:Nb};function Zb({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return la;let o=Xr({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function Ob({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:s}){if(!e||!o)return Zn;let i=o.getBoundingClientRect(),a=i.top+t+n,c=typeof IntersectionObserver>"u",u=[],l=null;for(let p of Jt(e,r)){let h=p.dataset.messageId;if(!h)continue;let f=p.dataset.scrollAnchor==="true",y=f||c?p.getBoundingClientRect():null;(c&&y?y.bottom>a&&y.top<i.bottom:s.has(h))&&u.push(h),f&&y&&y.top<=a+Nn&&(l=h)}return u.length===0&&l===null?Zn:{currentAnchorId:l,visibleMessageIds:u}}function Jt(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function Ab(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function jb(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Mb(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Lb(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Db({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of Jt(e,t)){if(!o.dataset.messageId)continue;let s=o.getBoundingClientRect();if(s.bottom>r.top&&s.top<r.bottom)return o}return null}function Ub({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let s=da(t,o),i=t.getBoundingClientRect().height,a=Hb(r);if(e==="center"){let c=Math.max(0,o.clientHeight-a.start-a.end);return s-a.start-(c-i)/2-n}if(e==="end")return s-o.clientHeight+i+a.end+n;if(e==="nearest"){let c=s+i,u=o.scrollTop+a.start,l=o.scrollTop+o.clientHeight-a.end;return s>=u&&c<=l?o.scrollTop:s<u?s-a.start-n:c-o.clientHeight+a.end+n}return s-a.start-n}function da(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function $n(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function qb({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Xr({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Xr({content:e,spacer:t,viewport:n}){let r=Jt(e,t),o=pa(e),s=n.getBoundingClientRect(),i=n.scrollTop,a=o.start+o.end;for(let c of r){let u=c.getBoundingClientRect();a=Math.max(a,u.bottom-s.top+i+o.end)}return a}function Fb(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function pa(e){let t=window.getComputedStyle(e);return{end:ur(t.paddingBlockEnd||t.paddingBottom),start:ur(t.paddingBlockStart||t.paddingTop)}}function Hb(e){let t=e?.parentElement;return t?pa(t):{end:0,start:0}}function Vb(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return ur(n)}function ur(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Bb({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:i,autoscrollingTimeoutRef:a,contentRef:c,defaultScrollPositionAppliedRef:u,itemCountRef:l,messageElementsRef:p,modeRef:h,pendingScrollToMessageRef:f,prependRestoreRef:y,scrollMarginRef:Z,scrollPreviousItemPeekRef:x,spacerGapRef:j,spacerHeightRef:z,spacerRef:w,viewportRef:$}=e,A=m.useCallback(O=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null),i.current!==O&&(i.current=O,t()),O&&(a.current=window.setTimeout(()=>{a.current=null,i.current=!1,t()},Pb))},[t]),M=m.useCallback(O=>{let L=w.current;if(!L)return;let F=Math.max(0,Math.ceil(O));z.current!==F&&(z.current=F,L.hidden=F===0,L.style.height=`${F}px`,L.style.marginTop=F>0?`${-j.current}px`:"")},[]),W=m.useCallback((O,{behavior:L="auto",autoscrolling:F=!1}={})=>{let X=$.current;if(!X)return;let G=Math.max(0,O);if(Math.abs(X.scrollTop-G)<=Nn){X.scrollTop=G,t();return}F&&A(!0),X.scrollTo({top:G,behavior:L}),n()},[t,n,A]),$e=m.useCallback(({behavior:O="auto"}={})=>$.current?(M(0),o.current=null,h.current="free-scrolling",W(0,{behavior:O}),r(),!0):!1,[r,W,M]),Be=m.useCallback(({behavior:O="auto"}={})=>{let L=$.current;return L?(M(0),o.current=null,h.current=s.current?"following-bottom":"free-scrolling",W(Fb(L),{autoscrolling:!0,behavior:O}),r(),!0):!1},[r,W,M]),we=m.useCallback((O,{align:L="start",behavior:F="auto",scrollMargin:X=Z.current}={},{keepPreviousPeek:G=!1}={})=>{let Le=c.current,Ce=$.current;if(!Le||!Ce||!Le.contains(O))return!1;let Je=Ub({align:L,element:O,scrollMargin:G?X+x.current:X,spacer:w.current,viewport:Ce}),Ge=qb({content:Le,scrollTop:Je,spacer:w.current,viewport:Ce});return M(Ge),y.current={element:O,viewportTop:$n(O,Ce)},h.current=G?"anchored-to-message":"settling-jump",o.current=G?O:null,W(Je,{behavior:F}),r(),!0},[r,W,M]),Pe=m.useCallback(()=>{let O=o.current;return!O||!O.isConnected||h.current!=="anchored-to-message"?!1:we(O,{align:"start"},{keepPreviousPeek:!0})},[we]),ze=m.useCallback((O,L)=>{let F=p.current.get(O);return F?(u.current=!0,we(F,L)?(f.current=null,!0):(f.current={messageId:O,options:L},!0)):l.current===0?(f.current={messageId:O,options:L},u.current=!0,!0):!1},[we]);return{flushPendingScrollToMessage:m.useCallback(()=>{let O=f.current;if(!O)return!1;let L=p.current.get(O.messageId);return!L||!we(L,O.options)?!1:(f.current=null,u.current=!0,!0)},[we]),reanchorToAnchoredMessage:Pe,scrollToElement:we,scrollToEnd:Be,scrollToMessage:ze,scrollToStart:$e}}function ha(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(s=>s()))},subscribe:(o,s,i)=>{let a=r.size===0;return r.add(o),a&&s?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function Jb(e,t){return ha(e,t)}function Wb(){return ha(Zn,Gb)}function Kb(e,t){return e.start===t.start&&e.end===t.end}function Gb(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Yb({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=m.useRef(e),s=m.useRef(!1),i=m.useRef(null),a=m.useRef(!1),c=m.useRef(t),u=m.useRef(0),l=m.useRef(null),p=m.useRef(0),h=m.useRef(e?"following-bottom":"free-scrolling"),f=m.useRef(new Map),y=m.useRef(null),Z=m.useRef(null),x=m.useRef(null),j=m.useRef(r),z=m.useRef(!0),w=m.useRef(null),$=m.useRef(n),A=m.useRef(null),M=m.useRef(0),W=m.useRef(0),$e=m.useRef(null),Be=m.useRef(null),we=m.useRef(null),Pe=m.useRef(null),ze=m.useRef(null),O=m.useRef(null),L=m.useRef(null),F=m.useRef(null),X=m.useRef(new Set),G=m.useRef(new WeakSet);return we.current===null&&(we.current=Jb(la,Kb)),F.current===null&&(F.current=Wb()),o.current=e,c.current=t,$.current=n,j.current=r,{autoScrollRef:o,autoscrollingRef:s,autoscrollingTimeoutRef:Pe,streamingTurnRef:x,contentRef:i,defaultScrollPositionAppliedRef:a,firstItemRef:l,itemCountRef:u,lastScrollTopRef:p,messageElementsRef:f,modeRef:h,pendingScrollFrameRef:A,pendingScrollToMessageRef:y,prependRestoreRef:Z,preserveScrollOnPrependRef:z,rootRef:w,scrollEdgeThresholdRef:c,scrollMarginRef:$,scrollPreviousItemPeekRef:j,spacerGapRef:M,spacerHeightRef:W,spacerRef:$e,stateFrameRef:Be,stateStore:we.current,viewportRef:ze,visibilityFrameRef:O,visibilityObserverRef:L,visibilityStore:F.current,visibleMessageIdsRef:X,handledScrollAnchorsRef:G}}function as(e,t){return m.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Qb({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=Tb,scrollPreviousItemPeek:r=Ib,scrollMargin:o=Eb}){let s=Yb({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:c,autoscrollingTimeoutRef:u,contentRef:l,defaultScrollPositionAppliedRef:p,firstItemRef:h,itemCountRef:f,lastScrollTopRef:y,messageElementsRef:Z,modeRef:x,pendingScrollFrameRef:j,pendingScrollToMessageRef:z,prependRestoreRef:w,preserveScrollOnPrependRef:$,rootRef:A,scrollEdgeThresholdRef:M,scrollMarginRef:W,scrollPreviousItemPeekRef:$e,spacerGapRef:Be,spacerHeightRef:we,spacerRef:Pe,stateFrameRef:ze,stateStore:O,viewportRef:L,visibilityFrameRef:F,visibilityObserverRef:X,visibilityStore:G,visibleMessageIdsRef:Le,handledScrollAnchorsRef:Ce}=s,Je=m.useRef(t);Je.current!==t&&(Je.current=t,p.current=!1);let Ge=m.useCallback(k=>{let P=A.current,N=L.current,ce=[k.start&&"start",k.end&&"end"].filter(Boolean).join(" "),De=c.current;for(let me of[P,N])me&&(ce?me.setAttribute("data-scrollable",ce):me.removeAttribute("data-scrollable"),me.toggleAttribute("data-autoscrolling",De))},[]),ut=m.useCallback(k=>{let P=L.current?.scrollTop??0,N=P<y.current-Nn;y.current=P,a.current&&!k.end&&x.current!=="settling-jump"&&x.current!=="anchored-to-message"?x.current="following-bottom":x.current==="following-bottom"&&k.end&&N&&!c.current&&(x.current="free-scrolling")},[]),Ae=m.useCallback(()=>{let k=Zb({content:l.current,scrollEdgeThreshold:M.current,spacer:Pe.current,viewport:L.current});ut(k);let P=x.current==="following-bottom"?{...k,end:!1}:k;Ge(P),O.setSnapshot(P)},[ut,O,Ge]),tt=m.useCallback(()=>{ze.current===null&&(ze.current=window.requestAnimationFrame(()=>{ze.current=null,Ae()}))},[Ae]),fe=m.useCallback(()=>{G.hasListeners()&&F.current===null&&(F.current=window.requestAnimationFrame(()=>{F.current=null,G.hasListeners()&&G.setSnapshot(Ob({content:l.current,scrollMargin:W.current,scrollPreviousItemPeek:$e.current,spacer:Pe.current,viewport:L.current,visibleMessageIds:Le.current}))}))},[G]),{flushPendingScrollToMessage:lt,reanchorToAnchoredMessage:ln,scrollToElement:H,scrollToEnd:D,scrollToMessage:_e,scrollToStart:ke}=Bb({refs:s,commitScrollState:Ae,scheduleStateCommit:tt,scheduleVisibilitySync:fe}),ve=m.useCallback(()=>{let k=w.current,P=L.current;if(!k||!P||!k.element.isConnected)return!1;let N=$n(k.element,P)-k.viewportTop;return Math.abs(N)<=Nn?!1:(P.scrollTop+=N,k.viewportTop=$n(k.element,P),tt(),fe(),!0)},[tt,fe]),Te=m.useCallback(()=>{let k=l.current,P=L.current;if(!k||!P){w.current=null;return}let N=Db({content:k,spacer:Pe.current,viewport:P});w.current=N?{element:N,viewportTop:$n(N,P)}:null},[]),be=m.useCallback(()=>{j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null,lt()&&Te()}))},[Te,lt]),nt=m.useCallback(()=>{if(!t||p.current||f.current===0)return!1;let k=!1;if(t==="last-anchor"){let P=l.current,N=L.current,ce=P&&N?Lb(Jt(P,Pe.current)):null;if(!P||!N||!ce)k=D({behavior:"auto"});else{let De=da(ce,N);k=Xr({content:P,spacer:Pe.current,viewport:N})-De<=N.clientHeight?D({behavior:"auto"}):H(ce,{align:"start"},{keepPreviousPeek:!0})}}else k=t==="end"?D({behavior:"auto"}):ke({behavior:"auto"});return k?(p.current=!0,!0):!1},[t,H,D,ke]),bt=m.useCallback(()=>{let k=l.current;if(!k)return;let P=Jt(k,Pe.current),N=f.current,ce=h.current;f.current=P.length,h.current=P[0]??null,(()=>{if(lt())return;if(N===0){if(nt()||P.length>0&&a.current&&D({behavior:"auto"}))return;Ae(),fe();return}let De=ce?P.indexOf(ce):-1;if($.current&&De>0){ve();return}if(P.length>N){let me=Ab(P,N);if(me){if(a.current&&x.current==="following-bottom"&&Mb(P,N)){D({behavior:"auto"});return}H(me,{align:"start"},{keepPreviousPeek:!0}),Ce.current.add(me);return}}if(P.length===N){let me=jb(P,Ce.current);if(me){H(me,{align:"start"},{keepPreviousPeek:!0}),Ce.current.add(me);return}}x.current==="following-bottom"&&a.current?D({behavior:"auto"}):(Ae(),fe())})(),Te()},[nt,Te,Ae,lt,ve,fe,H,D]),Ot=m.useCallback(()=>{if(x.current==="following-bottom"&&a.current){D({behavior:"auto"});return}let k=we.current;if(ln()){a.current&&k>0&&we.current===0&&D({behavior:"auto"});return}tt(),fe()},[ln,tt,fe,D]),yt=m.useCallback(()=>{let k=L.current;if(!(!k||!G.hasListeners())){if(typeof IntersectionObserver>"u"){fe();return}X.current||(X.current=new IntersectionObserver(P=>{for(let N of P){let ce=N.target.dataset.messageId;ce&&(N.isIntersecting?Le.current.add(ce):Le.current.delete(ce))}fe()},{root:k,rootMargin:`${-(W.current+$e.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),Z.current.forEach(P=>{X.current?.observe(P)}),fe()}},[fe,G]),wt=m.useCallback(()=>{F.current!==null&&(window.cancelAnimationFrame(F.current),F.current=null),X.current?.disconnect(),X.current=null,Le.current.clear(),G.setSnapshot(Zn)},[G]),At=m.useCallback((k,P,N)=>{if(P){Z.current.set(k,P),X.current?.observe(P),fe(),z.current?.messageId===k&&be();return}N&&Z.current.get(k)===N&&(Z.current.delete(k),Le.current.delete(k),X.current?.unobserve(N),fe())},[be,fe]),dn=m.useCallback(()=>{(x.current==="following-bottom"||x.current==="anchored-to-message"||x.current==="settling-jump")&&(i.current=null,x.current="free-scrolling")},[]),dt=m.useCallback(()=>Ge(O.getSnapshot()),[O,Ge]),kt=as(A,dt),pt=as(L,dt),pn=m.useCallback(k=>{l.current=k},[]),jt=m.useCallback(k=>{Pe.current=k,Be.current=Vb(k?.parentElement??null)},[]),hn=m.useCallback(()=>{Ae(),fe(),Te()},[Te,Ae,fe]),fn=m.useMemo(()=>({handleContentChange:bt,handleResize:Ot,observeVisibility:yt,preserveScrollOnPrependRef:$,scrollToEnd:D,scrollToMessage:_e,scrollToStart:ke,setContentElement:pn,setRootElement:kt,setSpacerElement:jt,setViewportElement:pt,stateStore:O,syncAfterScroll:hn,unobserveVisibility:wt,userScrollIntent:dn,viewportRef:L,visibilityStore:G}),[bt,Ot,yt,D,_e,ke,pn,kt,jt,pt,O,hn,wt,dn,G]);return m.useLayoutEffect(()=>{nt()},[nt]),m.useEffect(()=>()=>{ze.current!==null&&(window.cancelAnimationFrame(ze.current),ze.current=null),F.current!==null&&(window.cancelAnimationFrame(F.current),F.current=null),u.current!==null&&(window.clearTimeout(u.current),u.current=null),j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),X.current?.disconnect(),X.current=null},[]),m.useLayoutEffect(()=>{if(e&&x.current==="following-bottom"&&f.current>0){D({behavior:"auto"});return}Ae()},[e,Ae,D]),{context:fn,registerMessage:At}}function Xb(e){let t=m.useRef(e);return t.current=e,t}var fa=m.createContext(null),ma=m.createContext(null);function Nt(){let e=m.useContext(fa);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function ey(){let e=m.useContext(ma);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function ga(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=Nt();return m.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function _a(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=Nt(),r=m.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return m.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function ty({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s}){let{context:i,registerMessage:a}=Qb({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:s});return d.jsx(fa.Provider,{value:i,children:d.jsx(ma.Provider,{value:a,children:t})})}function ny({children:e,...t}){let{setRootElement:n}=Nt();return d.jsx("div",{ref:n,...t,children:e})}function ry({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:s,preserveScrollOnPrepend:i=!0,ref:a,role:c,tabIndex:u,...l}){let{handleResize:p,preserveScrollOnPrependRef:h,setViewportElement:f,syncAfterScroll:y,userScrollIntent:Z,viewportRef:x}=Nt();h.current=i;let j=m.useCallback(M=>{f(M),un(a)?.(M)},[a,f]);function z(M){y(),r?.(M)}function w(M){Z(),s?.(M)}function $(M){Z(),o?.(M)}function A(M){Cb.has(M.key)&&Z(),n?.(M)}return m.useEffect(()=>{let M=x.current;if(!M||typeof ResizeObserver>"u")return;let W=0,$e=new ResizeObserver(()=>{window.cancelAnimationFrame(W),W=window.requestAnimationFrame(p)});return $e.observe(M),()=>{window.cancelAnimationFrame(W),$e.disconnect()}},[p,x]),d.jsx("div",{ref:j,role:c??"region","aria-label":e??"Messages",tabIndex:u??0,onKeyDown:A,onScroll:z,onTouchMove:$,onWheel:w,...l,children:t})}function oy({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...s}){let{handleContentChange:i,handleResize:a,setContentElement:c,setSpacerElement:u}=Nt(),l=m.useRef(null),p=m.useCallback(h=>{l.current=h,c(h),un(n)?.(h)},[n,c]);return m.useLayoutEffect(()=>{let h=l.current;if(!h||(i(),typeof MutationObserver>"u"))return;let f=new MutationObserver(()=>{i()});return f.observe(h,{childList:!0}),()=>f.disconnect()},[i]),m.useEffect(()=>{let h=l.current;if(!h||typeof ResizeObserver>"u")return;let f=0,y=new ResizeObserver(()=>{window.cancelAnimationFrame(f),f=window.requestAnimationFrame(a)});return y.observe(h),()=>{window.cancelAnimationFrame(f),y.disconnect()}},[a]),d.jsxs("div",{ref:p,role:r??"log","aria-relevant":e??"additions",...s,children:[t,d.jsx("div",{ref:u,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function sy({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=ey(),s=m.useRef(null),i=m.useCallback(a=>{let c=s.current;s.current=a,e&&o(e,a,c),un(t)?.(a)},[e,t,o]);return d.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function iy({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:s,type:i="button",...a}){let{scrollToEnd:c,scrollToStart:u,stateStore:l}=Nt(),p=Xb(r),h=m.useCallback(x=>l.subscribe(x),[l]),f=m.useCallback(()=>{let x=l.getSnapshot();return n==="start"?x.start:x.end},[n,l]),y=m.useSyncExternalStore(h,f,f),Z=m.useCallback(x=>{y&&(p.current?.(x),x.defaultPrevented||(x.currentTarget.blur(),n==="start"?u({behavior:e}):c({behavior:e})))},[e,n,y,p,c,u]);return Sb({defaultTagName:"button",props:cr({type:i,inert:!y,tabIndex:y?s:-1,children:t??d.jsxs("span",{children:["Scroll to ",n]}),onClick:Z},a),render:o,state:{active:y,direction:n},stateAttributesMapping:{active:x=>({"data-active":x?"true":"false"})}})}var Zt={Provider:ty,Root:ny,Viewport:ry,Content:oy,Item:sy,Button:iy};const ay=Zt.Provider;function cy({className:e,...t}){return d.jsx(Zt.Root,{className:he("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function uy({className:e,...t}){return d.jsx(Zt.Viewport,{className:he("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function ly({className:e,...t}){return d.jsx(Zt.Content,{className:he("flex h-max min-h-full flex-col",e),...t})}function dy({className:e,...t}){return d.jsx(Zt.Item,{className:he("min-w-0 shrink-0",e),...t})}function py({className:e,...t}){return d.jsx(Zt.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?d.jsx(ot,{...r,type:"button",variant:"outline",size:"icon",className:he("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:d.jsx(Na,{})}):null,...t})}function hy(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function fy(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const my="lobu-spa";function Yn(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function On(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const ow=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:s,agentId:i,conversationId:a}=cn(),{data:c=[]}=Za(i,{conversationId:a});return d.jsx(Xv,{extension:r,children:d.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[d.jsx(gy,{messages:s,trips:c,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:d.jsx("div",{className:Ya,children:d.jsx(By,{})})]})})},gy=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>d.jsx(ay,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:d.jsx(vy,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function _y(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const vy=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:s}=_a(),{scrollToMessage:i}=ga(),a=m.useRef(null);m.useEffect(()=>{if(e.length===0||typeof window>"u")return;const u=fy({messageIds:e.map(l=>l.id),scrollTarget:hy(window.location.search),alreadyScrolledTo:a.current});u.scroll&&(a.current=u.id,i(u.id,{align:"start",behavior:"smooth"}))},[e,i]);const c=u=>n==="runs"?u.id.startsWith("sep:"):u.role==="user";return d.jsxs(cy,{children:[d.jsx(uy,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:d.jsxs(ly,{className:he(hr,Qa),children:[e.map(u=>{const l=n==="runs"&&o?_y(u.id):null;return d.jsx(dy,{messageId:u.id,scrollAnchor:c(u),"aria-current":u.id===s?"location":void 0,className:he("flex flex-col",n==="runs"&&c(u)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&u.id===s&&"border-primary"),children:l!=null?d.jsx(Cy,{message:u,onClick:()=>o?.(l)}):d.jsx($y,{message:u})},u.id)}),t.map(u=>d.jsx(yy,{trip:u},u.id)),d.jsx(ky,{}),r?d.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?d.jsx(by,{messages:e,mode:n}):null,d.jsx(py,{})]})},by=({messages:e,mode:t})=>{const{scrollToMessage:n}=ga(),{currentAnchorId:r,visibleMessageIds:o}=_a(),s=t==="runs"?e.flatMap(a=>a.parts).filter(a=>a.type==="tool-call"&&a.toolName==="tool-approval"&&a.args!==null&&typeof a.args=="object"&&a.args.status==="pending").length:0,i=e.flatMap(a=>{if(!(t==="runs"?a.id.startsWith("sep:"):a.role==="user"))return[];const u=a.parts.find(l=>l.type==="text");return[{id:a.id,label:u?.type==="text"?u.text:"Automation run"}]});return i.length===0?null:d.jsxs(La,{children:[d.jsx(Da,{asChild:!0,children:d.jsxs(ot,{type:"button",variant:"outline",size:"icon",className:he("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",s>0&&"w-auto px-3"),"aria-label":s>0?`Open transcript outline, ${s} ${s===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[d.jsx(Ua,{}),s>0?d.jsxs("span",{className:"text-xs tabular-nums",children:[s," waiting"]}):null]})}),d.jsxs(qa,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[d.jsxs("div",{className:"px-1",children:[d.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),d.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(a=>{const c=a.id===r,u=o.includes(a.id);return d.jsxs(ot,{type:"button",variant:c?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":c?"location":void 0,onClick:()=>n(a.id,{align:"start",behavior:"smooth"}),children:[d.jsx("span",{className:he("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",u&&"bg-primary/60",c&&"bg-primary")}),d.jsx("span",{className:"line-clamp-2",children:a.label})]},a.id)})})]})]})},yy=({trip:e})=>d.jsxs("div",{className:he(hr,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[d.jsx(Ma,{className:"mt-0.5 size-4 shrink-0"}),d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",d.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?d.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),wy=({prompts:e,onPick:t,className:n})=>e.length===0?null:d.jsx("div",{className:he("flex flex-wrap gap-2",n),children:e.map(r=>d.jsx(ot,{type:"button",variant:"outline",size:"sm",className:"h-auto rounded-full whitespace-normal text-left",title:r.message,"aria-label":`${r.title}: ${r.message}`,onClick:()=>t(r.message),children:r.title},`${r.title}\0${r.message}`))}),ky=()=>{const{currentSuggestions:e,running:t,append:n}=cn();return t||!e||e.length===0?null:d.jsx(wy,{prompts:e,className:hr,onPick:r=>n(r)})},$y=({message:e})=>e.role==="user"?d.jsx(Sy,{message:e}):e.role==="system"?d.jsx(Ny,{message:e}):d.jsx(zy,{message:e}),va=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return d.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:d.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=d.jsxs(d.Fragment,{children:[d.jsx(Xn,{className:"h-3 w-3 shrink-0"}),d.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return d.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?d.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},Sy=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?d.jsx("div",{className:ps,children:d.jsx("div",{className:"space-y-2",children:t.map(n=>d.jsx(xy,{part:n},On(e,n)))})}):d.jsx("div",{className:Xa,children:d.jsxs("div",{className:he(Kt,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?d.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>d.jsx(va,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?d.jsx("div",{className:"whitespace-pre-wrap break-words",children:d.jsx(Yr,{text:n.text,renderText:r=>r})},On(e,n)):null)]})})},xy=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return d.jsxs("div",{className:he(Kt,"overflow-hidden text-xs"),children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[d.jsx(Fa,{className:"size-3.5 shrink-0 text-muted-foreground"}),d.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?d.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?d.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?d.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},ba=new Set(["question","link-button","tool-approval"]),Ry="subscription-candidate",zy=({message:e})=>{const t=Wr(),{agentId:n,workspaceSlug:r}=cn(),o=c=>c.type==="tool-call"&&(ba.has(c.toolName)||t?.toolNames.has(c.toolName)),s=e.parts.filter(c=>c.type==="tool-call"&&!o(c)&&c.toolName!==Ry),i=e.parts.filter(c=>c.type!=="tool-call"||o(c)),a=e.parts.flatMap(c=>{if(c.type!=="tool-call")return[];const u=ea(c.result);return u?[u]:[]});return d.jsx("div",{className:ps,children:d.jsxs("div",{className:"space-y-2 text-sm",children:[s.length>0?d.jsx(Iy,{tools:s}):null,n&&r?a.map(c=>d.jsx(Ty,{candidate:c,agentId:n,workspaceSlug:r},`${c.connector_key}:${c.resource_ref}`)):null,i.map(c=>d.jsx(Py,{part:c},On(e,c))),e.attachments&&e.attachments.length>0?d.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(c=>d.jsx(va,{attachment:c},c.id))}):null]})})},Ty=({candidate:e,agentId:t,workspaceSlug:n})=>d.jsxs("div",{className:he(Kt,"flex items-center justify-between gap-3 p-3"),children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),d.jsx(ot,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:d.jsxs(ls,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[d.jsx(Va,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]}),Iy=({tools:e})=>d.jsxs(sa,{defaultOpen:!1,children:[d.jsx(ia,{children:e.length===1?e[0].toolName:`${e.length} tool calls`}),d.jsx(ca,{children:e.map(t=>{const n=t.args!==void 0&&t.args!==null,r=t.result!==void 0&&t.result!==null;return d.jsxs(aa,{icon:Ha,label:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"font-medium",children:t.toolName}),t.isError?d.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:t.isError?"active":"complete",children:[n?d.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Wt(t.args)}):null,r?d.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Wt(t.result)}):null]},t.toolCallId)})})]}),Ey=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const s=JSON.parse(r[0])?.error?.message;typeof s=="string"&&s.trim()&&(t=s,n=e)}catch{}return d.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[d.jsx(Ja,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),d.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[d.jsx("p",{className:"text-foreground/80",children:t}),n&&d.jsxs("details",{className:"text-xs text-muted-foreground",children:[d.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),d.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},Py=({part:e})=>{const t=Wr();return e.type==="reasoning"?d.jsx(yb,{}):e.type==="error"?d.jsx(Ey,{text:e.text}):e.type==="text"?e.text.trim()?d.jsx(Yr,{text:e.text,renderText:n=>d.jsx(Ba,{text:n})}):null:e.type!=="tool-call"?null:ba.has(e.toolName)||t?.toolNames.has(e.toolName)?d.jsx(Vy,{toolName:e.toolName,args:e.args}):null},Cy=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return d.jsx("button",{type:"button",onClick:t,className:he(Kt,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},Ny=({message:e})=>d.jsx("div",{className:"self-stretch",children:d.jsx("div",{className:he(Kt,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?d.jsx("div",{className:"whitespace-pre-wrap break-words",children:d.jsx(Yr,{text:t.text,renderText:n=>n})},On(e,t)):null)})}),Zy="/mcp-apps/interaction/index.html";function cs(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const Oy=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const s=m.useRef(null),[i,a]=m.useState(48),c=m.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return c.current={renderPayload:n,onToolCall:r,onOpenLink:o},m.useEffect(()=>{const u=s.current;if(!u?.contentWindow)return;const l=new Yv(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});l.addEventListener("sizechange",({height:f})=>{typeof f=="number"&&a(Math.max(32,Math.ceil(f)))}),l.oncalltool=async({name:f,arguments:y})=>({content:[],isError:await c.current.onToolCall(f,y??{})}),l.onopenlink=async({url:f})=>({isError:await c.current.onOpenLink(f)}),l.addEventListener("initialized",()=>{(async()=>(await l.sendToolInput({arguments:{}}),await l.sendToolResult({content:[],structuredContent:{...c.current.renderPayload,version:1,source:my}})))()});const p=new Kv(u.contentWindow,u.contentWindow);l.connect(p).catch(f=>{console.error("[mcp-app-host] failed to initialize",f)});const h=new MutationObserver(()=>{l.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{h.disconnect(),p.close()}},[]),d.jsx("iframe",{ref:s,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},Ay=new Set(["action"]),jy=["name","description","identity_md"];function Ke(e){return e==null||e===""?"":typeof e=="string"?e:Wt(e)}function us(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Wt(e)}function lr(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const ya=new Set(["delete","disconnect","merge","remove","remove_rule","reset","revoke"]);function dr(e){return e&&ya.has(e)?"warning":"default"}function pr(e,t){return e&&ya.has(e)?{level:"high",reason:t}:{level:"normal"}}function My(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(s=>({label:s,before:Ke(e.current?.[s]),after:Ke(t[s])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function Ly(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},s=Object.keys(o).filter(i=>!Ay.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:us(e.current?.[i])}:{},after:us(o[i])}));return r.push(s.length>0?{type:"diff",fields:s}:{type:"text",value:"No field changes.",muted:!0}),{title:`${lr(t)} Automation ${n}`,icon:"automation",impact:pr(e.action,"This archives the Automation and stops future runs."),tone:dr(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function Dy(e){return e.action==="merge"&&(e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.proposal?.winner_entity_id!==void 0||e.current?.winner!==void 0)}function Uy(e){if(e.resourceKind==="automation")return Ly(e);if(e.fields&&Object.keys(e.fields).length>0)return My(e,e.fields);if(e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0){const s=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",a=[];if(e.action==="delete")a.push({type:"text",value:"This will delete the entity.",muted:!0});else{const c=Object.keys(e.proposal??{}).filter(u=>!["entity_id","id"].includes(u)&&e.proposal?.[u]!==void 0&&Ke(e.proposal?.[u])!==Ke(e.current?.[u])).map(u=>({label:u,...e.action==="update"?{before:Ke(e.current?.[u])}:{},after:Ke(e.proposal?.[u])}));a.push(c.length>0?{type:"diff",fields:c}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${lr(i)} entity ${s}`,icon:"entity",impact:pr(e.action,e.action==="merge"?"This combines duplicate records into the selected winner.":"This deletes the entity."),tone:dr(e.action),blocks:a,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${s} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${s} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const s=jy.filter(i=>e.proposal?.[i]!==void 0&&Ke(e.proposal?.[i])!==Ke(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:Ke(e.current?.[i])}:{},after:Ke(e.proposal?.[i])}));o.push(s.length>0?{type:"diff",fields:s}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${lr(r)} agent ${n}`,icon:"agent",impact:pr(e.action,"This permanently deletes the agent and its configuration."),tone:dr(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function qy(e,t){const n=[];e.args!==void 0&&e.args!==null&&n.push({type:"code",value:Wt(e.args)});const r=t.map(o=>({id:o,label:o==="always"?"Always allow":`Approve ${o}`,variant:"outline",tool:"approve_tool_request",args:{decision:o},resolvedLabel:o==="always"?"Approved — always allowed.":`Approved for ${o}.`}));return r.push({id:"deny",label:"Deny",variant:"ghost",tool:"approve_tool_request",args:{decision:"deny"},resolvedLabel:"Denied."}),{title:`Wants to run ${e.tool??"a tool"}`,icon:"tool",impact:{level:"high",reason:"This grants the agent permission to use a tool."},tone:"warning",blocks:n,actions:r}}function Fy(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Hy(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Vy=({toolName:e,args:t})=>{const n=Wa(),r=Ka(),{append:o}=cn(),s=Wr(),i=t??{},a=s?.resolve(e,t)??null;let c=a?.view??null;const u={...a?.handlers??{}},l=new Set;if(!a){if(e==="tool-approval"&&typeof i.runId=="number"){const p=i.runId,h=typeof i.status=="string"?i.status:"pending",f=h==="pending",y=Dy(i),Z=y?$b(i):null,x=Z?.view??Uy(i),j=h==="rejected"?i.action==="merge"?"Kept separate":"Rejected":h==="failed"?"Failed":"Approved";c=f||y?x:{...x,title:`${x.title??"Approval"} · ${j}`,tone:h==="failed"?"warning":"default",blocks:[...x.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${j} by ${i.reviewedByName}.`:`${j}.`,muted:!0}],actions:(x.actions??[]).filter(w=>w.terminal===!1)},f&&(u.manage_operations=w=>{if(w.action==="approve")return cs($=>n.mutate({run_id:p},$));if(w.action==="reject"){const $=typeof w.reason=="string"?w.reason:void 0;return cs(A=>r.mutate({run_id:p,...$?{reason:$}:{}},A))}return Promise.resolve(!0)});const z=Z?.reviewUrls??new Set;for(const w of z)l.add(w);u.open_review_link=w=>{const $=typeof w.url=="string"?w.url:"";return!z.has($)||!Yn($)?Promise.resolve(!0):(window.open($,"_blank","noopener,noreferrer"),Promise.resolve(!1))}}else if(e==="tool-approval"){const p=Array.isArray(i.durationOptions)&&i.durationOptions.every(f=>typeof f=="string")&&i.durationOptions.length>0?i.durationOptions:["1h","24h","always"],h=new Set([...p,"deny"]);c=qy(i,p),u.approve_tool_request=async f=>{const y=typeof f.decision=="string"?f.decision:"";if(!i.requestId||!i.approveUrl||!h.has(y))return!0;try{return!(await Qn(i.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...i.orgSlug?{"x-lobu-org":i.orgSlug}:{}},credentials:"include",body:JSON.stringify({requestId:i.requestId,decision:y}),timeoutMs:2e4})).ok}catch{return!0}}}else if(e==="question"){const p=Array.isArray(i.options)?i.options.filter(h=>typeof h=="string"):[];c=Fy(i),u.answer_question=h=>{const f=typeof h.answer=="string"?h.answer:"";return p.includes(f)?(o(f),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!Yn(i.url))return null;const p=i.url;l.add(p),c=Hy(i,p)}}return c?d.jsx(Oy,{src:Zy,title:c.title??"Interaction",renderPayload:c,onToolCall:(p,h)=>u[p]?u[p](h):Promise.resolve(!0),onOpenLink:p=>!l.has(p)||!Yn(p)?Promise.resolve(!0):(window.open(p,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Wt(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const By=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:s,initialDraft:i,currentSuggestions:a,executionTarget:c}=cn(),u=Jy({suggestions:e?null:a}),[l,p]=m.useState(i??""),h=m.useRef(null),f=m.useRef(null),y=sc(ac),Z=m.useRef(i??"");m.useEffect(()=>{const z=i??"";if(z===Z.current)return;const w=Z.current;Z.current=z,z!==""&&p($=>$===""||$===w?z:$)},[i]);const x=m.useRef(l);x.current=l;const j=()=>{e||(t(x.current),p(""),f.current?.clear())};return d.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[!c&&r.length>0?d.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(z=>d.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[d.jsx(Xn,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),d.jsx("span",{className:"max-w-[12rem] truncate",children:z.name}),d.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>s(z.id),children:d.jsx(Oa,{className:"h-3 w-3"})})]},z.id))}):null,d.jsx(ic,{value:l,onChange:p,onSubmit:j,searchRefs:y,handleRef:f,placeholder:u,className:"max-h-48 overflow-y-auto"}),d.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[c?d.jsx("span",{className:"px-2 text-xs text-muted-foreground",children:"Running on your device"}):d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:h,type:"file",multiple:!0,className:"hidden",onChange:z=>{z.target.files&&o(z.target.files),z.target.value=""}}),d.jsxs(ot,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>h.current?.click(),children:[d.jsx(Xn,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Attach files"})]})]}),e?d.jsxs(ot,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[d.jsx(Aa,{size:"lg"}),d.jsx("span",{className:"sr-only",children:"Cancel"})]}):d.jsxs(ot,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:j,children:[d.jsx(ja,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function Jy({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{ow as A,nw as L,tw as R,rw as a,$b as b,mb as h,db as s};