@softspark/jira-mcp 1.6.0 → 1.7.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,45 @@ Versioning follows [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ---
9
9
 
10
+ ## v1.7.0 -- Apache-2.0 (2026-07-27)
11
+
12
+ ### Changed -- licence: MIT to Apache-2.0
13
+
14
+ The project is now licensed under the Apache License 2.0. It stays permissive:
15
+ fork it, modify it, ship it commercially. What changes is what a redistributor
16
+ owes back.
17
+
18
+ - **`NOTICE` is the point.** MIT already required keeping the copyright notice, so
19
+ attribution is not new. Apache-2.0 adds section 4(d): a redistributor must carry
20
+ the contents of `NOTICE` -- project name, copyright, source URL -- into their
21
+ distribution. `NOTICE` is in `package.json` `files`, so it ships with the package.
22
+ - **Modified files must say so** (section 4b), an express patent grant with
23
+ retaliation (section 3), and no rights to the project or company names
24
+ (section 6). None of these existed under MIT.
25
+ - **Attribution reaches the published bundles through a build banner.** This is
26
+ the part specific to this package: npm ships `dist/`, not `src/`, and the build
27
+ runs with `minify: true`, which strips every comment. SPDX headers in `src/`
28
+ are for whoever clones the repository; consumers see the tsup `banner`, now
29
+ present in both `dist/index.js` and `dist/cli.js`.
30
+ - **SPDX headers on 165 source files**, placed after any shebang.
31
+ - **Nothing is revoked.** Releases up to and including v1.6.0 were published under
32
+ MIT and remain available under MIT. All contributions were made by the
33
+ copyright holder, so no third-party permission was required.
34
+
35
+ `LICENSE` holds the verbatim Apache-2.0 text, cross-verified against two
36
+ independent published copies before being written.
37
+
38
+ ### Tests
39
+
40
+ - `tests/licensing.test.ts`, 8 assertions run by `npm test`: SPDX headers present
41
+ and naming Apache-2.0, `LICENSE` complete, `NOTICE` carrying attribution and
42
+ section 4(d), both files in `package.json` `files`, `package.json` declaring
43
+ Apache-2.0, and **both build entries carrying the licence banner**. The banner
44
+ assertion exists because losing it would strip attribution from the published
45
+ artifact while every other check stayed green.
46
+
47
+ ---
48
+
10
49
  ## v1.6.0 -- ADF Nested Lists, Task Lists & Doc-Parity Gates (2026-06-10)
11
50
 
12
51
  ### Added
package/LICENSE CHANGED
@@ -1,21 +1,201 @@
1
- MIT License
2
-
3
- Copyright (c) 2024-2026 Lukasz Krzemien (biuro@softspark.eu)
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.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,54 @@
1
+ jira-mcp
2
+ Copyright 2024-2026 Lukasz Krzemien (biuro@softspark.eu)
3
+
4
+ This product includes software developed by SoftSpark.
5
+ Source: https://github.com/softspark/jira-mcp
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ If you redistribute this software or a derivative of it, Section 4(d) of the
20
+ License requires you to carry the contents of this NOTICE file with it.
21
+
22
+ --------------------------------------------------------------------------------
23
+
24
+ PRIOR LICENSE
25
+
26
+ Releases up to and including v1.6.0 were distributed under the MIT License.
27
+ Those releases remain available under MIT; this change applies going forward and
28
+ does not revoke any permission already granted.
29
+
30
+ All contributions to this project were made by the copyright holder named above,
31
+ so no third-party permission was required for the change. The MIT notice is kept
32
+ below for the releases it still governs.
33
+
34
+ MIT License
35
+
36
+ Copyright (c) 2024-2026 Lukasz Krzemien (biuro@softspark.eu)
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining a copy
39
+ of this software and associated documentation files (the "Software"), to deal
40
+ in the Software without restriction, including without limitation the rights
41
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
42
+ copies of the Software, and to permit persons to whom the Software is
43
+ furnished to do so, subject to the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be included in all
46
+ copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
49
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
50
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
51
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
52
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
53
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54
+ SOFTWARE.
package/README.md CHANGED
@@ -4,18 +4,17 @@
4
4
 
5
5
  [![CI](https://github.com/softspark/jira-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/softspark/jira-mcp/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/@softspark/jira-mcp)](https://www.npmjs.com/package/@softspark/jira-mcp)
7
- [![version](https://img.shields.io/badge/version-1.6.0-blue)](CHANGELOG.md)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![version](https://img.shields.io/badge/version-1.7.0-blue)](CHANGELOG.md)
8
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
9
9
 
10
10
  ---
11
11
 
12
- ## What's New in v1.6.0
12
+ ## What's New in v1.7.0
13
13
 
14
- - **Nested lists in ADF conversion** -- indented markdown lists produce real nested `bulletList`/`orderedList` nodes in both directions instead of being flattened.
15
- - **Task lists (Jira checkboxes)** -- `- [ ]` / `- [x]` markdown round-trips through ADF `taskList`/`taskItem` nodes, including nesting.
16
- - **`date` nodes render on read** -- dates in descriptions and comments show as `YYYY-MM-DD` instead of disappearing; images (`![alt](url)`) degrade to clean links on write.
17
- - **Coverage gate enforced in CI** -- the test job runs `test:coverage`, so the 70% thresholds actually block merges.
18
- - **Doc-parity validation** -- `validate_counts.py` also checks the version badge and that every MCP tool is documented in `kb/reference/api.md` and `rules/jira-mcp.md`.
14
+ - **Licence: MIT to Apache-2.0.** Still permissive -- fork it, modify it, ship it commercially. What changes is what a redistributor owes back: the contents of [NOTICE](NOTICE) must travel with any redistribution (§4d), modified files must say they were modified (§4b), plus an express patent grant and a trademark reservation. Releases up to v1.6.0 stay available under MIT; nothing already granted is revoked.
15
+ - **Attribution reaches the published bundles.** npm ships `dist/`, not `src/`, and the build minifies away every comment -- so the SPDX headers added to 165 source files never reach a consumer. A build banner carries the licence into `dist/index.js` and `dist/cli.js` instead, and a test asserts both entries keep it.
16
+ - **Licensing gate in `npm test`** -- `tests/licensing.test.ts`, 8 assertions covering headers, `LICENSE`, `NOTICE`, npm `files`, and the build banner. Release SOP gains Phase 4.7 running the same gate before tagging.
17
+ - **Release SOP hardened** -- tag placement is now asserted before the push, and `git push --tags` is replaced with a single-tag push by full ref. A `--tags` push is how a sibling project silently skipped a publish.
19
18
 
20
19
  See [CHANGELOG.md](CHANGELOG.md) for full details.
21
20
 
@@ -258,7 +257,7 @@ src/
258
257
 
259
258
  **Typed error hierarchy** -- 20 error classes with machine-readable codes. Every tool returns structured `{ success, error, code }` responses. No stack traces leak to MCP clients.
260
259
 
261
- **Strict TypeScript** -- `strict: true`, no `any`, `readonly` interfaces, Zod validation at all boundaries, 672 tests across 64 test files. Self-contained 535KB package.
260
+ **Strict TypeScript** -- `strict: true`, no `any`, `readonly` interfaces, Zod validation at all boundaries, 680 tests across 65 test files. Self-contained 535KB package.
262
261
 
263
262
  ## Documentation
264
263
 
@@ -285,7 +284,17 @@ See [SECURITY.md](SECURITY.md).
285
284
 
286
285
  ## License
287
286
 
288
- [MIT](LICENSE) -- SoftSpark
287
+ Apache License 2.0 -- see [LICENSE](LICENSE) and [NOTICE](NOTICE). SoftSpark.
288
+
289
+ Fork it, modify it, ship it commercially. Three things the licence asks in return:
290
+
291
+ - **Keep the attribution.** Redistributions must carry the contents of [NOTICE](NOTICE) (§4d) -- project name, copyright and source URL.
292
+ - **Say what you changed.** Modified files must carry a prominent notice stating that you changed them (§4b).
293
+ - **Names are not included.** No rights to the "jira-mcp" or "SoftSpark" names or marks (§6).
294
+
295
+ The published bundles are minified, so the source headers do not survive into `dist/`. Attribution reaches consumers through a build banner instead -- the first comment in `dist/index.js` and `dist/cli.js`.
296
+
297
+ Releases up to and including v1.6.0 were published under MIT and stay available under MIT; the change applies going forward and revokes nothing already granted.
289
298
 
290
299
  ## Changelog
291
300
 
package/dist/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import {readFileSync,readdirSync,existsSync}from'fs';import {readFile,mkdir,writeFile,unlink,readdir,rm as rm$1,stat,access,rename}from'fs/promises';import {homedir}from'os';import {join,dirname,resolve}from'path';import {fileURLToPath}from'url';import Sz from'process';import {Command}from'commander';var xI=Object.create;var Vp=Object.defineProperty;var wI=Object.getOwnPropertyDescriptor;var SI=Object.getOwnPropertyNames;var TI=Object.getPrototypeOf,zI=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Zt=(t,e)=>{for(var n in e)Vp(t,n,{get:e[n],enumerable:true});},II=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of SI(e))!zI.call(t,r)&&r!==n&&Vp(t,r,{get:()=>e[r],enumerable:!(o=wI(e,r))||o.enumerable});return t};var F_=(t,e,n)=>(n=t!=null?xI(TI(t)):{},II(Vp(n,"default",{value:t,enumerable:true}),t));var Ms,Bp=f(()=>{Ms="1.6.0";});var G_={};Zt(G_,{GLOBAL_CACHE_DIR:()=>Sr,GLOBAL_COMMENT_TEMPLATES_DIR:()=>qs,GLOBAL_CONFIG_DIR:()=>he,GLOBAL_CONFIG_PATH:()=>Gp,GLOBAL_CREDENTIALS_PATH:()=>Kp,GLOBAL_STATE_PATH:()=>OI,GLOBAL_TASK_TEMPLATES_DIR:()=>Jn,GLOBAL_TASK_TEMPLATE_DEFINITIONS_DIR:()=>Fs,GLOBAL_TEMPLATES_DIR:()=>Ls,GLOBAL_USERS_PATH:()=>ki,GLOBAL_WORKFLOWS_PATH:()=>$i,PACKAGE_ROOT_DIR:()=>B_,SYSTEM_COMMENT_TEMPLATES_DIR:()=>Hp,SYSTEM_TASK_TEMPLATES_DIR:()=>Xp,SYSTEM_TEMPLATES_DIR:()=>Wp,ensureGlobalDirs:()=>CI});function EI(t){let e=t;for(;;){if(existsSync(join(e,"package.json")))return e;let n=dirname(e);if(n===e)return fileURLToPath(new URL("../..",import.meta.url));e=n;}}async function CI(){await mkdir(he,{recursive:true}),await mkdir(Sr,{recursive:true}),await mkdir(qs,{recursive:true}),await mkdir(Fs,{recursive:true}),await mkdir(Jn,{recursive:true});}var he,B_,Gp,Kp,Sr,$i,ki,OI,Ls,qs,Fs,Jn,Wp,Hp,Xp,Ie=f(()=>{he=join(homedir(),".softspark","jira-mcp");B_=EI(dirname(fileURLToPath(import.meta.url))),Gp=join(he,"config.json"),Kp=join(he,"credentials.json"),Sr=join(he,"cache"),$i=join(Sr,"workflows.json"),ki=join(Sr,"users.json"),OI=join(he,"state.json"),Ls=join(he,"templates"),qs=join(Ls,"comments"),Fs=join(Ls,"task-templates"),Jn=join(Ls,"tasks"),Wp=join(B_,"templates-system"),Hp=join(Wp,"comments"),Xp=join(Wp,"task-templates");});async function Te(t){try{return await access(t),!0}catch{return false}}async function Js(t,e){await writeFile(t,e,{encoding:"utf-8",mode:384});}async function kt(t){let e=await readFile(t,"utf-8");return JSON.parse(e)}async function pr(t,e){await writeFile(t,JSON.stringify(e,null,2),"utf-8");}var ut=f(()=>{});function K(t){console.log(t);}function Vs(t){console.warn(`Warning: ${t}`);}function de(t){console.error(`Error: ${t}`);}function Tr(t,e){let n=t.map((i,a)=>Math.max(i.length,...e.map(s=>(s[a]??"").length))),o=t.map((i,a)=>i.padEnd(n[a]??0)).join(" "),r=n.map(i=>"-".repeat(i)).join(" ");console.log(o),console.log(r);for(let i of e)console.log(i.map((a,s)=>(a??"").padEnd(n[s]??0)).join(" "));}var tt=f(()=>{});function h(t,e,n){function o(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:false}),s._zod.traits.has(t))return;s._zod.traits.add(t),e(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let m=l[d];m in s||(s[m]=u[m].bind(s));}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:t});function a(s){var c;let u=n?.Parent?new i:this;o(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?true:s?._zod?.traits?.has(t)}),Object.defineProperty(a,"name",{value:t}),a}function ze(t){return t&&Object.assign(xi,t),xi}var Bs,wi,Mt,zr,xi,Vn=f(()=>{Bs=Object.freeze({status:"aborted"});wi=Symbol("zod_brand"),Mt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");}},zr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError";}},xi={};});var b={};Zt(b,{BIGINT_FORMAT_RANGES:()=>sm,Class:()=>em,NUMBER_FORMAT_RANGES:()=>am,aborted:()=>Er,allowsEval:()=>nm,assert:()=>tP,assertEqual:()=>XI,assertIs:()=>QI,assertNever:()=>eP,assertNotEqual:()=>YI,assignProp:()=>Pr,base64ToUint8Array:()=>a$,base64urlToUint8Array:()=>pP,cached:()=>Gn,captureStackTrace:()=>Ks,cleanEnum:()=>dP,cleanRegex:()=>zi,clone:()=>Ue,cloneDef:()=>nP,createTransparentProxy:()=>uP,defineLazy:()=>W,esc:()=>Gs,escapeRegex:()=>It,extend:()=>r$,finalizeIssue:()=>lt,floatSafeRemainder:()=>tm,getElementAtPath:()=>oP,getEnumValues:()=>Ti,getLengthableOrigin:()=>ji,getParsedType:()=>cP,getSizableOrigin:()=>Pi,hexToUint8Array:()=>fP,isObject:()=>dn,isPlainObject:()=>jr,issue:()=>Kn,joinValues:()=>y,jsonStringifyReplacer:()=>Bn,merge:()=>lP,mergeDefs:()=>mr,normalizeParams:()=>S,nullish:()=>Ir,numKeys:()=>sP,objectClone:()=>rP,omit:()=>t$,optionalKeys:()=>im,parsedType:()=>w,partial:()=>o$,pick:()=>e$,prefixIssues:()=>bt,primitiveTypes:()=>om,promiseAllObject:()=>iP,propertyKeyTypes:()=>Ii,randomString:()=>aP,required:()=>i$,safeExtend:()=>n$,shallowClone:()=>Ws,slugify:()=>rm,stringifyPrimitive:()=>k,uint8ArrayToBase64:()=>s$,uint8ArrayToBase64url:()=>mP,uint8ArrayToHex:()=>hP,unwrapMessage:()=>Si});function XI(t){return t}function YI(t){return t}function QI(t){}function eP(t){throw new Error("Unexpected value in exhaustive check")}function tP(t){}function Ti(t){let e=Object.values(t).filter(o=>typeof o=="number");return Object.entries(t).filter(([o,r])=>e.indexOf(+o)===-1).map(([o,r])=>r)}function y(t,e="|"){return t.map(n=>k(n)).join(e)}function Bn(t,e){return typeof e=="bigint"?e.toString():e}function Gn(t){return {get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}}}}function Ir(t){return t==null}function zi(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function tm(t,e){let n=(t.toString().split(".")[1]||"").length,o=e.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]));}let i=n>r?n:r,a=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return a%s/10**i}function W(t,e,n){let o;Object.defineProperty(t,e,{get(){if(o!==Q_)return o===void 0&&(o=Q_,o=n()),o},set(r){Object.defineProperty(t,e,{value:r});},configurable:true});}function rP(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Pr(t,e,n){Object.defineProperty(t,e,{value:n,writable:true,enumerable:true,configurable:true});}function mr(...t){let e={};for(let n of t){let o=Object.getOwnPropertyDescriptors(n);Object.assign(e,o);}return Object.defineProperties({},e)}function nP(t){return mr(t._zod.def)}function oP(t,e){return e?e.reduce((n,o)=>n?.[o],t):t}function iP(t){let e=Object.keys(t),n=e.map(o=>t[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<e.length;i++)r[e[i]]=o[i];return r})}function aP(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<t;o++)n+=e[Math.floor(Math.random()*e.length)];return n}function Gs(t){return JSON.stringify(t)}function rm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function dn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function jr(t){if(dn(t)===false)return false;let e=t.constructor;if(e===void 0||typeof e!="function")return true;let n=e.prototype;return !(dn(n)===false||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===false)}function Ws(t){return jr(t)?{...t}:Array.isArray(t)?[...t]:t}function sP(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function It(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ue(t,e,n){let o=new t._zod.constr(e??t._zod.def);return (!e||n?.parent)&&(o._zod.parent=t),o}function S(t){let e=t;if(!e)return {};if(typeof e=="string")return {error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message;}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function uP(t){let e;return new Proxy({},{get(n,o,r){return e??(e=t()),Reflect.get(e,o,r)},set(n,o,r,i){return e??(e=t()),Reflect.set(e,o,r,i)},has(n,o){return e??(e=t()),Reflect.has(e,o)},deleteProperty(n,o){return e??(e=t()),Reflect.deleteProperty(e,o)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,o){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,o)},defineProperty(n,o,r){return e??(e=t()),Reflect.defineProperty(e,o,r)}})}function k(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function im(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function e$(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=mr(t._zod.def,{get shape(){let a={};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(a[s]=n.shape[s]);}return Pr(this,"shape",a),a},checks:[]});return Ue(t,i)}function t$(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=mr(t._zod.def,{get shape(){let a={...t._zod.def.shape};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete a[s];}return Pr(this,"shape",a),a},checks:[]});return Ue(t,i)}function r$(t,e){if(!jr(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let i=t._zod.def.shape;for(let a in e)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=mr(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return Pr(this,"shape",i),i}});return Ue(t,r)}function n$(t,e){if(!jr(e))throw new Error("Invalid input to safeExtend: expected a plain object");let n=mr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e};return Pr(this,"shape",o),o}});return Ue(t,n)}function lP(t,e){let n=mr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e._zod.def.shape};return Pr(this,"shape",o),o},get catchall(){return e._zod.def.catchall},checks:[]});return Ue(t,n)}function o$(t,e,n){let r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=mr(e._zod.def,{get shape(){let s=e._zod.def.shape,c={...s};if(n)for(let u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:s[u]}):s[u]);}else for(let u in s)c[u]=t?new t({type:"optional",innerType:s[u]}):s[u];return Pr(this,"shape",c),c},checks:[]});return Ue(e,a)}function i$(t,e,n){let o=mr(e._zod.def,{get shape(){let r=e._zod.def.shape,i={...r};if(n)for(let a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new t({type:"nonoptional",innerType:r[a]}));}else for(let a in r)i[a]=new t({type:"nonoptional",innerType:r[a]});return Pr(this,"shape",i),i}});return Ue(e,o)}function Er(t,e=0){if(t.aborted===true)return true;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==true)return true;return false}function bt(t,e){return e.map(n=>{var o;return (o=n).path??(o.path=[]),n.path.unshift(t),n})}function Si(t){return typeof t=="string"?t:t?.message}function lt(t,e,n){let o={...t,path:t.path??[]};if(!t.message){let r=Si(t.inst?._zod.def?.error?.(t))??Si(e?.error?.(t))??Si(n.customError?.(t))??Si(n.localeError?.(t))??"Invalid input";o.message=r;}return delete o.inst,delete o.continue,e?.reportInput||delete o.input,o}function Pi(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function ji(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function w(t){let e=typeof t;switch(e){case "number":return Number.isNaN(t)?"nan":"number";case "object":{if(t===null)return "null";if(Array.isArray(t))return "array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function Kn(...t){let[e,n,o]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:o}:{...e}}function dP(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function a$(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function s$(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function pP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return a$(e+n)}function mP(t){return s$(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fP(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2)n[o/2]=Number.parseInt(e.slice(o,o+2),16);return n}function hP(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Q_,Ks,nm,cP,Ii,om,am,sm,em,A=f(()=>{Q_=Symbol("evaluating");Ks="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};nm=Gn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return false;try{let t=Function;return new t(""),!0}catch{return false}});cP=t=>{let e=typeof t;switch(e){case "undefined":return "undefined";case "string":return "string";case "number":return Number.isNaN(t)?"nan":"number";case "boolean":return "boolean";case "function":return "function";case "bigint":return "bigint";case "symbol":return "symbol";case "object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Ii=new Set(["string","number","symbol"]),om=new Set(["string","number","bigint","boolean","symbol","undefined"]);am={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},sm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};em=class{constructor(...e){}};});function Wn(t,e=n=>n.message){let n={},o=[];for(let r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):o.push(e(r));return {formErrors:o,fieldErrors:n}}function Hn(t,e=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else {let a=n,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(e(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++;}}};return o(t),n}function Hs(t,e=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var a,s;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>o({issues:u},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else {let u=[...i,...c.path];if(u.length===0){n.errors.push(e(c));continue}let l=n,d=0;for(;d<u.length;){let m=u[d],p=d===u.length-1;typeof m=="string"?(l.properties??(l.properties={}),(a=l.properties)[m]??(a[m]={errors:[]}),l=l.properties[m]):(l.items??(l.items=[]),(s=l.items)[m]??(s[m]={errors:[]}),l=l.items[m]),p&&l.errors.push(e(c)),d++;}}};return o(t),n}function u$(t){let e=[],n=t.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?e.push(`[${o}]`):typeof o=="symbol"?e.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?e.push(`[${JSON.stringify(o)}]`):(e.length&&e.push("."),e.push(o));return e.join("")}function Xs(t){let e=[],n=[...t.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)e.push(`\u2716 ${o.message}`),o.path?.length&&e.push(` \u2192 at ${u$(o.path)}`);return e.join(`
2
+ import {readFileSync,readdirSync,existsSync}from'fs';import {readFile,mkdir,writeFile,unlink,readdir,rm as rm$1,stat,access,rename}from'fs/promises';import {homedir}from'os';import {join,dirname,resolve}from'path';import {fileURLToPath}from'url';import Sz from'process';import {Command}from'commander';/*! jira-mcp | Apache-2.0 | Copyright 2024-2026 Lukasz Krzemien (biuro@softspark.eu) | https://github.com/softspark/jira-mcp */
3
+ var xI=Object.create;var Vp=Object.defineProperty;var wI=Object.getOwnPropertyDescriptor;var SI=Object.getOwnPropertyNames;var TI=Object.getPrototypeOf,zI=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Zt=(t,e)=>{for(var n in e)Vp(t,n,{get:e[n],enumerable:true});},II=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of SI(e))!zI.call(t,r)&&r!==n&&Vp(t,r,{get:()=>e[r],enumerable:!(o=wI(e,r))||o.enumerable});return t};var F_=(t,e,n)=>(n=t!=null?xI(TI(t)):{},II(Vp(n,"default",{value:t,enumerable:true}),t));var Ms,Bp=f(()=>{Ms="1.7.0";});var G_={};Zt(G_,{GLOBAL_CACHE_DIR:()=>Sr,GLOBAL_COMMENT_TEMPLATES_DIR:()=>qs,GLOBAL_CONFIG_DIR:()=>he,GLOBAL_CONFIG_PATH:()=>Gp,GLOBAL_CREDENTIALS_PATH:()=>Kp,GLOBAL_STATE_PATH:()=>OI,GLOBAL_TASK_TEMPLATES_DIR:()=>Jn,GLOBAL_TASK_TEMPLATE_DEFINITIONS_DIR:()=>Fs,GLOBAL_TEMPLATES_DIR:()=>Ls,GLOBAL_USERS_PATH:()=>ki,GLOBAL_WORKFLOWS_PATH:()=>$i,PACKAGE_ROOT_DIR:()=>B_,SYSTEM_COMMENT_TEMPLATES_DIR:()=>Hp,SYSTEM_TASK_TEMPLATES_DIR:()=>Xp,SYSTEM_TEMPLATES_DIR:()=>Wp,ensureGlobalDirs:()=>CI});function EI(t){let e=t;for(;;){if(existsSync(join(e,"package.json")))return e;let n=dirname(e);if(n===e)return fileURLToPath(new URL("../..",import.meta.url));e=n;}}async function CI(){await mkdir(he,{recursive:true}),await mkdir(Sr,{recursive:true}),await mkdir(qs,{recursive:true}),await mkdir(Fs,{recursive:true}),await mkdir(Jn,{recursive:true});}var he,B_,Gp,Kp,Sr,$i,ki,OI,Ls,qs,Fs,Jn,Wp,Hp,Xp,Ie=f(()=>{he=join(homedir(),".softspark","jira-mcp");B_=EI(dirname(fileURLToPath(import.meta.url))),Gp=join(he,"config.json"),Kp=join(he,"credentials.json"),Sr=join(he,"cache"),$i=join(Sr,"workflows.json"),ki=join(Sr,"users.json"),OI=join(he,"state.json"),Ls=join(he,"templates"),qs=join(Ls,"comments"),Fs=join(Ls,"task-templates"),Jn=join(Ls,"tasks"),Wp=join(B_,"templates-system"),Hp=join(Wp,"comments"),Xp=join(Wp,"task-templates");});async function Te(t){try{return await access(t),!0}catch{return false}}async function Js(t,e){await writeFile(t,e,{encoding:"utf-8",mode:384});}async function kt(t){let e=await readFile(t,"utf-8");return JSON.parse(e)}async function pr(t,e){await writeFile(t,JSON.stringify(e,null,2),"utf-8");}var ut=f(()=>{});function K(t){console.log(t);}function Vs(t){console.warn(`Warning: ${t}`);}function de(t){console.error(`Error: ${t}`);}function Tr(t,e){let n=t.map((i,a)=>Math.max(i.length,...e.map(s=>(s[a]??"").length))),o=t.map((i,a)=>i.padEnd(n[a]??0)).join(" "),r=n.map(i=>"-".repeat(i)).join(" ");console.log(o),console.log(r);for(let i of e)console.log(i.map((a,s)=>(a??"").padEnd(n[s]??0)).join(" "));}var tt=f(()=>{});function h(t,e,n){function o(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:false}),s._zod.traits.has(t))return;s._zod.traits.add(t),e(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let m=l[d];m in s||(s[m]=u[m].bind(s));}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:t});function a(s){var c;let u=n?.Parent?new i:this;o(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?true:s?._zod?.traits?.has(t)}),Object.defineProperty(a,"name",{value:t}),a}function ze(t){return t&&Object.assign(xi,t),xi}var Bs,wi,Mt,zr,xi,Vn=f(()=>{Bs=Object.freeze({status:"aborted"});wi=Symbol("zod_brand"),Mt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");}},zr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError";}},xi={};});var b={};Zt(b,{BIGINT_FORMAT_RANGES:()=>sm,Class:()=>em,NUMBER_FORMAT_RANGES:()=>am,aborted:()=>Er,allowsEval:()=>nm,assert:()=>tP,assertEqual:()=>XI,assertIs:()=>QI,assertNever:()=>eP,assertNotEqual:()=>YI,assignProp:()=>Pr,base64ToUint8Array:()=>a$,base64urlToUint8Array:()=>pP,cached:()=>Gn,captureStackTrace:()=>Ks,cleanEnum:()=>dP,cleanRegex:()=>zi,clone:()=>Ue,cloneDef:()=>nP,createTransparentProxy:()=>uP,defineLazy:()=>W,esc:()=>Gs,escapeRegex:()=>It,extend:()=>r$,finalizeIssue:()=>lt,floatSafeRemainder:()=>tm,getElementAtPath:()=>oP,getEnumValues:()=>Ti,getLengthableOrigin:()=>ji,getParsedType:()=>cP,getSizableOrigin:()=>Pi,hexToUint8Array:()=>fP,isObject:()=>dn,isPlainObject:()=>jr,issue:()=>Kn,joinValues:()=>y,jsonStringifyReplacer:()=>Bn,merge:()=>lP,mergeDefs:()=>mr,normalizeParams:()=>S,nullish:()=>Ir,numKeys:()=>sP,objectClone:()=>rP,omit:()=>t$,optionalKeys:()=>im,parsedType:()=>w,partial:()=>o$,pick:()=>e$,prefixIssues:()=>bt,primitiveTypes:()=>om,promiseAllObject:()=>iP,propertyKeyTypes:()=>Ii,randomString:()=>aP,required:()=>i$,safeExtend:()=>n$,shallowClone:()=>Ws,slugify:()=>rm,stringifyPrimitive:()=>k,uint8ArrayToBase64:()=>s$,uint8ArrayToBase64url:()=>mP,uint8ArrayToHex:()=>hP,unwrapMessage:()=>Si});function XI(t){return t}function YI(t){return t}function QI(t){}function eP(t){throw new Error("Unexpected value in exhaustive check")}function tP(t){}function Ti(t){let e=Object.values(t).filter(o=>typeof o=="number");return Object.entries(t).filter(([o,r])=>e.indexOf(+o)===-1).map(([o,r])=>r)}function y(t,e="|"){return t.map(n=>k(n)).join(e)}function Bn(t,e){return typeof e=="bigint"?e.toString():e}function Gn(t){return {get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}}}}function Ir(t){return t==null}function zi(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function tm(t,e){let n=(t.toString().split(".")[1]||"").length,o=e.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]));}let i=n>r?n:r,a=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return a%s/10**i}function W(t,e,n){let o;Object.defineProperty(t,e,{get(){if(o!==Q_)return o===void 0&&(o=Q_,o=n()),o},set(r){Object.defineProperty(t,e,{value:r});},configurable:true});}function rP(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Pr(t,e,n){Object.defineProperty(t,e,{value:n,writable:true,enumerable:true,configurable:true});}function mr(...t){let e={};for(let n of t){let o=Object.getOwnPropertyDescriptors(n);Object.assign(e,o);}return Object.defineProperties({},e)}function nP(t){return mr(t._zod.def)}function oP(t,e){return e?e.reduce((n,o)=>n?.[o],t):t}function iP(t){let e=Object.keys(t),n=e.map(o=>t[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<e.length;i++)r[e[i]]=o[i];return r})}function aP(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<t;o++)n+=e[Math.floor(Math.random()*e.length)];return n}function Gs(t){return JSON.stringify(t)}function rm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function dn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function jr(t){if(dn(t)===false)return false;let e=t.constructor;if(e===void 0||typeof e!="function")return true;let n=e.prototype;return !(dn(n)===false||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===false)}function Ws(t){return jr(t)?{...t}:Array.isArray(t)?[...t]:t}function sP(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function It(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ue(t,e,n){let o=new t._zod.constr(e??t._zod.def);return (!e||n?.parent)&&(o._zod.parent=t),o}function S(t){let e=t;if(!e)return {};if(typeof e=="string")return {error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message;}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function uP(t){let e;return new Proxy({},{get(n,o,r){return e??(e=t()),Reflect.get(e,o,r)},set(n,o,r,i){return e??(e=t()),Reflect.set(e,o,r,i)},has(n,o){return e??(e=t()),Reflect.has(e,o)},deleteProperty(n,o){return e??(e=t()),Reflect.deleteProperty(e,o)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,o){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,o)},defineProperty(n,o,r){return e??(e=t()),Reflect.defineProperty(e,o,r)}})}function k(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function im(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function e$(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=mr(t._zod.def,{get shape(){let a={};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(a[s]=n.shape[s]);}return Pr(this,"shape",a),a},checks:[]});return Ue(t,i)}function t$(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=mr(t._zod.def,{get shape(){let a={...t._zod.def.shape};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete a[s];}return Pr(this,"shape",a),a},checks:[]});return Ue(t,i)}function r$(t,e){if(!jr(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let i=t._zod.def.shape;for(let a in e)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=mr(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return Pr(this,"shape",i),i}});return Ue(t,r)}function n$(t,e){if(!jr(e))throw new Error("Invalid input to safeExtend: expected a plain object");let n=mr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e};return Pr(this,"shape",o),o}});return Ue(t,n)}function lP(t,e){let n=mr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e._zod.def.shape};return Pr(this,"shape",o),o},get catchall(){return e._zod.def.catchall},checks:[]});return Ue(t,n)}function o$(t,e,n){let r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=mr(e._zod.def,{get shape(){let s=e._zod.def.shape,c={...s};if(n)for(let u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:s[u]}):s[u]);}else for(let u in s)c[u]=t?new t({type:"optional",innerType:s[u]}):s[u];return Pr(this,"shape",c),c},checks:[]});return Ue(e,a)}function i$(t,e,n){let o=mr(e._zod.def,{get shape(){let r=e._zod.def.shape,i={...r};if(n)for(let a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new t({type:"nonoptional",innerType:r[a]}));}else for(let a in r)i[a]=new t({type:"nonoptional",innerType:r[a]});return Pr(this,"shape",i),i}});return Ue(e,o)}function Er(t,e=0){if(t.aborted===true)return true;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==true)return true;return false}function bt(t,e){return e.map(n=>{var o;return (o=n).path??(o.path=[]),n.path.unshift(t),n})}function Si(t){return typeof t=="string"?t:t?.message}function lt(t,e,n){let o={...t,path:t.path??[]};if(!t.message){let r=Si(t.inst?._zod.def?.error?.(t))??Si(e?.error?.(t))??Si(n.customError?.(t))??Si(n.localeError?.(t))??"Invalid input";o.message=r;}return delete o.inst,delete o.continue,e?.reportInput||delete o.input,o}function Pi(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function ji(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function w(t){let e=typeof t;switch(e){case "number":return Number.isNaN(t)?"nan":"number";case "object":{if(t===null)return "null";if(Array.isArray(t))return "array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function Kn(...t){let[e,n,o]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:o}:{...e}}function dP(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function a$(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function s$(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function pP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return a$(e+n)}function mP(t){return s$(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fP(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2)n[o/2]=Number.parseInt(e.slice(o,o+2),16);return n}function hP(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Q_,Ks,nm,cP,Ii,om,am,sm,em,A=f(()=>{Q_=Symbol("evaluating");Ks="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};nm=Gn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return false;try{let t=Function;return new t(""),!0}catch{return false}});cP=t=>{let e=typeof t;switch(e){case "undefined":return "undefined";case "string":return "string";case "number":return Number.isNaN(t)?"nan":"number";case "boolean":return "boolean";case "function":return "function";case "bigint":return "bigint";case "symbol":return "symbol";case "object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Ii=new Set(["string","number","symbol"]),om=new Set(["string","number","bigint","boolean","symbol","undefined"]);am={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},sm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};em=class{constructor(...e){}};});function Wn(t,e=n=>n.message){let n={},o=[];for(let r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):o.push(e(r));return {formErrors:o,fieldErrors:n}}function Hn(t,e=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else {let a=n,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(e(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++;}}};return o(t),n}function Hs(t,e=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var a,s;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>o({issues:u},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else {let u=[...i,...c.path];if(u.length===0){n.errors.push(e(c));continue}let l=n,d=0;for(;d<u.length;){let m=u[d],p=d===u.length-1;typeof m=="string"?(l.properties??(l.properties={}),(a=l.properties)[m]??(a[m]={errors:[]}),l=l.properties[m]):(l.items??(l.items=[]),(s=l.items)[m]??(s[m]={errors:[]}),l=l.items[m]),p&&l.errors.push(e(c)),d++;}}};return o(t),n}function u$(t){let e=[],n=t.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?e.push(`[${o}]`):typeof o=="symbol"?e.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?e.push(`[${JSON.stringify(o)}]`):(e.length&&e.push("."),e.push(o));return e.join("")}function Xs(t){let e=[],n=[...t.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)e.push(`\u2716 ${o.message}`),o.path?.length&&e.push(` \u2192 at ${u$(o.path)}`);return e.join(`
3
4
  `)}var c$,Ei,dt,cm=f(()=>{Vn();A();c$=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:false}),Object.defineProperty(t,"issues",{value:e,enumerable:false}),t.message=JSON.stringify(e,Bn,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:false});},Ei=h("$ZodError",c$),dt=h("$ZodError",c$,{Parent:Error});});var Xn,Yn,Qn,eo,to,pn,ro,no,Ys,l$,Qs,d$,ec,p$,tc,m$,rc,f$,nc,h$,oc,g$,ic,y$,um=f(()=>{Vn();cm();A();Xn=t=>(e,n,o,r)=>{let i=o?Object.assign(o,{async:false}):{async:false},a=e._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Mt;if(a.issues.length){let s=new(r?.Err??t)(a.issues.map(c=>lt(c,i,ze())));throw Ks(s,r?.callee),s}return a.value},Yn=Xn(dt),Qn=t=>async(e,n,o,r)=>{let i=o?Object.assign(o,{async:true}):{async:true},a=e._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(r?.Err??t)(a.issues.map(c=>lt(c,i,ze())));throw Ks(s,r?.callee),s}return a.value},eo=Qn(dt),to=t=>(e,n,o)=>{let r=o?{...o,async:false}:{async:false},i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Mt;return i.issues.length?{success:false,error:new(t??Ei)(i.issues.map(a=>lt(a,r,ze())))}:{success:true,data:i.value}},pn=to(dt),ro=t=>async(e,n,o)=>{let r=o?Object.assign(o,{async:true}):{async:true},i=e._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:false,error:new t(i.issues.map(a=>lt(a,r,ze())))}:{success:true,data:i.value}},no=ro(dt),Ys=t=>(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Xn(t)(e,n,r)},l$=Ys(dt),Qs=t=>(e,n,o)=>Xn(t)(e,n,o),d$=Qs(dt),ec=t=>async(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Qn(t)(e,n,r)},p$=ec(dt),tc=t=>async(e,n,o)=>Qn(t)(e,n,o),m$=tc(dt),rc=t=>(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(t)(e,n,r)},f$=rc(dt),nc=t=>(e,n,o)=>to(t)(e,n,o),h$=nc(dt),oc=t=>async(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(t)(e,n,r)},g$=oc(dt),ic=t=>async(e,n,o)=>ro(t)(e,n,o),y$=ic(dt);});var pt={};Zt(pt,{base64:()=>Sm,base64url:()=>ac,bigint:()=>Em,boolean:()=>Cm,browserEmail:()=>wP,cidrv4:()=>xm,cidrv6:()=>wm,cuid:()=>lm,cuid2:()=>dm,date:()=>zm,datetime:()=>Pm,domain:()=>zP,duration:()=>gm,e164:()=>Tm,email:()=>vm,emoji:()=>_m,extendedDuration:()=>yP,guid:()=>ym,hex:()=>IP,hostname:()=>TP,html5Email:()=>kP,idnEmail:()=>xP,integer:()=>Om,ipv4:()=>$m,ipv6:()=>km,ksuid:()=>fm,lowercase:()=>Dm,mac:()=>bm,md5_base64:()=>jP,md5_base64url:()=>EP,md5_hex:()=>PP,nanoid:()=>hm,null:()=>Rm,number:()=>sc,rfc5322Email:()=>bP,sha1_base64:()=>CP,sha1_base64url:()=>RP,sha1_hex:()=>OP,sha256_base64:()=>DP,sha256_base64url:()=>AP,sha256_hex:()=>NP,sha384_base64:()=>ZP,sha384_base64url:()=>MP,sha384_hex:()=>UP,sha512_base64:()=>qP,sha512_base64url:()=>FP,sha512_hex:()=>LP,string:()=>jm,time:()=>Im,ulid:()=>pm,undefined:()=>Nm,unicodeEmail:()=>v$,uppercase:()=>Am,uuid:()=>mn,uuid4:()=>vP,uuid6:()=>_P,uuid7:()=>$P,xid:()=>mm});function _m(){return new RegExp(SP,"u")}function $$(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Im(t){return new RegExp(`^${$$(t)}$`)}function Pm(t){let e=$$({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${e}(?:${n.join("|")})`;return new RegExp(`^${_$}T(?:${o})$`)}function Oi(t,e){return new RegExp(`^[A-Za-z0-9+/]{${t}}${e}$`)}function Ci(t){return new RegExp(`^[A-Za-z0-9_-]{${t}}$`)}var lm,dm,pm,mm,fm,hm,gm,yP,ym,mn,vP,_P,$P,vm,kP,bP,v$,xP,wP,SP,$m,km,bm,xm,wm,Sm,ac,TP,zP,Tm,_$,zm,jm,Em,Om,sc,Cm,Rm,Nm,Dm,Am,IP,PP,jP,EP,OP,CP,RP,NP,DP,AP,UP,ZP,MP,LP,qP,FP,cc=f(()=>{A();lm=/^[cC][^\s-]{8,}$/,dm=/^[0-9a-z]+$/,pm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mm=/^[0-9a-vA-V]{20}$/,fm=/^[A-Za-z0-9]{27}$/,hm=/^[a-zA-Z0-9_-]{21}$/,gm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yP=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ym=/^([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})$/,mn=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,vP=mn(4),_P=mn(6),$P=mn(7),vm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,kP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,bP=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,v$=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,xP=v$,wP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,SP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";$m=/^(?:(?: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])$/,km=/^(([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}|:))$/,bm=t=>{let e=It(t??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},xm=/^((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])$/,wm=/^(([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])$/,Sm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ac=/^[A-Za-z0-9_-]*$/,TP=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,zP=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Tm=/^\+[1-9]\d{6,14}$/,_$="(?:(?:\\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])))",zm=new RegExp(`^${_$}$`);jm=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Em=/^-?\d+n?$/,Om=/^-?\d+$/,sc=/^-?\d+(?:\.\d+)?$/,Cm=/^(?:true|false)$/i,Rm=/^null$/i,Nm=/^undefined$/i,Dm=/^[^A-Z]*$/,Am=/^[^a-z]*$/,IP=/^[0-9a-fA-F]*$/;PP=/^[0-9a-fA-F]{32}$/,jP=Oi(22,"=="),EP=Ci(22),OP=/^[0-9a-fA-F]{40}$/,CP=Oi(27,"="),RP=Ci(27),NP=/^[0-9a-fA-F]{64}$/,DP=Oi(43,"="),AP=Ci(43),UP=/^[0-9a-fA-F]{96}$/,ZP=Oi(64,""),MP=Ci(64),LP=/^[0-9a-fA-F]{128}$/,qP=Oi(86,"=="),FP=Ci(86);});function k$(t,e,n){t.issues.length&&e.issues.push(...bt(n,t.issues));}var ge,b$,uc,lc,Um,Zm,Mm,Lm,qm,Fm,Jm,Vm,Bm,oo,Gm,Km,Wm,Hm,Xm,Ym,Qm,ef,tf,dc=f(()=>{Vn();cc();A();ge=h("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[]);}),b$={number:"number",bigint:"bigint",object:"date"},uc=h("$ZodCheckLessThan",(t,e)=>{ge.init(t,e);let n=b$[typeof e.value];t._zod.onattach.push(o=>{let r=o._zod.bag,i=(e.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?r.maximum=e.value:r.exclusiveMaximum=e.value);}),t._zod.check=o=>{(e.inclusive?o.value<=e.value:o.value<e.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:o.value,inclusive:e.inclusive,inst:t,continue:!e.abort});};}),lc=h("$ZodCheckGreaterThan",(t,e)=>{ge.init(t,e);let n=b$[typeof e.value];t._zod.onattach.push(o=>{let r=o._zod.bag,i=(e.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?r.minimum=e.value:r.exclusiveMinimum=e.value);}),t._zod.check=o=>{(e.inclusive?o.value>=e.value:o.value>e.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:o.value,inclusive:e.inclusive,inst:t,continue:!e.abort});};}),Um=h("$ZodCheckMultipleOf",(t,e)=>{ge.init(t,e),t._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=e.value);}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):tm(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort});};}),Zm=h("$ZodCheckNumberFormat",(t,e)=>{ge.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),o=n?"int":"number",[r,i]=am[e.format];t._zod.onattach.push(a=>{let s=a._zod.bag;s.format=e.format,s.minimum=r,s.maximum=i,n&&(s.pattern=Om);}),t._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:o,format:e.format,code:"invalid_type",continue:false,input:s,inst:t});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:o,inclusive:true,continue:!e.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:o,inclusive:true,continue:!e.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:true,inst:t,continue:!e.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:true,inst:t,continue:!e.abort});};}),Mm=h("$ZodCheckBigIntFormat",(t,e)=>{ge.init(t,e);let[n,o]=sm[e.format];t._zod.onattach.push(r=>{let i=r._zod.bag;i.format=e.format,i.minimum=n,i.maximum=o;}),t._zod.check=r=>{let i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:true,inst:t,continue:!e.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:true,inst:t,continue:!e.abort});};}),Lm=h("$ZodCheckMaxSize",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<r&&(o._zod.bag.maximum=e.maximum);}),t._zod.check=o=>{let r=o.value;r.size<=e.maximum||o.issues.push({origin:Pi(r),code:"too_big",maximum:e.maximum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),qm=h("$ZodCheckMinSize",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(o._zod.bag.minimum=e.minimum);}),t._zod.check=o=>{let r=o.value;r.size>=e.minimum||o.issues.push({origin:Pi(r),code:"too_small",minimum:e.minimum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),Fm=h("$ZodCheckSizeEquals",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=e.size,r.maximum=e.size,r.size=e.size;}),t._zod.check=o=>{let r=o.value,i=r.size;if(i===e.size)return;let a=i>e.size;o.issues.push({origin:Pi(r),...a?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:true,exact:true,input:o.value,inst:t,continue:!e.abort});};}),Jm=h("$ZodCheckMaxLength",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<r&&(o._zod.bag.maximum=e.maximum);}),t._zod.check=o=>{let r=o.value;if(r.length<=e.maximum)return;let a=ji(r);o.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),Vm=h("$ZodCheckMinLength",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(o._zod.bag.minimum=e.minimum);}),t._zod.check=o=>{let r=o.value;if(r.length>=e.minimum)return;let a=ji(r);o.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),Bm=h("$ZodCheckLengthEquals",(t,e)=>{var n;ge.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Ir(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=e.length,r.maximum=e.length,r.length=e.length;}),t._zod.check=o=>{let r=o.value,i=r.length;if(i===e.length)return;let a=ji(r),s=i>e.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:true,exact:true,input:o.value,inst:t,continue:!e.abort});};}),oo=h("$ZodCheckStringFormat",(t,e)=>{var n,o;ge.init(t,e),t._zod.onattach.push(r=>{let i=r._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern));}),e.pattern?(n=t._zod).check??(n.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort});}):(o=t._zod).check??(o.check=()=>{});}),Gm=h("$ZodCheckRegex",(t,e)=>{oo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort});};}),Km=h("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Dm),oo.init(t,e);}),Wm=h("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Am),oo.init(t,e);}),Hm=h("$ZodCheckIncludes",(t,e)=>{ge.init(t,e);let n=It(e.includes),o=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=o,t._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o);}),t._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:t,continue:!e.abort});};}),Xm=h("$ZodCheckStartsWith",(t,e)=>{ge.init(t,e);let n=new RegExp(`^${It(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n);}),t._zod.check=o=>{o.value.startsWith(e.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:o.value,inst:t,continue:!e.abort});};}),Ym=h("$ZodCheckEndsWith",(t,e)=>{ge.init(t,e);let n=new RegExp(`.*${It(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n);}),t._zod.check=o=>{o.value.endsWith(e.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:o.value,inst:t,continue:!e.abort});};});Qm=h("$ZodCheckProperty",(t,e)=>{ge.init(t,e),t._zod.check=n=>{let o=e.schema._zod.run({value:n.value[e.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>k$(r,n,e.property));k$(o,n,e.property);};}),ef=h("$ZodCheckMimeType",(t,e)=>{ge.init(t,e);let n=new Set(e.mime);t._zod.onattach.push(o=>{o._zod.bag.mime=e.mime;}),t._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:e.mime,input:o.value.type,inst:t,continue:!e.abort});};}),tf=h("$ZodCheckOverwrite",(t,e)=>{ge.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value);};});});var Ri,rf=f(()=>{Ri=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e);}indented(e){this.indent+=1,e(this),this.indent-=1;}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
