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