@leed-ai/cli 0.0.0-stage → 6.19.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 (263) hide show
  1. package/LICENSE.md +57 -0
  2. package/README.md +125 -2
  3. package/dist/LICENSE.md +57 -0
  4. package/dist/acorn-DAgDT1om.js +5087 -0
  5. package/dist/angular-l0_4PK8N.js +3598 -0
  6. package/dist/authShared-Dray38Ls.js +1161 -0
  7. package/dist/babel-CJeRQd5u.js +10038 -0
  8. package/dist/buildResults-tiq1nugP.js +21180 -0
  9. package/dist/chunk-1VJ9lAw7.js +42 -0
  10. package/dist/cliAuth-38JjD6hw.js +15 -0
  11. package/dist/env-B0bHiXJJ.js +29 -0
  12. package/dist/errors-CqKamGCu.js +481 -0
  13. package/dist/estree-E8WG8UHj.js +6930 -0
  14. package/dist/flow-6xaRIbPQ.js +52255 -0
  15. package/dist/glimmer-aJPjsfbT.js +7272 -0
  16. package/dist/graphql-mcgtPEiZ.js +1901 -0
  17. package/dist/html--eeea3Kl.js +6553 -0
  18. package/dist/leed.eleventy.mjs +6525 -0
  19. package/dist/leed.mjs +88952 -0
  20. package/dist/leed.sources.json +798 -0
  21. package/dist/leedLogger-Zkada5aO.js +78 -0
  22. package/dist/markdown-D73jNKwx.js +6836 -0
  23. package/dist/meriyah-CMp1nDDW.js +8932 -0
  24. package/dist/package.json +101 -0
  25. package/dist/postcss-h4fBr2Fn.js +6760 -0
  26. package/dist/prettier-CwFSKxfN.js +16821 -0
  27. package/dist/static/customer-site-worker/package.json +9 -0
  28. package/dist/static/customer-site-worker/src/assetsHydration.ts +55 -0
  29. package/dist/static/customer-site-worker/src/constants.ts +20 -0
  30. package/dist/static/customer-site-worker/src/cors.ts +120 -0
  31. package/dist/static/customer-site-worker/src/index.ts +242 -0
  32. package/dist/static/customer-site-worker/src/mcp-proxy.ts +98 -0
  33. package/dist/static/customer-site-worker/src/proxy.ts +92 -0
  34. package/dist/static/customer-site-worker/src/proxyHeaders.ts +47 -0
  35. package/dist/static/customer-site-worker/src/tier.ts +40 -0
  36. package/dist/static/customer-site-worker/src/types.ts +82 -0
  37. package/dist/static/customer-site-worker/test/functions-mock.worker.js +50 -0
  38. package/dist/static/customer-site-worker/tsconfig.json +19 -0
  39. package/dist/static/customer-site-worker/vitest.workers.config.ts +61 -0
  40. package/dist/static/install/husky/colors.mjs +5 -0
  41. package/dist/static/install/husky/hooks/commit-msg +1 -0
  42. package/dist/static/install/husky/hooks/pre-commit +1 -0
  43. package/dist/static/install/husky/hooks/pre-push +1 -0
  44. package/dist/static/install/husky/valid-command.mjs +29 -0
  45. package/dist/static/install/husky/valid-commit-msg.mjs +20 -0
  46. package/dist/static/install/package.json +10 -0
  47. package/dist/static/install/packages.txt +4 -0
  48. package/dist/static/install/tasks.json +111 -0
  49. package/dist/static/javascript/detectIncognito.js +195 -0
  50. package/dist/static/javascript/documentation.js +2781 -0
  51. package/dist/static/javascript/fp/fp.esm.js +2896 -0
  52. package/dist/static/javascript/fp/fp.js +3067 -0
  53. package/dist/static/javascript/live-search.js +986 -0
  54. package/dist/static/javascript/lunr-search.js +843 -0
  55. package/dist/static/javascript/timeme.js +451 -0
  56. package/dist/static/javascript/tracker/webmcp.js +67 -0
  57. package/dist/static/javascript/tracker/whisper.js +1 -0
  58. package/dist/static/javascript/utilities.js +819 -0
  59. package/dist/static/javascript/versions.json +74 -0
  60. package/dist/static/javascript/zoomable.js +488 -0
  61. package/dist/static/site/_data/eleventyComputed.js +228 -0
  62. package/dist/static/site/_data/leed-form-data.json +253 -0
  63. package/dist/static/site/_includes/leed/api/bits/array-type.hbs +24 -0
  64. package/dist/static/site/_includes/leed/api/bits/badges.hbs +9 -0
  65. package/dist/static/site/_includes/leed/api/bits/description.hbs +9 -0
  66. package/dist/static/site/_includes/leed/api/bits/examples.hbs +42 -0
  67. package/dist/static/site/_includes/leed/api/bits/scopes.hbs +28 -0
  68. package/dist/static/site/_includes/leed/api/object.hbs +110 -0
  69. package/dist/static/site/_includes/leed/api/parameters.hbs +11 -0
  70. package/dist/static/site/_includes/leed/api/property.hbs +153 -0
  71. package/dist/static/site/_includes/leed/api/request-body.hbs +51 -0
  72. package/dist/static/site/_includes/leed/api/responses.hbs +89 -0
  73. package/dist/static/site/_includes/leed/api/security-constraints.hbs +59 -0
  74. package/dist/static/site/_includes/leed/api/security.hbs +75 -0
  75. package/dist/static/site/_includes/leed/components/pagination.hbs +45 -0
  76. package/dist/static/site/_includes/leed/components/scroll-status-indicator-horizontal.hbs +22 -0
  77. package/dist/static/site/_includes/leed/docs/alpha/api.hbs +6 -0
  78. package/dist/static/site/_includes/leed/docs/alpha/base.hbs +26 -0
  79. package/dist/static/site/_includes/leed/docs/alpha/documentation.hbs +7 -0
  80. package/dist/static/site/_includes/leed/docs/api-article.hbs +75 -0
  81. package/dist/static/site/_includes/leed/docs/bravo/api.hbs +5 -0
  82. package/dist/static/site/_includes/leed/docs/bravo/base.hbs +31 -0
  83. package/dist/static/site/_includes/leed/docs/bravo/documentation.hbs +7 -0
  84. package/dist/static/site/_includes/leed/docs/charlie/api.hbs +6 -0
  85. package/dist/static/site/_includes/leed/docs/charlie/base.hbs +27 -0
  86. package/dist/static/site/_includes/leed/docs/charlie/documentation.hbs +10 -0
  87. package/dist/static/site/_includes/leed/docs/doc-article.hbs +40 -0
  88. package/dist/static/site/_includes/leed/docs/docs-footer.hbs +35 -0
  89. package/dist/static/site/_includes/leed/docs/docs-header.hbs +59 -0
  90. package/dist/static/site/_includes/leed/docs/document-search-modal.hbs +36 -0
  91. package/dist/static/site/_includes/leed/docs/document-search.hbs +23 -0
  92. package/dist/static/site/_includes/leed/docs/footer.hbs +12 -0
  93. package/dist/static/site/_includes/leed/docs/header/brand.hbs +19 -0
  94. package/dist/static/site/_includes/leed/docs/header/chrome.hbs +33 -0
  95. package/dist/static/site/_includes/leed/docs/header/compact.hbs +19 -0
  96. package/dist/static/site/_includes/leed/docs/header/cta.hbs +15 -0
  97. package/dist/static/site/_includes/leed/docs/header/nav.hbs +18 -0
  98. package/dist/static/site/_includes/leed/docs/header/top-search.hbs +15 -0
  99. package/dist/static/site/_includes/leed/docs/mini-bar.hbs +53 -0
  100. package/dist/static/site/_includes/leed/docs/pagination.hbs +19 -0
  101. package/dist/static/site/_includes/leed/docs/shell.hbs +56 -0
  102. package/dist/static/site/_includes/leed/docs/sidebar.hbs +52 -0
  103. package/dist/static/site/_includes/leed/docs/social-icons.hbs +81 -0
  104. package/dist/static/site/_includes/leed/docs/style.hbs +17 -0
  105. package/dist/static/site/_includes/leed/docs/toc.hbs +7 -0
  106. package/dist/static/site/_includes/leed/form.hbs +266 -0
  107. package/dist/static/site/_includes/leed/head.hbs +67 -0
  108. package/dist/static/site/_includes/leed/menu/builder.hbs +35 -0
  109. package/dist/static/site/_includes/leed/menu/item.hbs +67 -0
  110. package/dist/static/site/_includes/leed/menu/link.hbs +59 -0
  111. package/dist/static/site/_includes/leed/metadata/ogCard.hbs +40 -0
  112. package/dist/static/site/_includes/leed/metadata/siteMetadata.hbs +24 -0
  113. package/dist/static/site/_includes/leed/metadata/twitterCard.hbs +34 -0
  114. package/dist/static/site/_includes/leed/popup-video.hbs +21 -0
  115. package/dist/static/site/_includes/leed/stub-template.hbs +17 -0
  116. package/dist/static/site/_includes/leed/unsubscribe-form.hbs +30 -0
  117. package/dist/static/site/_layouts/leed-documentation.hbs +12 -0
  118. package/dist/static/site/leed-feed-atom.hbs +42 -0
  119. package/dist/static/site/leed-feed-json.hbs +56 -0
  120. package/dist/static/site/leed-feed-rss.hbs +39 -0
  121. package/dist/static/site/leed-headers.hbs +38 -0
  122. package/dist/static/site/leed-redirects.hbs +10 -0
  123. package/dist/static/site/leed-sitemap-pageType.hbs +28 -0
  124. package/dist/static/site/leed-sitemap.hbs +19 -0
  125. package/dist/static/site/leed-unsubscribe.hbs +44 -0
  126. package/dist/static/site/leed-unsubscribed.hbs +40 -0
  127. package/dist/static/tailwind/components/alerts.css +132 -0
  128. package/dist/static/tailwind/components/api-methods.css +39 -0
  129. package/dist/static/tailwind/components/breadcrumbs.css +31 -0
  130. package/dist/static/tailwind/components/code.css +88 -0
  131. package/dist/static/tailwind/components/collapsible.css +38 -0
  132. package/dist/static/tailwind/components/document-search.css +222 -0
  133. package/dist/static/tailwind/components/form.css +185 -0
  134. package/dist/static/tailwind/components/kbd.css +7 -0
  135. package/dist/static/tailwind/components/pagination.css +81 -0
  136. package/dist/static/tailwind/components/scroll-status-indicator.css +5 -0
  137. package/dist/static/tailwind/components/tab-groups.css +117 -0
  138. package/dist/static/tailwind/components/tables.css +0 -0
  139. package/dist/static/tailwind/components/toc.css +60 -0
  140. package/dist/static/tailwind/components.css +248 -0
  141. package/dist/static/tailwind/defaults.css +260 -0
  142. package/dist/static/tailwind/docs/api.css +701 -0
  143. package/dist/static/tailwind/docs/components/blockquote.css +5 -0
  144. package/dist/static/tailwind/docs/components/button.css +11 -0
  145. package/dist/static/tailwind/docs/components/docs-pagination.css +71 -0
  146. package/dist/static/tailwind/docs/components/mobile-bar.css +83 -0
  147. package/dist/static/tailwind/docs/components/navigation.css +279 -0
  148. package/dist/static/tailwind/docs/components/table.css +54 -0
  149. package/dist/static/tailwind/docs/components.css +6 -0
  150. package/dist/static/tailwind/docs/docs.css +427 -0
  151. package/dist/static/tailwind/docs/layouts/alpha.css +108 -0
  152. package/dist/static/tailwind/docs/layouts/bravo.css +218 -0
  153. package/dist/static/tailwind/docs/layouts/charlie.css +105 -0
  154. package/dist/static/tailwind/docs/layouts.css +3 -0
  155. package/dist/static/tailwind/docs/themes/amber.css +113 -0
  156. package/dist/static/tailwind/docs/themes/blue.css +94 -0
  157. package/dist/static/tailwind/docs/themes/cyan.css +111 -0
  158. package/dist/static/tailwind/docs/themes/emerald.css +111 -0
  159. package/dist/static/tailwind/docs/themes/fuchsia.css +111 -0
  160. package/dist/static/tailwind/docs/themes/green.css +95 -0
  161. package/dist/static/tailwind/docs/themes/indigo.css +111 -0
  162. package/dist/static/tailwind/docs/themes/lime.css +111 -0
  163. package/dist/static/tailwind/docs/themes/orange.css +111 -0
  164. package/dist/static/tailwind/docs/themes/pink.css +111 -0
  165. package/dist/static/tailwind/docs/themes/purple.css +111 -0
  166. package/dist/static/tailwind/docs/themes/red.css +111 -0
  167. package/dist/static/tailwind/docs/themes/rose.css +111 -0
  168. package/dist/static/tailwind/docs/themes/sky.css +111 -0
  169. package/dist/static/tailwind/docs/themes/teal.css +111 -0
  170. package/dist/static/tailwind/docs/themes/violet.css +111 -0
  171. package/dist/static/tailwind/docs/themes/yellow.css +111 -0
  172. package/dist/static/tailwind/docs/themes.css +84 -0
  173. package/dist/static/tailwind/font-awesome/free-7.3.1/brands.css +2455 -0
  174. package/dist/static/tailwind/font-awesome/free-7.3.1/fontawesome.css +8997 -0
  175. package/dist/static/tailwind/font-awesome/free-7.3.1/fonts.css +45 -0
  176. package/dist/static/tailwind/font-awesome/free-7.3.1/icons.json +2608 -0
  177. package/dist/static/tailwind/font-awesome/free-7.3.1.css +3 -0
  178. package/dist/static/tailwind/font-awesome/pro-7.0.0/brands.css +2215 -0
  179. package/dist/static/tailwind/font-awesome/pro-7.0.0/fontawesome.css +19281 -0
  180. package/dist/static/tailwind/font-awesome/pro-7.0.0/fonts.css +445 -0
  181. package/dist/static/tailwind/font-awesome/pro-7.0.0.css +3 -0
  182. package/dist/static/tailwind/font-awesome/pro-7.3.1/brands.css +2455 -0
  183. package/dist/static/tailwind/font-awesome/pro-7.3.1/fontawesome.css +20365 -0
  184. package/dist/static/tailwind/font-awesome/pro-7.3.1/fonts.css +589 -0
  185. package/dist/static/tailwind/font-awesome/pro-7.3.1.css +3 -0
  186. package/dist/static/tailwind/fonts/all.css +6 -0
  187. package/dist/static/tailwind/fonts/config.jsonc +31 -0
  188. package/dist/static/tailwind/fonts/geist-mono.css +142 -0
  189. package/dist/static/tailwind/fonts/geist.css +142 -0
  190. package/dist/static/tailwind/fonts/inter.css +215 -0
  191. package/dist/static/tailwind/fonts/jetbrains-mono.css +126 -0
  192. package/dist/static/tailwind/fonts/noto-sans.css +134 -0
  193. package/dist/static/tailwind/fonts/open-sans.css +89 -0
  194. package/dist/static/tailwind/highlighters.css +14 -0
  195. package/dist/static/tailwind/hljs/README.md +53 -0
  196. package/dist/static/tailwind/hljs/a11y.css +96 -0
  197. package/dist/static/tailwind/hljs/atom-fruit.css +90 -0
  198. package/dist/static/tailwind/hljs/atom-one.css +164 -0
  199. package/dist/static/tailwind/hljs/default.css +164 -0
  200. package/dist/static/tailwind/hljs/github.css +101 -0
  201. package/dist/static/tailwind/hljs/google-code.css +112 -0
  202. package/dist/static/tailwind/hljs/grayscale.css +115 -0
  203. package/dist/static/tailwind/hljs/gruvbox-hard.css +115 -0
  204. package/dist/static/tailwind/hljs/gruvbox-medium.css +115 -0
  205. package/dist/static/tailwind/hljs/gruvbox-soft.css +115 -0
  206. package/dist/static/tailwind/hljs/papercolor.css +120 -0
  207. package/dist/static/tailwind/hljs/qt-creator.css +91 -0
  208. package/dist/static/tailwind/hljs/summerfruit.css +115 -0
  209. package/dist/static/tailwind/hljs/tomorrow.css +115 -0
  210. package/dist/static/tailwind/leed.css +170 -0
  211. package/dist/static/tailwind/site-tokens.reference.css +105 -0
  212. package/dist/static/tailwind/utils/icons.css +102 -0
  213. package/dist/static/tailwind/utils/utilities.css +105 -0
  214. package/dist/static/templates/pages/PAGE.hbs +27 -0
  215. package/dist/static/templates/pages/PAGE_LAYOUT.hbs +19 -0
  216. package/dist/static/templates/pages/PAGE_TYPE_INDEX.hbs +89 -0
  217. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_ITEM.hbs +52 -0
  218. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_LIST.hbs +39 -0
  219. package/dist/static/templates/pages/PAGINATED_PAGE_TYPE_PAGINATION.hbs +11 -0
  220. package/dist/static/templates/raw-content/.ci/build.sh +58 -0
  221. package/dist/static/templates/raw-content/README.md +179 -0
  222. package/dist/static/templates/raw-content/_gitignore +50 -0
  223. package/dist/static/templates/raw-content/src/404.hbs +21 -0
  224. package/dist/static/templates/raw-content/src/_data/autolink.json +1 -0
  225. package/dist/static/templates/raw-content/src/_data/ctaList.json +1 -0
  226. package/dist/static/templates/raw-content/src/_data/leedForms.json +1 -0
  227. package/dist/static/templates/raw-content/src/_data/menu.json +1 -0
  228. package/dist/static/templates/raw-content/src/_includes/footer.hbs +18 -0
  229. package/dist/static/templates/raw-content/src/_includes/header-includes.hbs +25 -0
  230. package/dist/static/templates/raw-content/src/_includes/header.hbs +5 -0
  231. package/dist/static/templates/raw-content/src/_includes/site-template.hbs +23 -0
  232. package/dist/static/templates/raw-content/src/_includes/unsubscribe-DISABLED.hbs +17 -0
  233. package/dist/static/templates/raw-content/src/_includes/unsubscribed-DISABLED.hbs +13 -0
  234. package/dist/static/templates/raw-content/src/_layouts/empty.hbs +2 -0
  235. package/dist/static/templates/raw-content/src/index.hbs +21 -0
  236. package/dist/static/templates/raw-content/src/robots.hbs +9 -0
  237. package/dist/static/templates/raw-content/tailwind/site/base.css +44 -0
  238. package/dist/static/templates/raw-content/tailwind/site.config.css +3 -0
  239. package/dist/static/templates/sandbox/_gitignore +50 -0
  240. package/dist/static/templates/sandbox/identity.json +1 -0
  241. package/dist/static/templates/sandbox/src/404.hbs +21 -0
  242. package/dist/static/templates/sandbox/src/_data/autolink.json +1 -0
  243. package/dist/static/templates/sandbox/src/_data/ctaList.json +1 -0
  244. package/dist/static/templates/sandbox/src/_data/labelList.json +9 -0
  245. package/dist/static/templates/sandbox/src/_data/leedForms.json +20 -0
  246. package/dist/static/templates/sandbox/src/_data/menu.json +19 -0
  247. package/dist/static/templates/sandbox/src/_data/pageTypeList.json +14 -0
  248. package/dist/static/templates/sandbox/src/_data/searchIndexList.json +1 -0
  249. package/dist/static/templates/sandbox/src/_data/userList.json +11 -0
  250. package/dist/static/templates/sandbox/src/_includes/footer.hbs +18 -0
  251. package/dist/static/templates/sandbox/src/_includes/header-includes.hbs +25 -0
  252. package/dist/static/templates/sandbox/src/_includes/header.hbs +5 -0
  253. package/dist/static/templates/sandbox/src/_includes/site-template.hbs +23 -0
  254. package/dist/static/templates/sandbox/src/_layouts/empty.hbs +2 -0
  255. package/dist/static/templates/sandbox/src/index.hbs +20 -0
  256. package/dist/static/templates/sandbox/src/robots.hbs +9 -0
  257. package/dist/static/templates/sandbox/src/src.11tydata.json +39 -0
  258. package/dist/static/templates/sandbox/tailwind/site/base.css +44 -0
  259. package/dist/static/templates/sandbox/tailwind/site.config.css +3 -0
  260. package/dist/thrown-sukVkp_1.js +113 -0
  261. package/dist/typescript-D4T0V_Hn.js +23004 -0
  262. package/dist/yaml-9wR8GxF_.js +5236 -0
  263. package/package.json +157 -4
