@synnaxlabs/freighter 0.9.4 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ {
2
+ "vitest.disableWorkspaceWarning": true
3
+ }
package/dist/alamos.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- import { type Instrumentation } from "@synnaxlabs/alamos";
2
- import { type Middleware } from './middleware';
1
+ import { Middleware } from './middleware';
2
+ import { Instrumentation } from '@synnaxlabs/alamos';
3
+
3
4
  export declare const middleware: (instrumentation: Instrumentation) => Middleware;
5
+ //# sourceMappingURL=alamos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alamos.d.ts","sourceRoot":"","sources":["../src/alamos.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE5D,eAAO,MAAM,UAAU,oBACH,eAAe,KAAG,UAcnC,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { URL } from "@synnaxlabs/x";
2
- import { z } from "zod";
1
+ import { z } from 'zod';
2
+ import { URL } from '@synnaxlabs/x';
3
+
3
4
  export interface TypedError extends Error {
4
5
  discriminator: "FreighterError";
5
6
  /**
@@ -9,7 +10,7 @@ export interface TypedError extends Error {
9
10
  type: string;
10
11
  }
11
12
  export declare class BaseTypedError extends Error implements TypedError {
12
- discriminator: "FreighterError";
13
+ readonly discriminator = "FreighterError";
13
14
  type: string;
14
15
  constructor(message: string, type: string);
15
16
  }
@@ -64,10 +65,12 @@ export declare class UnknownError extends BaseTypedError implements TypedError {
64
65
  }
65
66
  /** Thrown/returned when a stream closed normally. */
66
67
  export declare class EOF extends BaseTypedError implements TypedError {
68
+ static readonly TYPE: string;
67
69
  constructor();
68
70
  }
69
71
  /** Thrown/returned when a stream is closed abnormally. */
70
72
  export declare class StreamClosed extends BaseTypedError implements TypedError {
73
+ static readonly TYPE: string;
71
74
  constructor();
72
75
  }
73
76
  export interface UnreachableArgs {
@@ -76,7 +79,9 @@ export interface UnreachableArgs {
76
79
  }
77
80
  /** Thrown when a target is unreachable. */
78
81
  export declare class Unreachable extends BaseTypedError implements TypedError {
82
+ static readonly TYPE: string;
79
83
  url: URL;
80
84
  constructor(args?: UnreachableArgs);
81
85
  }
82
86
  export {};
87
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,aAAa,EAAE,gBAAgB,CAAC;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,cAAe,SAAQ,KAAM,YAAW,UAAU;IAC7D,QAAQ,CAAC,aAAa,oBAAoB;IAC1C,IAAI,EAAE,MAAM,CAAC;gBAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAI1C;AAED,KAAK,YAAY,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,KAAK,GAAG,IAAI,CAAC;AAC5D,KAAK,YAAY,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,YAAY,GAAG,IAAI,CAAC;AAE/D,eAAO,MAAM,YAAY,UAAW,OAAO,wBAS1C,CAAC;AAEF,eAAO,MAAM,eAAe,YAAa,MAAM,UAAU,KAAK,GAAG,IAAI,KAAG,CAUvE,CAAC;AAEF,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,IAAI,QAAQ,CAAC;AAC1B,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,eAAO,MAAM,MAAM;;;;;;;;;EAAmD,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAsClD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,wBAGvB;IACD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB,KAAG,IAA6C,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,YAE5C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,YAAa,YAAY,KAAG,KAAK,GAAG,IAE3D,CAAC;AAEF,qBAAa,YAAa,SAAQ,cAAe,YAAW,UAAU;gBACxD,OAAO,EAAE,MAAM;CAG5B;AAID,qDAAqD;AACrD,qBAAa,GAAI,SAAQ,cAAe,YAAW,UAAU;IAC3D,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAgC;;CAKrD;AAED,0DAA0D;AAC1D,qBAAa,YAAa,SAAQ,cAAe,YAAW,UAAU;IACpE,MAAM,CAAC,QAAQ,CAAC,IAAI,SAA0C;;CAK/D;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED,2CAA2C;AAC3C,qBAAa,WAAY,SAAQ,cAAe,YAAW,UAAU;IACnE,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAwC;IAC5D,GAAG,EAAE,GAAG,CAAC;gBAEG,IAAI,GAAE,eAAoB;CAKvC"}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=errors.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.spec.d.ts","sourceRoot":"","sources":["../src/errors.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +1 @@
1
- "use strict";var is=Object.defineProperty;var os=(r,e,t)=>e in r?is(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var L=(r,e,t)=>(os(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var us=Object.defineProperty,cs=(r,e,t)=>e in r?us(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>(cs(r,typeof e!="symbol"?e+"":e,t),t),j;(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})(j||(j={}));var Tr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Tr||(Tr={}));const y=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ze=r=>{switch(typeof r){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(r)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(r)?y.array:r===null?y.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?y.promise:typeof Map<"u"&&r instanceof Map?y.map:typeof Set<"u"&&r instanceof Set?y.set:typeof Date<"u"&&r instanceof Date?y.date:y.object;default:return y.unknown}},h=j.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"]),ds=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class re 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,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.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()}}re.create=r=>new re(r);const tt=(r,e)=>{let t;switch(r.code){case h.invalid_type:r.received===y.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,j.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(r.options)}, received '${r.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.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}"`:j.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case h.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 h.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 h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(r)}return{message:t}};let dn=tt;function ls(r){dn=r}function Bt(){return dn}const Kt=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},hs=[];function g(r,e){const t=Kt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Bt(),tt].filter(n=>!!n)});r.common.issues.push(t)}class W{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 S;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 W.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 S;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 S=Object.freeze({status:"aborted"}),ln=r=>({status:"dirty",value:r}),H=r=>({status:"valid",value:r}),Or=r=>r.status==="aborted",Sr=r=>r.status==="dirty",rt=r=>r.status==="valid",Wt=r=>typeof Promise<"u"&&r instanceof Promise;var b;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));class de{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 Jr=(r,e)=>{if(rt(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 re(r.common.issues);return this._error=t,this._error}}};function N(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:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class C{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 Ze(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new W,ctx:{common:e.parent.common,data:e.data,parsedType:Ze(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wt(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:Ze(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Jr(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:Ze(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Wt(s)?s:Promise.resolve(s));return Jr(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:h.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!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 ie({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Te.create(this,this._def)}nullable(){return Le.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ne.create(this,this._def)}promise(){return Je.create(this,this._def)}or(e){return it.create([this,e],this._def)}and(e){return ot.create(this,e,this._def)}transform(e){return new ie({...N(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ht({...N(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new fn({typeName:x.ZodBranded,type:this,...N(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Gt({...N(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return Jt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fs=/^c[^\s-]{8,}$/i,ps=/^[a-z][a-z0-9]*$/,ms=/^[0-9A-HJKMNP-TV-Z]{26}$/,ys=/^[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,vs=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let gr;const _s=/^(((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}))$/,bs=/^(([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})))$/,ws=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 xs(r,e){return!!((e==="v4"||!e)&&_s.test(r)||(e==="v6"||!e)&&bs.test(r))}class ee extends C{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.string,received:s.parsedType}),S}const t=new W;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?g(n,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&g(n,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")vs.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"email",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")gr||(gr=new RegExp(gs,"u")),gr.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"emoji",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")ys.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"uuid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")fs.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"cuid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")ps.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"cuid2",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")ms.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"ulid",code:h.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),g(n,{validation:"url",code:h.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"regex",code:h.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ws(s).test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:h.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?xs(e.data,s.version)||(n=this._getOrReturnCtx(e,n),g(n,{validation:"ip",code:h.invalid_string,message:s.message}),t.dirty()):j.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...b.errToObj(n)})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.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,...b.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...b.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...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}}ee.create=r=>{var e;return new ee({checks:[],typeName:x.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...N(r)})};function ks(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 Ce extends C{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)!==y.number){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.number,received:s.parsedType}),S}let t;const n=new W;for(const s of this._def.checks)s.kind==="int"?j.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?ks(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_finite,message:s.message}),n.dirty()):j.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,n,s){return new Ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:b.toString(s)}]})}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.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"&&j.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)}}Ce.create=r=>new Ce({checks:[],typeName:x.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...N(r)});class Ee extends C{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)!==y.bigint){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.bigint,received:s.parsedType}),S}let t;const n=new W;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):j.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,b.toString(t))}gt(e,t){return this.setLimit("min",e,!1,b.toString(t))}lte(e,t){return this.setLimit("max",e,!0,b.toString(t))}lt(e,t){return this.setLimit("max",e,!1,b.toString(t))}setLimit(e,t,n,s){return new Ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:b.toString(s)}]})}_addCheck(e){return new Ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:b.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}}Ee.create=r=>{var e;return new Ee({checks:[],typeName:x.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...N(r)})};class nt extends C{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.boolean,received:t.parsedType}),S}return H(e.data)}}nt.create=r=>new nt({typeName:x.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...N(r)});class $e extends C{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_type,expected:y.date,received:s.parsedType}),S}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return g(s,{code:h.invalid_date}),S}const t=new W;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):j.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $e({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:b.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}}$e.create=r=>new $e({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:x.ZodDate,...N(r)});class Yt extends C{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.symbol,received:t.parsedType}),S}return H(e.data)}}Yt.create=r=>new Yt({typeName:x.ZodSymbol,...N(r)});class st extends C{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.undefined,received:t.parsedType}),S}return H(e.data)}}st.create=r=>new st({typeName:x.ZodUndefined,...N(r)});class at extends C{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.null,received:t.parsedType}),S}return H(e.data)}}at.create=r=>new at({typeName:x.ZodNull,...N(r)});class He extends C{constructor(){super(...arguments),this._any=!0}_parse(e){return H(e.data)}}He.create=r=>new He({typeName:x.ZodAny,...N(r)});class Pe extends C{constructor(){super(...arguments),this._unknown=!0}_parse(e){return H(e.data)}}Pe.create=r=>new Pe({typeName:x.ZodUnknown,...N(r)});class Se extends C{_parse(e){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.never,received:t.parsedType}),S}}Se.create=r=>new Se({typeName:x.ZodNever,...N(r)});class qt extends C{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.void,received:t.parsedType}),S}return H(e.data)}}qt.create=r=>new qt({typeName:x.ZodVoid,...N(r)});class ne extends C{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==y.array)return g(t,{code:h.invalid_type,expected:y.array,received:t.parsedType}),S;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(g(t,{code:i?h.too_big:h.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&&(g(t,{code:h.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&&(g(t,{code:h.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 de(t,i,t.path,o)))).then(i=>W.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new de(t,i,t.path,o)));return W.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ne({...this._def,minLength:{value:e,message:b.toString(t)}})}max(e,t){return new ne({...this._def,maxLength:{value:e,message:b.toString(t)}})}length(e,t){return new ne({...this._def,exactLength:{value:e,message:b.toString(t)}})}nonempty(e){return this.min(1,e)}}ne.create=(r,e)=>new ne({type:r,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...N(e)});function Ye(r){if(r instanceof $){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Te.create(Ye(n))}return new $({...r._def,shape:()=>e})}else return r instanceof ne?new ne({...r._def,type:Ye(r.element)}):r instanceof Te?Te.create(Ye(r.unwrap())):r instanceof Le?Le.create(Ye(r.unwrap())):r instanceof le?le.create(r.items.map(e=>Ye(e))):r}class $ extends C{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=j.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==y.object){const u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:y.object,received:u.parsedType}),S}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Se&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const c=s[u],m=n.data[u];o.push({key:{status:"valid",value:u},value:c._parse(new de(n,m,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Se){const u=this._def.unknownKeys;if(u==="passthrough")for(const c of i)o.push({key:{status:"valid",value:c},value:{status:"valid",value:n.data[c]}});else if(u==="strict")i.length>0&&(g(n,{code:h.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const c of i){const m=n.data[c];o.push({key:{status:"valid",value:c},value:u._parse(new de(n,m,n.path,c)),alwaysSet:c in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const c of o){const m=await c.key;u.push({key:m,value:await c.value,alwaysSet:c.alwaysSet})}return u}).then(u=>W.mergeObjectSync(t,u)):W.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new $({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(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=b.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new $({...this._def,unknownKeys:"strip"})}passthrough(){return new $({...this._def,unknownKeys:"passthrough"})}extend(e){return new $({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new $({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new $({...this._def,catchall:e})}pick(e){const t={};return j.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new $({...this._def,shape:()=>t})}omit(e){const t={};return j.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new $({...this._def,shape:()=>t})}deepPartial(){return Ye(this)}partial(e){const t={};return j.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new $({...this._def,shape:()=>t})}required(e){const t={};return j.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Te;)s=s._def.innerType;t[n]=s}}),new $({...this._def,shape:()=>t})}keyof(){return hn(j.objectKeys(this.shape))}}$.create=(r,e)=>new $({shape:()=>r,unknownKeys:"strip",catchall:Se.create(),typeName:x.ZodObject,...N(e)});$.strictCreate=(r,e)=>new $({shape:()=>r,unknownKeys:"strict",catchall:Se.create(),typeName:x.ZodObject,...N(e)});$.lazycreate=(r,e)=>new $({shape:r,unknownKeys:"strip",catchall:Se.create(),typeName:x.ZodObject,...N(e)});class it extends C{_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 re(o.ctx.common.issues));return g(t,{code:h.invalid_union,unionErrors:i}),S}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 u of n){const c={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:c});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new re(u));return g(t,{code:h.invalid_union,unionErrors:o}),S}}get options(){return this._def.options}}it.create=(r,e)=>new it({options:r,typeName:x.ZodUnion,...N(e)});const At=r=>r instanceof ct?At(r.schema):r instanceof ie?At(r.innerType()):r instanceof dt?[r.value]:r instanceof Ae?r.options:r instanceof lt?Object.keys(r.enum):r instanceof ht?At(r._def.innerType):r instanceof st?[void 0]:r instanceof at?[null]:null;class dr extends C{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return g(t,{code:h.invalid_type,expected:y.object,received:t.parsedType}),S;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}):(g(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}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=At(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 dr({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...N(n)})}}function Nr(r,e){const t=Ze(r),n=Ze(e);if(r===e)return{valid:!0,data:r};if(t===y.object&&n===y.object){const s=j.objectKeys(e),a=j.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Nr(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===y.array&&n===y.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],u=Nr(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===y.date&&n===y.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ot extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Or(a)||Or(i))return S;const o=Nr(a.value,i.value);return o.valid?((Sr(a)||Sr(i))&&t.dirty(),{status:t.value,value:o.data}):(g(n,{code:h.invalid_intersection_types}),S)};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}))}}ot.create=(r,e,t)=>new ot({left:r,right:e,typeName:x.ZodIntersection,...N(t)});class le extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return g(n,{code:h.invalid_type,expected:y.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return g(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new de(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>W.mergeArray(t,a)):W.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new le({...this._def,rest:e})}}le.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new le({items:r,typeName:x.ZodTuple,rest:null,...N(e)})};class ut extends C{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!==y.object)return g(n,{code:h.invalid_type,expected:y.object,received:n.parsedType}),S;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new de(n,o,n.path,o)),value:i._parse(new de(n,n.data[o],n.path,o))});return n.common.async?W.mergeObjectAsync(t,s):W.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof C?new ut({keyType:e,valueType:t,typeName:x.ZodRecord,...N(n)}):new ut({keyType:ee.create(),valueType:e,typeName:x.ZodRecord,...N(t)})}}class Ft extends C{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!==y.map)return g(n,{code:h.invalid_type,expected:y.map,received:n.parsedType}),S;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:s._parse(new de(n,o,n.path,[c,"key"])),value:a._parse(new de(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,m=await u.value;if(c.status==="aborted"||m.status==="aborted")return S;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,m=u.value;if(c.status==="aborted"||m.status==="aborted")return S;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}}}}Ft.create=(r,e,t)=>new Ft({valueType:e,keyType:r,typeName:x.ZodMap,...N(t)});class De extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return g(n,{code:h.invalid_type,expected:y.set,received:n.parsedType}),S;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(g(n,{code:h.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&&(g(n,{code:h.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(u){const c=new Set;for(const m of u){if(m.status==="aborted")return S;m.status==="dirty"&&t.dirty(),c.add(m.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>a._parse(new de(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new De({...this._def,minSize:{value:e,message:b.toString(t)}})}max(e,t){return new De({...this._def,maxSize:{value:e,message:b.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}De.create=(r,e)=>new De({valueType:r,minSize:null,maxSize:null,typeName:x.ZodSet,...N(e)});class Fe extends C{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return g(t,{code:h.invalid_type,expected:y.function,received:t.parsedType}),S;function n(o,u){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),tt].filter(c=>!!c),issueData:{code:h.invalid_arguments,argumentsError:u}})}function s(o,u){return Kt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),tt].filter(c=>!!c),issueData:{code:h.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Je){const o=this;return H(async function(...u){const c=new re([]),m=await o._def.args.parseAsync(u,a).catch(B=>{throw c.addIssue(n(u,B)),c}),I=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(I,a).catch(B=>{throw c.addIssue(s(I,B)),c})})}else{const o=this;return H(function(...u){const c=o._def.args.safeParse(u,a);if(!c.success)throw new re([n(u,c.error)]);const m=Reflect.apply(i,this,c.data),I=o._def.returns.safeParse(m,a);if(!I.success)throw new re([s(m,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Fe({...this._def,args:le.create(e).rest(Pe.create())})}returns(e){return new Fe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Fe({args:e||le.create([]).rest(Pe.create()),returns:t||Pe.create(),typeName:x.ZodFunction,...N(n)})}}class ct extends C{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})}}ct.create=(r,e)=>new ct({getter:r,typeName:x.ZodLazy,...N(e)});class dt extends C{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(r,e)=>new dt({value:r,typeName:x.ZodLiteral,...N(e)});function hn(r,e){return new Ae({values:r,typeName:x.ZodEnum,...N(e)})}class Ae extends C{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{expected:j.joinValues(n),received:t.parsedType,code:h.invalid_type}),S}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{received:t.data,code:h.invalid_enum_value,options:n}),S}return H(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 Ae.create(e)}exclude(e){return Ae.create(this.options.filter(t=>!e.includes(t)))}}Ae.create=hn;class lt extends C{_parse(e){const t=j.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){const s=j.objectValues(t);return g(n,{expected:j.joinValues(s),received:n.parsedType,code:h.invalid_type}),S}if(t.indexOf(e.data)===-1){const s=j.objectValues(t);return g(n,{received:n.data,code:h.invalid_enum_value,options:s}),S}return H(e.data)}get enum(){return this._def.values}}lt.create=(r,e)=>new lt({values:r,typeName:x.ZodNativeEnum,...N(e)});class Je extends C{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return g(t,{code:h.invalid_type,expected:y.promise,received:t.parsedType}),S;const n=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return H(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Je.create=(r,e)=>new Je({type:r,typeName:x.ZodPromise,...N(e)});class ie extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.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=>{g(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 u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u 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"?S:(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"?S:(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(!rt(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=>rt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);j.assertNever(s)}}ie.create=(r,e,t)=>new ie({schema:r,typeName:x.ZodEffects,effect:e,...N(t)});ie.createWithPreprocess=(r,e,t)=>new ie({schema:e,effect:{type:"preprocess",transform:r},typeName:x.ZodEffects,...N(t)});class Te extends C{_parse(e){return this._getType(e)===y.undefined?H(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(r,e)=>new Te({innerType:r,typeName:x.ZodOptional,...N(e)});class Le extends C{_parse(e){return this._getType(e)===y.null?H(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Le.create=(r,e)=>new Le({innerType:r,typeName:x.ZodNullable,...N(e)});class ht extends C{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ht.create=(r,e)=>new ht({innerType:r,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...N(e)});class Gt extends C{_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 Wt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new re(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Gt.create=(r,e)=>new Gt({innerType:r,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...N(e)});class Ht extends C{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return g(t,{code:h.invalid_type,expected:y.nan,received:t.parsedType}),S}return{status:"valid",value:e.data}}}Ht.create=r=>new Ht({typeName:x.ZodNaN,...N(r)});const Ts=Symbol("zod_brand");class fn extends C{_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 Nt extends C{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S:s.status==="dirty"?(t.dirty(),ln(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?S: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 Nt({in:e,out:t,typeName:x.ZodPipeline})}}class Jt extends C{_parse(e){const t=this._def.innerType._parse(e);return rt(t)&&(t.value=Object.freeze(t.value)),t}}Jt.create=(r,e)=>new Jt({innerType:r,typeName:x.ZodReadonly,...N(e)});const pn=(r,e={},t)=>r?He.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:u})}}):He.create(),Os={object:$.lazycreate};var x;(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"})(x||(x={}));const Ss=(r,e={message:`Input not instance of ${r.name}`})=>pn(t=>t instanceof r,e),mn=ee.create,yn=Ce.create,Ns=Ht.create,Zs=Ee.create,vn=nt.create,Is=$e.create,Cs=Yt.create,Es=st.create,As=at.create,js=He.create,Rs=Pe.create,Ms=Se.create,Ps=qt.create,Us=ne.create,$s=$.create,Ds=$.strictCreate,Ls=it.create,zs=dr.create,Vs=ot.create,Bs=le.create,Ks=ut.create,Ws=Ft.create,Ys=De.create,qs=Fe.create,Fs=ct.create,Gs=dt.create,Hs=Ae.create,Js=lt.create,Xs=Je.create,Xr=ie.create,Qs=Te.create,ea=Le.create,ta=ie.createWithPreprocess,ra=Nt.create,na=()=>mn().optional(),sa=()=>yn().optional(),aa=()=>vn().optional(),ia={string:r=>ee.create({...r,coerce:!0}),number:r=>Ce.create({...r,coerce:!0}),boolean:r=>nt.create({...r,coerce:!0}),bigint:r=>Ee.create({...r,coerce:!0}),date:r=>$e.create({...r,coerce:!0})},oa=S;var d=Object.freeze({__proto__:null,defaultErrorMap:tt,setErrorMap:ls,getErrorMap:Bt,makeIssue:Kt,EMPTY_PATH:hs,addIssueToContext:g,ParseStatus:W,INVALID:S,DIRTY:ln,OK:H,isAborted:Or,isDirty:Sr,isValid:rt,isAsync:Wt,get util(){return j},get objectUtil(){return Tr},ZodParsedType:y,getParsedType:Ze,ZodType:C,ZodString:ee,ZodNumber:Ce,ZodBigInt:Ee,ZodBoolean:nt,ZodDate:$e,ZodSymbol:Yt,ZodUndefined:st,ZodNull:at,ZodAny:He,ZodUnknown:Pe,ZodNever:Se,ZodVoid:qt,ZodArray:ne,ZodObject:$,ZodUnion:it,ZodDiscriminatedUnion:dr,ZodIntersection:ot,ZodTuple:le,ZodRecord:ut,ZodMap:Ft,ZodSet:De,ZodFunction:Fe,ZodLazy:ct,ZodLiteral:dt,ZodEnum:Ae,ZodNativeEnum:lt,ZodPromise:Je,ZodEffects:ie,ZodTransformer:ie,ZodOptional:Te,ZodNullable:Le,ZodDefault:ht,ZodCatch:Gt,ZodNaN:Ht,BRAND:Ts,ZodBranded:fn,ZodPipeline:Nt,ZodReadonly:Jt,custom:pn,Schema:C,ZodSchema:C,late:Os,get ZodFirstPartyTypeKind(){return x},coerce:ia,any:js,array:Us,bigint:Zs,boolean:vn,date:Is,discriminatedUnion:zs,effect:Xr,enum:Hs,function:qs,instanceof:Ss,intersection:Vs,lazy:Fs,literal:Gs,map:Ws,nan:Ns,nativeEnum:Js,never:Ms,null:As,nullable:ea,number:yn,object:$s,oboolean:aa,onumber:sa,optional:Qs,ostring:na,pipeline:ra,preprocess:ta,promise:Xs,record:Ks,set:Ys,strictObject:Ds,string:mn,symbol:Cs,transformer:Xr,tuple:Bs,undefined:Es,union:Ls,unknown:Rs,void:Ps,NEVER:oa,ZodIssueCode:h,quotelessJson:ds,ZodError:re});const Mr=d.tuple([d.number(),d.number()]),gn=d.object({width:d.number(),height:d.number()}),ua=d.object({signedWidth:d.number(),signedHeight:d.number()}),ca=["width","height"];d.enum(ca);const da=["start","center","end"],la=["signedWidth","signedHeight"];d.enum(la);const Xt=d.object({x:d.number(),y:d.number()}),ha=d.object({clientX:d.number(),clientY:d.number()}),fa=["x","y"],_n=d.enum(fa),bn=["top","right","bottom","left"];d.enum(bn);const pa=["left","right"],wn=d.enum(pa),ma=["top","bottom"],xn=d.enum(ma),kn=["center"],Qr=d.enum(kn),ya=[...bn,...kn],Tn=d.enum(ya);d.enum(da);const va=["first","last"];d.enum(va);const ga=d.object({lower:d.number(),upper:d.number()});d.union([ga,Mr]);d.union([_n,Tn]);d.union([_n,Tn,d.instanceof(String)]);const _r=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),_a(t)},_a=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},A={},lr={};Object.defineProperty(lr,"__esModule",{value:!0});function ba(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}lr.default=ba;var hr={};Object.defineProperty(hr,"__esModule",{value:!0});function wa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}hr.default=wa;var fr={};Object.defineProperty(fr,"__esModule",{value:!0});function xa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}fr.default=xa;var Pr={};Object.defineProperty(Pr,"__esModule",{value:!0});function ka(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Pr.default=ka;var Ur={};Object.defineProperty(Ur,"__esModule",{value:!0});function Ta(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Ur.default=Ta;var $r={};Object.defineProperty($r,"__esModule",{value:!0});function Oa(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}$r.default=Oa;var Dr={};Object.defineProperty(Dr,"__esModule",{value:!0});function Sa(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Dr.default=Sa;var Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});function Na(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Lr.default=Na;var pr={};Object.defineProperty(pr,"__esModule",{value:!0});function Za(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}pr.default=Za;var zr={},Ke={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Ke);var Ia=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(zr,"__esModule",{value:!0});var ye=Ke;function jt(r,e){if(e===void 0&&(e=ye.DefaultOption),!ye.isValidObject(r))return null;e=ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(ye.isValidObject(s)?ye.belongToTypes(s,e.keepTypesOnRecursion)||(s=jt(s,e)):e.recursiveInArray&&ye.isArrayObject(s)&&(s=Ia(s).map(function(i){var o=i;if(ye.isValidObject(i))ye.belongToTypes(o,e.keepTypesOnRecursion)||(o=jt(i,e));else if(ye.isArrayObject(i)){var u=jt({key:i},e);o=u.key}return o}))),t[a]=s}),t}zr.default=jt;var Vr={},Ca=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Vr,"__esModule",{value:!0});var ve=Ke;function Rt(r,e){if(e===void 0&&(e=ve.DefaultOption),!ve.isValidObject(r))return null;e=ve.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(ve.isValidObject(s)?ve.belongToTypes(s,e.keepTypesOnRecursion)||(s=Rt(s,e)):e.recursiveInArray&&ve.isArrayObject(s)&&(s=Ca(s).map(function(i){var o=i;if(ve.isValidObject(i))ve.belongToTypes(o,e.keepTypesOnRecursion)||(o=Rt(i,e));else if(ve.isArrayObject(i)){var u=Rt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Vr.default=Rt;var Br={},Ea=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Br,"__esModule",{value:!0});var ge=Ke,Aa=lr;function Mt(r,e){if(e===void 0&&(e=ge.DefaultOption),!ge.isValidObject(r))return null;e=ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Aa.default(n);e.recursive&&(ge.isValidObject(s)?ge.belongToTypes(s,e.keepTypesOnRecursion)||(s=Mt(s,e)):e.recursiveInArray&&ge.isArrayObject(s)&&(s=Ea(s).map(function(i){var o=i;if(ge.isValidObject(i))ge.belongToTypes(o,e.keepTypesOnRecursion)||(o=Mt(i,e));else if(ge.isArrayObject(i)){var u=Mt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Br.default=Mt;var Kr={},ja=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Kr,"__esModule",{value:!0});var _e=Ke,Ra=hr;function Pt(r,e){if(e===void 0&&(e=_e.DefaultOption),!_e.isValidObject(r))return null;e=_e.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Ra.default(n);e.recursive&&(_e.isValidObject(s)?_e.belongToTypes(s,e.keepTypesOnRecursion)||(s=Pt(s,e)):e.recursiveInArray&&_e.isArrayObject(s)&&(s=ja(s).map(function(i){var o=i;if(_e.isValidObject(i))_e.belongToTypes(o,e.keepTypesOnRecursion)||(o=Pt(i,e));else if(_e.isArrayObject(i)){var u=Pt({key:i},e);o=u.key}return o}))),t[a]=s}),t}Kr.default=Pt;var Wr={},Ma=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Wr,"__esModule",{value:!0});var be=Ke,Pa=fr;function Ut(r,e){if(e===void 0&&(e=be.DefaultOption),!be.isValidObject(r))return null;e=be.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Pa.default(n);e.recursive&&(be.isValidObject(s)?be.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ut(s,e)):e.recursiveInArray&&be.isArrayObject(s)&&(s=Ma(s).map(function(i){var o=i;if(be.isValidObject(i))be.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ut(i,e));else if(be.isArrayObject(i)){var u=Ut({key:i},e);o=u.key}return o}))),t[a]=s}),t}Wr.default=Ut;var Yr={},Ua=Q&&Q.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(Yr,"__esModule",{value:!0});var we=Ke,$a=pr;function $t(r,e){if(e===void 0&&(e=we.DefaultOption),!we.isValidObject(r))return null;e=we.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=$a.default(n);e.recursive&&(we.isValidObject(s)?we.belongToTypes(s,e.keepTypesOnRecursion)||(s=$t(s,e)):e.recursiveInArray&&we.isArrayObject(s)&&(s=Ua(s).map(function(i){var o=i;if(we.isValidObject(i))we.belongToTypes(o,e.keepTypesOnRecursion)||(o=$t(i,e));else if(we.isArrayObject(i)){var u=$t({key:i},e);o=u.key}return o}))),t[a]=s}),t}Yr.default=$t;Object.defineProperty(A,"__esModule",{value:!0});A.kebabKeys=A.pascalKeys=A.snakeKeys=A.camelKeys=A.upperKeys=A.lowerKeys=A.toLowerCase=A.toUpperCase=A.toKebabCase=A.toHeaderCase=A.toSentenceCase=A.toTextCase=A.toPathCase=A.toDotCase=A.toPascalCase=A.toSnakeCase=A.toCamelCase=void 0;var On=lr;A.toCamelCase=On.default;var Sn=hr;A.toSnakeCase=Sn.default;var Nn=fr;A.toPascalCase=Nn.default;var Zn=Pr;A.toDotCase=Zn.default;var In=Ur;A.toPathCase=In.default;var Cn=$r;A.toTextCase=Cn.default;var En=Dr;A.toSentenceCase=En.default;var An=Lr;A.toHeaderCase=An.default;var jn=pr;A.toKebabCase=jn.default;var Rn=zr;A.lowerKeys=Rn.default;var Mn=Vr;A.upperKeys=Mn.default;var Pn=Br;A.camelKeys=Pn.default;var Un=Kr;A.snakeKeys=Un.default;var $n=Wr;A.pascalKeys=$n.default;var Dn=Yr;A.kebabKeys=Dn.default;var Ln=function(r){return String(r||"").toLowerCase()};A.toLowerCase=Ln;var zn=function(r){return String(r||"").toUpperCase()};A.toUpperCase=zn;var Da={toCamelCase:On.default,toSnakeCase:Sn.default,toPascalCase:Nn.default,toDotCase:Zn.default,toPathCase:In.default,toTextCase:Cn.default,toSentenceCase:En.default,toHeaderCase:An.default,toKebabCase:jn.default,toUpperCase:zn,toLowerCase:Ln,lowerKeys:Rn.default,upperKeys:Mn.default,camelKeys:Pn.default,snakeKeys:Un.default,pascalKeys:$n.default,kebabKeys:Dn.default};A.default=Da;var Vn=A;const Bn={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},La=r=>Vn.snakeKeys(r,Bn),za=r=>Vn.camelKeys(r,Bn);var Qt;(r=>{r.toSnake=La,r.toCamel=za,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Qt||(Qt={}));d.object({x:wn.or(Qr),y:xn.or(Qr)});const Va=d.object({x:wn,y:xn}),Ba=Object.freeze({x:"left",y:"top"}),Ka=(r,e)=>r.x===e.x&&r.y===e.y,en=d.union([d.number(),Xt,Mr,gn,ua,ha]),Wa=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},tn={x:0,y:0},Ct=d.union([d.number(),d.string()]);d.object({top:Ct,left:Ct,width:Ct,height:Ct});d.object({left:d.number(),top:d.number(),right:d.number(),bottom:d.number()});d.object({one:Xt,two:Xt,root:Va});const qr=(r,e,t=0,n=0,s)=>{const a={one:{...tn},two:{...tn},root:s??Ba};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},br=r=>{const e=qr(r);return{lower:e.one.x,upper:e.two.x}},wr=r=>{const e=qr(r);return{lower:e.one.y,upper:e.two.y}},Ya=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,qa=d.object({signedWidth:d.number(),signedHeight:d.number()});d.union([gn,qa,Xt,Mr]);const Fa=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);d.object({offset:en,scale:en});const Ga=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Ha=r=>(e,t,n,s)=>[e,s?n/r:n*r],Ja=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,u=a-s,c=o-i;if(t==="dimension")return[r,n*(c/u)];const m=(n-s)*(c/u)+i;return[r,m]},Xa=r=>(e,t,n)=>[r,n],Qa=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},ei=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Fa(n,s,a),[e,n]},Zr=class et{constructor(){p(this,"ops",[]),p(this,"currBounds",null),p(this,"currType",null),p(this,"reversed",!1),this.ops=[]}static translate(e){return new et().translate(e)}static magnify(e){return new et().magnify(e)}static scale(e,t){return new et().scale(e,t)}translate(e){const t=this.new(),n=Ga(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ha(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=_r(e,t),s=this.new(),a=Ja(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=_r(e,t),s=this.new(),a=ei(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=_r(e,t),s=this.new(),a=Xa(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Qa();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new et;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};p(Zr,"IDENTITY",new Zr);let rn=Zr;const nn=class xe{constructor(e=new rn,t=new rn,n=null){p(this,"x"),p(this,"y"),p(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new xe().translate(e,t)}static translateX(e){return new xe().translateX(e)}static translateY(e){return new xe().translateY(e)}static clamp(e){return new xe().clamp(e)}static magnify(e){return new xe().magnify(e)}static scale(e){return new xe().scale(e)}static reBound(e){return new xe().reBound(e)}translate(e,t){const n=Wa(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Ya(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Ka(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(br(e)),t.y=t.y.scale(wr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(br(e)),t.y=this.y.reBound(wr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(br(e)),t.y=this.y.clamp(wr(e)),t}copy(){const e=new xe;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return qr(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};p(nn,"IDENTITY",new nn);const Kn=(r,e)=>{const t=new F(e);if(![G.DAY,G.HOUR,G.MINUTE,G.SECOND,G.MILLISECOND,G.MICROSECOND,G.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof F?new F(n):new G(n)},P=class O{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=O.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*O.MILLISECOND.valueOf();else if(typeof e=="string")this.value=O.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=O.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=O.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=O.MAX:e=O.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new O(BigInt(s.getTime())*O.MILLISECOND.valueOf()).truncate(O.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=O.hours(parseInt(n??"00",10)).add(O.minutes(parseInt(s??"00",10))).add(O.seconds(parseInt(i??"00",10))).add(O.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(O.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return O.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new O(BigInt(n.getTime())*O.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(O.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new G(BigInt(new Date().getTimezoneOffset())*O.MINUTE.valueOf())}static since(e){return new O().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new O(e).valueOf()}span(e){return this.range(e).span}range(e){return new ti(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new O(e).valueOf()}afterEq(e){return this.valueOf()>=new O(e).valueOf()}before(e){return this.valueOf()<new O(e).valueOf()}beforeEq(e){return this.valueOf()<=new O(e).valueOf()}add(e){return new O(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new O(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/O.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Kn(this,e)}get isToday(){return this.truncate(G.DAY).equals(O.now().truncate(G.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new O(new Date)}static max(...e){let t=O.MIN;for(const n of e){const s=new O(n);s.after(t)&&(t=s)}return t}static min(...e){let t=O.MAX;for(const n of e){const s=new O(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new O(e)}static microseconds(e){return O.nanoseconds(e*1e3)}static milliseconds(e){return O.microseconds(e*1e3)}static seconds(e){return O.milliseconds(e*1e3)}static minutes(e){return O.seconds(e*60)}static hours(e){return O.minutes(e*60)}static days(e){return O.hours(e*24)}};p(P,"NANOSECOND",P.nanoseconds(1)),p(P,"MICROSECOND",P.microseconds(1)),p(P,"MILLISECOND",P.milliseconds(1)),p(P,"SECOND",P.seconds(1)),p(P,"MINUTE",P.minutes(1)),p(P,"HOUR",P.hours(1)),p(P,"DAY",P.days(1)),p(P,"MAX",new P((1n<<63n)-1n)),p(P,"MIN",new P(0)),p(P,"ZERO",new P(0)),p(P,"z",d.union([d.object({value:d.bigint()}).transform(r=>new P(r.value)),d.string().transform(r=>new P(BigInt(r))),d.instanceof(Number).transform(r=>new P(r)),d.number().transform(r=>new P(r)),d.instanceof(P)]));let F=P;const U=class M{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new M(e).valueOf()}greaterThan(e){return this.valueOf()>new M(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new M(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new M(e).valueOf()}remainder(e){return Kn(this,e)}truncate(e){return new M(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(M.DAY),t=this.truncate(M.HOUR),n=this.truncate(M.MINUTE),s=this.truncate(M.SECOND),a=this.truncate(M.MILLISECOND),i=this.truncate(M.MICROSECOND),o=this.truncate(M.NANOSECOND),u=e,c=t.sub(e),m=n.sub(t),I=s.sub(n),B=a.sub(s),pe=i.sub(a),me=o.sub(i);let X="";return u.isZero||(X+=`${u.days}d `),c.isZero||(X+=`${c.hours}h `),m.isZero||(X+=`${m.minutes}m `),I.isZero||(X+=`${I.seconds}s `),B.isZero||(X+=`${B.milliseconds}ms `),pe.isZero||(X+=`${pe.microseconds}µs `),me.isZero||(X+=`${me.nanoseconds}ns`),X.trim()}get days(){return Number(this.valueOf()/M.DAY.valueOf())}get hours(){return Number(this.valueOf()/M.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/M.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/M.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/M.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/M.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new M(e).valueOf()}add(e){return new M(this.valueOf()+new M(e).valueOf())}sub(e){return new M(this.valueOf()-new M(e).valueOf())}static nanoseconds(e=1){return new M(e)}static microseconds(e=1){return M.nanoseconds(e*1e3)}static milliseconds(e=1){return M.microseconds(e*1e3)}static seconds(e=1){return M.milliseconds(e*1e3)}static minutes(e){return M.seconds(e.valueOf()*60)}static hours(e){return M.minutes(e*60)}static days(e){return M.hours(e*24)}};p(U,"NANOSECOND",U.nanoseconds(1)),p(U,"MICROSECOND",U.microseconds(1)),p(U,"MILLISECOND",U.milliseconds(1)),p(U,"SECOND",U.seconds(1)),p(U,"MINUTE",U.minutes(1)),p(U,"HOUR",U.hours(1)),p(U,"DAY",U.days(1)),p(U,"MAX",new U((1n<<63n)-1n)),p(U,"MIN",new U(0)),p(U,"ZERO",new U(0)),p(U,"z",d.union([d.object({value:d.bigint()}).transform(r=>new U(r.value)),d.string().transform(r=>new U(BigInt(r))),d.instanceof(Number).transform(r=>new U(r)),d.number().transform(r=>new U(r)),d.instanceof(U)]));let G=U;const Et=class Dt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Dt(e).valueOf()}get period(){return G.seconds(1/this.valueOf())}sampleCount(e){return new G(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new q(t).valueOf()}span(e){return G.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Dt(e)}static khz(e){return Dt.hz(e*1e3)}};p(Et,"z",d.union([d.number().transform(r=>new Et(r)),d.instanceof(Number).transform(r=>new Et(r)),d.instanceof(Et)]));const V=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ri(e*this.valueOf())}};p(V,"UNKNOWN",new V(0)),p(V,"BIT128",new V(16)),p(V,"BIT64",new V(8)),p(V,"BIT32",new V(4)),p(V,"BIT16",new V(2)),p(V,"BIT8",new V(1)),p(V,"z",d.union([d.number().transform(r=>new V(r)),d.instanceof(Number).transform(r=>new V(r)),d.instanceof(V)]));let q=V;const ue=class Lt{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new F(e.start),this.end=new F(e.end)):(this.start=new F(e),this.end=new F(t))}get span(){return new G(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Lt(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Lt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Lt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};p(ue,"MAX",new ue(F.MIN,F.MAX)),p(ue,"MIN",new ue(F.MAX,F.MIN)),p(ue,"ZERO",new ue(F.ZERO,F.ZERO)),p(ue,"z",d.union([d.object({start:F.z,end:F.z}).transform(r=>new ue(r.start,r.end)),d.instanceof(ue)]));let ti=ue;const l=class ce extends String{constructor(e){if(e instanceof ce||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=ce.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(ce.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ce.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(ce.JSON)||this.equals(ce.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ce.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ce.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return ce.BIG_INT_TYPES.some(e=>e.equals(this))}};p(l,"UNKNOWN",new l("unknown")),p(l,"FLOAT64",new l("float64")),p(l,"FLOAT32",new l("float32")),p(l,"INT64",new l("int64")),p(l,"INT32",new l("int32")),p(l,"INT16",new l("int16")),p(l,"INT8",new l("int8")),p(l,"UINT64",new l("uint64")),p(l,"UINT32",new l("uint32")),p(l,"UINT16",new l("uint16")),p(l,"UINT8",new l("uint8")),p(l,"BOOLEAN",l.UINT8),p(l,"TIMESTAMP",new l("timestamp")),p(l,"UUID",new l("uuid")),p(l,"STRING",new l("string")),p(l,"JSON",new l("json")),p(l,"ARRAY_CONSTRUCTORS",new Map([[l.UINT8.toString(),Uint8Array],[l.UINT16.toString(),Uint16Array],[l.UINT32.toString(),Uint32Array],[l.UINT64.toString(),BigUint64Array],[l.FLOAT32.toString(),Float32Array],[l.FLOAT64.toString(),Float64Array],[l.INT8.toString(),Int8Array],[l.INT16.toString(),Int16Array],[l.INT32.toString(),Int32Array],[l.INT64.toString(),BigInt64Array],[l.TIMESTAMP.toString(),BigInt64Array],[l.STRING.toString(),Uint8Array],[l.JSON.toString(),Uint8Array],[l.UUID.toString(),Uint8Array]])),p(l,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,l.UINT8],[Uint16Array.name,l.UINT16],[Uint32Array.name,l.UINT32],[BigUint64Array.name,l.UINT64],[Float32Array.name,l.FLOAT32],[Float64Array.name,l.FLOAT64],[Int8Array.name,l.INT8],[Int16Array.name,l.INT16],[Int32Array.name,l.INT32],[BigInt64Array.name,l.INT64]])),p(l,"DENSITIES",new Map([[l.UINT8.toString(),q.BIT8],[l.UINT16.toString(),q.BIT16],[l.UINT32.toString(),q.BIT32],[l.UINT64.toString(),q.BIT64],[l.FLOAT32.toString(),q.BIT32],[l.FLOAT64.toString(),q.BIT64],[l.INT8.toString(),q.BIT8],[l.INT16.toString(),q.BIT16],[l.INT32.toString(),q.BIT32],[l.INT64.toString(),q.BIT64],[l.TIMESTAMP.toString(),q.BIT64],[l.STRING.toString(),q.UNKNOWN],[l.JSON.toString(),q.UNKNOWN],[l.UUID.toString(),q.BIT128]])),p(l,"ALL",[l.UNKNOWN,l.FLOAT64,l.FLOAT32,l.INT64,l.INT32,l.INT16,l.INT8,l.UINT64,l.UINT32,l.UINT16,l.UINT8,l.TIMESTAMP,l.UUID,l.STRING,l.JSON]),p(l,"BIG_INT_TYPES",[l.INT64,l.UINT64,l.TIMESTAMP]),p(l,"z",d.union([d.string().transform(r=>new l(r)),d.instanceof(l)]));const K=class z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return z.bytes(this.valueOf()+e.valueOf())}sub(e){return z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/z.TERABYTE.valueOf()}toString(){const e=this.truncate(z.TERABYTE),t=this.truncate(z.GIGABYTE),n=this.truncate(z.MEGABYTE),s=this.truncate(z.KILOBYTE),a=this.truncate(z.BYTE),i=e,o=t.sub(e),u=n.sub(t),c=s.sub(n),m=a.sub(s);let I="";return i.isZero||(I+=`${i.terabytes}TB `),o.isZero||(I+=`${o.gigabytes}GB `),u.isZero||(I+=`${u.megabytes}MB `),c.isZero||(I+=`${c.kilobytes}KB `),(!m.isZero||I==="")&&(I+=`${m.valueOf()}B`),I.trim()}static bytes(e=1){return new z(e)}static kilobytes(e=1){return z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return z.megabytes(e.valueOf()*1e3)}static terabytes(e){return z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(K,"BYTE",new K(1)),p(K,"KILOBYTE",K.kilobytes(1)),p(K,"MEGABYTE",K.megabytes(1)),p(K,"GIGABYTE",K.gigabytes(1)),p(K,"TERABYTE",K.terabytes(1)),p(K,"ZERO",new K(0)),p(K,"z",d.union([d.number().transform(r=>new K(r)),d.instanceof(K)]));let ri=K;d.union([d.instanceof(Uint8Array),d.instanceof(Uint16Array),d.instanceof(Uint32Array),d.instanceof(BigUint64Array),d.instanceof(Float32Array),d.instanceof(Float64Array),d.instanceof(Int8Array),d.instanceof(Int16Array),d.instanceof(Int32Array),d.instanceof(BigInt64Array)]);d.record(d.union([d.number(),d.string(),d.symbol()]),d.unknown());const ni=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Wn=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",si=Wn(),Yn=["MacOS","Windows","Linux","Docker"],ai=d.enum(Yn);let xr;const ii=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},oi=(r={})=>{const{force:e,default:t}=r;return e??xr??(xr=ii(),xr??t)},qn=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Yn,RUNTIME:si,detect:Wn,getOS:oi,osZ:ai},Symbol.toStringTag,{value:"Module"})),ui=(...r)=>r.map(Fn).join(""),Fn=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),ci=r=>r.endsWith("/")?r.slice(0,-1):r,di=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&");var We;let li=(We=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){p(this,"protocol"),p(this,"host"),p(this,"port"),p(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Fn(n)}replace(r){return new We({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new We({...this,pathPrefix:ui(this.path,r)})}toString(){return ci(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},p(We,"UNKNOWN",new We({host:"unknown",port:0})),We);class hi{constructor(){p(this,"contentType","application/json"),p(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Qt.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):ni(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Qt.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new hi;var R;(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})(R||(R={}));var Ir;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ir||(Ir={}));const v=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ie=r=>{switch(typeof r){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(r)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(r)?v.array:r===null?v.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?v.promise:typeof Map<"u"&&r instanceof Map?v.map:typeof Set<"u"&&r instanceof Set?v.set:typeof Date<"u"&&r instanceof Date?v.date:v.object;default:return v.unknown}},f=R.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"]),fi=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class se 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,u=0;for(;u<i.path.length;){const c=i.path[u];u===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(t(i))):o[c]=o[c]||{_errors:[]},o=o[c],u++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.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()}}se.create=r=>new se(r);const ft=(r,e)=>{let t;switch(r.code){case f.invalid_type:r.received===v.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case f.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,R.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:t=`Unrecognized key(s) in object: ${R.joinValues(r.keys,", ")}`;break;case f.invalid_union:t="Invalid input";break;case f.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${R.joinValues(r.options)}`;break;case f.invalid_enum_value:t=`Invalid enum value. Expected ${R.joinValues(r.options)}, received '${r.received}'`;break;case f.invalid_arguments:t="Invalid function arguments";break;case f.invalid_return_type:t="Invalid function return type";break;case f.invalid_date:t="Invalid date";break;case f.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}"`:R.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case f.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 f.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 f.custom:t="Invalid input";break;case f.invalid_intersection_types:t="Intersection results could not be merged";break;case f.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case f.not_finite:t="Number must be finite";break;default:t=e.defaultError,R.assertNever(r)}return{message:t}};let Gn=ft;function pi(r){Gn=r}function er(){return Gn}const tr=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const u=n.filter(c=>!!c).slice().reverse();for(const c of u)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},mi=[];function _(r,e){const t=tr({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,er(),ft].filter(n=>!!n)});r.common.issues.push(t)}class Y{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 T;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 Y.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 T;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 T=Object.freeze({status:"aborted"}),Hn=r=>({status:"dirty",value:r}),J=r=>({status:"valid",value:r}),Cr=r=>r.status==="aborted",Er=r=>r.status==="dirty",pt=r=>r.status==="valid",rr=r=>typeof Promise<"u"&&r instanceof Promise;var w;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));class he{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 sn=(r,e)=>{if(pt(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 se(r.common.issues);return this._error=t,this._error}}};function Z(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 E{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ie(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Y,ctx:{common:e.parent.common,data:e.data,parsedType:Ie(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(rr(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:Ie(e)},a=this._parseSync({data:e,path:s.path,parent:s});return sn(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:Ie(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(rr(s)?s:Promise.resolve(s));return sn(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:f.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!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 oe({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Oe.create(this,this._def)}nullable(){return Be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ae.create(this,this._def)}promise(){return Qe.create(this,this._def)}or(e){return gt.create([this,e],this._def)}and(e){return _t.create(this,e,this._def)}transform(e){return new oe({...Z(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Tt({...Z(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new Xn({typeName:k.ZodBranded,type:this,...Z(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ir({...Z(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zt.create(this,e)}readonly(){return ur.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const yi=/^c[^\s-]{8,}$/i,vi=/^[a-z][a-z0-9]*$/,gi=/^[0-9A-HJKMNP-TV-Z]{26}$/,_i=/^[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,bi=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kr;const xi=/^(((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}))$/,ki=/^(([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})))$/,Ti=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 Oi(r,e){return!!((e==="v4"||!e)&&xi.test(r)||(e==="v6"||!e)&&ki.test(r))}class te extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.string,received:a.parsedType}),T}const n=new Y;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.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),_(s,{code:f.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?_(s,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&_(s,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")bi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"email",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")kr||(kr=new RegExp(wi,"u")),kr.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"emoji",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_i.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"uuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")vi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"cuid2",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gi.test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ulid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),_(s,{validation:"url",code:f.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),_(s,{validation:"regex",code:f.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),_(s,{code:f.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),_(s,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ti(a).test(e.data)||(s=this._getOrReturnCtx(e,s),_(s,{code:f.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?Oi(e.data,a.version)||(s=this._getOrReturnCtx(e,s),_(s,{validation:"ip",code:f.invalid_string,message:a.message}),n.dirty()):R.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:f.invalid_string,...w.errToObj(n)})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.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,...w.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new te({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new te({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new te({...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}}te.create=r=>{var e;return new te({checks:[],typeName:k.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Z(r)})};function Si(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 je extends E{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)!==v.number){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.number,received:a.parsedType}),T}let n;const s=new Y;for(const a of this._def.checks)a.kind==="int"?R.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:f.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),_(n,{code:f.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),_(n,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Si(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),_(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:f.not_finite,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new je({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new je({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.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"&&R.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)}}je.create=r=>new je({checks:[],typeName:k.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Z(r)});class Re extends E{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)!==v.bigint){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.bigint,received:a.parsedType}),T}let n;const s=new Y;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),_(n,{code:f.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),_(n,{code:f.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),_(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):R.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.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}}Re.create=r=>{var e;return new Re({checks:[],typeName:k.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Z(r)})};class mt extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.boolean,received:n.parsedType}),T}return J(e.data)}}mt.create=r=>new mt({typeName:k.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Z(r)});class ze extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_type,expected:v.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return _(a,{code:f.invalid_date}),T}const n=new Y;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),_(s,{code:f.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),_(s,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):R.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ze({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.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}}ze.create=r=>new ze({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:k.ZodDate,...Z(r)});class nr extends E{_parse(e){if(this._getType(e)!==v.symbol){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.symbol,received:n.parsedType}),T}return J(e.data)}}nr.create=r=>new nr({typeName:k.ZodSymbol,...Z(r)});class yt extends E{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.undefined,received:n.parsedType}),T}return J(e.data)}}yt.create=r=>new yt({typeName:k.ZodUndefined,...Z(r)});class vt extends E{_parse(e){if(this._getType(e)!==v.null){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.null,received:n.parsedType}),T}return J(e.data)}}vt.create=r=>new vt({typeName:k.ZodNull,...Z(r)});class Xe extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}Xe.create=r=>new Xe({typeName:k.ZodAny,...Z(r)});class Ue extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Ue.create=r=>new Ue({typeName:k.ZodUnknown,...Z(r)});class Ne extends E{_parse(e){const t=this._getOrReturnCtx(e);return _(t,{code:f.invalid_type,expected:v.never,received:t.parsedType}),T}}Ne.create=r=>new Ne({typeName:k.ZodNever,...Z(r)});class sr extends E{_parse(e){if(this._getType(e)!==v.undefined){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.void,received:n.parsedType}),T}return J(e.data)}}sr.create=r=>new sr({typeName:k.ZodVoid,...Z(r)});class ae extends E{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return _(t,{code:f.invalid_type,expected:v.array,received:t.parsedType}),T;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(_(t,{code:i?f.too_big:f.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&&(_(t,{code:f.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&&(_(t,{code:f.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 he(t,i,t.path,o)))).then(i=>Y.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new he(t,i,t.path,o)));return Y.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ae({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new ae({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new ae({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}ae.create=(r,e)=>new ae({type:r,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...Z(e)});function qe(r){if(r instanceof D){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Oe.create(qe(n))}return new D({...r._def,shape:()=>e})}else return r instanceof ae?new ae({...r._def,type:qe(r.element)}):r instanceof Oe?Oe.create(qe(r.unwrap())):r instanceof Be?Be.create(qe(r.unwrap())):r instanceof fe?fe.create(r.items.map(e=>qe(e))):r}class D extends E{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=R.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const c=this._getOrReturnCtx(e);return _(c,{code:f.invalid_type,expected:v.object,received:c.parsedType}),T}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ne&&this._def.unknownKeys==="strip"))for(const c in s.data)i.includes(c)||o.push(c);const u=[];for(const c of i){const m=a[c],I=s.data[c];u.push({key:{status:"valid",value:c},value:m._parse(new he(s,I,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Ne){const c=this._def.unknownKeys;if(c==="passthrough")for(const m of o)u.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(c==="strict")o.length>0&&(_(s,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const m of o){const I=s.data[m];u.push({key:{status:"valid",value:m},value:c._parse(new he(s,I,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const m of u){const I=await m.key;c.push({key:I,value:await m.value,alwaysSet:m.alwaysSet})}return c}).then(c=>Y.mergeObjectSync(n,c)):Y.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const u=(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=w.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new D({...this._def,catchall:e})}pick(e){const t={};return R.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new D({...this._def,shape:()=>t})}omit(e){const t={};return R.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new D({...this._def,shape:()=>t})}deepPartial(){return qe(this)}partial(e){const t={};return R.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new D({...this._def,shape:()=>t})}required(e){const t={};return R.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Oe;)a=a._def.innerType;t[n]=a}}),new D({...this._def,shape:()=>t})}keyof(){return Jn(R.objectKeys(this.shape))}}D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:Ne.create(),typeName:k.ZodObject,...Z(e)});class gt extends E{_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 se(o.ctx.common.issues));return _(t,{code:f.invalid_union,unionErrors:i}),T}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 u of n){const c={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:c});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new se(u));return _(t,{code:f.invalid_union,unionErrors:o}),T}}get options(){return this._def.options}}gt.create=(r,e)=>new gt({options:r,typeName:k.ZodUnion,...Z(e)});const zt=r=>r instanceof wt?zt(r.schema):r instanceof oe?zt(r.innerType()):r instanceof xt?[r.value]:r instanceof Me?r.options:r instanceof kt?Object.keys(r.enum):r instanceof Tt?zt(r._def.innerType):r instanceof yt?[void 0]:r instanceof vt?[null]:null;class mr extends E{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return _(t,{code:f.invalid_type,expected:v.object,received:t.parsedType}),T;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}):(_(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),T)}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=zt(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 mr({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...Z(n)})}}function Ar(r,e){const t=Ie(r),n=Ie(e);if(r===e)return{valid:!0,data:r};if(t===v.object&&n===v.object){const s=R.objectKeys(e),a=R.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Ar(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===v.array&&n===v.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],u=Ar(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===v.date&&n===v.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class _t extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Cr(a)||Cr(i))return T;const o=Ar(a.value,i.value);return o.valid?((Er(a)||Er(i))&&t.dirty(),{status:t.value,value:o.data}):(_(n,{code:f.invalid_intersection_types}),T)};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}))}}_t.create=(r,e,t)=>new _t({left:r,right:e,typeName:k.ZodIntersection,...Z(t)});class fe extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return _(n,{code:f.invalid_type,expected:v.array,received:n.parsedType}),T;if(n.data.length<this._def.items.length)return _(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&n.data.length>this._def.items.length&&(_(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new he(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>Y.mergeArray(t,i)):Y.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new fe({...this._def,rest:e})}}fe.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fe({items:r,typeName:k.ZodTuple,rest:null,...Z(e)})};class bt extends E{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!==v.object)return _(n,{code:f.invalid_type,expected:v.object,received:n.parsedType}),T;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new he(n,o,n.path,o)),value:i._parse(new he(n,n.data[o],n.path,o))});return n.common.async?Y.mergeObjectAsync(t,s):Y.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof E?new bt({keyType:e,valueType:t,typeName:k.ZodRecord,...Z(n)}):new bt({keyType:te.create(),valueType:e,typeName:k.ZodRecord,...Z(t)})}}class ar extends E{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!==v.map)return _(n,{code:f.invalid_type,expected:v.map,received:n.parsedType}),T;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],c)=>({key:s._parse(new he(n,o,n.path,[c,"key"])),value:a._parse(new he(n,u,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const c=await u.key,m=await u.value;if(c.status==="aborted"||m.status==="aborted")return T;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const c=u.key,m=u.value;if(c.status==="aborted"||m.status==="aborted")return T;(c.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(c.value,m.value)}return{status:t.value,value:o}}}}ar.create=(r,e,t)=>new ar({valueType:e,keyType:r,typeName:k.ZodMap,...Z(t)});class Ve extends E{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return _(n,{code:f.invalid_type,expected:v.set,received:n.parsedType}),T;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(_(n,{code:f.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&&(_(n,{code:f.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(u){const c=new Set;for(const m of u){if(m.status==="aborted")return T;m.status==="dirty"&&t.dirty(),c.add(m.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((u,c)=>a._parse(new he(n,u,n.path,c)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Ve({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Ve({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ve.create=(r,e)=>new Ve({valueType:r,minSize:null,maxSize:null,typeName:k.ZodSet,...Z(e)});class Ge extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return _(t,{code:f.invalid_type,expected:v.function,received:t.parsedType}),T;function n(o,u){return tr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,er(),ft].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:u}})}function s(o,u){return tr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,er(),ft].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Qe){const o=this;return J(async function(...u){const c=new se([]),m=await o._def.args.parseAsync(u,a).catch(pe=>{throw c.addIssue(n(u,pe)),c}),I=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(I,a).catch(pe=>{throw c.addIssue(s(I,pe)),c})})}else{const o=this;return J(function(...u){const c=o._def.args.safeParse(u,a);if(!c.success)throw new se([n(u,c.error)]);const m=Reflect.apply(i,this,c.data),I=o._def.returns.safeParse(m,a);if(!I.success)throw new se([s(m,I.error)]);return I.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ge({...this._def,args:fe.create(e).rest(Ue.create())})}returns(e){return new Ge({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Ge({args:e||fe.create([]).rest(Ue.create()),returns:t||Ue.create(),typeName:k.ZodFunction,...Z(n)})}}class wt extends E{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})}}wt.create=(r,e)=>new wt({getter:r,typeName:k.ZodLazy,...Z(e)});class xt extends E{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}xt.create=(r,e)=>new xt({value:r,typeName:k.ZodLiteral,...Z(e)});function Jn(r,e){return new Me({values:r,typeName:k.ZodEnum,...Z(e)})}class Me extends E{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{expected:R.joinValues(n),received:t.parsedType,code:f.invalid_type}),T}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{received:t.data,code:f.invalid_enum_value,options:n}),T}return J(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 Me.create(e)}exclude(e){return Me.create(this.options.filter(t=>!e.includes(t)))}}Me.create=Jn;class kt extends E{_parse(e){const t=R.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){const s=R.objectValues(t);return _(n,{expected:R.joinValues(s),received:n.parsedType,code:f.invalid_type}),T}if(t.indexOf(e.data)===-1){const s=R.objectValues(t);return _(n,{received:n.data,code:f.invalid_enum_value,options:s}),T}return J(e.data)}get enum(){return this._def.values}}kt.create=(r,e)=>new kt({values:r,typeName:k.ZodNativeEnum,...Z(e)});class Qe extends E{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return _(t,{code:f.invalid_type,expected:v.promise,received:t.parsedType}),T;const n=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qe.create=(r,e)=>new Qe({type:r,typeName:k.ZodPromise,...Z(e)});class oe extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.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=>{_(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 u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u 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"?T:(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"?T:(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(!pt(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=>pt(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);R.assertNever(s)}}oe.create=(r,e,t)=>new oe({schema:r,typeName:k.ZodEffects,effect:e,...Z(t)});oe.createWithPreprocess=(r,e,t)=>new oe({schema:e,effect:{type:"preprocess",transform:r},typeName:k.ZodEffects,...Z(t)});class Oe extends E{_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Oe.create=(r,e)=>new Oe({innerType:r,typeName:k.ZodOptional,...Z(e)});class Be extends E{_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Be.create=(r,e)=>new Be({innerType:r,typeName:k.ZodNullable,...Z(e)});class Tt extends E{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===v.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Tt.create=(r,e)=>new Tt({innerType:r,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Z(e)});class ir extends E{_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 rr(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new se(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ir.create=(r,e)=>new ir({innerType:r,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Z(e)});class or extends E{_parse(e){if(this._getType(e)!==v.nan){const n=this._getOrReturnCtx(e);return _(n,{code:f.invalid_type,expected:v.nan,received:n.parsedType}),T}return{status:"valid",value:e.data}}}or.create=r=>new or({typeName:k.ZodNaN,...Z(r)});const Ni=Symbol("zod_brand");class Xn extends E{_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 Zt extends E{_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"?T:a.status==="dirty"?(t.dirty(),Hn(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"?T: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 Zt({in:e,out:t,typeName:k.ZodPipeline})}}class ur extends E{_parse(e){const t=this._def.innerType._parse(e);return pt(t)&&(t.value=Object.freeze(t.value)),t}}ur.create=(r,e)=>new ur({innerType:r,typeName:k.ZodReadonly,...Z(e)});const Qn=(r,e={},t)=>r?Xe.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,c=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...c,fatal:u})}}):Xe.create(),Zi={object:D.lazycreate};var k;(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"})(k||(k={}));const Ii=(r,e={message:`Input not instance of ${r.name}`})=>Qn(t=>t instanceof r,e),es=te.create,ts=je.create,Ci=or.create,Ei=Re.create,rs=mt.create,Ai=ze.create,ji=nr.create,Ri=yt.create,Mi=vt.create,Pi=Xe.create,Ui=Ue.create,$i=Ne.create,Di=sr.create,Li=ae.create,zi=D.create,Vi=D.strictCreate,Bi=gt.create,Ki=mr.create,Wi=_t.create,Yi=fe.create,qi=bt.create,Fi=ar.create,Gi=Ve.create,Hi=Ge.create,Ji=wt.create,Xi=xt.create,Qi=Me.create,eo=kt.create,to=Qe.create,an=oe.create,ro=Oe.create,no=Be.create,so=oe.createWithPreprocess,ao=Zt.create,io=()=>es().optional(),oo=()=>ts().optional(),uo=()=>rs().optional(),co={string:r=>te.create({...r,coerce:!0}),number:r=>je.create({...r,coerce:!0}),boolean:r=>mt.create({...r,coerce:!0}),bigint:r=>Re.create({...r,coerce:!0}),date:r=>ze.create({...r,coerce:!0})},lo=T;var ke=Object.freeze({__proto__:null,defaultErrorMap:ft,setErrorMap:pi,getErrorMap:er,makeIssue:tr,EMPTY_PATH:mi,addIssueToContext:_,ParseStatus:Y,INVALID:T,DIRTY:Hn,OK:J,isAborted:Cr,isDirty:Er,isValid:pt,isAsync:rr,get util(){return R},get objectUtil(){return Ir},ZodParsedType:v,getParsedType:Ie,ZodType:E,ZodString:te,ZodNumber:je,ZodBigInt:Re,ZodBoolean:mt,ZodDate:ze,ZodSymbol:nr,ZodUndefined:yt,ZodNull:vt,ZodAny:Xe,ZodUnknown:Ue,ZodNever:Ne,ZodVoid:sr,ZodArray:ae,ZodObject:D,ZodUnion:gt,ZodDiscriminatedUnion:mr,ZodIntersection:_t,ZodTuple:fe,ZodRecord:bt,ZodMap:ar,ZodSet:Ve,ZodFunction:Ge,ZodLazy:wt,ZodLiteral:xt,ZodEnum:Me,ZodNativeEnum:kt,ZodPromise:Qe,ZodEffects:oe,ZodTransformer:oe,ZodOptional:Oe,ZodNullable:Be,ZodDefault:Tt,ZodCatch:ir,ZodNaN:or,BRAND:Ni,ZodBranded:Xn,ZodPipeline:Zt,ZodReadonly:ur,custom:Qn,Schema:E,ZodSchema:E,late:Zi,get ZodFirstPartyTypeKind(){return k},coerce:co,any:Pi,array:Li,bigint:Ei,boolean:rs,date:Ai,discriminatedUnion:Ki,effect:an,enum:Qi,function:Hi,instanceof:Ii,intersection:Wi,lazy:Ji,literal:Xi,map:Fi,nan:Ci,nativeEnum:eo,never:$i,null:Mi,nullable:no,number:ts,object:zi,oboolean:uo,onumber:oo,optional:ro,ostring:io,pipeline:ao,preprocess:so,promise:to,record:qi,set:Gi,strictObject:Vi,string:es,symbol:ji,transformer:an,tuple:Yi,undefined:Ri,union:Bi,unknown:Ui,void:Di,NEVER:lo,ZodIssueCode:f,quotelessJson:fi,ZodError:se});class It extends Error{constructor(t,n){super(t);L(this,"discriminator","FreighterError");L(this,"type");this.type=n}}const ho=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},jr="unknown",on="nil",yr="freighter",Fr=ke.object({type:ke.string(),data:ke.string()});class fo{constructor(){L(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:on,data:""};if(ho(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:jr,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===on)return null;if(e.type===jr)return new un(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new un(e.data)}}const Gr=new fo,ns=({encode:r,decode:e})=>Gr.register({encode:r,decode:e}),po=r=>Gr.encode(r),Hr=r=>Gr.decode(r);class un extends It{constructor(e){super(e,jr)}}class Ot extends It{constructor(){super("EOF",yr)}}class St extends It{constructor(){super("StreamClosed",yr)}}class vr extends It{constructor(t={}){const{message:n="Unreachable",url:s=li.UNKNOWN}=t;super(n,yr);L(this,"url");this.url=s}}const Vt="freighter",mo=r=>{if(r.type!==yr)return null;if(r instanceof Ot)return{type:Vt,data:"EOF"};if(r instanceof St)return{type:Vt,data:"StreamClosed"};if(r instanceof vr)return{type:Vt,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},yo=r=>{if(r.type!==Vt)return null;switch(r.data){case"EOF":return new Ot;case"StreamClosed":return new St;case"Unreachable":return new vr;default:throw new Error(`Unknown error type: ${r.data}`)}};ns({encode:mo,decode:yo});class ss{constructor(){L(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,s)};return await s(e)}}const as="Content-Type",cn=r=>{if(qn.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class vo extends ss{constructor(t,n,s=!1){super();L(this,"endpoint");L(this,"encoder");L(this,"fetch");return this.endpoint=t.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=cn(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[as]:this.encoder.contentType}}async send(t,n,s,a){n=s==null?void 0:s.parse(n);let i=null;const o=this.endpoint.child(t),u={};u.method="POST",u.body=this.encoder.encode(n??{});const[,c]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async m=>{const I={...m,params:{}};u.headers={...this.headers,...m.params};let B;try{B=await cn(m.protocol)(m.target,u)}catch(me){let X=me;return X.message==="Load failed"&&(X=new vr({url:o})),[I,X]}const pe=await B.arrayBuffer();if(B!=null&&B.ok)return a!=null&&(i=this.encoder.decode(pe,a)),[I,null];try{if(B.status!==400)return[I,new Error(B.statusText)];const me=this.encoder.decode(pe,Fr),X=Hr(me);return[I,X]}catch(me){return[I,new Error(`[freighter] - failed to decode error: ${B.statusText}: ${me.message}`)]}});return[i,c]}}const go=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},_o=()=>qn.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),bo=ke.object({type:ke.union([ke.literal("data"),ke.literal("close")]),payload:ke.unknown().optional(),error:ke.optional(Fr)});class wo{constructor(e,t,n,s){L(this,"encoder");L(this,"reqSchema");L(this,"resSchema");L(this,"ws");L(this,"serverClosed");L(this,"sendClosed");L(this,"receiveDataQueue",[]);L(this,"receiveCallbacksQueue",[]);this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ot;if(this.sendClosed)throw new St;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Hr(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,bo),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=So(e)?new Ot:new St}}}const xo="freighterctx",ko=1e3,To=1001,Oo=[ko,To],So=r=>Oo.includes(r.code),cr=class cr extends ss{constructor(t,n,s=!1){super();L(this,"baseUrl");L(this,"encoder");this.baseUrl=t.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(t,n,s){const a=_o();let i;const[,o]=await this.executeMiddleware({target:t,protocol:"websocket",params:{},role:"client"},async u=>{const c=a(this.buildURL(t,u)),m={...u,params:{}};c.binaryType=cr.MESSAGE_TYPE;const I=await this.wrapSocket(c,n,s);return I instanceof Error?[m,I]:(i=I,[m,null])});if(o!=null)throw o;return i}buildURL(t,n){const s=di({[as]:this.encoder.contentType,...n.params},xo);return this.baseUrl.child(t).toString()+s}async wrapSocket(t,n,s){return await new Promise(a=>{t.onopen=()=>{a(new wo(t,this.encoder,n,s))},t.onerror=i=>{const o=i;a(new Error(o.message))}})}};L(cr,"MESSAGE_TYPE","arraybuffer");let Rr=cr;exports.BaseTypedError=It;exports.EOF=Ot;exports.HTTPClient=vo;exports.StreamClosed=St;exports.Unreachable=vr;exports.WebSocketClient=Rr;exports.decodeError=Hr;exports.encodeError=po;exports.errorZ=Fr;exports.registerError=ns;exports.sendRequired=go;
2
- //# sourceMappingURL=freighter.cjs.map
1
+ "use strict";var $t=Object.defineProperty;var Ut=(t,e,r)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>(Ut(t,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("zod");var E=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d={},ue={};Object.defineProperty(ue,"__esModule",{value:!0});function xt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,r,n){return n.toUpperCase()}):""}ue.default=xt;var le={};Object.defineProperty(le,"__esModule",{value:!0});function Mt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}le.default=Mt;var ce={};Object.defineProperty(ce,"__esModule",{value:!0});function jt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,r,n){return n.toUpperCase()}):""}ce.default=jt;var Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});function Rt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Ne.default=Rt;var ze={};Object.defineProperty(ze,"__esModule",{value:!0});function Bt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}ze.default=Bt;var Ee={};Object.defineProperty(Ee,"__esModule",{value:!0});function Dt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ee.default=Dt;var Ce={};Object.defineProperty(Ce,"__esModule",{value:!0});function kt(t){if(t===void 0&&(t=""),!t)return"";var e=String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(r,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Ce.default=kt;var $e={};Object.defineProperty($e,"__esModule",{value:!0});function Lt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,r,n,s){return r+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}$e.default=Lt;var fe={};Object.defineProperty(fe,"__esModule",{value:!0});function Pt(t){return t===void 0&&(t=""),t?String(t).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,r,n){return r+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}fe.default=Pt;var Ue={},V={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.belongToTypes=t.isValidObject=t.isArrayObject=t.validateOptions=t.DefaultOption=void 0,t.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},t.validateOptions=function(e){return e===void 0&&(e=t.DefaultOption),e.recursive==null?e=t.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},t.isArrayObject=function(e){return e!=null&&Array.isArray(e)},t.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},t.belongToTypes=function(e,r){return(r||[]).some(function(n){return e instanceof n})}})(V);var Zt=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(Ue,"__esModule",{value:!0});var M=V;function Q(t,e){if(e===void 0&&(e=M.DefaultOption),!M.isValidObject(t))return null;e=M.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=n.toLowerCase();e.recursive&&(M.isValidObject(s)?M.belongToTypes(s,e.keepTypesOnRecursion)||(s=Q(s,e)):e.recursiveInArray&&M.isArrayObject(s)&&(s=Zt(s).map(function(u){var c=u;if(M.isValidObject(u))M.belongToTypes(c,e.keepTypesOnRecursion)||(c=Q(u,e));else if(M.isArrayObject(u)){var h=Q({key:u},e);c=h.key}return c}))),r[a]=s}),r}Ue.default=Q;var xe={},Yt=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(xe,"__esModule",{value:!0});var j=V;function _(t,e){if(e===void 0&&(e=j.DefaultOption),!j.isValidObject(t))return null;e=j.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=n.toUpperCase();e.recursive&&(j.isValidObject(s)?j.belongToTypes(s,e.keepTypesOnRecursion)||(s=_(s,e)):e.recursiveInArray&&j.isArrayObject(s)&&(s=Yt(s).map(function(u){var c=u;if(j.isValidObject(u))j.belongToTypes(c,e.keepTypesOnRecursion)||(c=_(u,e));else if(j.isArrayObject(u)){var h=_({key:u},e);c=h.key}return c}))),r[a]=s}),r}xe.default=_;var Me={},Kt=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(Me,"__esModule",{value:!0});var R=V,Vt=ue;function ee(t,e){if(e===void 0&&(e=R.DefaultOption),!R.isValidObject(t))return null;e=R.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=Vt.default(n);e.recursive&&(R.isValidObject(s)?R.belongToTypes(s,e.keepTypesOnRecursion)||(s=ee(s,e)):e.recursiveInArray&&R.isArrayObject(s)&&(s=Kt(s).map(function(u){var c=u;if(R.isValidObject(u))R.belongToTypes(c,e.keepTypesOnRecursion)||(c=ee(u,e));else if(R.isArrayObject(u)){var h=ee({key:u},e);c=h.key}return c}))),r[a]=s}),r}Me.default=ee;var je={},Ft=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(je,"__esModule",{value:!0});var B=V,qt=le;function te(t,e){if(e===void 0&&(e=B.DefaultOption),!B.isValidObject(t))return null;e=B.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=qt.default(n);e.recursive&&(B.isValidObject(s)?B.belongToTypes(s,e.keepTypesOnRecursion)||(s=te(s,e)):e.recursiveInArray&&B.isArrayObject(s)&&(s=Ft(s).map(function(u){var c=u;if(B.isValidObject(u))B.belongToTypes(c,e.keepTypesOnRecursion)||(c=te(u,e));else if(B.isArrayObject(u)){var h=te({key:u},e);c=h.key}return c}))),r[a]=s}),r}je.default=te;var Re={},Wt=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(Re,"__esModule",{value:!0});var D=V,Gt=ce;function re(t,e){if(e===void 0&&(e=D.DefaultOption),!D.isValidObject(t))return null;e=D.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=Gt.default(n);e.recursive&&(D.isValidObject(s)?D.belongToTypes(s,e.keepTypesOnRecursion)||(s=re(s,e)):e.recursiveInArray&&D.isArrayObject(s)&&(s=Wt(s).map(function(u){var c=u;if(D.isValidObject(u))D.belongToTypes(c,e.keepTypesOnRecursion)||(c=re(u,e));else if(D.isArrayObject(u)){var h=re({key:u},e);c=h.key}return c}))),r[a]=s}),r}Re.default=re;var Be={},Ht=E&&E.__spreadArrays||function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),s=0,e=0;e<r;e++)for(var a=arguments[e],u=0,c=a.length;u<c;u++,s++)n[s]=a[u];return n};Object.defineProperty(Be,"__esModule",{value:!0});var k=V,Xt=fe;function ne(t,e){if(e===void 0&&(e=k.DefaultOption),!k.isValidObject(t))return null;e=k.validateOptions(e);var r={};return Object.keys(t).forEach(function(n){var s=t[n],a=Xt.default(n);e.recursive&&(k.isValidObject(s)?k.belongToTypes(s,e.keepTypesOnRecursion)||(s=ne(s,e)):e.recursiveInArray&&k.isArrayObject(s)&&(s=Ht(s).map(function(u){var c=u;if(k.isValidObject(u))k.belongToTypes(c,e.keepTypesOnRecursion)||(c=ne(u,e));else if(k.isArrayObject(u)){var h=ne({key:u},e);c=h.key}return c}))),r[a]=s}),r}Be.default=ne;Object.defineProperty(d,"__esModule",{value:!0});d.kebabKeys=d.pascalKeys=d.snakeKeys=d.camelKeys=d.upperKeys=d.lowerKeys=d.toLowerCase=d.toUpperCase=d.toKebabCase=d.toHeaderCase=d.toSentenceCase=d.toTextCase=d.toPathCase=d.toDotCase=d.toPascalCase=d.toSnakeCase=d.toCamelCase=void 0;var Xe=ue;d.toCamelCase=Xe.default;var Je=le;d.toSnakeCase=Je.default;var Qe=ce;d.toPascalCase=Qe.default;var _e=Ne;d.toDotCase=_e.default;var et=ze;d.toPathCase=et.default;var tt=Ee;d.toTextCase=tt.default;var rt=Ce;d.toSentenceCase=rt.default;var nt=$e;d.toHeaderCase=nt.default;var st=fe;d.toKebabCase=st.default;var it=Ue;d.lowerKeys=it.default;var at=xe;d.upperKeys=at.default;var ot=Me;d.camelKeys=ot.default;var ut=je;d.snakeKeys=ut.default;var lt=Re;d.pascalKeys=lt.default;var ct=Be;d.kebabKeys=ct.default;var ft=function(t){return String(t||"").toLowerCase()};d.toLowerCase=ft;var dt=function(t){return String(t||"").toUpperCase()};d.toUpperCase=dt;var Jt={toCamelCase:Xe.default,toSnakeCase:Je.default,toPascalCase:Qe.default,toDotCase:_e.default,toPathCase:et.default,toTextCase:tt.default,toSentenceCase:rt.default,toHeaderCase:nt.default,toKebabCase:st.default,toUpperCase:dt,toLowerCase:ft,lowerKeys:it.default,upperKeys:at.default,camelKeys:ot.default,snakeKeys:ut.default,pascalKeys:lt.default,kebabKeys:ct.default};d.default=Jt;var ht=d;const pt={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Qt=t=>ht.snakeKeys(t,pt),_t=t=>ht.camelKeys(t,pt),er=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var tr=Object.defineProperty,rr=(t,e,r)=>e in t?tr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ye=(t,e,r)=>(rr(t,typeof e!="symbol"?e+"":e,r),r);let nr=class{constructor(){ye(this,"contentType","application/json"),ye(this,"decoder"),ye(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,r){return this.decodeString(this.decoder.decode(e),r)}decodeString(e,r){const n=_t(JSON.parse(e));return r!=null?r.parse(n):n}encodeString(e){return JSON.stringify(Qt(e),(r,n)=>ArrayBuffer.isView(n)?Array.from(n):er(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};new nr;const de=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const yt=i.z.object({width:i.z.number(),height:i.z.number()}),sr=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),ir=["width","height"];i.z.enum(ir);const ar=["start","center","end"],or=["signedWidth","signedHeight"];i.z.enum(or);const ae=i.z.object({x:i.z.number(),y:i.z.number()}),ur=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),lr=["x","y"],gt=i.z.enum(lr),vt=["top","right","bottom","left"];i.z.enum(vt);const cr=["left","right"],Ot=i.z.enum(cr),fr=["top","bottom"],bt=i.z.enum(fr),wt=["center"],Ze=i.z.enum(wt),dr=[...vt,...wt],mt=i.z.enum(dr);i.z.enum(ar);const hr=["first","last"];i.z.enum(hr);const pr=i.z.object({lower:i.z.number(),upper:i.z.number()}),yr=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([pr,de]);i.z.union([yr,de]);i.z.union([gt,mt]);i.z.union([gt,mt,i.z.instanceof(String)]);const ge=(t,e)=>{const r={};if(typeof t=="number"||typeof t=="bigint")e!=null?(r.lower=t,r.upper=e):(r.lower=typeof t=="bigint"?0n:0,r.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[r.lower,r.upper]=t}else return Ye(t);return Ye(r)},Ye=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t;i.z.object({x:Ot.or(Ze),y:bt.or(Ze)});const gr=i.z.object({x:Ot,y:bt}),vr=Object.freeze({x:"left",y:"top"}),Or=(t,e)=>t.x===e.x&&t.y===e.y,Ke=i.z.union([i.z.number(),ae,de,yt,sr,ur]),br=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},Ve=Object.freeze({x:0,y:0}),X=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:X,left:X,width:X,height:X});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:ae,two:ae,root:gr});const De=(t,e,r=0,n=0,s)=>{const a={one:{...Ve},two:{...Ve},root:s??vr};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+r,y:a.one.y+n},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+r,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+r}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},ve=t=>{const e=De(t);return{lower:e.one.x,upper:e.two.x}},Oe=t=>{const e=De(t);return{lower:e.one.y,upper:e.two.y}},wr=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var mr=Object.defineProperty,Tr=(t,e,r)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,P=(t,e,r)=>(Tr(t,typeof e!="symbol"?e+"":e,r),r);const Sr=(t,e,r)=>(e!=null&&(t=Math.max(t,e)),r!=null&&(t=Math.min(t,r)),t);i.z.object({offset:Ke,scale:Ke});const Ar=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],Ir=t=>(e,r,n,s)=>[e,s?n/t:n*t],Nr=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:a}=e,{lower:u,upper:c}=t,h=a-s,z=c-u;if(r==="dimension")return[t,n*(z/h)];const A=(n-s)*(z/h)+u;return[t,A]},zr=t=>(e,r,n)=>[t,n],Er=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},Cr=t=>(e,r,n)=>{const{lower:s,upper:a}=t;return n=Sr(n,s,a),[e,n]},me=class W{constructor(){P(this,"ops",[]),P(this,"currBounds",null),P(this,"currType",null),P(this,"reversed",!1),this.ops=[]}static translate(e){return new W().translate(e)}static magnify(e){return new W().magnify(e)}static scale(e,r){return new W().scale(e,r)}translate(e){const r=this.new(),n=Ar(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=Ir(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=ge(e,r),s=this.new(),a=Nr(n);return a.type="scale",s.ops.push(a),s}clamp(e,r){const n=ge(e,r),s=this.new(),a=Cr(n);return a.type="clamp",s.ops.push(a),s}reBound(e,r){const n=ge(e,r),s=this.new(),a=zr(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Er();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new W;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([u,c])=>s>=u&&s<=c))return;const a=e.ops.findIndex((u,c)=>u.type==="scale"&&c>s);a!==-1&&r.push([s,a])}),r.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};P(me,"IDENTITY",new me);let Fe=me;const qe=class L{constructor(e=new Fe,r=new Fe,n=null){P(this,"x"),P(this,"y"),P(this,"currRoot"),this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new L().translate(e,r)}static translateX(e){return new L().translateX(e)}static translateY(e){return new L().translateY(e)}static clamp(e){return new L().clamp(e)}static magnify(e){return new L().magnify(e)}static scale(e){return new L().scale(e)}static reBound(e){return new L().reBound(e)}translate(e,r){const n=br(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(wr(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Or(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(ve(e)),r.y=r.y.scale(Oe(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(ve(e)),r.y=this.y.reBound(Oe(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(ve(e)),r.y=this.y.clamp(Oe(e)),r}copy(){const e=new L;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return De(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};P(qe,"IDENTITY",new qe);i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const Tt=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",$r=Tt(),St=["MacOS","Windows","Linux","Docker"],Ur=i.z.enum(St);let be;const xr=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},Mr=(t={})=>{const{force:e,default:r}=t;return e??be??(be=xr(),be??r)},At=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:St,RUNTIME:$r,detect:Tt,getOS:Mr,osZ:Ur},Symbol.toStringTag,{value:"Module"})),jr=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([yt,jr,ae,de]);var Rr=Object.defineProperty,Br=(t,e,r)=>e in t?Rr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,l=(t,e,r)=>(Br(t,typeof e!="symbol"?e+"":e,r),r);const It=(t,e)=>{const r=new m(e);if(![T.DAY,T.HOUR,T.MINUTE,T.SECOND,T.MILLISECOND,T.MICROSECOND,T.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof m?new m(n):new T(n)},y=class f{constructor(e,r="UTC"){if(l(this,"value"),l(this,"encodeValue",!0),e==null)this.value=f.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*f.MILLISECOND.valueOf();else if(typeof e=="string")this.value=f.parseDateTimeString(e,r).valueOf();else if(Array.isArray(e))this.value=f.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=f.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=f.MAX:e=f.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new f(BigInt(s.getTime())*f.MILLISECOND.valueOf()).truncate(f.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,a]=e.split(":");let u="00",c="00";a!=null&&([u,c]=a.split("."));let h=f.hours(parseInt(n??"00",10)).add(f.minutes(parseInt(s??"00",10))).add(f.seconds(parseInt(u??"00",10))).add(f.milliseconds(parseInt(c??"00",10)));return r==="local"&&(h=h.add(f.utcOffset)),h.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return f.parseTimeString(e,r);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new f(BigInt(n.getTime())*f.MILLISECOND.valueOf(),r).valueOf()}fString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(f.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new T(BigInt(new Date().getTimezoneOffset())*f.MINUTE.valueOf())}static since(e){return new f().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new f(e).valueOf()}span(e){return this.range(e).span}range(e){return new Dr(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new f(e).valueOf()}afterEq(e){return this.valueOf()>=new f(e).valueOf()}before(e){return this.valueOf()<new f(e).valueOf()}beforeEq(e){return this.valueOf()<=new f(e).valueOf()}add(e){return new f(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new f(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(f.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return It(this,e)}get isToday(){return this.truncate(T.DAY).equals(f.now().truncate(T.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new f(new Date)}static max(...e){let r=f.MIN;for(const n of e){const s=new f(n);s.after(r)&&(r=s)}return r}static min(...e){let r=f.MAX;for(const n of e){const s=new f(n);s.before(r)&&(r=s)}return r}static nanoseconds(e){return new f(e)}static microseconds(e){return f.nanoseconds(e*1e3)}static milliseconds(e){return f.microseconds(e*1e3)}static seconds(e){return f.milliseconds(e*1e3)}static minutes(e){return f.seconds(e*60)}static hours(e){return f.minutes(e*60)}static days(e){return f.hours(e*24)}};l(y,"NANOSECOND",y.nanoseconds(1)),l(y,"MICROSECOND",y.microseconds(1)),l(y,"MILLISECOND",y.milliseconds(1)),l(y,"SECOND",y.seconds(1)),l(y,"MINUTE",y.minutes(1)),l(y,"HOUR",y.hours(1)),l(y,"DAY",y.days(1)),l(y,"MAX",new y((1n<<63n)-1n)),l(y,"MIN",new y(0)),l(y,"ZERO",new y(0)),l(y,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(t=>new y(t.value)),i.z.string().transform(t=>new y(BigInt(t))),i.z.instanceof(Number).transform(t=>new y(t)),i.z.number().transform(t=>new y(t)),i.z.instanceof(y)]));let m=y;const g=class p{constructor(e){l(this,"value"),l(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new p(e).valueOf()}greaterThan(e){return this.valueOf()>new p(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new p(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new p(e).valueOf()}remainder(e){return It(this,e)}truncate(e){return new p(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(p.DAY),r=this.truncate(p.HOUR),n=this.truncate(p.MINUTE),s=this.truncate(p.SECOND),a=this.truncate(p.MILLISECOND),u=this.truncate(p.MICROSECOND),c=this.truncate(p.NANOSECOND),h=e,z=r.sub(e),A=n.sub(r),O=s.sub(n),C=a.sub(s),q=u.sub(a),x=c.sub(u);let N="";return h.isZero||(N+=`${h.days}d `),z.isZero||(N+=`${z.hours}h `),A.isZero||(N+=`${A.minutes}m `),O.isZero||(N+=`${O.seconds}s `),C.isZero||(N+=`${C.milliseconds}ms `),q.isZero||(N+=`${q.microseconds}µs `),x.isZero||(N+=`${x.nanoseconds}ns`),N.trim()}get days(){return Number(this.valueOf())/Number(p.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(p.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(p.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(p.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(p.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(p.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new p(e).valueOf()}add(e){return new p(this.valueOf()+new p(e).valueOf())}sub(e){return new p(this.valueOf()-new p(e).valueOf())}static nanoseconds(e=1){return new p(e)}static microseconds(e=1){return p.nanoseconds(e*1e3)}static milliseconds(e=1){return p.microseconds(e*1e3)}static seconds(e=1){return p.milliseconds(e*1e3)}static minutes(e){return p.seconds(e.valueOf()*60)}static hours(e){return p.minutes(e*60)}static days(e){return p.hours(e*24)}};l(g,"NANOSECOND",g.nanoseconds(1)),l(g,"MICROSECOND",g.microseconds(1)),l(g,"MILLISECOND",g.milliseconds(1)),l(g,"SECOND",g.seconds(1)),l(g,"MINUTE",g.minutes(1)),l(g,"HOUR",g.hours(1)),l(g,"DAY",g.days(1)),l(g,"MAX",new g((1n<<63n)-1n)),l(g,"MIN",new g(0)),l(g,"ZERO",new g(0)),l(g,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(t=>new g(t.value)),i.z.string().transform(t=>new g(BigInt(t))),i.z.instanceof(Number).transform(t=>new g(t)),i.z.number().transform(t=>new g(t)),i.z.instanceof(g)]));let T=g;const J=class se extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new se(e).valueOf()}get period(){return T.seconds(1/this.valueOf())}sampleCount(e){return new T(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new I(r).valueOf()}span(e){return T.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/r.valueOf())}static hz(e){return new se(e)}static khz(e){return se.hz(e*1e3)}};l(J,"z",i.z.union([i.z.number().transform(t=>new J(t)),i.z.instanceof(Number).transform(t=>new J(t)),i.z.instanceof(J)]));const w=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new kr(e*this.valueOf())}};l(w,"UNKNOWN",new w(0)),l(w,"BIT128",new w(16)),l(w,"BIT64",new w(8)),l(w,"BIT32",new w(4)),l(w,"BIT16",new w(2)),l(w,"BIT8",new w(1)),l(w,"z",i.z.union([i.z.number().transform(t=>new w(t)),i.z.instanceof(Number).transform(t=>new w(t)),i.z.instanceof(w)]));let I=w;const $=class ie{constructor(e,r){l(this,"start"),l(this,"end"),typeof e=="object"&&"start"in e?(this.start=new m(e.start),this.end=new m(e.end)):(this.start=new m(e),this.end=new m(r))}get span(){return new T(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new ie(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=T.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=m.max(n.start,e.start),a=m.min(n.end,e.end);return a.before(s)?!1:new T(a.sub(s)).greaterThanOrEqual(r)}roughlyEquals(e,r){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}contains(e){return e instanceof ie?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new ie(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}};l($,"MAX",new $(m.MIN,m.MAX)),l($,"MIN",new $(m.MAX,m.MIN)),l($,"ZERO",new $(m.ZERO,m.ZERO)),l($,"z",i.z.union([i.z.object({start:m.z,end:m.z}).transform(t=>new $(t.start,t.end)),i.z.instanceof($)]));let Dr=$;const o=class U extends String{constructor(e){if(e instanceof U||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const r=U.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r!=null){super(r.valueOf());return}}throw super(U.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=U.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(U.JSON)||this.equals(U.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(U.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=U.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return U.BIG_INT_TYPES.some(e=>e.equals(this))}};l(o,"UNKNOWN",new o("unknown")),l(o,"FLOAT64",new o("float64")),l(o,"FLOAT32",new o("float32")),l(o,"INT64",new o("int64")),l(o,"INT32",new o("int32")),l(o,"INT16",new o("int16")),l(o,"INT8",new o("int8")),l(o,"UINT64",new o("uint64")),l(o,"UINT32",new o("uint32")),l(o,"UINT16",new o("uint16")),l(o,"UINT8",new o("uint8")),l(o,"BOOLEAN",o.UINT8),l(o,"TIMESTAMP",new o("timestamp")),l(o,"UUID",new o("uuid")),l(o,"STRING",new o("string")),l(o,"JSON",new o("json")),l(o,"ARRAY_CONSTRUCTORS",new Map([[o.UINT8.toString(),Uint8Array],[o.UINT16.toString(),Uint16Array],[o.UINT32.toString(),Uint32Array],[o.UINT64.toString(),BigUint64Array],[o.FLOAT32.toString(),Float32Array],[o.FLOAT64.toString(),Float64Array],[o.INT8.toString(),Int8Array],[o.INT16.toString(),Int16Array],[o.INT32.toString(),Int32Array],[o.INT64.toString(),BigInt64Array],[o.TIMESTAMP.toString(),BigInt64Array],[o.STRING.toString(),Uint8Array],[o.JSON.toString(),Uint8Array],[o.UUID.toString(),Uint8Array]])),l(o,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,o.UINT8],[Uint16Array.name,o.UINT16],[Uint32Array.name,o.UINT32],[BigUint64Array.name,o.UINT64],[Float32Array.name,o.FLOAT32],[Float64Array.name,o.FLOAT64],[Int8Array.name,o.INT8],[Int16Array.name,o.INT16],[Int32Array.name,o.INT32],[BigInt64Array.name,o.INT64]])),l(o,"DENSITIES",new Map([[o.UINT8.toString(),I.BIT8],[o.UINT16.toString(),I.BIT16],[o.UINT32.toString(),I.BIT32],[o.UINT64.toString(),I.BIT64],[o.FLOAT32.toString(),I.BIT32],[o.FLOAT64.toString(),I.BIT64],[o.INT8.toString(),I.BIT8],[o.INT16.toString(),I.BIT16],[o.INT32.toString(),I.BIT32],[o.INT64.toString(),I.BIT64],[o.TIMESTAMP.toString(),I.BIT64],[o.STRING.toString(),I.UNKNOWN],[o.JSON.toString(),I.UNKNOWN],[o.UUID.toString(),I.BIT128]])),l(o,"ALL",[o.UNKNOWN,o.FLOAT64,o.FLOAT32,o.INT64,o.INT32,o.INT16,o.INT8,o.UINT64,o.UINT32,o.UINT16,o.UINT8,o.TIMESTAMP,o.UUID,o.STRING,o.JSON]),l(o,"BIG_INT_TYPES",[o.INT64,o.UINT64,o.TIMESTAMP]),l(o,"z",i.z.union([i.z.string().transform(t=>new o(t)),i.z.instanceof(o)]));const S=class b extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return b.bytes(this.valueOf()+e.valueOf())}sub(e){return b.bytes(this.valueOf()-e.valueOf())}truncate(e){return new b(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return b.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/b.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/b.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/b.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/b.TERABYTE.valueOf()}toString(){const e=this.truncate(b.TERABYTE),r=this.truncate(b.GIGABYTE),n=this.truncate(b.MEGABYTE),s=this.truncate(b.KILOBYTE),a=this.truncate(b.BYTE),u=e,c=r.sub(e),h=n.sub(r),z=s.sub(n),A=a.sub(s);let O="";return u.isZero||(O+=`${u.terabytes}TB `),c.isZero||(O+=`${c.gigabytes}GB `),h.isZero||(O+=`${h.megabytes}MB `),z.isZero||(O+=`${z.kilobytes}KB `),(!A.isZero||O==="")&&(O+=`${A.valueOf()}B`),O.trim()}static bytes(e=1){return new b(e)}static kilobytes(e=1){return b.bytes(e.valueOf()*1e3)}static megabytes(e=1){return b.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return b.megabytes(e.valueOf()*1e3)}static terabytes(e){return b.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};l(S,"BYTE",new S(1)),l(S,"KILOBYTE",S.kilobytes(1)),l(S,"MEGABYTE",S.megabytes(1)),l(S,"GIGABYTE",S.gigabytes(1)),l(S,"TERABYTE",S.terabytes(1)),l(S,"ZERO",new S(0)),l(S,"z",i.z.union([i.z.number().transform(t=>new S(t)),i.z.instanceof(S)]));let kr=S;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);var Lr=Object.defineProperty,Pr=(t,e,r)=>e in t?Lr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,G=(t,e,r)=>(Pr(t,typeof e!="symbol"?e+"":e,r),r);const Zr=(...t)=>t.map(Nt).join(""),Nt=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Yr=t=>t.endsWith("/")?t.slice(0,-1):t,Kr=(t,e="")=>t===null?"":"?"+Object.entries(t).filter(([,r])=>r==null?!1:Array.isArray(r)?r.length>0:!0).map(([r,n])=>`${e}${r}=${n}`).join("&"),Te=class Se{constructor({host:e,port:r,protocol:n="",pathPrefix:s=""}){G(this,"protocol"),G(this,"host"),G(this,"port"),G(this,"path"),this.protocol=n,this.host=e,this.port=r,this.path=Nt(s)}replace(e){return new Se({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Se({...this,pathPrefix:Zr(this.path,e)})}toString(){return Yr(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};G(Te,"UNKNOWN",new Te({host:"unknown",port:0}));let Vr=Te;var Fr=Object.defineProperty,qr=(t,e,r)=>e in t?Fr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,we=(t,e,r)=>(qr(t,typeof e!="symbol"?e+"":e,r),r);const F=class extends Number{};we(F,"Absolute",255),we(F,"Default",1),we(F,"z",i.z.union([i.z.instanceof(F),i.z.number().int().min(0).max(255).transform(t=>new F(t)),i.z.instanceof(Number).transform(t=>new F(t))]));i.z.object({name:i.z.string(),key:i.z.string()});const Wr=i.z.string().regex(/^\d+\.\d+\.\d+$/);i.z.object({version:Wr});class H extends Error{constructor(r,n){super(r);v(this,"discriminator","FreighterError");v(this,"type");this.type=n}}const Gr=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Ae="unknown",We="nil",he="freighter",ke=i.z.object({type:i.z.string(),data:i.z.string()});class Hr{constructor(){v(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:We,data:""};if(Gr(e))for(const r of this.providers){const n=r.encode(e);if(n!=null)return n}return{type:Ae,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===We)return null;if(e.type===Ae)return new Ge(e.data);for(const r of this.providers){const n=r.decode(e);if(n!=null)return n}return new Ge(e.data)}}const Le=new Hr,zt=({encode:t,decode:e})=>Le.register({encode:t,decode:e}),Xr=t=>Le.encode(t),Pe=t=>Le.decode(t);class Ge extends H{constructor(e){super(e,Ae)}}const pe="freighter.";class Z extends H{constructor(){super("EOF",he)}}v(Z,"TYPE",pe+"eof");class Y extends H{constructor(){super("StreamClosed",he)}}v(Y,"TYPE",pe+"stream_closed");class K extends H{constructor(r={}){const{message:n="Unreachable",url:s=Vr.UNKNOWN}=r;super(n,he);v(this,"url");this.url=s}}v(K,"TYPE",pe+"unreachable");const Jr=t=>{if(t.type!==he)return null;if(t instanceof Z)return{type:Z.TYPE,data:"EOF"};if(t instanceof Y)return{type:Y.TYPE,data:"StreamClosed"};if(t instanceof K)return{type:K.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},Qr=t=>{if(!t.type.startsWith(pe))return null;switch(t.type){case Z.TYPE:return new Z;case Y.TYPE:return new Y;case K.TYPE:return new K;default:throw new Error(`Unknown error type: ${t.data}`)}};zt({encode:Jr,decode:Qr});class Et{constructor(){v(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,r){let n=0;const s=async a=>{if(n===this.middleware.length)return await r(a);const u=this.middleware[n];return n++,await u(a,s)};return await s(e)}}const Ct="Content-Type",He=t=>{if(At.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const r=require("https"),n=new r.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class _r extends Et{constructor(r,n,s=!1){super();v(this,"endpoint");v(this,"encoder");v(this,"fetch");return this.endpoint=r.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=He(this.endpoint.protocol),new Proxy(this,{get:(a,u,c)=>u==="endpoint"?this.endpoint:Reflect.get(a,u,c)})}get headers(){return{[Ct]:this.encoder.contentType}}async send(r,n,s,a){n=s==null?void 0:s.parse(n);let u=null;const c=this.endpoint.child(r),h={};h.method="POST",h.body=this.encoder.encode(n??{});const[,z]=await this.executeMiddleware({target:c.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async A=>{const O={...A,params:{}};h.headers={...this.headers,...A.params};let C;try{C=await He(A.protocol)(A.target,h)}catch(x){let N=x;return N.message==="Load failed"&&(N=new K({url:c})),[O,N]}const q=await C.arrayBuffer();if(C!=null&&C.ok)return a!=null&&(u=this.encoder.decode(q,a)),[O,null];try{if(C.status!==400)return[O,new Error(C.statusText)];const x=this.encoder.decode(q,ke),N=Pe(x);return[O,N]}catch(x){return[O,new Error(`[freighter] - failed to decode error: ${C.statusText}: ${x.message}`)]}});return[u,z]}}const en=async(t,e,r,n,s)=>{const[a,u]=await t.send(e,r,n,s);if(u!=null)throw u;return a},tn=()=>At.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),rn=i.z.object({type:i.z.union([i.z.literal("data"),i.z.literal("close")]),payload:i.z.unknown().optional(),error:i.z.optional(ke)});class nn{constructor(e,r,n,s){v(this,"encoder");v(this,"reqSchema");v(this,"resSchema");v(this,"ws");v(this,"serverClosed");v(this,"sendClosed");v(this,"receiveDataQueue",[]);v(this,"receiveCallbacksQueue",[]);this.encoder=r,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Z;if(this.sendClosed)throw new Y;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Pe(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((r,n)=>this.receiveCallbacksQueue.push({resolve:r,reject:n}))}addMessage(e){const r=this.receiveCallbacksQueue.shift();r!=null?r.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,rn)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:ln(e)?Z.TYPE:Y.TYPE,data:""}})}}const sn="freighterctx",an=1e3,on=1001,un=[an,on],ln=t=>un.includes(t.code),oe=class oe extends Et{constructor(r,n,s=!1){super();v(this,"baseUrl");v(this,"encoder");this.baseUrl=r.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(r,n,s){const a=tn();let u;const[,c]=await this.executeMiddleware({target:r,protocol:"websocket",params:{},role:"client"},async h=>{const z=a(this.buildURL(r,h)),A={...h,params:{}};z.binaryType=oe.MESSAGE_TYPE;const O=await this.wrapSocket(z,n,s);return O instanceof Error?[A,O]:(u=O,[A,null])});if(c!=null)throw c;return u}buildURL(r,n){const s=Kr({[Ct]:this.encoder.contentType,...n.params},sn);return this.baseUrl.child(r).toString()+s}async wrapSocket(r,n,s){return await new Promise(a=>{r.onopen=()=>{a(new nn(r,this.encoder,n,s))},r.onerror=u=>{const c=u;a(new Error(c.message))}})}};v(oe,"MESSAGE_TYPE","arraybuffer");let Ie=oe;exports.BaseTypedError=H;exports.EOF=Z;exports.HTTPClient=_r;exports.StreamClosed=Y;exports.Unreachable=K;exports.WebSocketClient=Ie;exports.decodeError=Pe;exports.encodeError=Xr;exports.errorZ=ke;exports.registerError=zt;exports.sendRequired=en;