4
5
  `).filter(a=>a),r=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a);}compile(){let e=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new e(...n,r.join(`
5
6
  `))}};});var nf,of=f(()=>{nf={major:4,minor:3,patch:6};});function sf(t){if(t==="")return true;if(t.length%4!==0)return false;try{return atob(t),!0}catch{return false}}function N$(t){if(!ac.test(t))return false;let e=t.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return sf(n)}function D$(t,e=null){try{let n=t.split(".");if(n.length!==3)return !1;let[o]=n;if(!o)return !1;let r=JSON.parse(atob(o));return !("typ"in r&&r?.typ!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return false}}function w$(t,e,n){t.issues.length&&e.issues.push(...bt(n,t.issues)),e.value[n]=t.value;}function gc(t,e,n,o,r){if(t.issues.length){if(r&&!(n in o))return;e.issues.push(...bt(n,t.issues));}t.value===void 0?n in o&&(e.value[n]=void 0):e.value[n]=t.value;}function A$(t){let e=Object.keys(t.shape);for(let o of e)if(!t.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let n=im(t.shape);return {...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function U$(t,e,n,o,r,i){let a=[],s=r.keySet,c=r.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in e){if(s.has(d))continue;if(u==="never"){a.push(d);continue}let m=c.run({value:e[d],issues:[]},o);m instanceof Promise?t.push(m.then(p=>gc(p,n,d,e,l))):gc(m,n,d,e,l);}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}function S$(t,e,n,o){for(let i of t)if(i.issues.length===0)return e.value=i.value,e;let r=t.filter(i=>!Er(i));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(a=>lt(a,o,ze())))}),e)}function T$(t,e,n,o){let r=t.filter(i=>i.issues.length===0);return r.length===1?(e.value=r[0].value,e):(r.length===0?e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(a=>lt(a,o,ze())))}):e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:[],inclusive:false}),e)}function af(t,e){if(t===e)return {valid:true,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return {valid:true,data:t};if(jr(t)&&jr(e)){let n=Object.keys(e),o=Object.keys(t).filter(i=>n.indexOf(i)!==-1),r={...t,...e};for(let i of o){let a=af(t[i],e[i]);if(!a.valid)return {valid:false,mergeErrorPath:[i,...a.mergeErrorPath]};r[i]=a.data;}return {valid:true,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return {valid:false,mergeErrorPath:[]};let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e[o],a=af(r,i);if(!a.valid)return {valid:false,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data);}return {valid:true,data:n}}return {valid:false,mergeErrorPath:[]}}function z$(t,e,n){let o=new Map,r;for(let s of e.issues)if(s.code==="unrecognized_keys"){r??(r=s);for(let c of s.keys)o.has(c)||o.set(c,{}),o.get(c).l=true;}else t.issues.push(s);for(let s of n.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)o.has(c)||o.set(c,{}),o.get(c).r=true;else t.issues.push(s);let i=[...o].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&r&&t.issues.push({...r,keys:i}),Er(t))return t;let a=af(e.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return t.value=a.data,t}function pc(t,e,n){t.issues.length&&e.issues.push(...bt(n,t.issues)),e.value[n]=t.value;}function I$(t,e,n,o,r,i,a){t.issues.length&&(Ii.has(typeof o)?n.issues.push(...bt(o,t.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:i,issues:t.issues.map(s=>lt(s,a,ze()))})),e.issues.length&&(Ii.has(typeof o)?n.issues.push(...bt(o,e.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:e.issues.map(s=>lt(s,a,ze()))})),n.value.set(t.value,e.value);}function P$(t,e){t.issues.length&&e.issues.push(...t.issues),e.value.add(t.value);}function j$(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}function E$(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}function O$(t,e){return !t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function mc(t,e,n){return t.issues.length?(t.aborted=true,t):e._zod.run({value:t.value,issues:t.issues},n)}function fc(t,e,n){if(t.issues.length)return t.aborted=true,t;if((n.direction||"forward")==="forward"){let r=e.transform(t.value,t);return r instanceof Promise?r.then(i=>hc(t,i,e.out,n)):hc(t,r,e.out,n)}else {let r=e.reverseTransform(t.value,t);return r instanceof Promise?r.then(i=>hc(t,i,e.in,n)):hc(t,r,e.in,n)}}function hc(t,e,n,o){return t.issues.length?(t.aborted=true,t):n._zod.run({value:e,issues:t.issues},o)}function C$(t){return t.value=Object.freeze(t.value),t}function R$(t,e,n,o){if(!t){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),e.issues.push(Kn(r));}}var J,Or,me,yc,vc,_c,$c,kc,bc,xc,wc,Sc,Tc,zc,Ic,Pc,jc,Ec,Oc,Cc,Rc,Nc,Dc,Ac,Uc,Zc,Mc,Lc,Ni,qc,io,Di,Fc,Jc,Vc,Bc,Gc,Kc,Wc,Hc,Xc,Yc,cf,uf,ao,Qc,eu,tu,Ai,ru,nu,ou,iu,au,su,cu,Ui,uu,lu,du,pu,mu,fu,hu,gu,yu,so,vu,_u,$u,ku,bu,xu,lf=f(()=>{dc();Vn();rf();um();cc();A();of();A();J=h("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=nf;let o=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&o.unshift(t);for(let r of o)for(let i of r._zod.onattach)i(t);if(o.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse;});else {let r=(a,s,c)=>{let u=Er(a),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;let m=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&c?.async===false)throw new Mt;if(l||p instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await p,a.issues.length!==m&&(u||(u=Er(a,m)));});else {if(a.issues.length===m)continue;u||(u=Er(a,m));}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(Er(a))return a.aborted=true,a;let u=r(s,o,c);if(u instanceof Promise){if(c.async===false)throw new Mt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(a,s)=>{if(s.skipChecks)return t._zod.parse(a,s);if(s.direction==="backward"){let u=t._zod.parse({value:a.value,issues:[]},{...s,skipChecks:true});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}let c=t._zod.parse(a,s);if(c instanceof Promise){if(s.async===false)throw new Mt;return c.then(u=>r(u,o,s))}return r(c,o,s)};}W(t,"~standard",()=>({validate:r=>{try{let i=pn(t,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return no(t,r).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}));}),Or=h("$ZodString",(t,e)=>{J.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??jm(t._zod.bag),t._zod.parse=(n,o)=>{if(e.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:t}),n};}),me=h("$ZodStringFormat",(t,e)=>{oo.init(t,e),Or.init(t,e);}),yc=h("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=ym),me.init(t,e);}),vc=h("$ZodUUID",(t,e)=>{if(e.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(o===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=mn(o));}else e.pattern??(e.pattern=mn());me.init(t,e);}),_c=h("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=vm),me.init(t,e);}),$c=h("$ZodURL",(t,e)=>{me.init(t,e),t._zod.check=n=>{try{let o=n.value.trim(),r=new URL(o);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort});}};}),kc=h("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=_m()),me.init(t,e);}),bc=h("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=hm),me.init(t,e);}),xc=h("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=lm),me.init(t,e);}),wc=h("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=dm),me.init(t,e);}),Sc=h("$ZodULID",(t,e)=>{e.pattern??(e.pattern=pm),me.init(t,e);}),Tc=h("$ZodXID",(t,e)=>{e.pattern??(e.pattern=mm),me.init(t,e);}),zc=h("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=fm),me.init(t,e);}),Ic=h("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Pm(e)),me.init(t,e);}),Pc=h("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=zm),me.init(t,e);}),jc=h("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Im(e)),me.init(t,e);}),Ec=h("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=gm),me.init(t,e);}),Oc=h("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=$m),me.init(t,e),t._zod.bag.format="ipv4";}),Cc=h("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=km),me.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`);}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort});}};}),Rc=h("$ZodMAC",(t,e)=>{e.pattern??(e.pattern=bm(e.delimiter)),me.init(t,e),t._zod.bag.format="mac";}),Nc=h("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=xm),me.init(t,e);}),Dc=h("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=wm),me.init(t,e),t._zod.check=n=>{let o=n.value.split("/");try{if(o.length!==2)throw new Error;let[r,i]=o;if(!i)throw new Error;let a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${r}]`);}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort});}};});Ac=h("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Sm),me.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{sf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort});};});Uc=h("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=ac),me.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{N$(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort});};}),Zc=h("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Tm),me.init(t,e);});Mc=h("$ZodJWT",(t,e)=>{me.init(t,e),t._zod.check=n=>{D$(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort});};}),Lc=h("$ZodCustomStringFormat",(t,e)=>{me.init(t,e),t._zod.check=n=>{e.fn(n.value)||n.issues.push({code:"invalid_format",format:e.format,input:n.value,inst:t,continue:!e.abort});};}),Ni=h("$ZodNumber",(t,e)=>{J.init(t,e),t._zod.pattern=t._zod.bag.pattern??sc,t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=Number(n.value);}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:t,...i?{received:i}:{}}),n};}),qc=h("$ZodNumberFormat",(t,e)=>{Zm.init(t,e),Ni.init(t,e);}),io=h("$ZodBoolean",(t,e)=>{J.init(t,e),t._zod.pattern=Cm,t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=!!n.value;}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n};}),Di=h("$ZodBigInt",(t,e)=>{J.init(t,e),t._zod.pattern=Em,t._zod.parse=(n,o)=>{if(e.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:t}),n};}),Fc=h("$ZodBigIntFormat",(t,e)=>{Mm.init(t,e),Di.init(t,e);}),Jc=h("$ZodSymbol",(t,e)=>{J.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:t}),n};}),Vc=h("$ZodUndefined",(t,e)=>{J.init(t,e),t._zod.pattern=Nm,t._zod.values=new Set([void 0]),t._zod.optin="optional",t._zod.optout="optional",t._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:t}),n};}),Bc=h("$ZodNull",(t,e)=>{J.init(t,e),t._zod.pattern=Rm,t._zod.values=new Set([null]),t._zod.parse=(n,o)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:t}),n};}),Gc=h("$ZodAny",(t,e)=>{J.init(t,e),t._zod.parse=n=>n;}),Kc=h("$ZodUnknown",(t,e)=>{J.init(t,e),t._zod.parse=n=>n;}),Wc=h("$ZodNever",(t,e)=>{J.init(t,e),t._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n);}),Hc=h("$ZodVoid",(t,e)=>{J.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:t}),n};}),Xc=h("$ZodDate",(t,e)=>{J.init(t,e),t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=new Date(n.value);}catch{}let r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:t}),n};});Yc=h("$ZodArray",(t,e)=>{J.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);let i=[];for(let a=0;a<r.length;a++){let s=r[a],c=e.element._zod.run({value:s,issues:[]},o);c instanceof Promise?i.push(c.then(u=>w$(u,n,a))):w$(c,n,a);}return i.length?Promise.all(i).then(()=>n):n};});cf=h("$ZodObject",(t,e)=>{if(J.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let s=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...s};return Object.defineProperty(e,"shape",{value:c}),c}});}let o=Gn(()=>A$(e));W(t._zod,"propValues",()=>{let s=e.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d);}}return c});let r=dn,i=e.catchall,a;t._zod.parse=(s,c)=>{a??(a=o.value);let u=s.value;if(!r(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),s;s.value={};let l=[],d=a.shape;for(let m of a.keys){let p=d[m],g=p._zod.optout==="optional",v=p._zod.run({value:u[m],issues:[]},c);v instanceof Promise?l.push(v.then(T=>gc(T,s,m,u,g))):gc(v,s,m,u,g);}return i?U$(l,u,s,c,o.value,t):l.length?Promise.all(l).then(()=>s):s};}),uf=h("$ZodObjectJIT",(t,e)=>{cf.init(t,e);let n=t._zod.parse,o=Gn(()=>A$(e)),r=m=>{let p=new Ri(["shape","payload","ctx"]),g=o.value,v=C=>{let L=Gs(C);return `shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};p.write("const input = payload.value;");let T=Object.create(null),z=0;for(let C of g.keys)T[C]=`key_${z++}`;p.write("const newResult = {};");for(let C of g.keys){let L=T[C],U=Gs(C),Ge=m[C]?._zod?.optout==="optional";p.write(`const ${L} = ${v(C)};`),Ge?p.write(`
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import {readFileSync,readdirSync,existsSync}from'fs';import {mkdir,readFile,writeFile,rename,access}from'fs/promises';import {homedir}from'os';import {join,dirname,resolve}from'path';import {fileURLToPath}from'url';import Nx from'process';var Uw=Object.create;var Pd=Object.defineProperty;var Zw=Object.getOwnPropertyDescriptor;var Mw=Object.getOwnPropertyNames;var Lw=Object.getPrototypeOf,qw=Object.prototype.hasOwnProperty;var Fw=(t,e)=>()=>(t&&(e=t(t=0)),e);var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Dt=(t,e)=>{for(var n in e)Pd(t,n,{get:e[n],enumerable:true});},Vw=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Mw(e))!qw.call(t,r)&&r!==n&&Pd(t,r,{get:()=>e[r],enumerable:!(o=Zw(e,r))||o.enumerable});return t};var gy=(t,e,n)=>(n=t!=null?Uw(Lw(t)):{},Vw(Pd(n,"default",{value:t,enumerable:true}),t));var ma=P(se=>{Object.defineProperty(se,"__esModule",{value:true});se.regexpCode=se.getEsmExportName=se.getProperty=se.safeStringify=se.stringify=se.strConcat=se.addCodeArg=se.str=se._=se.nil=se._Code=se.Name=se.IDENTIFIER=se._CodeOrName=void 0;var da=class{};se._CodeOrName=da;se.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var en=class extends da{constructor(e){if(super(),!se.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};se.Name=en;var yt=class extends da{constructor(e){super(),this._items=typeof e=="string"?[e]:e;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let e=this._items[0];return e===""||e==='""'}get str(){var e;return (e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((n,o)=>`${n}${o}`,"")}get names(){var e;return (e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((n,o)=>(o instanceof en&&(n[o.str]=(n[o.str]||0)+1),n),{})}};se._Code=yt;se.nil=new yt("");function Z$(t,...e){let n=[t[0]],o=0;for(;o<e.length;)eh(n,e[o]),n.push(t[++o]);return new yt(n)}se._=Z$;var Qf=new yt("+");function M$(t,...e){let n=[pa(t[0])],o=0;for(;o<e.length;)n.push(Qf),eh(n,e[o]),n.push(Qf,pa(t[++o]));return RI(n),new yt(n)}se.str=M$;function eh(t,e){e instanceof yt?t.push(...e._items):e instanceof en?t.push(e):t.push(DI(e));}se.addCodeArg=eh;function RI(t){let e=1;for(;e<t.length-1;){if(t[e]===Qf){let n=NI(t[e-1],t[e+1]);if(n!==void 0){t.splice(e-1,3,n);continue}t[e++]="+";}e++;}}function NI(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof en||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof en))return `"${t}${e.slice(1)}`}function CI(t,e){return e.emptyStr()?t:t.emptyStr()?e:M$`${t}${e}`}se.strConcat=CI;function DI(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:pa(Array.isArray(t)?t.join(","):t)}function AI(t){return new yt(pa(t))}se.stringify=AI;function pa(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}se.safeStringify=pa;function UI(t){return typeof t=="string"&&se.IDENTIFIER.test(t)?new yt(`.${t}`):Z$`[${t}]`}se.getProperty=UI;function ZI(t){if(typeof t=="string"&&se.IDENTIFIER.test(t))return new yt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}se.getEsmExportName=ZI;function MI(t){return new yt(t.toString())}se.regexpCode=MI;});var nh=P(Qe=>{Object.defineProperty(Qe,"__esModule",{value:true});Qe.ValueScope=Qe.ValueScopeName=Qe.Scope=Qe.varKinds=Qe.UsedValueState=void 0;var Ye=ma(),th=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value;}},ml;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed";})(ml||(Qe.UsedValueState=ml={}));Qe.varKinds={const:new Ye.Name("const"),let:new Ye.Name("let"),var:new Ye.Name("var")};var fl=class{constructor({prefixes:e,parent:n}={}){this._names={},this._prefixes=e,this._parent=n;}toName(e){return e instanceof Ye.Name?e:this.name(e)}name(e){return new Ye.Name(this._newName(e))}_newName(e){let n=this._names[e]||this._nameGroup(e);return `${e}${n.index++}`}_nameGroup(e){var n,o;if(!((o=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||o===void 0)&&o.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Qe.Scope=fl;var hl=class extends Ye.Name{constructor(e,n){super(n),this.prefix=e;}setValue(e,{property:n,itemIndex:o}){this.value=e,this.scopePath=(0, Ye._)`.${new Ye.Name(n)}[${o}]`;}};Qe.ValueScopeName=hl;var LI=(0, Ye._)`\n`,rh=class extends fl{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?LI:Ye.nil};}get(){return this._scope}name(e){return new hl(e,this._newName(e))}value(e,n){var o;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(e),{prefix:i}=r,a=(o=n.key)!==null&&o!==void 0?o:n.ref,s=this._values[i];if(s){let l=s.get(a);if(l)return l}else s=this._values[i]=new Map;s.set(a,r);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=n.ref,r.setValue(n,{property:i,itemIndex:u}),r}getValue(e,n){let o=this._values[e];if(o)return o.get(n)}scopeRefs(e,n=this._values){return this._reduceValues(n,o=>{if(o.scopePath===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return (0, Ye._)`${e}${o.scopePath}`})}scopeCode(e=this._values,n,o){return this._reduceValues(e,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},n,o)}_reduceValues(e,n,o={},r){let i=Ye.nil;for(let a in e){let s=e[a];if(!s)continue;let c=o[a]=o[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,ml.Started);let l=n(u);if(l){let d=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const;i=(0, Ye._)`${i}${d} ${u} = ${l};${this.opts._n}`;}else if(l=r?.(u))i=(0, Ye._)`${i}${l}${this.opts._n}`;else throw new th(u);c.set(u,ml.Completed);});}return i}};Qe.ValueScope=rh;});var H=P(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.or=Y.and=Y.not=Y.CodeGen=Y.operators=Y.varKinds=Y.ValueScopeName=Y.ValueScope=Y.Scope=Y.Name=Y.regexpCode=Y.stringify=Y.getProperty=Y.nil=Y.strConcat=Y.str=Y._=void 0;var ne=ma(),zt=nh(),xr=ma();Object.defineProperty(Y,"_",{enumerable:true,get:function(){return xr._}});Object.defineProperty(Y,"str",{enumerable:true,get:function(){return xr.str}});Object.defineProperty(Y,"strConcat",{enumerable:true,get:function(){return xr.strConcat}});Object.defineProperty(Y,"nil",{enumerable:true,get:function(){return xr.nil}});Object.defineProperty(Y,"getProperty",{enumerable:true,get:function(){return xr.getProperty}});Object.defineProperty(Y,"stringify",{enumerable:true,get:function(){return xr.stringify}});Object.defineProperty(Y,"regexpCode",{enumerable:true,get:function(){return xr.regexpCode}});Object.defineProperty(Y,"Name",{enumerable:true,get:function(){return xr.Name}});var _l=nh();Object.defineProperty(Y,"Scope",{enumerable:true,get:function(){return _l.Scope}});Object.defineProperty(Y,"ValueScope",{enumerable:true,get:function(){return _l.ValueScope}});Object.defineProperty(Y,"ValueScopeName",{enumerable:true,get:function(){return _l.ValueScopeName}});Object.defineProperty(Y,"varKinds",{enumerable:true,get:function(){return _l.varKinds}});Y.operators={GT:new ne._Code(">"),GTE:new ne._Code(">="),LT:new ne._Code("<"),LTE:new ne._Code("<="),EQ:new ne._Code("==="),NEQ:new ne._Code("!=="),NOT:new ne._Code("!"),OR:new ne._Code("||"),AND:new ne._Code("&&"),ADD:new ne._Code("+")};var er=class{optimizeNodes(){return this}optimizeNames(e,n){return this}},oh=class extends er{constructor(e,n,o){super(),this.varKind=e,this.name=n,this.rhs=o;}render({es5:e,_n:n}){let o=e?zt.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return `${o} ${this.name}${r};`+n}optimizeNames(e,n){if(e[this.name.str])return this.rhs&&(this.rhs=po(this.rhs,e,n)),this}get names(){return this.rhs instanceof ne._CodeOrName?this.rhs.names:{}}},gl=class extends er{constructor(e,n,o){super(),this.lhs=e,this.rhs=n,this.sideEffects=o;}render({_n:e}){return `${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof ne.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=po(this.rhs,e,n),this}get names(){let e=this.lhs instanceof ne.Name?{}:{...this.lhs.names};return vl(e,this.rhs)}},ih=class extends gl{constructor(e,n,o,r){super(e,o,r),this.op=n;}render({_n:e}){return `${this.lhs} ${this.op}= ${this.rhs};`+e}},ah=class extends er{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `${this.label}:`+e}},sh=class extends er{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `break${this.label?` ${this.label}`:""};`+e}},ch=class extends er{constructor(e){super(),this.error=e;}render({_n:e}){return `throw ${this.error};`+e}get names(){return this.error.names}},uh=class extends er{constructor(e){super(),this.code=e;}render({_n:e}){return `${this.code};`+e}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(e,n){return this.code=po(this.code,e,n),this}get names(){return this.code instanceof ne._CodeOrName?this.code.names:{}}},fa=class extends er{constructor(e=[]){super(),this.nodes=e;}render(e){return this.nodes.reduce((n,o)=>n+o.render(e),"")}optimizeNodes(){let{nodes:e}=this,n=e.length;for(;n--;){let o=e[n].optimizeNodes();Array.isArray(o)?e.splice(n,1,...o):o?e[n]=o:e.splice(n,1);}return e.length>0?this:void 0}optimizeNames(e,n){let{nodes:o}=this,r=o.length;for(;r--;){let i=o[r];i.optimizeNames(e,n)||(qI(e,i.names),o.splice(r,1));}return o.length>0?this:void 0}get names(){return this.nodes.reduce((e,n)=>nn(e,n.names),{})}},tr=class extends fa{render(e){return "{"+e._n+super.render(e)+"}"+e._n}},lh=class extends fa{},lo=class extends tr{};lo.kind="else";var tn=class t extends tr{constructor(e,n){super(n),this.condition=e;}render(e){let n=`if(${this.condition})`+super.render(e);return this.else&&(n+="else "+this.else.render(e)),n}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===true)return this.nodes;let n=this.else;if(n){let o=n.optimizeNodes();n=this.else=Array.isArray(o)?new lo(o):o;}if(n)return e===false?n instanceof t?n:n.nodes:this.nodes.length?this:new t(L$(e),n instanceof t?[n]:n.nodes);if(!(e===false||!this.nodes.length))return this}optimizeNames(e,n){var o;if(this.else=(o=this.else)===null||o===void 0?void 0:o.optimizeNames(e,n),!!(super.optimizeNames(e,n)||this.else))return this.condition=po(this.condition,e,n),this}get names(){let e=super.names;return vl(e,this.condition),this.else&&nn(e,this.else.names),e}};tn.kind="if";var rn=class extends tr{};rn.kind="for";var dh=class extends rn{constructor(e){super(),this.iteration=e;}render(e){return `for(${this.iteration})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iteration=po(this.iteration,e,n),this}get names(){return nn(super.names,this.iteration.names)}},ph=class extends rn{constructor(e,n,o,r){super(),this.varKind=e,this.name=n,this.from=o,this.to=r;}render(e){let n=e.es5?zt.varKinds.var:this.varKind,{name:o,from:r,to:i}=this;return `for(${n} ${o}=${r}; ${o}<${i}; ${o}++)`+super.render(e)}get names(){let e=vl(super.names,this.from);return vl(e,this.to)}},yl=class extends rn{constructor(e,n,o,r){super(),this.loop=e,this.varKind=n,this.name=o,this.iterable=r;}render(e){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iterable=po(this.iterable,e,n),this}get names(){return nn(super.names,this.iterable.names)}},ha=class extends tr{constructor(e,n,o){super(),this.name=e,this.args=n,this.async=o;}render(e){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ha.kind="func";var ga=class extends fa{render(e){return "return "+super.render(e)}};ga.kind="return";var mh=class extends tr{render(e){let n="try"+super.render(e);return this.catch&&(n+=this.catch.render(e)),this.finally&&(n+=this.finally.render(e)),n}optimizeNodes(){var e,n;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(e,n){var o,r;return super.optimizeNames(e,n),(o=this.catch)===null||o===void 0||o.optimizeNames(e,n),(r=this.finally)===null||r===void 0||r.optimizeNames(e,n),this}get names(){let e=super.names;return this.catch&&nn(e,this.catch.names),this.finally&&nn(e,this.finally.names),e}},ya=class extends tr{constructor(e){super(),this.error=e;}render(e){return `catch(${this.error})`+super.render(e)}};ya.kind="catch";var va=class extends tr{render(e){return "finally"+super.render(e)}};va.kind="finally";var fh=class{constructor(e,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?`
1
+ import {readFileSync,readdirSync,existsSync}from'fs';import {mkdir,readFile,writeFile,rename,access}from'fs/promises';import {homedir}from'os';import {join,dirname,resolve}from'path';import {fileURLToPath}from'url';import Nx from'process';/*! jira-mcp | Apache-2.0 | Copyright 2024-2026 Lukasz Krzemien (biuro@softspark.eu) | https://github.com/softspark/jira-mcp */
2
+ var Uw=Object.create;var Pd=Object.defineProperty;var Zw=Object.getOwnPropertyDescriptor;var Mw=Object.getOwnPropertyNames;var Lw=Object.getPrototypeOf,qw=Object.prototype.hasOwnProperty;var Fw=(t,e)=>()=>(t&&(e=t(t=0)),e);var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Dt=(t,e)=>{for(var n in e)Pd(t,n,{get:e[n],enumerable:true});},Vw=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Mw(e))!qw.call(t,r)&&r!==n&&Pd(t,r,{get:()=>e[r],enumerable:!(o=Zw(e,r))||o.enumerable});return t};var gy=(t,e,n)=>(n=t!=null?Uw(Lw(t)):{},Vw(Pd(n,"default",{value:t,enumerable:true}),t));var ma=P(se=>{Object.defineProperty(se,"__esModule",{value:true});se.regexpCode=se.getEsmExportName=se.getProperty=se.safeStringify=se.stringify=se.strConcat=se.addCodeArg=se.str=se._=se.nil=se._Code=se.Name=se.IDENTIFIER=se._CodeOrName=void 0;var da=class{};se._CodeOrName=da;se.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var en=class extends da{constructor(e){if(super(),!se.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e;}toString(){return this.str}emptyStr(){return false}get names(){return {[this.str]:1}}};se.Name=en;var yt=class extends da{constructor(e){super(),this._items=typeof e=="string"?[e]:e;}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;let e=this._items[0];return e===""||e==='""'}get str(){var e;return (e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((n,o)=>`${n}${o}`,"")}get names(){var e;return (e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((n,o)=>(o instanceof en&&(n[o.str]=(n[o.str]||0)+1),n),{})}};se._Code=yt;se.nil=new yt("");function Z$(t,...e){let n=[t[0]],o=0;for(;o<e.length;)eh(n,e[o]),n.push(t[++o]);return new yt(n)}se._=Z$;var Qf=new yt("+");function M$(t,...e){let n=[pa(t[0])],o=0;for(;o<e.length;)n.push(Qf),eh(n,e[o]),n.push(Qf,pa(t[++o]));return RI(n),new yt(n)}se.str=M$;function eh(t,e){e instanceof yt?t.push(...e._items):e instanceof en?t.push(e):t.push(DI(e));}se.addCodeArg=eh;function RI(t){let e=1;for(;e<t.length-1;){if(t[e]===Qf){let n=NI(t[e-1],t[e+1]);if(n!==void 0){t.splice(e-1,3,n);continue}t[e++]="+";}e++;}}function NI(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof en||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof en))return `"${t}${e.slice(1)}`}function CI(t,e){return e.emptyStr()?t:t.emptyStr()?e:M$`${t}${e}`}se.strConcat=CI;function DI(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:pa(Array.isArray(t)?t.join(","):t)}function AI(t){return new yt(pa(t))}se.stringify=AI;function pa(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}se.safeStringify=pa;function UI(t){return typeof t=="string"&&se.IDENTIFIER.test(t)?new yt(`.${t}`):Z$`[${t}]`}se.getProperty=UI;function ZI(t){if(typeof t=="string"&&se.IDENTIFIER.test(t))return new yt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}se.getEsmExportName=ZI;function MI(t){return new yt(t.toString())}se.regexpCode=MI;});var nh=P(Qe=>{Object.defineProperty(Qe,"__esModule",{value:true});Qe.ValueScope=Qe.ValueScopeName=Qe.Scope=Qe.varKinds=Qe.UsedValueState=void 0;var Ye=ma(),th=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value;}},ml;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed";})(ml||(Qe.UsedValueState=ml={}));Qe.varKinds={const:new Ye.Name("const"),let:new Ye.Name("let"),var:new Ye.Name("var")};var fl=class{constructor({prefixes:e,parent:n}={}){this._names={},this._prefixes=e,this._parent=n;}toName(e){return e instanceof Ye.Name?e:this.name(e)}name(e){return new Ye.Name(this._newName(e))}_newName(e){let n=this._names[e]||this._nameGroup(e);return `${e}${n.index++}`}_nameGroup(e){var n,o;if(!((o=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||o===void 0)&&o.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Qe.Scope=fl;var hl=class extends Ye.Name{constructor(e,n){super(n),this.prefix=e;}setValue(e,{property:n,itemIndex:o}){this.value=e,this.scopePath=(0, Ye._)`.${new Ye.Name(n)}[${o}]`;}};Qe.ValueScopeName=hl;var LI=(0, Ye._)`\n`,rh=class extends fl{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?LI:Ye.nil};}get(){return this._scope}name(e){return new hl(e,this._newName(e))}value(e,n){var o;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(e),{prefix:i}=r,a=(o=n.key)!==null&&o!==void 0?o:n.ref,s=this._values[i];if(s){let l=s.get(a);if(l)return l}else s=this._values[i]=new Map;s.set(a,r);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=n.ref,r.setValue(n,{property:i,itemIndex:u}),r}getValue(e,n){let o=this._values[e];if(o)return o.get(n)}scopeRefs(e,n=this._values){return this._reduceValues(n,o=>{if(o.scopePath===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return (0, Ye._)`${e}${o.scopePath}`})}scopeCode(e=this._values,n,o){return this._reduceValues(e,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},n,o)}_reduceValues(e,n,o={},r){let i=Ye.nil;for(let a in e){let s=e[a];if(!s)continue;let c=o[a]=o[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,ml.Started);let l=n(u);if(l){let d=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const;i=(0, Ye._)`${i}${d} ${u} = ${l};${this.opts._n}`;}else if(l=r?.(u))i=(0, Ye._)`${i}${l}${this.opts._n}`;else throw new th(u);c.set(u,ml.Completed);});}return i}};Qe.ValueScope=rh;});var H=P(Y=>{Object.defineProperty(Y,"__esModule",{value:true});Y.or=Y.and=Y.not=Y.CodeGen=Y.operators=Y.varKinds=Y.ValueScopeName=Y.ValueScope=Y.Scope=Y.Name=Y.regexpCode=Y.stringify=Y.getProperty=Y.nil=Y.strConcat=Y.str=Y._=void 0;var ne=ma(),zt=nh(),xr=ma();Object.defineProperty(Y,"_",{enumerable:true,get:function(){return xr._}});Object.defineProperty(Y,"str",{enumerable:true,get:function(){return xr.str}});Object.defineProperty(Y,"strConcat",{enumerable:true,get:function(){return xr.strConcat}});Object.defineProperty(Y,"nil",{enumerable:true,get:function(){return xr.nil}});Object.defineProperty(Y,"getProperty",{enumerable:true,get:function(){return xr.getProperty}});Object.defineProperty(Y,"stringify",{enumerable:true,get:function(){return xr.stringify}});Object.defineProperty(Y,"regexpCode",{enumerable:true,get:function(){return xr.regexpCode}});Object.defineProperty(Y,"Name",{enumerable:true,get:function(){return xr.Name}});var _l=nh();Object.defineProperty(Y,"Scope",{enumerable:true,get:function(){return _l.Scope}});Object.defineProperty(Y,"ValueScope",{enumerable:true,get:function(){return _l.ValueScope}});Object.defineProperty(Y,"ValueScopeName",{enumerable:true,get:function(){return _l.ValueScopeName}});Object.defineProperty(Y,"varKinds",{enumerable:true,get:function(){return _l.varKinds}});Y.operators={GT:new ne._Code(">"),GTE:new ne._Code(">="),LT:new ne._Code("<"),LTE:new ne._Code("<="),EQ:new ne._Code("==="),NEQ:new ne._Code("!=="),NOT:new ne._Code("!"),OR:new ne._Code("||"),AND:new ne._Code("&&"),ADD:new ne._Code("+")};var er=class{optimizeNodes(){return this}optimizeNames(e,n){return this}},oh=class extends er{constructor(e,n,o){super(),this.varKind=e,this.name=n,this.rhs=o;}render({es5:e,_n:n}){let o=e?zt.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return `${o} ${this.name}${r};`+n}optimizeNames(e,n){if(e[this.name.str])return this.rhs&&(this.rhs=po(this.rhs,e,n)),this}get names(){return this.rhs instanceof ne._CodeOrName?this.rhs.names:{}}},gl=class extends er{constructor(e,n,o){super(),this.lhs=e,this.rhs=n,this.sideEffects=o;}render({_n:e}){return `${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof ne.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=po(this.rhs,e,n),this}get names(){let e=this.lhs instanceof ne.Name?{}:{...this.lhs.names};return vl(e,this.rhs)}},ih=class extends gl{constructor(e,n,o,r){super(e,o,r),this.op=n;}render({_n:e}){return `${this.lhs} ${this.op}= ${this.rhs};`+e}},ah=class extends er{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `${this.label}:`+e}},sh=class extends er{constructor(e){super(),this.label=e,this.names={};}render({_n:e}){return `break${this.label?` ${this.label}`:""};`+e}},ch=class extends er{constructor(e){super(),this.error=e;}render({_n:e}){return `throw ${this.error};`+e}get names(){return this.error.names}},uh=class extends er{constructor(e){super(),this.code=e;}render({_n:e}){return `${this.code};`+e}optimizeNodes(){return `${this.code}`?this:void 0}optimizeNames(e,n){return this.code=po(this.code,e,n),this}get names(){return this.code instanceof ne._CodeOrName?this.code.names:{}}},fa=class extends er{constructor(e=[]){super(),this.nodes=e;}render(e){return this.nodes.reduce((n,o)=>n+o.render(e),"")}optimizeNodes(){let{nodes:e}=this,n=e.length;for(;n--;){let o=e[n].optimizeNodes();Array.isArray(o)?e.splice(n,1,...o):o?e[n]=o:e.splice(n,1);}return e.length>0?this:void 0}optimizeNames(e,n){let{nodes:o}=this,r=o.length;for(;r--;){let i=o[r];i.optimizeNames(e,n)||(qI(e,i.names),o.splice(r,1));}return o.length>0?this:void 0}get names(){return this.nodes.reduce((e,n)=>nn(e,n.names),{})}},tr=class extends fa{render(e){return "{"+e._n+super.render(e)+"}"+e._n}},lh=class extends fa{},lo=class extends tr{};lo.kind="else";var tn=class t extends tr{constructor(e,n){super(n),this.condition=e;}render(e){let n=`if(${this.condition})`+super.render(e);return this.else&&(n+="else "+this.else.render(e)),n}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===true)return this.nodes;let n=this.else;if(n){let o=n.optimizeNodes();n=this.else=Array.isArray(o)?new lo(o):o;}if(n)return e===false?n instanceof t?n:n.nodes:this.nodes.length?this:new t(L$(e),n instanceof t?[n]:n.nodes);if(!(e===false||!this.nodes.length))return this}optimizeNames(e,n){var o;if(this.else=(o=this.else)===null||o===void 0?void 0:o.optimizeNames(e,n),!!(super.optimizeNames(e,n)||this.else))return this.condition=po(this.condition,e,n),this}get names(){let e=super.names;return vl(e,this.condition),this.else&&nn(e,this.else.names),e}};tn.kind="if";var rn=class extends tr{};rn.kind="for";var dh=class extends rn{constructor(e){super(),this.iteration=e;}render(e){return `for(${this.iteration})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iteration=po(this.iteration,e,n),this}get names(){return nn(super.names,this.iteration.names)}},ph=class extends rn{constructor(e,n,o,r){super(),this.varKind=e,this.name=n,this.from=o,this.to=r;}render(e){let n=e.es5?zt.varKinds.var:this.varKind,{name:o,from:r,to:i}=this;return `for(${n} ${o}=${r}; ${o}<${i}; ${o}++)`+super.render(e)}get names(){let e=vl(super.names,this.from);return vl(e,this.to)}},yl=class extends rn{constructor(e,n,o,r){super(),this.loop=e,this.varKind=n,this.name=o,this.iterable=r;}render(e){return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,n){if(super.optimizeNames(e,n))return this.iterable=po(this.iterable,e,n),this}get names(){return nn(super.names,this.iterable.names)}},ha=class extends tr{constructor(e,n,o){super(),this.name=e,this.args=n,this.async=o;}render(e){return `${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ha.kind="func";var ga=class extends fa{render(e){return "return "+super.render(e)}};ga.kind="return";var mh=class extends tr{render(e){let n="try"+super.render(e);return this.catch&&(n+=this.catch.render(e)),this.finally&&(n+=this.finally.render(e)),n}optimizeNodes(){var e,n;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(e,n){var o,r;return super.optimizeNames(e,n),(o=this.catch)===null||o===void 0||o.optimizeNames(e,n),(r=this.finally)===null||r===void 0||r.optimizeNames(e,n),this}get names(){let e=super.names;return this.catch&&nn(e,this.catch.names),this.finally&&nn(e,this.finally.names),e}},ya=class extends tr{constructor(e){super(),this.error=e;}render(e){return `catch(${this.error})`+super.render(e)}};ya.kind="catch";var va=class extends tr{render(e){return "finally"+super.render(e)}};va.kind="finally";var fh=class{constructor(e,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?`
2
3
  `:""},this._extScope=e,this._scope=new zt.Scope({parent:e}),this._nodes=[new lh];}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,n){let o=this._extScope.value(e,n);return (this._values[o.prefix]||(this._values[o.prefix]=new Set)).add(o),o}getScopeValue(e,n){return this._extScope.getValue(e,n)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,n,o,r){let i=this._scope.toName(n);return o!==void 0&&r&&(this._constants[i.str]=o),this._leafNode(new oh(e,i,o)),i}const(e,n,o){return this._def(zt.varKinds.const,e,n,o)}let(e,n,o){return this._def(zt.varKinds.let,e,n,o)}var(e,n,o){return this._def(zt.varKinds.var,e,n,o)}assign(e,n,o){return this._leafNode(new gl(e,n,o))}add(e,n){return this._leafNode(new ih(e,Y.operators.ADD,n))}code(e){return typeof e=="function"?e():e!==ne.nil&&this._leafNode(new uh(e)),this}object(...e){let n=["{"];for(let[o,r]of e)n.length>1&&n.push(","),n.push(o),(o!==r||this.opts.es5)&&(n.push(":"),(0, ne.addCodeArg)(n,r));return n.push("}"),new ne._Code(n)}if(e,n,o){if(this._blockNode(new tn(e)),n&&o)this.code(n).else().code(o).endIf();else if(n)this.code(n).endIf();else if(o)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new tn(e))}else(){return this._elseNode(new lo)}endIf(){return this._endBlockNode(tn,lo)}_for(e,n){return this._blockNode(e),n&&this.code(n).endFor(),this}for(e,n){return this._for(new dh(e),n)}forRange(e,n,o,r,i=this.opts.es5?zt.varKinds.var:zt.varKinds.let){let a=this._scope.toName(e);return this._for(new ph(i,a,n,o),()=>r(a))}forOf(e,n,o,r=zt.varKinds.const){let i=this._scope.toName(e);if(this.opts.es5){let a=n instanceof ne.Name?n:this.var("_arr",n);return this.forRange("_i",0,(0, ne._)`${a}.length`,s=>{this.var(i,(0, ne._)`${a}[${s}]`),o(i);})}return this._for(new yl("of",r,i,n),()=>o(i))}forIn(e,n,o,r=this.opts.es5?zt.varKinds.var:zt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0, ne._)`Object.keys(${n})`,o);let i=this._scope.toName(e);return this._for(new yl("in",r,i,n),()=>o(i))}endFor(){return this._endBlockNode(rn)}label(e){return this._leafNode(new ah(e))}break(e){return this._leafNode(new sh(e))}return(e){let n=new ga;if(this._blockNode(n),this.code(e),n.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ga)}try(e,n,o){if(!n&&!o)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new mh;if(this._blockNode(r),this.code(e),n){let i=this.name("e");this._currNode=r.catch=new ya(i),n(i);}return o&&(this._currNode=r.finally=new va,this.code(o)),this._endBlockNode(ya,va)}throw(e){return this._leafNode(new ch(e))}block(e,n){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(n),this}endBlock(e){let n=this._blockStarts.pop();if(n===void 0)throw new Error("CodeGen: not in self-balancing block");let o=this._nodes.length-n;if(o<0||e!==void 0&&o!==e)throw new Error(`CodeGen: wrong number of nodes: ${o} vs ${e} expected`);return this._nodes.length=n,this}func(e,n=ne.nil,o,r){return this._blockNode(new ha(e,n,o)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(ha)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants);}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e);}_endBlockNode(e,n){let o=this._currNode;if(o instanceof e||n&&o instanceof n)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${n?`${e.kind}/${n.kind}`:e.kind}"`)}_elseNode(e){let n=this._currNode;if(!(n instanceof tn))throw new Error('CodeGen: "else" without "if"');return this._currNode=n.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let n=this._nodes;n[n.length-1]=e;}};Y.CodeGen=fh;function nn(t,e){for(let n in e)t[n]=(t[n]||0)+(e[n]||0);return t}function vl(t,e){return e instanceof ne._CodeOrName?nn(t,e.names):t}function po(t,e,n){if(t instanceof ne.Name)return o(t);if(!r(t))return t;return new ne._Code(t._items.reduce((i,a)=>(a instanceof ne.Name&&(a=o(a)),a instanceof ne._Code?i.push(...a._items):i.push(a),i),[]));function o(i){let a=n[i.str];return a===void 0||e[i.str]!==1?i:(delete e[i.str],a)}function r(i){return i instanceof ne._Code&&i._items.some(a=>a instanceof ne.Name&&e[a.str]===1&&n[a.str]!==void 0)}}function qI(t,e){for(let n in e)t[n]=(t[n]||0)-(e[n]||0);}function L$(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0, ne._)`!${hh(t)}`}Y.not=L$;var FI=q$(Y.operators.AND);function VI(...t){return t.reduce(FI)}Y.and=VI;var JI=q$(Y.operators.OR);function GI(...t){return t.reduce(JI)}Y.or=GI;function q$(t){return (e,n)=>e===ne.nil?n:n===ne.nil?e:(0, ne._)`${hh(e)} ${t} ${hh(n)}`}function hh(t){return t instanceof ne.Name?t:(0, ne._)`(${t})`}});var oe=P(ee=>{Object.defineProperty(ee,"__esModule",{value:true});ee.checkStrictMode=ee.getErrorPath=ee.Type=ee.useFunc=ee.setEvaluated=ee.evaluatedPropsToName=ee.mergeEvaluated=ee.eachItem=ee.unescapeJsonPointer=ee.escapeJsonPointer=ee.escapeFragment=ee.unescapeFragment=ee.schemaRefOrVal=ee.schemaHasRulesButRef=ee.schemaHasRules=ee.checkUnknownRules=ee.alwaysValidSchema=ee.toHash=void 0;var ye=H(),BI=ma();function KI(t){let e={};for(let n of t)e[n]=true;return e}ee.toHash=KI;function HI(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?true:(J$(t,e),!G$(e,t.self.RULES.all))}ee.alwaysValidSchema=HI;function J$(t,e=t.schema){let{opts:n,self:o}=t;if(!n.strictSchema||typeof e=="boolean")return;let r=o.RULES.keywords;for(let i in e)r[i]||H$(t,`unknown keyword: "${i}"`);}ee.checkUnknownRules=J$;function G$(t,e){if(typeof t=="boolean")return !t;for(let n in t)if(e[n])return true;return false}ee.schemaHasRules=G$;function WI(t,e){if(typeof t=="boolean")return !t;for(let n in t)if(n!=="$ref"&&e.all[n])return true;return false}ee.schemaHasRulesButRef=WI;function XI({topSchemaRef:t,schemaPath:e},n,o,r){if(!r){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return (0, ye._)`${n}`}return (0, ye._)`${t}${e}${(0, ye.getProperty)(o)}`}ee.schemaRefOrVal=XI;function YI(t){return B$(decodeURIComponent(t))}ee.unescapeFragment=YI;function QI(t){return encodeURIComponent(yh(t))}ee.escapeFragment=QI;function yh(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ee.escapeJsonPointer=yh;function B$(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ee.unescapeJsonPointer=B$;function eP(t,e){if(Array.isArray(t))for(let n of t)e(n);else e(t);}ee.eachItem=eP;function F$({mergeNames:t,mergeToName:e,mergeValues:n,resultToName:o}){return (r,i,a,s)=>{let c=a===void 0?i:a instanceof ye.Name?(i instanceof ye.Name?t(r,i,a):e(r,i,a),a):i instanceof ye.Name?(e(r,a,i),i):n(i,a);return s===ye.Name&&!(c instanceof ye.Name)?o(r,c):c}}ee.mergeEvaluated={props:F$({mergeNames:(t,e,n)=>t.if((0, ye._)`${n} !== true && ${e} !== undefined`,()=>{t.if((0, ye._)`${e} === true`,()=>t.assign(n,true),()=>t.assign(n,(0, ye._)`${n} || {}`).code((0, ye._)`Object.assign(${n}, ${e})`));}),mergeToName:(t,e,n)=>t.if((0, ye._)`${n} !== true`,()=>{e===true?t.assign(n,true):(t.assign(n,(0, ye._)`${n} || {}`),vh(t,n,e));}),mergeValues:(t,e)=>t===true?true:{...t,...e},resultToName:K$}),items:F$({mergeNames:(t,e,n)=>t.if((0, ye._)`${n} !== true && ${e} !== undefined`,()=>t.assign(n,(0, ye._)`${e} === true ? true : ${n} > ${e} ? ${n} : ${e}`)),mergeToName:(t,e,n)=>t.if((0, ye._)`${n} !== true`,()=>t.assign(n,e===true?true:(0, ye._)`${n} > ${e} ? ${n} : ${e}`)),mergeValues:(t,e)=>t===true?true:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function K$(t,e){if(e===true)return t.var("props",true);let n=t.var("props",(0, ye._)`{}`);return e!==void 0&&vh(t,n,e),n}ee.evaluatedPropsToName=K$;function vh(t,e,n){Object.keys(n).forEach(o=>t.assign((0, ye._)`${e}${(0, ye.getProperty)(o)}`,true));}ee.setEvaluated=vh;var V$={};function tP(t,e){return t.scopeValue("func",{ref:e,code:V$[e.code]||(V$[e.code]=new BI._Code(e.code))})}ee.useFunc=tP;var gh;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str";})(gh||(ee.Type=gh={}));function rP(t,e,n){if(t instanceof ye.Name){let o=e===gh.Num;return n?o?(0, ye._)`"[" + ${t} + "]"`:(0, ye._)`"['" + ${t} + "']"`:o?(0, ye._)`"/" + ${t}`:(0, ye._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0, ye.getProperty)(t).toString():"/"+yh(t)}ee.getErrorPath=rP;function H$(t,e,n=t.opts.strictSchema){if(n){if(e=`strict mode: ${e}`,n===true)throw new Error(e);t.self.logger.warn(e);}}ee.checkStrictMode=H$;});var rr=P(_h=>{Object.defineProperty(_h,"__esModule",{value:true});var Ze=H(),nP={data:new Ze.Name("data"),valCxt:new Ze.Name("valCxt"),instancePath:new Ze.Name("instancePath"),parentData:new Ze.Name("parentData"),parentDataProperty:new Ze.Name("parentDataProperty"),rootData:new Ze.Name("rootData"),dynamicAnchors:new Ze.Name("dynamicAnchors"),vErrors:new Ze.Name("vErrors"),errors:new Ze.Name("errors"),this:new Ze.Name("this"),self:new Ze.Name("self"),scope:new Ze.Name("scope"),json:new Ze.Name("json"),jsonPos:new Ze.Name("jsonPos"),jsonLen:new Ze.Name("jsonLen"),jsonPart:new Ze.Name("jsonPart")};_h.default=nP;});var _a=P(Me=>{Object.defineProperty(Me,"__esModule",{value:true});Me.extendErrors=Me.resetErrorsCount=Me.reportExtraError=Me.reportError=Me.keyword$DataError=Me.keywordError=void 0;var ie=H(),$l=oe(),Je=rr();Me.keywordError={message:({keyword:t})=>(0, ie.str)`must pass "${t}" keyword validation`};Me.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0, ie.str)`"${t}" keyword must be ${e} ($data)`:(0, ie.str)`"${t}" keyword is invalid ($data)`};function oP(t,e=Me.keywordError,n,o){let{it:r}=t,{gen:i,compositeRule:a,allErrors:s}=r,c=Y$(t,e,n);o??(a||s)?W$(i,c):X$(r,(0, ie._)`[${c}]`);}Me.reportError=oP;function iP(t,e=Me.keywordError,n){let{it:o}=t,{gen:r,compositeRule:i,allErrors:a}=o,s=Y$(t,e,n);W$(r,s),i||a||X$(o,Je.default.vErrors);}Me.reportExtraError=iP;function aP(t,e){t.assign(Je.default.errors,e),t.if((0, ie._)`${Je.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0, ie._)`${Je.default.vErrors}.length`,e),()=>t.assign(Je.default.vErrors,null)));}Me.resetErrorsCount=aP;function sP({gen:t,keyword:e,schemaValue:n,data:o,errsCount:r,it:i}){if(r===void 0)throw new Error("ajv implementation error");let a=t.name("err");t.forRange("i",r,Je.default.errors,s=>{t.const(a,(0, ie._)`${Je.default.vErrors}[${s}]`),t.if((0, ie._)`${a}.instancePath === undefined`,()=>t.assign((0, ie._)`${a}.instancePath`,(0, ie.strConcat)(Je.default.instancePath,i.errorPath))),t.assign((0, ie._)`${a}.schemaPath`,(0, ie.str)`${i.errSchemaPath}/${e}`),i.opts.verbose&&(t.assign((0, ie._)`${a}.schema`,n),t.assign((0, ie._)`${a}.data`,o));});}Me.extendErrors=sP;function W$(t,e){let n=t.const("err",e);t.if((0, ie._)`${Je.default.vErrors} === null`,()=>t.assign(Je.default.vErrors,(0, ie._)`[${n}]`),(0, ie._)`${Je.default.vErrors}.push(${n})`),t.code((0, ie._)`${Je.default.errors}++`);}function X$(t,e){let{gen:n,validateName:o,schemaEnv:r}=t;r.$async?n.throw((0, ie._)`new ${t.ValidationError}(${e})`):(n.assign((0, ie._)`${o}.errors`,e),n.return(false));}var on={keyword:new ie.Name("keyword"),schemaPath:new ie.Name("schemaPath"),params:new ie.Name("params"),propertyName:new ie.Name("propertyName"),message:new ie.Name("message"),schema:new ie.Name("schema"),parentSchema:new ie.Name("parentSchema")};function Y$(t,e,n){let{createErrors:o}=t.it;return o===false?(0, ie._)`{}`:cP(t,e,n)}function cP(t,e,n={}){let{gen:o,it:r}=t,i=[uP(r,n),lP(t,n)];return dP(t,e,i),o.object(...i)}function uP({errorPath:t},{instancePath:e}){let n=e?(0, ie.str)`${t}${(0, $l.getErrorPath)(e,$l.Type.Str)}`:t;return [Je.default.instancePath,(0, ie.strConcat)(Je.default.instancePath,n)]}function lP({keyword:t,it:{errSchemaPath:e}},{schemaPath:n,parentSchema:o}){let r=o?e:(0, ie.str)`${e}/${t}`;return n&&(r=(0, ie.str)`${r}${(0, $l.getErrorPath)(n,$l.Type.Str)}`),[on.schemaPath,r]}function dP(t,{params:e,message:n},o){let{keyword:r,data:i,schemaValue:a,it:s}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=s;o.push([on.keyword,r],[on.params,typeof e=="function"?e(t):e||(0, ie._)`{}`]),c.messages&&o.push([on.message,typeof n=="function"?n(t):n]),c.verbose&&o.push([on.schema,a],[on.parentSchema,(0, ie._)`${l}${d}`],[Je.default.data,i]),u&&o.push([on.propertyName,u]);}});var ek=P(mo=>{Object.defineProperty(mo,"__esModule",{value:true});mo.boolOrEmptySchema=mo.topBoolOrEmptySchema=void 0;var pP=_a(),mP=H(),fP=rr(),hP={message:"boolean schema is false"};function gP(t){let{gen:e,schema:n,validateName:o}=t;n===false?Q$(t,false):typeof n=="object"&&n.$async===true?e.return(fP.default.data):(e.assign((0, mP._)`${o}.errors`,null),e.return(true));}mo.topBoolOrEmptySchema=gP;function yP(t,e){let{gen:n,schema:o}=t;o===false?(n.var(e,false),Q$(t)):n.var(e,true);}mo.boolOrEmptySchema=yP;function Q$(t,e){let{gen:n,data:o}=t,r={gen:n,keyword:"false schema",data:o,schema:false,schemaCode:false,schemaValue:false,params:{},it:t};(0, pP.reportError)(r,hP,void 0,e);}});var $h=P(fo=>{Object.defineProperty(fo,"__esModule",{value:true});fo.getRules=fo.isJSONType=void 0;var vP=["string","number","integer","boolean","null","object","array"],_P=new Set(vP);function $P(t){return typeof t=="string"&&_P.has(t)}fo.isJSONType=$P;function kP(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return {types:{...t,integer:true,boolean:true,null:true},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}fo.getRules=kP;});var kh=P(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.shouldUseRule=wr.shouldUseGroup=wr.schemaHasRulesForType=void 0;function bP({schema:t,self:e},n){let o=e.RULES.types[n];return o&&o!==true&&tk(t,o)}wr.schemaHasRulesForType=bP;function tk(t,e){return e.rules.some(n=>rk(t,n))}wr.shouldUseGroup=tk;function rk(t,e){var n;return t[e.keyword]!==void 0||((n=e.definition.implements)===null||n===void 0?void 0:n.some(o=>t[o]!==void 0))}wr.shouldUseRule=rk;});var $a=P(Le=>{Object.defineProperty(Le,"__esModule",{value:true});Le.reportTypeError=Le.checkDataTypes=Le.checkDataType=Le.coerceAndCheckDataType=Le.getJSONTypes=Le.getSchemaTypes=Le.DataType=void 0;var xP=$h(),wP=kh(),SP=_a(),K=H(),nk=oe(),ho;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong";})(ho||(Le.DataType=ho={}));function TP(t){let e=ok(t.type);if(e.includes("null")){if(t.nullable===false)throw new Error("type: null contradicts nullable: false")}else {if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===true&&e.push("null");}return e}Le.getSchemaTypes=TP;function ok(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(xP.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Le.getJSONTypes=ok;function zP(t,e){let{gen:n,data:o,opts:r}=t,i=IP(e,r.coerceTypes),a=e.length>0&&!(i.length===0&&e.length===1&&(0, wP.schemaHasRulesForType)(t,e[0]));if(a){let s=xh(e,o,r.strictNumbers,ho.Wrong);n.if(s,()=>{i.length?PP(t,e,i):wh(t);});}return a}Le.coerceAndCheckDataType=zP;var ik=new Set(["string","number","integer","boolean","null"]);function IP(t,e){return e?t.filter(n=>ik.has(n)||e==="array"&&n==="array"):[]}function PP(t,e,n){let{gen:o,data:r,opts:i}=t,a=o.let("dataType",(0, K._)`typeof ${r}`),s=o.let("coerced",(0, K._)`undefined`);i.coerceTypes==="array"&&o.if((0, K._)`${a} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>o.assign(r,(0, K._)`${r}[0]`).assign(a,(0, K._)`typeof ${r}`).if(xh(e,r,i.strictNumbers),()=>o.assign(s,r))),o.if((0, K._)`${s} !== undefined`);for(let u of n)(ik.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);o.else(),wh(t),o.endIf(),o.if((0, K._)`${s} !== undefined`,()=>{o.assign(r,s),jP(t,s);});function c(u){switch(u){case "string":o.elseIf((0, K._)`${a} == "number" || ${a} == "boolean"`).assign(s,(0, K._)`"" + ${r}`).elseIf((0, K._)`${r} === null`).assign(s,(0, K._)`""`);return;case "number":o.elseIf((0, K._)`${a} == "boolean" || ${r} === null
3
4
  || (${a} == "string" && ${r} && ${r} == +${r})`).assign(s,(0, K._)`+${r}`);return;case "integer":o.elseIf((0, K._)`${a} === "boolean" || ${r} === null
4
5
  || (${a} === "string" && ${r} && ${r} == +${r} && !(${r} % 1))`).assign(s,(0, K._)`+${r}`);return;case "boolean":o.elseIf((0, K._)`${r} === "false" || ${r} === 0 || ${r} === null`).assign(s,false).elseIf((0, K._)`${r} === "true" || ${r} === 1`).assign(s,true);return;case "null":o.elseIf((0, K._)`${r} === "" || ${r} === 0 || ${r} === false`),o.assign(s,null);return;case "array":o.elseIf((0, K._)`${a} === "string" || ${a} === "number"
@@ -46,7 +47,7 @@ import {readFileSync,readdirSync,existsSync}from'fs';import {mkdir,readFile,writ
46
47
 
47
48
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of t.seen.entries()){let s=a[1];if(e===a[0]){i(a);continue}if(t.external){let u=t.external.registry.get(a[0])?.id;if(e!==a[0]&&u){i(a);continue}}if(t.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&t.reused==="ref"){i(a);continue}}}function vr(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=a=>{let s=t.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){o(l);let m=t.seen.get(l),p=m.schema;if(p.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):Object.assign(c,p),Object.assign(c,u),a._zod.parent===l)for(let v in c)v==="$ref"||v==="allOf"||v in u||delete c[v];if(p.$ref&&m.def)for(let v in c)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(c[v])===JSON.stringify(m.def[v])&&delete c[v];}let d=a._zod.parent;if(d&&d!==l){o(d);let m=t.seen.get(d);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(let p in c)p==="$ref"||p==="allOf"||p in m.def&&JSON.stringify(c[p])===JSON.stringify(m.def[p])&&delete c[p];}t.override({zodSchema:a,jsonSchema:c,path:s.path??[]});};for(let a of [...t.seen.entries()].reverse())o(a[0]);let r={};if(t.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(a);}Object.assign(r,n.def??n.schema);let i=t.external?.defs??{};for(let a of t.seen.entries()){let s=a[1];s.def&&s.defId&&(i[s.defId]=s.def);}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Wn(e,"input",t.processors),output:Wn(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ve(t,e){let n=e??{seen:new Set};if(n.seen.has(t))return false;n.seen.add(t);let o=t._zod.def;if(o.type==="transform")return true;if(o.type==="array")return Ve(o.element,n);if(o.type==="set")return Ve(o.valueType,n);if(o.type==="lazy")return Ve(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Ve(o.innerType,n);if(o.type==="intersection")return Ve(o.left,n)||Ve(o.right,n);if(o.type==="record"||o.type==="map")return Ve(o.keyType,n)||Ve(o.valueType,n);if(o.type==="pipe")return Ve(o.in,n)||Ve(o.out,n);if(o.type==="object"){for(let r in o.shape)if(Ve(o.shape[r],n))return true;return false}if(o.type==="union"){for(let r of o.options)if(Ve(r,n))return true;return false}if(o.type==="tuple"){for(let r of o.items)if(Ve(r,n))return true;return !!(o.rest&&Ve(o.rest,n))}return false}var Vp=(t,e={})=>n=>{let o=gr({...n,processors:e});return ce(t,o),yr(o,t),vr(o,t)},Wn=(t,e,n={})=>o=>{let{libraryOptions:r,target:i}=o??{},a=gr({...r??{},target:i,io:e,processors:n});return ce(t,a),yr(a,t),vr(a,t)};var PT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jp=(t,e,n,o)=>{let r=n;r.type="string";let{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof a=="number"&&(r.maxLength=a),s&&(r.format=PT[s]??s,r.format===""&&delete r.format,s==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?r.pattern=l[0].source:l.length>1&&(r.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]);}},Gp=(t,e,n,o)=>{let r=n,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof s=="string"&&s.includes("int")?r.type="integer":r.type="number",typeof l=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(r.minimum=l,r.exclusiveMinimum=true):r.exclusiveMinimum=l),typeof i=="number"&&(r.minimum=i,typeof l=="number"&&e.target!=="draft-04"&&(l>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=true):r.exclusiveMaximum=u),typeof a=="number"&&(r.maximum=a,typeof u=="number"&&e.target!=="draft-04"&&(u<=a?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c);},Bp=(t,e,n,o)=>{n.type="boolean";},Kp=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Hp=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Wp=(t,e,n,o)=>{e.target==="openapi-3.0"?(n.type="string",n.nullable=true,n.enum=[null]):n.type="null";},Xp=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Yp=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Qp=(t,e,n,o)=>{n.not={};},em=(t,e,n,o)=>{},tm=(t,e,n,o)=>{},rm=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},nm=(t,e,n,o)=>{let r=t._zod.def,i=ei(r.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i;},om=(t,e,n,o)=>{let r=t._zod.def,i=[];for(let a of r.values)if(a===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a));}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];n.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[a]:n.const=a;}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i;},im=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},am=(t,e,n,o)=>{let r=n,i=t._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=i.source;},sm=(t,e,n,o)=>{let r=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=t._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),c?c.length===1?(i.contentMediaType=c[0],Object.assign(r,i)):(Object.assign(r,i),r.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(r,i);},cm=(t,e,n,o)=>{n.type="boolean";},um=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},lm=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},dm=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},pm=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},mm=(t,e,n,o)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},fm=(t,e,n,o)=>{let r=n,i=t._zod.def,{minimum:a,maximum:s}=t._zod.bag;typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=ce(i.element,e,{...o,path:[...o.path,"items"]});},hm=(t,e,n,o)=>{let r=n,i=t._zod.def;r.type="object",r.properties={};let a=i.shape;for(let u in a)r.properties[u]=ce(a[u],e,{...o,path:[...o.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=i.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(r.required=Array.from(c)),i.catchall?._zod.def.type==="never"?r.additionalProperties=false:i.catchall?i.catchall&&(r.additionalProperties=ce(i.catchall,e,{...o,path:[...o.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=false);},yu=(t,e,n,o)=>{let r=t._zod.def,i=r.inclusive===false,a=r.options.map((s,c)=>ce(s,e,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=a:n.anyOf=a;},gm=(t,e,n,o)=>{let r=t._zod.def,i=ce(r.left,e,{...o,path:[...o.path,"allOf",0]}),a=ce(r.right,e,{...o,path:[...o.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];n.allOf=c;},ym=(t,e,n,o)=>{let r=n,i=t._zod.def;r.type="array";let a=e.target==="draft-2020-12"?"prefixItems":"items",s=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,p)=>ce(m,e,{...o,path:[...o.path,a,p]})),u=i.rest?ce(i.rest,e,{...o,path:[...o.path,s,...e.target==="openapi-3.0"?[i.items.length]:[]]}):null;e.target==="draft-2020-12"?(r.prefixItems=c,u&&(r.items=u)):e.target==="openapi-3.0"?(r.items={anyOf:c},u&&r.items.anyOf.push(u),r.minItems=c.length,u||(r.maxItems=c.length)):(r.items=c,u&&(r.additionalItems=u));let{minimum:l,maximum:d}=t._zod.bag;typeof l=="number"&&(r.minItems=l),typeof d=="number"&&(r.maxItems=d);},vm=(t,e,n,o)=>{let r=n,i=t._zod.def;r.type="object";let a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=ce(i.valueType,e,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(let d of c)r.patternProperties[d.source]=l;}else (e.target==="draft-07"||e.target==="draft-2020-12")&&(r.propertyNames=ce(i.keyType,e,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=ce(i.valueType,e,{...o,path:[...o.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(r.required=l);}},_m=(t,e,n,o)=>{let r=t._zod.def,i=ce(r.innerType,e,o),a=e.seen.get(t);e.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=true):n.anyOf=[i,{type:"null"}];},$m=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType;},km=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue));},bm=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)));},xm=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType;let a;try{a=r.catchValue(void 0);}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a;},wm=(t,e,n,o)=>{let r=t._zod.def,i=e.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;ce(i,e,o);let a=e.seen.get(t);a.ref=i;},Sm=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType,n.readOnly=true;},Tm=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType;},vu=(t,e,n,o)=>{let r=t._zod.def;ce(r.innerType,e,o);let i=e.seen.get(t);i.ref=r.innerType;},zm=(t,e,n,o)=>{let r=t._zod.innerType;ce(r,e,o);let i=e.seen.get(t);i.ref=r;},gu={string:Jp,number:Gp,boolean:Bp,bigint:Kp,symbol:Hp,null:Wp,undefined:Xp,void:Yp,never:Qp,any:em,unknown:tm,date:rm,enum:nm,literal:om,nan:im,template_literal:am,file:sm,success:cm,custom:um,function:lm,transform:dm,map:pm,set:mm,array:fm,object:hm,union:yu,intersection:gm,tuple:ym,record:vm,nullable:_m,nonoptional:$m,default:km,prefault:bm,catch:xm,pipe:wm,readonly:Sm,promise:Tm,optional:vu,lazy:zm};function Xn(t,e){if("_idmap"in t){let o=t,r=gr({...e,processors:gu}),i={};for(let c of o._idmap.entries()){let[u,l]=c;ce(l,r);}let a={},s={registry:o,uri:e?.uri,defs:i};r.external=s;for(let c of o._idmap.entries()){let[u,l]=c;yr(r,l),a[u]=vr(r,l);}if(Object.keys(i).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:i};}return {schemas:a}}let n=gr({...e,processors:gu});return ce(t,n),yr(n,t),vr(n,t)}var _u=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e;}get seen(){return this.ctx.seen}constructor(e){let n=e?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=gr({processors:gu,target:n,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}});}process(e,n={path:[],schemaPath:[]}){return ce(e,this.ctx,n)}emit(e,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),yr(this.ctx,e);let o=vr(this.ctx,e),{"~standard":r,...i}=o;return i}};var a_={};function Yn(t){return !!t._zod}function _r(t,e){return Yn(t)?Zr(t,e):t.safeParse(e)}function $u(t){if(!t)return;let e;if(Yn(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function u_(t){if(Yn(t)){let i=t._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let n=t._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}let o=t.value;if(o!==void 0)return o}var x={};Dt(x,{$brand:()=>Yo,$input:()=>Ec,$output:()=>jc,NEVER:()=>Wa,TimePrecision:()=>Cc,ZodAny:()=>Km,ZodArray:()=>Ym,ZodBase64:()=>Mu,ZodBase64URL:()=>Lu,ZodBigInt:()=>oo,ZodBigIntFormat:()=>Vu,ZodBoolean:()=>no,ZodCIDRv4:()=>Uu,ZodCIDRv6:()=>Zu,ZodCUID:()=>Eu,ZodCUID2:()=>Ou,ZodCatch:()=>_f,ZodCodec:()=>Wu,ZodCustom:()=>Xi,ZodCustomStringFormat:()=>to,ZodDate:()=>Gi,ZodDefault:()=>mf,ZodDiscriminatedUnion:()=>ef,ZodE164:()=>qu,ZodEmail:()=>Iu,ZodEmoji:()=>Pu,ZodEnum:()=>Qn,ZodError:()=>CT,ZodExactOptional:()=>lf,ZodFile:()=>cf,ZodFirstPartyTypeKind:()=>Ef,ZodFunction:()=>If,ZodGUID:()=>Li,ZodIPv4:()=>Du,ZodIPv6:()=>Au,ZodISODate:()=>xu,ZodISODateTime:()=>bu,ZodISODuration:()=>Su,ZodISOTime:()=>wu,ZodIntersection:()=>tf,ZodIssueCode:()=>AT,ZodJWT:()=>Fu,ZodKSUID:()=>Cu,ZodLazy:()=>Sf,ZodLiteral:()=>sf,ZodMAC:()=>Vm,ZodMap:()=>of,ZodNaN:()=>kf,ZodNanoID:()=>ju,ZodNever:()=>Wm,ZodNonOptional:()=>Ku,ZodNull:()=>Bm,ZodNullable:()=>pf,ZodNumber:()=>ro,ZodNumberFormat:()=>Qr,ZodObject:()=>Bi,ZodOptional:()=>Bu,ZodPipe:()=>Hu,ZodPrefault:()=>hf,ZodPromise:()=>zf,ZodReadonly:()=>bf,ZodRealError:()=>Xe,ZodRecord:()=>Wi,ZodSet:()=>af,ZodString:()=>eo,ZodStringFormat:()=>pe,ZodSuccess:()=>vf,ZodSymbol:()=>Jm,ZodTemplateLiteral:()=>wf,ZodTransform:()=>uf,ZodTuple:()=>rf,ZodType:()=>J,ZodULID:()=>Ru,ZodURL:()=>Vi,ZodUUID:()=>Zt,ZodUndefined:()=>Gm,ZodUnion:()=>Ki,ZodUnknown:()=>Hm,ZodVoid:()=>Xm,ZodXID:()=>Nu,ZodXor:()=>Qm,_ZodString:()=>zu,_default:()=>ff,_function:()=>p$,any:()=>K_,array:()=>X,base64:()=>E_,base64url:()=>O_,bigint:()=>F_,boolean:()=>ke,catch:()=>$f,check:()=>m$,cidrv4:()=>P_,cidrv6:()=>j_,clone:()=>Ie,codec:()=>u$,coerce:()=>Of,config:()=>$e,core:()=>st,cuid:()=>k_,cuid2:()=>b_,custom:()=>Xu,date:()=>W_,decode:()=>Am,decodeAsync:()=>Zm,describe:()=>f$,discriminatedUnion:()=>Hi,e164:()=>R_,email:()=>d_,emoji:()=>__,encode:()=>Dm,encodeAsync:()=>Um,endsWith:()=>Gr,enum:()=>Ee,exactOptional:()=>df,file:()=>i$,flattenError:()=>On,float32:()=>Z_,float64:()=>M_,formatError:()=>Rn,fromJSONSchema:()=>$$,function:()=>p$,getErrorMap:()=>ZT,globalRegistry:()=>ze,gt:()=>St,gte:()=>Pe,guid:()=>p_,hash:()=>U_,hex:()=>A_,hostname:()=>D_,httpUrl:()=>v_,includes:()=>Vr,instanceof:()=>g$,int:()=>Tu,int32:()=>L_,int64:()=>V_,intersection:()=>io,ipv4:()=>T_,ipv6:()=>I_,iso:()=>$r,json:()=>v$,jwt:()=>N_,keyof:()=>X_,ksuid:()=>S_,lazy:()=>Tf,length:()=>hr,literal:()=>N,locales:()=>Gn,looseObject:()=>je,looseRecord:()=>t$,lowercase:()=>qr,lt:()=>wt,lte:()=>Fe,mac:()=>z_,map:()=>r$,maxLength:()=>fr,maxSize:()=>Yt,meta:()=>h$,mime:()=>Br,minLength:()=>Ut,minSize:()=>Tt,multipleOf:()=>Xt,nan:()=>c$,nanoid:()=>$_,nativeEnum:()=>o$,negative:()=>Di,never:()=>Ju,nonnegative:()=>Ui,nonoptional:()=>yf,nonpositive:()=>Ai,normalize:()=>Kr,null:()=>Ji,nullable:()=>qi,nullish:()=>a$,number:()=>ae,object:()=>j,optional:()=>ge,overwrite:()=>ft,parse:()=>Om,parseAsync:()=>Rm,partialRecord:()=>e$,pipe:()=>Fi,positive:()=>Ci,prefault:()=>gf,preprocess:()=>Yi,prettifyError:()=>ts,promise:()=>d$,property:()=>Zi,readonly:()=>xf,record:()=>le,refine:()=>Pf,regex:()=>Lr,regexes:()=>We,registry:()=>fi,safeDecode:()=>Lm,safeDecodeAsync:()=>Fm,safeEncode:()=>Mm,safeEncodeAsync:()=>qm,safeParse:()=>Nm,safeParseAsync:()=>Cm,set:()=>n$,setErrorMap:()=>UT,size:()=>mr,slugify:()=>Hn,startsWith:()=>Jr,strictObject:()=>Y_,string:()=>y,stringFormat:()=>C_,stringbool:()=>y$,success:()=>s$,superRefine:()=>jf,symbol:()=>G_,templateLiteral:()=>l$,toJSONSchema:()=>Xn,toLowerCase:()=>Wr,toUpperCase:()=>Xr,transform:()=>Gu,treeifyError:()=>es,trim:()=>Hr,tuple:()=>nf,uint32:()=>q_,uint64:()=>J_,ulid:()=>x_,undefined:()=>B_,union:()=>fe,unknown:()=>me,uppercase:()=>Fr,url:()=>y_,util:()=>k,uuid:()=>m_,uuidv4:()=>f_,uuidv6:()=>h_,uuidv7:()=>g_,void:()=>H_,xid:()=>w_,xor:()=>Q_});var Mi={};Dt(Mi,{ZodAny:()=>Km,ZodArray:()=>Ym,ZodBase64:()=>Mu,ZodBase64URL:()=>Lu,ZodBigInt:()=>oo,ZodBigIntFormat:()=>Vu,ZodBoolean:()=>no,ZodCIDRv4:()=>Uu,ZodCIDRv6:()=>Zu,ZodCUID:()=>Eu,ZodCUID2:()=>Ou,ZodCatch:()=>_f,ZodCodec:()=>Wu,ZodCustom:()=>Xi,ZodCustomStringFormat:()=>to,ZodDate:()=>Gi,ZodDefault:()=>mf,ZodDiscriminatedUnion:()=>ef,ZodE164:()=>qu,ZodEmail:()=>Iu,ZodEmoji:()=>Pu,ZodEnum:()=>Qn,ZodExactOptional:()=>lf,ZodFile:()=>cf,ZodFunction:()=>If,ZodGUID:()=>Li,ZodIPv4:()=>Du,ZodIPv6:()=>Au,ZodIntersection:()=>tf,ZodJWT:()=>Fu,ZodKSUID:()=>Cu,ZodLazy:()=>Sf,ZodLiteral:()=>sf,ZodMAC:()=>Vm,ZodMap:()=>of,ZodNaN:()=>kf,ZodNanoID:()=>ju,ZodNever:()=>Wm,ZodNonOptional:()=>Ku,ZodNull:()=>Bm,ZodNullable:()=>pf,ZodNumber:()=>ro,ZodNumberFormat:()=>Qr,ZodObject:()=>Bi,ZodOptional:()=>Bu,ZodPipe:()=>Hu,ZodPrefault:()=>hf,ZodPromise:()=>zf,ZodReadonly:()=>bf,ZodRecord:()=>Wi,ZodSet:()=>af,ZodString:()=>eo,ZodStringFormat:()=>pe,ZodSuccess:()=>vf,ZodSymbol:()=>Jm,ZodTemplateLiteral:()=>wf,ZodTransform:()=>uf,ZodTuple:()=>rf,ZodType:()=>J,ZodULID:()=>Ru,ZodURL:()=>Vi,ZodUUID:()=>Zt,ZodUndefined:()=>Gm,ZodUnion:()=>Ki,ZodUnknown:()=>Hm,ZodVoid:()=>Xm,ZodXID:()=>Nu,ZodXor:()=>Qm,_ZodString:()=>zu,_default:()=>ff,_function:()=>p$,any:()=>K_,array:()=>X,base64:()=>E_,base64url:()=>O_,bigint:()=>F_,boolean:()=>ke,catch:()=>$f,check:()=>m$,cidrv4:()=>P_,cidrv6:()=>j_,codec:()=>u$,cuid:()=>k_,cuid2:()=>b_,custom:()=>Xu,date:()=>W_,describe:()=>f$,discriminatedUnion:()=>Hi,e164:()=>R_,email:()=>d_,emoji:()=>__,enum:()=>Ee,exactOptional:()=>df,file:()=>i$,float32:()=>Z_,float64:()=>M_,function:()=>p$,guid:()=>p_,hash:()=>U_,hex:()=>A_,hostname:()=>D_,httpUrl:()=>v_,instanceof:()=>g$,int:()=>Tu,int32:()=>L_,int64:()=>V_,intersection:()=>io,ipv4:()=>T_,ipv6:()=>I_,json:()=>v$,jwt:()=>N_,keyof:()=>X_,ksuid:()=>S_,lazy:()=>Tf,literal:()=>N,looseObject:()=>je,looseRecord:()=>t$,mac:()=>z_,map:()=>r$,meta:()=>h$,nan:()=>c$,nanoid:()=>$_,nativeEnum:()=>o$,never:()=>Ju,nonoptional:()=>yf,null:()=>Ji,nullable:()=>qi,nullish:()=>a$,number:()=>ae,object:()=>j,optional:()=>ge,partialRecord:()=>e$,pipe:()=>Fi,prefault:()=>gf,preprocess:()=>Yi,promise:()=>d$,readonly:()=>xf,record:()=>le,refine:()=>Pf,set:()=>n$,strictObject:()=>Y_,string:()=>y,stringFormat:()=>C_,stringbool:()=>y$,success:()=>s$,superRefine:()=>jf,symbol:()=>G_,templateLiteral:()=>l$,transform:()=>Gu,tuple:()=>nf,uint32:()=>q_,uint64:()=>J_,ulid:()=>x_,undefined:()=>B_,union:()=>fe,unknown:()=>me,url:()=>y_,uuid:()=>m_,uuidv4:()=>f_,uuidv6:()=>h_,uuidv7:()=>g_,void:()=>H_,xid:()=>w_,xor:()=>Q_});var ku={};Dt(ku,{endsWith:()=>Gr,gt:()=>St,gte:()=>Pe,includes:()=>Vr,length:()=>hr,lowercase:()=>qr,lt:()=>wt,lte:()=>Fe,maxLength:()=>fr,maxSize:()=>Yt,mime:()=>Br,minLength:()=>Ut,minSize:()=>Tt,multipleOf:()=>Xt,negative:()=>Di,nonnegative:()=>Ui,nonpositive:()=>Ai,normalize:()=>Kr,overwrite:()=>ft,positive:()=>Ci,property:()=>Zi,regex:()=>Lr,size:()=>mr,slugify:()=>Hn,startsWith:()=>Jr,toLowerCase:()=>Wr,toUpperCase:()=>Xr,trim:()=>Hr,uppercase:()=>Fr});var $r={};Dt($r,{ZodISODate:()=>xu,ZodISODateTime:()=>bu,ZodISODuration:()=>Su,ZodISOTime:()=>wu,date:()=>Pm,datetime:()=>Im,duration:()=>Em,time:()=>jm});var bu=f("ZodISODateTime",(t,e)=>{js.init(t,e),pe.init(t,e);});function Im(t){return Dc(bu,t)}var xu=f("ZodISODate",(t,e)=>{Es.init(t,e),pe.init(t,e);});function Pm(t){return Ac(xu,t)}var wu=f("ZodISOTime",(t,e)=>{Os.init(t,e),pe.init(t,e);});function jm(t){return Uc(wu,t)}var Su=f("ZodISODuration",(t,e)=>{Rs.init(t,e),pe.init(t,e);});function Em(t){return Zc(Su,t)}var l_=(t,e)=>{ii.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>Rn(t,n)},flatten:{value:n=>On(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,Pn,2);}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,Pn,2);}},isEmpty:{get(){return t.issues.length===0}}});},CT=f("ZodError",l_),Xe=f("ZodError",l_,{Parent:Error});var Om=Nn(Xe),Rm=Dn(Xe),Nm=Un(Xe),Cm=Zn(Xe),Dm=rs(Xe),Am=ns(Xe),Um=os(Xe),Zm=is(Xe),Mm=as(Xe),Lm=ss(Xe),qm=cs(Xe),Fm=us(Xe);var J=f("ZodType",(t,e)=>(q.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Wn(t,"input"),output:Wn(t,"output")}}),t.toJSONSchema=Vp(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(k.mergeDefs(e,{checks:[...e.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:true}),t.with=t.check,t.clone=(n,o)=>Ie(t,n,o),t.brand=()=>t,t.register=((n,o)=>(n.add(t,o),t)),t.parse=(n,o)=>Om(t,n,o,{callee:t.parse}),t.safeParse=(n,o)=>Nm(t,n,o),t.parseAsync=async(n,o)=>Rm(t,n,o,{callee:t.parseAsync}),t.safeParseAsync=async(n,o)=>Cm(t,n,o),t.spa=t.safeParseAsync,t.encode=(n,o)=>Dm(t,n,o),t.decode=(n,o)=>Am(t,n,o),t.encodeAsync=async(n,o)=>Um(t,n,o),t.decodeAsync=async(n,o)=>Zm(t,n,o),t.safeEncode=(n,o)=>Mm(t,n,o),t.safeDecode=(n,o)=>Lm(t,n,o),t.safeEncodeAsync=async(n,o)=>qm(t,n,o),t.safeDecodeAsync=async(n,o)=>Fm(t,n,o),t.refine=(n,o)=>t.check(Pf(n,o)),t.superRefine=n=>t.check(jf(n)),t.overwrite=n=>t.check(ft(n)),t.optional=()=>ge(t),t.exactOptional=()=>df(t),t.nullable=()=>qi(t),t.nullish=()=>ge(qi(t)),t.nonoptional=n=>yf(t,n),t.array=()=>X(t),t.or=n=>fe([t,n]),t.and=n=>io(t,n),t.transform=n=>Fi(t,Gu(n)),t.default=n=>ff(t,n),t.prefault=n=>gf(t,n),t.catch=n=>$f(t,n),t.pipe=n=>Fi(t,n),t.readonly=()=>xf(t),t.describe=n=>{let o=t.clone();return ze.add(o,{description:n}),o},Object.defineProperty(t,"description",{get(){return ze.get(t)?.description},configurable:true}),t.meta=(...n)=>{if(n.length===0)return ze.get(t);let o=t.clone();return ze.add(o,n[0]),o},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=n=>n(t),t)),zu=f("_ZodString",(t,e)=>{pr.init(t,e),J.init(t,e),t._zod.processJSONSchema=(o,r,i)=>Jp(t,o,r);let n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...o)=>t.check(Lr(...o)),t.includes=(...o)=>t.check(Vr(...o)),t.startsWith=(...o)=>t.check(Jr(...o)),t.endsWith=(...o)=>t.check(Gr(...o)),t.min=(...o)=>t.check(Ut(...o)),t.max=(...o)=>t.check(fr(...o)),t.length=(...o)=>t.check(hr(...o)),t.nonempty=(...o)=>t.check(Ut(1,...o)),t.lowercase=o=>t.check(qr(o)),t.uppercase=o=>t.check(Fr(o)),t.trim=()=>t.check(Hr()),t.normalize=(...o)=>t.check(Kr(...o)),t.toLowerCase=()=>t.check(Wr()),t.toUpperCase=()=>t.check(Xr()),t.slugify=()=>t.check(Hn());}),eo=f("ZodString",(t,e)=>{pr.init(t,e),zu.init(t,e),t.email=n=>t.check(hi(Iu,n)),t.url=n=>t.check(Kn(Vi,n)),t.jwt=n=>t.check(Ni(Fu,n)),t.emoji=n=>t.check($i(Pu,n)),t.guid=n=>t.check(Bn(Li,n)),t.uuid=n=>t.check(gi(Zt,n)),t.uuidv4=n=>t.check(yi(Zt,n)),t.uuidv6=n=>t.check(vi(Zt,n)),t.uuidv7=n=>t.check(_i(Zt,n)),t.nanoid=n=>t.check(ki(ju,n)),t.guid=n=>t.check(Bn(Li,n)),t.cuid=n=>t.check(bi(Eu,n)),t.cuid2=n=>t.check(xi(Ou,n)),t.ulid=n=>t.check(wi(Ru,n)),t.base64=n=>t.check(Ei(Mu,n)),t.base64url=n=>t.check(Oi(Lu,n)),t.xid=n=>t.check(Si(Nu,n)),t.ksuid=n=>t.check(Ti(Cu,n)),t.ipv4=n=>t.check(zi(Du,n)),t.ipv6=n=>t.check(Ii(Au,n)),t.cidrv4=n=>t.check(Pi(Uu,n)),t.cidrv6=n=>t.check(ji(Zu,n)),t.e164=n=>t.check(Ri(qu,n)),t.datetime=n=>t.check(Im(n)),t.date=n=>t.check(Pm(n)),t.time=n=>t.check(jm(n)),t.duration=n=>t.check(Em(n));});function y(t){return Oc(eo,t)}var pe=f("ZodStringFormat",(t,e)=>{ue.init(t,e),zu.init(t,e);}),Iu=f("ZodEmail",(t,e)=>{ks.init(t,e),pe.init(t,e);});function d_(t){return hi(Iu,t)}var Li=f("ZodGUID",(t,e)=>{_s.init(t,e),pe.init(t,e);});function p_(t){return Bn(Li,t)}var Zt=f("ZodUUID",(t,e)=>{$s.init(t,e),pe.init(t,e);});function m_(t){return gi(Zt,t)}function f_(t){return yi(Zt,t)}function h_(t){return vi(Zt,t)}function g_(t){return _i(Zt,t)}var Vi=f("ZodURL",(t,e)=>{bs.init(t,e),pe.init(t,e);});function y_(t){return Kn(Vi,t)}function v_(t){return Kn(Vi,{protocol:/^https?$/,hostname:We.domain,...k.normalizeParams(t)})}var Pu=f("ZodEmoji",(t,e)=>{xs.init(t,e),pe.init(t,e);});function __(t){return $i(Pu,t)}var ju=f("ZodNanoID",(t,e)=>{ws.init(t,e),pe.init(t,e);});function $_(t){return ki(ju,t)}var Eu=f("ZodCUID",(t,e)=>{Ss.init(t,e),pe.init(t,e);});function k_(t){return bi(Eu,t)}var Ou=f("ZodCUID2",(t,e)=>{Ts.init(t,e),pe.init(t,e);});function b_(t){return xi(Ou,t)}var Ru=f("ZodULID",(t,e)=>{zs.init(t,e),pe.init(t,e);});function x_(t){return wi(Ru,t)}var Nu=f("ZodXID",(t,e)=>{Is.init(t,e),pe.init(t,e);});function w_(t){return Si(Nu,t)}var Cu=f("ZodKSUID",(t,e)=>{Ps.init(t,e),pe.init(t,e);});function S_(t){return Ti(Cu,t)}var Du=f("ZodIPv4",(t,e)=>{Ns.init(t,e),pe.init(t,e);});function T_(t){return zi(Du,t)}var Vm=f("ZodMAC",(t,e)=>{Ds.init(t,e),pe.init(t,e);});function z_(t){return Nc(Vm,t)}var Au=f("ZodIPv6",(t,e)=>{Cs.init(t,e),pe.init(t,e);});function I_(t){return Ii(Au,t)}var Uu=f("ZodCIDRv4",(t,e)=>{As.init(t,e),pe.init(t,e);});function P_(t){return Pi(Uu,t)}var Zu=f("ZodCIDRv6",(t,e)=>{Us.init(t,e),pe.init(t,e);});function j_(t){return ji(Zu,t)}var Mu=f("ZodBase64",(t,e)=>{Zs.init(t,e),pe.init(t,e);});function E_(t){return Ei(Mu,t)}var Lu=f("ZodBase64URL",(t,e)=>{Ms.init(t,e),pe.init(t,e);});function O_(t){return Oi(Lu,t)}var qu=f("ZodE164",(t,e)=>{Ls.init(t,e),pe.init(t,e);});function R_(t){return Ri(qu,t)}var Fu=f("ZodJWT",(t,e)=>{qs.init(t,e),pe.init(t,e);});function N_(t){return Ni(Fu,t)}var to=f("ZodCustomStringFormat",(t,e)=>{Fs.init(t,e),pe.init(t,e);});function C_(t,e,n={}){return Yr(to,t,e,n)}function D_(t){return Yr(to,"hostname",We.hostname,t)}function A_(t){return Yr(to,"hex",We.hex,t)}function U_(t,e){let n=e?.enc??"hex",o=`${t}_${n}`,r=We[o];if(!r)throw new Error(`Unrecognized hash format: ${o}`);return Yr(to,o,r,e)}var ro=f("ZodNumber",(t,e)=>{ui.init(t,e),J.init(t,e),t._zod.processJSONSchema=(o,r,i)=>Gp(t,o,r),t.gt=(o,r)=>t.check(St(o,r)),t.gte=(o,r)=>t.check(Pe(o,r)),t.min=(o,r)=>t.check(Pe(o,r)),t.lt=(o,r)=>t.check(wt(o,r)),t.lte=(o,r)=>t.check(Fe(o,r)),t.max=(o,r)=>t.check(Fe(o,r)),t.int=o=>t.check(Tu(o)),t.safe=o=>t.check(Tu(o)),t.positive=o=>t.check(St(0,o)),t.nonnegative=o=>t.check(Pe(0,o)),t.negative=o=>t.check(wt(0,o)),t.nonpositive=o=>t.check(Fe(0,o)),t.multipleOf=(o,r)=>t.check(Xt(o,r)),t.step=(o,r)=>t.check(Xt(o,r)),t.finite=()=>t;let n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=true,t.format=n.format??null;});function ae(t){return Mc(ro,t)}var Qr=f("ZodNumberFormat",(t,e)=>{Vs.init(t,e),ro.init(t,e);});function Tu(t){return qc(Qr,t)}function Z_(t){return Fc(Qr,t)}function M_(t){return Vc(Qr,t)}function L_(t){return Jc(Qr,t)}function q_(t){return Gc(Qr,t)}var no=f("ZodBoolean",(t,e)=>{qn.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Bp(t,n,o);});function ke(t){return Bc(no,t)}var oo=f("ZodBigInt",(t,e)=>{li.init(t,e),J.init(t,e),t._zod.processJSONSchema=(o,r,i)=>Kp(t,o),t.gte=(o,r)=>t.check(Pe(o,r)),t.min=(o,r)=>t.check(Pe(o,r)),t.gt=(o,r)=>t.check(St(o,r)),t.gte=(o,r)=>t.check(Pe(o,r)),t.min=(o,r)=>t.check(Pe(o,r)),t.lt=(o,r)=>t.check(wt(o,r)),t.lte=(o,r)=>t.check(Fe(o,r)),t.max=(o,r)=>t.check(Fe(o,r)),t.positive=o=>t.check(St(BigInt(0),o)),t.negative=o=>t.check(wt(BigInt(0),o)),t.nonpositive=o=>t.check(Fe(BigInt(0),o)),t.nonnegative=o=>t.check(Pe(BigInt(0),o)),t.multipleOf=(o,r)=>t.check(Xt(o,r));let n=t._zod.bag;t.minValue=n.minimum??null,t.maxValue=n.maximum??null,t.format=n.format??null;});function F_(t){return Hc(oo,t)}var Vu=f("ZodBigIntFormat",(t,e)=>{Js.init(t,e),oo.init(t,e);});function V_(t){return Xc(Vu,t)}function J_(t){return Yc(Vu,t)}var Jm=f("ZodSymbol",(t,e)=>{Gs.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Hp(t,n);});function G_(t){return Qc(Jm,t)}var Gm=f("ZodUndefined",(t,e)=>{Bs.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Xp(t,n);});function B_(t){return eu(Gm,t)}var Bm=f("ZodNull",(t,e)=>{Ks.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Wp(t,n,o);});function Ji(t){return tu(Bm,t)}var Km=f("ZodAny",(t,e)=>{Hs.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>em();});function K_(){return ru(Km)}var Hm=f("ZodUnknown",(t,e)=>{Ws.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>tm();});function me(){return nu(Hm)}var Wm=f("ZodNever",(t,e)=>{Xs.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Qp(t,n,o);});function Ju(t){return ou(Wm,t)}var Xm=f("ZodVoid",(t,e)=>{Ys.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Yp(t,n);});function H_(t){return iu(Xm,t)}var Gi=f("ZodDate",(t,e)=>{Qs.init(t,e),J.init(t,e),t._zod.processJSONSchema=(o,r,i)=>rm(t,o),t.min=(o,r)=>t.check(Pe(o,r)),t.max=(o,r)=>t.check(Fe(o,r));let n=t._zod.bag;t.minDate=n.minimum?new Date(n.minimum):null,t.maxDate=n.maximum?new Date(n.maximum):null;});function W_(t){return au(Gi,t)}var Ym=f("ZodArray",(t,e)=>{ec.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>fm(t,n,o,r),t.element=e.element,t.min=(n,o)=>t.check(Ut(n,o)),t.nonempty=n=>t.check(Ut(1,n)),t.max=(n,o)=>t.check(fr(n,o)),t.length=(n,o)=>t.check(hr(n,o)),t.unwrap=()=>t.element;});function X(t,e){return Fp(Ym,t,e)}function X_(t){let e=t._zod.def.shape;return Ee(Object.keys(e))}var Bi=f("ZodObject",(t,e)=>{qp.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>hm(t,n,o,r),k.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Ee(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:me()}),t.loose=()=>t.clone({...t._zod.def,catchall:me()}),t.strict=()=>t.clone({...t._zod.def,catchall:Ju()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>k.extend(t,n),t.safeExtend=n=>k.safeExtend(t,n),t.merge=n=>k.merge(t,n),t.pick=n=>k.pick(t,n),t.omit=n=>k.omit(t,n),t.partial=(...n)=>k.partial(Bu,t,n[0]),t.required=(...n)=>k.required(Ku,t,n[0]);});function j(t,e){let n={type:"object",shape:t??{},...k.normalizeParams(e)};return new Bi(n)}function Y_(t,e){return new Bi({type:"object",shape:t,catchall:Ju(),...k.normalizeParams(e)})}function je(t,e){return new Bi({type:"object",shape:t,catchall:me(),...k.normalizeParams(e)})}var Ki=f("ZodUnion",(t,e)=>{Fn.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>yu(t,n,o,r),t.options=e.options;});function fe(t,e){return new Ki({type:"union",options:t,...k.normalizeParams(e)})}var Qm=f("ZodXor",(t,e)=>{Ki.init(t,e),tc.init(t,e),t._zod.processJSONSchema=(n,o,r)=>yu(t,n,o,r),t.options=e.options;});function Q_(t,e){return new Qm({type:"union",options:t,inclusive:false,...k.normalizeParams(e)})}var ef=f("ZodDiscriminatedUnion",(t,e)=>{Ki.init(t,e),rc.init(t,e);});function Hi(t,e,n){return new ef({type:"union",options:e,discriminator:t,...k.normalizeParams(n)})}var tf=f("ZodIntersection",(t,e)=>{nc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>gm(t,n,o,r);});function io(t,e){return new tf({type:"intersection",left:t,right:e})}var rf=f("ZodTuple",(t,e)=>{di.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>ym(t,n,o,r),t.rest=n=>t.clone({...t._zod.def,rest:n});});function nf(t,e,n){let o=e instanceof q,r=o?n:e,i=o?e:null;return new rf({type:"tuple",items:t,rest:i,...k.normalizeParams(r)})}var Wi=f("ZodRecord",(t,e)=>{oc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>vm(t,n,o,r),t.keyType=e.keyType,t.valueType=e.valueType;});function le(t,e,n){return new Wi({type:"record",keyType:t,valueType:e,...k.normalizeParams(n)})}function e$(t,e,n){let o=Ie(t);return o._zod.values=void 0,new Wi({type:"record",keyType:o,valueType:e,...k.normalizeParams(n)})}function t$(t,e,n){return new Wi({type:"record",keyType:t,valueType:e,mode:"loose",...k.normalizeParams(n)})}var of=f("ZodMap",(t,e)=>{ic.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>pm(t,n),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...n)=>t.check(Tt(...n)),t.nonempty=n=>t.check(Tt(1,n)),t.max=(...n)=>t.check(Yt(...n)),t.size=(...n)=>t.check(mr(...n));});function r$(t,e,n){return new of({type:"map",keyType:t,valueType:e,...k.normalizeParams(n)})}var af=f("ZodSet",(t,e)=>{ac.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>mm(t,n),t.min=(...n)=>t.check(Tt(...n)),t.nonempty=n=>t.check(Tt(1,n)),t.max=(...n)=>t.check(Yt(...n)),t.size=(...n)=>t.check(mr(...n));});function n$(t,e){return new af({type:"set",valueType:t,...k.normalizeParams(e)})}var Qn=f("ZodEnum",(t,e)=>{sc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(o,r,i)=>nm(t,o,r),t.enum=e.entries,t.options=Object.values(e.entries);let n=new Set(Object.keys(e.entries));t.extract=(o,r)=>{let i={};for(let a of o)if(n.has(a))i[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Qn({...e,checks:[],...k.normalizeParams(r),entries:i})},t.exclude=(o,r)=>{let i={...e.entries};for(let a of o)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Qn({...e,checks:[],...k.normalizeParams(r),entries:i})};});function Ee(t,e){let n=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new Qn({type:"enum",entries:n,...k.normalizeParams(e)})}function o$(t,e){return new Qn({type:"enum",entries:t,...k.normalizeParams(e)})}var sf=f("ZodLiteral",(t,e)=>{cc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>om(t,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}});});function N(t,e){return new sf({type:"literal",values:Array.isArray(t)?t:[t],...k.normalizeParams(e)})}var cf=f("ZodFile",(t,e)=>{uc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>sm(t,n,o),t.min=(n,o)=>t.check(Tt(n,o)),t.max=(n,o)=>t.check(Yt(n,o)),t.mime=(n,o)=>t.check(Br(Array.isArray(n)?n:[n],o));});function i$(t){return uu(cf,t)}var uf=f("ZodTransform",(t,e)=>{lc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>dm(t,n),t._zod.parse=(n,o)=>{if(o.direction==="backward")throw new sr(t.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(k.issue(i,n.value,e));else {let a=i;a.fatal&&(a.continue=false),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=t),n.issues.push(k.issue(a));}};let r=e.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n)):(n.value=r,n)};});function Gu(t){return new uf({type:"transform",transform:t})}var Bu=f("ZodOptional",(t,e)=>{pi.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>vu(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function ge(t){return new Bu({type:"optional",innerType:t})}var lf=f("ZodExactOptional",(t,e)=>{dc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>vu(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function df(t){return new lf({type:"optional",innerType:t})}var pf=f("ZodNullable",(t,e)=>{pc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>_m(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function qi(t){return new pf({type:"nullable",innerType:t})}function a$(t){return ge(qi(t))}var mf=f("ZodDefault",(t,e)=>{mc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>km(t,n,o,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap;});function ff(t,e){return new mf({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():k.shallowClone(e)}})}var hf=f("ZodPrefault",(t,e)=>{fc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>bm(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function gf(t,e){return new hf({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():k.shallowClone(e)}})}var Ku=f("ZodNonOptional",(t,e)=>{hc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>$m(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function yf(t,e){return new Ku({type:"nonoptional",innerType:t,...k.normalizeParams(e)})}var vf=f("ZodSuccess",(t,e)=>{gc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>cm(t,n,o),t.unwrap=()=>t._zod.def.innerType;});function s$(t){return new vf({type:"success",innerType:t})}var _f=f("ZodCatch",(t,e)=>{yc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>xm(t,n,o,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap;});function $f(t,e){return new _f({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var kf=f("ZodNaN",(t,e)=>{vc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>im(t,n);});function c$(t){return cu(kf,t)}var Hu=f("ZodPipe",(t,e)=>{_c.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>wm(t,n,o,r),t.in=e.in,t.out=e.out;});function Fi(t,e){return new Hu({type:"pipe",in:t,out:e})}var Wu=f("ZodCodec",(t,e)=>{Hu.init(t,e),Vn.init(t,e);});function u$(t,e,n){return new Wu({type:"pipe",in:t,out:e,transform:n.decode,reverseTransform:n.encode})}var bf=f("ZodReadonly",(t,e)=>{$c.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Sm(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function xf(t){return new bf({type:"readonly",innerType:t})}var wf=f("ZodTemplateLiteral",(t,e)=>{kc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>am(t,n,o);});function l$(t,e){return new wf({type:"template_literal",parts:t,...k.normalizeParams(e)})}var Sf=f("ZodLazy",(t,e)=>{wc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>zm(t,n,o,r),t.unwrap=()=>t._zod.def.getter();});function Tf(t){return new Sf({type:"lazy",getter:t})}var zf=f("ZodPromise",(t,e)=>{xc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>Tm(t,n,o,r),t.unwrap=()=>t._zod.def.innerType;});function d$(t){return new zf({type:"promise",innerType:t})}var If=f("ZodFunction",(t,e)=>{bc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>lm(t,n);});function p$(t){return new If({type:"function",input:Array.isArray(t?.input)?nf(t?.input):t?.input??X(me()),output:t?.output??me()})}var Xi=f("ZodCustom",(t,e)=>{Sc.init(t,e),J.init(t,e),t._zod.processJSONSchema=(n,o,r)=>um(t,n);});function m$(t){let e=new de({check:"custom"});return e._zod.check=t,e}function Xu(t,e){return lu(Xi,t??(()=>true),e)}function Pf(t,e={}){return du(Xi,t,e)}function jf(t){return pu(t)}var f$=mu,h$=fu;function g$(t,e={}){let n=new Xi({type:"custom",check:"custom",fn:o=>o instanceof t,abort:true,...k.normalizeParams(e)});return n._zod.bag.Class=t,n._zod.check=o=>{o.value instanceof t||o.issues.push({code:"invalid_type",expected:t.name,input:o.value,inst:n,path:[...n._zod.def.path??[]]});},n}var y$=(...t)=>hu({Codec:Wu,Boolean:no,String:eo},...t);function v$(t){let e=Tf(()=>fe([y(t),ae(),ke(),Ji(),X(e),le(y(),e)]));return e}function Yi(t,e){return Fi(Gu(t),e)}var AT={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function UT(t){$e({customError:t});}function ZT(){return $e().customError}var Ef;Ef||(Ef={});var I={...Mi,...ku,iso:$r},MT=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function LT(t,e){let n=t.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function qT(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=t.slice(1).split("/").filter(Boolean);if(n.length===0)return e.rootSchema;let o=e.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===o){let r=n[1];if(!r||!e.defs[r])throw new Error(`Reference not found: ${t}`);return e.defs[r]}throw new Error(`Reference not found: ${t}`)}function _$(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return I.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let r=t.$ref;if(e.refs.has(r))return e.refs.get(r);if(e.processing.has(r))return I.lazy(()=>{if(!e.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return e.refs.get(r)});e.processing.add(r);let i=qT(r,e),a=Ue(i,e);return e.refs.set(r,a),e.processing.delete(r),a}if(t.enum!==void 0){let r=t.enum;if(e.version==="openapi-3.0"&&t.nullable===true&&r.length===1&&r[0]===null)return I.null();if(r.length===0)return I.never();if(r.length===1)return I.literal(r[0]);if(r.every(a=>typeof a=="string"))return I.enum(r);let i=r.map(a=>I.literal(a));return i.length<2?i[0]:I.union([i[0],i[1],...i.slice(2)])}if(t.const!==void 0)return I.literal(t.const);let n=t.type;if(Array.isArray(n)){let r=n.map(i=>{let a={...t,type:i};return _$(a,e)});return r.length===0?I.never():r.length===1?r[0]:I.union(r)}if(!n)return I.any();let o;switch(n){case "string":{let r=I.string();if(t.format){let i=t.format;i==="email"?r=r.check(I.email()):i==="uri"||i==="uri-reference"?r=r.check(I.url()):i==="uuid"||i==="guid"?r=r.check(I.uuid()):i==="date-time"?r=r.check(I.iso.datetime()):i==="date"?r=r.check(I.iso.date()):i==="time"?r=r.check(I.iso.time()):i==="duration"?r=r.check(I.iso.duration()):i==="ipv4"?r=r.check(I.ipv4()):i==="ipv6"?r=r.check(I.ipv6()):i==="mac"?r=r.check(I.mac()):i==="cidr"?r=r.check(I.cidrv4()):i==="cidr-v6"?r=r.check(I.cidrv6()):i==="base64"?r=r.check(I.base64()):i==="base64url"?r=r.check(I.base64url()):i==="e164"?r=r.check(I.e164()):i==="jwt"?r=r.check(I.jwt()):i==="emoji"?r=r.check(I.emoji()):i==="nanoid"?r=r.check(I.nanoid()):i==="cuid"?r=r.check(I.cuid()):i==="cuid2"?r=r.check(I.cuid2()):i==="ulid"?r=r.check(I.ulid()):i==="xid"?r=r.check(I.xid()):i==="ksuid"&&(r=r.check(I.ksuid()));}typeof t.minLength=="number"&&(r=r.min(t.minLength)),typeof t.maxLength=="number"&&(r=r.max(t.maxLength)),t.pattern&&(r=r.regex(new RegExp(t.pattern))),o=r;break}case "number":case "integer":{let r=n==="integer"?I.number().int():I.number();typeof t.minimum=="number"&&(r=r.min(t.minimum)),typeof t.maximum=="number"&&(r=r.max(t.maximum)),typeof t.exclusiveMinimum=="number"?r=r.gt(t.exclusiveMinimum):t.exclusiveMinimum===true&&typeof t.minimum=="number"&&(r=r.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?r=r.lt(t.exclusiveMaximum):t.exclusiveMaximum===true&&typeof t.maximum=="number"&&(r=r.lt(t.maximum)),typeof t.multipleOf=="number"&&(r=r.multipleOf(t.multipleOf)),o=r;break}case "boolean":{o=I.boolean();break}case "null":{o=I.null();break}case "object":{let r={},i=t.properties||{},a=new Set(t.required||[]);for(let[c,u]of Object.entries(i)){let l=Ue(u,e);r[c]=a.has(c)?l:l.optional();}if(t.propertyNames){let c=Ue(t.propertyNames,e),u=t.additionalProperties&&typeof t.additionalProperties=="object"?Ue(t.additionalProperties,e):I.any();if(Object.keys(r).length===0){o=I.record(c,u);break}let l=I.object(r).passthrough(),d=I.looseRecord(c,u);o=I.intersection(l,d);break}if(t.patternProperties){let c=t.patternProperties,u=Object.keys(c),l=[];for(let m of u){let p=Ue(c[m],e),h=I.string().regex(new RegExp(m));l.push(I.looseRecord(h,p));}let d=[];if(Object.keys(r).length>0&&d.push(I.object(r).passthrough()),d.push(...l),d.length===0)o=I.object({}).passthrough();else if(d.length===1)o=d[0];else {let m=I.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)m=I.intersection(m,d[p]);o=m;}break}let s=I.object(r);t.additionalProperties===false?o=s.strict():typeof t.additionalProperties=="object"?o=s.catchall(Ue(t.additionalProperties,e)):o=s.passthrough();break}case "array":{let r=t.prefixItems,i=t.items;if(r&&Array.isArray(r)){let a=r.map(c=>Ue(c,e)),s=i&&typeof i=="object"&&!Array.isArray(i)?Ue(i,e):void 0;s?o=I.tuple(a).rest(s):o=I.tuple(a),typeof t.minItems=="number"&&(o=o.check(I.minLength(t.minItems))),typeof t.maxItems=="number"&&(o=o.check(I.maxLength(t.maxItems)));}else if(Array.isArray(i)){let a=i.map(c=>Ue(c,e)),s=t.additionalItems&&typeof t.additionalItems=="object"?Ue(t.additionalItems,e):void 0;s?o=I.tuple(a).rest(s):o=I.tuple(a),typeof t.minItems=="number"&&(o=o.check(I.minLength(t.minItems))),typeof t.maxItems=="number"&&(o=o.check(I.maxLength(t.maxItems)));}else if(i!==void 0){let a=Ue(i,e),s=I.array(a);typeof t.minItems=="number"&&(s=s.min(t.minItems)),typeof t.maxItems=="number"&&(s=s.max(t.maxItems)),o=s;}else o=I.array(I.any());break}default:throw new Error(`Unsupported type: ${n}`)}return t.description&&(o=o.describe(t.description)),t.default!==void 0&&(o=o.default(t.default)),o}function Ue(t,e){if(typeof t=="boolean")return t?I.any():I.never();let n=_$(t,e),o=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let s=t.anyOf.map(u=>Ue(u,e)),c=I.union(s);n=o?I.intersection(n,c):c;}if(t.oneOf&&Array.isArray(t.oneOf)){let s=t.oneOf.map(u=>Ue(u,e)),c=I.xor(s);n=o?I.intersection(n,c):c;}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)n=o?n:I.any();else {let s=o?n:Ue(t.allOf[0],e),c=o?0:1;for(let u=c;u<t.allOf.length;u++)s=I.intersection(s,Ue(t.allOf[u],e));n=s;}t.nullable===true&&e.version==="openapi-3.0"&&(n=I.nullable(n)),t.readOnly===true&&(n=I.readonly(n));let r={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in t&&(r[s]=t[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in t&&(r[s]=t[s]);for(let s of Object.keys(t))MT.has(s)||(r[s]=t[s]);return Object.keys(r).length>0&&e.registry.add(n,r),n}function $$(t,e){if(typeof t=="boolean")return t?I.any():I.never();let n=LT(t,e?.defaultTarget),o=t.$defs||t.definitions||{},r={version:n,defs:o,refs:new Map,processing:new Set,rootSchema:t,registry:e?.registry??ze};return Ue(t,r)}var Of={};Dt(Of,{bigint:()=>GT,boolean:()=>JT,date:()=>BT,number:()=>VT,string:()=>FT});function FT(t){return Rc(eo,t)}function VT(t){return Lc(ro,t)}function JT(t){return Kc(no,t)}function GT(t){return Wc(oo,t)}function BT(t){return su(Gi,t)}$e(Tc());var Nf="2025-11-25";var k$=[Nf,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],kr="io.modelcontextprotocol/related-task",Qu="2.0",Se=Xu(t=>t!==null&&(typeof t=="object"||typeof t=="function")),b$=fe([y(),ae().int()]),x$=y();je({ttl:ae().optional(),pollInterval:ae().optional()});var HT=j({ttl:ae().optional()}),WT=j({taskId:y()}),Cf=je({progressToken:b$.optional(),[kr]:WT.optional()}),ct=j({_meta:Cf.optional()}),Qi=ct.extend({task:HT.optional()}),w$=t=>Qi.safeParse(t).success,Oe=j({method:y(),params:ct.loose().optional()}),ht=j({_meta:Cf.optional()}),gt=j({method:y(),params:ht.loose().optional()}),Re=je({_meta:Cf.optional()}),el=fe([y(),ae().int()]),S$=j({jsonrpc:N(Qu),id:el,...Oe.shape}).strict(),Df=t=>S$.safeParse(t).success,T$=j({jsonrpc:N(Qu),...gt.shape}).strict(),z$=t=>T$.safeParse(t).success,Af=j({jsonrpc:N(Qu),id:el,result:Re}).strict(),ea=t=>Af.safeParse(t).success;var re;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired";})(re||(re={}));var Uf=j({jsonrpc:N(Qu),id:el.optional(),error:j({code:ae().int(),message:y(),data:me().optional()})}).strict();var I$=t=>Uf.safeParse(t).success;var P$=fe([S$,T$,Af,Uf]);fe([Af,Uf]);var tl=Re.strict(),XT=ht.extend({requestId:el.optional(),reason:y().optional()}),rl=gt.extend({method:N("notifications/cancelled"),params:XT}),YT=j({src:y(),mimeType:y().optional(),sizes:X(y()).optional(),theme:Ee(["light","dark"]).optional()}),ta=j({icons:X(YT).optional()}),ao=j({name:y(),title:y().optional()}),j$=ao.extend({...ao.shape,...ta.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),QT=io(j({applyDefaults:ke().optional()}),le(y(),me())),ez=Yi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,io(j({form:QT.optional(),url:Se.optional()}),le(y(),me()).optional())),tz=je({list:Se.optional(),cancel:Se.optional(),requests:je({sampling:je({createMessage:Se.optional()}).optional(),elicitation:je({create:Se.optional()}).optional()}).optional()}),rz=je({list:Se.optional(),cancel:Se.optional(),requests:je({tools:je({call:Se.optional()}).optional()}).optional()}),nz=j({experimental:le(y(),Se).optional(),sampling:j({context:Se.optional(),tools:Se.optional()}).optional(),elicitation:ez.optional(),roots:j({listChanged:ke().optional()}).optional(),tasks:tz.optional(),extensions:le(y(),Se).optional()}),oz=ct.extend({protocolVersion:y(),capabilities:nz,clientInfo:j$}),Zf=Oe.extend({method:N("initialize"),params:oz});var iz=j({experimental:le(y(),Se).optional(),logging:Se.optional(),completions:Se.optional(),prompts:j({listChanged:ke().optional()}).optional(),resources:j({subscribe:ke().optional(),listChanged:ke().optional()}).optional(),tools:j({listChanged:ke().optional()}).optional(),tasks:rz.optional(),extensions:le(y(),Se).optional()}),az=Re.extend({protocolVersion:y(),capabilities:iz,serverInfo:j$,instructions:y().optional()}),Mf=gt.extend({method:N("notifications/initialized"),params:ht.optional()});var nl=Oe.extend({method:N("ping"),params:ct.optional()}),sz=j({progress:ae(),total:ge(ae()),message:ge(y())}),cz=j({...ht.shape,...sz.shape,progressToken:b$}),ol=gt.extend({method:N("notifications/progress"),params:cz}),uz=ct.extend({cursor:x$.optional()}),ra=Oe.extend({params:uz.optional()}),na=Re.extend({nextCursor:x$.optional()}),lz=Ee(["working","input_required","completed","failed","cancelled"]),oa=j({taskId:y(),status:lz,ttl:fe([ae(),Ji()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:ge(ae()),statusMessage:ge(y())}),so=Re.extend({task:oa}),dz=ht.merge(oa),ia=gt.extend({method:N("notifications/tasks/status"),params:dz}),il=Oe.extend({method:N("tasks/get"),params:ct.extend({taskId:y()})}),al=Re.merge(oa),sl=Oe.extend({method:N("tasks/result"),params:ct.extend({taskId:y()})});Re.loose();var cl=ra.extend({method:N("tasks/list")}),ul=na.extend({tasks:X(oa)}),ll=Oe.extend({method:N("tasks/cancel"),params:ct.extend({taskId:y()})}),E$=Re.merge(oa),O$=j({uri:y(),mimeType:ge(y()),_meta:le(y(),me()).optional()}),R$=O$.extend({text:y()}),Lf=y().refine(t=>{try{return atob(t),!0}catch{return false}},{message:"Invalid Base64 string"}),N$=O$.extend({blob:Lf}),aa=Ee(["user","assistant"]),co=j({audience:X(aa).optional(),priority:ae().min(0).max(1).optional(),lastModified:$r.datetime({offset:true}).optional()}),C$=j({...ao.shape,...ta.shape,uri:y(),description:ge(y()),mimeType:ge(y()),size:ge(ae()),annotations:co.optional(),_meta:ge(je({}))}),pz=j({...ao.shape,...ta.shape,uriTemplate:y(),description:ge(y()),mimeType:ge(y()),annotations:co.optional(),_meta:ge(je({}))}),mz=ra.extend({method:N("resources/list")}),fz=na.extend({resources:X(C$)}),hz=ra.extend({method:N("resources/templates/list")}),gz=na.extend({resourceTemplates:X(pz)}),qf=ct.extend({uri:y()}),yz=qf,vz=Oe.extend({method:N("resources/read"),params:yz}),_z=Re.extend({contents:X(fe([R$,N$]))}),$z=gt.extend({method:N("notifications/resources/list_changed"),params:ht.optional()}),kz=qf,bz=Oe.extend({method:N("resources/subscribe"),params:kz}),xz=qf,wz=Oe.extend({method:N("resources/unsubscribe"),params:xz}),Sz=ht.extend({uri:y()}),Tz=gt.extend({method:N("notifications/resources/updated"),params:Sz}),zz=j({name:y(),description:ge(y()),required:ge(ke())}),Iz=j({...ao.shape,...ta.shape,description:ge(y()),arguments:ge(X(zz)),_meta:ge(je({}))}),Pz=ra.extend({method:N("prompts/list")}),jz=na.extend({prompts:X(Iz)}),Ez=ct.extend({name:y(),arguments:le(y(),y()).optional()}),Oz=Oe.extend({method:N("prompts/get"),params:Ez}),Ff=j({type:N("text"),text:y(),annotations:co.optional(),_meta:le(y(),me()).optional()}),Vf=j({type:N("image"),data:Lf,mimeType:y(),annotations:co.optional(),_meta:le(y(),me()).optional()}),Jf=j({type:N("audio"),data:Lf,mimeType:y(),annotations:co.optional(),_meta:le(y(),me()).optional()}),Rz=j({type:N("tool_use"),name:y(),id:y(),input:le(y(),me()),_meta:le(y(),me()).optional()}),Nz=j({type:N("resource"),resource:fe([R$,N$]),annotations:co.optional(),_meta:le(y(),me()).optional()}),Cz=C$.extend({type:N("resource_link")}),Gf=fe([Ff,Vf,Jf,Cz,Nz]),Dz=j({role:aa,content:Gf}),Az=Re.extend({description:y().optional(),messages:X(Dz)}),Uz=gt.extend({method:N("notifications/prompts/list_changed"),params:ht.optional()}),Zz=j({title:y().optional(),readOnlyHint:ke().optional(),destructiveHint:ke().optional(),idempotentHint:ke().optional(),openWorldHint:ke().optional()}),Mz=j({taskSupport:Ee(["required","optional","forbidden"]).optional()}),D$=j({...ao.shape,...ta.shape,description:y().optional(),inputSchema:j({type:N("object"),properties:le(y(),Se).optional(),required:X(y()).optional()}).catchall(me()),outputSchema:j({type:N("object"),properties:le(y(),Se).optional(),required:X(y()).optional()}).catchall(me()).optional(),annotations:Zz.optional(),execution:Mz.optional(),_meta:le(y(),me()).optional()}),Bf=ra.extend({method:N("tools/list")}),Lz=na.extend({tools:X(D$)}),dl=Re.extend({content:X(Gf).default([]),structuredContent:le(y(),me()).optional(),isError:ke().optional()});dl.or(Re.extend({toolResult:me()}));var qz=Qi.extend({name:y(),arguments:le(y(),me()).optional()}),sa=Oe.extend({method:N("tools/call"),params:qz}),Fz=gt.extend({method:N("notifications/tools/list_changed"),params:ht.optional()});j({autoRefresh:ke().default(true),debounceMs:ae().int().nonnegative().default(300)});var ca=Ee(["debug","info","notice","warning","error","critical","alert","emergency"]),Vz=ct.extend({level:ca}),Kf=Oe.extend({method:N("logging/setLevel"),params:Vz}),Jz=ht.extend({level:ca,logger:y().optional(),data:me()}),Gz=gt.extend({method:N("notifications/message"),params:Jz}),Bz=j({name:y().optional()}),Kz=j({hints:X(Bz).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),Hz=j({mode:Ee(["auto","required","none"]).optional()}),Wz=j({type:N("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:X(Gf).default([]),structuredContent:j({}).loose().optional(),isError:ke().optional(),_meta:le(y(),me()).optional()}),Xz=Hi("type",[Ff,Vf,Jf]),Yu=Hi("type",[Ff,Vf,Jf,Rz,Wz]),Yz=j({role:aa,content:fe([Yu,X(Yu)]),_meta:le(y(),me()).optional()}),Qz=Qi.extend({messages:X(Yz),modelPreferences:Kz.optional(),systemPrompt:y().optional(),includeContext:Ee(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:X(y()).optional(),metadata:Se.optional(),tools:X(D$).optional(),toolChoice:Hz.optional()}),eI=Oe.extend({method:N("sampling/createMessage"),params:Qz}),ua=Re.extend({model:y(),stopReason:ge(Ee(["endTurn","stopSequence","maxTokens"]).or(y())),role:aa,content:Xz}),Hf=Re.extend({model:y(),stopReason:ge(Ee(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:aa,content:fe([Yu,X(Yu)])}),tI=j({type:N("boolean"),title:y().optional(),description:y().optional(),default:ke().optional()}),rI=j({type:N("string"),title:y().optional(),description:y().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:Ee(["email","uri","date","date-time"]).optional(),default:y().optional()}),nI=j({type:Ee(["number","integer"]),title:y().optional(),description:y().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),oI=j({type:N("string"),title:y().optional(),description:y().optional(),enum:X(y()),default:y().optional()}),iI=j({type:N("string"),title:y().optional(),description:y().optional(),oneOf:X(j({const:y(),title:y()})),default:y().optional()}),aI=j({type:N("string"),title:y().optional(),description:y().optional(),enum:X(y()),enumNames:X(y()).optional(),default:y().optional()}),sI=fe([oI,iI]),cI=j({type:N("array"),title:y().optional(),description:y().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:j({type:N("string"),enum:X(y())}),default:X(y()).optional()}),uI=j({type:N("array"),title:y().optional(),description:y().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:j({anyOf:X(j({const:y(),title:y()}))}),default:X(y()).optional()}),lI=fe([cI,uI]),dI=fe([aI,sI,lI]),pI=fe([dI,tI,rI,nI]),mI=Qi.extend({mode:N("form").optional(),message:y(),requestedSchema:j({type:N("object"),properties:le(y(),pI),required:X(y()).optional()})}),fI=Qi.extend({mode:N("url"),message:y(),elicitationId:y(),url:y().url()}),hI=fe([mI,fI]),gI=Oe.extend({method:N("elicitation/create"),params:hI}),yI=ht.extend({elicitationId:y()}),vI=gt.extend({method:N("notifications/elicitation/complete"),params:yI}),uo=Re.extend({action:Ee(["accept","decline","cancel"]),content:Yi(t=>t===null?void 0:t,le(y(),fe([y(),ae(),ke(),X(y())])).optional())}),_I=j({type:N("ref/resource"),uri:y()});var $I=j({type:N("ref/prompt"),name:y()}),kI=ct.extend({ref:fe([$I,_I]),argument:j({name:y(),value:y()}),context:j({arguments:le(y(),y()).optional()}).optional()}),bI=Oe.extend({method:N("completion/complete"),params:kI});var xI=Re.extend({completion:je({values:X(y()).max(100),total:ge(ae().int()),hasMore:ge(ke())})}),wI=j({uri:y().startsWith("file://"),name:y().optional(),_meta:le(y(),me()).optional()}),SI=Oe.extend({method:N("roots/list"),params:ct.optional()}),Wf=Re.extend({roots:X(wI)}),TI=gt.extend({method:N("notifications/roots/list_changed"),params:ht.optional()});fe([nl,Zf,bI,Kf,Oz,Pz,mz,hz,vz,bz,wz,sa,Bf,il,sl,cl,ll]);fe([rl,ol,Mf,TI,ia]);fe([tl,ua,Hf,uo,Wf,al,ul,so]);fe([nl,eI,gI,SI,il,sl,cl,ll]);fe([rl,ol,Gz,Tz,$z,Fz,Uz,ia,vI]);fe([tl,az,xI,Az,jz,fz,gz,_z,dl,Lz,al,ul,so]);var B=class t extends Error{constructor(e,n,o){super(`MCP error ${e}: ${n}`),this.code=e,this.data=o,this.name="McpError";}static fromError(e,n,o){if(e===re.UrlElicitationRequired&&o){let r=o;if(r.elicitations)return new Rf(r.elicitations,n)}return new t(e,n,o)}},Rf=class extends B{constructor(e,n=`URL elicitation${e.length>1?"s":""} required`){super(re.UrlElicitationRequired,n,{elicitations:e});}get elicitations(){return this.data?.elicitations??[]}};function br(t){return t==="completed"||t==="failed"||t==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Xf(t){let n=$u(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=u_(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function Yf(t,e){let n=_r(t,e);if(!n.success)throw n.error;return n.data}var OI=6e4,pl=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(rl,n=>{this._oncancel(n);}),this.setNotificationHandler(ol,n=>{this._onprogress(n);}),this.setRequestHandler(nl,n=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(il,async(n,o)=>{let r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new B(re.InvalidParams,"Failed to retrieve task: Task not found");return {...r}}),this.setRequestHandler(sl,async(n,o)=>{let r=async()=>{let i=n.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,o.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else {let d=c,m=new B(d.error.code,d.error.message,d.error.data);l(m);}else {let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`));}continue}await this._transport?.send(s.message,{relatedRequestId:o.requestId});}}let a=await this._taskStore.getTask(i,o.sessionId);if(!a)throw new B(re.InvalidParams,`Task not found: ${i}`);if(!br(a.status))return await this._waitForTaskUpdate(i,o.signal),await r();if(br(a.status)){let s=await this._taskStore.getTaskResult(i,o.sessionId);return this._clearTaskQueue(i),{...s,_meta:{...s._meta,[kr]:{taskId:i}}}}return await r()};return await r()}),this.setRequestHandler(cl,async(n,o)=>{try{let{tasks:r,nextCursor:i}=await this._taskStore.listTasks(n.params?.cursor,o.sessionId);return {tasks:r,nextCursor:i,_meta:{}}}catch(r){throw new B(re.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(ll,async(n,o)=>{try{let r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new B(re.InvalidParams,`Task not found: ${n.params.taskId}`);if(br(r.status))throw new B(re.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(n.params.taskId);let i=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!i)throw new B(re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return {_meta:{},...i}}catch(r){throw r instanceof B?r:new B(re.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}));}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason);}_setupTimeout(e,n,o,r,i=false){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:o,resetTimeoutOnProgress:i,onTimeout:r});}_resetTimeout(e){let n=this._timeoutInfo.get(e);if(!n)return false;let o=Date.now()-n.startTime;if(n.maxTotalTimeout&&o>=n.maxTotalTimeout)throw this._timeoutInfo.delete(e),B.fromError(re.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:o});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),true}_cleanupTimeout(e){let n=this._timeoutInfo.get(e);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(e));}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose();};let o=this.transport?.onerror;this._transport.onerror=i=>{o?.(i),this._onerror(i);};let r=this._transport?.onmessage;this._transport.onmessage=(i,a)=>{r?.(i,a),ea(i)||I$(i)?this._onresponse(i):Df(i)?this._onrequest(i,a):z$(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`));},await this._transport.start();}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();for(let o of this._requestHandlerAbortControllers.values())o.abort();this._requestHandlerAbortControllers.clear();let n=B.fromError(re.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let o of e.values())o(n);}_onerror(e){this.onerror?.(e);}_onnotification(e){let n=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)));}_onrequest(e,n){let o=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[kr]?.taskId;if(o===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:re.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let s=w$(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,u={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(a.signal.aborted)return;let d={relatedRequestId:e.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d);},sendRequest:async(l,d,m)=>{if(a.signal.aborted)throw new B(re.ConnectionClosed,"Request was cancelled");let p={...m,relatedRequestId:e.id};i&&!p.relatedTask&&(p.relatedTask={taskId:i});let h=p.relatedTask?.taskId??i;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,p)},authInfo:n?.authInfo,requestId:e.id,requestInfo:n?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(e.method);}).then(()=>o(e,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d);},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:re.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d);}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id);});}_onprogress(e){let{progressToken:n,...o}=e.params,r=Number(n),i=this._progressHandlers.get(r);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r);}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(c);return}i(o);}_onresponse(e){let n=Number(e.id),o=this._requestResolvers.get(n);if(o){if(this._requestResolvers.delete(n),ea(e))o(e);else {let a=new B(e.error.code,e.error.message,e.error.data);o(a);}return}let r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let i=false;if(ea(e)&&e.result&&typeof e.result=="object"){let a=e.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(i=true,this._taskProgressTokens.set(s.taskId,n));}}if(i||this._progressHandlers.delete(n),ea(e))r(e);else {let a=B.fromError(e.error.code,e.error.message,e.error.data);r(a);}}get transport(){return this._transport}async close(){await this._transport?.close();}async*requestStream(e,n,o){let{task:r}=o??{};if(!r){try{yield {type:"result",result:await this.request(e,n,o)};}catch(a){yield {type:"error",error:a instanceof B?a:new B(re.InternalError,String(a))};}return}let i;try{let a=await this.request(e,so,o);if(a.task)i=a.task.taskId,yield {type:"taskCreated",task:a.task};else throw new B(re.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},o);if(yield {type:"taskStatus",task:s},br(s.status)){s.status==="completed"?yield {type:"result",result:await this.getTaskResult({taskId:i},n,o)}:s.status==="failed"?yield {type:"error",error:new B(re.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield {type:"error",error:new B(re.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield {type:"result",result:await this.getTaskResult({taskId:i},n,o)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),o?.signal?.throwIfAborted();}}catch(a){yield {type:"error",error:a instanceof B?a:new B(re.InternalError,String(a))};}}request(e,n,o){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:s,relatedTask:c}=o??{};return new Promise((u,l)=>{let d=C=>{l(C);};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===true)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method);}catch(C){d(C);return}o?.signal?.throwIfAborted();let m=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:m};o?.onprogress&&(this._progressHandlers.set(m,o.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:m}}),s&&(p.params={...p.params,task:s}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[kr]:c}});let h=C=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(C)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(Z=>this._onerror(new Error(`Failed to send cancellation: ${Z}`)));let O=C instanceof B?C:new B(re.RequestTimeout,String(C));l(O);};this._responseHandlers.set(m,C=>{if(!o?.signal?.aborted){if(C instanceof Error)return l(C);try{let O=_r(n,C.result);O.success?u(O.data):l(O.error);}catch(O){l(O);}}}),o?.signal?.addEventListener("abort",()=>{h(o?.signal?.reason);});let v=o?.timeout??OI,S=()=>h(B.fromError(re.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(m,v,o?.maxTotalTimeout,S,o?.resetTimeoutOnProgress??false);let T=c?.taskId;if(T){let C=O=>{let Z=this._responseHandlers.get(m);Z?Z(O):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`));};this._requestResolvers.set(m,C),this._enqueueTaskMessage(T,{type:"request",message:p,timestamp:Date.now()}).catch(O=>{this._cleanupTimeout(m),l(O);});}else this._transport.send(p,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(C=>{this._cleanupTimeout(m),l(C);});})}async getTask(e,n){return this.request({method:"tasks/get",params:e},al,n)}async getTaskResult(e,n,o){return this.request({method:"tasks/result",params:e},n,o)}async listTasks(e,n){return this.request({method:"tasks/list",params:e},ul,n)}async cancelTask(e,n){return this.request({method:"tasks/cancel",params:e},E$,n)}async notification(e,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let o=n?.relatedTask?.taskId;if(o){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[kr]:n.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[kr]:n.relatedTask}}}),this._transport?.send(s,n).catch(c=>this._onerror(c));});return}let a={...e,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[kr]:n.relatedTask}}}),await this._transport.send(a,n);}setRequestHandler(e,n){let o=Xf(e);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(r,i)=>{let a=Yf(e,r);return Promise.resolve(n(a,i))});}removeRequestHandler(e){this._requestHandlers.delete(e);}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,n){let o=Xf(e);this._notificationHandlers.set(o,r=>{let i=Yf(e,r);return Promise.resolve(n(i))});}removeNotificationHandler(e){this._notificationHandlers.delete(e);}_cleanupTaskProgressHandler(e){let n=this._taskProgressTokens.get(e);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(e));}async _enqueueTaskMessage(e,n,o){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,n,o,r);}async _clearTaskQueue(e,n){if(this._taskMessageQueue){let o=await this._taskMessageQueue.dequeueAll(e,n);for(let r of o)if(r.type==="request"&&Df(r.message)){let i=r.message.id,a=this._requestResolvers.get(i);a?(a(new B(re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${e} cleanup`));}}}async _waitForTaskUpdate(e,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let r=await this._taskStore?.getTask(e);r?.pollInterval&&(o=r.pollInterval);}catch{}return new Promise((r,i)=>{if(n.aborted){i(new B(re.InvalidRequest,"Request cancelled"));return}let a=setTimeout(r,o);n.addEventListener("abort",()=>{clearTimeout(a),i(new B(re.InvalidRequest,"Request cancelled"));},{once:true});})}requestTaskStore(e,n){let o=this._taskStore;if(!o)throw new Error("No task store configured");return {createTask:async r=>{if(!e)throw new Error("No request provided");return await o.createTask(r,e.id,{method:e.method,params:e.params},n)},getTask:async r=>{let i=await o.getTask(r,n);if(!i)throw new B(re.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(r,i,a)=>{await o.storeTaskResult(r,i,a,n);let s=await o.getTask(r,n);if(s){let c=ia.parse({method:"notifications/tasks/status",params:s});await this.notification(c),br(s.status)&&this._cleanupTaskProgressHandler(r);}},getTaskResult:r=>o.getTaskResult(r,n),updateTaskStatus:async(r,i,a)=>{let s=await o.getTask(r,n);if(!s)throw new B(re.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(br(s.status))throw new B(re.InvalidParams,`Cannot update task "${r}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(r,i,a,n);let c=await o.getTask(r,n);if(c){let u=ia.parse({method:"notifications/tasks/status",params:c});await this.notification(u),br(c.status)&&this._cleanupTaskProgressHandler(r);}},listTasks:r=>o.listTasks(r,n)}}};function A$(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function U$(t,e){let n={...t};for(let o in e){let r=o,i=e[r];if(i===void 0)continue;let a=n[r];A$(a)&&A$(i)?n[r]={...a,...i}:n[r]=i;}return n}var Px=gy(Ug()),jx=gy(Ix());function CN(){let t=new Px.default({strict:false,validateFormats:true,validateSchema:false,allErrors:true});return (0, jx.default)(t),t}var Bl=class{constructor(e){this._ajv=e??CN();}getValidator(e){let n="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return o=>n(o)?{valid:true,data:o,errorMessage:void 0}:{valid:false,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}};var Kl=class{constructor(e){this._server=e;}requestStream(e,n,o){return this._server.requestStream(e,n,o)}createMessageStream(e,n){let o=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!o?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let r=e.messages[e.messages.length-1],i=Array.isArray(r.content)?r.content:[r.content],a=i.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(a){if(i.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(m=>m.type==="tool_use").map(m=>m.id)),d=new Set(i.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(l.size!==d.size||![...l].every(m=>d.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},ua,n)}elicitInputStream(e,n){let o=this._server.getClientCapabilities(),r=e.mode??"form";switch(r){case "url":{if(!o?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case "form":{if(!o?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=r==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:i},uo,n)}async getTask(e,n){return this._server.getTask({taskId:e},n)}async getTaskResult(e,n,o){return this._server.getTaskResult({taskId:e},n,o)}async listTasks(e,n){return this._server.listTasks(e?{cursor:e}:void 0,n)}async cancelTask(e,n){return this._server.cancelTask({taskId:e},n)}};function Ex(t,e,n){if(!t)throw new Error(`${n} does not support task creation (required for ${e})`);switch(e){case "tools/call":if(!t.tools?.call)throw new Error(`${n} does not support task creation for tools/call (required for ${e})`);break;}}function Ox(t,e,n){if(!t)throw new Error(`${n} does not support task creation (required for ${e})`);switch(e){case "sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${n} does not support task creation for sampling/createMessage (required for ${e})`);break;case "elicitation/create":if(!t.elicitation?.create)throw new Error(`${n} does not support task creation for elicitation/create (required for ${e})`);break;}}var Hl=class extends pl{constructor(e,n){super(n),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ca.options.map((o,r)=>[o,r])),this.isMessageIgnored=(o,r)=>{let i=this._loggingLevels.get(r);return i?this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(i):false},this._capabilities=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new Bl,this.setRequestHandler(Zf,o=>this._oninitialize(o)),this.setNotificationHandler(Mf,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Kf,async(o,r)=>{let i=r.sessionId||r.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=o.params,s=ca.safeParse(a);return s.success&&this._loggingLevels.set(i,s.data),{}});}get experimental(){return this._experimental||(this._experimental={tasks:new Kl(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=U$(this._capabilities,e);}setRequestHandler(e,n){let r=$u(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let i;if(Yn(r)){let s=r;i=s._zod?.def?.value??s.value;}else {let s=r;i=s._def?.value??s.value;}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(c,u)=>{let l=_r(sa,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new B(re.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,m=await Promise.resolve(n(c,u));if(d.task){let h=_r(so,m);if(!h.success){let v=h.error instanceof Error?h.error.message:String(h.error);throw new B(re.InvalidParams,`Invalid task creation result: ${v}`)}return h.data}let p=_r(dl,m);if(!p.success){let h=p.error instanceof Error?p.error.message:String(p.error);throw new B(re.InvalidParams,`Invalid tools/call result: ${h}`)}return p.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,n)}assertCapabilityForMethod(e){switch(e){case "sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case "elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case "roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;}}assertNotificationCapability(e){switch(e){case "notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case "notifications/resources/updated":case "notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case "notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case "notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case "notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case "completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case "logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case "prompts/get":case "prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case "resources/list":case "resources/templates/list":case "resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case "tools/call":case "tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case "tasks/get":case "tasks/list":case "tasks/result":case "tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;}}assertTaskCapability(e){Ox(this._clientCapabilities?.tasks?.requests,e,"Client");}assertTaskHandlerCapability(e){this._capabilities&&Ex(this._capabilities.tasks?.requests,e,"Server");}async _oninitialize(e){let n=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:k$.includes(n)?n:Nf,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},tl)}async createMessage(e,n){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],r=Array.isArray(o.content)?o.content:[o.content],i=r.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(i){if(r.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(r.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Hf,n):this.request({method:"sampling/createMessage",params:e},ua,n)}async elicitInput(e,n){switch(e.mode??"form"){case "url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let r=e;return this.request({method:"elicitation/create",params:r},uo,n)}case "form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let r=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:r},uo,n);if(i.action==="accept"&&i.content&&r.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!s.valid)throw new B(re.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof B?a:new B(re.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return i}}}createElicitationCompletionNotifier(e,n){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return ()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},n)}async listRoots(e,n){return this.request({method:"roots/list",params:e},Wf,n)}async sendLoggingMessage(e,n){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,n))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Wl=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e;}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
48
49
  `);if(e===-1)return null;let n=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),DN(n)}clear(){this._buffer=void 0;}};function DN(t){return P$.parse(JSON.parse(t))}function Rx(t){return JSON.stringify(t)+`
49
- `}var Xl=class{constructor(e=Nx.stdin,n=Nx.stdout){this._stdin=e,this._stdout=n,this._readBuffer=new Wl,this._started=false,this._ondata=o=>{this._readBuffer.append(o),this.processReadBuffer();},this._onerror=o=>{this.onerror?.(o);};}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=true,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror);}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e);}catch(e){this.onerror?.(e);}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.();}send(e){return new Promise(n=>{let o=Rx(e);this._stdout.write(o)?n():this._stdout.once("drain",n);})}};var Cx="1.6.0";async function Er(t){try{return await access(t),!0}catch{return false}}var UN=["pl","en","de","es","fr","pt","it","nl"],jo=x.enum(UN),Or="pl",ZN=x.object({url:x.string().url(),language:jo.optional()}),Dx=x.object({projects:x.record(x.string(),ZN),default_project:x.string(),default_language:jo.optional()}).refine(t=>t.default_project in t.projects,{message:"default_project must reference a configured project"}),Po=x.object({username:x.string().email(),api_token:x.string().min(1)}),Gg=x.object({default:Po,instances:x.record(x.string().url(),Po).optional()}),Ax=x.union([Po,Gg]),Bg=x.object({url:x.string().url(),username:x.string().email(),api_token:x.string().min(1),language:jo});x.object({projects:x.record(x.string(),Bg),default_project:x.string(),default_language:jo,credentials:Po});var rt=class extends Error{code;constructor(e,n){super(e),this.name="JiraMcpError",this.code=n;}},Yl=class extends rt{constructor(e,n="CONFIG_ERROR"){super(e,n),this.name="ConfigError";}},Ma=class extends Yl{constructor(e){super(e,"CONFIG_NOT_FOUND"),this.name="ConfigNotFoundError";}},Ot=class extends Yl{constructor(e){super(e,"CONFIG_VALIDATION"),this.name="ConfigValidationError";}},ut=class extends rt{constructor(e,n="JIRA_CONNECTION"){super(e,n),this.name="JiraConnectionError";}},Ql=class extends ut{constructor(e){super(e,"JIRA_AUTH"),this.name="JiraAuthenticationError";}},ed=class extends ut{constructor(e){super(e,"JIRA_PERMISSION"),this.name="JiraPermissionError";}},La=class extends rt{constructor(e,n="CACHE_ERROR"){super(e,n),this.name="CacheError";}},Rt=class extends La{constructor(e){super(e,"CACHE_NOT_FOUND"),this.name="CacheNotFoundError";}},Rr=class extends La{constructor(e){super(e,"CACHE_CORRUPTION"),this.name="CacheCorruptionError";}},Nt=class extends La{constructor(e){super(e,"TASK_NOT_FOUND"),this.name="TaskNotFoundError";}},pn=class extends rt{constructor(e,n="TEMPLATE_ERROR"){super(e,n),this.name="TemplateError";}},Eo=class extends pn{constructor(e){super(e,"TEMPLATE_NOT_FOUND"),this.name="TemplateNotFoundError";}};var td=class extends rt{constructor(e,n="APPROVAL_ERROR"){super(e,n),this.name="ApprovalError";}},rd=class extends td{constructor(e){super(e,"COMMENT_APPROVAL_REQUIRED"),this.name="CommentApprovalRequiredError";}},nd=class extends td{constructor(e){super(e,"DELETION_APPROVAL_REQUIRED"),this.name="DeletionApprovalRequiredError";}},qa=class extends rt{constructor(e){super(e,"OWNERSHIP_REQUIRED"),this.name="OwnershipError";}},od=class extends rt{constructor(e){super(e,"COMMENT_NOT_FOUND"),this.name="CommentNotFoundError";}};fn();async function KN(t){if(t?.configPath)return resolve(t.configPath);let e=process.env.JIRA_CONFIG_PATH;if(e)return resolve(e);let n=resolve(process.cwd(),"config.json");return await Er(n)?(console.warn(`[jira-mcp] WARNING: Loading config.json from working directory (${n}) instead of global config. This may be a security risk if running from an untrusted directory.`),n):Kg}async function HN(t){if(t?.credentialsPath)return resolve(t.credentialsPath);let e=process.env.JIRA_CREDENTIALS_PATH;if(e)return resolve(e);let n=resolve(process.cwd(),"credentials.json");return await Er(n)?(console.warn(`[jira-mcp] WARNING: Loading credentials.json from working directory (${n}) instead of global config. This may be a security risk if running from an untrusted directory.`),n):Hg}async function qx(t,e){if(!await Er(t))throw new Ma(`${e} not found: ${t}`);let n;try{n=await readFile(t,"utf-8");}catch(o){let r=o instanceof Error?o.message:String(o);throw new Ma(`Failed to read ${e}: ${r}`)}try{return JSON.parse(n)}catch(o){let r=o instanceof Error?o.message:String(o);throw new Ot(`Invalid JSON in ${e}: ${r}`)}}function WN(t){let e=Po.safeParse(t);if(e.success&&!("default"in t))return {default:e.data,instances:{}};let n=Gg.safeParse(t);if(n.success)return {default:n.data.default,instances:n.data.instances??{}};throw new Ot("Credentials file format not recognized. Expected { username, api_token } or { default: { username, api_token }, instances?: {} }.")}function XN(t,e){return t.instances[e]??t.default}async function ld(t){let e=await KN(t),n=await HN(t),o=await qx(e,"configuration file"),r=Dx.safeParse(o);if(!r.success)throw new Ot(`Configuration validation failed: ${r.error.message}`);let i=r.data,a=await qx(n,"credentials file"),s=Ax.safeParse(a);if(!s.success)throw new Ot(`Credentials validation failed: ${s.error.message}`);let c=WN(s.data),u=i.default_language??Or,l={};for(let[d,m]of Object.entries(i.projects)){let p=XN(c,m.url),h={url:m.url,username:p.username,api_token:p.api_token,language:m.language??u},v=Bg.safeParse(h);if(!v.success)throw new Ot(`Project '${d}' validation failed: ${v.error.message}`);l[d]=v.data;}return {projects:l,default_project:i.default_project,default_language:u,credentials:c.default}}function Fx(t){let e=new Map;for(let[o,r]of Object.entries(t.projects)){let i=e.get(r.url);i?i.keys.push(o):e.set(r.url,{keys:[o]});}let n=[];for(let[o,{keys:r}]of e){let i=r[0];if(!i)continue;let a=t.projects[i];a&&n.push({url:o,username:a.username,api_token:a.api_token,projectKeys:r});}return n}var YN=1e3,Vx=3,QN=1e3,eC=new Set([429,503]);function tC(t){return new Promise(e=>setTimeout(e,t))}var rC=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"],dd=class{authToken;instanceUrl;constructor(e){this.instanceUrl=e.url,this.authToken=Buffer.from(`${e.username}:${e.api_token}`).toString("base64");}async request(e,n,o,r){let i=new URL(n,this.instanceUrl);if(r)for(let[u,l]of Object.entries(r))i.searchParams.set(u,l);let a={Authorization:`Basic ${this.authToken}`,Accept:"application/json"};o!==void 0&&(a["Content-Type"]="application/json");let s={method:e,headers:a,body:o!==void 0?JSON.stringify(o):void 0},c;for(let u=0;u<=Vx;u++){let l=await fetch(i.toString(),s);if(l.ok)return l.status===204?void 0:await l.json();let m=await l.text()||l.statusText,p=m.length>200?`${m.slice(0,200)}...`:m;if(l.status===401)throw new Ql(`Authentication failed: ${p}`);if(l.status===403)throw new ed(`Permission denied: ${p}`);if(eC.has(l.status)&&u<Vx){let h=l.headers.get("Retry-After"),v=h?Math.min(parseInt(h,10)*1e3,3e4):QN*Math.pow(2,u);await tC(v),c=new ut(`Jira API error (${l.status}): ${p}`);continue}throw new ut(`Jira API error (${l.status}): ${p}`)}throw c??new ut("Request failed after retries")}async searchIssues(e,n){return ((await this.request("GET","/rest/api/3/search/jql",void 0,{jql:e,fields:(n?[...n]:rC).join(","),maxResults:String(YN)})).issues??[]).map(i=>{let a=i.fields;return {key:i.key,summary:a.summary,status:a.status?.name??"Unknown",assignee:a.assignee?.emailAddress??null,priority:a.priority?.name??"None",issueType:a.issuetype?.name??a.issueType?.name??"Unknown",created:a.created,updated:a.updated,projectKey:i.key.split("-")[0]??"",epicLink:a.customfield_10014??null}})}async getIssue(e){let n=["summary","description","creator","status","assignee","priority","issuetype","created","updated","project","comment","timetracking"],o=await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:n.join(",")}),r=o.fields,i=(r.comment?.comments??[]).map(a=>({id:a.id??"",author:a.author?.emailAddress??a.author?.displayName??"Unknown",authorAccountId:a.author?.accountId??null,body:a.body??null,created:a.created??""}));return {key:o.key,summary:r.summary,description:r.description??null,creator:r.creator?.emailAddress??r.creator?.displayName??"Unknown",creatorAccountId:r.creator?.accountId??null,status:r.status?.name??"Unknown",assignee:r.assignee?.emailAddress??null,priority:r.priority?.name??"None",issueType:r.issuetype?.name??r.issueType?.name??"Unknown",created:r.created,updated:r.updated,projectKey:o.key.split("-")[0]??"",comments:i,timeTracking:{originalEstimate:r.timetracking?.originalEstimate??null,remainingEstimate:r.timetracking?.remainingEstimate??null,timeSpent:r.timetracking?.timeSpent??null,originalEstimateSeconds:r.timetracking?.originalEstimateSeconds??null,remainingEstimateSeconds:r.timetracking?.remainingEstimateSeconds??null,timeSpentSeconds:r.timetracking?.timeSpentSeconds??null}}}async addComment(e,n){let o=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/comment`,{body:n});return {id:o.id??"",author:o.author?.emailAddress??o.author?.displayName??"Unknown",authorAccountId:o.author?.accountId??null,body:o.body??null,created:o.created??""}}async deleteIssue(e){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}`);}async deleteComment(e,n){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}/comment/${encodeURIComponent(n)}`);}async getTransitions(e){return ((await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`)).transitions??[]).map(o=>({id:o.id??"",name:o.name??"",toStatus:o.to?.name??""}))}async doTransition(e,n){await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`,{transition:{id:n}});}async assignIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}/assignee`,{accountId:n});}async findUser(e){let o=(await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:"1"}))?.[0];if(!o?.accountId)throw new ut(`User not found for email: ${e}`);return o.accountId}async getCurrentUser(){let e=await this.request("GET","/rest/api/3/myself");return {accountId:e.accountId,emailAddress:e.emailAddress??null,displayName:e.displayName??"Unknown",active:e.active}}async addWorklog(e,n,o){let r={timeSpentSeconds:n};o&&(r.comment=o);let i=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/worklog`,r);return {id:i.id??"",timeSpent:i.timeSpent??"",timeSpentSeconds:i.timeSpentSeconds??n,created:i.created??""}}async getTimeTracking(e){let o=(await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:"timetracking"})).fields.timetracking;return {originalEstimate:o?.originalEstimate??null,remainingEstimate:o?.remainingEstimate??null,timeSpent:o?.timeSpent??null,originalEstimateSeconds:o?.originalEstimateSeconds??null,remainingEstimateSeconds:o?.remainingEstimateSeconds??null,timeSpentSeconds:o?.timeSpentSeconds??null}}async createIssue(e){let n=await this.request("POST","/rest/api/3/issue",{fields:e});return {key:n.key,id:n.id,url:`${this.instanceUrl}/browse/${n.key}`}}async updateIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}`,{fields:n});}async getFields(){return (await this.request("GET","/rest/api/3/field")).map(n=>({id:n.id??"",name:n.name??"",custom:n.custom??false,...n.schema?.custom!==void 0?{schema:{custom:n.schema.custom}}:{}}))}async searchUsers(e,n=50){return (await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:String(n)})??[]).map(r=>({accountId:r.accountId,emailAddress:r.emailAddress??null,displayName:r.displayName??"Unknown",active:r.active}))}async getProjectStatuses(e){return (await this.request("GET",`/rest/api/3/project/${encodeURIComponent(e)}/statuses`)).map(o=>({id:o.id,name:o.name,statuses:o.statuses.map(r=>({name:r.name??"",id:r.id??""}))}))}};var Ro=class{byProject=new Map;byUrl=new Map;config;constructor(e){this.config=e,this.#e();}getConnector(e){let n=this.byProject.get(e);if(!n)throw new Ot(`Project '${e}' not found in configuration`);return n}getConnectorForTask(e){let n=e.split("-")[0];if(!n)throw new Ot(`Invalid task key format: '${e}'. Expected 'PROJECT-NUMBER'.`);return this.getConnector(n)}getInstances(){return this.byUrl}#e(){let e=new Map;for(let[n,o]of Object.entries(this.config.projects)){let r=e.get(o.url);r?r.push(n):e.set(o.url,[n]);}for(let[n,o]of e){let r=o[0];if(!r)continue;let i=this.config.projects[r];if(!i)continue;let a=new dd(i),s={connector:a,projectKeys:o};this.byUrl.set(n,s);for(let c of o)this.byProject.set(c,a);}}};var Va="1.0",nC=x.object({key:x.string(),summary:x.string(),status:x.string(),assignee:x.string().nullable(),priority:x.string(),issue_type:x.string(),created:x.string(),updated:x.string(),project_key:x.string(),project_url:x.string().url(),epic_link:x.string().nullable()}),oC=x.object({version:x.string(),last_sync:x.string(),jira_user:x.string()}),Qg=x.object({metadata:oC,tasks:x.array(nC)});function lC(t){return t.replaceAll("@","_at_").replaceAll(".","_")}var pd=class{cacheDir;jiraUser;cachePath;constructor(e,n){this.cacheDir=e,this.jiraUser=n,this.cachePath=join(e,`tasks_${lC(n)}.json`);}async initialize(){if(await mkdir(this.cacheDir,{recursive:true}),await Er(this.cachePath)){try{await this.load();}catch(n){if(!(n instanceof Rt)){let o=n instanceof Error?n.message:String(n);throw new Rr(`Existing cache is corrupted: ${o}`)}}return}let e={metadata:{version:Va,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[]};await this.#e(e);}async load(){if(!await Er(this.cachePath))throw new Rt(`Cache not found: ${this.cachePath}`);let e;try{e=await readFile(this.cachePath,"utf-8");}catch(r){let i=r instanceof Error?r.message:String(r);throw new Rt(`Failed to read cache file: ${i}`)}let n;try{n=JSON.parse(e);}catch(r){let i=r instanceof Error?r.message:String(r);throw new Rr(`Cache file is corrupted (invalid JSON): ${i}`)}let o=Qg.safeParse(n);if(!o.success)throw new Rr(`Cache data failed validation: ${o.error.message}`);if(o.data.metadata.version!==Va)throw new Rr(`Cache version ${o.data.metadata.version} !== ${Va}`);return o.data}async save(e){let n={metadata:{version:Va,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[...e]},o=Qg.safeParse(n);if(!o.success)throw new Rr(`Task data failed validation: ${o.error.message}`);await this.#e(o.data);}async getTask(e){let o=(await this.load()).tasks.find(r=>r.key===e);if(!o)throw new Nt(`Task ${e} not found in cache`);return o}async getAllTasks(){return (await this.load()).tasks}async updateTask(e,n){let o=await this.load(),r=o.tasks.findIndex(c=>c.key===e);if(r===-1)throw new Nt(`Task ${e} not found in cache`);let i=o.tasks[r];if(!i)throw new Nt(`Task ${e} not found in cache`);let a={...i,...n,key:e,updated:new Date().toISOString()},s=[...o.tasks.slice(0,r),a,...o.tasks.slice(r+1)];return await this.save(s),a}async deleteTask(e){let n=await this.load(),o=n.tasks.filter(r=>r.key!==e);if(o.length===n.tasks.length)throw new Nt(`Task ${e} not found in cache`);await this.save(o);}async upsertTask(e){let n=[];try{n=(await this.load()).tasks;}catch(i){if(!(i instanceof Rt))throw i}let o=n.findIndex(i=>i.key===e.key),r=o===-1?[...n,e]:n.map((i,a)=>a===o?e:i);return await this.save(r),e}async getMetadata(){return (await this.load()).metadata}async#e(e){let n=`${this.cachePath}.tmp`,o=JSON.stringify(e,null,2);await writeFile(n,o,{encoding:"utf-8",mode:384}),await rename(n,this.cachePath);}};function md(t){return t.replace(/([\\"])/g,"\\$1")}var fd=class{#e;#t;#r;constructor(e,n,o){this.#e=e,this.#t=n,this.#r=o;}async sync(e){let n=e?.jql??`assignee = "${md(this.#t.credentials.username)}" ORDER BY updated DESC`,o=Fx(this.#t);if(e?.projectKey){let i=this.#t.projects[e.projectKey];i&&(o=o.filter(a=>a.url===i.url));}let r=[];for(let i of o){let c=(await this.#r(i.url,i.username,i.api_token).searchIssues(n)).map(u=>this.#n(u,i.url));r.push(...c);}return await this.#e.save(r),r.length}#n(e,n){let o=e.fields.assignee?.emailAddress??null,r=e.fields.priority?.name??"None",i=e.fields.customfield_10014??null;return {key:e.key,summary:e.fields.summary,status:e.fields.status.name,assignee:o,priority:r,issue_type:e.fields.issuetype.name,created:e.fields.created,updated:e.fields.updated,project_key:e.fields.project.key,project_url:n,epic_link:i}}};fn();var Nr={WORKFLOW:"workflow",COMMUNICATION:"communication",REPORTING:"reporting",DEVELOPMENT:"development"};var Bx=/^[a-z][a-z0-9-]*$/,Kx=x.object({name:x.string().regex(/^\w+$/,"Variable name must be alphanumeric/underscore"),description:x.string().default(""),required:x.boolean().default(false),default:x.string().optional(),example:x.string().optional()}),pC=x.object({kind:x.literal("comment"),id:x.string().regex(Bx,"Template id must be a URL-safe slug"),name:x.string().min(1),description:x.string().min(1),category:x.enum([Nr.WORKFLOW,Nr.COMMUNICATION,Nr.REPORTING,Nr.DEVELOPMENT]),variables:x.array(Kx).default([])}),mC=x.object({kind:x.literal("task"),id:x.string().regex(Bx,"Template id must be a URL-safe slug"),name:x.string().min(1),description:x.string().min(1),summary:x.string().min(1),issue_type:x.string().optional(),priority:x.string().optional(),labels:x.array(x.string()).optional(),epic_key:x.string().optional(),variables:x.array(Kx).default([])});function Hx(t){return t.map(e=>({name:e.name,description:e.description,required:e.required,defaultValue:e.default,example:e.example}))}function Wx(t,e){let n=t.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);if(!n)throw new pn(`Template file "${e}" must start with a JSON metadata block delimited by ---`);let[,o,r=""]=n;if(o===void 0)throw new pn(`Template file "${e}" is missing metadata.`);let i;try{i=JSON.parse(o);}catch(a){let s=a instanceof Error?a.message:String(a);throw new pn(`Template file "${e}" contains invalid JSON metadata: ${s}`)}return {metadata:i,body:r.trim()}}function Xx(t){if(!readdirSync||!t)return [];try{return readdirSync(t).filter(e=>e.endsWith(".md")).sort().map(e=>join(t,e))}catch{return []}}function hd(t,e){let n=[];for(let o of Xx(t)){let r=readFileSync(o,"utf-8"),i=Wx(r,o),a=pC.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,category:a.category,variables:Hx(a.variables),body:i.body,source:e,filePath:o});}return n}function gd(t,e){let n=[];for(let o of Xx(t)){let r=readFileSync(o,"utf-8"),i=Wx(r,o),a=mC.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,summary:a.summary,issueType:a.issue_type,priority:a.priority,labels:a.labels,epicKey:a.epic_key,variables:Hx(a.variables),body:i.body,source:e,filePath:o});}return n}fn();var Yx=hd(Xg,"system");var yd=class{templates;constructor(e){let n=new Map;for(let o of Yx)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new Eo(`Template "${e}" not found. Use listTemplates() to see available templates.`);return n}listTemplates(e){let n=[...this.templates.values()];return e?n.filter(o=>o.category===e):n}listCategories(){let e=new Set;for(let n of this.templates.values())e.add(n.category);return [...e]}};fn();var Qx=gd(Yg,"system");var vd=class{templates;constructor(e){let n=new Map;for(let o of Qx)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new Eo(`Task template "${e}" not found. Use listTaskTemplates() to see available templates.`);return n}listTemplates(){return [...this.templates.values()]}};function ew(t){let e=hd(sd,"user"),n=gd(cd,"user");return {commentRegistry:new yd(e),taskRegistry:new vd(n)}}function ey(t){return {version:1,type:"doc",content:[{type:"paragraph",content:[{type:"text",text:t}]}]}}function Jt(t){let e=t.replace(/\\n/g,`
50
+ `}var Xl=class{constructor(e=Nx.stdin,n=Nx.stdout){this._stdin=e,this._stdout=n,this._readBuffer=new Wl,this._started=false,this._ondata=o=>{this._readBuffer.append(o),this.processReadBuffer();},this._onerror=o=>{this.onerror?.(o);};}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=true,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror);}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e);}catch(e){this.onerror?.(e);}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.();}send(e){return new Promise(n=>{let o=Rx(e);this._stdout.write(o)?n():this._stdout.once("drain",n);})}};var Cx="1.7.0";async function Er(t){try{return await access(t),!0}catch{return false}}var UN=["pl","en","de","es","fr","pt","it","nl"],jo=x.enum(UN),Or="pl",ZN=x.object({url:x.string().url(),language:jo.optional()}),Dx=x.object({projects:x.record(x.string(),ZN),default_project:x.string(),default_language:jo.optional()}).refine(t=>t.default_project in t.projects,{message:"default_project must reference a configured project"}),Po=x.object({username:x.string().email(),api_token:x.string().min(1)}),Gg=x.object({default:Po,instances:x.record(x.string().url(),Po).optional()}),Ax=x.union([Po,Gg]),Bg=x.object({url:x.string().url(),username:x.string().email(),api_token:x.string().min(1),language:jo});x.object({projects:x.record(x.string(),Bg),default_project:x.string(),default_language:jo,credentials:Po});var rt=class extends Error{code;constructor(e,n){super(e),this.name="JiraMcpError",this.code=n;}},Yl=class extends rt{constructor(e,n="CONFIG_ERROR"){super(e,n),this.name="ConfigError";}},Ma=class extends Yl{constructor(e){super(e,"CONFIG_NOT_FOUND"),this.name="ConfigNotFoundError";}},Ot=class extends Yl{constructor(e){super(e,"CONFIG_VALIDATION"),this.name="ConfigValidationError";}},ut=class extends rt{constructor(e,n="JIRA_CONNECTION"){super(e,n),this.name="JiraConnectionError";}},Ql=class extends ut{constructor(e){super(e,"JIRA_AUTH"),this.name="JiraAuthenticationError";}},ed=class extends ut{constructor(e){super(e,"JIRA_PERMISSION"),this.name="JiraPermissionError";}},La=class extends rt{constructor(e,n="CACHE_ERROR"){super(e,n),this.name="CacheError";}},Rt=class extends La{constructor(e){super(e,"CACHE_NOT_FOUND"),this.name="CacheNotFoundError";}},Rr=class extends La{constructor(e){super(e,"CACHE_CORRUPTION"),this.name="CacheCorruptionError";}},Nt=class extends La{constructor(e){super(e,"TASK_NOT_FOUND"),this.name="TaskNotFoundError";}},pn=class extends rt{constructor(e,n="TEMPLATE_ERROR"){super(e,n),this.name="TemplateError";}},Eo=class extends pn{constructor(e){super(e,"TEMPLATE_NOT_FOUND"),this.name="TemplateNotFoundError";}};var td=class extends rt{constructor(e,n="APPROVAL_ERROR"){super(e,n),this.name="ApprovalError";}},rd=class extends td{constructor(e){super(e,"COMMENT_APPROVAL_REQUIRED"),this.name="CommentApprovalRequiredError";}},nd=class extends td{constructor(e){super(e,"DELETION_APPROVAL_REQUIRED"),this.name="DeletionApprovalRequiredError";}},qa=class extends rt{constructor(e){super(e,"OWNERSHIP_REQUIRED"),this.name="OwnershipError";}},od=class extends rt{constructor(e){super(e,"COMMENT_NOT_FOUND"),this.name="CommentNotFoundError";}};fn();async function KN(t){if(t?.configPath)return resolve(t.configPath);let e=process.env.JIRA_CONFIG_PATH;if(e)return resolve(e);let n=resolve(process.cwd(),"config.json");return await Er(n)?(console.warn(`[jira-mcp] WARNING: Loading config.json from working directory (${n}) instead of global config. This may be a security risk if running from an untrusted directory.`),n):Kg}async function HN(t){if(t?.credentialsPath)return resolve(t.credentialsPath);let e=process.env.JIRA_CREDENTIALS_PATH;if(e)return resolve(e);let n=resolve(process.cwd(),"credentials.json");return await Er(n)?(console.warn(`[jira-mcp] WARNING: Loading credentials.json from working directory (${n}) instead of global config. This may be a security risk if running from an untrusted directory.`),n):Hg}async function qx(t,e){if(!await Er(t))throw new Ma(`${e} not found: ${t}`);let n;try{n=await readFile(t,"utf-8");}catch(o){let r=o instanceof Error?o.message:String(o);throw new Ma(`Failed to read ${e}: ${r}`)}try{return JSON.parse(n)}catch(o){let r=o instanceof Error?o.message:String(o);throw new Ot(`Invalid JSON in ${e}: ${r}`)}}function WN(t){let e=Po.safeParse(t);if(e.success&&!("default"in t))return {default:e.data,instances:{}};let n=Gg.safeParse(t);if(n.success)return {default:n.data.default,instances:n.data.instances??{}};throw new Ot("Credentials file format not recognized. Expected { username, api_token } or { default: { username, api_token }, instances?: {} }.")}function XN(t,e){return t.instances[e]??t.default}async function ld(t){let e=await KN(t),n=await HN(t),o=await qx(e,"configuration file"),r=Dx.safeParse(o);if(!r.success)throw new Ot(`Configuration validation failed: ${r.error.message}`);let i=r.data,a=await qx(n,"credentials file"),s=Ax.safeParse(a);if(!s.success)throw new Ot(`Credentials validation failed: ${s.error.message}`);let c=WN(s.data),u=i.default_language??Or,l={};for(let[d,m]of Object.entries(i.projects)){let p=XN(c,m.url),h={url:m.url,username:p.username,api_token:p.api_token,language:m.language??u},v=Bg.safeParse(h);if(!v.success)throw new Ot(`Project '${d}' validation failed: ${v.error.message}`);l[d]=v.data;}return {projects:l,default_project:i.default_project,default_language:u,credentials:c.default}}function Fx(t){let e=new Map;for(let[o,r]of Object.entries(t.projects)){let i=e.get(r.url);i?i.keys.push(o):e.set(r.url,{keys:[o]});}let n=[];for(let[o,{keys:r}]of e){let i=r[0];if(!i)continue;let a=t.projects[i];a&&n.push({url:o,username:a.username,api_token:a.api_token,projectKeys:r});}return n}var YN=1e3,Vx=3,QN=1e3,eC=new Set([429,503]);function tC(t){return new Promise(e=>setTimeout(e,t))}var rC=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"],dd=class{authToken;instanceUrl;constructor(e){this.instanceUrl=e.url,this.authToken=Buffer.from(`${e.username}:${e.api_token}`).toString("base64");}async request(e,n,o,r){let i=new URL(n,this.instanceUrl);if(r)for(let[u,l]of Object.entries(r))i.searchParams.set(u,l);let a={Authorization:`Basic ${this.authToken}`,Accept:"application/json"};o!==void 0&&(a["Content-Type"]="application/json");let s={method:e,headers:a,body:o!==void 0?JSON.stringify(o):void 0},c;for(let u=0;u<=Vx;u++){let l=await fetch(i.toString(),s);if(l.ok)return l.status===204?void 0:await l.json();let m=await l.text()||l.statusText,p=m.length>200?`${m.slice(0,200)}...`:m;if(l.status===401)throw new Ql(`Authentication failed: ${p}`);if(l.status===403)throw new ed(`Permission denied: ${p}`);if(eC.has(l.status)&&u<Vx){let h=l.headers.get("Retry-After"),v=h?Math.min(parseInt(h,10)*1e3,3e4):QN*Math.pow(2,u);await tC(v),c=new ut(`Jira API error (${l.status}): ${p}`);continue}throw new ut(`Jira API error (${l.status}): ${p}`)}throw c??new ut("Request failed after retries")}async searchIssues(e,n){return ((await this.request("GET","/rest/api/3/search/jql",void 0,{jql:e,fields:(n?[...n]:rC).join(","),maxResults:String(YN)})).issues??[]).map(i=>{let a=i.fields;return {key:i.key,summary:a.summary,status:a.status?.name??"Unknown",assignee:a.assignee?.emailAddress??null,priority:a.priority?.name??"None",issueType:a.issuetype?.name??a.issueType?.name??"Unknown",created:a.created,updated:a.updated,projectKey:i.key.split("-")[0]??"",epicLink:a.customfield_10014??null}})}async getIssue(e){let n=["summary","description","creator","status","assignee","priority","issuetype","created","updated","project","comment","timetracking"],o=await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:n.join(",")}),r=o.fields,i=(r.comment?.comments??[]).map(a=>({id:a.id??"",author:a.author?.emailAddress??a.author?.displayName??"Unknown",authorAccountId:a.author?.accountId??null,body:a.body??null,created:a.created??""}));return {key:o.key,summary:r.summary,description:r.description??null,creator:r.creator?.emailAddress??r.creator?.displayName??"Unknown",creatorAccountId:r.creator?.accountId??null,status:r.status?.name??"Unknown",assignee:r.assignee?.emailAddress??null,priority:r.priority?.name??"None",issueType:r.issuetype?.name??r.issueType?.name??"Unknown",created:r.created,updated:r.updated,projectKey:o.key.split("-")[0]??"",comments:i,timeTracking:{originalEstimate:r.timetracking?.originalEstimate??null,remainingEstimate:r.timetracking?.remainingEstimate??null,timeSpent:r.timetracking?.timeSpent??null,originalEstimateSeconds:r.timetracking?.originalEstimateSeconds??null,remainingEstimateSeconds:r.timetracking?.remainingEstimateSeconds??null,timeSpentSeconds:r.timetracking?.timeSpentSeconds??null}}}async addComment(e,n){let o=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/comment`,{body:n});return {id:o.id??"",author:o.author?.emailAddress??o.author?.displayName??"Unknown",authorAccountId:o.author?.accountId??null,body:o.body??null,created:o.created??""}}async deleteIssue(e){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}`);}async deleteComment(e,n){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}/comment/${encodeURIComponent(n)}`);}async getTransitions(e){return ((await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`)).transitions??[]).map(o=>({id:o.id??"",name:o.name??"",toStatus:o.to?.name??""}))}async doTransition(e,n){await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`,{transition:{id:n}});}async assignIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}/assignee`,{accountId:n});}async findUser(e){let o=(await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:"1"}))?.[0];if(!o?.accountId)throw new ut(`User not found for email: ${e}`);return o.accountId}async getCurrentUser(){let e=await this.request("GET","/rest/api/3/myself");return {accountId:e.accountId,emailAddress:e.emailAddress??null,displayName:e.displayName??"Unknown",active:e.active}}async addWorklog(e,n,o){let r={timeSpentSeconds:n};o&&(r.comment=o);let i=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/worklog`,r);return {id:i.id??"",timeSpent:i.timeSpent??"",timeSpentSeconds:i.timeSpentSeconds??n,created:i.created??""}}async getTimeTracking(e){let o=(await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:"timetracking"})).fields.timetracking;return {originalEstimate:o?.originalEstimate??null,remainingEstimate:o?.remainingEstimate??null,timeSpent:o?.timeSpent??null,originalEstimateSeconds:o?.originalEstimateSeconds??null,remainingEstimateSeconds:o?.remainingEstimateSeconds??null,timeSpentSeconds:o?.timeSpentSeconds??null}}async createIssue(e){let n=await this.request("POST","/rest/api/3/issue",{fields:e});return {key:n.key,id:n.id,url:`${this.instanceUrl}/browse/${n.key}`}}async updateIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}`,{fields:n});}async getFields(){return (await this.request("GET","/rest/api/3/field")).map(n=>({id:n.id??"",name:n.name??"",custom:n.custom??false,...n.schema?.custom!==void 0?{schema:{custom:n.schema.custom}}:{}}))}async searchUsers(e,n=50){return (await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:String(n)})??[]).map(r=>({accountId:r.accountId,emailAddress:r.emailAddress??null,displayName:r.displayName??"Unknown",active:r.active}))}async getProjectStatuses(e){return (await this.request("GET",`/rest/api/3/project/${encodeURIComponent(e)}/statuses`)).map(o=>({id:o.id,name:o.name,statuses:o.statuses.map(r=>({name:r.name??"",id:r.id??""}))}))}};var Ro=class{byProject=new Map;byUrl=new Map;config;constructor(e){this.config=e,this.#e();}getConnector(e){let n=this.byProject.get(e);if(!n)throw new Ot(`Project '${e}' not found in configuration`);return n}getConnectorForTask(e){let n=e.split("-")[0];if(!n)throw new Ot(`Invalid task key format: '${e}'. Expected 'PROJECT-NUMBER'.`);return this.getConnector(n)}getInstances(){return this.byUrl}#e(){let e=new Map;for(let[n,o]of Object.entries(this.config.projects)){let r=e.get(o.url);r?r.push(n):e.set(o.url,[n]);}for(let[n,o]of e){let r=o[0];if(!r)continue;let i=this.config.projects[r];if(!i)continue;let a=new dd(i),s={connector:a,projectKeys:o};this.byUrl.set(n,s);for(let c of o)this.byProject.set(c,a);}}};var Va="1.0",nC=x.object({key:x.string(),summary:x.string(),status:x.string(),assignee:x.string().nullable(),priority:x.string(),issue_type:x.string(),created:x.string(),updated:x.string(),project_key:x.string(),project_url:x.string().url(),epic_link:x.string().nullable()}),oC=x.object({version:x.string(),last_sync:x.string(),jira_user:x.string()}),Qg=x.object({metadata:oC,tasks:x.array(nC)});function lC(t){return t.replaceAll("@","_at_").replaceAll(".","_")}var pd=class{cacheDir;jiraUser;cachePath;constructor(e,n){this.cacheDir=e,this.jiraUser=n,this.cachePath=join(e,`tasks_${lC(n)}.json`);}async initialize(){if(await mkdir(this.cacheDir,{recursive:true}),await Er(this.cachePath)){try{await this.load();}catch(n){if(!(n instanceof Rt)){let o=n instanceof Error?n.message:String(n);throw new Rr(`Existing cache is corrupted: ${o}`)}}return}let e={metadata:{version:Va,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[]};await this.#e(e);}async load(){if(!await Er(this.cachePath))throw new Rt(`Cache not found: ${this.cachePath}`);let e;try{e=await readFile(this.cachePath,"utf-8");}catch(r){let i=r instanceof Error?r.message:String(r);throw new Rt(`Failed to read cache file: ${i}`)}let n;try{n=JSON.parse(e);}catch(r){let i=r instanceof Error?r.message:String(r);throw new Rr(`Cache file is corrupted (invalid JSON): ${i}`)}let o=Qg.safeParse(n);if(!o.success)throw new Rr(`Cache data failed validation: ${o.error.message}`);if(o.data.metadata.version!==Va)throw new Rr(`Cache version ${o.data.metadata.version} !== ${Va}`);return o.data}async save(e){let n={metadata:{version:Va,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[...e]},o=Qg.safeParse(n);if(!o.success)throw new Rr(`Task data failed validation: ${o.error.message}`);await this.#e(o.data);}async getTask(e){let o=(await this.load()).tasks.find(r=>r.key===e);if(!o)throw new Nt(`Task ${e} not found in cache`);return o}async getAllTasks(){return (await this.load()).tasks}async updateTask(e,n){let o=await this.load(),r=o.tasks.findIndex(c=>c.key===e);if(r===-1)throw new Nt(`Task ${e} not found in cache`);let i=o.tasks[r];if(!i)throw new Nt(`Task ${e} not found in cache`);let a={...i,...n,key:e,updated:new Date().toISOString()},s=[...o.tasks.slice(0,r),a,...o.tasks.slice(r+1)];return await this.save(s),a}async deleteTask(e){let n=await this.load(),o=n.tasks.filter(r=>r.key!==e);if(o.length===n.tasks.length)throw new Nt(`Task ${e} not found in cache`);await this.save(o);}async upsertTask(e){let n=[];try{n=(await this.load()).tasks;}catch(i){if(!(i instanceof Rt))throw i}let o=n.findIndex(i=>i.key===e.key),r=o===-1?[...n,e]:n.map((i,a)=>a===o?e:i);return await this.save(r),e}async getMetadata(){return (await this.load()).metadata}async#e(e){let n=`${this.cachePath}.tmp`,o=JSON.stringify(e,null,2);await writeFile(n,o,{encoding:"utf-8",mode:384}),await rename(n,this.cachePath);}};function md(t){return t.replace(/([\\"])/g,"\\$1")}var fd=class{#e;#t;#r;constructor(e,n,o){this.#e=e,this.#t=n,this.#r=o;}async sync(e){let n=e?.jql??`assignee = "${md(this.#t.credentials.username)}" ORDER BY updated DESC`,o=Fx(this.#t);if(e?.projectKey){let i=this.#t.projects[e.projectKey];i&&(o=o.filter(a=>a.url===i.url));}let r=[];for(let i of o){let c=(await this.#r(i.url,i.username,i.api_token).searchIssues(n)).map(u=>this.#n(u,i.url));r.push(...c);}return await this.#e.save(r),r.length}#n(e,n){let o=e.fields.assignee?.emailAddress??null,r=e.fields.priority?.name??"None",i=e.fields.customfield_10014??null;return {key:e.key,summary:e.fields.summary,status:e.fields.status.name,assignee:o,priority:r,issue_type:e.fields.issuetype.name,created:e.fields.created,updated:e.fields.updated,project_key:e.fields.project.key,project_url:n,epic_link:i}}};fn();var Nr={WORKFLOW:"workflow",COMMUNICATION:"communication",REPORTING:"reporting",DEVELOPMENT:"development"};var Bx=/^[a-z][a-z0-9-]*$/,Kx=x.object({name:x.string().regex(/^\w+$/,"Variable name must be alphanumeric/underscore"),description:x.string().default(""),required:x.boolean().default(false),default:x.string().optional(),example:x.string().optional()}),pC=x.object({kind:x.literal("comment"),id:x.string().regex(Bx,"Template id must be a URL-safe slug"),name:x.string().min(1),description:x.string().min(1),category:x.enum([Nr.WORKFLOW,Nr.COMMUNICATION,Nr.REPORTING,Nr.DEVELOPMENT]),variables:x.array(Kx).default([])}),mC=x.object({kind:x.literal("task"),id:x.string().regex(Bx,"Template id must be a URL-safe slug"),name:x.string().min(1),description:x.string().min(1),summary:x.string().min(1),issue_type:x.string().optional(),priority:x.string().optional(),labels:x.array(x.string()).optional(),epic_key:x.string().optional(),variables:x.array(Kx).default([])});function Hx(t){return t.map(e=>({name:e.name,description:e.description,required:e.required,defaultValue:e.default,example:e.example}))}function Wx(t,e){let n=t.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);if(!n)throw new pn(`Template file "${e}" must start with a JSON metadata block delimited by ---`);let[,o,r=""]=n;if(o===void 0)throw new pn(`Template file "${e}" is missing metadata.`);let i;try{i=JSON.parse(o);}catch(a){let s=a instanceof Error?a.message:String(a);throw new pn(`Template file "${e}" contains invalid JSON metadata: ${s}`)}return {metadata:i,body:r.trim()}}function Xx(t){if(!readdirSync||!t)return [];try{return readdirSync(t).filter(e=>e.endsWith(".md")).sort().map(e=>join(t,e))}catch{return []}}function hd(t,e){let n=[];for(let o of Xx(t)){let r=readFileSync(o,"utf-8"),i=Wx(r,o),a=pC.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,category:a.category,variables:Hx(a.variables),body:i.body,source:e,filePath:o});}return n}function gd(t,e){let n=[];for(let o of Xx(t)){let r=readFileSync(o,"utf-8"),i=Wx(r,o),a=mC.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,summary:a.summary,issueType:a.issue_type,priority:a.priority,labels:a.labels,epicKey:a.epic_key,variables:Hx(a.variables),body:i.body,source:e,filePath:o});}return n}fn();var Yx=hd(Xg,"system");var yd=class{templates;constructor(e){let n=new Map;for(let o of Yx)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new Eo(`Template "${e}" not found. Use listTemplates() to see available templates.`);return n}listTemplates(e){let n=[...this.templates.values()];return e?n.filter(o=>o.category===e):n}listCategories(){let e=new Set;for(let n of this.templates.values())e.add(n.category);return [...e]}};fn();var Qx=gd(Yg,"system");var vd=class{templates;constructor(e){let n=new Map;for(let o of Qx)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new Eo(`Task template "${e}" not found. Use listTaskTemplates() to see available templates.`);return n}listTemplates(){return [...this.templates.values()]}};function ew(t){let e=hd(sd,"user"),n=gd(cd,"user");return {commentRegistry:new yd(e),taskRegistry:new vd(n)}}function ey(t){return {version:1,type:"doc",content:[{type:"paragraph",content:[{type:"text",text:t}]}]}}function Jt(t){let e=t.replace(/\\n/g,`
50
51
  `);if(e.trim().length===0)return ey(e);try{let n=aw(e,{nextTaskId:1});return n.length===0?ey(e):{version:1,type:"doc",content:n}}catch{return ey(e)}}function fC(t){return {lines:t.split(`