@@ -0,0 +1,67 @@
1
+ (function(){let e={type:`object`,description:`One resource entry per requested id/path, in input order.`,properties:{resources:{type:`array`,description:`The resolved post resources.`,items:{type:`object`,description:`A published post (content present) OR a per-item not_found / protected_resource marker.`,properties:{pageId:{type:`string`,description:`Internal page id of the post, when resolved.`},title:{type:`string`,description:`Post title, when resolved.`},path:{type:`string`,description:`Site path the post lives under.`},url:{type:`string`,description:`Canonical absolute URL of the post.`},content:{type:`string`,description:`The post's Leed Markdown source (present only on a hit).`},publishedAt:{type:`string`,description:`ISO publish timestamp, when known.`},error:{type:`string`,description:"Per-item marker: `not_found` (missing/unpublished) or `protected_resource` (docs/api via /mcp)."},accessVia:{type:`string`,description:"Protected-resource pointer (`/mcp`), present only on protected items."},discovery:{type:`string`,description:`Protected-resource OAuth discovery path, present only on protected items.`}},additionalProperties:!1}}},required:[`resources`],additionalProperties:!1},t=[{name:`search_site`,description:`Full-text and semantic search across this site's published blog posts and articles. Returns ranked results with title, path, url, and a snippet — cherry-pick the returned pageIds into get_pages_by_id (or the paths into get_pages_by_path) to read full post content. Call list_post_types first to see which post types (blog, news, etc.) are available to search. Does NOT search developer documentation or API references — those are served via the authenticated Docs MCP at /mcp.`,inputSchema:{type:`object`,properties:{query:{type:`string`,description:`Free-text or semantic search query.`,minLength:1},limit:{type:`integer`,description:`Max results (1-25, default 10).`,minimum:1,maximum:25}},required:[`query`],additionalProperties:!1},outputSchema:{type:`object`,description:`Ranked search hits over published posts.`,properties:{mode:{type:`string`,description:`Search strategy actually used: freetext | vector | hybrid.`},results:{type:`array`,description:`Ranked hits, best first.`,items:{type:`object`,description:`A search hit (no full content — use get_pages_by_id to read it).`,properties:{pageId:{type:`string`,description:`Internal page id — pass to get_pages_by_id.`},title:{type:`string`,description:`Post title.`},path:{type:`string`,description:`Site path the post lives under.`},url:{type:`string`,description:`Canonical absolute URL of the post.`},snippet:{type:`string`,description:`Short text excerpt around the match.`},score:{type:`number`,description:`Relevance score (hybrid/vector score or FTS rank).`}},additionalProperties:!1}}},required:[`mode`,`results`],additionalProperties:!1},method:`GET`,path:`/api/agent/search`},{name:`get_site_overview`,description:`Get a high-level overview of this site: its name, description, primary url, and the count of published posts available to search. Call list_post_types to enumerate those post types (blog, news, etc.) with their base paths and per-type published counts.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:{type:`object`,description:`High-level site identity + content availability.`,properties:{name:{type:`string`,description:`Display name of the site.`},description:{type:`string`,description:`Short site description.`},url:{type:`string`,description:`Primary site origin.`},publishedPostTypes:{type:`integer`,description:`Number of published post page-types.`},publishedPostsCount:{type:`integer`,description:`Number of published posts available to search.`},protectedContent:{type:`object`,description:`Developer docs/API served via the authenticated Docs MCP (not this surface).`,properties:{kinds:{type:`array`,description:`The protected content kinds.`,items:{type:`string`}},available:{type:`boolean`,description:`Whether any published docs/api content exists.`},accessVia:{type:`string`,description:"Where to reach it (`/mcp`)."},discovery:{type:`string`,description:`OAuth protected-resource discovery path.`}},required:[`kinds`,`available`,`accessVia`,`discovery`],additionalProperties:!1}},required:[`name`,`description`,`url`,`publishedPostTypes`,`publishedPostsCount`,`protectedContent`],additionalProperties:!1},method:`GET`,path:`/api/agent/overview`},{name:`list_post_types`,description:`List this site's published post types (blog, news, etc.): name, base path, and published post count — the content categories available to search and read.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:{type:`object`,description:`The site's published post types.`,properties:{postTypes:{type:`array`,description:`Published post types.`,items:{type:`object`,description:`A published post type — a content category available to search and read.`,properties:{pageTypeId:{type:`string`,description:`Stable page-type id of the post type.`},name:{type:`string`,description:`Display name of the post type (e.g. Blog, News).`},basePath:{type:`string`,description:`Base site path the post type's content lives under.`},publishedCount:{type:`integer`,description:`Number of published posts of this type.`}},required:[`pageTypeId`,`name`,`basePath`,`publishedCount`],additionalProperties:!1}}},required:[`postTypes`],additionalProperties:!1},method:`GET`,path:`/api/agent/post-types`},{name:`get_pages_by_id`,description:`Fetch full content for one or more published posts by their pageIds (cherry-pick the pageIds returned by search_site). Returns, per id, the post's title, path, url, and Leed Markdown content. A docs/api page yields a per-item protected_resource marker pointing at the authenticated Docs MCP at /mcp; a missing or unpublished page yields a per-item not_found marker.`,inputSchema:{type:`object`,properties:{ids:{type:`array`,description:`Page IDs to fetch (from search_site). Up to 25 per call.`,items:{type:`string`,description:`An internal page id.`,minLength:1},minItems:1,maxItems:25}},required:[`ids`],additionalProperties:!1},outputSchema:e,method:`GET`,path:`/api/agent/pages-by-id`},{name:`get_pages_by_path`,description:`Fetch full content for one or more published posts by their site paths (from search_site or list_recent_posts). Returns, per path, the post's title, pageId, url, and Leed Markdown content. A docs/api path yields a per-item protected_resource marker pointing at the authenticated Docs MCP at /mcp; a missing, unpublished, or invalid path yields a per-item not_found marker.`,inputSchema:{type:`object`,properties:{paths:{type:`array`,description:`Site paths to fetch (e.g. /blog/my-post/). Up to 25 per call.`,items:{type:`string`,description:`A site path.`,minLength:1},minItems:1,maxItems:25}},required:[`paths`],additionalProperties:!1},outputSchema:e,method:`GET`,path:`/api/agent/pages-by-path`},{name:`list_recent_posts`,description:`List the most recently published blog posts, newest first. Returns title, path, url, and published date for each — cherry-pick paths or pageIds into get_pages_by_path / get_pages_by_id to read full content.`,inputSchema:{type:`object`,properties:{limit:{type:`integer`,description:`Max posts (1-50, default 10).`,minimum:1,maximum:50}},additionalProperties:!1},outputSchema:{type:`object`,description:`Most recently published posts, newest first.`,properties:{posts:{type:`array`,description:`Recent post pointers.`,items:{type:`object`,description:`A lightweight published-post pointer (no content).`,properties:{pageId:{type:`string`,description:`Internal page id of the post.`},title:{type:`string`,description:`Post title.`},path:{type:`string`,description:`Site path the post lives under.`},url:{type:`string`,description:`Canonical absolute URL of the post.`},publishedAt:{type:`string`,description:`ISO publish timestamp, when known.`}},additionalProperties:!1}}},required:[`posts`],additionalProperties:!1},method:`GET`,path:`/api/agent/recent-posts`}];t.map(e=>e.name);var n;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(n||={});var r;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(r||={});let i=n.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),a=e=>{switch(typeof e){case`undefined`:return i.undefined;case`string`:return i.string;case`number`:return Number.isNaN(e)?i.nan:i.number;case`boolean`:return i.boolean;case`function`:return i.function;case`bigint`:return i.bigint;case`symbol`:return i.symbol;case`object`:return Array.isArray(e)?i.array:e===null?i.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?i.promise:typeof Map<`u`&&e instanceof Map?i.map:typeof Set<`u`&&e instanceof Set?i.set:typeof Date<`u`&&e instanceof Date?i.date:i.object;default:return i.unknown}},o=n.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var s=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,n.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};s.create=e=>new s(e);let c=(e,t)=>{let r;switch(e.code){case o.invalid_type:r=e.received===i.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,n.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:r=`Unrecognized key(s) in object: ${n.joinValues(e.keys,`, `)}`;break;case o.invalid_union:r=`Invalid input`;break;case o.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${n.joinValues(e.options)}`;break;case o.invalid_enum_value:r=`Invalid enum value. Expected ${n.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:r=`Invalid function arguments`;break;case o.invalid_return_type:r=`Invalid function return type`;break;case o.invalid_date:r=`Invalid date`;break;case o.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:n.assertNever(e.validation):r=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case o.too_small:r=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case o.too_big:r=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case o.custom:r=`Invalid input`;break;case o.invalid_intersection_types:r=`Intersection results could not be merged`;break;case o.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:r=`Number must be finite`;break;default:r=t.defaultError,n.assertNever(e)}return{message:r}},l=c;function u(){return l}let d=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function f(e,t){let n=u(),r=d({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===c?void 0:c].filter(e=>!!e)});e.common.issues.push(r)}var p=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return m;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return m;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let m=Object.freeze({status:`aborted`}),ee=e=>({status:`dirty`,value:e}),h=e=>({status:`valid`,value:e}),te=e=>e.status===`aborted`,ne=e=>e.status===`dirty`,re=e=>e.status===`valid`,ie=e=>typeof Promise<`u`&&e instanceof Promise;var g;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(g||={});var ae=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};let oe=(e,t)=>{if(re(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new s(e.common.issues);return this._error=t,this._error}}};function _(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var v=class{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new p,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ie(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};return oe(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return re(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>re(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},r=this._parse({data:e,path:n.path,parent:n});return oe(n,await(ie(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:o.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new st({schema:this,typeName:b.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return ct.create(this,this._def)}nullable(){return lt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return He.create(this)}promise(){return ot.create(this,this._def)}or(e){return Ge.create([this,e],this._def)}and(e){return Ye.create(this,e,this._def)}transform(e){return new st({..._(this._def),schema:this,typeName:b.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new ut({..._(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new pt({typeName:b.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new dt({..._(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return mt.create(this,e)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let se=/^c[^\s-]{8,}$/i,ce=/^[0-9a-z]+$/,le=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ue=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,de=/^[a-z0-9_-]{21}$/i,fe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,pe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,me=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,he,ge=/^(?:(?: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])$/,_e=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ve=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ye=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,be=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Se=`((\\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])))`,Ce=RegExp(`^${Se}$`);function we(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Te(e){return RegExp(`^${we(e)}$`)}function Ee(e){let t=`${Se}T${we(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function De(e,t){return!!((t===`v4`||!t)&&ge.test(e)||(t===`v6`||!t)&&ve.test(e))}function Oe(e,t){if(!fe.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function ke(e,t){return!!((t===`v4`||!t)&&_e.test(e)||(t===`v6`||!t)&&ye.test(e))}var Ae=class e extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==i.string){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.string,received:t.parsedType}),m}let t=new p,r;for(let i of this._def.checks)if(i.kind===`min`)e.data.length<i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:o.too_small,minimum:i.value,type:`string`,inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind===`max`)e.data.length>i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:o.too_big,maximum:i.value,type:`string`,inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind===`length`){let n=e.data.length>i.value,a=e.data.length<i.value;(n||a)&&(r=this._getOrReturnCtx(e,r),n?f(r,{code:o.too_big,maximum:i.value,type:`string`,inclusive:!0,exact:!0,message:i.message}):a&&f(r,{code:o.too_small,minimum:i.value,type:`string`,inclusive:!0,exact:!0,message:i.message}),t.dirty())}else if(i.kind===`email`)me.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`email`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`emoji`)he||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),he.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`emoji`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`uuid`)ue.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`uuid`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`nanoid`)de.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`nanoid`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`cuid`)se.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`cuid`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`cuid2`)ce.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`cuid2`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`ulid`)le.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`ulid`,code:o.invalid_string,message:i.message}),t.dirty());else if(i.kind===`url`)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:`url`,code:o.invalid_string,message:i.message}),t.dirty()}else i.kind===`regex`?(i.regex.lastIndex=0,i.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`regex`,code:o.invalid_string,message:i.message}),t.dirty())):i.kind===`trim`?e.data=e.data.trim():i.kind===`includes`?e.data.includes(i.value,i.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),t.dirty()):i.kind===`toLowerCase`?e.data=e.data.toLowerCase():i.kind===`toUpperCase`?e.data=e.data.toUpperCase():i.kind===`startsWith`?e.data.startsWith(i.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:{startsWith:i.value},message:i.message}),t.dirty()):i.kind===`endsWith`?e.data.endsWith(i.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:{endsWith:i.value},message:i.message}),t.dirty()):i.kind===`datetime`?Ee(i).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:`datetime`,message:i.message}),t.dirty()):i.kind===`date`?Ce.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:`date`,message:i.message}),t.dirty()):i.kind===`time`?Te(i).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:o.invalid_string,validation:`time`,message:i.message}),t.dirty()):i.kind===`duration`?pe.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`duration`,code:o.invalid_string,message:i.message}),t.dirty()):i.kind===`ip`?De(e.data,i.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`ip`,code:o.invalid_string,message:i.message}),t.dirty()):i.kind===`jwt`?Oe(e.data,i.alg)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`jwt`,code:o.invalid_string,message:i.message}),t.dirty()):i.kind===`cidr`?ke(e.data,i.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`cidr`,code:o.invalid_string,message:i.message}),t.dirty()):i.kind===`base64`?be.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`base64`,code:o.invalid_string,message:i.message}),t.dirty()):i.kind===`base64url`?xe.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:`base64url`,code:o.invalid_string,message:i.message}),t.dirty()):n.assertNever(i);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:o.invalid_string,...g.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...g.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...g.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...g.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...g.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...g.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...g.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...g.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...g.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...g.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...g.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...g.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ae.create=e=>new Ae({checks:[],typeName:b.ZodString,coerce:e?.coerce??!1,..._(e)});function je(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Me=class e extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==i.number){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.number,received:t.parsedType}),m}let t,r=new p;for(let i of this._def.checks)i.kind===`int`?n.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:o.invalid_type,expected:`integer`,received:`float`,message:i.message}),r.dirty()):i.kind===`min`?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.too_small,minimum:i.value,type:`number`,inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind===`max`?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.too_big,maximum:i.value,type:`number`,inclusive:i.inclusive,exact:!1,message:i.message}),r.dirty()):i.kind===`multipleOf`?je(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):i.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:o.not_finite,message:i.message}),r.dirty()):n.assertNever(i);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:g.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:g.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:g.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&n.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Me.create=e=>new Me({checks:[],typeName:b.ZodNumber,coerce:e?.coerce||!1,..._(e)});var Ne=class e extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==i.bigint)return this._getInvalidInput(e);let t,r=new p;for(let i of this._def.checks)i.kind===`min`?(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.too_small,type:`bigint`,minimum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind===`max`?(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.too_big,type:`bigint`,maximum:i.value,inclusive:i.inclusive,message:i.message}),r.dirty()):i.kind===`multipleOf`?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),f(t,{code:o.not_multiple_of,multipleOf:i.value,message:i.message}),r.dirty()):n.assertNever(i);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ne.create=e=>new Ne({checks:[],typeName:b.ZodBigInt,coerce:e?.coerce??!1,..._(e)});var Pe=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==i.boolean){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.boolean,received:t.parsedType}),m}return h(e.data)}};Pe.create=e=>new Pe({typeName:b.ZodBoolean,coerce:e?.coerce||!1,..._(e)});var Fe=class e extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==i.date){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.date,received:t.parsedType}),m}if(Number.isNaN(e.data.getTime()))return f(this._getOrReturnCtx(e),{code:o.invalid_date}),m;let t=new p,r;for(let i of this._def.checks)i.kind===`min`?e.data.getTime()<i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:o.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:`date`}),t.dirty()):i.kind===`max`?e.data.getTime()>i.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:o.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:`date`}),t.dirty()):n.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Fe.create=e=>new Fe({checks:[],coerce:e?.coerce||!1,typeName:b.ZodDate,..._(e)});var Ie=class extends v{_parse(e){if(this._getType(e)!==i.symbol){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.symbol,received:t.parsedType}),m}return h(e.data)}};Ie.create=e=>new Ie({typeName:b.ZodSymbol,..._(e)});var y=class extends v{_parse(e){if(this._getType(e)!==i.undefined){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.undefined,received:t.parsedType}),m}return h(e.data)}};y.create=e=>new y({typeName:b.ZodUndefined,..._(e)});var Le=class extends v{_parse(e){if(this._getType(e)!==i.null){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.null,received:t.parsedType}),m}return h(e.data)}};Le.create=e=>new Le({typeName:b.ZodNull,..._(e)});var Re=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return h(e.data)}};Re.create=e=>new Re({typeName:b.ZodAny,..._(e)});var ze=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return h(e.data)}};ze.create=e=>new ze({typeName:b.ZodUnknown,..._(e)});var Be=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.never,received:t.parsedType}),m}};Be.create=e=>new Be({typeName:b.ZodNever,..._(e)});var Ve=class extends v{_parse(e){if(this._getType(e)!==i.undefined){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.void,received:t.parsedType}),m}return h(e.data)}};Ve.create=e=>new Ve({typeName:b.ZodVoid,..._(e)});var He=class e extends v{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==i.array)return f(t,{code:o.invalid_type,expected:i.array,received:t.parsedType}),m;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(f(t,{code:e?o.too_big:o.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(f(t,{code:o.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(f(t,{code:o.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ae(t,e,t.path,n)))).then(e=>p.mergeArray(n,e));let a=[...t.data].map((e,n)=>r.type._parseSync(new ae(t,e,t.path,n)));return p.mergeArray(n,a)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(e){return this.min(1,e)}};He.create=(e,t)=>new He({type:e,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,..._(t)});function Ue(e){if(e instanceof We){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=ct.create(Ue(r))}return new We({...e._def,shape:()=>t})}else if(e instanceof He)return new He({...e._def,type:Ue(e.element)});else if(e instanceof ct)return ct.create(Ue(e.unwrap()));else if(e instanceof lt)return lt.create(Ue(e.unwrap()));else if(e instanceof Xe)return Xe.create(e.items.map(e=>Ue(e)));else return e}var We=class e extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=n.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==i.object){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.object,received:t.parsedType}),m}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Be&&this._def.unknownKeys===`strip`))for(let e in n.data)a.includes(e)||s.push(e);let c=[];for(let e of a){let t=r[e],i=n.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new ae(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Be){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)s.length>0&&(f(n,{code:o.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let r=n.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new ae(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>p.mergeObjectSync(t,e)):p.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(t){return g.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:g.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let e of n.objectKeys(t))t[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let e of n.objectKeys(this.shape))t[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ue(this)}partial(t){let r={};for(let e of n.objectKeys(this.shape)){let n=this.shape[e];t&&!t[e]?r[e]=n:r[e]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let e of n.objectKeys(this.shape))if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof ct;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return rt(n.objectKeys(this.shape))}};We.create=(e,t)=>new We({shape:()=>e,unknownKeys:`strip`,catchall:Be.create(),typeName:b.ZodObject,..._(t)}),We.strictCreate=(e,t)=>new We({shape:()=>e,unknownKeys:`strict`,catchall:Be.create(),typeName:b.ZodObject,..._(t)}),We.lazycreate=(e,t)=>new We({shape:e,unknownKeys:`strip`,catchall:Be.create(),typeName:b.ZodObject,..._(t)});var Ge=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new s(e.ctx.common.issues));return f(t,{code:o.invalid_union,unionErrors:n}),m}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new s(e));return f(t,{code:o.invalid_union,unionErrors:i}),m}}get options(){return this._def.options}};Ge.create=(e,t)=>new Ge({options:e,typeName:b.ZodUnion,..._(t)});let Ke=e=>e instanceof tt?Ke(e.schema):e instanceof st?Ke(e.innerType()):e instanceof nt?[e.value]:e instanceof it?e.options:e instanceof at?n.objectValues(e.enum):e instanceof ut?Ke(e._def.innerType):e instanceof y?[void 0]:e instanceof Le?[null]:e instanceof ct?[void 0,...Ke(e.unwrap())]:e instanceof lt?[null,...Ke(e.unwrap())]:e instanceof pt||e instanceof ht?Ke(e.unwrap()):e instanceof dt?Ke(e._def.innerType):[];var qe=class e extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.object)return f(t,{code:o.invalid_type,expected:i.object,received:t.parsedType}),m;let n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ke(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,..._(r)})}};function Je(e,t){let r=a(e),o=a(t);if(e===t)return{valid:!0,data:e};if(r===i.object&&o===i.object){let r=n.objectKeys(t),i=n.objectKeys(e).filter(e=>r.indexOf(e)!==-1),a={...e,...t};for(let n of i){let r=Je(e[n],t[n]);if(!r.valid)return{valid:!1};a[n]=r.data}return{valid:!0,data:a}}else if(r===i.array&&o===i.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Je(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(r===i.date&&o===i.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Ye=class extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(te(e)||te(r))return m;let i=Je(e.value,r.value);return i.valid?((ne(e)||ne(r))&&t.dirty(),{status:t.value,value:i.data}):(f(n,{code:o.invalid_intersection_types}),m)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ye.create=(e,t,n)=>new Ye({left:e,right:t,typeName:b.ZodIntersection,..._(n)});var Xe=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.array)return f(n,{code:o.invalid_type,expected:i.array,received:n.parsedType}),m;if(n.data.length<this._def.items.length)return f(n,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),m;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ae(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>p.mergeArray(t,e)):p.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Xe.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Xe({items:e,typeName:b.ZodTuple,rest:null,..._(t)})};var Ze=class e extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.object)return f(n,{code:o.invalid_type,expected:i.object,received:n.parsedType}),m;let r=[],a=this._def.keyType,s=this._def.valueType;for(let e in n.data)r.push({key:a._parse(new ae(n,e,n.path,e)),value:s._parse(new ae(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?p.mergeObjectAsync(t,r):p.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof v?new e({keyType:t,valueType:n,typeName:b.ZodRecord,..._(r)}):new e({keyType:Ae.create(),valueType:t,typeName:b.ZodRecord,..._(n)})}},Qe=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.map)return f(n,{code:o.invalid_type,expected:i.map,received:n.parsedType}),m;let r=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([e,t],i)=>({key:r._parse(new ae(n,e,n.path,[i,`key`])),value:a._parse(new ae(n,t,n.path,[i,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return m;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return m;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Qe.create=(e,t,n)=>new Qe({valueType:t,keyType:e,typeName:b.ZodMap,..._(n)});var $e=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==i.set)return f(n,{code:o.invalid_type,expected:i.set,received:n.parsedType}),m;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(f(n,{code:o.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(f(n,{code:o.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let a=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return m;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...n.data.values()].map((e,t)=>a._parse(new ae(n,e,n.path,t)));return n.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:g.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};$e.create=(e,t)=>new $e({valueType:e,minSize:null,maxSize:null,typeName:b.ZodSet,..._(t)});var et=class e extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==i.function)return f(t,{code:o.invalid_type,expected:i.function,received:t.parsedType}),m;function n(e,n){return d({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,u(),c].filter(e=>!!e),issueData:{code:o.invalid_arguments,argumentsError:n}})}function r(e,n){return d({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,u(),c].filter(e=>!!e),issueData:{code:o.invalid_return_type,returnTypeError:n}})}let a={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof ot){let e=this;return h(async function(...t){let i=new s([]),o=await e._def.args.parseAsync(t,a).catch(e=>{throw i.addIssue(n(t,e)),i}),c=await Reflect.apply(l,this,o);return await e._def.returns._def.type.parseAsync(c,a).catch(e=>{throw i.addIssue(r(c,e)),i})})}else{let e=this;return h(function(...t){let i=e._def.args.safeParse(t,a);if(!i.success)throw new s([n(t,i.error)]);let o=Reflect.apply(l,this,i.data),c=e._def.returns.safeParse(o,a);if(!c.success)throw new s([r(o,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Xe.create(t).rest(ze.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Xe.create([]).rest(ze.create()),returns:n||ze.create(),typeName:b.ZodFunction,..._(r)})}},tt=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};tt.create=(e,t)=>new tt({getter:e,typeName:b.ZodLazy,..._(t)});var nt=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),m}return{status:`valid`,value:e.data}}get value(){return this._def.value}};nt.create=(e,t)=>new nt({value:e,typeName:b.ZodLiteral,..._(t)});function rt(e,t){return new it({values:e,typeName:b.ZodEnum,..._(t)})}var it=class e extends v{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:n.joinValues(r),received:t.parsedType,code:o.invalid_type}),m}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:o.invalid_enum_value,options:n}),m}return h(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};it.create=rt;var at=class extends v{_parse(e){let t=n.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==i.string&&r.parsedType!==i.number){let e=n.objectValues(t);return f(r,{expected:n.joinValues(e),received:r.parsedType,code:o.invalid_type}),m}if(this._cache||=new Set(n.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=n.objectValues(t);return f(r,{received:r.data,code:o.invalid_enum_value,options:e}),m}return h(e.data)}get enum(){return this._def.values}};at.create=(e,t)=>new at({values:e,typeName:b.ZodNativeEnum,..._(t)});var ot=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==i.promise&&t.common.async===!1?(f(t,{code:o.invalid_type,expected:i.promise,received:t.parsedType}),m):h((t.parsedType===i.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ot.create=(e,t)=>new ot({type:e,typeName:b.ZodPromise,..._(t)});var st=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{f(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return m;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return n.status===`aborted`?m:n.status===`dirty`||t.value===`dirty`?ee(n.value):n});{if(t.value===`aborted`)return m;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return n.status===`aborted`?m:n.status===`dirty`||t.value===`dirty`?ee(n.value):n}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return n.status===`aborted`?m:(n.status===`dirty`&&t.dirty(),e(n.value),{status:t.value,value:n.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(n=>n.status===`aborted`?m:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!re(e))return m;let n=i.transform(e.value,a);if(n instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:n}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>re(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:t.value,value:e})):m);n.assertNever(i)}};st.create=(e,t,n)=>new st({schema:e,typeName:b.ZodEffects,effect:t,..._(n)}),st.createWithPreprocess=(e,t,n)=>new st({schema:t,effect:{type:`preprocess`,transform:e},typeName:b.ZodEffects,..._(n)});var ct=class extends v{_parse(e){return this._getType(e)===i.undefined?h(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ct.create=(e,t)=>new ct({innerType:e,typeName:b.ZodOptional,..._(t)});var lt=class extends v{_parse(e){return this._getType(e)===i.null?h(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};lt.create=(e,t)=>new lt({innerType:e,typeName:b.ZodNullable,..._(t)});var ut=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===i.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ut.create=(e,t)=>new ut({innerType:e,typeName:b.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,..._(t)});var dt=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ie(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new s(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new s(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};dt.create=(e,t)=>new dt({innerType:e,typeName:b.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,..._(t)});var ft=class extends v{_parse(e){if(this._getType(e)!==i.nan){let t=this._getOrReturnCtx(e);return f(t,{code:o.invalid_type,expected:i.nan,received:t.parsedType}),m}return{status:`valid`,value:e.data}}};ft.create=e=>new ft({typeName:b.ZodNaN,..._(e)});var pt=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},mt=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?m:e.status===`dirty`?(t.dirty(),ee(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?m:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:b.ZodPipeline})}},ht=class extends v{_parse(e){let t=this._def.innerType._parse(e),n=e=>(re(e)&&(e.value=Object.freeze(e.value)),e);return ie(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};ht.create=(e,t)=>new ht({innerType:e,typeName:b.ZodReadonly,..._(t)}),We.lazycreate;var b;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(b||={}),Ae.create,Me.create,ft.create,Ne.create,Pe.create,Fe.create,Ie.create,y.create,Le.create,Re.create,ze.create,Be.create,Ve.create,He.create;let gt=We.create;We.strictCreate,Ge.create,qe.create,Ye.create,Xe.create,Ze.create,Qe.create,$e.create,et.create,tt.create,nt.create,it.create,at.create,ot.create,st.create,ct.create,lt.create,st.createWithPreprocess,mt.create;var _t;function x(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var vt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},yt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(_t=globalThis).__zod_globalConfig??(_t.__zod_globalConfig={});let bt=globalThis.__zod_globalConfig;function xt(e){return e&&Object.assign(bt,e),bt}function St(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Ct(e,t){return typeof t==`bigint`?t.toString():t}function wt(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Tt(e){return e==null}function Et(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Dt(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}let Ot=Symbol(`evaluating`);function S(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ot)return r===void 0&&(r=Ot,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function kt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function At(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function jt(e){return JSON.stringify(e)}function Mt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let Nt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Pt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Ft=wt(()=>{if(bt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function It(e){if(Pt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Pt(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Lt(e){return It(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let Rt=new Set([`string`,`number`,`symbol`]);function zt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Bt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Vt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Ht={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ut(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Bt(e,At(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return kt(this,`shape`,e),e},checks:[]}))}function Wt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Bt(e,At(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return kt(this,`shape`,r),r},checks:[]}))}function Gt(e,t){if(!It(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Bt(e,At(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return kt(this,`shape`,n),n}}))}function Kt(e,t){if(!It(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Bt(e,At(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return kt(this,`shape`,n),n}}))}function qt(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Bt(e,At(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return kt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Jt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Bt(t,At(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return kt(this,`shape`,i),i},checks:[]}))}function Yt(e,t,n){return Bt(t,At(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return kt(this,`shape`,i),i}}))}function Xt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zt(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 Qt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $t(e){return typeof e==`string`?e:e?.message}function en(e,t,n){let r=e.message?e.message:$t(e.inst?._zod.def?.error?.(e))??$t(t?.error?.(e))??$t(n.customError?.(e))??$t(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function tn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let rn=(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,Ct,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},an=x(`$ZodError`,rn),on=x(`$ZodError`,rn,{Parent:Error});function sn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function cn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}let ln=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new vt;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>en(e,a,xt())));throw Nt(t,i?.callee),t}return o.value},un=ln(on),dn=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>en(e,a,xt())));throw Nt(t,i?.callee),t}return o.value},fn=dn(on),pn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new vt;return a.issues.length?{success:!1,error:new(e??an)(a.issues.map(e=>en(e,i,xt())))}:{success:!0,data:a.value}},mn=pn(on),hn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>en(e,i,xt())))}:{success:!0,data:a.value}},gn=hn(on),_n=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ln(e)(t,n,i)},vn=e=>(t,n,r)=>ln(e)(t,n,r),yn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return dn(e)(t,n,i)},bn=e=>async(t,n,r)=>dn(e)(t,n,r),xn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return pn(e)(t,n,i)},Sn=e=>(t,n,r)=>pn(e)(t,n,r),Cn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return hn(e)(t,n,i)},wn=e=>async(t,n,r)=>hn(e)(t,n,r),Tn=/^[cC][0-9a-z]{6,}$/,En=/^[0-9a-z]+$/,Dn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,On=/^[0-9a-vA-V]{20}$/,kn=/^[A-Za-z0-9]{27}$/,An=/^[a-zA-Z0-9_-]{21}$/,jn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Mn=/^([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})$/,Nn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Pn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Fn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let In=/^(?:(?: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])$/,Ln=/^(([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}|:))$/,Rn=/^((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])$/,zn=/^(([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])$/,Bn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vn=/^[A-Za-z0-9_-]*$/,Hn=/^https?$/,Un=/^\+[1-9]\d{6,14}$/,Wn=`(?:(?:\\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])))`,Gn=RegExp(`^${Wn}$`);function Kn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function qn(e){return RegExp(`^${Kn(e)}$`)}function Jn(e){let t=Kn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Wn}T(?:${r})$`)}let Yn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Xn=/^-?\d+$/,Zn=/^-?\d+(?:\.\d+)?$/,Qn=/^(?:true|false)$/i,$n=/^null$/i,er=/^[^A-Z]*$/,tr=/^[^a-z]*$/,w=x(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nr={number:`number`,bigint:`bigint`,object:`date`},rr=x(`$ZodCheckLessThan`,(e,t)=>{w.init(e,t);let n=nr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.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})}}),ir=x(`$ZodCheckGreaterThan`,(e,t)=>{w.init(e,t);let n=nr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.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})}}),ar=x(`$ZodCheckMultipleOf`,(e,t)=>{w.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Dt(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})}}),or=x(`$ZodCheckNumberFormat`,(e,t)=>{w.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ht[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Xn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),sr=x(`$ZodCheckMaxLength`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Tt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=tn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),cr=x(`$ZodCheckMinLength`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Tt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=tn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=x(`$ZodCheckLengthEquals`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Tt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=tn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ur=x(`$ZodCheckStringFormat`,(e,t)=>{var n,r;w.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dr=x(`$ZodCheckRegex`,(e,t)=>{ur.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})}}),fr=x(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=er,ur.init(e,t)}),pr=x(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=tr,ur.init(e,t)}),mr=x(`$ZodCheckIncludes`,(e,t)=>{w.init(e,t);let n=zt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),hr=x(`$ZodCheckStartsWith`,(e,t)=>{w.init(e,t);let n=RegExp(`^${zt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),gr=x(`$ZodCheckEndsWith`,(e,t)=>{w.init(e,t);let n=RegExp(`.*${zt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),_r=x(`$ZodCheckOverwrite`,(e,t)=>{w.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var vr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
+ `))}};let yr={major:4,minor:4,patch:3},T=x(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Xt(e),i;for(let a of t){if(a._zod.def.when){if(Zt(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new vt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Xt(e,t))});else{if(e.issues.length===t)continue;r||=Xt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Xt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new vt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new vt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}S(e,`~standard`,()=>({validate:t=>{try{let n=mn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return gn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),br=x(`$ZodString`,(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Yn(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}}),E=x(`$ZodStringFormat`,(e,t)=>{ur.init(e,t),br.init(e,t)}),xr=x(`$ZodGUID`,(e,t)=>{t.pattern??=Mn,E.init(e,t)}),Sr=x(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Nn(e)}else t.pattern??=Nn();E.init(e,t)}),Cr=x(`$ZodEmail`,(e,t)=>{t.pattern??=Pn,E.init(e,t)}),wr=x(`$ZodURL`,(e,t)=>{E.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===Hn.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}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.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=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Tr=x(`$ZodEmoji`,(e,t)=>{t.pattern??=Fn(),E.init(e,t)}),Er=x(`$ZodNanoID`,(e,t)=>{t.pattern??=An,E.init(e,t)}),Dr=x(`$ZodCUID`,(e,t)=>{t.pattern??=Tn,E.init(e,t)}),Or=x(`$ZodCUID2`,(e,t)=>{t.pattern??=En,E.init(e,t)}),kr=x(`$ZodULID`,(e,t)=>{t.pattern??=Dn,E.init(e,t)}),Ar=x(`$ZodXID`,(e,t)=>{t.pattern??=On,E.init(e,t)}),jr=x(`$ZodKSUID`,(e,t)=>{t.pattern??=kn,E.init(e,t)}),Mr=x(`$ZodISODateTime`,(e,t)=>{t.pattern??=Jn(t),E.init(e,t)}),Nr=x(`$ZodISODate`,(e,t)=>{t.pattern??=Gn,E.init(e,t)}),Pr=x(`$ZodISOTime`,(e,t)=>{t.pattern??=qn(t),E.init(e,t)}),Fr=x(`$ZodISODuration`,(e,t)=>{t.pattern??=jn,E.init(e,t)}),Ir=x(`$ZodIPv4`,(e,t)=>{t.pattern??=In,E.init(e,t),e._zod.bag.format=`ipv4`}),Lr=x(`$ZodIPv6`,(e,t)=>{t.pattern??=Ln,E.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})}}}),Rr=x(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Rn,E.init(e,t)}),zr=x(`$ZodCIDRv6`,(e,t)=>{t.pattern??=zn,E.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Br(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Vr=x(`$ZodBase64`,(e,t)=>{t.pattern??=Bn,E.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Br(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Hr(e){if(!Vn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Br(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let Ur=x(`$ZodBase64URL`,(e,t)=>{t.pattern??=Vn,E.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Hr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Wr=x(`$ZodE164`,(e,t)=>{t.pattern??=Un,E.init(e,t)});function Gr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Kr=x(`$ZodJWT`,(e,t)=>{E.init(e,t),e._zod.check=n=>{Gr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),qr=x(`$ZodNumber`,(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Jr=x(`$ZodNumberFormat`,(e,t)=>{or.init(e,t),qr.init(e,t)}),Yr=x(`$ZodBoolean`,(e,t)=>{T.init(e,t),e._zod.pattern=Qn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Xr=x(`$ZodNull`,(e,t)=>{T.init(e,t),e._zod.pattern=$n,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Zr=x(`$ZodUnknown`,(e,t)=>{T.init(e,t),e._zod.parse=e=>e}),Qr=x(`$ZodNever`,(e,t)=>{T.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function $r(e,t,n){e.issues.length&&t.issues.push(...Qt(n,e.issues)),t.value[n]=e.value}let ei=x(`$ZodArray`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>$r(t,n,e))):$r(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function ti(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Qt(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function ni(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Vt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ri(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ti(e,n,i,t,u,d))):ti(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let ii=x(`$ZodObject`,(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=wt(()=>ni(t));S(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Pt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ti(n,t,e,s,r,i))):ti(a,t,e,s,r,i)}return i?ri(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ai=x(`$ZodObjectJIT`,(e,t)=>{ii.init(e,t);let n=e._zod.parse,r=wt(()=>ni(t)),i=e=>{let t=new vr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=jt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=jt(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
+ if (${n}.issues.length) {
5
+ if (${o} in input) {
6
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${n}.value === undefined) {
14
+ if (${o} in input) {
15
+ newResult[${o}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${o}] = ${n}.value;
19
+ }
20
+
21
+ `):c?t.write(`
22
+ if (${n}.issues.length) {
23
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
26
+ })));
27
+ }
28
+
29
+ if (${n}.value === undefined) {
30
+ if (${o} in input) {
31
+ newResult[${o}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${o}] = ${n}.value;
35
+ }
36
+
37
+ `):t.write(`
38
+ const ${n}_present = ${o} in input;
39
+ if (${n}.issues.length) {
40
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
41
+ ...iss,
42
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
43
+ })));
44
+ }
45
+ if (!${n}_present && !${n}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${o}]
51
+ });
52
+ }
53
+
54
+ if (${n}_present) {
55
+ if (${n}.value === undefined) {
56
+ newResult[${o}] = undefined;
57
+ } else {
58
+ newResult[${o}] = ${n}.value;
59
+ }
60
+ }
61
+
62
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Pt,s=!bt.jitless,c=s&&Ft.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ri([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function oi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Xt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>en(e,r,xt())))}),t)}let si=x(`$ZodUnion`,(e,t)=>{T.init(e,t),S(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),S(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),S(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),S(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Et(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>oi(t,r,e,i)):oi(o,r,e,i)}}),ci=x(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,si.init(e,t);let n=e._zod.parse;S(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=wt(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Pt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),li=x(`$ZodIntersection`,(e,t)=>{T.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>di(e,t,n)):di(e,i,a)}});function ui(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(It(e)&&It(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=ui(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=ui(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function di(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Xt(e))return e;let o=ui(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let fi=x(`$ZodRecord`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!It(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>en(e,r,xt())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Qt(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Qt(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Zn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>en(e,r,xt())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Qt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Qt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),pi=x(`$ZodEnum`,(e,t)=>{T.init(e,t);let n=St(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Rt.has(typeof e)).map(e=>typeof e==`string`?zt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),mi=x(`$ZodLiteral`,(e,t)=>{if(T.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?zt(e):e?zt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),hi=x(`$ZodTransform`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new yt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new vt;return n.value=i,n.fallback=!0,n}});function gi(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let _i=x(`$ZodOptional`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Et(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>gi(e,r)):gi(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),vi=x(`$ZodExactOptional`,(e,t)=>{_i.init(e,t),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),yi=x(`$ZodNullable`,(e,t)=>{T.init(e,t),S(e._zod,`optin`,()=>t.innerType._zod.optin),S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Et(e.source)}|null)$`):void 0}),S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),bi=x(`$ZodDefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>xi(e,t)):xi(r,t)}});function xi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Si=x(`$ZodPrefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ci=x(`$ZodNonOptional`,(e,t)=>{T.init(e,t),S(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>wi(t,e)):wi(i,e)}});function wi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Ti=x(`$ZodCatch`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>en(e,n,xt()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>en(e,n,xt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Ei=x(`$ZodPipe`,(e,t)=>{T.init(e,t),S(e._zod,`values`,()=>t.in._zod.values),S(e._zod,`optin`,()=>t.in._zod.optin),S(e._zod,`optout`,()=>t.out._zod.optout),S(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Di(e,t.in,n)):Di(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Di(e,t.out,n)):Di(r,t.out,n)}});function Di(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}let Oi=x(`$ZodPreprocess`,(e,t)=>{Ei.init(e,t)}),ki=x(`$ZodReadonly`,(e,t)=>{T.init(e,t),S(e._zod,`propValues`,()=>t.innerType._zod.propValues),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`optin`,()=>t.innerType?._zod?.optin),S(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ai):Ai(r)}});function Ai(e){return e.value=Object.freeze(e.value),e}let ji=x(`$ZodCustom`,(e,t)=>{w.init(e,t),T.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Mi(t,n,r,e));Mi(i,n,r,e)}});function Mi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(nn(e))}}var Ni,Pi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Fi(){return new Pi}(Ni=globalThis).__zod_globalRegistry??(Ni.__zod_globalRegistry=Fi());let Ii=globalThis.__zod_globalRegistry;function Li(e,t){return new e({type:`string`,...C(t)})}function Ri(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...C(t)})}function zi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...C(t)})}function Bi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...C(t)})}function Vi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...C(t)})}function Hi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...C(t)})}function Ui(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...C(t)})}function Wi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...C(t)})}function Gi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...C(t)})}function Ki(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...C(t)})}function qi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...C(t)})}function Ji(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...C(t)})}function Yi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...C(t)})}function Xi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...C(t)})}function Zi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...C(t)})}function Qi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...C(t)})}function $i(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...C(t)})}function ea(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...C(t)})}function ta(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...C(t)})}function na(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...C(t)})}function ra(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...C(t)})}function ia(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...C(t)})}function aa(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...C(t)})}function oa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...C(t)})}function sa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...C(t)})}function ca(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...C(t)})}function la(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...C(t)})}function ua(e,t){return new e({type:`number`,checks:[],...C(t)})}function da(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...C(t)})}function fa(e,t){return new e({type:`boolean`,...C(t)})}function pa(e,t){return new e({type:`null`,...C(t)})}function ma(e){return new e({type:`unknown`})}function ha(e,t){return new e({type:`never`,...C(t)})}function ga(e,t){return new rr({check:`less_than`,...C(t),value:e,inclusive:!1})}function _a(e,t){return new rr({check:`less_than`,...C(t),value:e,inclusive:!0})}function va(e,t){return new ir({check:`greater_than`,...C(t),value:e,inclusive:!1})}function ya(e,t){return new ir({check:`greater_than`,...C(t),value:e,inclusive:!0})}function ba(e,t){return new ar({check:`multiple_of`,...C(t),value:e})}function xa(e,t){return new sr({check:`max_length`,...C(t),maximum:e})}function Sa(e,t){return new cr({check:`min_length`,...C(t),minimum:e})}function Ca(e,t){return new lr({check:`length_equals`,...C(t),length:e})}function wa(e,t){return new dr({check:`string_format`,format:`regex`,...C(t),pattern:e})}function Ta(e){return new fr({check:`string_format`,format:`lowercase`,...C(e)})}function Ea(e){return new pr({check:`string_format`,format:`uppercase`,...C(e)})}function Da(e,t){return new mr({check:`string_format`,format:`includes`,...C(t),includes:e})}function Oa(e,t){return new hr({check:`string_format`,format:`starts_with`,...C(t),prefix:e})}function ka(e,t){return new gr({check:`string_format`,format:`ends_with`,...C(t),suffix:e})}function Aa(e){return new _r({check:`overwrite`,tx:e})}function ja(e){return Aa(t=>t.normalize(e))}function Ma(){return Aa(e=>e.trim())}function Na(){return Aa(e=>e.toLowerCase())}function Pa(){return Aa(e=>e.toUpperCase())}function Fa(){return Aa(e=>Mt(e))}function Ia(e,t,n){return new e({type:`array`,element:t,...C(n)})}function La(e,t,n){let r=C(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Ra(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...C(n)})}function za(e,t){let n=Ba(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(nn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(nn(r))}},e(t.value,t)),t);return n}function Ba(e,t){let n=new w({check:`custom`,...C(t)});return n._zod.check=e,n}function Va(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??Ii,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 D(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,D(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&O(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ha(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ua(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Ga(t,`input`,e.processors),output:Ga(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function O(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return O(r.element,n);if(r.type===`set`)return O(r.valueType,n);if(r.type===`lazy`)return O(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 O(r.innerType,n);if(r.type===`intersection`)return O(r.left,n)||O(r.right,n);if(r.type===`record`||r.type===`map`)return O(r.keyType,n)||O(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:O(r.in,n)||O(r.out,n);if(r.type===`object`){for(let e in r.shape)if(O(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(O(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(O(e,n))return!0;return!!(r.rest&&O(r.rest,n))}return!1}let Wa=(e,t={})=>n=>{let r=Va({...n,processors:t});return D(e,r),Ha(r,e),Ua(r,e)},Ga=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Va({...i??{},target:a,io:t,processors:n});return D(e,o),Ha(o,e),Ua(o,e)},Ka={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},qa=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Ka[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ja=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Ya=(e,t,n,r)=>{n.type=`boolean`},Xa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Za=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},Qa=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},$a=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},eo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},to=(e,t,n,r)=>{n.not={}},no=(e,t,n,r)=>{},ro=(e,t,n,r)=>{},io=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},ao=(e,t,n,r)=>{let i=e._zod.def,a=St(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},oo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},so=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},co=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},lo=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},uo=(e,t,n,r)=>{n.type=`boolean`},fo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},go=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},_o=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=D(a.element,t,{...r,path:[...r.path,`items`]})},vo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=D(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=D(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},yo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>D(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},bo=(e,t,n,r)=>{let i=e._zod.def,a=D(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=D(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},xo=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>D(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?D(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},So=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=D(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=D(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=D(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Co=(e,t,n,r)=>{let i=e._zod.def,a=D(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},wo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},To=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Eo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Do=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Oo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;D(o,t,r);let s=t.seen.get(e);s.ref=o},ko=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ao=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Mo={string:qa,number:Ja,boolean:Ya,bigint:Xa,symbol:Za,null:Qa,undefined:$a,void:eo,never:to,any:no,unknown:ro,date:io,enum:ao,literal:oo,nan:so,template_literal:co,file:lo,success:uo,custom:fo,function:po,transform:mo,map:ho,set:go,array:_o,object:vo,union:yo,intersection:bo,tuple:xo,record:So,nullable:Co,nonoptional:wo,default:To,prefault:Eo,catch:Do,pipe:Oo,readonly:ko,promise:Ao,optional:jo,lazy:(e,t,n,r)=>{let i=e._zod.innerType;D(i,t,r);let a=t.seen.get(e);a.ref=i}};function No(e,t){if(`_idmap`in e){let n=e,r=Va({...t,processors:Mo}),i={};for(let e of n._idmap.entries()){let[t,n]=e;D(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Ha(r,n),a[t]=Ua(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Va({...t,processors:Mo});return D(e,n),Ha(n,e),Ua(n,e)}let Po=x(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);T.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>un(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mn(e,t,n),e.parseAsync=async(t,n)=>fn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>gn(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Bt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Fo=x(`ZodMiniObject`,(e,t)=>{ii.init(e,t),Po.init(e,t),S(e,`shape`,()=>t.shape)});function Io(e,t){return new Fo({type:`object`,shape:e??{},...C(t)})}let Lo=x(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),j.init(e,t)});function Ro(e){return oa(Lo,e)}let zo=x(`ZodISODate`,(e,t)=>{Nr.init(e,t),j.init(e,t)});function Bo(e){return sa(zo,e)}let Vo=x(`ZodISOTime`,(e,t)=>{Pr.init(e,t),j.init(e,t)});function Ho(e){return ca(Vo,e)}let Uo=x(`ZodISODuration`,(e,t)=>{Fr.init(e,t),j.init(e,t)});function Wo(e){return la(Uo,e)}let Go=x(`ZodError`,(e,t)=>{an.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>cn(e,t)},flatten:{value:t=>sn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ct,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ct,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ko=ln(Go),qo=dn(Go),Jo=pn(Go),Yo=hn(Go),Xo=_n(Go),Zo=vn(Go),Qo=yn(Go),$o=bn(Go),es=xn(Go),ts=Sn(Go),ns=Cn(Go),rs=wn(Go),is=new WeakMap;function as(e,t,n){let r=Object.getPrototypeOf(e),i=is.get(r);if(i||(i=new Set,is.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}let k=x(`ZodType`,(e,t)=>(T.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ga(e,`input`),output:Ga(e,`output`)}}),e.toJSONSchema=Wa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.parse=(t,n)=>Ko(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Jo(e,t,n),e.parseAsync=async(t,n)=>qo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Yo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xo(e,t,n),e.decode=(t,n)=>Zo(e,t,n),e.encodeAsync=async(t,n)=>Qo(e,t,n),e.decodeAsync=async(t,n)=>$o(e,t,n),e.safeEncode=(t,n)=>es(e,t,n),e.safeDecode=(t,n)=>ts(e,t,n),e.safeEncodeAsync=async(t,n)=>ns(e,t,n),e.safeDecodeAsync=async(t,n)=>rs(e,t,n),as(e,`ZodType`,{check(...e){let t=this.def;return this.clone(At(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Bt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(hc(e,t))},superRefine(e,t){return this.check(gc(e,t))},overwrite(e){return this.check(Aa(e))},optional(){return V(this)},exactOptional(){return Zs(this)},nullable(){return $s(this)},nullish(){return V($s(this))},nonoptional(e){return ac(this,e)},array(){return F(this)},or(e){return R([this,e])},and(e){return Hs(this,e)},transform(e){return lc(this,Js(e))},default(e){return tc(this,e)},prefault(e){return rc(this,e)},catch(e){return sc(this,e)},pipe(e){return lc(this,e)},readonly(){return fc(this)},describe(e){let t=this.clone();return Ii.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ii.get(this);let t=this.clone();return Ii.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,`description`,{get(){return Ii.get(e)?.description},configurable:!0}),e)),os=x(`_ZodString`,(e,t)=>{br.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,as(e,`_ZodString`,{regex(...e){return this.check(wa(...e))},includes(...e){return this.check(Da(...e))},startsWith(...e){return this.check(Oa(...e))},endsWith(...e){return this.check(ka(...e))},min(...e){return this.check(Sa(...e))},max(...e){return this.check(xa(...e))},length(...e){return this.check(Ca(...e))},nonempty(...e){return this.check(Sa(1,...e))},lowercase(e){return this.check(Ta(e))},uppercase(e){return this.check(Ea(e))},trim(){return this.check(Ma())},normalize(...e){return this.check(ja(...e))},toLowerCase(){return this.check(Na())},toUpperCase(){return this.check(Pa())},slugify(){return this.check(Fa())}})}),ss=x(`ZodString`,(e,t)=>{br.init(e,t),os.init(e,t),e.email=t=>e.check(Ri(cs,t)),e.url=t=>e.check(Wi(ds,t)),e.jwt=t=>e.check(aa(Es,t)),e.emoji=t=>e.check(Gi(fs,t)),e.guid=t=>e.check(zi(ls,t)),e.uuid=t=>e.check(Bi(us,t)),e.uuidv4=t=>e.check(Vi(us,t)),e.uuidv6=t=>e.check(Hi(us,t)),e.uuidv7=t=>e.check(Ui(us,t)),e.nanoid=t=>e.check(Ki(ps,t)),e.guid=t=>e.check(zi(ls,t)),e.cuid=t=>e.check(qi(ms,t)),e.cuid2=t=>e.check(Ji(hs,t)),e.ulid=t=>e.check(Yi(gs,t)),e.base64=t=>e.check(na(Cs,t)),e.base64url=t=>e.check(ra(ws,t)),e.xid=t=>e.check(Xi(_s,t)),e.ksuid=t=>e.check(Zi(vs,t)),e.ipv4=t=>e.check(Qi(ys,t)),e.ipv6=t=>e.check($i(bs,t)),e.cidrv4=t=>e.check(ea(xs,t)),e.cidrv6=t=>e.check(ta(Ss,t)),e.e164=t=>e.check(ia(Ts,t)),e.datetime=t=>e.check(Ro(t)),e.date=t=>e.check(Bo(t)),e.time=t=>e.check(Ho(t)),e.duration=t=>e.check(Wo(t))});function A(e){return Li(ss,e)}let j=x(`ZodStringFormat`,(e,t)=>{E.init(e,t),os.init(e,t)}),cs=x(`ZodEmail`,(e,t)=>{Cr.init(e,t),j.init(e,t)}),ls=x(`ZodGUID`,(e,t)=>{xr.init(e,t),j.init(e,t)}),us=x(`ZodUUID`,(e,t)=>{Sr.init(e,t),j.init(e,t)}),ds=x(`ZodURL`,(e,t)=>{wr.init(e,t),j.init(e,t)}),fs=x(`ZodEmoji`,(e,t)=>{Tr.init(e,t),j.init(e,t)}),ps=x(`ZodNanoID`,(e,t)=>{Er.init(e,t),j.init(e,t)}),ms=x(`ZodCUID`,(e,t)=>{Dr.init(e,t),j.init(e,t)}),hs=x(`ZodCUID2`,(e,t)=>{Or.init(e,t),j.init(e,t)}),gs=x(`ZodULID`,(e,t)=>{kr.init(e,t),j.init(e,t)}),_s=x(`ZodXID`,(e,t)=>{Ar.init(e,t),j.init(e,t)}),vs=x(`ZodKSUID`,(e,t)=>{jr.init(e,t),j.init(e,t)}),ys=x(`ZodIPv4`,(e,t)=>{Ir.init(e,t),j.init(e,t)}),bs=x(`ZodIPv6`,(e,t)=>{Lr.init(e,t),j.init(e,t)}),xs=x(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),j.init(e,t)}),Ss=x(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),j.init(e,t)}),Cs=x(`ZodBase64`,(e,t)=>{Vr.init(e,t),j.init(e,t)}),ws=x(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),j.init(e,t)}),Ts=x(`ZodE164`,(e,t)=>{Wr.init(e,t),j.init(e,t)}),Es=x(`ZodJWT`,(e,t)=>{Kr.init(e,t),j.init(e,t)}),Ds=x(`ZodNumber`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),as(e,`ZodNumber`,{gt(e,t){return this.check(va(e,t))},gte(e,t){return this.check(ya(e,t))},min(e,t){return this.check(ya(e,t))},lt(e,t){return this.check(ga(e,t))},lte(e,t){return this.check(_a(e,t))},max(e,t){return this.check(_a(e,t))},int(e){return this.check(ks(e))},safe(e){return this.check(ks(e))},positive(e){return this.check(va(0,e))},nonnegative(e){return this.check(ya(0,e))},negative(e){return this.check(ga(0,e))},nonpositive(e){return this.check(_a(0,e))},multipleOf(e,t){return this.check(ba(e,t))},step(e,t){return this.check(ba(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function M(e){return ua(Ds,e)}let Os=x(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Ds.init(e,t)});function ks(e){return da(Os,e)}let As=x(`ZodBoolean`,(e,t)=>{Yr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r)});function N(e){return fa(As,e)}let js=x(`ZodNull`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r)});function Ms(e){return pa(js,e)}let Ns=x(`ZodUnknown`,(e,t)=>{Zr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function P(){return ma(Ns)}let Ps=x(`ZodNever`,(e,t)=>{Qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r)});function Fs(e){return ha(Ps,e)}let Is=x(`ZodArray`,(e,t)=>{ei.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.element=t.element,as(e,`ZodArray`,{min(e,t){return this.check(Sa(e,t))},nonempty(e){return this.check(Sa(1,e))},max(e,t){return this.check(xa(e,t))},length(e,t){return this.check(Ca(e,t))},unwrap(){return this.element}})});function F(e,t){return Ia(Is,e,t)}let Ls=x(`ZodObject`,(e,t)=>{ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),S(e,`shape`,()=>t.shape),as(e,`ZodObject`,{keyof(){return Gs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:P()})},loose(){return this.clone({...this._zod.def,catchall:P()})},strict(){return this.clone({...this._zod.def,catchall:Fs()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Gt(this,e)},safeExtend(e){return Kt(this,e)},merge(e){return qt(this,e)},pick(e){return Ut(this,e)},omit(e){return Wt(this,e)},partial(...e){return Jt(Ys,this,e[0])},required(...e){return Yt(ic,this,e[0])}})});function I(e,t){return new Ls({type:`object`,shape:e??{},...C(t)})}function L(e,t){return new Ls({type:`object`,shape:e,catchall:P(),...C(t)})}let Rs=x(`ZodUnion`,(e,t)=>{si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.options=t.options});function R(e,t){return new Rs({type:`union`,options:e,...C(t)})}let zs=x(`ZodDiscriminatedUnion`,(e,t)=>{Rs.init(e,t),ci.init(e,t)});function Bs(e,t,n){return new zs({type:`union`,options:t,discriminator:e,...C(n)})}let Vs=x(`ZodIntersection`,(e,t)=>{li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r)});function Hs(e,t){return new Vs({type:`intersection`,left:e,right:t})}let Us=x(`ZodRecord`,(e,t)=>{fi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function z(e,t,n){return!t||!t._zod?new Us({type:`record`,keyType:A(),valueType:e,...C(t)}):new Us({type:`record`,keyType:e,valueType:t,...C(n)})}let Ws=x(`ZodEnum`,(e,t)=>{pi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ws({...t,checks:[],...C(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ws({...t,checks:[],...C(r),entries:i})}});function Gs(e,t){return new Ws({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...C(t)})}let Ks=x(`ZodLiteral`,(e,t)=>{mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new Ks({type:`literal`,values:Array.isArray(e)?e:[e],...C(t)})}let qs=x(`ZodTransform`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new yt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(nn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(nn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Js(e){return new qs({type:`transform`,transform:e})}let Ys=x(`ZodOptional`,(e,t)=>{_i.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function V(e){return new Ys({type:`optional`,innerType:e})}let Xs=x(`ZodExactOptional`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e){return new Xs({type:`optional`,innerType:e})}let Qs=x(`ZodNullable`,(e,t)=>{yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $s(e){return new Qs({type:`nullable`,innerType:e})}let ec=x(`ZodDefault`,(e,t)=>{bi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tc(e,t){return new ec({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Lt(t)}})}let nc=x(`ZodPrefault`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e,t){return new nc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Lt(t)}})}let ic=x(`ZodNonOptional`,(e,t)=>{Ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ac(e,t){return new ic({type:`nonoptional`,innerType:e,...C(t)})}let oc=x(`ZodCatch`,(e,t)=>{Ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Do(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sc(e,t){return new oc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let cc=x(`ZodPipe`,(e,t)=>{Ei.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oo(e,t,n,r),e.in=t.in,e.out=t.out});function lc(e,t){return new cc({type:`pipe`,in:e,out:t})}let uc=x(`ZodPreprocess`,(e,t)=>{cc.init(e,t),Oi.init(e,t)}),dc=x(`ZodReadonly`,(e,t)=>{ki.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ko(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fc(e){return new dc({type:`readonly`,innerType:e})}let pc=x(`ZodCustom`,(e,t)=>{ji.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r)});function mc(e,t){return La(pc,e??(()=>!0),t)}function hc(e,t={}){return Ra(pc,e,t)}function gc(e,t){return za(e,t)}function _c(e,t){return new uc({type:`pipe`,in:Js(e),out:t})}let vc=Symbol(`Let zodToJsonSchema decide on which parser to use`),yc={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},bc=e=>typeof e==`string`?{...yc,name:e}:{...yc,...e},xc=e=>{let t=bc(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Sc(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function H(e,t,n,r,i){e[t]=n,Sc(e,t,r,i)}let Cc=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function U(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?Cc(t,e.currentPath):t.join(`/`)}}function wc(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==b.ZodAny&&(n.items=G(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&H(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&H(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(H(n,`minItems`,e.exactLength.value,e.exactLength.message,t),H(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Tc(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?H(n,`minimum`,r.value,r.message,t):H(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),H(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?H(n,`maximum`,r.value,r.message,t):H(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),H(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:H(n,`multipleOf`,r.value,r.message,t);break}return n}function Ec(){return{type:`boolean`}}function Dc(e,t){return G(e.type._def,t)}let Oc=(e,t)=>G(e.innerType._def,t);function kc(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>kc(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Ac(e,t)}}let Ac=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:H(n,`minimum`,r.value,r.message,t);break;case`max`:H(n,`maximum`,r.value,r.message,t);break}return n};function jc(e,t){return{...G(e.innerType._def,t),default:e.defaultValue()}}function Mc(e,t){return t.effectStrategy===`input`?G(e.schema._def,t):U(t)}function Nc(e){return{type:`string`,enum:Array.from(e.values)}}let Pc=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Fc(e,t){let n=[G(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),G(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(Pc(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function Ic(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let Lc,Rc={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Lc===void 0&&(Lc=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Lc),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function zc(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:H(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:H(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:Uc(n,`email`,r.message,t);break;case`format:idn-email`:Uc(n,`idn-email`,r.message,t);break;case`pattern:zod`:W(n,Rc.email,r.message,t);break}break;case`url`:Uc(n,`uri`,r.message,t);break;case`uuid`:Uc(n,`uuid`,r.message,t);break;case`regex`:W(n,r.regex,r.message,t);break;case`cuid`:W(n,Rc.cuid,r.message,t);break;case`cuid2`:W(n,Rc.cuid2,r.message,t);break;case`startsWith`:W(n,RegExp(`^${Bc(r.value,t)}`),r.message,t);break;case`endsWith`:W(n,RegExp(`${Bc(r.value,t)}$`),r.message,t);break;case`datetime`:Uc(n,`date-time`,r.message,t);break;case`date`:Uc(n,`date`,r.message,t);break;case`time`:Uc(n,`time`,r.message,t);break;case`duration`:Uc(n,`duration`,r.message,t);break;case`length`:H(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),H(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:W(n,RegExp(Bc(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&Uc(n,`ipv4`,r.message,t),r.version!==`v4`&&Uc(n,`ipv6`,r.message,t);break;case`base64url`:W(n,Rc.base64url,r.message,t);break;case`jwt`:W(n,Rc.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&W(n,Rc.ipv4Cidr,r.message,t),r.version!==`v4`&&W(n,Rc.ipv6Cidr,r.message,t);break;case`emoji`:W(n,Rc.emoji(),r.message,t);break;case`ulid`:W(n,Rc.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:Uc(n,`binary`,r.message,t);break;case`contentEncoding:base64`:H(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:W(n,Rc.base64,r.message,t);break}break;case`nanoid`:W(n,Rc.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function Bc(e,t){return t.patternStrategy===`escape`?Hc(e):e}let Vc=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Hc(e){let t=``;for(let n=0;n<e.length;n++)Vc.has(e[n])||(t+=`\\`),t+=e[n];return t}function Uc(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):H(e,`format`,t,n,r)}function W(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:Wc(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):H(e,`pattern`,Wc(t,r),n,r)}function Wc(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
65
+ ]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
66
+ ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Gc(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===b.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:G(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??U(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:G(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===b.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=zc(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===b.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===b.ZodBranded&&e.keyType._def.type._def.typeName===b.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Dc(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Kc(e,t){return t.mapStrategy===`record`?Gc(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[G(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||U(t),G(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||U(t)],minItems:2,maxItems:2}}}function qc(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Jc(e){return e.target===`openAi`?void 0:{not:U({...e,currentPath:[...e.currentPath,`not`]})}}function Yc(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}let Xc={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Zc(e,t){if(t.target===`openApi3`)return Qc(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Xc&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Xc[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Qc(e,t)}let Qc=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>G(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function $c(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:Xc[e.innerType._def.typeName],nullable:!0}:{type:[Xc[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=G(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=G(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function el(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Sc(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?H(n,`minimum`,r.value,r.message,t):H(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),H(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?H(n,`maximum`,r.value,r.message,t):H(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),H(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:H(n,`multipleOf`,r.value,r.message,t);break}return n}function tl(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=rl(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=G(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=nl(e,t);return o!==void 0&&(r.additionalProperties=o),r}function nl(e,t){if(e.catchall._def.typeName!==`ZodNever`)return G(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function rl(e){try{return e.isOptional()}catch{return!0}}let il=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return G(e.innerType._def,t);let n=G(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:U(t)},n]}:U(t)},al=(e,t)=>{if(t.pipeStrategy===`input`)return G(e.in._def,t);if(t.pipeStrategy===`output`)return G(e.out._def,t);let n=G(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,G(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function ol(e,t){return G(e.type._def,t)}function sl(e,t){let n={type:`array`,uniqueItems:!0,items:G(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&H(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&H(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function cl(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>G(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:G(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>G(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function ll(e){return{not:U(e)}}function ul(e){return U(e)}let dl=(e,t)=>G(e.innerType._def,t),fl=(e,t,n)=>{switch(t){case b.ZodString:return zc(e,n);case b.ZodNumber:return el(e,n);case b.ZodObject:return tl(e,n);case b.ZodBigInt:return Tc(e,n);case b.ZodBoolean:return Ec();case b.ZodDate:return kc(e,n);case b.ZodUndefined:return ll(n);case b.ZodNull:return Yc(n);case b.ZodArray:return wc(e,n);case b.ZodUnion:case b.ZodDiscriminatedUnion:return Zc(e,n);case b.ZodIntersection:return Fc(e,n);case b.ZodTuple:return cl(e,n);case b.ZodRecord:return Gc(e,n);case b.ZodLiteral:return Ic(e,n);case b.ZodEnum:return Nc(e);case b.ZodNativeEnum:return qc(e);case b.ZodNullable:return $c(e,n);case b.ZodOptional:return il(e,n);case b.ZodMap:return Kc(e,n);case b.ZodSet:return sl(e,n);case b.ZodLazy:return()=>e.getter()._def;case b.ZodPromise:return ol(e,n);case b.ZodNaN:case b.ZodNever:return Jc(n);case b.ZodEffects:return Mc(e,n);case b.ZodAny:return U(n);case b.ZodUnknown:return ul(n);case b.ZodDefault:return jc(e,n);case b.ZodBranded:return Dc(e,n);case b.ZodReadonly:return dl(e,n);case b.ZodCatch:return Oc(e,n);case b.ZodPipeline:return al(e,n);case b.ZodFunction:case b.ZodVoid:case b.ZodSymbol:return;default:return(e=>void 0)(t)}};function G(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==vc)return i}if(r&&!n){let e=pl(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=fl(e,e.typeName,t),o=typeof a==`function`?G(a(),t):a;if(o&&ml(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}let pl=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Cc(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),U(t)):t.$refStrategy===`seen`?U(t):void 0}},ml=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),hl=(e,t)=>{let n=xc(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:G(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??U(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=G(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??U(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s};function gl(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!gl(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!gl(e[r],t[r]))return!1;return!0}return e===t}function _l(e){return encodeURI(vl(e))}function vl(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}let yl={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},bl={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},xl={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},Sl=typeof self<`u`&&self.location&&self.location.origin!==`null`?new URL(self.location.origin+self.location.pathname+location.search):new URL(`https://github.com/cfworker`);function Cl(e,t=Object.create(null),n=Sl,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:Cl(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,`__absolute_uri__`,{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_ref__`,{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_recursive_ref__`,{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(xl[i])continue;let a=`${r}/${_l(i)}`,o=e[i];if(Array.isArray(o)){if(yl[i]){let e=o.length;for(let r=0;r<e;r++)Cl(o[r],t,n,`${a}/${r}`)}}else if(bl[i])for(let e in o)Cl(o[e],t,n,`${a}/${_l(e)}`);else Cl(o,t,n,a)}return t}let wl=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Tl=[0,31,28,31,30,31,30,31,31,30,31,30,31],El=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Dl=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Ol=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,kl=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Al=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,jl=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Ml=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Nl=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Pl=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Fl=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Il=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Ll=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Rl=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function zl(e){return e.test.bind(e)}let Bl={date:Hl,time:Ul.bind(void 0,!1),"date-time":Gl,duration:Rl,uri:Jl,"uri-reference":zl(Ol),"uri-template":zl(kl),url:zl(Al),email:Fl,hostname:zl(Dl),ipv4:zl(Il),ipv6:zl(Ll),regex:Xl,uuid:zl(jl),"json-pointer":zl(Ml),"json-pointer-uri-fragment":zl(Nl),"relative-json-pointer":zl(Pl)};function Vl(e){return e%4==0&&(e%100!=0||e%400==0)}function Hl(e){let t=e.match(wl);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Vl(n)?29:Tl[r])}function Ul(e,t){let n=t.match(El);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}let Wl=/t|\s/i;function Gl(e){let t=e.split(Wl);return t.length==2&&Hl(t[0])&&Ul(!0,t[1])}let Kl=/\/|:/,ql=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Jl(e){return Kl.test(e)&&ql.test(e)}let Yl=/[^\\]\\Z/;function Xl(e){if(Yl.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function Zl(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function K(e,t,n=`2019-09`,r=Cl(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:ee,enum:h,required:te,not:ne,anyOf:re,allOf:ie,oneOf:g,if:ae,then:oe,else:_,format:v,properties:se,patternProperties:ce,additionalProperties:le,unevaluatedProperties:ue,minProperties:de,maxProperties:fe,propertyNames:pe,dependentRequired:me,dependentSchemas:he,dependencies:ge,prefixItems:_e,items:ve,additionalItems:ye,unevaluatedItems:be,contains:xe,minContains:Se,maxContains:Ce,minItems:we,maxItems:Te,uniqueItems:Ee,minimum:De,maximum:Oe,exclusiveMinimum:ke,exclusiveMaximum:Ae,multipleOf:je,minLength:Me,maxLength:Ne,pattern:Pe,__absolute_ref__:Fe,__absolute_recursive_ref__:Ie}=t,y=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[Ie]:a,u=`${s}/$recursiveRef`,d=K(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||y.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[Fe||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw Fe&&Fe!==d&&(e+=` Absolute URI "${Fe}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
67
+ - `)}`,Error(e)}let l=`${s}/$ref`,u=K(e,t,n,r,i,a,o,l,c);if(u.valid||y.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:y.length===0,errors:y}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(ee!==void 0&&(u===`object`||u===`array`?gl(e,ee)||y.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(ee)}.`}):e!==ee&&y.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(ee)}.`})),h!==void 0&&(u===`object`||u===`array`?h.some(t=>gl(e,t))||y.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(h)}.`}):h.some(t=>e===t)||y.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(h)}.`})),ne!==void 0){let t=`${s}/not`;K(e,ne,n,r,i,a,o,t).valid&&y.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let Le=[];if(re!==void 0){let t=`${s}/anyOf`,l=y.length,u=!1;for(let s=0;s<re.length;s++){let l=re[s],d=Object.create(c),f=K(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);y.push(...f.errors),u||=f.valid,f.valid&&Le.push(d)}u?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(ie!==void 0){let t=`${s}/allOf`,l=y.length,u=!0;for(let s=0;s<ie.length;s++){let l=ie[s],d=Object.create(c),f=K(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);y.push(...f.errors),u&&=f.valid,f.valid&&Le.push(d)}u?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(g!==void 0){let t=`${s}/oneOf`,l=y.length,u=g.filter((s,l)=>{let u=Object.create(c),d=K(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return y.push(...d.errors),d.valid&&Le.push(u),d.valid}).length;u===1?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...Le),ae!==void 0){let t=`${s}/if`;if(K(e,ae,n,r,i,a,o,t,c).valid){if(oe!==void 0){let l=K(e,oe,n,r,i,a,o,`${s}/then`,c);l.valid||y.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(_!==void 0){let l=K(e,_,n,r,i,a,o,`${s}/else`,c);l.valid||y.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(te!==void 0)for(let t of te)t in e||y.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(de!==void 0&&t.length<de&&y.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${de} properties.`}),fe!==void 0&&t.length>fe&&y.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${fe} properties.`}),pe!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${_l(s)}`,c=K(s,pe,n,r,i,a,e,t);c.valid||y.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(me!==void 0){let t=`${s}/dependantRequired`;for(let n in me)if(n in e){let r=me[n];for(let i of r)i in e||y.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(he!==void 0)for(let t in he){let l=`${s}/dependentSchemas`;if(t in e){let s=K(e,he[t],n,r,i,a,o,`${l}/${_l(t)}`,c);s.valid||y.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(ge!==void 0){let t=`${s}/dependencies`;for(let s in ge)if(s in e){let c=ge[s];if(Array.isArray(c))for(let n of c)n in e||y.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=K(e,c,n,r,i,a,o,`${t}/${_l(s)}`);l.valid||y.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(se!==void 0){let t=`${s}/properties`;for(let s in se){if(!(s in e))continue;let d=`${o}/${_l(s)}`,f=K(e[s],se[s],n,r,i,a,d,`${t}/${_l(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,y.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&ce!==void 0){let t=`${s}/patternProperties`;for(let s in ce){let d=new RegExp(s,`u`),f=ce[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${_l(p)}`,ee=K(e[p],f,n,r,i,a,m,`${t}/${_l(s)}`);ee.valid?c[p]=l[p]=!0:(u=i,y.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...ee.errors))}}}if(!u&&le!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${_l(s)}`,f=K(e[s],le,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,y.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&ue!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${_l(s)}`,u=K(e[s],ue,n,r,i,a,l,t);u.valid?c[s]=!0:y.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){Te!==void 0&&e.length>Te&&y.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${Te}).`}),we!==void 0&&e.length<we&&y.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${we}).`});let t=e.length,l=0,u=!1;if(_e!==void 0){let d=`${s}/prefixItems`,f=Math.min(_e.length,t);for(;l<f;l++){let t=K(e[l],_e[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(ve!==void 0){let d=`${s}/items`;if(Array.isArray(ve)){let s=Math.min(ve.length,t);for(;l<s;l++){let t=K(e[l],ve[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=K(e[l],ve,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&ye!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=K(e[l],ye,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,y.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(xe!==void 0)if(t===0&&Se===void 0)y.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(Se!==void 0&&t<Se)y.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${Se}).`});else{let l=`${s}/contains`,u=y.length,d=0;for(let s=0;s<t;s++){let t=K(e[s],xe,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):y.push(...t.errors)}d>=(Se||0)&&(y.length=u),Se===void 0&&Ce===void 0&&d===0?y.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):Se!==void 0&&d<Se?y.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Se} items matching schema. Only ${d} items were found.`}):Ce!==void 0&&d>Ce&&y.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${Ce} items matching schema. ${d} items were found.`})}if(!u&&be!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=K(e[l],be,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||y.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(Ee)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&gl(r,t))&&(y.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(De!==void 0&&(ke===!0&&e<=De||e<De)&&y.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${ke?`or equal to `:``} ${De}.`}),Oe!==void 0&&(Ae===!0&&e>=Oe||e>Oe)&&y.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Ae?`or equal to `:``} ${Oe}.`})):(De!==void 0&&e<De&&y.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${De}.`}),Oe!==void 0&&e>Oe&&y.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Oe}.`}),ke!==void 0&&e<=ke&&y.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${ke}.`}),Ae!==void 0&&e>=Ae&&y.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Ae}.`})),je!==void 0){let t=e%je;Math.abs(0-t)>=1.1920929e-7&&Math.abs(je-t)>=1.1920929e-7&&y.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${je}.`})}}else if(u===`string`){let t=Me===void 0&&Ne===void 0?0:Zl(e);Me!==void 0&&t<Me&&y.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${Me}).`}),Ne!==void 0&&t>Ne&&y.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Ne}).`}),Pe!==void 0&&!new RegExp(Pe,`u`).test(e)&&y.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),v!==void 0&&Bl[v]&&!Bl[v](e)&&y.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${v}".`})}return{valid:y.length===0,errors:y}}var Ql=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=Cl(e)}validate(e){return K(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),Cl(e,this.lookup)}};let $l=`Failed to parse input arguments`,eu=`Tool was executed but the invocation failed. For example, the script function threw an error`,tu=`Tool was cancelled`,nu={type:`object`,properties:{}},ru=[`draft-2020-12`,`draft-07`],iu=Symbol(`standardValidator`),q={installed:!1,previousNavigatorModelContextDescriptor:void 0,previousNavigatorModelContextTestingDescriptor:void 0,previousDocumentModelContextDescriptor:void 0,installedNavigatorModelContext:!1,installedNavigatorModelContextTesting:!1,installedDocumentModelContext:!1};var au=class extends EventTarget{tools=new Map;testingShim=null;_ontoolchange=null;unregisterToolDeprecationWarned=!1;get ontoolchange(){return this._ontoolchange}set ontoolchange(e){this._ontoolchange=e}registerTool(e,t){let n=t?.signal;if(n?.aborted){console.warn(`[WebMCPPolyfill] registerTool("${e?.name??`<unknown>`}") skipped: options.signal was already aborted.`);return}let r=vu(e,this.tools);this.tools.set(r.name,r),this.notifyToolsChanged(),n&&n.addEventListener(`abort`,()=>{this.tools.delete(r.name)&&this.notifyToolsChanged()},{once:!0})}unregisterTool(e){this.warnUnregisterToolDeprecationOnce();let t=lu(e);this.tools.delete(t)&&this.notifyToolsChanged()}getTools(){return Promise.resolve(this.getRegisteredToolInfos())}executeTool(e,t,n){return this.executeToolByName(e.name,t,n,!1)}getTestingShim(){return this.testingShim||=new ou(this),this.testingShim}getToolInfos(){return[...this.tools.values()].map(e=>{let t;try{t=JSON.stringify(e.inputSchema??{type:`object`})}catch{t=`{"type":"object"}`}return{name:e.name,description:e.description,inputSchema:t}})}getRegisteredToolInfos(){return this.getToolInfos().map(e=>{let t=this.tools.get(e.name);return{...e,title:t?.title??``,origin:globalThis.location?.origin??``,window:globalThis.window}})}async executeToolForTesting(e,t,n){return this.executeToolByName(e,t,n,!0)}async executeToolByName(e,t,n,r){if(n?.signal?.aborted)throw su(tu);let i=this.tools.get(e);if(!i)throw su(`Tool not found: ${e}`);let a=cu(t),o=await Su(a,i);if(o)throw su(o);let s=!0,c={requestUserInteraction:async t=>{if(!s)throw Error(`ModelContextClient for tool "${e}" is no longer active after execute() resolved`);if(typeof t!=`function`)throw TypeError(`requestUserInteraction(callback) requires a function callback`);return t()}};try{let e=i.execute(a,c),t=await ju(Promise.resolve(e),n?.signal);if(r)return Au(Ou(t));let o=JSON.stringify(t);return o===void 0?null:o}catch(e){throw su(e instanceof Error?`${eu}: ${e.message}`:eu)}finally{s=!1}}notifyToolsChanged(){queueMicrotask(()=>{let e=new Event(`toolchange`);try{this._ontoolchange?.call(this,e)}catch(e){console.warn(`[WebMCPPolyfill] navigator.modelContext.ontoolchange handler threw:`,e)}this.dispatchEvent(e),this.testingShim?.dispatchToolChange()})}warnUnregisterToolDeprecationOnce(){this.unregisterToolDeprecationWarned||(this.unregisterToolDeprecationWarned=!0,console.warn(`[WebMCPPolyfill] navigator.modelContext.unregisterTool() is deprecated. The April 23, 2026 WebMCP draft removed it in favor of registerTool(tool, { signal }) — pass an AbortSignal and abort it to unregister.`))}},ou=class extends EventTarget{context;_ontoolchange=null;constructor(e){super(),this.context=e}listTools(){return this.context.getToolInfos()}executeTool(e,t,n){return this.context.executeToolForTesting(e,t,n)}getCrossDocumentScriptToolResult(){return Promise.resolve(`[]`)}get ontoolchange(){return this._ontoolchange}set ontoolchange(e){this._ontoolchange=e}registerToolsChangedCallback(e){if(typeof e!=`function`)throw TypeError(`Failed to execute 'registerToolsChangedCallback' on 'ModelContextTesting': parameter 1 is not of type 'Function'.`);this.addEventListener(`toolchange`,e)}dispatchToolChange(){let e=new Event(`toolchange`);try{this._ontoolchange?.call(this,e)}catch(e){console.warn(`[WebMCPPolyfill] ontoolchange handler threw:`,e)}this.dispatchEvent(e),this.dispatchEvent(new Event(`toolschanged`))}};function su(e){try{return new DOMException(e,`UnknownError`)}catch{let t=Error(e);return t.name=`UnknownError`,t}}function cu(e){let t;try{t=JSON.parse(e)}catch{throw su($l)}if(!t||typeof t!=`object`||Array.isArray(t))throw su($l);return t}function lu(e){if(typeof e==`string`)return e;if(J(e)&&typeof e.name==`string`)return e.name;throw TypeError(`Failed to execute 'unregisterTool' on 'ModelContext': parameter 1 must be a string or an object with a string name.`)}function J(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function uu(e){if(!J(e))return null;let t=e[`~standard`];return J(t)?t:null}function du(e){let t=uu(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function fu(e){let t=uu(e);return!t||t.version!==1||!J(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function pu(e){return{"~standard":{version:1,vendor:`@mcp-b/webmcp-polyfill-json-schema`,validate(t){if(!J(t))return{issues:[{message:`expected object arguments`}]};let n=yu(t,e);return n?{issues:[n]}:{value:t}}}}}function mu(e){for(let t of ru)try{let n=e[`~standard`].jsonSchema.input({target:t});return gu(n),n}catch(e){console.warn(`[WebMCPPolyfill] Standard JSON Schema conversion failed for target "${t}":`,e)}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function hu(e){if(e===void 0){let e=nu;return{inputSchema:e,standardValidator:pu(e)}}if(fu(e)){let t=mu(e);return{inputSchema:t,standardValidator:pu(t)}}if(du(e))return{inputSchema:nu,standardValidator:e};if(gu(e),Object.keys(e).length===0)return{inputSchema:nu,standardValidator:pu(nu)};let t=e.type===void 0?{type:`object`,...e}:e;return{inputSchema:t,standardValidator:pu(t)}}function gu(e){if(!J(e))throw Error(`inputSchema must be a JSON Schema object`);_u(e,`$`)}function _u(e,t){let n=e.type;if(n!==void 0&&typeof n!=`string`&&!(Array.isArray(n)&&n.every(e=>typeof e==`string`&&e.length>0)))throw Error(`Invalid JSON Schema at ${t}: "type" must be a string or string[]`);let r=e.required;if(r!==void 0&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`)))throw Error(`Invalid JSON Schema at ${t}: "required" must be an array of strings`);let i=e.properties;if(i!==void 0){if(!J(i))throw Error(`Invalid JSON Schema at ${t}: "properties" must be an object`);for(let[e,n]of Object.entries(i)){if(!J(n))throw Error(`Invalid JSON Schema at ${t}.properties.${e}: expected object schema`);_u(n,`${t}.properties.${e}`)}}let a=e.items;if(a!==void 0)if(Array.isArray(a))for(let[e,n]of a.entries()){if(!J(n))throw Error(`Invalid JSON Schema at ${t}.items[${e}]: expected object schema`);_u(n,`${t}.items[${e}]`)}else if(J(a))_u(a,`${t}.items`);else throw Error(`Invalid JSON Schema at ${t}: "items" must be an object or object[]`);for(let n of[`allOf`,`anyOf`,`oneOf`]){let r=e[n];if(r!==void 0){if(!Array.isArray(r))throw Error(`Invalid JSON Schema at ${t}: "${n}" must be an array`);for(let[e,i]of r.entries()){if(!J(i))throw Error(`Invalid JSON Schema at ${t}.${n}[${e}]: expected object schema`);_u(i,`${t}.${n}[${e}]`)}}}let o=e.not;if(o!==void 0){if(!J(o))throw Error(`Invalid JSON Schema at ${t}: "not" must be an object schema`);_u(o,`${t}.not`)}try{JSON.stringify(e)}catch{throw Error(`Invalid JSON Schema at ${t}: schema must be JSON-serializable`)}}function vu(e,t){if(!e||typeof e!=`object`)throw TypeError(`registerTool(tool) requires a tool object`);if(typeof e.name!=`string`||e.name.length===0)throw TypeError(`Tool "name" must be a non-empty string`);if(typeof e.description!=`string`||e.description.length===0)throw TypeError(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`);if(t.has(e.name))throw Error(`Tool already registered: ${e.name}`);let n=hu(e.inputSchema),r=e.annotations,i=r?{...r,...r.readOnlyHint===`true`?{readOnlyHint:!0}:r.readOnlyHint===`false`?{readOnlyHint:!1}:{},...r.destructiveHint===`true`?{destructiveHint:!0}:r.destructiveHint===`false`?{destructiveHint:!1}:{},...r.idempotentHint===`true`?{idempotentHint:!0}:r.idempotentHint===`false`?{idempotentHint:!1}:{},...r.openWorldHint===`true`?{openWorldHint:!0}:r.openWorldHint===`false`?{openWorldHint:!1}:{}}:void 0;return{...e,...i?{annotations:i}:{},inputSchema:n.inputSchema,[iu]:n.standardValidator}}function yu(e,t){let n=new Ql(t,`2020-12`,!0).validate(e);if(n.valid)return null;let r=n.errors[n.errors.length-1];return r?{message:r.error}:{message:`Input validation failed`}}function bu(e){if(!e||e.length===0)return null;let t=e.map(e=>J(e)&&`key`in e?e.key:e).map(e=>String(e)).filter(e=>e.length>0);return t.length===0?null:t.join(`.`)}async function xu(e,t){let n;try{n=await Promise.resolve(t[`~standard`].validate(e))}catch(e){let t=e instanceof Error?`: ${e.message}`:``;return console.error(`[WebMCPPolyfill] Standard Schema validation threw unexpectedly:`,e),`Input validation error: schema validation failed${t}`}if(!n.issues||n.issues.length===0)return null;let r=n.issues[0];if(!r)return`Input validation error`;let i=bu(r?.path);return i?`Input validation error: ${r.message} at ${i}`:`Input validation error: ${r.message}`}async function Su(e,t){return xu(e,t[iu])}function Cu(e){return J(e)&&Array.isArray(e.content)}function wu(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Tu(e){return wu(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>Tu(e)):J(e)?Object.values(e).every(e=>Tu(e)):!1}function Eu(e){if(!(!J(e)||!Tu(e)))return e}function Du(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function Ou(e){if(Cu(e))return e;let t=Eu(e);return{content:[{type:`text`,text:Du(e)}],...t?{structuredContent:t}:{},isError:!1}}function ku(e){for(let t of e.content??[])if(t.type===`text`&&`text`in t&&typeof t.text==`string`)return t.text;return null}function Au(e){if(e.isError)throw su(ku(e)?.replace(/^Error:\s*/i,``).trim()||eu);let t=e.metadata;if(t&&typeof t==`object`&&t.willNavigate)return null;try{return JSON.stringify(e)}catch{throw su(eu)}}function ju(e,t){return t?t.aborted?Promise.reject(su(tu)):new Promise((n,r)=>{let i=()=>{a(),r(su(tu))},a=()=>{t.removeEventListener(`abort`,i)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{a(),n(e)},e=>{a(),r(e)})}):e}function Mu(){return typeof navigator<`u`?navigator:null}function Nu(){return typeof document<`u`?document:null}function Pu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!1,value:n})}function Fu(e,t){Object.defineProperty(e,`modelContext`,{configurable:!0,enumerable:!0,writable:!1,value:t})}let Iu=!1;function Lu(e,t){Object.defineProperty(e,`modelContext`,{configurable:!0,enumerable:!0,get(){return Iu||(Iu=!0,console.warn(`[WebMCPPolyfill] navigator.modelContext is deprecated. The May 27, 2026 WebMCP draft moved the modelContext getter from Navigator to Document — use document.modelContext instead. See https://github.com/webmachinelearning/webmcp/pull/184.`)),t}})}function Ru(e){let t=Mu(),n=Nu();if(!t&&!n||n?.modelContext)return;let r=t?.modelContext,i=!!r;if(q.installed&&zu(),n&&r){q.previousDocumentModelContextDescriptor=Object.getOwnPropertyDescriptor(n,`modelContext`),Fu(n,r),q.installedDocumentModelContext=!0,q.installed=!0;return}if(i)return;let a=new au,o=a;if(o.__isWebMCPPolyfill=!0,n&&(q.previousDocumentModelContextDescriptor=Object.getOwnPropertyDescriptor(n,`modelContext`),Fu(n,o),q.installedDocumentModelContext=!0),t){q.previousNavigatorModelContextDescriptor=Object.getOwnPropertyDescriptor(t,`modelContext`),q.previousNavigatorModelContextTestingDescriptor=Object.getOwnPropertyDescriptor(t,`modelContextTesting`),Iu=!1,Lu(t,o),q.installedNavigatorModelContext=!0;let n=e?.installTestingShim??`if-missing`,r=!!t.modelContextTesting;(n===`always`||(n===!0||n===`if-missing`)&&!r)&&(Pu(t,`modelContextTesting`,a.getTestingShim()),q.installedNavigatorModelContextTesting=!0)}q.installed=!0}function zu(){if(!q.installed)return;let e=(e,t,n)=>{if(n){Object.defineProperty(e,t,n);return}delete e[t]},t=Mu(),n=Nu();n&&q.installedDocumentModelContext&&e(n,`modelContext`,q.previousDocumentModelContextDescriptor),t&&q.installedNavigatorModelContext&&e(t,`modelContext`,q.previousNavigatorModelContextDescriptor),t&&q.installedNavigatorModelContextTesting&&e(t,`modelContextTesting`,q.previousNavigatorModelContextTestingDescriptor),q.installed=!1,q.previousDocumentModelContextDescriptor=void 0,q.previousNavigatorModelContextDescriptor=void 0,q.previousNavigatorModelContextTestingDescriptor=void 0,q.installedDocumentModelContext=!1,q.installedNavigatorModelContext=!1,q.installedNavigatorModelContextTesting=!1,Iu=!1}if(typeof window<`u`&&typeof document<`u`){let e=window.__webMCPPolyfillOptions;if(e?.autoInitialize!==!1)try{Ru(e)}catch(e){console.error(`[WebMCPPolyfill] Auto-initialization failed:`,e)}}function Bu(e){return!!e._zod}function Vu(e){let t=Object.values(e);if(t.length===0)return Io({});let n=t.every(Bu),r=t.every(e=>!Bu(e));if(n)return Io(e);if(r)return gt(e);throw Error(`Mixed Zod versions detected in object shape.`)}function Hu(e,t){return Bu(e)?mn(e,t):e.safeParse(t)}async function Uu(e,t){return Bu(e)?await gn(e,t):await e.safeParseAsync(t)}function Wu(e){if(!e)return;let t;if(t=Bu(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Gu(e){if(e){if(typeof e==`object`){let t=e,n=e;if(!t._def&&!n._zod){let t=Object.values(e);if(t.length>0&&t.every(e=>typeof e==`object`&&!!e&&(e._def!==void 0||e._zod!==void 0||typeof e.parse==`function`)))return Vu(e)}}if(Bu(e)){let t=e._zod?.def;if(t&&(t.type===`object`||t.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function Ku(e){if(e&&typeof e==`object`){if(`message`in e&&typeof e.message==`string`)return e.message;if(`issues`in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t==`object`&&`message`in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function qu(e){return e.description}function Ju(e){if(Bu(e))return e._zod?.def?.type===`optional`;let t=e;return typeof e.isOptional==`function`?e.isOptional():t._def?.typeName===`ZodOptional`}function Yu(e){if(Bu(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}let Xu=`2025-11-25`,Zu=[Xu,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Qu=`io.modelcontextprotocol/related-task`,Y=mc(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),$u=R([A(),M().int()]),ed=A();L({ttl:R([M(),Ms()]).optional(),pollInterval:M().optional()});let td=I({ttl:M().optional()}),nd=I({taskId:A()}),rd=L({progressToken:$u.optional(),[Qu]:nd.optional()}),id=I({_meta:rd.optional()}),ad=id.extend({task:td.optional()}),od=e=>ad.safeParse(e).success,X=I({method:A(),params:id.loose().optional()}),sd=I({_meta:rd.optional()}),cd=I({method:A(),params:sd.loose().optional()}),Z=L({_meta:rd.optional()}),ld=R([A(),M().int()]),ud=I({jsonrpc:B(`2.0`),id:ld,...X.shape}).strict(),dd=e=>ud.safeParse(e).success,fd=I({jsonrpc:B(`2.0`),...cd.shape}).strict(),pd=e=>fd.safeParse(e).success,md=I({jsonrpc:B(`2.0`),id:ld,result:Z}).strict(),hd=e=>md.safeParse(e).success;var Q;(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`})(Q||={});let gd=I({jsonrpc:B(`2.0`),id:ld.optional(),error:I({code:M().int(),message:A(),data:P().optional()})}).strict(),_d=e=>gd.safeParse(e).success,vd=R([ud,fd,md,gd]);R([md,gd]);let yd=Z.strict(),bd=sd.extend({requestId:ld.optional(),reason:A().optional()}),xd=cd.extend({method:B(`notifications/cancelled`),params:bd}),Sd=I({icons:F(I({src:A(),mimeType:A().optional(),sizes:F(A()).optional(),theme:Gs([`light`,`dark`]).optional()})).optional()}),Cd=I({name:A(),title:A().optional()}),wd=Cd.extend({...Cd.shape,...Sd.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),Td=_c(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Hs(I({form:Hs(I({applyDefaults:N().optional()}),z(A(),P())).optional(),url:Y.optional()}),z(A(),P()).optional())),Ed=L({list:Y.optional(),cancel:Y.optional(),requests:L({sampling:L({createMessage:Y.optional()}).optional(),elicitation:L({create:Y.optional()}).optional()}).optional()}),Dd=L({list:Y.optional(),cancel:Y.optional(),requests:L({tools:L({call:Y.optional()}).optional()}).optional()}),Od=I({experimental:z(A(),Y).optional(),sampling:I({context:Y.optional(),tools:Y.optional()}).optional(),elicitation:Td.optional(),roots:I({listChanged:N().optional()}).optional(),tasks:Ed.optional()}),kd=id.extend({protocolVersion:A(),capabilities:Od,clientInfo:wd}),Ad=X.extend({method:B(`initialize`),params:kd}),jd=I({experimental:z(A(),Y).optional(),logging:Y.optional(),completions:Y.optional(),prompts:I({listChanged:N().optional()}).optional(),resources:I({subscribe:N().optional(),listChanged:N().optional()}).optional(),tools:I({listChanged:N().optional()}).optional(),tasks:Dd.optional()}),Md=Z.extend({protocolVersion:A(),capabilities:jd,serverInfo:wd,instructions:A().optional()}),Nd=cd.extend({method:B(`notifications/initialized`),params:sd.optional()}),Pd=X.extend({method:B(`ping`),params:id.optional()}),Fd=I({progress:M(),total:V(M()),message:V(A())}),Id=I({...sd.shape,...Fd.shape,progressToken:$u}),Ld=cd.extend({method:B(`notifications/progress`),params:Id}),Rd=id.extend({cursor:ed.optional()}),zd=X.extend({params:Rd.optional()}),Bd=Z.extend({nextCursor:ed.optional()}),Vd=Gs([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Hd=I({taskId:A(),status:Vd,ttl:R([M(),Ms()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:V(M()),statusMessage:V(A())}),Ud=Z.extend({task:Hd}),Wd=sd.merge(Hd),Gd=cd.extend({method:B(`notifications/tasks/status`),params:Wd}),Kd=X.extend({method:B(`tasks/get`),params:id.extend({taskId:A()})}),qd=Z.merge(Hd),Jd=X.extend({method:B(`tasks/result`),params:id.extend({taskId:A()})});Z.loose();let Yd=zd.extend({method:B(`tasks/list`)}),Xd=Bd.extend({tasks:F(Hd)}),Zd=X.extend({method:B(`tasks/cancel`),params:id.extend({taskId:A()})}),Qd=Z.merge(Hd),$d=I({uri:A(),mimeType:V(A()),_meta:z(A(),P()).optional()}),ef=$d.extend({text:A()}),tf=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),nf=$d.extend({blob:tf}),rf=Gs([`user`,`assistant`]),af=I({audience:F(rf).optional(),priority:M().min(0).max(1).optional(),lastModified:Ro({offset:!0}).optional()}),of=I({...Cd.shape,...Sd.shape,uri:A(),description:V(A()),mimeType:V(A()),annotations:af.optional(),_meta:V(L({}))}),sf=I({...Cd.shape,...Sd.shape,uriTemplate:A(),description:V(A()),mimeType:V(A()),annotations:af.optional(),_meta:V(L({}))}),cf=zd.extend({method:B(`resources/list`)}),lf=Bd.extend({resources:F(of)}),uf=zd.extend({method:B(`resources/templates/list`)}),df=Bd.extend({resourceTemplates:F(sf)}),ff=id.extend({uri:A()}),pf=ff,mf=X.extend({method:B(`resources/read`),params:pf}),hf=Z.extend({contents:F(R([ef,nf]))}),gf=cd.extend({method:B(`notifications/resources/list_changed`),params:sd.optional()}),_f=ff,vf=X.extend({method:B(`resources/subscribe`),params:_f}),yf=ff,bf=X.extend({method:B(`resources/unsubscribe`),params:yf}),xf=sd.extend({uri:A()}),Sf=cd.extend({method:B(`notifications/resources/updated`),params:xf}),Cf=I({name:A(),description:V(A()),required:V(N())}),wf=I({...Cd.shape,...Sd.shape,description:V(A()),arguments:V(F(Cf)),_meta:V(L({}))}),Tf=zd.extend({method:B(`prompts/list`)}),Ef=Bd.extend({prompts:F(wf)}),Df=id.extend({name:A(),arguments:z(A(),A()).optional()}),Of=X.extend({method:B(`prompts/get`),params:Df}),kf=I({type:B(`text`),text:A(),annotations:af.optional(),_meta:z(A(),P()).optional()}),Af=I({type:B(`image`),data:tf,mimeType:A(),annotations:af.optional(),_meta:z(A(),P()).optional()}),jf=I({type:B(`audio`),data:tf,mimeType:A(),annotations:af.optional(),_meta:z(A(),P()).optional()}),Mf=I({type:B(`tool_use`),name:A(),id:A(),input:z(A(),P()),_meta:z(A(),P()).optional()}),Nf=I({type:B(`resource`),resource:R([ef,nf]),annotations:af.optional(),_meta:z(A(),P()).optional()}),Pf=R([kf,Af,jf,of.extend({type:B(`resource_link`)}),Nf]),Ff=I({role:rf,content:Pf}),If=Z.extend({description:A().optional(),messages:F(Ff)}),Lf=cd.extend({method:B(`notifications/prompts/list_changed`),params:sd.optional()}),Rf=I({title:A().optional(),readOnlyHint:N().optional(),destructiveHint:N().optional(),idempotentHint:N().optional(),openWorldHint:N().optional()}),zf=I({taskSupport:Gs([`required`,`optional`,`forbidden`]).optional()}),Bf=I({...Cd.shape,...Sd.shape,description:A().optional(),inputSchema:I({type:B(`object`),properties:z(A(),Y).optional(),required:F(A()).optional()}).catchall(P()),outputSchema:I({type:B(`object`),properties:z(A(),Y).optional(),required:F(A()).optional()}).catchall(P()).optional(),annotations:Rf.optional(),execution:zf.optional(),_meta:z(A(),P()).optional()}),Vf=zd.extend({method:B(`tools/list`)}),Hf=Bd.extend({tools:F(Bf)}),Uf=Z.extend({content:F(Pf).default([]),structuredContent:z(A(),P()).optional(),isError:N().optional()});Uf.or(Z.extend({toolResult:P()}));let Wf=ad.extend({name:A(),arguments:z(A(),P()).optional()}),Gf=X.extend({method:B(`tools/call`),params:Wf}),Kf=cd.extend({method:B(`notifications/tools/list_changed`),params:sd.optional()});I({autoRefresh:N().default(!0),debounceMs:M().int().nonnegative().default(300)});let qf=Gs([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Jf=id.extend({level:qf}),Yf=X.extend({method:B(`logging/setLevel`),params:Jf}),Xf=sd.extend({level:qf,logger:A().optional(),data:P()}),Zf=cd.extend({method:B(`notifications/message`),params:Xf}),Qf=I({hints:F(I({name:A().optional()})).optional(),costPriority:M().min(0).max(1).optional(),speedPriority:M().min(0).max(1).optional(),intelligencePriority:M().min(0).max(1).optional()}),$f=I({mode:Gs([`auto`,`required`,`none`]).optional()}),ep=I({type:B(`tool_result`),toolUseId:A().describe(`The unique identifier for the corresponding tool call.`),content:F(Pf).default([]),structuredContent:I({}).loose().optional(),isError:N().optional(),_meta:z(A(),P()).optional()}),tp=Bs(`type`,[kf,Af,jf]),np=Bs(`type`,[kf,Af,jf,Mf,ep]),rp=I({role:rf,content:R([np,F(np)]),_meta:z(A(),P()).optional()}),ip=ad.extend({messages:F(rp),modelPreferences:Qf.optional(),systemPrompt:A().optional(),includeContext:Gs([`none`,`thisServer`,`allServers`]).optional(),temperature:M().optional(),maxTokens:M().int(),stopSequences:F(A()).optional(),metadata:Y.optional(),tools:F(Bf).optional(),toolChoice:$f.optional()}),ap=X.extend({method:B(`sampling/createMessage`),params:ip}),op=Z.extend({model:A(),stopReason:V(Gs([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:rf,content:tp}),sp=Z.extend({model:A(),stopReason:V(Gs([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:rf,content:R([np,F(np)])}),cp=I({type:B(`boolean`),title:A().optional(),description:A().optional(),default:N().optional()}),lp=I({type:B(`string`),title:A().optional(),description:A().optional(),minLength:M().optional(),maxLength:M().optional(),format:Gs([`email`,`uri`,`date`,`date-time`]).optional(),default:A().optional()}),up=I({type:Gs([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:M().optional(),maximum:M().optional(),default:M().optional()}),dp=I({type:B(`string`),title:A().optional(),description:A().optional(),enum:F(A()),default:A().optional()}),fp=I({type:B(`string`),title:A().optional(),description:A().optional(),oneOf:F(I({const:A(),title:A()})),default:A().optional()}),pp=R([R([I({type:B(`string`),title:A().optional(),description:A().optional(),enum:F(A()),enumNames:F(A()).optional(),default:A().optional()}),R([dp,fp]),R([I({type:B(`array`),title:A().optional(),description:A().optional(),minItems:M().optional(),maxItems:M().optional(),items:I({type:B(`string`),enum:F(A())}),default:F(A()).optional()}),I({type:B(`array`),title:A().optional(),description:A().optional(),minItems:M().optional(),maxItems:M().optional(),items:I({anyOf:F(I({const:A(),title:A()}))}),default:F(A()).optional()})])]),cp,lp,up]),mp=R([ad.extend({mode:B(`form`).optional(),message:A(),requestedSchema:I({type:B(`object`),properties:z(A(),pp),required:F(A()).optional()})}),ad.extend({mode:B(`url`),message:A(),elicitationId:A(),url:A().url()})]),hp=X.extend({method:B(`elicitation/create`),params:mp}),gp=sd.extend({elicitationId:A()}),_p=cd.extend({method:B(`notifications/elicitation/complete`),params:gp}),vp=Z.extend({action:Gs([`accept`,`decline`,`cancel`]),content:_c(e=>e===null?void 0:e,z(A(),R([A(),M(),N(),F(A())])).optional())}),yp=I({type:B(`ref/resource`),uri:A()}),bp=I({type:B(`ref/prompt`),name:A()}),xp=id.extend({ref:R([bp,yp]),argument:I({name:A(),value:A()}),context:I({arguments:z(A(),A()).optional()}).optional()}),Sp=X.extend({method:B(`completion/complete`),params:xp});function Cp(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function wp(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}let Tp=Z.extend({completion:L({values:F(A()).max(100),total:V(M().int()),hasMore:V(N())})}),Ep=I({uri:A().startsWith(`file://`),name:A().optional(),_meta:z(A(),P()).optional()}),Dp=X.extend({method:B(`roots/list`),params:id.optional()}),Op=Z.extend({roots:F(Ep)}),kp=cd.extend({method:B(`notifications/roots/list_changed`),params:sd.optional()});R([Pd,Ad,Sp,Yf,Of,Tf,cf,uf,mf,vf,bf,Gf,Vf,Kd,Jd,Yd,Zd]),R([xd,Ld,Nd,kp,Gd]),R([yd,op,sp,vp,Op,qd,Xd,Ud]),R([Pd,ap,hp,Dp,Kd,Jd,Yd,Zd]),R([xd,Ld,Zf,Sf,gf,Kf,Lf,Gd,_p]),R([yd,Md,Tp,If,Ef,lf,df,hf,Uf,Hf,qd,Xd,Ud]);var $=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===Q.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Ap(e.elicitations,n)}return new e(t,n,r)}},Ap=class extends ${constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function jp(e){return e===`completed`||e===`failed`||e===`cancelled`}function Mp(e){return!e||e===`jsonSchema7`||e===`draft-7`?`draft-7`:e===`jsonSchema2019-09`||e===`draft-2020-12`?`draft-2020-12`:`draft-7`}function Np(e,t){return Bu(e)?No(e,{target:Mp(t?.target),io:t?.pipeStrategy??`input`}):hl(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??`input`})}function Pp(e){let t=Wu(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Yu(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Fp(e,t){let n=Hu(e,t);if(!n.success)throw n.error;return n.data}var Ip=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(xd,e=>{this._oncancel(e)}),this.setNotificationHandler(Ld,e=>{this._onprogress(e)}),this.setRequestHandler(Pd,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Kd,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(Jd,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new $(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new $(Q.InvalidParams,`Task not found: ${r}`);if(!jp(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(jp(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[Qu]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Yd,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new $(Q.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Zd,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Task not found: ${e.params.taskId}`);if(jp(n.status))throw new $(Q.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new $(Q.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof $?e:new $(Q.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),$.fromError(Q.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),hd(e)||_d(e)?this._onresponse(e):dd(e)?this._onrequest(e,t):pd(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=$.fromError(Q.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Qu]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:Q.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=od(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new $(Q.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Q.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),hd(e)?n(e):n(new $(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(hd(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),hd(e)?r(e):r($.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Ud,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new $(Q.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},jp(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new $(Q.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new $(Q.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Qu]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof $?e:new $(Q.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Hu(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p($.fromError(Q.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let ee=s?.taskId;ee?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(ee,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},qd,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},Xd,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},Qd,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[Qu]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[Qu]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[Qu]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Pp(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Fp(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Pp(e);this._notificationHandlers.set(n,n=>{let r=Fp(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&dd(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new $(Q.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new $(Q.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new $(Q.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=Gd.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),jp(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new $(Q.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(jp(a.status))throw new $(Q.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=Gd.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),jp(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Lp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Rp(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];Lp(a)&&Lp(i)?n[r]={...a,...i}:n[r]=i}return n}var zp=class{compile(e){throw Error(`[WebMCP] Ajv stub was invoked. This indicates the MCP SDK is bypassing PolyfillJsonSchemaValidator. Please report this as a bug.`)}getSchema(e){}errorsText(e){return``}};function Bp(){return new zp({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0})}var Vp=class{constructor(e){this._ajv=e??Bp()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}};function Hp(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`tools/call`:if(!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Up(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var Wp=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}},Gp=class extends Ip{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(qf.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Vp,this.setRequestHandler(Ad,e=>this._oninitialize(e)),this.setNotificationHandler(Nd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Yf,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=qf.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||={tasks:new Wp(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Rp(this._capabilities,e)}setRequestHandler(e,t){let n=Wu(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(Bu(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=Hu(Gf,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new $(Q.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=Hu(Ud,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new $(Q.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=Hu(Uf,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new $(Q.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){Up(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&Hp(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Zu.includes(t)?t:Xu,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},yd)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},sp,t):this.request({method:`sampling/createMessage`,params:e},op,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},vp,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},vp,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new $(Q.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof $?e:new $(Q.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},Op,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};let Kp=Symbol.for(`mcp.completable`);function qp(e){return!!e&&typeof e==`object`&&Kp in e}function Jp(e){return e[Kp]?.complete}var Yp;(function(e){e.Completable=`McpCompletable`})(Yp||={});let Xp=/^[A-Za-z0-9._-]{1,128}$/;function Zp(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!Xp.test(e)){let n=e.split(``).filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function Qp(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function $p(e){let t=Zp(e);return Qp(e,t.warnings),t.isValid}var em=class{constructor(e){this._mcpServer=e}registerToolTask(e,t,n){let r={taskSupport:`required`,...t.execution};if(r.taskSupport===`forbidden`)throw Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,r,t._meta,n)}},tm=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Gp(e,t)}get experimental(){return this._experimental||={tasks:new em(this)},this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(cm(Vf)),this.server.assertCanSetRequestHandler(cm(Gf)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Vf,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:(()=>{let e=Gu(t.inputSchema);return e?Np(e,{strictUnions:!0,pipeStrategy:`input`}):nm})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){let e=Gu(t.outputSchema);e&&(n.outputSchema=Np(e,{strictUnions:!0,pipeStrategy:`output`}))}return n})})),this.server.setRequestHandler(Gf,async(e,t)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new $(Q.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Tool ${e.params.name} disabled`);let r=!!e.params.task,i=n.execution?.taskSupport,a=`createTask`in n.handler;if((i===`required`||i===`optional`)&&!a)throw new $(Q.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i===`required`&&!r)throw new $(Q.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i===`optional`&&!r&&a)return await this.handleAutomaticTaskPolling(n,e,t);let o=await this.validateToolInput(n,e.params.arguments,e.params.name),s=await this.executeToolHandler(n,o,t);return r||await this.validateToolOutput(n,s,e.params.name),s}catch(e){if(e instanceof $&&e.code===Q.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await Uu(Gu(e.inputSchema)??e.inputSchema,t);if(!r.success){let e=Ku(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${e}`)}return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||!(`content`in t)||t.isError)return;if(!t.structuredContent)throw new $(Q.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Uu(Gu(e.outputSchema),t.structuredContent);if(!r.success){let e=Ku(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${e}`)}}async executeToolHandler(e,t,n){let r=e.handler;if(`createTask`in r){if(!n.taskStore)throw Error(`No task store provided.`);let i={...n,taskStore:n.taskStore};if(e.inputSchema){let e=r;return await Promise.resolve(e.createTask(t,i))}else{let e=r;return await Promise.resolve(e.createTask(i))}}if(e.inputSchema){let e=r;return await Promise.resolve(e(t,n))}else{let e=r;return await Promise.resolve(e(n))}}async handleAutomaticTaskPolling(e,t,n){if(!n.taskStore)throw Error(`No task store provided for task-capable tool.`);let r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,a={...n,taskStore:n.taskStore},o=r?await Promise.resolve(i.createTask(r,a)):await Promise.resolve(i.createTask(a)),s=o.task.taskId,c=o.task,l=c.pollInterval??5e3;for(;c.status!==`completed`&&c.status!==`failed`&&c.status!==`cancelled`;){await new Promise(e=>setTimeout(e,l));let e=await n.taskStore.getTask(s);if(!e)throw new $(Q.InternalError,`Task ${s} not found during polling`);c=e}return await n.taskStore.getTaskResult(s)}setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(cm(Sp)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Sp,async e=>{switch(e.params.ref.type){case`ref/prompt`:return Cp(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return wp(e),this.handleResourceCompletion(e,e.params.ref);default:throw new $(Q.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return um;let r=Wu(n.argsSchema)?.[e.params.argument.name];if(!qp(r))return um;let i=Jp(r);return i?lm(await i(e.params.argument.value,e.params.context)):um}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return um;throw new $(Q.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?lm(await r(e.params.argument.value,e.params.context)):um}setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(cm(cf)),this.server.assertCanSetRequestHandler(cm(uf)),this.server.assertCanSetRequestHandler(cm(mf)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(cf,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(uf,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(mf,async(e,t)=>{let n=new URL(e.params.uri),r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new $(Q.InvalidParams,`Resource ${n} disabled`);return r.readCallback(n,t)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return e.readCallback(n,r,t)}throw new $(Q.InvalidParams,`Resource ${n} not found`)}),!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(cm(Tf)),this.server.assertCanSetRequestHandler(cm(Of)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Tf,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?sm(t.argsSchema):void 0}))})),this.server.setRequestHandler(Of,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let r=await Uu(Gu(n.argsSchema),e.params.arguments);if(!r.success){let t=Ku(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}let i=r.data,a=n.callback;return await Promise.resolve(a(i,t))}else{let e=n.callback;return await Promise.resolve(e(t))}}),!0)}resource(e,t,...n){let r;typeof n[0]==`object`&&(r=n.shift());let i=n[0];if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let n=this._createRegisteredResource(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let n=this._createRegisteredResourceTemplate(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}registerResource(e,t,n,r){if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let i=this._createRegisteredResource(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i){let a={title:t,description:n,argsSchema:r===void 0?void 0:Vu(r),callback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.description!==void 0&&(a.description=t.description),t.argsSchema!==void 0&&(a.argsSchema=Vu(t.argsSchema)),t.callback!==void 0&&(a.callback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=a,r&&Object.values(r).some(e=>qp(e instanceof Ys?e._def?.innerType:e))&&this.setCompletionRequestHandler(),a}_createRegisteredTool(e,t,n,r,i,a,o,s,c){$p(e);let l={title:t,description:n,inputSchema:om(r),outputSchema:om(i),annotations:a,execution:o,_meta:s,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&$p(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.paramsSchema!==void 0&&(l.inputSchema=Vu(t.paramsSchema)),t.outputSchema!==void 0&&(l.outputSchema=Vu(t.outputSchema)),t.callback!==void 0&&(l.handler=t.callback),t.annotations!==void 0&&(l.annotations=t.annotations),t._meta!==void 0&&(l._meta=t._meta),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let n,r,i;if(typeof t[0]==`string`&&(n=t.shift()),t.length>1){let e=t[0];am(e)?(r=t.shift(),t.length>1&&typeof t[0]==`object`&&t[0]!==null&&!am(t[0])&&(i=t.shift())):typeof e==`object`&&e&&(i=t.shift())}let a=t[0];return this._createRegisteredTool(e,void 0,n,r,void 0,i,{taskSupport:`forbidden`},void 0,a)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,_meta:c}=t;return this._createRegisteredTool(e,r,i,a,o,s,{taskSupport:`forbidden`},c,n)}prompt(e,...t){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let n;typeof t[0]==`string`&&(n=t.shift());let r;t.length>1&&(r=t.shift());let i=t[0],a=this._createRegisteredPrompt(e,void 0,n,r,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a}=t,o=this._createRegisteredPrompt(e,r,i,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};let nm={type:`object`,properties:{}};function rm(e){return typeof e==`object`&&!!e&&`parse`in e&&typeof e.parse==`function`&&`safeParse`in e&&typeof e.safeParse==`function`}function im(e){return`_def`in e||`_zod`in e||rm(e)}function am(e){return typeof e!=`object`||!e||im(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(rm)}function om(e){if(e)return am(e)?Vu(e):e}function sm(e){let t=Wu(e);return t?Object.entries(t).map(([e,t])=>({name:e,description:qu(t),required:!Ju(t)})):[]}function cm(e){let t=Wu(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Yu(t);if(typeof n==`string`)return n;throw Error(`Schema method literal must be a string`)}function lm(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}let um={completion:{values:[],hasMore:!1}};var dm=class{getValidator(e){return t=>{if(!J(t))return{valid:!1,data:void 0,errorMessage:`expected object arguments`};let n=yu(t,e);return n?{valid:!1,data:void 0,errorMessage:n.message}:{valid:!0,data:t,errorMessage:void 0}}}};let fm={type:`object`,properties:{}};function pm(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function mm(e){return pm(e)&&Array.isArray(e.content)}function hm(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function gm(e){if(!e||typeof e!=`object`)return!1;let{name:t,message:n}=e;return t===`SecurityError`&&typeof n==`string`&&/permissions policy|feature "tools" is disallowed/i.test(n)}function _m(e){return hm(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>_m(e)):pm(e)?Object.values(e).every(e=>_m(e)):!1}function vm(e){if(!(!pm(e)||!_m(e)))return e}function ym(e){return!!e&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`}function bm(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function xm(e){if(mm(e))return e;let t=vm(e);return{content:[{type:`text`,text:bm(e)}],...t?{structuredContent:t}:{},isError:!1}}function Sm(e){return e?.signal?e:{...e,signal:AbortSignal.timeout(1e4)}}var Cm=class extends tm{__isBrowserMcpServer=!0;native;_promptSchemas=new Map;_jsonValidator;_publicMethodsBound=!1;_unregisterToolDeprecationWarned=!1;_nativeToolCleanups=new Map;_producerEventTarget=new EventTarget;_ontoolchange=null;constructor(e,t){let n=new dm,r={capabilities:Rp(t?.capabilities||{},{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}),jsonSchemaValidator:t?.jsonSchemaValidator??n};super(e,r),this._jsonValidator=n,this.native=t?.native,this.bindPublicApiMethods()}bindPublicApiMethods(){this._publicMethodsBound||=(this.registerTool=this.registerTool.bind(this),this.unregisterTool=this.unregisterTool.bind(this),this.listTools=this.listTools.bind(this),this.getTools=this.getTools.bind(this),this.callTool=this.callTool.bind(this),this.executeTool=this.executeTool.bind(this),this.addEventListener=this.addEventListener.bind(this),this.removeEventListener=this.removeEventListener.bind(this),this.dispatchEvent=this.dispatchEvent.bind(this),this.registerResource=this.registerResource.bind(this),this.listResources=this.listResources.bind(this),this.readResource=this.readResource.bind(this),this.registerPrompt=this.registerPrompt.bind(this),this.listPrompts=this.listPrompts.bind(this),this.getPrompt=this.getPrompt.bind(this),this.createMessage=this.createMessage.bind(this),this.elicitInput=this.elicitInput.bind(this),!0)}get _parentTools(){return this._registeredTools}get _parentResources(){return this._registeredResources}get _parentPrompts(){return this._registeredPrompts}toTransportSchema(e,t=!0){if(!e||typeof e!=`object`)return t?(console.warn(`[BrowserMcpServer] toTransportSchema received non-object schema (${typeof e}), using default`),fm):{};let n=Gu(e),r=n?Np(n,{strictUnions:!0,pipeStrategy:`input`}):e;return Object.keys(r).length===0?t?fm:r:t&&r.type===void 0?{type:`object`,...r}:r}isZodSchema(e){if(!e||typeof e!=`object`)return!1;let t=e;return`_zod`in t||`_def`in t}getNativeToolsApi(){if(!this.native)return;let e=this.native;if(!(typeof e.listTools!=`function`||typeof e.callTool!=`function`))return e}getNativeUnregisterTool(){if(!this.native)return;let e=this.native.unregisterTool;if(typeof e==`function`)return t=>e.call(this.native,t)}createNativeToolCleanup(e){let t=new AbortController,n;if(e){let r=()=>{t.abort()};e.aborted?r():(e.addEventListener(`abort`,r,{once:!0}),n=()=>e.removeEventListener(`abort`,r))}return{options:{signal:t.signal},abort:()=>{n?.(),t.signal.aborted||t.abort()}}}registerNativeToolMirror(e,t){if(!this.native)return;let n=this.native.registerTool,r=this.getNativeUnregisterTool(),i=t||!r?this.createNativeToolCleanup(t):void 0,a;try{a=i?n.call(this.native,e,i.options):n.call(this.native,e)}catch(e){if(i?.abort(),gm(e)){console.warn(`[BrowserMcpServer] Native WebMCP tool mirror is blocked by permissions policy; continuing with WebMCP transport registration only.`);return}throw e}if(!i)return;let o={abort:i.abort,nativeSignalAccepted:n.length>=2||!r};return this._nativeToolCleanups.set(e.name,o),ym(a)&&a.then(void 0,t=>{if(i.abort(),this._nativeToolCleanups.get(e.name)===o&&this._nativeToolCleanups.delete(e.name),gm(t)){console.warn(`[BrowserMcpServer] Native WebMCP tool mirror is blocked by permissions policy; continuing with WebMCP transport registration only.`);return}console.warn(`[BrowserMcpServer] Native WebMCP tool mirror registration rejected; continuing with WebMCP transport registration only.`,t)}),o}unregisterNativeToolMirror(e,t){let n=this._nativeToolCleanups.get(e);this._nativeToolCleanups.delete(e);let r=this.getNativeUnregisterTool();if(t?.preferAbortSignal&&n?.nativeSignalAccepted===!0||!r){n?.abort();return}try{r(e)}finally{n?.abort()}}registerToolInServer(e){let t=this.toTransportSchema(e.inputSchema);return super.registerTool(e.name,{description:e.description,inputSchema:t,...e.outputSchema?{outputSchema:e.outputSchema}:{},...e.annotations?{annotations:e.annotations}:{}},async t=>xm(await e.execute(t,{requestUserInteraction:async e=>e()}))),this.notifyProducerToolsChanged(),{unregister:()=>this.unregisterTool(e.name)}}get ontoolchange(){return this._ontoolchange}set ontoolchange(e){this._ontoolchange=e}addEventListener(e,t,n){this._producerEventTarget.addEventListener(e,t,n)}removeEventListener(e,t,n){this._producerEventTarget.removeEventListener(e,t,n)}dispatchEvent(e){return this._producerEventTarget.dispatchEvent(e)}notifyProducerToolsChanged(){queueMicrotask(()=>{let e=new Event(`toolchange`);try{this._ontoolchange?.call(this,e)}catch(e){console.warn(`[BrowserMcpServer] navigator.modelContext.ontoolchange handler threw:`,e)}this.dispatchEvent(e)})}backfillTools(e,t){let n=0;for(let r of e){if(!r?.name||this._parentTools[r.name])continue;let e={name:r.name,description:r.description??``,inputSchema:r.inputSchema??fm,execute:async e=>t(r.name,e)};r.outputSchema&&(e.outputSchema=r.outputSchema),r.annotations&&(e.annotations=r.annotations),this.registerToolInServer(e),n++}return n}registerTool(e,t){let n=t?.signal;if(n?.aborted)return console.warn(`[BrowserMcpServer] registerTool("${e?.name??`<unknown>`}") skipped: options.signal was already aborted.`),{unregister:()=>{}};this.registerNativeToolMirror(e,n);let r;try{r=this.registerToolInServer(e)}catch(t){if(this.native)try{this.unregisterNativeToolMirror(e.name)}catch(e){console.error(`[BrowserMcpServer] Rollback of native tool registration failed:`,e)}throw t}return n&&n.addEventListener(`abort`,()=>{this._parentTools[e.name]?.remove();try{this.unregisterNativeToolMirror(e.name,{preferAbortSignal:!0})}catch(e){console.warn(`[BrowserMcpServer] Native unregister via abort fallback failed:`,e)}this.notifyProducerToolsChanged()},{once:!0}),r}syncNativeTools(){let e=this.getNativeToolsApi();if(!e)return 0;let t=e.callTool.bind(e);return this.backfillTools(e.listTools(),async(e,n)=>t({name:e,arguments:n}))}unregisterTool(e){this.warnUnregisterToolDeprecationOnce();let t=this.resolveToolNameForUnregister(e),n=this._parentTools[t];n?.remove(),this.native&&this.unregisterNativeToolMirror(t),n&&this.notifyProducerToolsChanged()}registerResource(e){let t=super.registerResource(e.name,e.uri,{...e.description!==void 0&&{description:e.description},...e.mimeType!==void 0&&{mimeType:e.mimeType}},async t=>({contents:(await e.read(t)).contents}));return{unregister:()=>t.remove()}}registerPrompt(e){e.argsSchema&&this._promptSchemas.set(e.name,e.argsSchema);let t=super.registerPrompt(e.name,{...e.description!==void 0&&{description:e.description}},async t=>({messages:(await e.get(t)).messages}));return{unregister:()=>{this._promptSchemas.delete(e.name),t.remove()}}}resolveToolNameForUnregister(e){if(typeof e==`string`)return e;if(pm(e)&&typeof e.name==`string`)return e.name;throw TypeError(`Failed to execute 'unregisterTool' on 'ModelContext': parameter 1 must be a string or an object with a string name.`)}warnUnregisterToolDeprecationOnce(){this._unregisterToolDeprecationWarned||(this._unregisterToolDeprecationWarned=!0,console.warn(`[BrowserMcpServer] navigator.modelContext.unregisterTool() is deprecated. The April 23, 2026 WebMCP draft removed it in favor of registerTool(tool, { signal }) — pass an AbortSignal and abort it to unregister.`))}listResources(){return Object.entries(this._parentResources).filter(([,e])=>e.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata}))}async readResource(e){let t=this._parentResources[e];if(!t)throw Error(`Resource not found: ${e}`);return t.readCallback(new URL(e),{})}listPrompts(){return Object.entries(this._parentPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let n=this._promptSchemas.get(e);return{name:e,...t.description!==void 0&&{description:t.description},...n?.properties?{arguments:Object.entries(n.properties).map(([e,t])=>({name:e,...typeof t==`object`&&t&&`description`in t?{description:t.description}:{},...n.required?.includes(e)?{required:!0}:{}}))}:{}}})}async getPrompt(e,t={}){let n=this._parentPrompts[e];if(!n)throw Error(`Prompt not found: ${e}`);let r=this._promptSchemas.get(e);if(r){let n=this._jsonValidator.getValidator(r)(t);if(!n.valid)throw Error(`Invalid arguments for prompt ${e}: ${n.errorMessage}`)}return n.callback(t,{})}listTools(){return Object.entries(this._parentTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,description:t.description??``,inputSchema:this.toTransportSchema(t.inputSchema??fm)};return t.outputSchema&&(n.outputSchema=this.toTransportSchema(t.outputSchema,!1)),t.annotations&&(n.annotations=t.annotations),n})}async getTools(){let e=typeof globalThis.location==`object`&&typeof globalThis.location?.origin==`string`?globalThis.location.origin:``,t=typeof globalThis.window==`object`?globalThis.window:void 0;return this.listTools().map(n=>{let r;try{r=JSON.stringify(n.inputSchema??fm)}catch{r=JSON.stringify(fm)}return{name:n.name,title:typeof n.annotations?.title==`string`?n.annotations.title:n.description??``,description:n.description??``,inputSchema:r,origin:e,window:t}})}async validateToolInput(e,t,n){if(!e.inputSchema)return;if(this.isZodSchema(e.inputSchema)){let r=await Uu(e.inputSchema,t??{});if(!r.success)throw Error(`Invalid arguments for tool ${n}: ${Ku(r.error)}`);return r.data}let r=this._jsonValidator.getValidator(e.inputSchema)(t??{});if(!r.valid)throw Error(`Invalid arguments for tool ${n}: ${r.errorMessage}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema)return;let r=t;if(!(`content`in r)||r.isError||!r.structuredContent)return;if(this.isZodSchema(e.outputSchema)){let t=await Uu(e.outputSchema,r.structuredContent);if(!t.success)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${Ku(t.error)}`);return}let i=this._jsonValidator.getValidator(e.outputSchema)(r.structuredContent);if(!i.valid)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${i.errorMessage}`)}async callTool(e){let t=this._parentTools[e.name];if(!t)throw Error(`Tool not found: ${e.name}`);return t.handler(e.arguments??{},{})}async executeTool(e,t={}){if(typeof e==`string`)return this.callTool({name:e,arguments:typeof t==`string`?JSON.parse(t):t});let n=await this.callTool({name:e.name,arguments:typeof t==`string`?JSON.parse(t):t}),r=JSON.stringify(n);return r===void 0?null:r}async connect(e){return this.setToolRequestHandlers(),this.setResourceRequestHandlers(),this.setPromptRequestHandlers(),this.server.setRequestHandler(Vf,()=>({tools:this.listTools()})),this.server.setRequestHandler(Tf,()=>({prompts:this.listPrompts()})),this.server.setRequestHandler(Of,async e=>{let t=this._parentPrompts[e.params.name];if(!t)throw Error(`Prompt ${e.params.name} not found`);if(!t.enabled)throw Error(`Prompt ${e.params.name} disabled`);let n=this._promptSchemas.get(e.params.name);if(n){let r=this._jsonValidator.getValidator(n)(e.params.arguments??{});if(!r.valid)throw Error(`Invalid arguments for prompt ${e.params.name}: ${r.errorMessage}`);return t.callback(e.params.arguments,{})}return t.callback({},{})}),super.connect(e)}async createMessage(e,t){return this.server.createMessage(e,Sm(t))}async elicitInput(e,t){return this.server.elicitInput(e,Sm(t))}};(function(e){return e.START=`start`,e.STARTED=`started`,e.STOP=`stop`,e.STOPPED=`stopped`,e.PING=`ping`,e.PONG=`pong`,e.ERROR=`error`,e.LIST_TOOLS=`list_tools`,e.CALL_TOOL=`call_tool`,e.TOOL_LIST_UPDATED=`tool_list_updated`,e.TOOL_LIST_UPDATED_ACK=`tool_list_updated_ack`,e.PROCESS_DATA=`process_data`,e.SERVER_STARTED=`server_started`,e.SERVER_STOPPED=`server_stopped`,e.ERROR_FROM_NATIVE_HOST=`error_from_native_host`,e.CONNECT_NATIVE=`connectNative`,e.PING_NATIVE=`ping_native`,e.DISCONNECT_NATIVE=`disconnect_native`,e})({}),{NAME:`com.chromemcp.nativehost`,DEFAULT_PORT:12306}.NAME;var wm=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;_serverReadyTimeout;_serverReadyRetryMs;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-iframe`,this._serverReadyRetryMs=e.serverReadyRetryMs??250}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){this.broadcastServerReady();return}try{let e=vd.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this.broadcastServerReady()}broadcastServerReady(){window.parent&&window.parent!==window?(window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`),this.clearServerReadyRetry()):this.scheduleServerReadyRetry()}scheduleServerReadyRetry(){this._serverReadyTimeout||=setTimeout(()=>{this._serverReadyTimeout=void 0,this._started&&this.broadcastServerReady()},this._serverReadyRetryMs)}clearServerReadyRetry(){this._serverReadyTimeout&&=(clearTimeout(this._serverReadyTimeout),void 0)}async send(e){if(!this._started)throw Error(`Transport not started`);this._clientOrigin&&window.parent&&window.parent!==window&&window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this._clientOrigin)}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._started=!1,this._clientOrigin&&window.parent&&window.parent!==window&&window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.clearServerReadyRetry(),this.onclose?.()}},Tm=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_beforeUnloadHandler;_cleanupInterval;_pendingRequests=new Map;SELF_TARGET_ORIGIN=`*`;REQUEST_TIMEOUT_MS=3e5;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-default`}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},this.SELF_TARGET_ORIGIN);return}try{let e=vd.parse(t);`method`in e&&`id`in e&&e.id!==void 0&&this._pendingRequests.set(e.id,{request:e,receivedAt:Date.now(),interruptedSent:!1}),this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._beforeUnloadHandler=()=>{this._handleBeforeUnload()},window.addEventListener(`beforeunload`,this._beforeUnloadHandler),this._cleanupInterval=setInterval(()=>{this._cleanupStaleRequests()},6e4),window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},this.SELF_TARGET_ORIGIN)}async send(e){if(!this._started)throw Error(`Transport not started`);if((`result`in e||`error`in e)&&e.id!==void 0){if(this._pendingRequests.get(e.id)?.interruptedSent){`${e.id}`,this._pendingRequests.delete(e.id);return}this._pendingRequests.delete(e.id)}window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this.SELF_TARGET_ORIGIN)}_handleBeforeUnload(){let e=Array.from(this._pendingRequests.entries()).reverse();for(let[t,n]of e){n.interruptedSent=!0;let e={jsonrpc:`2.0`,id:t,result:{content:[{type:`text`,text:`Tool execution interrupted by page navigation`}],metadata:{navigationInterrupted:!0,originalMethod:`method`in n.request?n.request.method:`unknown`,timestamp:Date.now()}}};try{window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this.SELF_TARGET_ORIGIN)}catch(e){console.error(`[TabServerTransport] Failed to send beforeunload response:`,e)}}this._pendingRequests.clear()}_cleanupStaleRequests(){let e=Date.now(),t=[];for(let[n,r]of this._pendingRequests)e-r.receivedAt>this.REQUEST_TIMEOUT_MS&&t.push(n);if(t.length>0){console.warn(`[TabServerTransport] Cleaning up ${t.length} stale requests`);for(let e of t)this._pendingRequests.delete(e)}}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._beforeUnloadHandler&&window.removeEventListener(`beforeunload`,this._beforeUnloadHandler),this._cleanupInterval!==void 0&&clearInterval(this._cleanupInterval),this._pendingRequests.clear(),this._started=!1,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},this.SELF_TARGET_ORIGIN),this.onclose?.()}};let Em=null;function Dm(){return typeof window<`u`&&window.navigator!==void 0}function Om(){return Object.getOwnPropertyDescriptor(navigator,`modelContext`)?navigator.modelContext:document.modelContext??navigator.modelContext}function km(e){try{Object.defineProperty(document,`modelContext`,{configurable:!0,enumerable:!0,writable:!1,value:e})}catch{Object.defineProperty(Object.getPrototypeOf(document),`modelContext`,{configurable:!0,enumerable:!0,get(){return e}})}document.modelContext!==e&&console.error(`[WebModelContext] Failed to replace document.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(document,`modelContext`))}function Am(e){try{Object.defineProperty(navigator,`modelContext`,{configurable:!0,enumerable:!0,writable:!1,value:e})}catch{Object.defineProperty(Object.getPrototypeOf(navigator),`modelContext`,{configurable:!0,enumerable:!0,get(){return e}})}navigator.modelContext!==e&&console.error(`[WebModelContext] Failed to replace navigator.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(navigator,`modelContext`))}function jm(e){km(e),Am(e)}function Mm(e){if(window.parent!==window&&e?.iframeServer!==!1){let{allowedOrigins:t,...n}=typeof e?.iframeServer==`object`?e.iframeServer:{};return new wm({allowedOrigins:t??[`*`],...n})}if(e?.tabServer===!1)throw Error(`tabServer transport is disabled and iframe transport was not selected`);let{allowedOrigins:t,...n}=typeof e?.tabServer==`object`?e.tabServer:{};return new Tm({allowedOrigins:t??[`*`],...n})}function Nm(e){if(e)try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:t}catch(e){console.warn(`[WebMCP] Failed to parse testing inputSchema JSON:`,e);return}}function Pm(){let e=navigator.modelContextTesting;if(e){if(typeof e.getRegisteredTools==`function`)return{testingShim:e,tools:e.getRegisteredTools()};if(typeof e.listTools==`function`)return{testingShim:e,tools:e.listTools().map(e=>({name:e.name,description:e.description??``,inputSchema:Nm(e.inputSchema)??{type:`object`,properties:{}}}))}}}function Fm(e){let t=Pm();if(!t)return 0;let{testingShim:n,tools:r}=t;return e.backfillTools(r,async(e,t)=>{let r=await n.executeTool(e,JSON.stringify(t??{}));if(r===null)return{content:[{type:`text`,text:`Tool execution interrupted by navigation`}],isError:!0};let i;try{i=JSON.parse(r)}catch(t){throw Error(`Failed to parse serialized tool response for ${e}: ${t instanceof Error?t.message:String(t)}`)}if(!i||typeof i!=`object`||Array.isArray(i))throw Error(`Invalid serialized tool response for ${e}`);return i})}function Im(e){if(!Dm()||Em||Om()?.__isBrowserMcpServer)return;Ru({installTestingShim:e?.installTestingShim??`if-missing`});let t=Om();if(!t)throw Error(`modelContext is not available`);let n=new Cm({name:`${window.location.hostname||`localhost`}-webmcp`,version:`1.0.0`},{native:t});n.syncNativeTools(),Fm(n);let r=Object.getOwnPropertyDescriptor(document,`modelContext`),i=Object.getOwnPropertyDescriptor(navigator,`modelContext`);jm(n);let a=Mm(e?.transport);Em={native:t,server:n,transport:a,previousDocumentModelContextDescriptor:r,previousNavigatorModelContextDescriptor:i},n.connect(a).catch(e=>{console.error(`[WebModelContext] Failed to connect MCP transport:`,e)})}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions;if(e?.autoInitialize!==!1)try{Im(e)}catch(e){console.error(`[WebModelContext] Auto-initialization failed:`,e)}}function Lm(e,t){let n=new URL(e.path,window.location.origin);for(let[r,i]of Object.entries(t)){if(i==null)continue;if(Array.isArray(i)){let e=r.endsWith(`s`)?r.slice(0,-1):r;for(let t of i)t!=null&&n.searchParams.append(e,String(t));continue}let t=e.name===`search_site`&&r===`query`?`q`:r;n.searchParams.set(t,String(i))}return n.toString()}function Rm(e,t){e.registerTool({name:t.name,description:t.description,inputSchema:t.inputSchema,annotations:{readOnlyHint:!0,openWorldHint:!1},execute:async e=>{try{let n=await fetch(Lm(t,e),{headers:{Accept:`application/json`}}),r=await n.text();return n.ok?{content:[{type:`text`,text:r}]}:{content:[{type:`text`,text:`Error ${n.status}: ${r}`}],isError:!0}}catch(e){return{content:[{type:`text`,text:`Request failed: ${String(e)}`}],isError:!0}}}})}function zm(){if(typeof navigator>`u`||typeof window>`u`)return;try{Im()}catch(e){console.error(`[webmcp] polyfill init failed:`,e);return}let e=navigator.modelContext;if(!(!e||typeof e.registerTool!=`function`))for(let n of t)try{Rm(e,n)}catch(e){console.error(`[webmcp] failed to register ${n.name}:`,e)}}zm()})();