@fungi.computer/grove 0.0.0-stage → 0.1.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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -2
  3. package/dist/assets/Effect-CxgtVs4O.js +76 -0
  4. package/dist/assets/MapleMono-VF-CCDrizxw.woff2 +0 -0
  5. package/dist/assets/Nunito-VF-8c6a9bb-cyrillic-BsWUdSU9.woff2 +0 -0
  6. package/dist/assets/Nunito-VF-8c6a9bb-cyrillic-ext-Cb1j0nGJ.woff2 +0 -0
  7. package/dist/assets/Nunito-VF-8c6a9bb-latin-BYs3GYNf.woff2 +0 -0
  8. package/dist/assets/Nunito-VF-8c6a9bb-latin-ext-0RvtKGDy.woff2 +0 -0
  9. package/dist/assets/Nunito-VF-8c6a9bb-vietnamese-cS2dauUA.woff2 +0 -0
  10. package/dist/assets/anthropic-messages-DVt3Yh9K.js +41 -0
  11. package/dist/assets/azure-openai-responses-QZaJy-8U.js +1 -0
  12. package/dist/assets/base-face-BaB6vmvy.js +1 -0
  13. package/dist/assets/burger-CoqBXzRV.js +1 -0
  14. package/dist/assets/cat-2dRm7fBw.js +1 -0
  15. package/dist/assets/cloudflare-workers-ai-system-one-Bq-3_D9p.js +1 -0
  16. package/dist/assets/compat-fz0ZcRJH.js +2 -0
  17. package/dist/assets/diagnostics-CmW2yJSB.js +1 -0
  18. package/dist/assets/document-D5hwZS3o.js +1 -0
  19. package/dist/assets/error-CJ3RHG07.js +1 -0
  20. package/dist/assets/error-body-pkrba6pf.js +1 -0
  21. package/dist/assets/extension-hook-0UB2lkEs.js +560 -0
  22. package/dist/assets/extensions-CAsZR9ky.js +1 -0
  23. package/dist/assets/github-copilot-headers-DRgtIyTm.js +1 -0
  24. package/dist/assets/google-generative-ai-DP-8xZvz.js +1 -0
  25. package/dist/assets/google-shared-Cs5udoZV.js +8 -0
  26. package/dist/assets/google-vertex-BJiAIGUd.js +1 -0
  27. package/dist/assets/hash-yQufAZII.js +1 -0
  28. package/dist/assets/headers-FK4rgixo.js +1 -0
  29. package/dist/assets/index-Bw6tV9qS.css +1 -0
  30. package/dist/assets/index-DRDNbHYF.js +171 -0
  31. package/dist/assets/json-parse-nqKewMRF.js +3 -0
  32. package/dist/assets/mistral-conversations-mRYg3mWw.js +4 -0
  33. package/dist/assets/models-CcNnosqL.js +1 -0
  34. package/dist/assets/mushroom-B9t9hgQE.js +1 -0
  35. package/dist/assets/node.browser-DFtqp6Hr.js +1 -0
  36. package/dist/assets/node.browser-hsQQ6fyG.js +1 -0
  37. package/dist/assets/openai-Cpe0uoXQ.js +19 -0
  38. package/dist/assets/openai-codex-responses-CA-ivUEd.js +9 -0
  39. package/dist/assets/openai-completions-BxBCgHHI.js +5 -0
  40. package/dist/assets/openai-prompt-cache-DXo9f3w5.js +1 -0
  41. package/dist/assets/openai-responses-cvwOEFWg.js +1 -0
  42. package/dist/assets/openai-responses-shared-DzD8B6NI.js +10 -0
  43. package/dist/assets/openrouter-images-DwousKhc.js +1 -0
  44. package/dist/assets/parakeet-conversation-COndlivb.css +1 -0
  45. package/dist/assets/parakeet-conversation-w0nznEs9.js +3 -0
  46. package/dist/assets/pi-messages-CfXPQ4jp.js +7 -0
  47. package/dist/assets/preload-helper-mbhLTglw.js +8 -0
  48. package/dist/assets/provider-env-CcCbsTJq.js +1 -0
  49. package/dist/assets/provider-retry-CSlu6hjs.js +1 -0
  50. package/dist/assets/renderer-s3PB0XrL.js +1 -0
  51. package/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
  52. package/dist/assets/runtime-core-GKyHklNK.js +2 -0
  53. package/dist/assets/sanitize-unicode-DmIE6hZJ.js +1 -0
  54. package/dist/assets/system-one-shared-CGF8IYMZ.js +1 -0
  55. package/dist/assets/transform-messages-CrQEqmfx.js +1 -0
  56. package/dist/assets/typesafe-system-one-CWcJw-Ys.js +1 -0
  57. package/dist/index.html +19 -0
  58. package/package.json +175 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jamstack Consulting LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # Grove (`@fungi.computer/grove`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Grove is where you talk to your agents: an inbox of conversations, and agents