51
52
  `),pos:0}}function No(t){return t.lines[t.pos]}function nt(t){let e=t.lines[t.pos]??"";return t.pos++,e}function Co(t){return t.pos<t.lines.length}var nw=/^(#{1,6})\s+(.+)$/,ay=/^(\s*)[-*+]\s+(.*)$/,sy=/^(\s*)\d+\.\s+(.*)$/,hC=/^(\s*)[-*+]\s+\[([ xX])\]\s+(.*)$/,ow=/^```(\w*)$/,cy=/^>\s?(.*)$/,iw=/^(?:---+|\*\*\*+|___+)\s*$/,gC=/^:?-{3,}:?$/;function aw(t,e){let n=fC(t),o=[];for(;Co(n);){let r=No(n);if(r===void 0)break;if(r.trim()===""){nt(n);continue}let i=ow.exec(r);if(i){o.push(yC(n,i[1]??""));continue}if(iw.test(r)){nt(n),o.push({type:"rule"});continue}let a=nw.exec(r);if(a){nt(n);let s=(a[1]??"#").length,c=a[2]??"";o.push({type:"heading",attrs:{level:s},content:iy(c)});continue}if(cy.test(r)){o.push(vC(n,e));continue}if(ay.test(r)||sy.test(r)){o.push(...oy(_C(n),e));continue}if(sw(n)){o.push(bC(n));continue}o.push(kC(n));}return o}function yC(t,e){nt(t);let n=[];for(;Co(t);){let r=No(t);if(r!==void 0&&/^```\s*$/.test(r)){nt(t);break}n.push(nt(t));}let o=n.join(`
52
53
  `);return {type:"codeBlock",attrs:{language:e||"text"},content:o.length>0?[{type:"text",text:o}]:[]}}function vC(t,e){let n=[];for(;Co(t);){let i=No(t);if(i===void 0)break;let a=cy.exec(i);if(!a)break;nt(t),n.push(a[1]??"");}let o=n.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softspark/jira-mcp",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "MCP server for Jira integration — multi-instance routing, ADF formatting, task caching, and comment templates via the Model Context Protocol.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -23,7 +23,7 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/softspark/jira-mcp/issues"
25
25
  },
26
- "license": "MIT",
26
+ "license": "Apache-2.0",
27
27
  "author": "SoftSpark <biuro@softspark.eu>",
28
28
  "type": "module",
29
29
  "main": "dist/index.js",
@@ -44,7 +44,8 @@
44
44
  "templates-system/**/*.md",
45
45
  "README.md",
46
46
  "CHANGELOG.md",
47
- "LICENSE"
47
+ "LICENSE",
48
+ "NOTICE"
48
49
  ],
49
50
  "engines": {
50
51
  "node": ">=18.0.0"