@svazqz/api-contract-kit 0.1.6-alpha

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.
@@ -0,0 +1,68 @@
1
+ const h = {
2
+ id: "json",
3
+ requestContentType: "application/json",
4
+ responseContentType: "application/json",
5
+ decodeRequest: async (e) => {
6
+ if (!(e.headers.get("content-type") || "").includes("application/json")) {
7
+ const r = await e.text();
8
+ if (!r) return;
9
+ try {
10
+ return JSON.parse(r);
11
+ } catch {
12
+ return r;
13
+ }
14
+ }
15
+ const s = await e.text();
16
+ if (s)
17
+ return JSON.parse(s);
18
+ },
19
+ encodeResponse: async (e) => ({
20
+ body: JSON.stringify(e),
21
+ headers: { "content-type": "application/json" }
22
+ })
23
+ }, b = (e, t) => {
24
+ let s = `${e}${t.query ? `?${new URLSearchParams(t.query || {})}` : ""}`;
25
+ return t && t.urlParams && Object.keys(t.urlParams).forEach(
26
+ (r) => {
27
+ s = s.replace(
28
+ `{${r}}`,
29
+ t == null ? void 0 : t.urlParams[r]
30
+ );
31
+ }
32
+ ), s;
33
+ }, y = (e) => {
34
+ const t = e.fetchFn ?? fetch, s = e.headersProvider;
35
+ return { call: async (n, a) => {
36
+ const c = b(
37
+ (n == null ? void 0 : n.endpoint) || (n == null ? void 0 : n.path) || "/",
38
+ a
39
+ ), p = await (s == null ? void 0 : s()) ?? {}, l = `${e.baseUrl}${c}`, d = await t(l, {
40
+ method: n.method || "get",
41
+ body: a.body === void 0 ? void 0 : JSON.stringify(a.body),
42
+ headers: {
43
+ ...p,
44
+ ...a.headers ?? {},
45
+ ...a.body === void 0 ? {} : { "content-type": h.requestContentType }
46
+ },
47
+ signal: a.signal
48
+ });
49
+ if (!d.ok) {
50
+ const o = await d.text();
51
+ throw new Error(o || `Request failed with status ${d.status}`);
52
+ }
53
+ return await h.decodeRequest(d);
54
+ } };
55
+ }, u = (e, t) => async (s) => {
56
+ var c;
57
+ const r = (c = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : c.env, n = (r == null ? void 0 : r.NEXT_PUBLIC_BASE_API_URL) || "";
58
+ return y({
59
+ baseUrl: (t == null ? void 0 : t.baseUrl) ?? n,
60
+ fetchFn: t == null ? void 0 : t.fetchFn,
61
+ headersProvider: t == null ? void 0 : t.headersProvider
62
+ }).call(e, s);
63
+ };
64
+ export {
65
+ u as apiConsumer,
66
+ y as createClient
67
+ };
68
+ //# sourceMappingURL=client.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.es.js","sources":["../src/utils.ts","../src/client.ts"],"sourcesContent":["import { ZodType, ZodNumber, ZodBoolean } from 'zod';\nimport { ApiCodec, ServerFnDefinition } from './types';\nimport { RouteConfig } from '@asteasolutions/zod-to-openapi';\n\nexport function validateQueryParams<\n URLParams extends ZodType,\n QueryParams extends ZodType,\n Body extends ZodType,\n Response extends ZodType,\n>(\n request: Request,\n def: ServerFnDefinition<URLParams, QueryParams, Body, Response>,\n) {\n const queryParams = {};\n const params = new URL(request.url).searchParams.keys();\n for (const param of params) {\n if ((def.schemas?.queryParams as any).shape[param] instanceof ZodNumber) {\n (queryParams as unknown as any)[param as unknown as string] = Number(\n new URL(request.url).searchParams.get(param),\n );\n } else if (\n (def.schemas?.queryParams as any).shape[param] instanceof ZodBoolean\n ) {\n (queryParams as unknown as any)[param as unknown as string] = Boolean(\n new URL(request.url).searchParams.get(param),\n );\n } else {\n (queryParams as unknown as any)[param as unknown as string] =\n new URL(request.url).searchParams.get(param);\n }\n }\n def.schemas?.queryParams?.parse(queryParams);\n return queryParams;\n}\n\nexport async function validatePayload<\n URLParams extends ZodType,\n QueryParams extends ZodType,\n Body extends ZodType,\n Response extends ZodType,\n>(\n request: Request,\n def: ServerFnDefinition<URLParams, QueryParams, Body, Response>,\n ProtoClass: any,\n) {\n let parsedPayload: Body | undefined = undefined;\n\n if (ProtoClass) {\n try {\n const lResponse = await request.arrayBuffer();\n parsedPayload = ProtoClass.decode(new Uint8Array(lResponse));\n } catch {\n throw new Error('Protocol buffer parsing error');\n }\n } else {\n parsedPayload = await request.json();\n }\n def.schemas?.payload?.parse(parsedPayload);\n return parsedPayload;\n}\n\nexport const setOpenAPIMetadata = (_def: any) => {\n const openapiPathPrefix = `${_def.openapiPathPrefix ?? '/api'}`;\n const endpoint = `${_def.endpoint ?? _def.path ?? ''}`;\n const codec = _def.codec ?? jsonCodec;\n\n const apiConfig = {\n method: _def.method,\n path: `${openapiPathPrefix}${endpoint}`,\n summary: _def.openapi?.summary ?? '',\n request: {},\n responses: {},\n } as RouteConfig;\n\n const baseResponses =\n _def.schemas?.response\n ? {\n 200: {\n description: _def.openapi?.responses?.[200]?.description ?? '',\n content: {\n [codec.responseContentType]: {\n schema: _def.schemas?.response,\n },\n },\n },\n }\n : {};\n\n const customResponses = _def.openapi?.responses ?? {};\n apiConfig.responses = { ...baseResponses, ...customResponses };\n\n if (_def.schemas?.queryParams) {\n (apiConfig.request as any).query = (\n _def.schemas?.queryParams as any\n )?.openapi('Query Params');\n }\n if (_def.schemas?.payload) {\n (apiConfig.request as any).body = {\n description: 'Body',\n content: {\n [codec.requestContentType]: {\n schema: _def.schemas?.payload,\n },\n },\n required: true,\n };\n }\n if (_def.schemas?.urlArgs) {\n (apiConfig.request as any).params = (_def.schemas?.urlArgs as any)?.openapi(\n 'URL Params',\n );\n }\n\n (apiConfig as any).description = _def.openapi?.description;\n (apiConfig as any).tags = _def.openapi?.tags;\n (apiConfig as any).operationId = _def.openapi?.operationId;\n (apiConfig as any).deprecated = _def.openapi?.deprecated;\n (apiConfig as any).security = _def.openapi?.security;\n\n return apiConfig;\n};\n\nexport const jsonCodec: ApiCodec = {\n id: 'json',\n requestContentType: 'application/json',\n responseContentType: 'application/json',\n decodeRequest: async (request) => {\n const contentType = request.headers.get('content-type') || '';\n if (!contentType.includes('application/json')) {\n const text = await request.text();\n if (!text) return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n }\n const text = await request.text();\n if (!text) return undefined;\n return JSON.parse(text);\n },\n encodeResponse: async (value) => ({\n body: JSON.stringify(value),\n headers: { 'content-type': 'application/json' },\n }),\n};\n","import { ZodType } from 'zod';\nimport { APIConsumerPayload, ConsumerFn, DTO, ServerFnDefinition } from './types';\nimport { jsonCodec } from './utils';\n\nconst getEndpointWithArgsAndQuery = <\n URLParams extends ZodType,\n QueryParams extends ZodType,\n Body extends ZodType,\n _ResponseSchema extends ZodType,\n>(\n endpoint: string,\n consumerPayload: APIConsumerPayload<\n DTO<URLParams>,\n DTO<QueryParams>,\n DTO<Body>\n >,\n) => {\n let url = `${endpoint}${\n consumerPayload.query\n ? `?${new URLSearchParams(consumerPayload.query || {})}`\n : ''\n }`;\n\n if (consumerPayload && consumerPayload.urlParams) {\n Object.keys(consumerPayload.urlParams).forEach(\n (arg: keyof typeof consumerPayload.urlParams) => {\n url = url.replace(\n `{${arg as string}}`,\n consumerPayload?.urlParams![arg],\n );\n },\n );\n }\n\n return url;\n};\n\nexport type ApiClientConfig = {\n baseUrl: string;\n fetchFn?: typeof fetch;\n headersProvider?:\n | (() => Promise<Record<string, string>>)\n | (() => Record<string, string>);\n};\n\nexport const createClient = (config: ApiClientConfig) => {\n const fetchFn = config.fetchFn ?? fetch;\n const headersProvider = config.headersProvider;\n\n const call = async <\n URLParams extends ZodType,\n QueryParams extends ZodType,\n Body extends ZodType,\n ResponseSchema extends ZodType,\n >(\n apiDefinition: ServerFnDefinition<URLParams, QueryParams, Body, ResponseSchema>,\n consumerPayload: APIConsumerPayload<\n DTO<URLParams>,\n DTO<QueryParams>,\n DTO<Body>\n >,\n ): Promise<DTO<ResponseSchema>> => {\n const endpointKey = getEndpointWithArgsAndQuery(\n apiDefinition?.endpoint || apiDefinition?.path || '/',\n consumerPayload,\n );\n\n const resolvedHeaders =\n (await headersProvider?.()) ?? ({} as Record<string, string>);\n\n const url = `${config.baseUrl}${endpointKey}`;\n const response = await fetchFn(url, {\n method: apiDefinition.method || 'get',\n body:\n consumerPayload.body === undefined\n ? undefined\n : JSON.stringify(consumerPayload.body),\n headers: {\n ...resolvedHeaders,\n ...(consumerPayload.headers ?? {}),\n ...(consumerPayload.body === undefined\n ? {}\n : { 'content-type': jsonCodec.requestContentType }),\n },\n signal: consumerPayload.signal,\n });\n\n if (!response.ok) {\n const text = await response.text();\n throw new Error(text || `Request failed with status ${response.status}`);\n }\n\n const parsed = (await jsonCodec.decodeRequest(response)) as DTO<ResponseSchema>;\n return parsed;\n };\n\n return { call };\n};\n\nexport const apiConsumer =\n <\n URLParams extends ZodType,\n QueryParams extends ZodType,\n Body extends ZodType,\n ResponseSchema extends ZodType,\n >(\n apiDefinition: ServerFnDefinition<URLParams, QueryParams, Body, ResponseSchema>,\n config?: Partial<ApiClientConfig> & { baseUrl: string },\n ): ConsumerFn<URLParams, QueryParams, Body, ResponseSchema> =>\n async (\n consumerPayload: APIConsumerPayload<\n DTO<URLParams>,\n DTO<QueryParams>,\n DTO<Body>\n >,\n ) => {\n const runtimeEnv = (globalThis as any)?.process?.env;\n const fallbackBaseUrl =\n runtimeEnv?.NEXT_PUBLIC_BASE_API_URL || '';\n\n const client = createClient({\n baseUrl: config?.baseUrl ?? fallbackBaseUrl,\n fetchFn: config?.fetchFn,\n headersProvider: config?.headersProvider,\n });\n\n return client.call(apiDefinition, consumerPayload);\n };\n"],"names":["jsonCodec","request","text","value","getEndpointWithArgsAndQuery","endpoint","consumerPayload","url","arg","createClient","config","fetchFn","headersProvider","apiDefinition","endpointKey","resolvedHeaders","response","apiConsumer","_a","runtimeEnv","fallbackBaseUrl"],"mappings":"AA0HO,MAAMA,IAAsB;AAAA,EACjC,IAAI;AAAA,EACJ,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe,OAAOC,MAAY;AAEhC,QAAI,EADgBA,EAAQ,QAAQ,IAAI,cAAc,KAAK,IAC1C,SAAS,kBAAkB,GAAG;AAC7C,YAAMC,IAAO,MAAMD,EAAQ,KAAA;AAC3B,UAAI,CAACC,EAAM;AACX,UAAI;AACF,eAAO,KAAK,MAAMA,CAAI;AAAA,MACxB,QAAQ;AACN,eAAOA;AAAAA,MACT;AAAA,IACF;AACA,UAAMA,IAAO,MAAMD,EAAQ,KAAA;AAC3B,QAAKC;AACL,aAAO,KAAK,MAAMA,CAAI;AAAA,EACxB;AAAA,EACA,gBAAgB,OAAOC,OAAW;AAAA,IAChC,MAAM,KAAK,UAAUA,CAAK;AAAA,IAC1B,SAAS,EAAE,gBAAgB,mBAAA;AAAA,EAAmB;AAElD,GC7IMC,IAA8B,CAMlCC,GACAC,MAKG;AACH,MAAIC,IAAM,GAAGF,CAAQ,GACnBC,EAAgB,QACZ,IAAI,IAAI,gBAAgBA,EAAgB,SAAS,CAAA,CAAE,CAAC,KACpD,EACN;AAEA,SAAIA,KAAmBA,EAAgB,aACrC,OAAO,KAAKA,EAAgB,SAAS,EAAE;AAAA,IACrC,CAACE,MAAgD;AAC/C,MAAAD,IAAMA,EAAI;AAAA,QACR,IAAIC,CAAa;AAAA,QACjBF,KAAA,gBAAAA,EAAiB,UAAWE;AAAA,MAAG;AAAA,IAEnC;AAAA,EAAA,GAIGD;AACT,GAUaE,IAAe,CAACC,MAA4B;AACvD,QAAMC,IAAUD,EAAO,WAAW,OAC5BE,IAAkBF,EAAO;AAiD/B,SAAO,EAAE,MA/CI,OAMXG,GACAP,MAKiC;AACjC,UAAMQ,IAAcV;AAAA,OAClBS,KAAA,gBAAAA,EAAe,cAAYA,KAAA,gBAAAA,EAAe,SAAQ;AAAA,MAClDP;AAAA,IAAA,GAGIS,IACH,OAAMH,KAAA,gBAAAA,QAAyB,CAAA,GAE5BL,IAAM,GAAGG,EAAO,OAAO,GAAGI,CAAW,IACrCE,IAAW,MAAML,EAAQJ,GAAK;AAAA,MAClC,QAAQM,EAAc,UAAU;AAAA,MAChC,MACEP,EAAgB,SAAS,SACrB,SACA,KAAK,UAAUA,EAAgB,IAAI;AAAA,MACzC,SAAS;AAAA,QACP,GAAGS;AAAA,QACH,GAAIT,EAAgB,WAAW,CAAA;AAAA,QAC/B,GAAIA,EAAgB,SAAS,SACzB,CAAA,IACA,EAAE,gBAAgBN,EAAU,mBAAA;AAAA,MAAmB;AAAA,MAErD,QAAQM,EAAgB;AAAA,IAAA,CACzB;AAED,QAAI,CAACU,EAAS,IAAI;AAChB,YAAMd,IAAO,MAAMc,EAAS,KAAA;AAC5B,YAAM,IAAI,MAAMd,KAAQ,8BAA8Bc,EAAS,MAAM,EAAE;AAAA,IACzE;AAGA,WADgB,MAAMhB,EAAU,cAAcgB,CAAQ;AAAA,EAExD,EAES;AACX,GAEaC,IACX,CAMEJ,GACAH,MAEF,OACEJ,MAKG;ADOA,MAAAY;ACNH,QAAMC,KAAcD,IAAA,yCAAoB,YAApB,gBAAAA,EAA6B,KAC3CE,KACJD,KAAA,gBAAAA,EAAY,6BAA4B;AAQ1C,SANeV,EAAa;AAAA,IAC1B,UAASC,KAAA,gBAAAA,EAAQ,YAAWU;AAAA,IAC5B,SAASV,KAAA,gBAAAA,EAAQ;AAAA,IACjB,iBAAiBA,KAAA,gBAAAA,EAAQ;AAAA,EAAA,CAC1B,EAEa,KAAKG,GAAeP,CAAe;AACnD;"}
@@ -0,0 +1,3 @@
1
+ import { ZodType } from 'zod';
2
+ import { ServerFnDefinition } from './types';
3
+ export declare const createAPIDefinition: <URLParams extends ZodType, QueryParams extends ZodType, Body extends ZodType, ResponseSchema extends ZodType>(def: ServerFnDefinition<URLParams, QueryParams, Body, ResponseSchema>) => ServerFnDefinition<URLParams, QueryParams, Body, ResponseSchema>;
@@ -0,0 +1,18 @@
1
+ type ExportOpenApiConfig = {
2
+ baseDir: string;
3
+ indexPath: string;
4
+ outPath?: string;
5
+ pathPrefix?: string;
6
+ loadDefinitions?: (absolutePath: string) => unknown;
7
+ mkdirFn?: (dirPath: string) => void;
8
+ writeFileFn?: (filePath: string, contents: string) => void;
9
+ };
10
+ export declare const exportOpenApi: (config: ExportOpenApiConfig) => import('openapi3-ts/oas30').OpenAPIObject;
11
+ type RunCliConfig = {
12
+ baseDir?: string;
13
+ loadDefinitions?: (absolutePath: string) => unknown;
14
+ mkdirFn?: (dirPath: string) => void;
15
+ writeFileFn?: (filePath: string, contents: string) => void;
16
+ };
17
+ export declare const runOpenApiCli: (argv?: string[], config?: RunCliConfig) => import('openapi3-ts/oas30').OpenAPIObject;
18
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function It(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ht={exports:{}},Z=ht.exports={},D,$;function tt(){throw new Error("setTimeout has not been defined")}function nt(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?D=setTimeout:D=tt}catch{D=tt}try{typeof clearTimeout=="function"?$=clearTimeout:$=nt}catch{$=nt}})();function mt(r){if(D===setTimeout)return setTimeout(r,0);if((D===tt||!D)&&setTimeout)return D=setTimeout,setTimeout(r,0);try{return D(r,0)}catch{try{return D.call(null,r,0)}catch{return D.call(this,r,0)}}}function Et(r){if($===clearTimeout)return clearTimeout(r);if(($===nt||!$)&&clearTimeout)return $=clearTimeout,clearTimeout(r);try{return $(r)}catch{try{return $.call(null,r)}catch{return $.call(this,r)}}}var U=[],ce=!1,K,Me=-1;function Rt(){!ce||!K||(ce=!1,K.length?U=K.concat(U):Me=-1,U.length&&vt())}function vt(){if(!ce){var r=mt(Rt);ce=!0;for(var e=U.length;e;){for(K=U,U=[];++Me<e;)K&&K[Me].run();Me=-1,e=U.length}K=null,ce=!1,Et(r)}}Z.nextTick=function(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];U.push(new gt(r,e)),U.length===1&&!ce&&mt(vt)};function gt(r,e){this.fun=r,this.array=e}gt.prototype.run=function(){this.fun.apply(null,this.array)};Z.title="browser";Z.browser=!0;Z.env={};Z.argv=[];Z.version="";Z.versions={};function W(){}Z.on=W;Z.addListener=W;Z.once=W;Z.off=W;Z.removeListener=W;Z.removeAllListeners=W;Z.emit=W;Z.prependListener=W;Z.prependOnceListener=W;Z.listeners=function(r){return[]};Z.binding=function(r){throw new Error("process.binding is not supported")};Z.cwd=function(){return"/"};Z.chdir=function(r){throw new Error("process.chdir is not supported")};Z.umask=function(){return 0};var Pt=ht.exports;const $e=It(Pt);var At=null,ct=At;function M(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function ut(r,e){for(var t="",n=0,s=-1,a=0,i,o=0;o<=r.length;++o){if(o<r.length)i=r.charCodeAt(o);else{if(i===47)break;i=47}if(i===47){if(!(s===o-1||a===1))if(s!==o-1&&a===2){if(t.length<2||n!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var c=t.lastIndexOf("/");if(c!==t.length-1){c===-1?(t="",n=0):(t=t.slice(0,c),n=t.length-1-t.lastIndexOf("/")),s=o,a=0;continue}}else if(t.length===2||t.length===1){t="",n=0,s=o,a=0;continue}}e&&(t.length>0?t+="/..":t="..",n=2)}else t.length>0?t+="/"+r.slice(s+1,o):t=r.slice(s+1,o),n=o-s-1;s=o,a=0}else i===46&&a!==-1?++a:a=-1}return t}function St(r,e){var t=e.dir||e.root,n=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+n:t+r+n:n}var ue={resolve:function(){for(var e="",t=!1,n,s=arguments.length-1;s>=-1&&!t;s--){var a;s>=0?a=arguments[s]:(n===void 0&&(n=$e.cwd()),a=n),M(a),a.length!==0&&(e=a+"/"+e,t=a.charCodeAt(0)===47)}return e=ut(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(M(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;return e=ut(e,!t),e.length===0&&!t&&(e="."),e.length>0&&n&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return M(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var n=arguments[t];M(n),n.length>0&&(e===void 0?e=n:e+="/"+n)}return e===void 0?".":ue.normalize(e)},relative:function(e,t){if(M(e),M(t),e===t||(e=ue.resolve(e),t=ue.resolve(t),e===t))return"";for(var n=1;n<e.length&&e.charCodeAt(n)===47;++n);for(var s=e.length,a=s-n,i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var o=t.length,c=o-i,u=a<c?a:c,l=-1,h=0;h<=u;++h){if(h===u){if(c>u){if(t.charCodeAt(i+h)===47)return t.slice(i+h+1);if(h===0)return t.slice(i+h)}else a>u&&(e.charCodeAt(n+h)===47?l=h:h===0&&(l=0));break}var j=e.charCodeAt(n+h),k=t.charCodeAt(i+h);if(j!==k)break;j===47&&(l=h)}var C="";for(h=n+l+1;h<=s;++h)(h===s||e.charCodeAt(h)===47)&&(C.length===0?C+="..":C+="/..");return C.length>0?C+t.slice(i+l):(i+=l,t.charCodeAt(i)===47&&++i,t.slice(i))},_makeLong:function(e){return e},dirname:function(e){if(M(e),e.length===0)return".";for(var t=e.charCodeAt(0),n=t===47,s=-1,a=!0,i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!a){s=i;break}}else a=!1;return s===-1?n?"/":".":n&&s===1?"//":e.slice(0,s)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');M(e);var n=0,s=-1,a=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var o=t.length-1,c=-1;for(i=e.length-1;i>=0;--i){var u=e.charCodeAt(i);if(u===47){if(!a){n=i+1;break}}else c===-1&&(a=!1,c=i+1),o>=0&&(u===t.charCodeAt(o)?--o===-1&&(s=i):(o=-1,s=c))}return n===s?s=c:s===-1&&(s=e.length),e.slice(n,s)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!a){n=i+1;break}}else s===-1&&(a=!1,s=i+1);return s===-1?"":e.slice(n,s)}},extname:function(e){M(e);for(var t=-1,n=0,s=-1,a=!0,i=0,o=e.length-1;o>=0;--o){var c=e.charCodeAt(o);if(c===47){if(!a){n=o+1;break}continue}s===-1&&(a=!1,s=o+1),c===46?t===-1?t=o:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||s===-1||i===0||i===1&&t===s-1&&t===n+1?"":e.slice(t,s)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return St("/",e)},parse:function(e){M(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),s=n===47,a;s?(t.root="/",a=1):a=0;for(var i=-1,o=0,c=-1,u=!0,l=e.length-1,h=0;l>=a;--l){if(n=e.charCodeAt(l),n===47){if(!u){o=l+1;break}continue}c===-1&&(u=!1,c=l+1),n===46?i===-1?i=l:h!==1&&(h=1):i!==-1&&(h=-1)}return i===-1||c===-1||h===0||h===1&&i===c-1&&i===o+1?c!==-1&&(o===0&&s?t.base=t.name=e.slice(1,c):t.base=t.name=e.slice(o,c)):(o===0&&s?(t.name=e.slice(1,i),t.base=e.slice(1,c)):(t.name=e.slice(o,i),t.base=e.slice(o,c)),t.ext=e.slice(i,c)),o>0?t.dir=e.slice(0,o-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};ue.posix=ue;var ze=ue,x;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var rt;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(rt||(rt={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),F=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Nt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class A extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}A.create=r=>new A(r);const xe=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}};let yt=xe;function Mt(r){yt=r}function Le(){return yt}const Ve=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},Dt=[];function p(r,e){const t=Ve({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Le(),xe].filter(n=>!!n)});r.common.issues.push(t)}class I{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return I.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const g=Object.freeze({status:"aborted"}),_t=r=>({status:"dirty",value:r}),E=r=>({status:"valid",value:r}),st=r=>r.status==="aborted",at=r=>r.status==="dirty",we=r=>r.status==="valid",Ue=r=>typeof Promise<"u"&&r instanceof Promise;var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(m||(m={}));class L{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const dt=(r,e)=>{if(we(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new A(r.common.issues);return this._error=t,this._error}}};function y(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},description:s}}class b{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return F(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:F(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:F(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ue(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:F(e)},a=this._parseSync({data:e,path:s.path,parent:s});return dt(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:F(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Ue(s)?s:Promise.resolve(s));return dt(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new N({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return B.create(this,this._def)}nullable(){return ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return S.create(this,this._def)}promise(){return pe.create(this,this._def)}or(e){return je.create([this,e],this._def)}and(e){return Ze.create(this,e,this._def)}transform(e){return new N({...y(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Pe({...y(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new xt({typeName:v.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Fe({...y(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ae.create(this,e)}readonly(){return Je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $t=/^c[^\s-]{8,}$/i,Lt=/^[a-z][a-z0-9]*$/,Vt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ut=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Bt=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let et;const Wt=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Ft=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ht=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Jt(r,e){return!!((e==="v4"||!e)&&Wt.test(r)||(e==="v6"||!e)&&Ft.test(r))}class P extends b{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),g}const n=new I;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Bt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")et||(et=new RegExp(qt,"u")),et.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ut.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")$t.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Lt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Vt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ht(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?Jt(e.data,a.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...m.errToObj(n)})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...m.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...m.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new P({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}P.create=r=>{var e;return new P({checks:[],typeName:v.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};function Gt(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class H extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),g}let n;const s=new I;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Gt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new H({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}H.create=r=>new H({checks:[],typeName:v.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class J extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){const a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.bigint,received:a.parsedType}),g}let n;const s=new I;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new J({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}J.create=r=>{var e;return new J({checks:[],typeName:v.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...y(r)})};class ke extends b{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.boolean,received:n.parsedType}),g}return E(e.data)}}ke.create=r=>new ke({typeName:v.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...y(r)});class X extends b{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),g}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_date}),g}const n=new I;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}X.create=r=>new X({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:v.ZodDate,...y(r)});class Be extends b{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.symbol,received:n.parsedType}),g}return E(e.data)}}Be.create=r=>new Be({typeName:v.ZodSymbol,...y(r)});class Te extends b{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.undefined,received:n.parsedType}),g}return E(e.data)}}Te.create=r=>new Te({typeName:v.ZodUndefined,...y(r)});class Oe extends b{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.null,received:n.parsedType}),g}return E(e.data)}}Oe.create=r=>new Oe({typeName:v.ZodNull,...y(r)});class fe extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}}fe.create=r=>new fe({typeName:v.ZodAny,...y(r)});class Q extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}}Q.create=r=>new Q({typeName:v.ZodUnknown,...y(r)});class q extends b{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),g}}q.create=r=>new q({typeName:v.ZodNever,...y(r)});class qe extends b{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.void,received:n.parsedType}),g}return E(e.data)}}qe.create=r=>new qe({typeName:v.ZodVoid,...y(r)});class S extends b{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return p(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),g;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(p(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new L(t,i,t.path,o)))).then(i=>I.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new L(t,i,t.path,o)));return I.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new S({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new S({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new S({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}S.create=(r,e)=>new S({type:r,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...y(e)});function oe(r){if(r instanceof T){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=B.create(oe(n))}return new T({...r._def,shape:()=>e})}else return r instanceof S?new S({...r._def,type:oe(r.element)}):r instanceof B?B.create(oe(r.unwrap())):r instanceof ee?ee.create(oe(r.unwrap())):r instanceof V?V.create(r.items.map(e=>oe(e))):r}class T extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return p(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),g}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const l=a[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new L(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof q){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(p(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const h=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new L(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>I.mergeObjectSync(n,u)):I.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new T({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new T({...this._def,unknownKeys:"strip"})}passthrough(){return new T({...this._def,unknownKeys:"passthrough"})}extend(e){return new T({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new T({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new T({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new T({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new T({...this._def,shape:()=>t})}deepPartial(){return oe(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new T({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof B;)a=a._def.innerType;t[n]=a}}),new T({...this._def,shape:()=>t})}keyof(){return bt(x.objectKeys(this.shape))}}T.create=(r,e)=>new T({shape:()=>r,unknownKeys:"strip",catchall:q.create(),typeName:v.ZodObject,...y(e)});T.strictCreate=(r,e)=>new T({shape:()=>r,unknownKeys:"strict",catchall:q.create(),typeName:v.ZodObject,...y(e)});T.lazycreate=(r,e)=>new T({shape:r,unknownKeys:"strip",catchall:q.create(),typeName:v.ZodObject,...y(e)});class je extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new A(o.ctx.common.issues));return p(t,{code:d.invalid_union,unionErrors:i}),g}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const u={...t,common:{...t.common,issues:[]},parent:null},l=c._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new A(c));return p(t,{code:d.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}}je.create=(r,e)=>new je({options:r,typeName:v.ZodUnion,...y(e)});const De=r=>r instanceof Ie?De(r.schema):r instanceof N?De(r.innerType()):r instanceof Ee?[r.value]:r instanceof G?r.options:r instanceof Re?Object.keys(r.enum):r instanceof Pe?De(r._def.innerType):r instanceof Te?[void 0]:r instanceof Oe?[null]:null;class Ke extends b{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return p(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),g;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=De(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ke({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...y(n)})}}function it(r,e){const t=F(r),n=F(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){const s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=it(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=it(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ze extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(st(a)||st(i))return g;const o=it(a.value,i.value);return o.valid?((at(a)||at(i))&&t.dirty(),{status:t.value,value:o.data}):(p(n,{code:d.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ze.create=(r,e,t)=>new Ze({left:r,right:e,typeName:v.ZodIntersection,...y(t)});class V extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return p(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return p(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new L(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>I.mergeArray(t,i)):I.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new V({...this._def,rest:e})}}V.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new V({items:r,typeName:v.ZodTuple,rest:null,...y(e)})};class Ce extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return p(n,{code:d.invalid_type,expected:f.object,received:n.parsedType}),g;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new L(n,o,n.path,o)),value:i._parse(new L(n,n.data[o],n.path,o))});return n.common.async?I.mergeObjectAsync(t,s):I.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof b?new Ce({keyType:e,valueType:t,typeName:v.ZodRecord,...y(n)}):new Ce({keyType:P.create(),valueType:e,typeName:v.ZodRecord,...y(t)})}}class We extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return p(n,{code:d.invalid_type,expected:f.map,received:n.parsedType}),g;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new L(n,o,n.path,[u,"key"])),value:a._parse(new L(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return g;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return g;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),o.set(u.value,l.value)}return{status:t.value,value:o}}}}We.create=(r,e,t)=>new We({valueType:e,keyType:r,typeName:v.ZodMap,...y(t)});class z extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return p(n,{code:d.invalid_type,expected:f.set,received:n.parsedType}),g;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(p(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(p(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return g;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const o=[...n.data.values()].map((c,u)=>a._parse(new L(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new z({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(r,e)=>new z({valueType:r,minSize:null,maxSize:null,typeName:v.ZodSet,...y(e)});class de extends b{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return p(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),g;function n(o,c){return Ve({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Le(),xe].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(o,c){return Ve({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Le(),xe].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof pe){const o=this;return E(async function(...c){const u=new A([]),l=await o._def.args.parseAsync(c,a).catch(k=>{throw u.addIssue(n(c,k)),u}),h=await Reflect.apply(i,this,l);return await o._def.returns._def.type.parseAsync(h,a).catch(k=>{throw u.addIssue(s(h,k)),u})})}else{const o=this;return E(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new A([n(c,u.error)]);const l=Reflect.apply(i,this,u.data),h=o._def.returns.safeParse(l,a);if(!h.success)throw new A([s(l,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new de({...this._def,args:V.create(e).rest(Q.create())})}returns(e){return new de({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new de({args:e||V.create([]).rest(Q.create()),returns:t||Q.create(),typeName:v.ZodFunction,...y(n)})}}class Ie extends b{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ie.create=(r,e)=>new Ie({getter:r,typeName:v.ZodLazy,...y(e)});class Ee extends b{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ee.create=(r,e)=>new Ee({value:r,typeName:v.ZodLiteral,...y(e)});function bt(r,e){return new G({values:r,typeName:v.ZodEnum,...y(e)})}class G extends b{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:x.joinValues(n),received:t.parsedType,code:d.invalid_type}),g}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:d.invalid_enum_value,options:n}),g}return E(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return G.create(e)}exclude(e){return G.create(this.options.filter(t=>!e.includes(t)))}}G.create=bt;class Re extends b{_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const s=x.objectValues(t);return p(n,{expected:x.joinValues(s),received:n.parsedType,code:d.invalid_type}),g}if(t.indexOf(e.data)===-1){const s=x.objectValues(t);return p(n,{received:n.data,code:d.invalid_enum_value,options:s}),g}return E(e.data)}get enum(){return this._def.values}}Re.create=(r,e)=>new Re({values:r,typeName:v.ZodNativeEnum,...y(e)});class pe extends b{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return p(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),g;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return E(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}pe.create=(r,e)=>new pe({type:r,typeName:v.ZodPromise,...y(e)});class N extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{p(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!we(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>we(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(s)}}N.create=(r,e,t)=>new N({schema:r,typeName:v.ZodEffects,effect:e,...y(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:v.ZodEffects,...y(t)});class B extends b{_parse(e){return this._getType(e)===f.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(r,e)=>new B({innerType:r,typeName:v.ZodOptional,...y(e)});class ee extends b{_parse(e){return this._getType(e)===f.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(r,e)=>new ee({innerType:r,typeName:v.ZodNullable,...y(e)});class Pe extends b{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Pe.create=(r,e)=>new Pe({innerType:r,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class Fe extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ue(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new A(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Fe.create=(r,e)=>new Fe({innerType:r,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class He extends b{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}}He.create=r=>new He({typeName:v.ZodNaN,...y(r)});const Yt=Symbol("zod_brand");class xt extends b{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ae extends b{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),_t(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ae({in:e,out:t,typeName:v.ZodPipeline})}}class Je extends b{_parse(e){const t=this._def.innerType._parse(e);return we(t)&&(t.value=Object.freeze(t.value)),t}}Je.create=(r,e)=>new Je({innerType:r,typeName:v.ZodReadonly,...y(e)});const wt=(r,e={},t)=>r?fe.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...u,fatal:c})}}):fe.create(),Kt={object:T.lazycreate};var v;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(v||(v={}));const Qt=(r,e={message:`Input not instance of ${r.name}`})=>wt(t=>t instanceof r,e),kt=P.create,Tt=H.create,Xt=He.create,zt=J.create,Ot=ke.create,en=X.create,tn=Be.create,nn=Te.create,rn=Oe.create,sn=fe.create,an=Q.create,on=q.create,cn=qe.create,un=S.create,dn=T.create,ln=T.strictCreate,fn=je.create,pn=Ke.create,hn=Ze.create,mn=V.create,vn=Ce.create,gn=We.create,yn=z.create,_n=de.create,bn=Ie.create,xn=Ee.create,wn=G.create,kn=Re.create,Tn=pe.create,lt=N.create,On=B.create,jn=ee.create,Zn=N.createWithPreprocess,Cn=Ae.create,In=()=>kt().optional(),En=()=>Tt().optional(),Rn=()=>Ot().optional(),Pn={string:r=>P.create({...r,coerce:!0}),number:r=>H.create({...r,coerce:!0}),boolean:r=>ke.create({...r,coerce:!0}),bigint:r=>J.create({...r,coerce:!0}),date:r=>X.create({...r,coerce:!0})},An=g;var Sn=Object.freeze({__proto__:null,defaultErrorMap:xe,setErrorMap:Mt,getErrorMap:Le,makeIssue:Ve,EMPTY_PATH:Dt,addIssueToContext:p,ParseStatus:I,INVALID:g,DIRTY:_t,OK:E,isAborted:st,isDirty:at,isValid:we,isAsync:Ue,get util(){return x},get objectUtil(){return rt},ZodParsedType:f,getParsedType:F,ZodType:b,ZodString:P,ZodNumber:H,ZodBigInt:J,ZodBoolean:ke,ZodDate:X,ZodSymbol:Be,ZodUndefined:Te,ZodNull:Oe,ZodAny:fe,ZodUnknown:Q,ZodNever:q,ZodVoid:qe,ZodArray:S,ZodObject:T,ZodUnion:je,ZodDiscriminatedUnion:Ke,ZodIntersection:Ze,ZodTuple:V,ZodRecord:Ce,ZodMap:We,ZodSet:z,ZodFunction:de,ZodLazy:Ie,ZodLiteral:Ee,ZodEnum:G,ZodNativeEnum:Re,ZodPromise:pe,ZodEffects:N,ZodTransformer:N,ZodOptional:B,ZodNullable:ee,ZodDefault:Pe,ZodCatch:Fe,ZodNaN:He,BRAND:Yt,ZodBranded:xt,ZodPipeline:Ae,ZodReadonly:Je,custom:wt,Schema:b,ZodSchema:b,late:Kt,get ZodFirstPartyTypeKind(){return v},coerce:Pn,any:sn,array:un,bigint:zt,boolean:Ot,date:en,discriminatedUnion:pn,effect:lt,enum:wn,function:_n,instanceof:Qt,intersection:hn,lazy:bn,literal:xn,map:gn,nan:Xt,nativeEnum:kn,never:on,null:rn,nullable:jn,number:Tt,object:dn,oboolean:Rn,onumber:En,optional:On,ostring:In,pipeline:Cn,preprocess:Zn,promise:Tn,record:vn,set:yn,strictObject:ln,string:kt,symbol:tn,transformer:lt,tuple:mn,undefined:nn,union:fn,unknown:an,void:cn,NEVER:An,ZodIssueCode:d,quotelessJson:Nt,ZodError:A});function ye(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t}function _(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function Nn(r){return"_def"in r}function me(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...n){const s=t.apply(this,n);return s._def.openapi=this._def.openapi,s}}function Mn(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(s,a){var i,o,c,u,l,h;const j=typeof s=="string"?a:s,k=j??{},{param:C}=k,O=ye(k,["param"]),R=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof s=="string"?{refId:s}:void 0),Y=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),O),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||C?{param:Object.assign(Object.assign({},(h=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||h===void 0?void 0:h.param),C)}:void 0),he=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(R).length>0?{_internal:R}:void 0),Object.keys(Y).length>0?{metadata:Y}:void 0)}));if(_(this,"ZodObject")){const Se=this.extend;he.extend=function(...Ne){var te,ne,re,se,ae,ie;const Xe=Se.apply(this,Ne);return Xe._def.openapi={_internal:{extendedFrom:!((ne=(te=this._def.openapi)===null||te===void 0?void 0:te._internal)===null||ne===void 0)&&ne.refId?{refId:(se=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||se===void 0?void 0:se.refId,schema:this}:(ae=this._def.openapi)===null||ae===void 0?void 0:ae._internal.extendedFrom},metadata:(ie=Xe._def.openapi)===null||ie===void 0?void 0:ie.metadata},Xe}}return he},me(r,"optional"),me(r,"nullable"),me(r,"default"),me(r,"transform"),me(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,l;c._def.openapi=(l=(u=s[o])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const n=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...s){const a=n.apply(this,s);return a._def.openapi=void 0,a}}function Ge(r,e){if(r==null||e===null||e===void 0)return r===e;if(r===e||r.valueOf()===e.valueOf())return!0;if(Array.isArray(r)&&(!Array.isArray(e)||r.length!==e.length)||!(r instanceof Object)||!(e instanceof Object))return!1;const t=Object.keys(r);return Object.keys(e).every(n=>t.indexOf(n)!==-1)&&t.every(n=>Ge(r[n],e[n]))}class Dn{constructor(){this.buckets=new Map}put(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);if(!n){this.buckets.set(t,[e]);return}n.some(a=>Ge(a,e))||n.push(e)}contains(e){const t=this.hashCodeOf(e),n=this.buckets.get(t);return n?n.some(s=>Ge(s,e)):!1}values(){return[...this.buckets.values()].flat()}stats(){let e=0,t=0,n=0;for(const a of this.buckets.values())e+=1,t+=a.length,a.length>1&&(n+=1);const s=e/t;return{totalBuckets:e,collisions:n,totalValues:t,hashEffectiveness:s}}hashCodeOf(e){let t=0;if(Array.isArray(e)){for(let n=0;n<e.length;n++)t^=this.hashCodeOf(e[n])*n;return t}if(typeof e=="string"){for(let n=0;n<e.length;n++)t^=e.charCodeAt(n)*n;return t}if(typeof e=="number")return e;if(typeof e=="object")for(const[n,s]of Object.entries(e))t^=this.hashCodeOf(n)+this.hashCodeOf(s??"");return t}}function _e(r){return r==null}function be(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{t[n]=e(s)}),t}function $n(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e.some(a=>a===n)||(t[n]=s)}),t}function le(r,e){const t={};return Object.entries(r).forEach(([n,s])=>{e(s,n)||(t[n]=s)}),t}function ft(r){return r.filter(e=>!_e(e))}const ot=Ge;function Ln(r){const e=new Dn;return r.forEach(t=>e.put(t)),[...e.values()]}function jt(r){return typeof r=="string"}class Vn{constructor(e){this.parents=e,this._definitions=[]}get definitions(){var e,t;return[...(t=(e=this.parents)===null||e===void 0?void 0:e.flatMap(s=>s.definitions))!==null&&t!==void 0?t:[],...this._definitions]}register(e,t){const n=this.schemaWithRefId(e,t);return this._definitions.push({type:"schema",schema:n}),n}registerParameter(e,t){var n,s,a;const i=this.schemaWithRefId(e,t),o=(n=i._def.openapi)===null||n===void 0?void 0:n.metadata,c=i.openapi(Object.assign(Object.assign({},o),{param:Object.assign(Object.assign({},o==null?void 0:o.param),{name:(a=(s=o==null?void 0:o.param)===null||s===void 0?void 0:s.name)!==null&&a!==void 0?a:e})}));return this._definitions.push({type:"parameter",schema:c}),c}registerPath(e){this._definitions.push({type:"route",route:e})}registerWebhook(e){this._definitions.push({type:"webhook",webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:"component",componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}}class Qe{constructor(e){this.message=e}}class ve extends Qe{constructor(e,t){super(e),this.data=t}}class Ye extends Qe{constructor(e){super(`Missing parameter data, please specify \`${e.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`ZodSchema.openapi\``),this.data=e}}function ge(r,e){try{return r()}catch(t){throw t instanceof Ye?new Ye(Object.assign(Object.assign({},t.data),e)):t}}class Un extends Qe{constructor(e){super("Unknown zod object type, please specify `type` and other OpenAPI props using `ZodSchema.openapi`."),this.data=e}}class w{static getMetadata(e){var t;const n=this.unwrapChained(e),s=e._def.openapi?e._def.openapi:n._def.openapi,a=(t=e.description)!==null&&t!==void 0?t:n.description;return{_internal:s==null?void 0:s._internal,metadata:Object.assign({description:a},s==null?void 0:s.metadata)}}static getInternalMetadata(e){const t=this.unwrapChained(e),n=e._def.openapi?e._def.openapi:t._def.openapi;return n==null?void 0:n._internal}static getParamMetadata(e){var t,n;const s=this.unwrapChained(e),a=e._def.openapi?e._def.openapi:s._def.openapi,i=(t=e.description)!==null&&t!==void 0?t:s.description;return{_internal:a==null?void 0:a._internal,metadata:Object.assign(Object.assign({},a==null?void 0:a.metadata),{param:Object.assign({description:i},(n=a==null?void 0:a.metadata)===null||n===void 0?void 0:n.param)})}}static buildSchemaMetadata(e){return le($n(e,["param"]),_e)}static buildParameterMetadata(e){return le(e,_e)}static applySchemaMetadata(e,t){return le(Object.assign(Object.assign({},e),this.buildSchemaMetadata(t)),_e)}static getRefId(e){var t;return(t=this.getInternalMetadata(e))===null||t===void 0?void 0:t.refId}static unwrapChained(e){return this.unwrapUntil(e)}static getDefaultValue(e){const t=this.unwrapUntil(e,"ZodDefault");return t==null?void 0:t._def.defaultValue()}static unwrapUntil(e,t){return t&&_(e,t)?e:_(e,"ZodOptional")||_(e,"ZodNullable")||_(e,"ZodBranded")?this.unwrapUntil(e.unwrap(),t):_(e,"ZodDefault")||_(e,"ZodReadonly")?this.unwrapUntil(e._def.innerType,t):_(e,"ZodEffects")?this.unwrapUntil(e._def.schema,t):_(e,"ZodPipeline")?this.unwrapUntil(e._def.in,t):t?void 0:e}static isOptionalSchema(e){return _(e,"ZodEffects")?this.isOptionalSchema(e._def.schema):e.isOptional()}}class Bn{transform(e,t,n){var s,a;const i=e._def.type;return Object.assign(Object.assign({},t("array")),{items:n(i),minItems:(s=e._def.minLength)===null||s===void 0?void 0:s.value,maxItems:(a=e._def.maxLength)===null||a===void 0?void 0:a.value})}}class qn{transform(e){return Object.assign(Object.assign({},e("string")),{pattern:"^d+$"})}}class Wn{transform(e,t,n,s,a){const i=[...e.options.values()],o=i.map(s);return t?{oneOf:n(o,t)}:{oneOf:o,discriminator:this.mapDiscriminator(i,e.discriminator,a)}}mapDiscriminator(e,t,n){if(e.some(a=>w.getRefId(a)===void 0))return;const s={};return e.forEach(a=>{var i;const o=w.getRefId(a),c=(i=a.shape)===null||i===void 0?void 0:i[t];if(_(c,"ZodEnum")||_(c,"ZodNativeEnum")){Object.values(c.enum).filter(jt).forEach(h=>{s[h]=n(o)});return}const u=c==null?void 0:c._def.value;if(typeof u!="string")throw new Error(`Discriminator ${t} could not be found in one of the values of a discriminated union`);s[u]=n(o)}),{propertyName:t,mapping:s}}}class Fn{transform(e,t){return Object.assign(Object.assign({},t("string")),{enum:e._def.values})}}class Hn{transform(e,t,n,s){const i={allOf:this.flattenIntersectionTypes(e).map(s)};return t?{anyOf:n([i],t)}:i}flattenIntersectionTypes(e){if(!_(e,"ZodIntersection"))return[e];const t=this.flattenIntersectionTypes(e._def.left),n=this.flattenIntersectionTypes(e._def.right);return[...t,...n]}}class Jn{transform(e,t){return Object.assign(Object.assign({},t(typeof e._def.value)),{enum:[e._def.value]})}}function Gn(r){const t=Object.keys(r).filter(a=>typeof r[r[a]]!="number").map(a=>r[a]),n=t.filter(a=>typeof a=="number").length,s=n===0?"string":n===t.length?"numeric":"mixed";return{values:t,type:s}}class Yn{transform(e,t){const{type:n,values:s}=Gn(e._def.values);if(n==="mixed")throw new Qe("Enum has mixed string and number values, please specify the OpenAPI type manually");return Object.assign(Object.assign({},t(n==="numeric"?"integer":"string")),{enum:s})}}class Kn{transform(e,t,n){return Object.assign(Object.assign({},t(e.isInt?"integer":"number")),n(e._def.checks))}}class Qn{transform(e,t,n,s){var a;const i=(a=w.getInternalMetadata(e))===null||a===void 0?void 0:a.extendedFrom,o=this.requiredKeysOf(e),c=be(e._def.shape(),s);if(!i)return Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{properties:c,default:t}),o.length>0?{required:o}:{}),this.generateAdditionalProperties(e,s));const u=i.schema;s(u);const l=this.requiredKeysOf(u),h=be(u==null?void 0:u._def.shape(),s),j=Object.fromEntries(Object.entries(c).filter(([O,R])=>!ot(h[O],R))),k=o.filter(O=>!l.includes(O)),C=Object.assign(Object.assign(Object.assign(Object.assign({},n("object")),{default:t,properties:j}),k.length>0?{required:k}:{}),this.generateAdditionalProperties(e,s));return{allOf:[{$ref:`#/components/schemas/${i.refId}`},C]}}generateAdditionalProperties(e,t){const n=e._def.unknownKeys,s=e._def.catchall;return _(s,"ZodNever")?n==="strict"?{additionalProperties:!1}:{}:{additionalProperties:t(s)}}requiredKeysOf(e){return Object.entries(e._def.shape()).filter(([t,n])=>!w.isOptionalSchema(n)).map(([t,n])=>t)}}class Xn{transform(e,t,n){const s=e._def.valueType,a=e._def.keyType,i=n(s);if(_(a,"ZodEnum")||_(a,"ZodNativeEnum")){const c=Object.values(a.enum).filter(jt).reduce((u,l)=>Object.assign(Object.assign({},u),{[l]:i}),{});return Object.assign(Object.assign({},t("object")),{properties:c})}return Object.assign(Object.assign({},t("object")),{additionalProperties:i})}}class zn{transform(e,t){var n,s,a;const i=this.getZodStringCheck(e,"regex"),o=(n=this.getZodStringCheck(e,"length"))===null||n===void 0?void 0:n.value,c=Number.isFinite(e.minLength)&&(s=e.minLength)!==null&&s!==void 0?s:void 0,u=Number.isFinite(e.maxLength)&&(a=e.maxLength)!==null&&a!==void 0?a:void 0;return Object.assign(Object.assign({},t("string")),{minLength:o??c,maxLength:o??u,format:this.mapStringFormat(e),pattern:i==null?void 0:i.regex.source})}mapStringFormat(e){if(e.isUUID)return"uuid";if(e.isEmail)return"email";if(e.isURL)return"uri";if(e.isDatetime)return"date-time";if(e.isCUID)return"cuid";if(e.isCUID2)return"cuid2";if(e.isULID)return"ulid";if(e.isIP)return"ip";if(e.isEmoji)return"emoji"}getZodStringCheck(e,t){return e._def.checks.find(n=>n.kind===t)}}class er{constructor(e){this.versionSpecifics=e}transform(e,t,n){const{items:s}=e._def,a=s.map(n);return Object.assign(Object.assign({},t("array")),this.versionSpecifics.mapTupleItems(a))}}class tr{transform(e,t,n){const a=this.flattenUnionTypes(e).map(i=>{const o=this.unwrapNullable(i);return n(o)});return{anyOf:t(a)}}flattenUnionTypes(e){return _(e,"ZodUnion")?e._def.options.flatMap(n=>this.flattenUnionTypes(n)):[e]}unwrapNullable(e){return _(e,"ZodNullable")?this.unwrapNullable(e.unwrap()):e}}class nr{constructor(e){this.versionSpecifics=e,this.objectTransformer=new Qn,this.stringTransformer=new zn,this.numberTransformer=new Kn,this.bigIntTransformer=new qn,this.literalTransformer=new Jn,this.enumTransformer=new Fn,this.nativeEnumTransformer=new Yn,this.arrayTransformer=new Bn,this.unionTransformer=new tr,this.discriminatedUnionTransformer=new Wn,this.intersectionTransformer=new Hn,this.recordTransformer=new Xn,this.tupleTransformer=new er(e)}transform(e,t,n,s,a){if(_(e,"ZodNull"))return this.versionSpecifics.nullType;if(_(e,"ZodUnknown")||_(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_(e,"ZodObject"))return this.objectTransformer.transform(e,a,o=>this.versionSpecifics.mapNullableType(o,t),n);const i=this.transformSchemaWithoutDefault(e,t,n,s);return Object.assign(Object.assign({},i),{default:a})}transformSchemaWithoutDefault(e,t,n,s){if(_(e,"ZodUnknown")||_(e,"ZodAny"))return this.versionSpecifics.mapNullableType(void 0,t);if(_(e,"ZodString"))return this.stringTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(_(e,"ZodNumber"))return this.numberTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),i=>this.versionSpecifics.getNumberChecks(i));if(_(e,"ZodBigInt"))return this.bigIntTransformer.transform(i=>this.versionSpecifics.mapNullableType(i,t));if(_(e,"ZodBoolean"))return this.versionSpecifics.mapNullableType("boolean",t);if(_(e,"ZodLiteral"))return this.literalTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(_(e,"ZodEnum"))return this.enumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(_(e,"ZodNativeEnum"))return this.nativeEnumTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t));if(_(e,"ZodArray"))return this.arrayTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(_(e,"ZodTuple"))return this.tupleTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(_(e,"ZodUnion"))return this.unionTransformer.transform(e,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(_(e,"ZodDiscriminatedUnion"))return this.discriminatedUnionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n,s);if(_(e,"ZodIntersection"))return this.intersectionTransformer.transform(e,t,i=>this.versionSpecifics.mapNullableOfArray(i,t),n);if(_(e,"ZodRecord"))return this.recordTransformer.transform(e,i=>this.versionSpecifics.mapNullableType(i,t),n);if(_(e,"ZodDate"))return this.versionSpecifics.mapNullableType("string",t);const a=w.getRefId(e);throw new Un({currentSchema:e._def,schemaName:a})}}class rr{constructor(e,t){this.definitions=e,this.versionSpecifics=t,this.schemaRefs={},this.paramRefs={},this.pathRefs={},this.rawComponents=[],this.openApiTransformer=new nr(t),this.sortDefinitions()}generateDocumentData(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents(),paths:this.pathRefs}}generateComponents(){return this.definitions.forEach(e=>this.generateSingle(e)),{components:this.buildComponents()}}buildComponents(){var e,t;const n={};return this.rawComponents.forEach(({componentType:s,name:a,component:i})=>{var o;(o=n[s])!==null&&o!==void 0||(n[s]={}),n[s][a]=i}),Object.assign(Object.assign({},n),{schemas:Object.assign(Object.assign({},(e=n.schemas)!==null&&e!==void 0?e:{}),this.schemaRefs),parameters:Object.assign(Object.assign({},(t=n.parameters)!==null&&t!==void 0?t:{}),this.paramRefs)})}sortDefinitions(){const e=["schema","parameter","component","route"];this.definitions.sort((t,n)=>{if(!("type"in t))return"type"in n?-1:0;if(!("type"in n))return 1;const s=e.findIndex(i=>i===t.type),a=e.findIndex(i=>i===n.type);return s-a})}generateSingle(e){if(!("type"in e)){this.generateSchemaWithRef(e);return}switch(e.type){case"parameter":this.generateParameterDefinition(e.schema);return;case"schema":this.generateSchemaWithRef(e.schema);return;case"route":this.generateSingleRoute(e.route);return;case"component":this.rawComponents.push(e);return}}generateParameterDefinition(e){const t=w.getRefId(e),n=this.generateParameter(e);return t&&(this.paramRefs[t]=n),n}getParameterRef(e,t){var n,s,a,i,o;const c=(n=e==null?void 0:e.metadata)===null||n===void 0?void 0:n.param,u=!((s=e==null?void 0:e._internal)===null||s===void 0)&&s.refId?this.paramRefs[(a=e._internal)===null||a===void 0?void 0:a.refId]:void 0;if(!(!(!((i=e==null?void 0:e._internal)===null||i===void 0)&&i.refId)||!u)){if(c&&u.in!==c.in||t!=null&&t.in&&u.in!==t.in)throw new ve(`Conflicting location for parameter ${u.name}`,{key:"in",values:ft([u.in,t==null?void 0:t.in,c==null?void 0:c.in])});if(c&&u.name!==c.name||t!=null&&t.name&&u.name!==(t==null?void 0:t.name))throw new ve("Conflicting names for parameter",{key:"name",values:ft([u.name,t==null?void 0:t.name,c==null?void 0:c.name])});return{$ref:`#/components/parameters/${(o=e._internal)===null||o===void 0?void 0:o.refId}`}}}generateInlineParameters(e,t){var n;const s=w.getMetadata(e),a=(n=s==null?void 0:s.metadata)===null||n===void 0?void 0:n.param,i=this.getParameterRef(s,{in:t});if(i)return[i];if(_(e,"ZodObject")){const o=e._def.shape();return Object.entries(o).map(([u,l])=>{var h,j;const k=w.getMetadata(l),C=this.getParameterRef(k,{in:t,name:u});if(C)return C;const O=(h=k==null?void 0:k.metadata)===null||h===void 0?void 0:h.param;if(O!=null&&O.name&&O.name!==u)throw new ve("Conflicting names for parameter",{key:"name",values:[u,O.name]});if(O!=null&&O.in&&O.in!==t)throw new ve(`Conflicting location for parameter ${(j=O.name)!==null&&j!==void 0?j:u}`,{key:"in",values:[t,O.in]});return this.generateParameter(l.openapi({param:{name:u,in:t}}))})}if(a!=null&&a.in&&a.in!==t)throw new ve(`Conflicting location for parameter ${a.name}`,{key:"in",values:[t,a.in]});return[this.generateParameter(e.openapi({param:{in:t}}))]}generateSimpleParameter(e){var t;const n=w.getParamMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=!w.isOptionalSchema(e)&&!e.isNullable(),i=this.generateSchemaWithRef(e);return Object.assign({schema:i,required:a},s?w.buildParameterMetadata(s):{})}generateParameter(e){var t;const n=w.getMetadata(e),s=(t=n==null?void 0:n.metadata)===null||t===void 0?void 0:t.param,a=s==null?void 0:s.name,i=s==null?void 0:s.in;if(!a)throw new Ye({missingField:"name"});if(!i)throw new Ye({missingField:"in",paramName:a});const o=this.generateSimpleParameter(e);return Object.assign(Object.assign({},o),{in:i,name:a})}generateSchemaWithMetadata(e){var t;const n=w.unwrapChained(e),s=w.getMetadata(e),a=w.getDefaultValue(e),i=!((t=s==null?void 0:s.metadata)===null||t===void 0)&&t.type?{type:s==null?void 0:s.metadata.type}:this.toOpenAPISchema(n,e.isNullable(),a);return s!=null&&s.metadata?w.applySchemaMetadata(i,s.metadata):le(i,_e)}constructReferencedOpenAPISchema(e){var t;const n=w.getMetadata(e),s=w.unwrapChained(e),a=w.getDefaultValue(e),i=e.isNullable();return!((t=n==null?void 0:n.metadata)===null||t===void 0)&&t.type?this.versionSpecifics.mapNullableType(n.metadata.type,i):this.toOpenAPISchema(s,i,a)}generateSimpleSchema(e){var t;const n=w.getMetadata(e),s=w.getRefId(e);if(!s||!this.schemaRefs[s])return this.generateSchemaWithMetadata(e);const a=this.schemaRefs[s],i={$ref:this.generateSchemaRef(s)},o=le(w.buildSchemaMetadata((t=n==null?void 0:n.metadata)!==null&&t!==void 0?t:{}),(l,h)=>l===void 0||ot(l,a[h]));if(o.type)return{allOf:[i,o]};const c=le(this.constructReferencedOpenAPISchema(e),(l,h)=>l===void 0||ot(l,a[h])),u=w.applySchemaMetadata(c,o);return Object.keys(u).length>0?{allOf:[i,u]}:i}generateSchemaWithRef(e){const t=w.getRefId(e),n=this.generateSimpleSchema(e);return t&&this.schemaRefs[t]===void 0?(this.schemaRefs[t]=n,{$ref:this.generateSchemaRef(t)}):n}generateSchemaRef(e){return`#/components/schemas/${e}`}getRequestBody(e){if(!e)return;const{content:t}=e,n=ye(e,["content"]),s=this.getBodyContent(t);return Object.assign(Object.assign({},n),{content:s})}getParameters(e){if(!e)return[];const{headers:t}=e,n=this.cleanParameter(e.query),s=this.cleanParameter(e.params),a=this.cleanParameter(e.cookies),i=ge(()=>n?this.generateInlineParameters(n,"query"):[],{location:"query"}),o=ge(()=>s?this.generateInlineParameters(s,"path"):[],{location:"path"}),c=ge(()=>a?this.generateInlineParameters(a,"cookie"):[],{location:"cookie"}),u=ge(()=>{if(Array.isArray(t))return t.flatMap(h=>this.generateInlineParameters(h,"header"));const l=this.cleanParameter(t);return l?this.generateInlineParameters(l,"header"):[]},{location:"header"});return[...o,...i,...u,...c]}cleanParameter(e){if(e)return _(e,"ZodEffects")?this.cleanParameter(e._def.schema):e}generatePath(e){const{method:t,path:n,request:s,responses:a}=e,i=ye(e,["method","path","request","responses"]),o=be(a,h=>this.getResponse(h)),c=ge(()=>this.getParameters(s),{route:`${t} ${n}`}),u=this.getRequestBody(s==null?void 0:s.body);return{[t]:Object.assign(Object.assign(Object.assign(Object.assign({},i),c.length>0?{parameters:[...i.parameters||[],...c]}:{}),u?{requestBody:u}:{}),{responses:o})}}generateSingleRoute(e){const t=this.generatePath(e);return this.pathRefs[e.path]=Object.assign(Object.assign({},this.pathRefs[e.path]),t),t}getResponse(e){var{content:t,headers:n}=e,s=ye(e,["content","headers"]);const a=t?{content:this.getBodyContent(t)}:{};if(!n)return Object.assign(Object.assign({},s),a);const i=_(n,"ZodObject")?this.getResponseHeaders(n):n;return Object.assign(Object.assign(Object.assign({},s),{headers:i}),a)}getResponseHeaders(e){const t=e._def.shape();return be(t,s=>this.generateSimpleParameter(s))}getBodyContent(e){return be(e,t=>{if(!t||!Nn(t.schema))return t;const{schema:n}=t,s=ye(t,["schema"]),a=this.generateSchemaWithRef(n);return Object.assign({schema:a},s)})}toOpenAPISchema(e,t,n){return this.openApiTransformer.transform(e,t,s=>this.generateSchemaWithRef(s),s=>this.generateSchemaRef(s),n)}}class sr{get nullType(){return{nullable:!0}}mapNullableOfArray(e,t){return t?[...e,this.nullType]:e}mapNullableType(e,t){return Object.assign(Object.assign({},e?{type:e}:void 0),t?this.nullType:void 0)}mapTupleItems(e){const t=Ln(e);return{items:t.length===1?t[0]:{anyOf:t},minItems:e.length,maxItems:e.length}}getNumberChecks(e){return Object.assign({},...e.map(t=>{switch(t.kind){case"min":return t.inclusive?{minimum:Number(t.value)}:{minimum:Number(t.value),exclusiveMinimum:!0};case"max":return t.inclusive?{maximum:Number(t.value)}:{maximum:Number(t.value),exclusiveMaximum:!0};default:return{}}}))}}class ar{constructor(e){const t=new sr;this.generator=new rr(e,t)}generateDocument(e){const t=this.generator.generateDocumentData();return Object.assign(Object.assign({},e),t)}generateComponents(){return this.generator.generateComponents()}}const ir=r=>{var o,c,u,l,h,j,k,C,O,R,Y,he,Se,Ne,te,ne,re,se,ae,ie;const e=`${r.openapiPathPrefix??"/api"}`,t=`${r.endpoint??r.path??""}`,n=r.codec??or,s={method:r.method,path:`${e}${t}`,summary:((o=r.openapi)==null?void 0:o.summary)??"",request:{},responses:{}},a=(c=r.schemas)!=null&&c.response?{200:{description:((h=(l=(u=r.openapi)==null?void 0:u.responses)==null?void 0:l[200])==null?void 0:h.description)??"",content:{[n.responseContentType]:{schema:(j=r.schemas)==null?void 0:j.response}}}}:{},i=((k=r.openapi)==null?void 0:k.responses)??{};return s.responses={...a,...i},(C=r.schemas)!=null&&C.queryParams&&(s.request.query=(R=(O=r.schemas)==null?void 0:O.queryParams)==null?void 0:R.openapi("Query Params")),(Y=r.schemas)!=null&&Y.payload&&(s.request.body={description:"Body",content:{[n.requestContentType]:{schema:(he=r.schemas)==null?void 0:he.payload}},required:!0}),(Se=r.schemas)!=null&&Se.urlArgs&&(s.request.params=(te=(Ne=r.schemas)==null?void 0:Ne.urlArgs)==null?void 0:te.openapi("URL Params")),s.description=(ne=r.openapi)==null?void 0:ne.description,s.tags=(re=r.openapi)==null?void 0:re.tags,s.operationId=(se=r.openapi)==null?void 0:se.operationId,s.deprecated=(ae=r.openapi)==null?void 0:ae.deprecated,s.security=(ie=r.openapi)==null?void 0:ie.security,s},or={requestContentType:"application/json",responseContentType:"application/json"},cr=r=>require(r),Zt=r=>{const e=new Vn;Mn(Sn);const t=r.outPath||`${r.baseDir}/dist`,n=r.pathPrefix||"/api",s=r.loadDefinitions??cr,a=r.mkdirFn??(j=>ct.mkdirSync(j,{recursive:!0})),i=r.writeFileFn??((j,k)=>ct.writeFileSync(j,k,{encoding:"utf-8"})),o=ze.resolve(r.baseDir,r.indexPath),c=s(o);Object.entries(c).forEach(([j,k])=>{Object.entries(k).forEach(([C,O])=>{const R=O,Y=R.apiConfig??ir({...R,endpoint:R.endpoint??R.path,openapiPathPrefix:n});e.registerPath(Y)})});const l=new ar(e.definitions).generateDocument({info:{title:"",version:"1"},openapi:"3.0.0"}),h=ze.resolve(t,"apps/openapi");return a(h),i(ze.resolve(h,"docs.json"),JSON.stringify(l,null,2)),l},Ct=(r=$e.argv,e={})=>{if(r.length<4)throw new Error("You need to specify the index file (relative to project root) for API generation.");const t=e.baseDir??`${$e.cwd()}`,n=r[3],s=r[4]||`${t}/dist`,a=r[5]||"/api",i=Zt({baseDir:t,indexPath:n,outPath:s,pathPrefix:a,loadDefinitions:e.loadDefinitions,mkdirFn:e.mkdirFn,writeFileFn:e.writeFileFn});return console.log(JSON.stringify(i,null,2)),i},pt=$e.argv[1]||"";(pt.endsWith("open-api.cjs.js")||pt.endsWith("open-api.es.js"))&&Ct();exports.exportOpenApi=Zt;exports.runOpenApiCli=Ct;
2
+ //# sourceMappingURL=open-api.cjs.js.map