4
+ that answer by calling your other Apps.
5
+
6
+ ![Grove: the conversation list beside a finished conversation in which the agent ran three scripts against Bonsai and listed the repositories with open changes](docs/media/conversation.png)
7
+
8
+ Grove is one of the starter Apps of
9
+ [Oyster](https://github.com/fungi-computer/oyster), the open App host that runs
10
+ on your own Cloudflare account. On Oyster, agents run on Workers AI, and every
11
+ App you install becomes a tool they can call as code, as in the picture above,
12
+ where the agent calls Bonsai's `repos.list`.
13
+
14
+ ## What you can do
15
+
16
+ - Create an agent with **New Agent**, then start a conversation with it.
17
+ - Read every conversation in one inbox, grouped as **Needs you**, **Working**,
18
+ **Finished** and **Unavailable**. The agent rail counts what needs you.
19
+ - Filter the inbox to one agent by clicking its face.
20
+ - Send a follow-up while the agent works (**Queue**), stop it (**Cancel**),
21
+ retry a failed turn, or fork a conversation from any message.
22
+ - Watch each tool call inline, with its script, timing and result.
23
+ - Collapse the agent rail and the inbox, or drag the inbox wider. On a phone,
24
+ **Agents and conversations** opens both as one sheet.
25
+
26
+ <img alt="Grove in the light theme: the agent rail and the conversation list beside an empty conversation pane" src="docs/media/inbox-light.png">
27
+
28
+ ## Get it
29
+
30
+ Grove installs with the other starter Apps. On a deployed Oyster (see the
31
+ [Oyster quick start](https://github.com/fungi-computer/oyster#quick-start-deploy-your-own-oyster)),
32
+ run:
33
+
34
+ ```sh
35
+ export OYSTER_URL=https://oyster.<your-subdomain>.workers.dev
36
+ export OYSTER_OWNER_KEY=<your owner key>
37
+ npx oyster install-apps
38
+ ```
39
+
40
+ The installer clones this repository and the six others, seeds each on your
41
+ Oyster with `git push`, builds them on your Computer and installs them. Sign in
42
+ at `$OYSTER_URL/login` with the owner key; the Tourtois desktop opens with
43
+ Grove's inbox on it. Run `install-apps` again to update; each App keeps its
44
+ data.
45
+
46
+ ## Change it
47
+
48
+ Every installed App is also a template you can fork on your own Oyster. Fork
49
+ Grove into a Bonsai repository and clone it with ordinary `git`:
50
+
51
+ ```sh
52
+ curl -X POST -H "Authorization: Bearer $OYSTER_OWNER_KEY" -H 'content-type: application/json' \
53
+ -d '{"appId":"app_grove","name":"my-grove"}' \
54
+ $OYSTER_URL/apps/bonsai/methods/apps.fork
55
+ git -c http.extraHeader="Authorization: Bearer $OYSTER_OWNER_KEY" \
56
+ clone $OYSTER_URL/git/bonsai/my-grove.git
57
+ ```
58
+
59
+ The reply names your fork's App id and repository. Push your edits, open the
60
+ repository in Bonsai and choose **Settings**, then **Build & install** with that
61
+ App id and your commit as `git:<sha>`. Install the Release at `grove` to replace
62
+ the running Grove, or at a new id to keep both.
63
+
64
+ To work from GitHub instead, fork this repository and point the installer at
65
+ your forks with `--repositories <base URL>` and `--ref <branch or tag>`. The
66
+ installer reads all seven starter Apps from that base, so fork them under one
67
+ account.
68
+
69
+ ## Agent tools
70
+
71
+ Agents and scripts call Grove through Oyster's MCP endpoint, or at
72
+ `POST $OYSTER_URL/apps/grove/methods/<name>` with a key; see
73
+ [Git, keys and MCP](https://github.com/fungi-computer/oyster#git-keys-and-mcp).
74
+
75
+ | Method | What it does |
76
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------- |
77
+ | `listInbox` | Reads a page of your inbox. |
78
+ | `listSessions({agentId})` | Lists one agent's conversations. |
79
+ | `openInboxItem` | Marks a conversation as seen and returns it. |
80
+ | `sendMessage({..., text})` | Sends a follow-up into an existing conversation without interrupting it, up to ten a minute per conversation. |
81
+
82
+ Grove also puts its inbox on the Tourtois desktop, so you see what needs you
83
+ without opening the App.
84
+
85
+ ## Build and check
86
+
87
+ Grove is a React App built with Vite. Conversations render with Parakeet and
88
+ read their state from [Shiitake](https://github.com/fungi-computer/shiitake)
89
+ sessions; controls come from [Caps](https://github.com/fungi-computer/caps).
90
+
91
+ ```sh
92
+ pnpm install
93
+ pnpm build
94
+ pnpm typecheck
95
+ pnpm test
96
+ ```
97
+
98
+ [src/inbox.tsx](src/inbox.tsx) owns the agent list, the inbox and the open
99
+ conversation. [src/inbox-list.tsx](src/inbox-list.tsx) draws the inbox, and
100
+ [src/conversation-opening.ts](src/conversation-opening.ts) switches
101
+ conversations without losing your draft when a read fails. The agent tools are
102
+ in [backend/methods.ts](backend/methods.ts), and [package.json](package.json)
103
+ declares the permissions the App asks for.
104
+
105
+ ## License
106
+
107
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,76 @@
1
+ var e,t=Object.freeze({status:`aborted`});function n(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 r=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},i=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(e=globalThis).__zod_globalConfig??(e.__zod_globalConfig={});var a=globalThis.__zod_globalConfig;function o(e){return e&&Object.assign(a,e),a}function s(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 c(e,t){return typeof t==`bigint`?t.toString():t}function l(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function u(e){return e==null}function d(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function f(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}var ee=Symbol(`evaluating`);function p(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ee)return r===void 0&&(r=ee,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function m(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function te(e){return JSON.stringify(e)}function ne(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var re=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ie(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ae=l(()=>{if(a.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function oe(e){if(ie(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return ie(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function se(e){return oe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ce=new Set([`string`,`number`,`symbol`]);function le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ue(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function g(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 de(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var fe={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pe(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 ue(e,h(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 m(this,`shape`,e),e},checks:[]}))}function me(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 ue(e,h(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 m(this,`shape`,r),r},checks:[]}))}function he(e,t){if(!oe(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 ue(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return m(this,`shape`,n),n}}))}function ge(e,t){if(!oe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ue(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return m(this,`shape`,n),n}}))}function _e(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return ue(e,h(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return m(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ve(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 ue(t,h(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 m(this,`shape`,i),i},checks:[]}))}function ye(e,t,n){return ue(t,h(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 m(this,`shape`,i),i}}))}function be(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 xe(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 Se(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ce(e){return typeof e==`string`?e:e?.message}function we(e,t,n){let r=e.message?e.message:Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(n.customError?.(e))??Ce(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 Te(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ee(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var De=(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,c,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Oe=n(`$ZodError`,De),ke=n(`$ZodError`,De,{Parent:Error});function Ae(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 je(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}function Me(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ne(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Me(e.path)}`);return t.join(`
2
+ `)}var Pe=e=>(t,n,i,a)=>{let s=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},s);if(c instanceof Promise)throw new r;if(c.issues.length){let t=new((a?.Err)??e)(c.issues.map(e=>we(e,s,o())));throw re(t,a?.callee),t}return c.value},Fe=Pe(ke),Ie=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new((i?.Err)??e)(s.issues.map(e=>we(e,a,o())));throw re(t,i?.callee),t}return s.value},Le=Ie(ke),Re=e=>(t,n,i)=>{let a=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},a);if(s instanceof Promise)throw new r;return s.issues.length?{success:!1,error:new(e??Oe)(s.issues.map(e=>we(e,a,o())))}:{success:!0,data:s.value}},ze=Re(ke),Be=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=>we(e,i,o())))}:{success:!0,data:a.value}},Ve=Be(ke),He=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Pe(e)(t,n,i)},Ue=e=>(t,n,r)=>Pe(e)(t,n,r),We=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ie(e)(t,n,i)},Ge=e=>async(t,n,r)=>Ie(e)(t,n,r),Ke=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Re(e)(t,n,i)},qe=e=>(t,n,r)=>Re(e)(t,n,r),Je=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Be(e)(t,n,i)},Ye=e=>async(t,n,r)=>Be(e)(t,n,r),Xe=/^[cC][0-9a-z]{6,}$/,Ze=/^[0-9a-z]+$/,Qe=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$e=/^[0-9a-vA-V]{20}$/,et=/^[A-Za-z0-9]{27}$/,tt=/^[a-zA-Z0-9_-]{21}$/,nt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rt=/^([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})$/,it=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)$/,at=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ot=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function st(){return new RegExp(ot,`u`)}var ct=/^(?:(?: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])$/,lt=/^(([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}|:))$/,ut=/^((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])$/,dt=/^(([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])$/,ft=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pt=/^[A-Za-z0-9_-]*$/,mt=/^https?$/,ht=/^\+[1-9]\d{6,14}$/,gt=`(?:(?:\\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])))`,_t=RegExp(`^${gt}$`);function vt(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 yt(e){return RegExp(`^${vt(e)}$`)}function bt(e){let t=vt({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(`^${gt}T(?:${r})$`)}var xt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},St=/^-?\d+n?$/,Ct=/^-?\d+$/,wt=/^-?\d+(?:\.\d+)?$/,Tt=/^(?:true|false)$/i,Et=/^null$/i,Dt=/^undefined$/i,Ot=/^[^A-Z]*$/,kt=/^[^a-z]*$/,_=n(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),At={number:`number`,bigint:`bigint`,object:`date`},jt=n(`$ZodCheckLessThan`,(e,t)=>{_.init(e,t);let n=At[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})}}),Mt=n(`$ZodCheckGreaterThan`,(e,t)=>{_.init(e,t);let n=At[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})}}),Nt=n(`$ZodCheckMultipleOf`,(e,t)=>{_.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):f(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})}}),Pt=n(`$ZodCheckNumberFormat`,(e,t)=>{_.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=fe[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=Ct)}),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})}}),Ft=n(`$ZodCheckMaxLength`,(e,t)=>{var n;_.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!u(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=Te(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),It=n(`$ZodCheckMinLength`,(e,t)=>{var n;_.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!u(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=Te(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Lt=n(`$ZodCheckLengthEquals`,(e,t)=>{var n;_.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!u(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=Te(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})}}),Rt=n(`$ZodCheckStringFormat`,(e,t)=>{var n,r;_.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=()=>{})}),zt=n(`$ZodCheckRegex`,(e,t)=>{Rt.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})}}),Bt=n(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ot,Rt.init(e,t)}),Vt=n(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=kt,Rt.init(e,t)}),Ht=n(`$ZodCheckIncludes`,(e,t)=>{_.init(e,t);let n=le(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})}}),Ut=n(`$ZodCheckStartsWith`,(e,t)=>{_.init(e,t);let n=RegExp(`^${le(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})}}),Wt=n(`$ZodCheckEndsWith`,(e,t)=>{_.init(e,t);let n=RegExp(`.*${le(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})}}),Gt=n(`$ZodCheckOverwrite`,(e,t)=>{_.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Kt=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(`
3
+ `).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(`
4
+ `))}},qt={major:4,minor:4,patch:3},v=n(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qt;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let i=be(e),a;for(let o of t){if(o._zod.def.when){if(xe(e)||!o._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&n?.async===!1)throw new r;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(i||=be(e,t))});else{if(e.issues.length===t)continue;i||=be(e,t)}}return a?a.then(()=>e):e},n=(n,a,o)=>{if(be(n))return n.aborted=!0,n;let s=t(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new r;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,a,o)):n(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new r;return s.then(e=>t(e,i,o))}return t(s,i,o)}}p(e,`~standard`,()=>({validate:t=>{try{let n=ze(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ve(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Jt=n(`$ZodString`,(e,t)=>{v.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xt(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}}),y=n(`$ZodStringFormat`,(e,t)=>{Rt.init(e,t),Jt.init(e,t)}),Yt=n(`$ZodGUID`,(e,t)=>{t.pattern??=rt,y.init(e,t)}),Xt=n(`$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??=it(e)}else t.pattern??=it();y.init(e,t)}),Zt=n(`$ZodEmail`,(e,t)=>{t.pattern??=at,y.init(e,t)}),Qt=n(`$ZodURL`,(e,t)=>{y.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===mt.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})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),$t=n(`$ZodEmoji`,(e,t)=>{t.pattern??=st(),y.init(e,t)}),en=n(`$ZodNanoID`,(e,t)=>{t.pattern??=tt,y.init(e,t)}),tn=n(`$ZodCUID`,(e,t)=>{t.pattern??=Xe,y.init(e,t)}),nn=n(`$ZodCUID2`,(e,t)=>{t.pattern??=Ze,y.init(e,t)}),rn=n(`$ZodULID`,(e,t)=>{t.pattern??=Qe,y.init(e,t)}),an=n(`$ZodXID`,(e,t)=>{t.pattern??=$e,y.init(e,t)}),on=n(`$ZodKSUID`,(e,t)=>{t.pattern??=et,y.init(e,t)}),sn=n(`$ZodISODateTime`,(e,t)=>{t.pattern??=bt(t),y.init(e,t)}),cn=n(`$ZodISODate`,(e,t)=>{t.pattern??=_t,y.init(e,t)}),ln=n(`$ZodISOTime`,(e,t)=>{t.pattern??=yt(t),y.init(e,t)}),un=n(`$ZodISODuration`,(e,t)=>{t.pattern??=nt,y.init(e,t)}),dn=n(`$ZodIPv4`,(e,t)=>{t.pattern??=ct,y.init(e,t),e._zod.bag.format=`ipv4`}),fn=n(`$ZodIPv6`,(e,t)=>{t.pattern??=lt,y.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})}}}),pn=n(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ut,y.init(e,t)}),mn=n(`$ZodCIDRv6`,(e,t)=>{t.pattern??=dt,y.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 hn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var gn=n(`$ZodBase64`,(e,t)=>{t.pattern??=ft,y.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{hn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function _n(e){if(!pt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return hn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var vn=n(`$ZodBase64URL`,(e,t)=>{t.pattern??=pt,y.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{_n(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),yn=n(`$ZodE164`,(e,t)=>{t.pattern??=ht,y.init(e,t)});function bn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var xn=n(`$ZodJWT`,(e,t)=>{y.init(e,t),e._zod.check=n=>{bn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Sn=n(`$ZodNumber`,(e,t)=>{v.init(e,t),e._zod.pattern=e._zod.bag.pattern??wt,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}}),Cn=n(`$ZodNumberFormat`,(e,t)=>{Pt.init(e,t),Sn.init(e,t)}),wn=n(`$ZodBoolean`,(e,t)=>{v.init(e,t),e._zod.pattern=Tt,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}}),Tn=n(`$ZodBigInt`,(e,t)=>{v.init(e,t),e._zod.pattern=St,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),En=n(`$ZodSymbol`,(e,t)=>{v.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),Dn=n(`$ZodUndefined`,(e,t)=>{v.init(e,t),e._zod.pattern=Dt,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),On=n(`$ZodNull`,(e,t)=>{v.init(e,t),e._zod.pattern=Et,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}}),kn=n(`$ZodUnknown`,(e,t)=>{v.init(e,t),e._zod.parse=e=>e}),An=n(`$ZodNever`,(e,t)=>{v.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),jn=n(`$ZodVoid`,(e,t)=>{v.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}});function Mn(e,t,n){e.issues.length&&t.issues.push(...Se(n,e.issues)),t.value[n]=e.value}var Nn=n(`$ZodArray`,(e,t)=>{v.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=>Mn(t,n,e))):Mn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Pn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...Se(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 Fn(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=de(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function In(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=>Pn(e,n,i,t,u,d))):Pn(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}var Ln=n(`$ZodObject`,(e,t)=>{if(v.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=l(()=>Fn(t));p(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=ie,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=>Pn(n,t,e,s,r,i))):Pn(a,t,e,s,r,i)}return i?In(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Rn=n(`$ZodObjectJIT`,(e,t)=>{Ln.init(e,t);let n=e._zod.parse,r=l(()=>Fn(t)),i=e=>{let t=new Kt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=te(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=te(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
5
+ if (${n}.issues.length) {
6
+ if (${o} in input) {
7
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
8
+ ...iss,
9
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
10
+ })));
11
+ }
12
+ }
13
+
14
+ if (${n}.value === undefined) {
15
+ if (${o} in input) {
16
+ newResult[${o}] = undefined;
17
+ }
18
+ } else {
19
+ newResult[${o}] = ${n}.value;
20
+ }
21
+
22
+ `):c?t.write(`
23
+ if (${n}.issues.length) {
24
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
25
+ ...iss,
26
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
27
+ })));
28
+ }
29
+
30
+ if (${n}.value === undefined) {
31
+ if (${o} in input) {
32
+ newResult[${o}] = undefined;
33
+ }
34
+ } else {
35
+ newResult[${o}] = ${n}.value;
36
+ }
37
+
38
+ `):t.write(`
39
+ const ${n}_present = ${o} in input;
40
+ if (${n}.issues.length) {
41
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
42
+ ...iss,
43
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
44
+ })));
45
+ }
46
+ if (!${n}_present && !${n}.issues.length) {
47
+ payload.issues.push({
48
+ code: "invalid_type",
49
+ expected: "nonoptional",
50
+ input: undefined,
51
+ path: [${o}]
52
+ });
53
+ }
54
+
55
+ if (${n}_present) {
56
+ if (${n}.value === undefined) {
57
+ newResult[${o}] = undefined;
58
+ } else {
59
+ newResult[${o}] = ${n}.value;
60
+ }
61
+ }
62
+
63
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,s=ie,c=!a.jitless,u=c&&ae.value,d=t.catchall,f;e._zod.parse=(a,l)=>{f??=r.value;let ee=a.value;return s(ee)?c&&u&&l?.async===!1&&l.jitless!==!0?(o||=i(t.shape),a=o(a,l),d?In([],ee,a,l,f,e):a):n(a,l):(a.issues.push({expected:`object`,code:`invalid_type`,input:ee,inst:e}),a)}});function zn(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=>!be(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=>we(e,r,o())))}),t)}var Bn=n(`$ZodUnion`,(e,t)=>{v.init(e,t),p(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),p(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),p(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),p(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=>d(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=>zn(t,r,e,i)):zn(o,r,e,i)}}),Vn=n(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Bn.init(e,t);let n=e._zod.parse;p(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=l(()=>{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(!ie(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)}}),Hn=n(`$ZodIntersection`,(e,t)=>{v.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])=>Wn(e,t,n)):Wn(e,i,a)}});function Un(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(oe(e)&&oe(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=Un(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=Un(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 Wn(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}),be(e))return e;let o=Un(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Gn=n(`$ZodTuple`,(e,t)=>{v.init(e,t);let n=t.items;e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:`tuple`,code:`invalid_type`}),r;r.value=[];let o=[],s=Kn(n,`optin`),c=Kn(n,`optout`);if(!t.rest){if(a.length<s)return r.issues.push({code:`too_small`,minimum:s,inclusive:!0,input:a,inst:e,origin:`array`}),r;a.length>n.length&&r.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:a,inst:e,origin:`array`})}let l=Array(n.length);for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:a[e],issues:[]},i);t instanceof Promise?o.push(t.then(t=>{l[e]=t})):l[e]=t}if(t.rest){let e=n.length-1,s=a.slice(n.length);for(let n of s){e++;let a=t.rest._zod.run({value:n,issues:[]},i);a instanceof Promise?o.push(a.then(t=>qn(t,r,e))):qn(a,r,e)}}return o.length?Promise.all(o).then(()=>Jn(l,r,n,a,c)):Jn(l,r,n,a,c)}});function Kn(e,t){for(let n=e.length-1;n>=0;n--)if(e[n]._zod[t]!==`optional`)return n+1;return 0}function qn(e,t,n){e.issues.length&&t.issues.push(...Se(n,e.issues)),t.value[n]=e.value}function Jn(e,t,n,r,i){for(let a=0;a<n.length;a++){let n=e[a],o=a<r.length;if(n.issues.length){if(!o&&a>=i){t.value.length=a;break}t.issues.push(...Se(a,n.issues))}t.value[a]=n.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var Yn=n(`$ZodRecord`,(e,t)=>{v.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!oe(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],s=t.keyType._zod.values;if(s){n.value={};let c=new Set;for(let l of s)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>we(e,r,o())),input:l,path:[l],inst:e});continue}let u=s.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...Se(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...Se(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let s of Reflect.ownKeys(i)){if(s===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,s))continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&wt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=i[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>we(e,r,o())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...Se(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...Se(s,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Xn=n(`$ZodEnum`,(e,t)=>{v.init(e,t);let n=s(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ce.has(typeof e)).map(e=>typeof e==`string`?le(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}}),Zn=n(`$ZodLiteral`,(e,t)=>{if(v.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`?le(e):e?le(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}}),Qn=n(`$ZodTransform`,(e,t)=>{v.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,a)=>{if(a.direction===`backward`)throw new i(e.constructor.name);let o=t.transform(n.value,n);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new r;return n.value=o,n.fallback=!0,n}});function $n(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var er=n(`$ZodOptional`,(e,t)=>{v.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,p(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),p(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(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=>$n(e,r)):$n(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),tr=n(`$ZodExactOptional`,(e,t)=>{er.init(e,t),p(e._zod,`values`,()=>t.innerType._zod.values),p(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),nr=n(`$ZodNullable`,(e,t)=>{v.init(e,t),p(e._zod,`optin`,()=>t.innerType._zod.optin),p(e._zod,`optout`,()=>t.innerType._zod.optout),p(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${d(e.source)}|null)$`):void 0}),p(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)}),rr=n(`$ZodDefault`,(e,t)=>{v.init(e,t),e._zod.optin=`optional`,p(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=>ir(e,t)):ir(r,t)}});function ir(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ar=n(`$ZodPrefault`,(e,t)=>{v.init(e,t),e._zod.optin=`optional`,p(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))}),or=n(`$ZodNonOptional`,(e,t)=>{v.init(e,t),p(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=>sr(t,e)):sr(i,e)}});function sr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var cr=n(`$ZodCatch`,(e,t)=>{v.init(e,t),e._zod.optin=`optional`,p(e._zod,`optout`,()=>t.innerType._zod.optout),p(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=>we(e,n,o()))},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=>we(e,n,o()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),lr=n(`$ZodNaN`,(e,t)=>{v.init(e,t),e._zod.parse=(t,n)=>((typeof t.value!=`number`||!Number.isNaN(t.value))&&t.issues.push({input:t.value,inst:e,expected:`nan`,code:`invalid_type`}),t)}),ur=n(`$ZodPipe`,(e,t)=>{v.init(e,t),p(e._zod,`values`,()=>t.in._zod.values),p(e._zod,`optin`,()=>t.in._zod.optin),p(e._zod,`optout`,()=>t.out._zod.optout),p(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=>dr(e,t.in,n)):dr(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>dr(e,t.out,n)):dr(r,t.out,n)}});function dr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var fr=n(`$ZodReadonly`,(e,t)=>{v.init(e,t),p(e._zod,`propValues`,()=>t.innerType._zod.propValues),p(e._zod,`values`,()=>t.innerType._zod.values),p(e._zod,`optin`,()=>t.innerType?._zod?.optin),p(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(pr):pr(r)}});function pr(e){return e.value=Object.freeze(e.value),e}var mr=n(`$ZodFunction`,(e,t)=>(v.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if(typeof t!=`function`)throw Error(`implement() must be called with a function`);return function(...n){let r=e._def.input?Fe(e._def.input,n):n,i=Reflect.apply(t,this,r);return e._def.output?Fe(e._def.output,i):i}},e.implementAsync=t=>{if(typeof t!=`function`)throw Error(`implementAsync() must be called with a function`);return async function(...n){let r=e._def.input?await Le(e._def.input,n):n,i=await Reflect.apply(t,this,r);return e._def.output?await Le(e._def.output,i):i}},e._zod.parse=(t,n)=>typeof t.value==`function`?(t.value=e._def.output&&e._def.output._zod.def.type===`promise`?e.implementAsync(t.value):e.implement(t.value),t):(t.issues.push({code:`invalid_type`,expected:`function`,input:t.value,inst:e}),t),e.input=(...t)=>{let n=e.constructor;return Array.isArray(t[0])?new n({type:`function`,input:new Gn({type:`tuple`,items:t[0],rest:t[1]}),output:e._def.output}):new n({type:`function`,input:t[0],output:e._def.output})},e.output=t=>{let n=e.constructor;return new n({type:`function`,input:e._def.input,output:t})},e)),hr=n(`$ZodPromise`,(e,t)=>{v.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),gr=n(`$ZodLazy`,(e,t)=>{v.init(e,t),p(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),p(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),p(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),p(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),p(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),_r=n(`$ZodCustom`,(e,t)=>{_.init(e,t),v.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=>vr(t,n,r,e));vr(i,n,r,e)}});function vr(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(Ee(e))}}var yr,br=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 xr(){return new br}(yr=globalThis).__zod_globalRegistry??(yr.__zod_globalRegistry=xr());var Sr=globalThis.__zod_globalRegistry;function Cr(e,t){return new e({type:`string`,...g(t)})}function wr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...g(t)})}function Tr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...g(t)})}function Er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...g(t)})}function Dr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...g(t)})}function Or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...g(t)})}function kr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...g(t)})}function Ar(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...g(t)})}function jr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...g(t)})}function Mr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...g(t)})}function Nr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...g(t)})}function Pr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...g(t)})}function Fr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...g(t)})}function Ir(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...g(t)})}function Lr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...g(t)})}function Rr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...g(t)})}function zr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...g(t)})}function Br(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...g(t)})}function Vr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...g(t)})}function Hr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...g(t)})}function Ur(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...g(t)})}function Wr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...g(t)})}function Gr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...g(t)})}function Kr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...g(t)})}function qr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...g(t)})}function Jr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...g(t)})}function Yr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...g(t)})}function Xr(e,t){return new e({type:`number`,checks:[],...g(t)})}function Zr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...g(t)})}function Qr(e,t){return new e({type:`boolean`,...g(t)})}function $r(e,t){return new e({type:`bigint`,...g(t)})}function ei(e,t){return new e({type:`symbol`,...g(t)})}function ti(e,t){return new e({type:`undefined`,...g(t)})}function ni(e,t){return new e({type:`null`,...g(t)})}function ri(e){return new e({type:`unknown`})}function ii(e,t){return new e({type:`never`,...g(t)})}function ai(e,t){return new e({type:`void`,...g(t)})}function oi(e,t){return new e({type:`nan`,...g(t)})}function si(e,t){return new jt({check:`less_than`,...g(t),value:e,inclusive:!1})}function ci(e,t){return new jt({check:`less_than`,...g(t),value:e,inclusive:!0})}function li(e,t){return new Mt({check:`greater_than`,...g(t),value:e,inclusive:!1})}function ui(e,t){return new Mt({check:`greater_than`,...g(t),value:e,inclusive:!0})}function di(e,t){return new Nt({check:`multiple_of`,...g(t),value:e})}function fi(e,t){return new Ft({check:`max_length`,...g(t),maximum:e})}function pi(e,t){return new It({check:`min_length`,...g(t),minimum:e})}function mi(e,t){return new Lt({check:`length_equals`,...g(t),length:e})}function hi(e,t){return new zt({check:`string_format`,format:`regex`,...g(t),pattern:e})}function gi(e){return new Bt({check:`string_format`,format:`lowercase`,...g(e)})}function _i(e){return new Vt({check:`string_format`,format:`uppercase`,...g(e)})}function vi(e,t){return new Ht({check:`string_format`,format:`includes`,...g(t),includes:e})}function yi(e,t){return new Ut({check:`string_format`,format:`starts_with`,...g(t),prefix:e})}function bi(e,t){return new Wt({check:`string_format`,format:`ends_with`,...g(t),suffix:e})}function xi(e){return new Gt({check:`overwrite`,tx:e})}function Si(e){return xi(t=>t.normalize(e))}function Ci(){return xi(e=>e.trim())}function wi(){return xi(e=>e.toLowerCase())}function Ti(){return xi(e=>e.toUpperCase())}function Ei(){return xi(e=>ne(e))}function Di(e,t,n){return new e({type:`array`,element:t,...g(n)})}function Oi(e,t,n){let r=g(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ki(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...g(n)})}function Ai(e,t){let n=ji(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ee(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(Ee(r))}},e(t.value,t)),t);return n}function ji(e,t){let n=new _({check:`custom`,...g(t)});return n._zod.check=e,n}function Mi(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??Sr,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 b(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,b(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`&&x(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 Ni(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>
64
+
65
+ 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 Pi(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:Ii(t,`input`,e.processors),output:Ii(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function x(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 x(r.element,n);if(r.type===`set`)return x(r.valueType,n);if(r.type===`lazy`)return x(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 x(r.innerType,n);if(r.type===`intersection`)return x(r.left,n)||x(r.right,n);if(r.type===`record`||r.type===`map`)return x(r.keyType,n)||x(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:x(r.in,n)||x(r.out,n);if(r.type===`object`){for(let e in r.shape)if(x(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(x(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(x(e,n))return!0;return!!(r.rest&&x(r.rest,n))}return!1}var Fi=(e,t={})=>n=>{let r=Mi({...n,processors:t});return b(e,r),Ni(r,e),Pi(r,e)},Ii=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Mi({...i??{},target:a,io:t,processors:n});return b(e,o),Ni(o,e),Pi(o,e)},Li={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ri=(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=Li[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}))])}},zi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),ee=t.target===`draft-04`||t.target===`openapi-3.0`;d?ee?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?ee?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Bi=(e,t,n,r)=>{n.type=`boolean`},Vi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Hi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},Ui=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Ki=(e,t,n,r)=>{n.not={}},qi=(e,t,n,r)=>{},Ji=(e,t,n,r)=>{},Yi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Xi=(e,t,n,r)=>{let i=e._zod.def,a=s(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Zi=(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}},Qi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},$i=(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},ea=(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)},ta=(e,t,n,r)=>{n.type=`boolean`},na=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ra=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},ia=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},aa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},oa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},sa=(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=b(a.element,t,{...r,path:[...r.path,`items`]})},ca=(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]=b(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=b(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},la=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>b(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ua=(e,t,n,r)=>{let i=e._zod.def,a=b(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=b(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]]},da=(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)=>b(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?b(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)},fa=(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=b(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=b(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=b(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)}},pa=(e,t,n,r)=>{let i=e._zod.def,a=b(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`}]},ma=(e,t,n,r)=>{let i=e._zod.def;b(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ha=(e,t,n,r)=>{let i=e._zod.def;b(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ga=(e,t,n,r)=>{let i=e._zod.def;b(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)))},_a=(e,t,n,r)=>{let i=e._zod.def;b(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},va=(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;b(o,t,r);let s=t.seen.get(e);s.ref=o},ya=(e,t,n,r)=>{let i=e._zod.def;b(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ba=(e,t,n,r)=>{let i=e._zod.def;b(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xa=(e,t,n,r)=>{let i=e._zod.def;b(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Sa=(e,t,n,r)=>{let i=e._zod.innerType;b(i,t,r);let a=t.seen.get(e);a.ref=i},Ca={string:Ri,number:zi,boolean:Bi,bigint:Vi,symbol:Hi,null:Ui,undefined:Wi,void:Gi,never:Ki,any:qi,unknown:Ji,date:Yi,enum:Xi,literal:Zi,nan:Qi,template_literal:$i,file:ea,success:ta,custom:na,function:ra,transform:ia,map:aa,set:oa,array:sa,object:ca,union:la,intersection:ua,tuple:da,record:fa,nullable:pa,nonoptional:ma,default:ha,prefault:ga,catch:_a,pipe:va,readonly:ya,promise:ba,optional:xa,lazy:Sa};function wa(e,t){if(`_idmap`in e){let n=e,r=Mi({...t,processors:Ca}),i={};for(let e of n._idmap.entries()){let[t,n]=e;b(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Ni(r,n),a[t]=Pi(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Mi({...t,processors:Ca});return b(e,n),Ni(n,e),Pi(n,e)}var Ta=n(`ZodISODateTime`,(e,t)=>{sn.init(e,t),w.init(e,t)});function Ea(e){return Kr(Ta,e)}var Da=n(`ZodISODate`,(e,t)=>{cn.init(e,t),w.init(e,t)});function Oa(e){return qr(Da,e)}var ka=n(`ZodISOTime`,(e,t)=>{ln.init(e,t),w.init(e,t)});function Aa(e){return Jr(ka,e)}var ja=n(`ZodISODuration`,(e,t)=>{un.init(e,t),w.init(e,t)});function Ma(e){return Yr(ja,e)}var S=n(`ZodError`,(e,t)=>{Oe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>je(e,t)},flatten:{value:t=>Ae(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,c,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,c,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Na=Pe(S),Pa=Ie(S),Fa=Re(S),Ia=Be(S),La=He(S),Ra=Ue(S),za=We(S),Ba=Ge(S),Va=Ke(S),Ha=qe(S),Ua=Je(S),Wa=Ye(S),Ga=new WeakMap;function Ka(e,t,n){let r=Object.getPrototypeOf(e),i=Ga.get(r);if(i||(i=new Set,Ga.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})}})}}}var C=n(`ZodType`,(e,t)=>(v.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ii(e,`input`),output:Ii(e,`output`)}}),e.toJSONSchema=Fi(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Na(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Fa(e,t,n),e.parseAsync=async(t,n)=>Pa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ia(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>La(e,t,n),e.decode=(t,n)=>Ra(e,t,n),e.encodeAsync=async(t,n)=>za(e,t,n),e.decodeAsync=async(t,n)=>Ba(e,t,n),e.safeEncode=(t,n)=>Va(e,t,n),e.safeDecode=(t,n)=>Ha(e,t,n),e.safeEncodeAsync=async(t,n)=>Ua(e,t,n),e.safeDecodeAsync=async(t,n)=>Wa(e,t,n),Ka(e,`ZodType`,{check(...e){let t=this.def;return this.clone(h(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 ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ps(e,t))},superRefine(e,t){return this.check(Fs(e,t))},overwrite(e){return this.check(xi(e))},optional(){return ss(this)},exactOptional(){return ls(this)},nullable(){return ds(this)},nullish(){return ss(ds(this))},nonoptional(e){return _s(this,e)},array(){return zo(this)},or(e){return Go([this,e])},and(e){return Yo(this,e)},transform(e){return Cs(this,as(e))},default(e){return ps(this,e)},prefault(e){return hs(this,e)},catch(e){return ys(this,e)},pipe(e){return Cs(this,e)},readonly(){return Ts(this)},describe(e){let t=this.clone();return Sr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Sr.get(this);let t=this.clone();return Sr.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 Sr.get(e)?.description},configurable:!0}),e)),qa=n(`_ZodString`,(e,t)=>{Jt.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ka(e,`_ZodString`,{regex(...e){return this.check(hi(...e))},includes(...e){return this.check(vi(...e))},startsWith(...e){return this.check(yi(...e))},endsWith(...e){return this.check(bi(...e))},min(...e){return this.check(pi(...e))},max(...e){return this.check(fi(...e))},length(...e){return this.check(mi(...e))},nonempty(...e){return this.check(pi(1,...e))},lowercase(e){return this.check(gi(e))},uppercase(e){return this.check(_i(e))},trim(){return this.check(Ci())},normalize(...e){return this.check(Si(...e))},toLowerCase(){return this.check(wi())},toUpperCase(){return this.check(Ti())},slugify(){return this.check(Ei())}})}),Ja=n(`ZodString`,(e,t)=>{Jt.init(e,t),qa.init(e,t),e.email=t=>e.check(wr(Xa,t)),e.url=t=>e.check(Ar(eo,t)),e.jwt=t=>e.check(Gr(_o,t)),e.emoji=t=>e.check(jr(no,t)),e.guid=t=>e.check(Tr(Za,t)),e.uuid=t=>e.check(Er(Qa,t)),e.uuidv4=t=>e.check(Dr(Qa,t)),e.uuidv6=t=>e.check(Or(Qa,t)),e.uuidv7=t=>e.check(kr(Qa,t)),e.nanoid=t=>e.check(Mr(ro,t)),e.guid=t=>e.check(Tr(Za,t)),e.cuid=t=>e.check(Nr(io,t)),e.cuid2=t=>e.check(Pr(ao,t)),e.ulid=t=>e.check(Fr(oo,t)),e.base64=t=>e.check(Hr(mo,t)),e.base64url=t=>e.check(Ur(ho,t)),e.xid=t=>e.check(Ir(so,t)),e.ksuid=t=>e.check(Lr(co,t)),e.ipv4=t=>e.check(Rr(lo,t)),e.ipv6=t=>e.check(zr(uo,t)),e.cidrv4=t=>e.check(Br(fo,t)),e.cidrv6=t=>e.check(Vr(po,t)),e.e164=t=>e.check(Wr(go,t)),e.datetime=t=>e.check(Ea(t)),e.date=t=>e.check(Oa(t)),e.time=t=>e.check(Aa(t)),e.duration=t=>e.check(Ma(t))});function Ya(e){return Cr(Ja,e)}var w=n(`ZodStringFormat`,(e,t)=>{y.init(e,t),qa.init(e,t)}),Xa=n(`ZodEmail`,(e,t)=>{Zt.init(e,t),w.init(e,t)}),Za=n(`ZodGUID`,(e,t)=>{Yt.init(e,t),w.init(e,t)}),Qa=n(`ZodUUID`,(e,t)=>{Xt.init(e,t),w.init(e,t)});function $a(e){return Er(Qa,e)}var eo=n(`ZodURL`,(e,t)=>{Qt.init(e,t),w.init(e,t)});function to(e){return Ar(eo,e)}var no=n(`ZodEmoji`,(e,t)=>{$t.init(e,t),w.init(e,t)}),ro=n(`ZodNanoID`,(e,t)=>{en.init(e,t),w.init(e,t)}),io=n(`ZodCUID`,(e,t)=>{tn.init(e,t),w.init(e,t)}),ao=n(`ZodCUID2`,(e,t)=>{nn.init(e,t),w.init(e,t)}),oo=n(`ZodULID`,(e,t)=>{rn.init(e,t),w.init(e,t)}),so=n(`ZodXID`,(e,t)=>{an.init(e,t),w.init(e,t)}),co=n(`ZodKSUID`,(e,t)=>{on.init(e,t),w.init(e,t)}),lo=n(`ZodIPv4`,(e,t)=>{dn.init(e,t),w.init(e,t)}),uo=n(`ZodIPv6`,(e,t)=>{fn.init(e,t),w.init(e,t)}),fo=n(`ZodCIDRv4`,(e,t)=>{pn.init(e,t),w.init(e,t)}),po=n(`ZodCIDRv6`,(e,t)=>{mn.init(e,t),w.init(e,t)}),mo=n(`ZodBase64`,(e,t)=>{gn.init(e,t),w.init(e,t)}),ho=n(`ZodBase64URL`,(e,t)=>{vn.init(e,t),w.init(e,t)}),go=n(`ZodE164`,(e,t)=>{yn.init(e,t),w.init(e,t)}),_o=n(`ZodJWT`,(e,t)=>{xn.init(e,t),w.init(e,t)}),vo=n(`ZodNumber`,(e,t)=>{Sn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r),Ka(e,`ZodNumber`,{gt(e,t){return this.check(li(e,t))},gte(e,t){return this.check(ui(e,t))},min(e,t){return this.check(ui(e,t))},lt(e,t){return this.check(si(e,t))},lte(e,t){return this.check(ci(e,t))},max(e,t){return this.check(ci(e,t))},int(e){return this.check(xo(e))},safe(e){return this.check(xo(e))},positive(e){return this.check(li(0,e))},nonnegative(e){return this.check(ui(0,e))},negative(e){return this.check(si(0,e))},nonpositive(e){return this.check(ci(0,e))},multipleOf(e,t){return this.check(di(e,t))},step(e,t){return this.check(di(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 yo(e){return Xr(vo,e)}var bo=n(`ZodNumberFormat`,(e,t)=>{Cn.init(e,t),vo.init(e,t)});function xo(e){return Zr(bo,e)}var So=n(`ZodBoolean`,(e,t)=>{wn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bi(e,t,n,r)});function Co(e){return Qr(So,e)}var wo=n(`ZodBigInt`,(e,t)=>{Tn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vi(e,t,n,r),e.gte=(t,n)=>e.check(ui(t,n)),e.min=(t,n)=>e.check(ui(t,n)),e.gt=(t,n)=>e.check(li(t,n)),e.gte=(t,n)=>e.check(ui(t,n)),e.min=(t,n)=>e.check(ui(t,n)),e.lt=(t,n)=>e.check(si(t,n)),e.lte=(t,n)=>e.check(ci(t,n)),e.max=(t,n)=>e.check(ci(t,n)),e.positive=t=>e.check(li(BigInt(0),t)),e.negative=t=>e.check(si(BigInt(0),t)),e.nonpositive=t=>e.check(ci(BigInt(0),t)),e.nonnegative=t=>e.check(ui(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(di(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function To(e){return $r(wo,e)}var Eo=n(`ZodSymbol`,(e,t)=>{En.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r)});function Do(e){return ei(Eo,e)}var Oo=n(`ZodUndefined`,(e,t)=>{Dn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r)});function ko(e){return ti(Oo,e)}var Ao=n(`ZodNull`,(e,t)=>{On.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r)});function jo(e){return ni(Ao,e)}var Mo=n(`ZodUnknown`,(e,t)=>{kn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function No(){return ri(Mo)}var Po=n(`ZodNever`,(e,t)=>{An.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ki(e,t,n,r)});function Fo(e){return ii(Po,e)}var Io=n(`ZodVoid`,(e,t)=>{jn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gi(e,t,n,r)});function Lo(e){return ai(Io,e)}var Ro=n(`ZodArray`,(e,t)=>{Nn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,n,r),e.element=t.element,Ka(e,`ZodArray`,{min(e,t){return this.check(pi(e,t))},nonempty(e){return this.check(pi(1,e))},max(e,t){return this.check(fi(e,t))},length(e,t){return this.check(mi(e,t))},unwrap(){return this.element}})});function zo(e,t){return Di(Ro,e,t)}var Bo=n(`ZodObject`,(e,t)=>{Rn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ca(e,t,n,r),p(e,`shape`,()=>t.shape),Ka(e,`ZodObject`,{keyof(){return ts(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:No()})},loose(){return this.clone({...this._zod.def,catchall:No()})},strict(){return this.clone({...this._zod.def,catchall:Fo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return he(this,e)},safeExtend(e){return ge(this,e)},merge(e){return _e(this,e)},pick(e){return pe(this,e)},omit(e){return me(this,e)},partial(...e){return ve(os,this,e[0])},required(...e){return ye(gs,this,e[0])}})});function Vo(e,t){return new Bo({type:`object`,shape:e??{},...g(t)})}function Ho(e,t){return new Bo({type:`object`,shape:e,catchall:Fo(),...g(t)})}function Uo(e,t){return new Bo({type:`object`,shape:e,catchall:No(),...g(t)})}var Wo=n(`ZodUnion`,(e,t)=>{Bn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>la(e,t,n,r),e.options=t.options});function Go(e,t){return new Wo({type:`union`,options:e,...g(t)})}var Ko=n(`ZodDiscriminatedUnion`,(e,t)=>{Wo.init(e,t),Vn.init(e,t)});function qo(e,t,n){return new Ko({type:`union`,options:t,discriminator:e,...g(n)})}var Jo=n(`ZodIntersection`,(e,t)=>{Hn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ua(e,t,n,r)});function Yo(e,t){return new Jo({type:`intersection`,left:e,right:t})}var Xo=n(`ZodTuple`,(e,t)=>{Gn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>da(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})});function Zo(e,t,n){let r=t instanceof v;return new Xo({type:`tuple`,items:e,rest:r?t:null,...g(r?n:t)})}var Qo=n(`ZodRecord`,(e,t)=>{Yn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fa(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function $o(e,t,n){return!t||!t._zod?new Qo({type:`record`,keyType:Ya(),valueType:e,...g(t)}):new Qo({type:`record`,keyType:e,valueType:t,...g(n)})}var es=n(`ZodEnum`,(e,t)=>{Xn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(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 es({...t,checks:[],...g(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 es({...t,checks:[],...g(r),entries:i})}});function ts(e,t){return new es({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...g(t)})}var ns=n(`ZodLiteral`,(e,t)=>{Zn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zi(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 rs(e,t){return new ns({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}var is=n(`ZodTransform`,(e,t)=>{Qn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new i(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ee(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(Ee(t))}};let a=t.transform(n.value,n);return a instanceof Promise?a.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=a,n.fallback=!0,n)}});function as(e){return new is({type:`transform`,transform:e})}var os=n(`ZodOptional`,(e,t)=>{er.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ss(e){return new os({type:`optional`,innerType:e})}var cs=n(`ZodExactOptional`,(e,t)=>{tr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ls(e){return new cs({type:`optional`,innerType:e})}var us=n(`ZodNullable`,(e,t)=>{nr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ds(e){return new us({type:`nullable`,innerType:e})}var fs=n(`ZodDefault`,(e,t)=>{rr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ha(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ps(e,t){return new fs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():se(t)}})}var ms=n(`ZodPrefault`,(e,t)=>{ar.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hs(e,t){return new ms({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():se(t)}})}var gs=n(`ZodNonOptional`,(e,t)=>{or.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function _s(e,t){return new gs({type:`nonoptional`,innerType:e,...g(t)})}var vs=n(`ZodCatch`,(e,t)=>{cr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ys(e,t){return new vs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var bs=n(`ZodNaN`,(e,t)=>{lr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qi(e,t,n,r)});function xs(e){return oi(bs,e)}var Ss=n(`ZodPipe`,(e,t)=>{ur.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r),e.in=t.in,e.out=t.out});function Cs(e,t){return new Ss({type:`pipe`,in:e,out:t})}var ws=n(`ZodReadonly`,(e,t)=>{fr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ts(e){return new ws({type:`readonly`,innerType:e})}var Es=n(`ZodLazy`,(e,t)=>{gr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sa(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Ds(e){return new Es({type:`lazy`,getter:e})}var Os=n(`ZodPromise`,(e,t)=>{hr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ba(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ks(e){return new Os({type:`promise`,innerType:e})}var As=n(`ZodFunction`,(e,t)=>{mr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r)});function js(e){return new As({type:`function`,input:Array.isArray(e?.input)?Zo(e?.input):e?.input??zo(No()),output:e?.output??No()})}var Ms=n(`ZodCustom`,(e,t)=>{_r.init(e,t),C.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r)});function Ns(e,t){return Oi(Ms,e??(()=>!0),t)}function Ps(e,t={}){return ki(Ms,e,t)}function Fs(e,t){return Ai(e,t)}function Is(e,t={}){let n=new Ms({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...g(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}function Ls(e){let t=Ds(()=>Go([Ya(e),yo(),Co(),jo(),zo(t),$o(Ya(),t)]));return t}var Rs=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},zs={pipe(){return Rs(this,arguments)}},Bs=function(){function e(){}return e.prototype=zs,e}(),T=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},E=e=>e,Vs=e=>()=>e,Hs=Vs(!0),Us=Vs(!1),Ws=Vs(void 0),Gs=Ws;function Ks(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function qs(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function Js(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}var Ys=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},Xs=new WeakSet,Zs=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Qs=0,$s=()=>{Qs++};function ec(e){return typeof e==`string`}function tc(e){return typeof e==`number`}function nc(e){return typeof e==`boolean`}function rc(e){return typeof e==`bigint`}function ic(e){return typeof e==`symbol`}function ac(e){return ec(e)||tc(e)||ic(e)}function oc(e){return typeof e==`function`}function sc(e){return e===void 0}function cc(e){return e!==void 0}function lc(e){return e!=null}function uc(e){return!1}function dc(e){return!0}function fc(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function pc(e){return typeof e==`object`&&!!e||oc(e)}var D=T(2,(e,t)=>pc(e)&&t in e);function mc(e){return D(e,Symbol.iterator)||ec(e)}var O=`~effect/Hash`,k=e=>{switch(typeof e){case`number`:return yc(e);case`bigint`:return j(e.toString(10));case`string`:return j(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?j(`Invalid Date`):j(e.toISOString());if(e instanceof RegExp)return j(e.toString());{if(Xs.has(e))return hc(e);let t=Oc.get(e);if(t!==void 0)return t;if(kc.has(e))return $s(),j(`[Circular]`);kc.add(e);let n=Qs,r;try{r=`~effect/Hash`in e?e[O]():typeof e==`function`?hc(e):e instanceof DataView?Cc(Zs(e)):Array.isArray(e)||ArrayBuffer.isView(e)?Cc(e):e instanceof Map?wc(e):e instanceof Set?Ec(e):xc(e)}finally{kc.delete(e)}return n===Qs&&Oc.set(e,r),r}}return _c(gc(j(String(e))))},hc=e=>(Dc.has(e)||Dc.set(e,_c(Math.random()*4294967296|0)),Dc.get(e)),gc=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),A=T(2,(e,t)=>gc(Math.imul(e,2654435761)+Math.imul(t,2246822507))),_c=e=>e&3221225471|e>>>1&1073741824,vc=new DataView(new ArrayBuffer(8)),yc=e=>{let t=e|0;return t===e?_c(t):(vc.setFloat64(0,e===e?e:NaN),_c(A(vc.getInt32(0),vc.getInt32(4))))},j=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return _c(t)},bc=(e,t)=>{let n=12289;for(let r of t)n^=A(k(r),k(e[r]));return _c(n)},xc=e=>bc(e,Ys(e)),Sc=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return _c(r)},Cc=e=>{let t=6151;for(let n of e)t=A(t,k(n));return _c(t)},wc=Sc(j(`Map`),([e,t])=>A(k(e),k(t))),Tc=j(`Set`),Ec=Sc(Tc,e=>A(Tc,k(e))),Dc=new WeakMap,Oc=new WeakMap,kc=new WeakSet,M=`~effect/Equal`;function N(){return arguments.length===1?e=>Ac(e,arguments[0]):Ac(arguments[0],arguments[1])}function Ac(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||Xs.has(e)||Xs.has(t)?!1:jc(e,t):!1}function jc(e,t){let n=Nc.length;for(let r=n;r-->0;)if(Nc[r]===e&&Pc[r]===t)return!0;if(n)return Mc(e,t);let r=Fc.get(e);r||Fc.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=Mc(e,t)),i}function Mc(e,t){Nc.push(e),Pc.push(t);try{return Ic(e,t)}finally{Nc.pop(),Pc.pop()}}var Nc=[],Pc=[],Fc=new WeakMap;function Ic(e,t){if(k(e)!==k(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=Kc(e);if(n!==Kc(t)||typeof e==`function`&&!n)return!1;if(n)return e[M](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:Lc(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?Rc(Zs(e),Zs(t)):Rc(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Bc(e,t,Vc,Hc):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Bc(e,t,k,Ac):zc(e,t)}function Lc(e,t){for(let n=0;n<e.length;n++)if(!Ac(e[n],t[n]))return!1;return!0}function Rc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zc(e,t){let n=Ys(e),r=Ys(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Ac(e[i],t[i]))return!1;return!0}function Bc(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}var Vc=e=>k(e[0]),Hc=(e,t)=>Ac(e[0],t[0])&&Ac(e[1],t[1]),Uc=()=>0;function Wc(e,t){return Gc((n,r)=>e(n[0],r[0])&&t(n[1],r[1]))}function Gc(e){return function(t,n){return Bc(t,n,Uc,e)}}var Kc=e=>D(e,M),qc=e=>(t,n)=>t===n||e(t,n),Jc=(e,t)=>e===t,Yc=()=>Jc;function Xc(e){return qc((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function Zc(e){return qc((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Qc=Symbol.for(`~effect/Redactable`),$c=e=>D(e,Qc);function el(e){return $c(e)?tl(e):e}function tl(e){return e[Qc](globalThis[`~effect/Fiber/currentFiber`]?.context??il)}var nl=`~effect/Fiber/currentFiber`,rl=new Map,il={"~effect/Context":{},base:rl,depth:0,mapUnsafe:rl,pipe(){return Rs(this,arguments)}};function P(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return al;r.add(e);let l;if(Qc in e)l=c(tl(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
66
+ `+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=cl(e);else if(!t?.ignoreToString&&D(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=ll(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${ol(t)}:${c(ul(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${ol(t)}: ${c(ul(e,t),n+1)}`).join(`,
67
+ `)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var al=`[Circular]`;function ol(e){return typeof e==`string`?JSON.stringify(e):String(e)}function sl(e){return e.map(e=>`[${ol(e)}]`).join(``)}function cl(e){try{return e.toISOString()}catch{return`Invalid Date`}}function ll(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function ul(e,t){try{return e[t]}catch{return`[property access threw]`}}function dl(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=D(r,Qc)?el(r):el(t);if(typeof i==`bigint`)return P(i);if(typeof i!=`object`||!i)return i;let a=i instanceof Error&&!D(i,`toJSON`)?{...i,name:i.name,message:i.message}:i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return;if(n.push(i),a!==i&&n.push(a),!fl(a)||pl(a))return a;let o=new Proxy(a,{get(e,t){let n=Reflect.get(e,t,e);return Object.getOwnPropertyDescriptor(e,t)?.get===void 0?n:el(n)}});return n.push(o),o},t?.space)??`null`}function fl(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function pl(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var ml=Symbol.for(`nodejs.util.inspect.custom`),hl=e=>{try{return e=el(e),D(e,`toJSON`)&&oc(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(hl):e}catch{return`[toJSON threw]`}},gl=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?dl(e,{space:t}):P(e,{space:t})}catch{return String(e)}},_l={toJSON(){return hl(this)},[ml](){return this.toJSON()},toString(){return P(this.toJSON())}},vl=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),yl=()=>Error.stackTraceLimit,bl=e=>{vl&&(Error.stackTraceLimit=e)},xl=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}},Sl=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return yl()!==0&&t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})();function Cl(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function wl(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&Cl(e,n,t[n])}var Tl=`~effect/Effect`,El=`~effect/Exit`,Dl={_A:E,_E:E,_R:E},Ol=`${Tl}/identifier`,F=`${Tl}/args`,I=`${Tl}/evaluate`,L=`${Tl}/successCont`,R=`${Tl}/failureCont`,kl=`${Tl}/ensureCont`,Al=Symbol.for(`effect/Effect/Yield`),jl={pipe(){return Rs(this,arguments)},toJSON(){return{...this}},toString(){return P(this.toJSON(),{ignoreToString:!0,space:2})},[ml](){return this.toJSON()}},Ml={[Tl]:Dl,...jl,[Symbol.iterator](){return new xl(this)},toJSON(){return{_id:`Effect`,op:this[Ol],...F in this?{args:this[F]}:void 0}}},Nl=e=>D(e,Tl),Pl=e=>D(e,El),Fl=`~effect/Cause`,Il=`~effect/Cause/Reason`,Ll=e=>D(e,Fl),Rl=class{constructor(e){this[Fl]=Fl,this.reasons=e}pipe(){return Rs(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${P(this.reasons)})`}[ml](){return this.toJSON()}[M](e){return Ll(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>N(t,e.reasons[n]))}[O](){return Cc(this.reasons)}},zl=new WeakMap,Bl=class{[Il];annotations;_tag;constructor(e,t,n){if(this[Il]=Il,this._tag=e,t!==Vl&&typeof n==`object`&&n&&t.size>0){let e=zl.get(n);e&&(t=new Map([...e,...t])),zl.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return Rs(this,arguments)}toString(){return P(this)}[ml](){return this.toString()}},Vl=new Map,Hl=class extends Bl{constructor(e,t=Vl){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${P(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[M](e){return Zl(e)&&N(this.error,e.error)&&N(this.annotations,e.annotations)}[O](){return A(j(this._tag))(A(k(this.error))(k(this.annotations)))}},Ul=e=>new Rl(e),Wl=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=k(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>N(e,i)))continue;else t.push(i);r.push(i)}return r},Gl=T(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new Rl(Wl(e.reasons,t.reasons));return N(e,n)?e:n}),Kl=new Rl([]),ql=e=>new Rl([new Hl(e)]),Jl=class extends Bl{constructor(e,t=Vl){super(`Die`,t,e),this.defect=e}toString(){return`Die(${P(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[M](e){return Ql(e)&&N(this.defect,e.defect)&&N(this.annotations,e.annotations)}[O](){return A(j(this._tag))(A(k(this.defect))(k(this.annotations)))}},Yl=e=>new Rl([new Jl(e)]),Xl=T(e=>Ll(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new Rl(e.reasons.map(e=>e.annotate(t,n)))),Zl=e=>e._tag===`Fail`,Ql=e=>e._tag===`Die`,$l=e=>e._tag===`Interrupt`;function eu(e){return ou(`Effect.evaluate: Not implemented`)}var z=e=>({...Ml,[Ol]:e.op,[I]:e[I]??eu,[L]:e[L],[R]:e[R],[kl]:e[kl]}),tu=e=>{let t=z(e),n=function(e){this[F]=e};return n.prototype=t,function(e){return new n(e)}},nu=e=>{let t={[El]:El,_tag:e.op,get[e.prop](){return this[F]},...z(e),toString(){return`${e.op}(${P(this[F])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[F]}},[M](e){return Pl(e)&&e._tag===this._tag&&N(this[F],e[F])},[O](){return A(j(e.op),k(this[F]))}},n=function(e){this[F]=e};return n.prototype=t,function(e){return new n(e)}},B=nu({op:`Success`,prop:`value`,[I](e){let t=e.getCont(L);return t?t[L](this[F],e,this):e.yieldWith(this)}}),ru={key:`effect/Cause/StackTrace`},iu={key:`effect/Cause/InterruptorStackTrace`},V=nu({op:`Failure`,prop:`cause`,[I](e){let t=this[F],n=!1;e.cache.stackFrame&&(t=Xl(t,{mapUnsafe:new Map([[ru.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(R),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=Ol in r,r=e.getCont(R);a&&(t=Ul(t.reasons.filter(e=>e._tag!==`Fail`))),t=Gl(t,i),n=!0}return r?r[R](t,e,n?void 0:this):e.yieldWith(n?V(t):this)}}),au=e=>V(ql(e)),ou=e=>V(Yl(e)),H=tu({op:`WithFiber`,[I](e){return this[F](e)}}),su=function(){class e extends globalThis.Error{}let t=z({op:`YieldableError`,[I](){return au(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),cu=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends su{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(wl(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),lu=e=>{class t extends cu{_tag=e}return t.prototype.name=e,t};lu(`NoSuchElementError`);var uu=`~effect/Cause/Done`,du=e=>D(e,uu),fu={[uu]:uu,_tag:`Done`,value:void 0},pu=e=>e===void 0?fu:{[uu]:uu,_tag:`Done`,value:e},mu=au(fu),hu=e=>e===void 0?mu:au(pu(e)),gu=e=>e.length>0,_u=`~effect/Option`,vu={[_u]:{_A:e=>e},...jl,[Symbol.iterator](){return new xl(this)}},yu=Object.defineProperty(Object.assign(Object.create(vu),{_tag:`Some`,_op:`Some`,[M](e){return Su(e)&&wu(e)&&N(this.value,e.value)},[O](){return A(k(this._tag))(k(this.value))},toString(){return`some(${P(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:hl(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),bu=k(`None`),xu=Object.assign(Object.create(vu),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[M](e){return Su(e)&&Cu(e)},[O](){return bu},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Su=e=>D(e,_u),Cu=e=>e._tag===`None`,wu=e=>e._tag===`Some`,Tu=Object.create(xu),Eu=function(e){this.value=e};Eu.prototype=yu;var Du=e=>new Eu(e),Ou=`~effect/Result`,ku={[Ou]:{_A:e=>e,_E:e=>e},...jl,[Symbol.iterator](){return new xl(this)}},Au=Object.assign(Object.create(ku),{_tag:`Success`,_op:`Success`,[M](e){return Mu(e)&&Pu(e)&&N(this.success,e.success)},[O](){return A(k(this._tag))(k(this.success))},toString(){return`success(${P(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:hl(this.success)}}}),ju=Object.assign(Object.create(ku),{_tag:`Failure`,_op:`Failure`,[M](e){return Mu(e)&&Nu(e)&&N(this.failure,e.failure)},[O](){return A(k(this._tag))(k(this.failure))},toString(){return`failure(${P(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:hl(this.failure)}}}),Mu=e=>D(e,Ou),Nu=e=>e._tag===`Failure`,Pu=e=>e._tag===`Success`,Fu=function(e){this.failure=e};Fu.prototype=ju;var Iu=e=>new Fu(e),Lu=function(e){this.success=e};Lu.prototype=Au;var Ru=e=>new Lu(e),zu=e=>Nu(e)?Tu:Du(e.success);function Bu(e){return(t,n)=>t===n?0:e(t,n)}var Vu=Bu((e,t)=>e<t?-1:1),Hu=Bu((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),Uu=Bu((e,t)=>e<t?-1:1),Wu=T(2,(e,t)=>Bu((n,r)=>e(t(n),t(r)))),Gu=Wu(Hu,e=>e.getTime()),Ku=e=>T(2,(t,n)=>e(t,n)===-1),qu=e=>T(2,(t,n)=>e(t,n)===1),Ju=e=>T(2,(t,n)=>e(t,n)!==1),Yu=e=>T(2,(t,n)=>e(t,n)!==-1),Xu=()=>Tu,Zu=Du,Qu=Su,$u=Cu,ed=wu,td=T(2,(e,{onNone:t,onSome:n})=>$u(e)?t():n(e.value)),nd=T(2,(e,t)=>$u(e)?t():e.value),rd=T(2,(e,t)=>$u(e)?t():e),id=e=>e==null?Xu():Zu(e),ad=nd(Ws),od=e=>(...t)=>{try{return Zu(e(...t))}catch{return Xu()}},sd=T(2,(e,t)=>$u(e)?Xu():Zu(t(e.value))),cd=T(2,(e,t)=>$u(e)?Xu():t(e.value))(E),ld=e=>$u(e)?[]:[e.value],ud=T(2,(e,t)=>$u(e)?Xu():t(e.value)?Zu(e.value):Xu()),dd=Ru,fd=Iu,pd=Nu,md=Pu,hd=zu,gd=T(2,(e,t)=>pd(e)?fd(t(e.failure)):e),_d=T(2,(e,t)=>md(e)?dd(t(e.success)):e),vd=T(2,(e,{onFailure:t,onSuccess:n})=>pd(e)?t(e.failure):n(e.success)),yd=T(2,(e,t)=>{if(md(e))return e.success;throw t(e.failure)})(E),bd=globalThis.Array,xd=e=>bd.isArray(e)?e:bd.from(e),Sd=T(2,(e,t)=>[...e,t]);bd.isArray;var Cd=gu,wd=gu,Td=()=>[],Ed=e=>[e],Dd=T(2,(e,t)=>e.map(t)),Od=Zc,kd=e=>z({op:e.label,[I]:e.evaluate}),Ad=`~effect/Context/Service`,jd=function(){function e(){}let t=e;Object.setPrototypeOf(t,Md);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Pd]=Pd,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Nd.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Md={[Ad]:Ad,...kd({label:`Service`,evaluate(e){return B(U(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return Zd(this,e)},use(e){return H(t=>e(U(t.context,this)))},useSync(e){return H(t=>B(e(U(t.context,this))))}},Nd=new Set,Pd=`~effect/Context/Reference`,Fd=`~effect/Context`,Id=8,Ld=8,Rd=(e,t,n,r)=>{let i=Object.create(Gd);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},zd=(e,t)=>{t&&(zd(e,t.parent),e.set(t.key,t.value))},Bd=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return zd(t,e.overlay),e._flat=t},Vd=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Wd(n)},Hd=Symbol(),Ud=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Hd:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Ld&&(n.base=Bd(n),n.overlay=void 0,n.depth=0),r)},Wd=e=>Rd(void 0,e,void 0,0),Gd={get mapUnsafe(){return Bd(this)},...jl,[Fd]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[M](e){if(!qd(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!N(r,n.get(e)))return!1;return!0},[O](){return yc(this.mapUnsafe.size)}},Kd=(e,t)=>e.cacheRoot===t.cacheRoot,qd=e=>D(e,Fd),Jd=e=>!!e[Pd],Yd=()=>Xd,Xd=Wd(new Map),Zd=(e,t)=>Wd(new Map([[e.key,t]])),Qd=T(3,(e,t,n)=>$d(e,t.key,n)),$d=(e,t,n)=>{let r=e,i=Nd.has(t)?void 0:r.cacheRoot;if(r.depth>=Id){let e=new Map(r.mapUnsafe);return e.set(t,n),Rd(i,e,void 0,0)}return Rd(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},ef=(e,t)=>{let n=Ud(e,t);return n===Hd?void 0:n},tf=T(2,(e,t)=>{let n=Ud(e,t.key);if(n===Hd){if(Jd(t))return rf(t);throw af(t)}return n}),U=tf,nf=`~effect/Context/defaultValue`,rf=e=>nf in e?e[nf]:e[nf]=e.defaultValue(),af=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
68
+ `);e.splice(1,3),t.stack=e.join(`
69
+ `)}return t},of=T(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Vd(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),W=jd,sf=`~effect/Duration`,cf=BigInt(0),lf=BigInt(1),uf=BigInt(2),df=BigInt(10),ff=BigInt(1e3),pf=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),mf=e=>pf(e*1e6),hf=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=df**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*uf>=a?lf:cf);return r?-s:s},gf=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,_f=e=>{switch(typeof e){case`number`:return kf(e);case`bigint`:return Of(e);case`string`:{if(e===`Infinity`)return Ef;if(e===`-Infinity`)return Df;let t=gf.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return Of(hf(r,lf));if(i===`micro`||i===`micros`)return Of(hf(r,ff));let a=Number(r);switch(i){case`milli`:case`millis`:return kf(a);case`second`:case`seconds`:return Af(a);case`minute`:case`minutes`:return jf(a);case`hour`:case`hours`:return Mf(a);case`day`:case`days`:return Nf(a);case`week`:case`weeks`:return Pf(a)}break}case`object`:{if(e===null)break;if(sf in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(tc)?vf(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Tf:e[0]===-1/0||e[1]===-1/0?Df:e[0]===1/0||e[1]===1/0?Ef:G(pf(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?G(n):G(pf(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return vf(e)},vf=e=>{throw Error(`Invalid Input: ${e}`)},yf={_tag:`Millis`,millis:0},bf={_tag:`Infinity`},xf={_tag:`NegativeInfinity`},Sf={[sf]:sf,[O](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?k(pf(e)):yc(this.value.millis)}case`Nanos`:return k(this.value.nanos);default:return xc(this.value)}},[M](e){return Cf(e)&&Vf(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[ml](){return this.toJSON()},pipe(){return Rs(this,arguments)}},G=e=>{let t=Object.create(Sf);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?yf:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:mf(e)}:e>0?bf:xf:e===cf?yf:{_tag:`Nanos`,nanos:e},t},Cf=e=>D(e,sf),wf=e=>e.value._tag!==`Infinity`&&e.value._tag!==`NegativeInfinity`,Tf=G(0),Ef=G(1/0),Df=G(-1/0),Of=e=>G(e),kf=e=>G(e),Af=e=>G(e*1e3),jf=e=>G(e*6e4),Mf=e=>G(e*36e5),Nf=e=>G(e*864e5),Pf=e=>G(e*6048e5),Ff=e=>Rf(_f(e),{onMillis:E,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),If=e=>Rf(_f(e),{onMillis:e=>e/1e3,onNanos:e=>Number(e)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Lf=e=>{let t=_f(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return mf(t.value.millis)}},Rf=T(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),zf=T(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Lf(e),t.value.nanos):n.onNanos(e.value.nanos,Lf(t))),Bf=(e,t)=>zf(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Vf=T(2,(e,t)=>Bf(e,t)),Hf=e=>t=>{let n=e(t);return pd(n)?Xu():Zu(n.success)},Uf=W(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new Jf}),Wf=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Gf=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Kf=e=>{try{return Gf(e)}catch{return Wf(e)}},qf=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},Jf=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Wf:Kf)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new Yf(this.setImmediate)}},Yf=class{tasks=new qf;running=void 0;setImmediate;constructor(e=Kf){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},Xf=W(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Zf=W(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Qf=`effect/Tracer/ParentSpan`;jd()(Qf,{fiberCached:!0});var $f=`effect/Tracer`,ep=`effect/Metric/FiberRuntimeMetrics`,tp=W(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:Ws}),np=W(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:Hs}),rp=W(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),ip=W(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ap=W(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),op=W(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),sp=class extends Bl{constructor(e,t=Vl){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[M](e){return $l(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[O](){return A(j(`${this._tag}:${this.fiberId}`))(hc(this.annotations))}},cp=e=>new Rl([new sp(e)]),lp=e=>{let t=e.reasons.find(Zl);return t?dd(t):fd(e)},up=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return dd(n.error)}return fd(e)},dp=Hf(up),fp=e=>{let t=e.reasons.find(Ql);return t?dd(t.defect):fd(e)},pp=e=>e.reasons.some($l),mp=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?dd(t):fd(e)},hp=e=>e.reasons.length>0&&e.reasons.every($l),gp=T(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Zl(e)?(n=!0,new Hl(t(e.error),e.annotations)):e);return n?Ul(r):e}),_p=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},vp=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=yl();i!==0&&bl(1);try{for(let i of e.reasons){if(i._tag===`Interrupt`){r.push(i);continue}n.push(yp(i._tag===`Die`?i.defect:i.error,i.annotations,t))}if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=wp(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(yp(i,r[0].annotations,t))}}finally{i!==0&&bl(i)}return n},yp=(e,t,n)=>{let r=typeof e,i;if(e&&r===`object`){if(i=new globalThis.Error(bp(e),{cause:e.cause?yp(e.cause):void 0}),typeof e.name==`string`&&(i.name=e.name),typeof e.stack==`string`)i.stack=Sp(e.stack,i,t);else{let e=`${i.name}: ${i.message}`;i.stack=t?Cp(e,t):e}n?.includeCauseInStack&&(i.stack=Dp(i));for(let t of Object.keys(e))t in i||(i[t]=e[t])}else{i=new globalThis.Error(e?r===`string`?e:dl(e):`Unknown error: ${e}`);let n=`${i.name}: ${i.message}`;i.stack=t?Cp(n,t):n}return i},bp=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return dl(e)},xp=/\((.*)\)/g,Sp=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
70
+ `),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?Cp(a.join(`
71
+ `),n):a.join(`
72
+ `)},Cp=(e,t)=>{let n=t?.get(ru.key);return n&&(e=`${e}\n${Tp(n)}`),e},wp=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(iu.key);n.push(` at fiber (${t})`),r&&n.push(Tp(r))}return n.join(`
73
+ `)},Tp=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(xp),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
74
+ `)},Ep=e=>vp(e).map(Dp).join(`
75
+ `),Dp=e=>e.cause?`${e.stack} {\n${Op(e.cause,` `)}\n}`:e.stack,Op=(e,t)=>{let n=e.stack.split(`
76
+ `),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Op(e.cause,`${t} `)}\n${t}}`),r},kp=`~effect/Fiber`,Ap={_A:E,_E:E},jp={id:0},Mp=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Np=()=>Mp===void 0?void 0:new Mp(`effect/Fiber`),Pp=()=>globalThis[nl],Fp=class{constructor(e,t=!0){this.setContext(e),this.id=++jp.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[kp](){return Ap}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return U(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Gs):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=cp(e);this.cache.stackFrame&&(n=Xl(n,Zd(ru,this.cache.stackFrame))),t&&(n=Xl(n,t)),this._interruptedCause=this._interruptedCause?Gl(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(q(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;return this._asyncContext=void 0,t.runInAsyncScope(this.evaluate,this,e)}if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Al){this._asyncContext=Np();return}let n=zp.interruptChildren&&zp.interruptChildren(this);if(n!==void 0)return this.evaluate(Z(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=Yd()}runLoop(e){let t=globalThis[nl];globalThis[nl]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=q(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Z(Xp,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[I](this),i===Al){let e=this._yielded;if(El in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Al}}catch(e){if(!D(i,I))return ou(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=ou(e)}}finally{this._running=n,globalThis[nl]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Lp;for(;;){let t=this._stack.pop();if(!t)return;let n=t[kl];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&Rp-1))return B(e);let t=this.getCont(L);return t?t[L](e,this):this.yieldWith(B(e))}yieldWith(e){return this._yielded=e,Al}children(){return this._children??=new Set}pipe(){return Rs(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Kd(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Ip(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},Ip=e=>{let t=ef(e,$f);return{scheduler:U(e,Uf),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:U(e,np),span:ef(e,Qf),logLevel:U(e,ip),minimumLogLevel:U(e,ap),stackFrame:U(e,tp),runtimeMetrics:ef(e,ep),maxOpsBeforeYield:U(e,Xf),preventYield:U(e,Zf)}},Lp={[L](e,t){return q(t._interruptedCause)},[R](e,t){return q(t._interruptedCause)}},Rp=32,zp={interruptChildren:void 0},Bp=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(iu.key,e.cache.stackFrame),Wd(t)},Vp=e=>{if(e._children!==void 0&&e._children.size!==0)return qp(e._children)},Hp=e=>{let t=e;return t._exit?K(t._exit):sm(n=>t._exit?n(K(t._exit)):J(e.addObserver(e=>n(K(e)))))},Up=e=>sm(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(K(r))}return a(),J(()=>i?.())}),Wp=e=>{let t=e;return t._exit?t._exit:sm(n=>t._exit?n(t._exit):J(e.addObserver(n)))},Gp=e=>H(t=>Kp(e,t.id)),Kp=T(e=>D(e[0],kp),(e,t,n)=>H(r=>{let i=Bp(r);return i=i&&n?of(i,n):i??n,e.interruptUnsafe(t,i),km(Hp(e))})),qp=e=>H(t=>{let n=Bp(t),r=Td();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return km(Up(r))}),K=B,q=V,Jp=au,J=tu({op:`Sync`,[I](e){let t=this[F](),n=e.getCont(L);return n?n[L](t,e):e.yieldWith(B(t))}}),Y=tu({op:`Suspend`,[I](e){return this[F]()}}),Yp=vd({onFailure:Jp,onSuccess:K}),Xp=tu({op:`Yield`,[I](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate($)},this[F]??0),e.yieldWith(()=>{t=!0})}})(0),Zp=K(Xu()),Qp=e=>Y(()=>q(e())),$p=e=>ou(e),em=e=>Y(()=>Jp(e())),X=K(void 0),tm=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new $g(e,`An error occurred in Effect.try`):e.catch;return Y(()=>{try{return K(t())}catch(e){return Jp(n(e))}})},nm=e=>am(function(t,n){e(n).then(e=>t(K(e)),e=>t($p(e)))},e.length!==0),rm=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new $g(e,`An error occurred in Effect.tryPromise`):e.catch;return am(function(e,r){let i=e=>Y(()=>{try{return Jp(Sl(()=>n(e)))}catch(e){return $p(e)}});try{t(r).then(t=>e(K(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},im=e=>H(t=>e(t.id)),am=function(){let e=z({op:`Async`,[I](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e._yielded=()=>{t=!0},r===void 0&&i===void 0||e._stack.push(om(()=>(t=!0,r?.abort(),i??$))),Al):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),om=tu({op:`AsyncFinalizer`,[kl](e){e.interruptible&&(e.interruptible=!1,e._stack.push(og))},[R](e,t){return pp(e)?Z(jh(V(e),this[F]()),()=>q(e)):q(e)}}),sm=e=>am(e,e.length>=2),cm=sm(Gs),lm=(...e)=>{if(e.length===1){let t=e[0];return Y(()=>mm(t()))}let[t,n]=e;return Y(()=>mm(n.call(t.self)))},um=(e,...t)=>{let n=t.length===0?function(){return Y(()=>mm(e.apply(this,arguments)))}:function(){let n=Y(()=>mm(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return dm(e.length,n)},dm=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),fm=(e,...t)=>dm(e.length,t.length===0?function(){return pm(()=>e.apply(this,arguments))}:function(){let n=pm(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),pm=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return K(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return Y(()=>n?(n=!1,Z(r.value,e=>mm(t,e))):Y(()=>mm(e())))}}}catch(e){return $p(e)}},mm=function(){let e=z({op:`Iterator`,[L](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return K(r.value);if(!Q(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[I](e){return this[L](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),hm=T(2,(e,t)=>new vm(e,ym,K(t))),gm=function(e){return e._stack.push(this),this[F]},_m=z({op:`OnSuccess`,[I]:gm}),vm=function(e,t,n){this[F]=e,this[L]=t,this.payload=n};vm.prototype=_m;var ym=function(){return this.payload},bm=function(e,t){return t.succeedWith(this.payload)},xm=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as `+e+`]`)===!0})(),Sm=function(e,t){let n=this.payload;return t.succeedWith(xm?n(e):Sl(()=>n(e)))},Cm=function(e){let t=this.payload;return t(e)},wm=function(e){let t=this.payload;return new vm(t(e),bm,e)},Tm=function(e){return new vm(this.payload,bm,e)},Em=e=>Fm(e,Zu),Dm=T(2,(e,t)=>new vm(e,Nl(t)?ym:Cm,t)),Om=T(2,(e,t)=>new vm(e,Nl(t)?Tm:wm,t)),km=e=>new vm(e,ym,$),Am=(e,t)=>H(n=>{let r=new Set;return Xh(n,()=>r.size===0?void 0:qp(r)),sm(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=Sg(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),jm=T(e=>Nl(e[1]),(e,t,n)=>Am([e,t],n)),Z=T(2,(e,t)=>new vm(e,Cm,t)),Mm=T(2,(e,t)=>Q(e)?e._tag===`Success`?t.onSuccess(e.value):t.onFailure(e.cause):ph(e,t)),Q=e=>e[El]!==void 0,Nm=T(2,(e,t)=>Q(e)?e._tag===`Success`?t(e.value):e:Z(e,t)),Pm=e=>Z(e,E),Fm=T(2,(e,t)=>new vm(e,Sm,t)),Im=T(2,(e,t)=>Q(e)?Hm(e,t):Fm(e,t)),Lm=T(2,(e,t)=>Q(e)?Um(e,t):lh(e,t)),Rm=e=>V(cp(e)),zm=e=>e._tag===`Success`,Bm=e=>e._tag===`Failure`,Vm=e=>e._tag===`Failure`?dd(e.cause):fd(e),$=B(void 0),Hm=T(2,(e,t)=>e._tag===`Success`?B(t(e.value)):e),Um=T(2,(e,t)=>{if(e._tag===`Success`)return e;let n=up(e.cause);return pd(n)?e:au(t(n.success))}),Wm=T(2,(e,t)=>zm(e)?t:e),Gm=T(2,(e,t)=>zm(e)?t.onSuccess(e.value):t.onFailure(e.cause)),Km=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?$:V(Ul(t))},qm=T(2,(e,t)=>H(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Xh(n,()=>{n.setContext(r)}),e)})),Jm=T(3,(e,t,n)=>qm(e,e=>{let r=tf(e,t),i=n(r);return r===i?e:Qd(e,t,i)})),Ym=()=>Xm,Xm=H(e=>K(e.context)),Zm=e=>H(t=>e(t.context)),Qm=T(2,(e,t)=>Q(e)?e:qm(e,of(t))),$m=function(){return arguments.length===1?T(2,(e,t)=>eh(e,arguments[0],t)):T(3,(e,t,n)=>eh(e,t,n)).apply(this,arguments)},eh=(e,t,n)=>qm(e,Qd(t,n)),th=T(e=>Nl(e[0]),(e,t)=>pg({while:Hs,body:Vs(t?.disableYield?e:Z(e,e=>Xp)),step:Gs})),nh=T(2,(e,t)=>new ih(e,t.length===1?t:e=>t(e))),rh=z({op:`OnFailure`,[I]:gm}),ih=function(e,t){this[F]=e,this[R]=t};ih.prototype=rh;var ah=T(3,(e,t,n)=>nh(e,e=>{let r=t(e);return pd(r)?q(r.failure):n(r.success,e)})),oh=T(2,(e,t)=>ah(e,up,e=>t(e))),sh=T(3,(e,t,n)=>nh(e,e=>{let r=t(e);return pd(r)?q(e):Dm(n(r.success,e),q(e))})),ch=T(2,(e,t)=>sh(e,up,e=>t(e))),lh=T(2,(e,t)=>oh(e,e=>em(()=>t(e)))),uh=e=>oh(e,$p),dh=T(e=>Nl(e[0]),(e,t)=>{if(!t?.log)return vh(e,{onFailure:e=>X,onSuccess:e=>X});let n=c_(t.log===!0?void 0:t.log);return ph(e,{onFailure(e){let r=lp(e);return pd(r)?q(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>X})}),fh=e=>bh(e,{onFailure:fd,onSuccess:dd}),ph=T(2,(e,t)=>new hh(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),mh=z({op:`OnSuccessAndFailure`,[I]:gm}),hh=function(e,t,n){this[F]=e,this[L]=t,this[R]=n};hh.prototype=mh;var gh=function(e,t){let n=this.payload;return t.succeedWith(xm?n.onSuccess(e):Sl(()=>n.onSuccess(e)))},_h=((e,t)=>{let n=z({op:e,[I]:gm,[L]:gh,[R]:t}),r=function(e,t){this[F]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(Zl);if(n===void 0)return q(e);let r=this.payload;return t.succeedWith(xm?r.onFailure(n.error):Sl(()=>r.onFailure(n.error)))}),vh=T(2,(e,t)=>ph(e,{onFailure:e=>{let n=e.reasons.find(Zl);return n?t.onFailure(n.error):q(e)},onSuccess:t.onSuccess})),yh=T(2,(e,t)=>new _h(e,t)),bh=T(2,(e,t)=>{if(Q(e)){if(e._tag===`Success`)return B(t.onSuccess(e.value));let n=up(e.cause);return pd(n)?e:B(t.onFailure(n.success))}return yh(e,t)}),xh=e=>Q(e)?B(e):Sh(e),Sh=tu({op:`Exit`,[I](e){return e._stack.push(this),this[F]},[L](e,t,n){return t.succeedWith(n??B(e))},[R](e,t,n){return t.succeedWith(n??V(e))}}),Ch=T(2,(e,t)=>Z(wh(e,t.duration),e=>$u(e)?t.orElse():K(e.value))),wh=T(2,(e,t)=>jm(Em(e),hm(Kg(t),Xu()))),Th=`~effect/Scope`,Eh=`~effect/Scope/Closeable`,Dh=jd(`effect/Scope`),Oh=(e,t)=>H(n=>(lg(n),kh(e,t)??X)),kh=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Lh(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Ah(n.finalizer,t);let r=n.finalizers;return r.size===1?Ah(r.values().next().value,t):Mh(e,r,t)},Ah=(e,t)=>{try{return e(t)}catch(e){return ou(e)}},jh=(e,t)=>zm(e)?t:nh(t,t=>q(Gl(e.cause,t))),Mh=um(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Pp();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*xh(Ah(s,n))):i.push(Sg(o,Ah(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Up(i)),yield*Km(r)}),Nh=(e,t)=>{let n=zh(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Ih(e,n,e=>Oh(n,e)),n)},Ph=(e,t)=>Y(()=>e.state._tag===`Closed`?t(e.state.exit):(Ih(e,{},t),X)),Fh=(e,t)=>Ph(e,Vs(t)),Ih=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},Lh=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=Bh:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=Bh))},Rh=e=>zh(e,void 0),zh=(e=`sequential`,t)=>({[Eh]:Eh,[Th]:Th,strategy:e,parent:t,state:Bh}),Bh={_tag:`Empty`},Vh=e=>J(()=>Rh(e)),Hh=Dh,Uh=$m(Dh),Wh=e=>H(t=>{let n=t.context,r=Rh();return t.setContext(Qd(t.context,Dh,r)),Xh(t,e=>(t.setContext(n),kh(r,e))),e}),Gh=e=>Y(()=>{let t=Rh();return Zh(e(t),e=>Y(()=>kh(t,e)??X))}),Kh=(e,t,n)=>Zm(r=>dg(i=>Z(Hh,a=>Om(n?.interruptible?i(e):e,e=>Ph(a,n=>Qm(t(e,n),r)))))),qh=e=>Z(Hh,t=>Zm(n=>Ph(t,t=>Qm(e(t),n)))),Jh=function(){let e=z({op:`OnExit`,[I](e){return e._stack.push(this),this.effect},[kl](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(og),e.interruptible=!1)},[L](e,t,n){n??=B(e);let r;try{r=this.onExit(n)}catch(e){r=ou(e)}return r?Z(r,e=>n):n},[R](e,t,n){n??=V(e);let r;try{r=this.onExit(n)}catch(e){r=ou(e)}return r?Z(jh(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Yh=(e,t,n)=>new Jh(e,t,n),Xh=(e,t)=>{e._stack.push(new Jh(void 0,t,void 0))},Zh=T(2,Yh),Qh=T(2,(e,t)=>Zh(e,e=>t)),$h=T(3,(e,t,n)=>Zh(e,e=>{let r=t(e);return pd(r)?X:n(r.success,e)})),eg=T(2,(e,t)=>$h(e,Vm,t)),tg=T(3,(e,t,n)=>Zh(e,e=>{if(e._tag!==`Failure`)return X;let r=t(e.cause);return pd(r)?X:n(r.success,e.cause)})),ng=T(2,(e,t)=>tg(mp,t)(e)),rg=(e,t,n)=>dg(r=>Z(e,e=>Yh(Y(()=>r(t(e))),t=>n(e,t),!0))),ig=e=>H(t=>t.interruptible?(t.interruptible=!1,t._stack.push(og),e):e),ag=tu({op:`SetInterruptible`,[kl](e){if(e.interruptible=this[F],e._interruptedCause&&e.interruptible)return()=>q(e._interruptedCause)}}),og=ag(!0),sg=ag(!1),cg=e=>{if(e.interruptible=!0,e._stack.push(sg),e._interruptedCause)return q(e._interruptedCause)},lg=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(og))},ug=e=>H(t=>t.interruptible?e:cg(t)??e),dg=e=>H(t=>t.interruptible?(t.interruptible=!1,t._stack.push(og),e(ug)):e(E)),fg=(e,t)=>mc(e)?t?.mode===`result`?mg(e,fh,t):mg(e,E,t):t?.discard?t.mode===`result`?mg(Object.values(e),fh,t):mg(Object.values(e),E,t):Y(()=>{let n={};return hm(mg(Object.entries(e),([e,r])=>Fm(t?.mode===`result`?fh(r):r,t=>{Cl(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),pg=tu({op:`While`,[L](e,t){return this[F].step(e),this[F].while()?(t._stack.push(this),this[F].body()):$},[I](e){return this[F].while()?(e._stack.push(this),this[F].body()):$}}),mg=T(e=>typeof e[1]==`function`,(e,t,n)=>Y(()=>{let r=gg(n?.concurrency);if(r===1)return hg(e,t,n);let i=xd(e),a=i.length;if(a===0)return n?.discard?X:K([]);let o=n?.discard?void 0:Array(a),s=bg({f:t,out:o},i,{concurrency:r});return s?hm(s,o):K(o)})),hg=(e,t,n)=>Y(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return hm(pg({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),gg=e=>e===`unbounded`?1/0:Math.max(1,e??1),_g=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Z(xh(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??X),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!Q(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},vg=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,ee,p=e=>{let t=ou(e);return f=t,c=!0,u&&u.size>0?Z(ig(qp(Array.from(u))),()=>f??t):t},m=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],h=ee??t(e,o,a);if(Q(h)){if(f=n(e,o,h,a),f)break}else if(l){ee=void 0;let t=Sg(l,h,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=Ul(e);f=V(f._tag===`Failure`?Gl(f.cause,t):t)}}}else{let t=n(e,o,a,r);t&&(f=t,m())}if(i){let e=m();e&&d(e)}else c&&u.size===0&&d(f??X)}catch(e){d(p(e))}}),u.size<s)continue;i=!0,a++;return}else return sm(e=>{l=Pp(),u=new Set,ee=h,d=e;let t;try{t=m()}catch(t){return e(p(t))}return t?e(t):Y(()=>(f??=$,Z(u?qp(u):X,()=>f?._tag===`Failure`?f:X)))})}if(c=!0,f){if(u&&u.size>0){let e=Bp(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(X);else return $}};return m()}},yg=()=>e=>vg(e),bg=vg({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),xg=T(e=>Nl(e[0]),(e,t)=>H(n=>(p_(),K(Sg(n,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),Sg=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Fp(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Np(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},Cg=T(e=>Nl(e[0]),(e,t)=>H(n=>K(Sg(n,e,t?.startImmediately,!0,t?.uninterruptible)))),wg=T(e=>Nl(e[0]),(e,t,n)=>H(r=>{let i=Sg(r,e,n?.startImmediately,!0,n?.uninterruptible);if(!i._exit){if(t.state._tag!==`Closed`){let e={};Ih(t,e,()=>im(e=>e===i.id?X:Gp(i))),i.addObserver(()=>Lh(t,e))}else i.interruptUnsafe(r.id,Bp(r))}return K(i)})),Tg=e=>(t,n)=>{let r=new Fp(n?.scheduler?Qd(e,Uf,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Eg=T(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(Lh(t,e),Ih(t,e,()=>Gp(e)),e.addObserver(()=>Lh(t,e)),e)),Dg=Tg(Yd()),Og=e=>{let t=Tg(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},kg=Og(Yd()),Ag=e=>{let t=Og(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw _p(e.cause);return e.value})},jg=e=>{let t=Tg(e);return e=>{if(Q(e))return e;let n=new Jf(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??ou(new Zg(r))}},Mg=jg(Yd()),Ng=(e=>{let t=jg(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw _p(n.cause);return n.value}})(Yd()),Pg=K(!0),Fg=K(!1),Ig=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return Pg;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],Pg}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t]($)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t]($)}open=H(e=>this._isOpen?Fg:(this._isOpen=!0,this.scheduleUnsafe(e)));release=H(e=>this._isOpen?Fg:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=sm(e=>this._isOpen?e(X):(this.waiters.push(e),J(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=J(()=>this.closeUnsafe());whenOpen=e=>Z(this.await,()=>e);isOpen(){return this._isOpen}},Lg=e=>new Ig(e??!1),Rg=e=>J(()=>Lg(e)),zg=W(`effect/Clock`,{defaultValue:()=>new Vg}),Bg=2**31-1,Vg=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=J(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Wg()}currentTimeNanos=J(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Ug()}monotonicTimeNanos=J(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Ff(e))}sleepMillis(e){return e<=0?Xp:Number.isFinite(e)?sm(t=>{let n=e>Bg?this.sleepMillis(e-Bg):X,r=setTimeout(()=>t(n),Math.min(e,Bg));return J(()=>clearTimeout(r))}):cm}},Hg=BigInt(1e6),Ug=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Hg;return e>t&&(t=e),t}}(),Wg=function(){let e=BigInt(1e9),t;return()=>{let n=Ug(),r=BigInt(Date.now())*Hg;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Gg=e=>H(t=>e(t.getRef(zg))),Kg=e=>Gg(t=>t.sleep(_f(e))),qg=Gg(e=>e.currentTimeMillis);lu(`TimeoutError`);var Jg=`~effect/Cause/IllegalArgumentError`,Yg=class extends lu(`IllegalArgumentError`){[Jg]=Jg;constructor(e){super({message:e})}};lu(`ExceededCapacityError`);var Xg=`~effect/Cause/AsyncFiberError`,Zg=class extends lu(`AsyncFiberError`){[Xg]=Xg;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Qg=`~effect/Cause/UnknownError`,$g=class extends lu(`UnknownError`){[Qg]=Qg;constructor(e,t){super({message:t,cause:e})}},e_=W(`effect/Console`,{defaultValue:()=>globalThis.console}),t_=qu(Wu(Hu,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),n_=W(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([d_,f_])}),r_=W(`effect/Logger/LogToStderr`,{defaultValue:Us}),i_={"~effect/Logger":{_Message:E,_Output:E},pipe(){return Rs(this,arguments)}},a_=e=>{let t=Object.create(i_);return t.log=e,t},o_=e=>e.replace(/[\s="]/g,`_`),s_=(e,t)=>`${o_(e[0])}=${t-e[1]}ms`,c_=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];Ll(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?Ul(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=Kl),H(r=>{let i=e??r.cache.logLevel;if(t_(r.cache.minimumLogLevel,i))return X;let a=r.getRef(zg),o=r.getRef(n_);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return X})},l_={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};l_.gray,l_.blue,l_.green,l_.yellow,l_.red,l_.bgBrightRed,l_.black;var u_=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,d_=a_(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Ep(e));let o=t.getTime(),s=n.getRef(op),c=``;for(let e of s)c+=` ${s_(e,o)}`;let l=n.getRef(rp);Object.keys(l).length>0&&a.push(l);let u=n.getRef(e_);(n.getRef(r_)?u.error:u.log)(`[${u_(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),f_=a_(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(zg),a=t.getRef(rp),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))Cl(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Ep(e)),o.event(gl(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)});function p_(){zp.interruptChildren??=Vp}var m_=rp,h_=Nl,g_=fg,__=mg,v_=pg,y_=nm,b_=rm,x_=K,S_=Y,C_=J,w_=X,T_=sm,E_=cm,D_=lm,O_=Jp,k_=q,A_=Qp,j_=$p,M_=tm,N_=Xp,P_=Yp,F_=Z,I_=Pm,L_=Dm,R_=Om,z_=fh,B_=xh,V_=Fm,H_=hm,U_=km,W_=oh,G_=nh,K_=lh,q_=uh,J_=ch,Y_=dh,X_=wh,Z_=Ch,Q_=Kg,$_=jm,ev=yh,tv=Mm,nv=ph,rv=vh,iv=Ym,av=Qm,ov=$m,sv=Wh,cv=Gh,lv=Kh,uv=rg,dv=qh,fv=Qh,pv=eg,mv=Yh,hv=Zh,gv=ng,_v=ig,vv=dg,yv=th,bv=xg,xv=wg,Sv=Cg,Cv=Dg,wv=Tg,Tv=Ag,Ev=kg,Dv=Ng,Ov=Mg,kv=um,Av=c_(`Error`),jv=T(e=>h_(e[0]),(e,...t)=>Jm(e,m_,e=>{let n=t.length===1?{...e,...t[0]}:{...e};return t.length===1||Cl(n,t[0],t[1]),n}));jd()(`effect/Effect/Transaction`);var Mv=Im,Nv=Lm,Pv=Nm,Fv=fm;export{Cv as $,rs as $i,td as $n,yc as $r,Lg as $t,D_ as A,er as Aa,es as Ai,wd as An,tu as Ar,Zm as At,tv as B,g as Ba,ts as Bi,gd as Bn,sl as Br,Hp as Bt,Fv as C,Vn as Ca,Js as Ci,Qd as Cn,ou as Cr,Dm as Ct,Sv as D,An as Da,Ro as Di,Td as Dn,du as Dr,gp as Dt,bv as E,Zn as Ea,Rs as Ei,Sd as En,B as Er,ah as Et,Mv as F,ze as Fa,os as Fi,yd as Fn,bl as Fr,Bm as Ft,mv as G,Lo as Gi,id as Gn,Yc as Gr,up as Gt,E_ as H,t as Ha,Is as Hi,dd as Hn,Zc as Hr,Wp as Ht,K_ as I,Ve as Ia,Ss as Ii,hd as In,_l as Ir,zm as It,y_ as J,Co as Ji,$u as Jn,Gc as Jr,Pp as Jt,gv as K,zo as Ki,nd as Kn,N as Kr,dp as Kt,Nv as L,Ne as La,Ja as Li,pd as Ln,ml as Lr,Gm as Lt,h_ as M,v as Ma,us as Mi,Dd as Mn,wl as Mr,Q as Mt,Av as N,Fe as Na,vo as Ni,Ed as Nn,Cl as Nr,Km as Nt,xv as O,nr as Oa,So as Oi,xd as On,Pl as Or,Ep as Ot,V_ as P,Le as Pa,Bo as Pi,fd as Pn,yl as Pr,Rm as Pt,z_ as Q,Ds as Qi,sd as Qn,k as Qr,Rg as Qt,ev as R,ue as Ra,C as Ri,md as Rn,P as Rr,$ as Rt,kv as S,_r as Sa,qs as Si,jd as Sn,I as Sr,Yg as St,yv as T,gr as Ta,zs as Ti,U as Tn,V as Tr,sm as Tt,pv as U,jo as Ui,ud as Un,Xc as Ur,Eg as Ut,rv as V,n as Va,js as Vi,vd as Vn,ol as Vr,Gp as Vt,hv as W,ko as Wi,cd as Wn,qc as Wr,fp as Wt,ov as X,qo as Xi,ed as Xn,Cc as Xr,yg as Xt,av as Y,Ns as Yi,Qu as Yn,M as Yr,hp as Yt,$_ as Z,Ls as Zi,od as Zn,A as Zr,_g as Zt,k_ as _,ii as _a,Gs as _i,_f as _n,F as _r,_v as _t,L_ as a,$o as aa,oc as ai,Oh as an,Gu as ar,sv as at,Pv as b,Cr as ba,Ks as bi,If as bn,Ul as br,v_ as bt,U_ as c,Do as ca,cc as ci,Rh as cn,qu as cr,x_ as ct,W_ as d,No as da,pc as di,Zp as dn,Ju as dr,R_ as dt,Uo as ea,j as ei,Yh as en,Xu as er,wv as et,iv as f,to as fa,ac as fi,Y as fn,Bu as fr,J_ as ft,O_ as g,pi as ga,dc as gi,Jf as gn,lu as gr,M_ as gt,B_ as h,fi as ha,sc as hi,X as hn,jl as hr,b_ as ht,g_ as i,ks as ia,nc as ii,Ph as in,Uu as ir,Ov as it,Y_ as j,Jt as ja,ns as ji,Od as jn,H as jr,qg as jt,P_ as k,Ln as ka,fs as ki,Cd as kn,Zl as kr,_p as kt,T_ as l,Zo as la,tc as li,Dh as ln,Yu as lr,S_ as lt,fv as m,wa as ma,ic as mi,dg as mn,cu as mr,Z_ as mt,uv as n,yo as na,D as ni,gg as nn,Zu as nr,Tv as nt,jv as o,Ho as oa,uc as oi,Nh as on,Hu as or,cv as ot,j_ as p,$a as pa,ec as pi,J as pn,pu as pr,X_ as pt,q_ as q,To as qi,ad as qn,Wc as qr,Z as qt,dv as r,Vo as ra,rc as ri,Fh as rn,ld as rr,Dv as rt,H_ as s,Ya as sa,lc as si,Vh as sn,Vu as sr,Q_ as st,lv as t,xs as ta,O as ti,Uh as tn,rd as tr,Ev as tt,G_ as u,Go as ua,fc as ui,K as un,Ku as ur,C_ as ut,A_ as v,ki as va,Vs as vi,wf as vn,Yl as vr,vv as vt,__ as w,Xn as wa,Bs as wi,Yd as wn,au as wr,Em as wt,I_ as x,Sr as xa,E as xi,W as xn,hu as xr,N_ as xt,F_ as y,hi as ya,T as yi,Af as yn,ql as yr,w_ as yt,nv as z,p as za,Wo as zi,_d as zn,cl as zr,Wm as zt};