@synnaxlabs/client 0.21.0 → 0.22.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/.turbo/turbo-build.log +7 -7
- package/.vscode/settings.json +3 -0
- package/dist/auth/auth.d.ts +7 -6
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +14 -11
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/creator.d.ts +10 -0
- package/dist/channel/creator.d.ts.map +1 -0
- package/dist/channel/payload.d.ts +6 -2
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +65 -35
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +4 -3
- package/dist/client.cjs +18 -21
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +12 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6546 -6457
- package/dist/client.js.map +1 -1
- package/dist/connection/checker.d.ts +4 -3
- package/dist/connection/checker.d.ts.map +1 -1
- package/dist/control/authority.d.ts +2 -1
- package/dist/control/state.d.ts +6 -4
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +24 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +5 -4
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +10 -9
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +13 -12
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/iterator.d.ts +5 -4
- package/dist/framer/iterator.d.ts.map +1 -1
- package/dist/framer/streamProxy.d.ts +3 -2
- package/dist/framer/streamProxy.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +13 -4
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +42 -33
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/client.d.ts +4 -3
- package/dist/hardware/device/client.d.ts +107 -14
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/external.d.ts +0 -2
- package/dist/hardware/device/external.d.ts.map +1 -1
- package/dist/hardware/device/index.d.ts +1 -1
- package/dist/hardware/device/index.d.ts.map +1 -1
- package/dist/hardware/rack/client.d.ts +43 -20
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/external.d.ts +0 -2
- package/dist/hardware/rack/external.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +197 -14
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/index.d.ts +1 -1
- package/dist/hardware/task/index.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/label/client.d.ts +8 -6
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/payload.d.ts +2 -1
- package/dist/label/retriever.d.ts +3 -2
- package/dist/label/writer.d.ts +4 -3
- package/dist/ontology/client.d.ts +82 -14
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/external.d.ts +0 -1
- package/dist/ontology/external.d.ts.map +1 -1
- package/dist/ontology/group/client.d.ts +3 -2
- package/dist/ontology/group/client.d.ts.map +1 -1
- package/dist/ontology/group/group.d.ts +1 -0
- package/dist/ontology/group/payload.d.ts +2 -1
- package/dist/ontology/group/writer.d.ts +4 -3
- package/dist/ontology/payload.d.ts +71 -60
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts +3 -2
- package/dist/ranger/active.d.ts +3 -2
- package/dist/ranger/alias.d.ts +7 -6
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +162 -11
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/external.d.ts +0 -1
- package/dist/ranger/external.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts +5 -3
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +57 -50
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/range.d.ts +12 -10
- package/dist/ranger/range.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +3 -2
- package/dist/setupspecs.d.ts +2 -1
- package/dist/signals/observable.d.ts +8 -15
- package/dist/signals/observable.d.ts.map +1 -1
- package/dist/transport.d.ts +3 -2
- package/dist/transport.d.ts.map +1 -1
- package/dist/user/payload.d.ts +2 -1
- package/dist/util/retrieve.d.ts +24 -0
- package/dist/util/retrieve.d.ts.map +1 -0
- package/dist/util/retrieve.spec.d.ts +2 -0
- package/dist/util/retrieve.spec.d.ts.map +1 -0
- package/dist/util/telem.d.ts +2 -1
- package/dist/util/telem.d.ts.map +1 -1
- package/dist/util/zod.d.ts +4 -0
- package/dist/util/zod.d.ts.map +1 -0
- package/dist/workspace/client.d.ts +9 -6
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +6 -5
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +3 -2
- package/dist/workspace/lineplot/payload.d.ts.map +1 -1
- package/dist/workspace/lineplot/retriever.d.ts +3 -2
- package/dist/workspace/lineplot/retriever.d.ts.map +1 -1
- package/dist/workspace/lineplot/writer.d.ts +7 -6
- package/dist/workspace/lineplot/writer.d.ts.map +1 -1
- package/dist/workspace/payload.d.ts +3 -2
- package/dist/workspace/payload.d.ts.map +1 -1
- package/dist/workspace/retriever.d.ts +3 -2
- package/dist/workspace/schematic/client.d.ts +18 -0
- package/dist/workspace/schematic/client.d.ts.map +1 -0
- package/dist/workspace/schematic/external.d.ts.map +1 -0
- package/dist/workspace/schematic/index.d.ts +2 -0
- package/dist/workspace/schematic/index.d.ts.map +1 -0
- package/dist/workspace/{pid → schematic}/payload.d.ts +6 -5
- package/dist/workspace/schematic/payload.d.ts.map +1 -0
- package/dist/workspace/schematic/retriever.d.ts +10 -0
- package/dist/workspace/schematic/retriever.d.ts.map +1 -0
- package/dist/workspace/schematic/schematic.spec.d.ts +2 -0
- package/dist/workspace/schematic/schematic.spec.d.ts.map +1 -0
- package/dist/workspace/{pid → schematic}/writer.d.ts +11 -10
- package/dist/workspace/schematic/writer.d.ts.map +1 -0
- package/dist/workspace/writer.d.ts +5 -4
- package/dist/workspace/writer.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/auth/auth.spec.ts +55 -15
- package/src/auth/auth.ts +41 -42
- package/src/channel/batchRetriever.spec.ts +37 -40
- package/src/channel/channel.spec.ts +4 -4
- package/src/channel/client.ts +42 -49
- package/src/channel/creator.ts +37 -0
- package/src/channel/payload.ts +2 -1
- package/src/channel/retriever.ts +55 -71
- package/src/client.ts +23 -20
- package/src/connection/checker.ts +1 -1
- package/src/connection/connection.spec.ts +1 -6
- package/src/control/state.ts +3 -1
- package/src/errors.ts +71 -67
- package/src/framer/adapter.spec.ts +33 -1
- package/src/framer/adapter.ts +10 -6
- package/src/framer/client.ts +11 -9
- package/src/framer/frame.spec.ts +1 -1
- package/src/framer/frame.ts +9 -6
- package/src/framer/iterator.spec.ts +1 -1
- package/src/framer/iterator.ts +1 -1
- package/src/framer/streamProxy.ts +12 -13
- package/src/framer/streamer.spec.ts +1 -1
- package/src/framer/streamer.ts +25 -1
- package/src/framer/writer.spec.ts +23 -11
- package/src/framer/writer.ts +6 -6
- package/src/hardware/device/client.ts +155 -28
- package/src/hardware/device/device.spec.ts +2 -2
- package/src/hardware/device/external.ts +0 -2
- package/src/hardware/device/index.ts +2 -2
- package/src/hardware/rack/client.ts +139 -56
- package/src/hardware/rack/external.ts +0 -2
- package/src/hardware/rack/rack.spec.ts +20 -1
- package/src/hardware/task/client.ts +324 -31
- package/src/hardware/task/index.ts +1 -1
- package/src/hardware/task/task.spec.ts +41 -0
- package/src/index.ts +3 -4
- package/src/label/client.ts +3 -2
- package/src/label/retriever.ts +1 -1
- package/src/label/writer.ts +1 -1
- package/src/ontology/client.ts +195 -41
- package/src/ontology/external.ts +0 -1
- package/src/ontology/group/client.ts +1 -2
- package/src/ontology/group/payload.ts +1 -1
- package/src/ontology/ontology.spec.ts +16 -0
- package/src/ontology/payload.ts +22 -13
- package/src/ranger/active.ts +5 -5
- package/src/ranger/alias.ts +2 -2
- package/src/ranger/client.ts +68 -17
- package/src/ranger/external.ts +0 -1
- package/src/ranger/kv.ts +6 -1
- package/src/ranger/payload.ts +6 -4
- package/src/ranger/range.ts +4 -1
- package/src/ranger/ranger.spec.ts +24 -2
- package/src/signals/observable.ts +24 -63
- package/src/transport.ts +2 -1
- package/src/util/retrieve.spec.ts +56 -0
- package/src/util/retrieve.ts +103 -0
- package/src/util/telem.ts +1 -1
- package/src/util/zod.ts +4 -0
- package/src/workspace/client.ts +6 -4
- package/src/workspace/lineplot/client.ts +3 -3
- package/src/workspace/lineplot/linePlot.spec.ts +11 -11
- package/src/workspace/lineplot/payload.ts +1 -1
- package/src/workspace/lineplot/retriever.ts +5 -13
- package/src/workspace/lineplot/writer.ts +8 -7
- package/src/workspace/payload.ts +6 -3
- package/src/workspace/retriever.ts +1 -1
- package/src/workspace/{pid → schematic}/client.ts +10 -10
- package/src/workspace/{pid → schematic}/external.ts +2 -2
- package/src/workspace/{pid → schematic}/index.ts +1 -1
- package/src/workspace/{pid → schematic}/payload.ts +4 -4
- package/src/workspace/{pid → schematic}/retriever.ts +10 -10
- package/src/workspace/{pid/pid.spec.ts → schematic/schematic.spec.ts} +35 -35
- package/src/workspace/{pid → schematic}/writer.ts +26 -25
- package/src/workspace/workspace.spec.ts +7 -7
- package/src/workspace/writer.ts +8 -2
- package/dist/hardware/device/payload.d.ts +0 -30
- package/dist/hardware/device/payload.d.ts.map +0 -1
- package/dist/hardware/device/retriever.d.ts +0 -10
- package/dist/hardware/device/retriever.d.ts.map +0 -1
- package/dist/hardware/device/writer.d.ts +0 -9
- package/dist/hardware/device/writer.d.ts.map +0 -1
- package/dist/hardware/rack/payload.d.ts +0 -26
- package/dist/hardware/rack/payload.d.ts.map +0 -1
- package/dist/hardware/rack/retriever.d.ts +0 -10
- package/dist/hardware/rack/retriever.d.ts.map +0 -1
- package/dist/hardware/rack/writer.d.ts +0 -9
- package/dist/hardware/rack/writer.d.ts.map +0 -1
- package/dist/hardware/task/external.d.ts +0 -4
- package/dist/hardware/task/external.d.ts.map +0 -1
- package/dist/hardware/task/payload.d.ts +0 -42
- package/dist/hardware/task/payload.d.ts.map +0 -1
- package/dist/hardware/task/retriever.d.ts +0 -29
- package/dist/hardware/task/retriever.d.ts.map +0 -1
- package/dist/hardware/task/writer.d.ts +0 -9
- package/dist/hardware/task/writer.d.ts.map +0 -1
- package/dist/ontology/retriever.d.ts +0 -13
- package/dist/ontology/retriever.d.ts.map +0 -1
- package/dist/ontology/signals.d.ts +0 -30
- package/dist/ontology/signals.d.ts.map +0 -1
- package/dist/ranger/retriever.d.ts +0 -11
- package/dist/ranger/retriever.d.ts.map +0 -1
- package/dist/workspace/pid/client.d.ts +0 -17
- package/dist/workspace/pid/client.d.ts.map +0 -1
- package/dist/workspace/pid/external.d.ts.map +0 -1
- package/dist/workspace/pid/index.d.ts +0 -2
- package/dist/workspace/pid/index.d.ts.map +0 -1
- package/dist/workspace/pid/payload.d.ts.map +0 -1
- package/dist/workspace/pid/pid.spec.d.ts +0 -2
- package/dist/workspace/pid/pid.spec.d.ts.map +0 -1
- package/dist/workspace/pid/retriever.d.ts +0 -9
- package/dist/workspace/pid/retriever.d.ts.map +0 -1
- package/dist/workspace/pid/writer.d.ts.map +0 -1
- package/src/hardware/device/payload.ts +0 -27
- package/src/hardware/device/retriever.ts +0 -71
- package/src/hardware/device/writer.ts +0 -59
- package/src/hardware/rack/payload.ts +0 -26
- package/src/hardware/rack/retriever.ts +0 -68
- package/src/hardware/rack/writer.ts +0 -59
- package/src/hardware/task/external.ts +0 -12
- package/src/hardware/task/payload.ts +0 -40
- package/src/hardware/task/retriever.ts +0 -70
- package/src/hardware/task/writer.ts +0 -65
- package/src/ontology/retriever.ts +0 -91
- package/src/ontology/signals.ts +0 -136
- package/src/ranger/retriever.ts +0 -50
- /package/dist/workspace/{pid → schematic}/external.d.ts +0 -0
package/dist/client.cjs
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
"use strict";var Zl=Object.defineProperty;var Il=(r,e,t)=>e in r?Zl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>(Il(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod");var Al=Object.defineProperty,Cl=(r,e,t)=>e in r?Al(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fe=(r,e,t)=>(Cl(r,typeof e!="symbol"?e+"":e,t),t),$l=Object.defineProperty,jl=(r,e,t)=>e in r?$l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,b=(r,e,t)=>(jl(r,typeof e!="symbol"?e+"":e,t),t),J;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(J||(J={}));var Aa;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Aa||(Aa={}));const T=J.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zt=r=>{switch(typeof r){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(r)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(r)?T.array:r===null?T.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?T.promise:typeof Map<"u"&&r instanceof Map?T.map:typeof Set<"u"&&r instanceof Set?T.set:typeof Date<"u"&&r instanceof Date?T.date:T.object;default:return T.unknown}},v=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"]),Rl=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let qe=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return n(this),s}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={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};qe.create=r=>new qe(r);const $r=(r,e)=>{let t;switch(r.code){case v.invalid_type:r.received===T.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,J.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${J.joinValues(r.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${J.joinValues(r.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${J.joinValues(r.options)}, received '${r.received}'`;break;case v.invalid_arguments:t="Invalid function arguments";break;case v.invalid_return_type:t="Invalid function return type";break;case v.invalid_date:t="Invalid date";break;case v.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 v.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 v.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 v.custom:t="Invalid input";break;case v.invalid_intersection_types:t="Intersection results could not be merged";break;case v.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case v.not_finite:t="Number must be finite";break;default:t=e.defaultError,J.assertNever(r)}return{message:t}};let Ao=$r;function zl(r){Ao=r}function cn(){return Ao}const un=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const u=s.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Pl=[];function N(r,e){const t=un({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,cn(),$r].filter(s=>!!s)});r.common.issues.push(t)}let $e=class Co{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return M;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Co.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return M;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}};const M=Object.freeze({status:"aborted"}),$o=r=>({status:"dirty",value:r}),Ie=r=>({status:"valid",value:r}),Ca=r=>r.status==="aborted",$a=r=>r.status==="dirty",jr=r=>r.status==="valid",ln=r=>typeof Promise<"u"&&r instanceof Promise;var Z;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Z||(Z={}));let at=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 to=(r,e)=>{if(jr(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 qe(r.common.issues);return this._error=t,this._error}}};function U(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}let q=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 zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ln(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return to(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={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:zt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ln(n)?n:Promise.resolve(n));return to(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:v.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Ge({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Nt.create(this,this._def)}nullable(){return Qt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this,this._def)}promise(){return _r.create(this,this._def)}or(e){return Ur.create([this,e],this._def)}and(e){return Br.create(this,e,this._def)}transform(e){return new Ge({...U(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Wr({...U(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Do({typeName:$.ZodBranded,type:this,...U(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new mn({...U(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ni.create(this,e)}readonly(){return gn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Ml=/^c[^\s-]{8,}$/i,Dl=/^[a-z][a-z0-9]*$/,Ll=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ul=/^[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,Bl=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Vl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let la;const ql=/^(((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}))$/,Kl=/^(([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})))$/,Wl=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 Fl(r,e){return!!((e==="v4"||!e)&&ql.test(r)||(e==="v6"||!e)&&Kl.test(r))}class Ue extends q{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.string,received:n.parsedType}),M}const t=new $e;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Bl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")la||(la=new RegExp(Vl,"u")),la.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Ul.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Ml.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Dl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Ll.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:v.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:v.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Wl(n).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Fl(e.data,n.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:v.invalid_string,message:n.message}),t.dirty()):J.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:v.invalid_string,...Z.errToObj(s)})}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.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,...Z.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Z.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new Ue({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ue({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ue({...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}}Ue.create=r=>{var e;return new Ue({checks:[],typeName:$.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};function Yl(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}let Rr=class ja extends q{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)!==T.number){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.number,received:n.parsedType}),M}let t;const s=new $e;for(const n of this._def.checks)n.kind==="int"?J.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Yl(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_finite,message:n.message}),s.dirty()):J.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new ja({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new ja({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.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 s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Rr.create=r=>new Rr({checks:[],typeName:$.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let zr=class Ra extends q{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)!==T.bigint){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.bigint,received:n.parsedType}),M}let t;const s=new $e;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):J.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new Ra({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new Ra({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.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}};zr.create=r=>{var e;return new zr({checks:[],typeName:$.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};class Pr extends q{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.boolean,received:t.parsedType}),M}return Ie(e.data)}}Pr.create=r=>new Pr({typeName:$.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let Mr=class jo extends q{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.date,received:n.parsedType}),M}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_date}),M}const t=new $e;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):J.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Z.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}};Mr.create=r=>new Mr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:$.ZodDate,...U(r)});let dn=class extends q{_parse(e){if(this._getType(e)!==T.symbol){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.symbol,received:t.parsedType}),M}return Ie(e.data)}};dn.create=r=>new dn({typeName:$.ZodSymbol,...U(r)});class Dr extends q{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.undefined,received:t.parsedType}),M}return Ie(e.data)}}Dr.create=r=>new Dr({typeName:$.ZodUndefined,...U(r)});class Lr extends q{_parse(e){if(this._getType(e)!==T.null){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.null,received:t.parsedType}),M}return Ie(e.data)}}Lr.create=r=>new Lr({typeName:$.ZodNull,...U(r)});let wr=class extends q{constructor(){super(...arguments),this._any=!0}_parse(e){return Ie(e.data)}};wr.create=r=>new wr({typeName:$.ZodAny,...U(r)});let Yt=class extends q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ie(e.data)}};Yt.create=r=>new Yt({typeName:$.ZodUnknown,...U(r)});class Zt extends q{_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.never,received:t.parsedType}),M}}Zt.create=r=>new Zt({typeName:$.ZodNever,...U(r)});class hn extends q{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.void,received:t.parsedType}),M}return Ie(e.data)}}hn.create=r=>new hn({typeName:$.ZodVoid,...U(r)});let Xt=class Ps extends q{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==T.array)return N(t,{code:v.invalid_type,expected:T.array,received:t.parsedType}),M;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(N(t,{code:i?v.too_big:v.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(N(t,{code:v.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(N(t,{code:v.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new at(t,i,t.path,o)))).then(i=>$e.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new at(t,i,t.path,o)));return $e.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ps({...this._def,minLength:{value:e,message:Z.toString(t)}})}max(e,t){return new Ps({...this._def,maxLength:{value:e,message:Z.toString(t)}})}length(e,t){return new Ps({...this._def,exactLength:{value:e,message:Z.toString(t)}})}nonempty(e){return this.min(1,e)}};Xt.create=(r,e)=>new Xt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...U(e)});function dr(r){if(r instanceof Pe){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Nt.create(dr(s))}return new Pe({...r._def,shape:()=>e})}else return r instanceof Xt?new Xt({...r._def,type:dr(r.element)}):r instanceof Nt?Nt.create(dr(r.unwrap())):r instanceof Qt?Qt.create(dr(r.unwrap())):r instanceof Dt?Dt.create(r.items.map(e=>dr(e))):r}let Pe=class Le extends q{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)!==T.object){const u=this._getOrReturnCtx(e);return N(u,{code:v.invalid_type,expected:T.object,received:u.parsedType}),M}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Zt&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=n[u],h=s.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new at(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Zt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(N(s,{code:v.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 l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new at(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>$e.mergeObjectSync(t,u)):$e.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new Le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const u=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=Z.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Le({...this._def,unknownKeys:"strip"})}passthrough(){return new Le({...this._def,unknownKeys:"passthrough"})}extend(e){return new Le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Le({...this._def,catchall:e})}pick(e){const t={};return J.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new Le({...this._def,shape:()=>t})}omit(e){const t={};return J.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new Le({...this._def,shape:()=>t})}deepPartial(){return dr(this)}partial(e){const t={};return J.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new Le({...this._def,shape:()=>t})}required(e){const t={};return J.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Nt;)n=n._def.innerType;t[s]=n}}),new Le({...this._def,shape:()=>t})}keyof(){return Mo(J.objectKeys(this.shape))}};Pe.create=(r,e)=>new Pe({shape:()=>r,unknownKeys:"strip",catchall:Zt.create(),typeName:$.ZodObject,...U(e)});Pe.strictCreate=(r,e)=>new Pe({shape:()=>r,unknownKeys:"strict",catchall:Zt.create(),typeName:$.ZodObject,...U(e)});Pe.lazycreate=(r,e)=>new Pe({shape:r,unknownKeys:"strip",catchall:Zt.create(),typeName:$.ZodObject,...U(e)});class Ur extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(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 qe(o.ctx.common.issues));return N(t,{code:v.invalid_union,unionErrors:i}),M}if(t.common.async)return Promise.all(s.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(n);{let a;const i=[];for(const u of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new qe(u));return N(t,{code:v.invalid_union,unionErrors:o}),M}}get options(){return this._def.options}}Ur.create=(r,e)=>new Ur({options:r,typeName:$.ZodUnion,...U(e)});const Ms=r=>r instanceof Vr?Ms(r.schema):r instanceof Ge?Ms(r.innerType()):r instanceof qr?[r.value]:r instanceof xs?r.options:r instanceof Kr?Object.keys(r.enum):r instanceof Wr?Ms(r._def.innerType):r instanceof Dr?[void 0]:r instanceof Lr?[null]:null;class Wn extends q{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return N(t,{code:v.invalid_type,expected:T.object,received:t.parsedType}),M;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);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}):(N(t,{code:v.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),M)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Ms(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(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Wn({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...U(s)})}}function za(r,e){const t=zt(r),s=zt(e);if(r===e)return{valid:!0,data:r};if(t===T.object&&s===T.object){const n=J.objectKeys(e),a=J.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=za(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===T.array&&s===T.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=za(i,o);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return t===T.date&&s===T.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Br=class extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ca(a)||Ca(i))return M;const o=za(a.value,i.value);return o.valid?(($a(a)||$a(i))&&t.dirty(),{status:t.value,value:o.data}):(N(s,{code:v.invalid_intersection_types}),M)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Br.create=(r,e,t)=>new Br({left:r,right:e,typeName:$.ZodIntersection,...U(t)});let Dt=class Ro extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.array)return N(s,{code:v.invalid_type,expected:T.array,received:s.parsedType}),M;if(s.data.length<this._def.items.length)return N(s,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&s.data.length>this._def.items.length&&(N(s,{code:v.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new at(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>$e.mergeArray(t,a)):$e.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Ro({...this._def,rest:e})}};Dt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Dt({items:r,typeName:$.ZodTuple,rest:null,...U(e)})};let zo=class Pa extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.object)return N(s,{code:v.invalid_type,expected:T.object,received:s.parsedType}),M;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new at(s,o,s.path,o)),value:i._parse(new at(s,s.data[o],s.path,o))});return s.common.async?$e.mergeObjectAsync(t,n):$e.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof q?new Pa({keyType:e,valueType:t,typeName:$.ZodRecord,...U(s)}):new Pa({keyType:Ue.create(),valueType:e,typeName:$.ZodRecord,...U(t)})}},pn=class extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.map)return N(s,{code:v.invalid_type,expected:T.map,received:s.parsedType}),M;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,u],l)=>({key:n._parse(new at(s,o,s.path,[l,"key"])),value:a._parse(new at(s,u,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};pn.create=(r,e,t)=>new pn({valueType:e,keyType:r,typeName:$.ZodMap,...U(t)});let fn=class Ma extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.set)return N(s,{code:v.invalid_type,expected:T.set,received:s.parsedType}),M;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(N(s,{code:v.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(N(s,{code:v.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return M;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((u,l)=>a._parse(new at(s,u,s.path,l)));return s.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Ma({...this._def,minSize:{value:e,message:Z.toString(t)}})}max(e,t){return new Ma({...this._def,maxSize:{value:e,message:Z.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};fn.create=(r,e)=>new fn({valueType:r,minSize:null,maxSize:null,typeName:$.ZodSet,...U(e)});let Po=class Ds extends q{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return N(t,{code:v.invalid_type,expected:T.function,received:t.parsedType}),M;function s(o,u){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),$r].filter(l=>!!l),issueData:{code:v.invalid_arguments,argumentsError:u}})}function n(o,u){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),$r].filter(l=>!!l),issueData:{code:v.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof _r){const o=this;return Ie(async function(...u){const l=new qe([]),h=await o._def.args.parseAsync(u,a).catch(Q=>{throw l.addIssue(s(u,Q)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(Q=>{throw l.addIssue(n(k,Q)),l})})}else{const o=this;return Ie(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new qe([s(u,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new qe([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ds({...this._def,args:Dt.create(e).rest(Yt.create())})}returns(e){return new Ds({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Ds({args:e||Dt.create([]).rest(Yt.create()),returns:t||Yt.create(),typeName:$.ZodFunction,...U(s)})}},Vr=class extends q{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})}};Vr.create=(r,e)=>new Vr({getter:r,typeName:$.ZodLazy,...U(e)});class qr extends q{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:e.data}}get value(){return this._def.value}}qr.create=(r,e)=>new qr({value:r,typeName:$.ZodLiteral,...U(e)});function Mo(r,e){return new xs({values:r,typeName:$.ZodEnum,...U(e)})}let xs=class Da extends q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{expected:J.joinValues(s),received:t.parsedType,code:v.invalid_type}),M}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{received:t.data,code:v.invalid_enum_value,options:s}),M}return Ie(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 Da.create(e)}exclude(e){return Da.create(this.options.filter(t=>!e.includes(t)))}};xs.create=Mo;let Kr=class extends q{_parse(e){const t=J.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==T.string&&s.parsedType!==T.number){const n=J.objectValues(t);return N(s,{expected:J.joinValues(n),received:s.parsedType,code:v.invalid_type}),M}if(t.indexOf(e.data)===-1){const n=J.objectValues(t);return N(s,{received:s.data,code:v.invalid_enum_value,options:n}),M}return Ie(e.data)}get enum(){return this._def.values}};Kr.create=(r,e)=>new Kr({values:r,typeName:$.ZodNativeEnum,...U(e)});let _r=class extends q{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return N(t,{code:v.invalid_type,expected:T.promise,received:t.parsedType}),M;const s=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return Ie(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};_r.create=(r,e)=>new _r({type:r,typeName:$.ZodPromise,...U(e)});let Ge=class extends q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{N(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const u=n.refinement(o,a);if(s.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(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!jr(i))return i;const o=n.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:s.data,path:s.path,parent:s}).then(i=>jr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);J.assertNever(n)}};Ge.create=(r,e,t)=>new Ge({schema:r,typeName:$.ZodEffects,effect:e,...U(t)});Ge.createWithPreprocess=(r,e,t)=>new Ge({schema:e,effect:{type:"preprocess",transform:r},typeName:$.ZodEffects,...U(t)});let Nt=class extends q{_parse(e){return this._getType(e)===T.undefined?Ie(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Nt.create=(r,e)=>new Nt({innerType:r,typeName:$.ZodOptional,...U(e)});let Qt=class extends q{_parse(e){return this._getType(e)===T.null?Ie(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(r,e)=>new Qt({innerType:r,typeName:$.ZodNullable,...U(e)});let Wr=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===T.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Wr.create=(r,e)=>new Wr({innerType:r,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...U(e)});let mn=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ln(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qe(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new qe(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};mn.create=(r,e)=>new mn({innerType:r,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...U(e)});let yn=class extends q{_parse(e){if(this._getType(e)!==T.nan){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.nan,received:t.parsedType}),M}return{status:"valid",value:e.data}}};yn.create=r=>new yn({typeName:$.ZodNaN,...U(r)});const Gl=Symbol("zod_brand");let Do=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},ni=class Lo extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),$o(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Lo({in:e,out:t,typeName:$.ZodPipeline})}};class gn extends q{_parse(e){const t=this._def.innerType._parse(e);return jr(t)&&(t.value=Object.freeze(t.value)),t}}gn.create=(r,e)=>new gn({innerType:r,typeName:$.ZodReadonly,...U(e)});const Uo=(r,e={},t)=>r?wr.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:u})}}):wr.create(),Jl={object:Pe.lazycreate};var $;(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"})($||($={}));const Hl=(r,e={message:`Input not instance of ${r.name}`})=>Uo(t=>t instanceof r,e),Bo=Ue.create,Vo=Rr.create,Xl=yn.create,Ql=zr.create,qo=Pr.create,ed=Mr.create,td=dn.create,rd=Dr.create,sd=Lr.create,nd=wr.create,ad=Yt.create,id=Zt.create,od=hn.create,cd=Xt.create,ud=Pe.create,ld=Pe.strictCreate,dd=Ur.create,hd=Wn.create,pd=Br.create,fd=Dt.create,md=zo.create,yd=pn.create,gd=fn.create,vd=Po.create,wd=Vr.create,_d=qr.create,bd=xs.create,kd=Kr.create,Td=_r.create,ro=Ge.create,Od=Nt.create,xd=Qt.create,Nd=Ge.createWithPreprocess,Sd=ni.create,Ed=()=>Bo().optional(),Zd=()=>Vo().optional(),Id=()=>qo().optional(),Ad={string:r=>Ue.create({...r,coerce:!0}),number:r=>Rr.create({...r,coerce:!0}),boolean:r=>Pr.create({...r,coerce:!0}),bigint:r=>zr.create({...r,coerce:!0}),date:r=>Mr.create({...r,coerce:!0})},Cd=M;var f=Object.freeze({__proto__:null,defaultErrorMap:$r,setErrorMap:zl,getErrorMap:cn,makeIssue:un,EMPTY_PATH:Pl,addIssueToContext:N,ParseStatus:$e,INVALID:M,DIRTY:$o,OK:Ie,isAborted:Ca,isDirty:$a,isValid:jr,isAsync:ln,get util(){return J},get objectUtil(){return Aa},ZodParsedType:T,getParsedType:zt,ZodType:q,ZodString:Ue,ZodNumber:Rr,ZodBigInt:zr,ZodBoolean:Pr,ZodDate:Mr,ZodSymbol:dn,ZodUndefined:Dr,ZodNull:Lr,ZodAny:wr,ZodUnknown:Yt,ZodNever:Zt,ZodVoid:hn,ZodArray:Xt,ZodObject:Pe,ZodUnion:Ur,ZodDiscriminatedUnion:Wn,ZodIntersection:Br,ZodTuple:Dt,ZodRecord:zo,ZodMap:pn,ZodSet:fn,ZodFunction:Po,ZodLazy:Vr,ZodLiteral:qr,ZodEnum:xs,ZodNativeEnum:Kr,ZodPromise:_r,ZodEffects:Ge,ZodTransformer:Ge,ZodOptional:Nt,ZodNullable:Qt,ZodDefault:Wr,ZodCatch:mn,ZodNaN:yn,BRAND:Gl,ZodBranded:Do,ZodPipeline:ni,ZodReadonly:gn,custom:Uo,Schema:q,ZodSchema:q,late:Jl,get ZodFirstPartyTypeKind(){return $},coerce:Ad,any:nd,array:cd,bigint:Ql,boolean:qo,date:ed,discriminatedUnion:hd,effect:ro,enum:bd,function:vd,instanceof:Hl,intersection:pd,lazy:wd,literal:_d,map:yd,nan:Xl,nativeEnum:kd,never:id,null:sd,nullable:xd,number:Vo,object:ud,oboolean:Id,onumber:Zd,optional:Od,ostring:Ed,pipeline:Sd,preprocess:Nd,promise:Td,record:md,set:gd,strictObject:ld,string:Bo,symbol:td,transformer:ro,tuple:fd,undefined:rd,union:dd,unknown:ad,void:od,NEVER:Cd,ZodIssueCode:v,quotelessJson:Rl,ZodError:qe});const ai=f.tuple([f.number(),f.number()]),Ko=f.object({width:f.number(),height:f.number()}),$d=f.object({signedWidth:f.number(),signedHeight:f.number()}),jd=["width","height"];f.enum(jd);const Rd=["start","center","end"],zd=["signedWidth","signedHeight"];f.enum(zd);const vn=f.object({x:f.number(),y:f.number()}),Pd=f.object({clientX:f.number(),clientY:f.number()}),Md=["x","y"],Wo=f.enum(Md),Fo=["top","right","bottom","left"];f.enum(Fo);const Dd=["left","right"],Yo=f.enum(Dd),Ld=["top","bottom"],Go=f.enum(Ld),Jo=["center"],so=f.enum(Jo),Ud=[...Fo,...Jo],Ho=f.enum(Ud);f.enum(Rd);const Bd=["first","last"];f.enum(Bd);const Vd=f.object({lower:f.number(),upper:f.number()});f.union([Vd,ai]);f.union([Wo,Ho]);f.union([Wo,Ho,f.instanceof(String)]);const da=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),qd(t)},qd=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});function Kd(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,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}Fn.default=Kd;var Yn={};Object.defineProperty(Yn,"__esModule",{value:!0});function Wd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Yn.default=Wd;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});function Fd(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,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}Gn.default=Fd;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});function Yd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}ii.default=Yd;var oi={};Object.defineProperty(oi,"__esModule",{value:!0});function Gd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}oi.default=Gd;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});function Jd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}ci.default=Jd;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});function Hd(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,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}ui.default=Hd;var li={};Object.defineProperty(li,"__esModule",{value:!0});function Xd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}li.default=Xd;var Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});function Qd(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Jn.default=Qd;var di={},or={};(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(s){return e instanceof s})}})(or);var eh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(di,"__esModule",{value:!0});var lt=or;function Ls(r,e){if(e===void 0&&(e=lt.DefaultOption),!lt.isValidObject(r))return null;e=lt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(lt.isValidObject(n)?lt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ls(n,e)):e.recursiveInArray&<.isArrayObject(n)&&(n=eh(n).map(function(i){var o=i;if(lt.isValidObject(i))lt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ls(i,e));else if(lt.isArrayObject(i)){var u=Ls({key:i},e);o=u.key}return o}))),t[a]=n}),t}di.default=Ls;var hi={},th=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(hi,"__esModule",{value:!0});var dt=or;function Us(r,e){if(e===void 0&&(e=dt.DefaultOption),!dt.isValidObject(r))return null;e=dt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(dt.isValidObject(n)?dt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Us(n,e)):e.recursiveInArray&&dt.isArrayObject(n)&&(n=th(n).map(function(i){var o=i;if(dt.isValidObject(i))dt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Us(i,e));else if(dt.isArrayObject(i)){var u=Us({key:i},e);o=u.key}return o}))),t[a]=n}),t}hi.default=Us;var pi={},rh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(pi,"__esModule",{value:!0});var ht=or,sh=Fn;function Bs(r,e){if(e===void 0&&(e=ht.DefaultOption),!ht.isValidObject(r))return null;e=ht.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=sh.default(s);e.recursive&&(ht.isValidObject(n)?ht.belongToTypes(n,e.keepTypesOnRecursion)||(n=Bs(n,e)):e.recursiveInArray&&ht.isArrayObject(n)&&(n=rh(n).map(function(i){var o=i;if(ht.isValidObject(i))ht.belongToTypes(o,e.keepTypesOnRecursion)||(o=Bs(i,e));else if(ht.isArrayObject(i)){var u=Bs({key:i},e);o=u.key}return o}))),t[a]=n}),t}pi.default=Bs;var fi={},nh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(fi,"__esModule",{value:!0});var pt=or,ah=Yn;function Vs(r,e){if(e===void 0&&(e=pt.DefaultOption),!pt.isValidObject(r))return null;e=pt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=ah.default(s);e.recursive&&(pt.isValidObject(n)?pt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Vs(n,e)):e.recursiveInArray&&pt.isArrayObject(n)&&(n=nh(n).map(function(i){var o=i;if(pt.isValidObject(i))pt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Vs(i,e));else if(pt.isArrayObject(i)){var u=Vs({key:i},e);o=u.key}return o}))),t[a]=n}),t}fi.default=Vs;var mi={},ih=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(mi,"__esModule",{value:!0});var ft=or,oh=Gn;function qs(r,e){if(e===void 0&&(e=ft.DefaultOption),!ft.isValidObject(r))return null;e=ft.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=oh.default(s);e.recursive&&(ft.isValidObject(n)?ft.belongToTypes(n,e.keepTypesOnRecursion)||(n=qs(n,e)):e.recursiveInArray&&ft.isArrayObject(n)&&(n=ih(n).map(function(i){var o=i;if(ft.isValidObject(i))ft.belongToTypes(o,e.keepTypesOnRecursion)||(o=qs(i,e));else if(ft.isArrayObject(i)){var u=qs({key:i},e);o=u.key}return o}))),t[a]=n}),t}mi.default=qs;var yi={},ch=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(yi,"__esModule",{value:!0});var mt=or,uh=Jn;function Ks(r,e){if(e===void 0&&(e=mt.DefaultOption),!mt.isValidObject(r))return null;e=mt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=uh.default(s);e.recursive&&(mt.isValidObject(n)?mt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ks(n,e)):e.recursiveInArray&&mt.isArrayObject(n)&&(n=ch(n).map(function(i){var o=i;if(mt.isValidObject(i))mt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ks(i,e));else if(mt.isArrayObject(i)){var u=Ks({key:i},e);o=u.key}return o}))),t[a]=n}),t}yi.default=Ks;Object.defineProperty(F,"__esModule",{value:!0});F.kebabKeys=F.pascalKeys=F.snakeKeys=F.camelKeys=F.upperKeys=F.lowerKeys=F.toLowerCase=F.toUpperCase=F.toKebabCase=F.toHeaderCase=F.toSentenceCase=F.toTextCase=F.toPathCase=F.toDotCase=F.toPascalCase=F.toSnakeCase=F.toCamelCase=void 0;var Xo=Fn;F.toCamelCase=Xo.default;var Qo=Yn;F.toSnakeCase=Qo.default;var ec=Gn;F.toPascalCase=ec.default;var tc=ii;F.toDotCase=tc.default;var rc=oi;F.toPathCase=rc.default;var sc=ci;F.toTextCase=sc.default;var nc=ui;F.toSentenceCase=nc.default;var ac=li;F.toHeaderCase=ac.default;var ic=Jn;F.toKebabCase=ic.default;var oc=di;F.lowerKeys=oc.default;var cc=hi;F.upperKeys=cc.default;var uc=pi;F.camelKeys=uc.default;var lc=fi;F.snakeKeys=lc.default;var dc=mi;F.pascalKeys=dc.default;var hc=yi;F.kebabKeys=hc.default;var pc=function(r){return String(r||"").toLowerCase()};F.toLowerCase=pc;var fc=function(r){return String(r||"").toUpperCase()};F.toUpperCase=fc;var lh={toCamelCase:Xo.default,toSnakeCase:Qo.default,toPascalCase:ec.default,toDotCase:tc.default,toPathCase:rc.default,toTextCase:sc.default,toSentenceCase:nc.default,toHeaderCase:ac.default,toKebabCase:ic.default,toUpperCase:fc,toLowerCase:pc,lowerKeys:oc.default,upperKeys:cc.default,camelKeys:uc.default,snakeKeys:lc.default,pascalKeys:dc.default,kebabKeys:hc.default};F.default=lh;var mc=F;const yc={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},dh=r=>mc.snakeKeys(r,yc),hh=r=>mc.camelKeys(r,yc);var wn;(r=>{r.toSnake=dh,r.toCamel=hh,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(wn||(wn={}));f.object({x:Yo.or(so),y:Go.or(so)});const ph=f.object({x:Yo,y:Go}),fh=Object.freeze({x:"left",y:"top"}),mh=(r,e)=>r.x===e.x&&r.y===e.y,no=f.union([f.number(),vn,ai,Ko,$d,Pd]),yh=(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}},ao={x:0,y:0},js=f.union([f.number(),f.string()]);f.object({top:js,left:js,width:js,height:js});f.object({left:f.number(),top:f.number(),right:f.number(),bottom:f.number()});f.object({one:vn,two:vn,root:ph});const gi=(r,e,t=0,s=0,n)=>{const a={one:{...ao},two:{...ao},root:n??fh};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+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??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+s}: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))},ha=r=>{const e=gi(r);return{lower:e.one.x,upper:e.two.x}},pa=r=>{const e=gi(r);return{lower:e.one.y,upper:e.two.y}},gh=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,vh=f.object({signedWidth:f.number(),signedHeight:f.number()});f.union([Ko,vh,vn,ai]);const wh=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);f.object({offset:no,scale:no});const _h=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],bh=r=>(e,t,s,n)=>[e,n?s/r:s*r],kh=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,u=a-n,l=o-i;if(t==="dimension")return[r,s*(l/u)];const h=(s-n)*(l/u)+i;return[r,h]},Th=r=>(e,t,s)=>[r,s],Oh=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},xh=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=wh(s,n,a),[e,s]},La=class Sr{constructor(){b(this,"ops",[]),b(this,"currBounds",null),b(this,"currType",null),b(this,"reversed",!1),this.ops=[]}static translate(e){return new Sr().translate(e)}static magnify(e){return new Sr().magnify(e)}static scale(e,t){return new Sr().scale(e,t)}translate(e){const t=this.new(),s=_h(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=bh(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=da(e,t),n=this.new(),a=kh(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=da(e,t),n=this.new(),a=xh(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=da(e,t),n=this.new(),a=Th(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=Oh();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 Sr;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};b(La,"IDENTITY",new La);let io=La;const oo=class kt{constructor(e=new io,t=new io,s=null){b(this,"x"),b(this,"y"),b(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new kt().translate(e,t)}static translateX(e){return new kt().translateX(e)}static translateY(e){return new kt().translateY(e)}static clamp(e){return new kt().clamp(e)}static magnify(e){return new kt().magnify(e)}static scale(e){return new kt().scale(e)}static reBound(e){return new kt().reBound(e)}translate(e,t){const s=yh(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}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(gh(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!mh(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(ha(e)),t.y=t.y.scale(pa(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(ha(e)),t.y=this.y.reBound(pa(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(ha(e)),t.y=this.y.clamp(pa(e)),t}copy(){const e=new kt;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 gi(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};b(oo,"IDENTITY",new oo);const gc=(r,e)=>{const t=new Ne(e);if(![Se.DAY,Se.HOUR,Se.MINUTE,Se.SECOND,Se.MILLISECOND,Se.MICROSECOND,Se.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof Ne?new Ne(s):new Se(s)},ae=class z{constructor(e,t="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new z(BigInt(n.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=z.hours(parseInt(s??"00",10)).add(z.minutes(parseInt(n??"00",10))).add(z.seconds(parseInt(i??"00",10))).add(z.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(z.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new z(BigInt(s.getTime())*z.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(z.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new Se(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new Nh(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 z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return gc(this,e)}get isToday(){return this.truncate(Se.DAY).equals(z.now().truncate(Se.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let t=z.MIN;for(const s of e){const n=new z(s);n.after(t)&&(t=n)}return t}static min(...e){let t=z.MAX;for(const s of e){const n=new z(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};b(ae,"NANOSECOND",ae.nanoseconds(1)),b(ae,"MICROSECOND",ae.microseconds(1)),b(ae,"MILLISECOND",ae.milliseconds(1)),b(ae,"SECOND",ae.seconds(1)),b(ae,"MINUTE",ae.minutes(1)),b(ae,"HOUR",ae.hours(1)),b(ae,"DAY",ae.days(1)),b(ae,"MAX",new ae((1n<<63n)-1n)),b(ae,"MIN",new ae(0)),b(ae,"ZERO",new ae(0)),b(ae,"z",f.union([f.object({value:f.bigint()}).transform(r=>new ae(r.value)),f.string().transform(r=>new ae(BigInt(r))),f.instanceof(Number).transform(r=>new ae(r)),f.number().transform(r=>new ae(r)),f.instanceof(ae)]));let Ne=ae;const ie=class ee{constructor(e){b(this,"value"),b(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 ee(e).valueOf()}greaterThan(e){return this.valueOf()>new ee(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ee(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ee(e).valueOf()}remainder(e){return gc(this,e)}truncate(e){return new ee(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(ee.DAY),t=this.truncate(ee.HOUR),s=this.truncate(ee.MINUTE),n=this.truncate(ee.SECOND),a=this.truncate(ee.MILLISECOND),i=this.truncate(ee.MICROSECOND),o=this.truncate(ee.NANOSECOND),u=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),Q=a.sub(n),ye=i.sub(a),Re=o.sub(i);let de="";return u.isZero||(de+=`${u.days}d `),l.isZero||(de+=`${l.hours}h `),h.isZero||(de+=`${h.minutes}m `),k.isZero||(de+=`${k.seconds}s `),Q.isZero||(de+=`${Q.milliseconds}ms `),ye.isZero||(de+=`${ye.microseconds}µs `),Re.isZero||(de+=`${Re.nanoseconds}ns`),de.trim()}get days(){return Number(this.valueOf()/ee.DAY.valueOf())}get hours(){return Number(this.valueOf()/ee.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/ee.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/ee.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/ee.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/ee.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new ee(e).valueOf()}add(e){return new ee(this.valueOf()+new ee(e).valueOf())}sub(e){return new ee(this.valueOf()-new ee(e).valueOf())}static nanoseconds(e=1){return new ee(e)}static microseconds(e=1){return ee.nanoseconds(e*1e3)}static milliseconds(e=1){return ee.microseconds(e*1e3)}static seconds(e=1){return ee.milliseconds(e*1e3)}static minutes(e){return ee.seconds(e.valueOf()*60)}static hours(e){return ee.minutes(e*60)}static days(e){return ee.hours(e*24)}};b(ie,"NANOSECOND",ie.nanoseconds(1)),b(ie,"MICROSECOND",ie.microseconds(1)),b(ie,"MILLISECOND",ie.milliseconds(1)),b(ie,"SECOND",ie.seconds(1)),b(ie,"MINUTE",ie.minutes(1)),b(ie,"HOUR",ie.hours(1)),b(ie,"DAY",ie.days(1)),b(ie,"MAX",new ie((1n<<63n)-1n)),b(ie,"MIN",new ie(0)),b(ie,"ZERO",new ie(0)),b(ie,"z",f.union([f.object({value:f.bigint()}).transform(r=>new ie(r.value)),f.string().transform(r=>new ie(BigInt(r))),f.instanceof(Number).transform(r=>new ie(r)),f.number().transform(r=>new ie(r)),f.instanceof(ie)]));let Se=ie;const Rs=class Ws extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ws(e).valueOf()}get period(){return Se.seconds(1/this.valueOf())}sampleCount(e){return new Se(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new xe(t).valueOf()}span(e){return Se.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ws(e)}static khz(e){return Ws.hz(e*1e3)}};b(Rs,"z",f.union([f.number().transform(r=>new Rs(r)),f.instanceof(Number).transform(r=>new Rs(r)),f.instanceof(Rs)]));const ge=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Sh(e*this.valueOf())}};b(ge,"UNKNOWN",new ge(0)),b(ge,"BIT128",new ge(16)),b(ge,"BIT64",new ge(8)),b(ge,"BIT32",new ge(4)),b(ge,"BIT16",new ge(2)),b(ge,"BIT8",new ge(1)),b(ge,"z",f.union([f.number().transform(r=>new ge(r)),f.instanceof(Number).transform(r=>new ge(r)),f.instanceof(ge)]));let xe=ge;const Qe=class Fs{constructor(e,t){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new Ne(e.start),this.end=new Ne(e.end)):(this.start=new Ne(e),this.end=new Ne(t))}get span(){return new Se(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 Fs(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Fs?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Fs(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}};b(Qe,"MAX",new Qe(Ne.MIN,Ne.MAX)),b(Qe,"MIN",new Qe(Ne.MAX,Ne.MIN)),b(Qe,"ZERO",new Qe(Ne.ZERO,Ne.ZERO)),b(Qe,"z",f.union([f.object({start:Ne.z,end:Ne.z}).transform(r=>new Qe(r.start,r.end)),f.instanceof(Qe)]));let Nh=Qe;const g=class et extends String{constructor(e){if(e instanceof et||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=et.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(et.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=et.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(et.JSON)||this.equals(et.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(et.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=et.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return et.BIG_INT_TYPES.some(e=>e.equals(this))}};b(g,"UNKNOWN",new g("unknown")),b(g,"FLOAT64",new g("float64")),b(g,"FLOAT32",new g("float32")),b(g,"INT64",new g("int64")),b(g,"INT32",new g("int32")),b(g,"INT16",new g("int16")),b(g,"INT8",new g("int8")),b(g,"UINT64",new g("uint64")),b(g,"UINT32",new g("uint32")),b(g,"UINT16",new g("uint16")),b(g,"UINT8",new g("uint8")),b(g,"BOOLEAN",g.UINT8),b(g,"TIMESTAMP",new g("timestamp")),b(g,"UUID",new g("uuid")),b(g,"STRING",new g("string")),b(g,"JSON",new g("json")),b(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),b(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),b(g,"DENSITIES",new Map([[g.UINT8.toString(),xe.BIT8],[g.UINT16.toString(),xe.BIT16],[g.UINT32.toString(),xe.BIT32],[g.UINT64.toString(),xe.BIT64],[g.FLOAT32.toString(),xe.BIT32],[g.FLOAT64.toString(),xe.BIT64],[g.INT8.toString(),xe.BIT8],[g.INT16.toString(),xe.BIT16],[g.INT32.toString(),xe.BIT32],[g.INT64.toString(),xe.BIT64],[g.TIMESTAMP.toString(),xe.BIT64],[g.STRING.toString(),xe.UNKNOWN],[g.JSON.toString(),xe.UNKNOWN],[g.UUID.toString(),xe.BIT128]])),b(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),b(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),b(g,"z",f.union([f.string().transform(r=>new g(r)),f.instanceof(g)]));const _e=class he extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return he.bytes(this.valueOf()+e.valueOf())}sub(e){return he.bytes(this.valueOf()-e.valueOf())}truncate(e){return new he(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return he.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/he.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/he.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/he.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/he.TERABYTE.valueOf()}toString(){const e=this.truncate(he.TERABYTE),t=this.truncate(he.GIGABYTE),s=this.truncate(he.MEGABYTE),n=this.truncate(he.KILOBYTE),a=this.truncate(he.BYTE),i=e,o=t.sub(e),u=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),u.isZero||(k+=`${u.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new he(e)}static kilobytes(e=1){return he.bytes(e.valueOf()*1e3)}static megabytes(e=1){return he.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return he.megabytes(e.valueOf()*1e3)}static terabytes(e){return he.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(_e,"BYTE",new _e(1)),b(_e,"KILOBYTE",_e.kilobytes(1)),b(_e,"MEGABYTE",_e.megabytes(1)),b(_e,"GIGABYTE",_e.gigabytes(1)),b(_e,"TERABYTE",_e.terabytes(1)),b(_e,"ZERO",new _e(0)),b(_e,"z",f.union([f.number().transform(r=>new _e(r)),f.instanceof(_e)]));let Sh=_e;f.union([f.instanceof(Uint8Array),f.instanceof(Uint16Array),f.instanceof(Uint32Array),f.instanceof(BigUint64Array),f.instanceof(Float32Array),f.instanceof(Float64Array),f.instanceof(Int8Array),f.instanceof(Int16Array),f.instanceof(Int32Array),f.instanceof(BigInt64Array)]);f.record(f.union([f.number(),f.string(),f.symbol()]),f.unknown());const Eh=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),vc=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Zh=vc(),wc=["MacOS","Windows","Linux","Docker"],Ih=f.enum(wc);let fa;const Ah=()=>{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"},Ch=(r={})=>{const{force:e,default:t}=r;return e??fa??(fa=Ah(),fa??t)},_c=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wc,RUNTIME:Zh,detect:vc,getOS:Ch,osZ:Ih},Symbol.toStringTag,{value:"Module"})),$h=(...r)=>r.map(bc).join(""),bc=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),jh=r=>r.endsWith("/")?r.slice(0,-1):r,Rh=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,s])=>`${e}${t}=${s}`).join("&");var ur;let zh=(ur=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){b(this,"protocol"),b(this,"host"),b(this,"port"),b(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=bc(s)}replace(r){return new ur({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new ur({...this,pathPrefix:$h(this.path,r)})}toString(){return jh(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},b(ur,"UNKNOWN",new ur({host:"unknown",port:0})),ur),Ph=class{constructor(){b(this,"contentType","application/json"),b(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(wn.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Eh(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=wn.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}};new Ph;const Mh=f.string().regex(/^\d+\.\d+\.\d+$/);f.object({version:Mh});var H;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(H||(H={}));var Ua;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ua||(Ua={}));const O=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=r=>{switch(typeof r){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(r)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(r)?O.array:r===null?O.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?O.promise:typeof Map<"u"&&r instanceof Map?O.map:typeof Set<"u"&&r instanceof Set?O.set:typeof Date<"u"&&r instanceof Date?O.date:O.object;default:return O.unknown}},w=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"]),Dh=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Ke=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Ke.create=r=>new Ke(r);const Fr=(r,e)=>{let t;switch(r.code){case w.invalid_type:r.received===O.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,H.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${H.joinValues(r.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${H.joinValues(r.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${H.joinValues(r.options)}, received '${r.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.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}"`:H.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case w.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 w.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 w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,H.assertNever(r)}return{message:t}};let kc=Fr;function Lh(r){kc=r}function _n(){return kc}const bn=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const u=s.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Uh=[];function S(r,e){const t=bn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_n(),Fr].filter(s=>!!s)});r.common.issues.push(t)}let je=class Tc{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return D;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Tc.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return D;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}};const D=Object.freeze({status:"aborted"}),Oc=r=>({status:"dirty",value:r}),Ae=r=>({status:"valid",value:r}),Ba=r=>r.status==="aborted",Va=r=>r.status==="dirty",Yr=r=>r.status==="valid",kn=r=>typeof Promise<"u"&&r instanceof Promise;var I;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));let it=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 co=(r,e)=>{if(Yr(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 Ke(r.common.issues);return this._error=t,this._error}}};function B(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}let K=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 Pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(kn(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return co(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={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:Pt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(kn(n)?n:Promise.resolve(n));return co(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:w.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Je({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return St.create(this,this._def)}nullable(){return tr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this,this._def)}promise(){return kr.create(this,this._def)}or(e){return es.create([this,e],this._def)}and(e){return ts.create(this,e,this._def)}transform(e){return new Je({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new is({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new Ic({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Sn({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return vi.create(this,e)}readonly(){return Zn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Bh=/^c[^\s-]{8,}$/i,Vh=/^[a-z][a-z0-9]*$/,qh=/^[0-9A-HJKMNP-TV-Z]{26}$/,Kh=/^[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,Wh=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ma;const Yh=/^(((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}))$/,Gh=/^(([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})))$/,Jh=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 Hh(r,e){return!!((e==="v4"||!e)&&Yh.test(r)||(e==="v6"||!e)&&Gh.test(r))}class Be extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.string,received:n.parsedType}),D}const t=new je;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Wh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"email",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ma||(ma=new RegExp(Fh,"u")),ma.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"emoji",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Kh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"uuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Bh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Vh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid2",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")qh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ulid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),S(s,{validation:"url",code:w.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"regex",code:w.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Jh(n).test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Hh(e.data,n.version)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ip",code:w.invalid_string,message:n.message}),t.dirty()):H.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:w.invalid_string,...I.errToObj(s)})}_addCheck(e){return new Be({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...I.errToObj(e)})}url(e){return this._addCheck({kind:"url",...I.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...I.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...I.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...I.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...I.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...I.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...I.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,...I.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...I.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...I.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...I.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...I.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...I.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...I.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...I.errToObj(t)})}nonempty(e){return this.min(1,I.errToObj(e))}trim(){return new Be({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Be({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Be({...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}}Be.create=r=>{var e;return new Be({checks:[],typeName:j.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};function Xh(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Lt extends K{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)!==O.number){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.number,received:n.parsedType}),D}let t;const s=new je;for(const n of this._def.checks)n.kind==="int"?H.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Xh(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_finite,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new Lt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new Lt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:I.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:I.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.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"&&H.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Lt.create=r=>new Lt({checks:[],typeName:j.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});let Gr=class qa extends K{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)!==O.bigint){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.bigint,received:n.parsedType}),D}let t;const s=new je;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new qa({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new qa({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.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}};Gr.create=r=>{var e;return new Gr({checks:[],typeName:j.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};let Jr=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.boolean,received:t.parsedType}),D}return Ae(e.data)}};Jr.create=r=>new Jr({typeName:j.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});let Hr=class xc extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.date,received:n.parsedType}),D}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_date}),D}const t=new je;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):H.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.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}};Hr.create=r=>new Hr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:j.ZodDate,...B(r)});let Tn=class extends K{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.symbol,received:t.parsedType}),D}return Ae(e.data)}};Tn.create=r=>new Tn({typeName:j.ZodSymbol,...B(r)});let Xr=class extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.undefined,received:t.parsedType}),D}return Ae(e.data)}};Xr.create=r=>new Xr({typeName:j.ZodUndefined,...B(r)});let Qr=class extends K{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.null,received:t.parsedType}),D}return Ae(e.data)}};Qr.create=r=>new Qr({typeName:j.ZodNull,...B(r)});let br=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}};br.create=r=>new br({typeName:j.ZodAny,...B(r)});class Gt extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}}Gt.create=r=>new Gt({typeName:j.ZodUnknown,...B(r)});let It=class extends K{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.never,received:t.parsedType}),D}};It.create=r=>new It({typeName:j.ZodNever,...B(r)});class On extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.void,received:t.parsedType}),D}return Ae(e.data)}}On.create=r=>new On({typeName:j.ZodVoid,...B(r)});let er=class Ys extends K{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==O.array)return S(t,{code:w.invalid_type,expected:O.array,received:t.parsedType}),D;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(S(t,{code:i?w.too_big:w.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(S(t,{code:w.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(S(t,{code:w.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new it(t,i,t.path,o)))).then(i=>je.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new it(t,i,t.path,o)));return je.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ys({...this._def,minLength:{value:e,message:I.toString(t)}})}max(e,t){return new Ys({...this._def,maxLength:{value:e,message:I.toString(t)}})}length(e,t){return new Ys({...this._def,exactLength:{value:e,message:I.toString(t)}})}nonempty(e){return this.min(1,e)}};er.create=(r,e)=>new er({type:r,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function hr(r){if(r instanceof ue){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=St.create(hr(s))}return new ue({...r._def,shape:()=>e})}else return r instanceof er?new er({...r._def,type:hr(r.element)}):r instanceof St?St.create(hr(r.unwrap())):r instanceof tr?tr.create(hr(r.unwrap())):r instanceof ot?ot.create(r.items.map(e=>hr(e))):r}class ue extends K{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=H.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const u=this._getOrReturnCtx(e);return S(u,{code:w.invalid_type,expected:O.object,received:u.parsedType}),D}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof It&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=n[u],h=s.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new it(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof It){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(S(s,{code:w.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 l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new it(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>je.mergeObjectSync(t,u)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return I.errToObj,new ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const u=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=I.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(e){const t={};return H.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}omit(e){const t={};return H.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}deepPartial(){return hr(this)}partial(e){const t={};return H.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new ue({...this._def,shape:()=>t})}required(e){const t={};return H.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof St;)n=n._def.innerType;t[s]=n}}),new ue({...this._def,shape:()=>t})}keyof(){return Zc(H.objectKeys(this.shape))}}ue.create=(r,e)=>new ue({shape:()=>r,unknownKeys:"strip",catchall:It.create(),typeName:j.ZodObject,...B(e)});ue.strictCreate=(r,e)=>new ue({shape:()=>r,unknownKeys:"strict",catchall:It.create(),typeName:j.ZodObject,...B(e)});ue.lazycreate=(r,e)=>new ue({shape:r,unknownKeys:"strip",catchall:It.create(),typeName:j.ZodObject,...B(e)});let es=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(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 Ke(o.ctx.common.issues));return S(t,{code:w.invalid_union,unionErrors:i}),D}if(t.common.async)return Promise.all(s.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(n);{let a;const i=[];for(const u of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ke(u));return S(t,{code:w.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};es.create=(r,e)=>new es({options:r,typeName:j.ZodUnion,...B(e)});const Gs=r=>r instanceof ss?Gs(r.schema):r instanceof Je?Gs(r.innerType()):r instanceof ns?[r.value]:r instanceof Ut?r.options:r instanceof as?Object.keys(r.enum):r instanceof is?Gs(r._def.innerType):r instanceof Xr?[void 0]:r instanceof Qr?[null]:null;let Nc=class Sc extends K{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:w.invalid_type,expected:O.object,received:t.parsedType}),D;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);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}):(S(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Gs(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(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Sc({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...B(s)})}};function Ka(r,e){const t=Pt(r),s=Pt(e);if(r===e)return{valid:!0,data:r};if(t===O.object&&s===O.object){const n=H.objectKeys(e),a=H.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Ka(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===O.array&&s===O.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Ka(i,o);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return t===O.date&&s===O.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let ts=class extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ba(a)||Ba(i))return D;const o=Ka(a.value,i.value);return o.valid?((Va(a)||Va(i))&&t.dirty(),{status:t.value,value:o.data}):(S(s,{code:w.invalid_intersection_types}),D)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};ts.create=(r,e,t)=>new ts({left:r,right:e,typeName:j.ZodIntersection,...B(t)});class ot extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.array)return S(s,{code:w.invalid_type,expected:O.array,received:s.parsedType}),D;if(s.data.length<this._def.items.length)return S(s,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&s.data.length>this._def.items.length&&(S(s,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new it(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>je.mergeArray(t,a)):je.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ot({...this._def,rest:e})}}ot.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ot({items:r,typeName:j.ZodTuple,rest:null,...B(e)})};class rs extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.object)return S(s,{code:w.invalid_type,expected:O.object,received:s.parsedType}),D;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new it(s,o,s.path,o)),value:i._parse(new it(s,s.data[o],s.path,o))});return s.common.async?je.mergeObjectAsync(t,n):je.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof K?new rs({keyType:e,valueType:t,typeName:j.ZodRecord,...B(s)}):new rs({keyType:Be.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}}let xn=class extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.map)return S(s,{code:w.invalid_type,expected:O.map,received:s.parsedType}),D;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,u],l)=>({key:n._parse(new it(s,o,s.path,[l,"key"])),value:a._parse(new it(s,u,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};xn.create=(r,e,t)=>new xn({valueType:e,keyType:r,typeName:j.ZodMap,...B(t)});let Nn=class Wa extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.set)return S(s,{code:w.invalid_type,expected:O.set,received:s.parsedType}),D;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(S(s,{code:w.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(S(s,{code:w.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return D;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((u,l)=>a._parse(new it(s,u,s.path,l)));return s.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Wa({...this._def,minSize:{value:e,message:I.toString(t)}})}max(e,t){return new Wa({...this._def,maxSize:{value:e,message:I.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Nn.create=(r,e)=>new Nn({valueType:r,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});let Ec=class Js extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:w.invalid_type,expected:O.function,received:t.parsedType}),D;function s(o,u){return bn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Fr].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:u}})}function n(o,u){return bn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Fr].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof kr){const o=this;return Ae(async function(...u){const l=new Ke([]),h=await o._def.args.parseAsync(u,a).catch(Q=>{throw l.addIssue(s(u,Q)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(Q=>{throw l.addIssue(n(k,Q)),l})})}else{const o=this;return Ae(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Ke([s(u,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new Ke([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Js({...this._def,args:ot.create(e).rest(Gt.create())})}returns(e){return new Js({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Js({args:e||ot.create([]).rest(Gt.create()),returns:t||Gt.create(),typeName:j.ZodFunction,...B(s)})}};class ss extends K{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})}}ss.create=(r,e)=>new ss({getter:r,typeName:j.ZodLazy,...B(e)});class ns extends K{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}}ns.create=(r,e)=>new ns({value:r,typeName:j.ZodLiteral,...B(e)});function Zc(r,e){return new Ut({values:r,typeName:j.ZodEnum,...B(e)})}class Ut extends K{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{expected:H.joinValues(s),received:t.parsedType,code:w.invalid_type}),D}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{received:t.data,code:w.invalid_enum_value,options:s}),D}return Ae(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 Ut.create(e)}exclude(e){return Ut.create(this.options.filter(t=>!e.includes(t)))}}Ut.create=Zc;let as=class extends K{_parse(e){const t=H.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==O.string&&s.parsedType!==O.number){const n=H.objectValues(t);return S(s,{expected:H.joinValues(n),received:s.parsedType,code:w.invalid_type}),D}if(t.indexOf(e.data)===-1){const n=H.objectValues(t);return S(s,{received:s.data,code:w.invalid_enum_value,options:n}),D}return Ae(e.data)}get enum(){return this._def.values}};as.create=(r,e)=>new as({values:r,typeName:j.ZodNativeEnum,...B(e)});let kr=class extends K{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:w.invalid_type,expected:O.promise,received:t.parsedType}),D;const s=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return Ae(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};kr.create=(r,e)=>new kr({type:r,typeName:j.ZodPromise,...B(e)});let Je=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{S(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const u=n.refinement(o,a);if(s.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(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Yr(i))return i;const o=n.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:s.data,path:s.path,parent:s}).then(i=>Yr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);H.assertNever(n)}};Je.create=(r,e,t)=>new Je({schema:r,typeName:j.ZodEffects,effect:e,...B(t)});Je.createWithPreprocess=(r,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:r},typeName:j.ZodEffects,...B(t)});class St extends K{_parse(e){return this._getType(e)===O.undefined?Ae(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}St.create=(r,e)=>new St({innerType:r,typeName:j.ZodOptional,...B(e)});let tr=class extends K{_parse(e){return this._getType(e)===O.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tr.create=(r,e)=>new tr({innerType:r,typeName:j.ZodNullable,...B(e)});let is=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===O.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};is.create=(r,e)=>new is({innerType:r,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});let Sn=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return kn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ke(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ke(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Sn.create=(r,e)=>new Sn({innerType:r,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});let En=class extends K{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.nan,received:t.parsedType}),D}return{status:"valid",value:e.data}}};En.create=r=>new En({typeName:j.ZodNaN,...B(r)});const Qh=Symbol("zod_brand");class Ic extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}let vi=class Ac extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),Oc(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Ac({in:e,out:t,typeName:j.ZodPipeline})}};class Zn extends K{_parse(e){const t=this._def.innerType._parse(e);return Yr(t)&&(t.value=Object.freeze(t.value)),t}}Zn.create=(r,e)=>new Zn({innerType:r,typeName:j.ZodReadonly,...B(e)});const Cc=(r,e={},t)=>r?br.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:u})}}):br.create(),ep={object:ue.lazycreate};var j;(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"})(j||(j={}));const tp=(r,e={message:`Input not instance of ${r.name}`})=>Cc(t=>t instanceof r,e),$c=Be.create,jc=Lt.create,rp=En.create,sp=Gr.create,Rc=Jr.create,np=Hr.create,ap=Tn.create,ip=Xr.create,op=Qr.create,cp=br.create,up=Gt.create,lp=It.create,dp=On.create,hp=er.create,pp=ue.create,fp=ue.strictCreate,mp=es.create,yp=Nc.create,gp=ts.create,vp=ot.create,wp=rs.create,_p=xn.create,bp=Nn.create,kp=Ec.create,Tp=ss.create,Op=ns.create,xp=Ut.create,Np=as.create,Sp=kr.create,uo=Je.create,Ep=St.create,Zp=tr.create,Ip=Je.createWithPreprocess,Ap=vi.create,Cp=()=>$c().optional(),$p=()=>jc().optional(),jp=()=>Rc().optional(),Rp={string:r=>Be.create({...r,coerce:!0}),number:r=>Lt.create({...r,coerce:!0}),boolean:r=>Jr.create({...r,coerce:!0}),bigint:r=>Gr.create({...r,coerce:!0}),date:r=>Hr.create({...r,coerce:!0})},zp=D;var xt=Object.freeze({__proto__:null,defaultErrorMap:Fr,setErrorMap:Lh,getErrorMap:_n,makeIssue:bn,EMPTY_PATH:Uh,addIssueToContext:S,ParseStatus:je,INVALID:D,DIRTY:Oc,OK:Ae,isAborted:Ba,isDirty:Va,isValid:Yr,isAsync:kn,get util(){return H},get objectUtil(){return Ua},ZodParsedType:O,getParsedType:Pt,ZodType:K,ZodString:Be,ZodNumber:Lt,ZodBigInt:Gr,ZodBoolean:Jr,ZodDate:Hr,ZodSymbol:Tn,ZodUndefined:Xr,ZodNull:Qr,ZodAny:br,ZodUnknown:Gt,ZodNever:It,ZodVoid:On,ZodArray:er,ZodObject:ue,ZodUnion:es,ZodDiscriminatedUnion:Nc,ZodIntersection:ts,ZodTuple:ot,ZodRecord:rs,ZodMap:xn,ZodSet:Nn,ZodFunction:Ec,ZodLazy:ss,ZodLiteral:ns,ZodEnum:Ut,ZodNativeEnum:as,ZodPromise:kr,ZodEffects:Je,ZodTransformer:Je,ZodOptional:St,ZodNullable:tr,ZodDefault:is,ZodCatch:Sn,ZodNaN:En,BRAND:Qh,ZodBranded:Ic,ZodPipeline:vi,ZodReadonly:Zn,custom:Cc,Schema:K,ZodSchema:K,late:ep,get ZodFirstPartyTypeKind(){return j},coerce:Rp,any:cp,array:hp,bigint:sp,boolean:Rc,date:np,discriminatedUnion:yp,effect:uo,enum:xp,function:kp,instanceof:tp,intersection:gp,lazy:Tp,literal:Op,map:_p,nan:rp,nativeEnum:Np,never:lp,null:op,nullable:Zp,number:jc,object:pp,oboolean:jp,onumber:$p,optional:Ep,ostring:Cp,pipeline:Ap,preprocess:Ip,promise:Sp,record:wp,set:bp,strictObject:fp,string:$c,symbol:ap,transformer:uo,tuple:vp,undefined:ip,union:mp,unknown:up,void:dp,NEVER:zp,ZodIssueCode:w,quotelessJson:Dh,ZodError:Ke});let Ns=class extends Error{constructor(e,t){super(e),fe(this,"discriminator","FreighterError"),fe(this,"type"),this.type=t}};const Pp=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},Fa="unknown",lo="nil",Hn="freighter",Ss=xt.object({type:xt.string(),data:xt.string()});class Mp{constructor(){fe(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:lo,data:""};if(Pp(e))for(const t of this.providers){const s=t.encode(e);if(s!=null)return s}return{type:Fa,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===lo)return null;if(e.type===Fa)return new ho(e.data);for(const t of this.providers){const s=t.decode(e);if(s!=null)return s}return new ho(e.data)}}const zc=new Mp,Pc=({encode:r,decode:e})=>zc.register({encode:r,decode:e}),wi=r=>zc.decode(r);let ho=class extends Ns{constructor(e){super(e,Fa)}},os=class extends Ns{constructor(){super("EOF",Hn)}},In=class extends Ns{constructor(){super("StreamClosed",Hn)}},cs=class extends Ns{constructor(e={}){const{message:t="Unreachable",url:s=zh.UNKNOWN}=e;super(t,Hn),fe(this,"url"),this.url=s}};const Hs="freighter",Dp=r=>{if(r.type!==Hn)return null;if(r instanceof os)return{type:Hs,data:"EOF"};if(r instanceof In)return{type:Hs,data:"StreamClosed"};if(r instanceof cs)return{type:Hs,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},Lp=r=>{if(r.type!==Hs)return null;switch(r.data){case"EOF":return new os;case"StreamClosed":return new In;case"Unreachable":return new cs;default:throw new Error(`Unknown error type: ${r.data}`)}};Pc({encode:Dp,decode:Lp});let Mc=class{constructor(){fe(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let s=0;const n=async a=>{if(s===this.middleware.length)return await t(a);const i=this.middleware[s];return s++,await i(a,n)};return await n(e)}};const Dc="Content-Type",po=r=>{if(_c.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),s=new t.Agent({rejectUnauthorized:!1});return async(n,a)=>await e(n,{...a,agent:s})};class Up extends Mc{constructor(e,t,s=!1){return super(),fe(this,"endpoint"),fe(this,"encoder"),fe(this,"fetch"),this.endpoint=e.replace({protocol:s?"https":"http"}),this.encoder=t,this.fetch=po(this.endpoint.protocol),new Proxy(this,{get:(n,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(n,a,i)})}get headers(){return{[Dc]:this.encoder.contentType}}async send(e,t,s,n){t=s==null?void 0:s.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const h={...l,params:{}};o.headers={...this.headers,...l.params};let k;try{k=await po(l.protocol)(l.target,o)}catch(ye){let Re=ye;return Re.message==="Load failed"&&(Re=new cs({url:i})),[h,Re]}const Q=await k.arrayBuffer();if(k!=null&&k.ok)return n!=null&&(a=this.encoder.decode(Q,n)),[h,null];try{if(k.status!==400)return[h,new Error(k.statusText)];const ye=this.encoder.decode(Q,Ss),Re=wi(ye);return[h,Re]}catch(ye){return[h,new Error(`[freighter] - failed to decode error: ${k.statusText}: ${ye.message}`)]}});return[a,u]}}const C=async(r,e,t,s,n)=>{const[a,i]=await r.send(e,t,s,n);if(i!=null)throw i;return a},Bp=()=>_c.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Vp=xt.object({type:xt.union([xt.literal("data"),xt.literal("close")]),payload:xt.unknown().optional(),error:xt.optional(Ss)});class qp{constructor(e,t,s,n){fe(this,"encoder"),fe(this,"reqSchema"),fe(this,"resSchema"),fe(this,"ws"),fe(this,"serverClosed"),fe(this,"sendClosed"),fe(this,"receiveDataQueue",[]),fe(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=s,this.resSchema=n,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new os;if(this.sendClosed)throw new In;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=wi(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(){return this.receiveDataQueue.shift()??await new Promise((t,s)=>this.receiveCallbacksQueue.push({resolve:t,reject:s}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,Vp),s=this.receiveCallbacksQueue.shift();s!=null?s.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Gp(e)?new os:new In}}}const Kp="freighterctx",Wp=1e3,Fp=1001,Yp=[Wp,Fp],Gp=r=>Yp.includes(r.code),Lc=class Uc extends Mc{constructor(e,t,s=!1){super(),fe(this,"baseUrl"),fe(this,"encoder"),this.baseUrl=e.replace({protocol:s?"wss":"ws"}),this.encoder=t}async stream(e,t,s){const n=Bp();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const u=n(this.buildURL(e,o)),l={...o,params:{}};u.binaryType=Uc.MESSAGE_TYPE;const h=await this.wrapSocket(u,t,s);return h instanceof Error?[l,h]:(a=h,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const s=Rh({[Dc]:this.encoder.contentType,...t.params},Kp);return this.baseUrl.child(e).toString()+s}async wrapSocket(e,t,s){return await new Promise(n=>{e.onopen=()=>{n(new qp(e,this.encoder,t,s))},e.onerror=a=>{const i=a;n(new Error(i.message))}})}};fe(Lc,"MESSAGE_TYPE","arraybuffer");let Jp=Lc;var Hp=Object.defineProperty,Xp=(r,e,t)=>e in r?Hp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>(Xp(r,typeof e!="symbol"?e+"":e,t),t);let Qp="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ef=(r=21)=>{let e="",t=r;for(;t--;)e+=Qp[Math.random()*64|0];return e};const tf=r=>r!=null&&typeof r=="object"&&"toString"in r,rf=(r,e=!1)=>{const t=tf(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>n-a;break;case"bigint":s=(n,a)=>n-a>BigInt(0)?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?sf(s):s},sf=r=>(e,t)=>r(t,e);var X;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(X||(X={}));var Ya;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ya||(Ya={}));const x=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mt=r=>{switch(typeof r){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(r)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(r)?x.array:r===null?x.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?x.promise:typeof Map<"u"&&r instanceof Map?x.map:typeof Set<"u"&&r instanceof Set?x.set:typeof Date<"u"&&r instanceof Date?x.date:x.object;default:return x.unknown}},_=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),nf=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class We extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}We.create=r=>new We(r);const us=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===x.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,X.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:X.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.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 _.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 _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(r)}return{message:t}};let Bc=us;function af(r){Bc=r}function An(){return Bc}const Cn=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const u=s.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},of=[];function E(r,e){const t=Cn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,An(),us].filter(s=>!!s)});r.common.issues.push(t)}class Te{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return L;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Te.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return L;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const L=Object.freeze({status:"aborted"}),Vc=r=>({status:"dirty",value:r}),Ce=r=>({status:"valid",value:r}),Ga=r=>r.status==="aborted",Ja=r=>r.status==="dirty",ls=r=>r.status==="valid",$n=r=>typeof Promise<"u"&&r instanceof Promise;var A;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));class ct{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 fo=(r,e)=>{if(ls(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 We(r.common.issues);return this._error=t,this._error}}};function V(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}class W{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 Mt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Te,ctx:{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if($n(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return fo(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={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:Mt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await($n(n)?n:Promise.resolve(n));return fo(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:_.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new He({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Et.create(this,this._def)}nullable(){return nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fe.create(this,this._def)}promise(){return Or.create(this,this._def)}or(e){return fs.create([this,e],this._def)}and(e){return ms.create(this,e,this._def)}transform(e){return new He({...V(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new _s({...V(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new Kc({typeName:R.ZodBranded,type:this,...V(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Pn({...V(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Es.create(this,e)}readonly(){return Dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cf=/^c[^\s-]{8,}$/i,uf=/^[a-z][a-z0-9]*$/,lf=/^[0-9A-HJKMNP-TV-Z]{26}$/,df=/^[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,hf=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ya;const ff=/^(((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}))$/,mf=/^(([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})))$/,yf=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 gf(r,e){return!!((e==="v4"||!e)&&ff.test(r)||(e==="v6"||!e)&&mf.test(r))}class Ve extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.string,received:n.parsedType}),L}const t=new Te;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")hf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"email",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ya||(ya=new RegExp(pf,"u")),ya.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"emoji",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")df.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"uuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")cf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")uf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid2",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")lf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ulid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),E(s,{validation:"url",code:_.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"regex",code:_.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?yf(n).test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?gf(e.data,n.version)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ip",code:_.invalid_string,message:n.message}),t.dirty()):X.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:_.invalid_string,...A.errToObj(s)})}_addCheck(e){return new Ve({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.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,...A.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ve({...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}}Ve.create=r=>{var e;return new Ve({checks:[],typeName:R.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...V(r)})};function vf(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Bt extends W{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)!==x.number){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.number,received:n.parsedType}),L}let t;const s=new Te;for(const n of this._def.checks)n.kind==="int"?X.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?vf(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_finite,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new Bt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bt.create=r=>new Bt({checks:[],typeName:R.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...V(r)});class Vt extends W{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)!==x.bigint){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.bigint,received:n.parsedType}),L}let t;const s=new Te;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new Vt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new Vt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.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}}Vt.create=r=>{var e;return new Vt({checks:[],typeName:R.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...V(r)})};class ds extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.boolean,received:t.parsedType}),L}return Ce(e.data)}}ds.create=r=>new ds({typeName:R.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...V(r)});class rr extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.date,received:n.parsedType}),L}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_date}),L}const t=new Te;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):X.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.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}}rr.create=r=>new rr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:R.ZodDate,...V(r)});class jn extends W{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.symbol,received:t.parsedType}),L}return Ce(e.data)}}jn.create=r=>new jn({typeName:R.ZodSymbol,...V(r)});class hs extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.undefined,received:t.parsedType}),L}return Ce(e.data)}}hs.create=r=>new hs({typeName:R.ZodUndefined,...V(r)});class ps extends W{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.null,received:t.parsedType}),L}return Ce(e.data)}}ps.create=r=>new ps({typeName:R.ZodNull,...V(r)});class Tr extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}}Tr.create=r=>new Tr({typeName:R.ZodAny,...V(r)});class Jt extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}}Jt.create=r=>new Jt({typeName:R.ZodUnknown,...V(r)});class At extends W{_parse(e){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.never,received:t.parsedType}),L}}At.create=r=>new At({typeName:R.ZodNever,...V(r)});class Rn extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.void,received:t.parsedType}),L}return Ce(e.data)}}Rn.create=r=>new Rn({typeName:R.ZodVoid,...V(r)});class Fe extends W{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==x.array)return E(t,{code:_.invalid_type,expected:x.array,received:t.parsedType}),L;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(E(t,{code:i?_.too_big:_.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(E(t,{code:_.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(E(t,{code:_.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new ct(t,i,t.path,o)))).then(i=>Te.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new ct(t,i,t.path,o)));return Te.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Fe({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new Fe({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new Fe({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}}Fe.create=(r,e)=>new Fe({type:r,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...V(e)});function pr(r){if(r instanceof le){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Et.create(pr(s))}return new le({...r._def,shape:()=>e})}else return r instanceof Fe?new Fe({...r._def,type:pr(r.element)}):r instanceof Et?Et.create(pr(r.unwrap())):r instanceof nr?nr.create(pr(r.unwrap())):r instanceof ut?ut.create(r.items.map(e=>pr(e))):r}class le extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=X.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==x.object){const u=this._getOrReturnCtx(e);return E(u,{code:_.invalid_type,expected:x.object,received:u.parsedType}),L}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof At&&this._def.unknownKeys==="strip"))for(const u in s.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=n[u],h=s.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new ct(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof At){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(E(s,{code:_.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 l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new ct(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>Te.mergeObjectSync(t,u)):Te.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const u=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=A.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new le({...this._def,unknownKeys:"strip"})}passthrough(){return new le({...this._def,unknownKeys:"passthrough"})}extend(e){return new le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new le({...this._def,catchall:e})}pick(e){const t={};return X.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}omit(e){const t={};return X.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}deepPartial(){return pr(this)}partial(e){const t={};return X.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new le({...this._def,shape:()=>t})}required(e){const t={};return X.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Et;)n=n._def.innerType;t[s]=n}}),new le({...this._def,shape:()=>t})}keyof(){return qc(X.objectKeys(this.shape))}}le.create=(r,e)=>new le({shape:()=>r,unknownKeys:"strip",catchall:At.create(),typeName:R.ZodObject,...V(e)});le.strictCreate=(r,e)=>new le({shape:()=>r,unknownKeys:"strict",catchall:At.create(),typeName:R.ZodObject,...V(e)});le.lazycreate=(r,e)=>new le({shape:r,unknownKeys:"strip",catchall:At.create(),typeName:R.ZodObject,...V(e)});class fs extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(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 We(o.ctx.common.issues));return E(t,{code:_.invalid_union,unionErrors:i}),L}if(t.common.async)return Promise.all(s.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(n);{let a;const i=[];for(const u of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new We(u));return E(t,{code:_.invalid_union,unionErrors:o}),L}}get options(){return this._def.options}}fs.create=(r,e)=>new fs({options:r,typeName:R.ZodUnion,...V(e)});const Xs=r=>r instanceof gs?Xs(r.schema):r instanceof He?Xs(r.innerType()):r instanceof vs?[r.value]:r instanceof qt?r.options:r instanceof ws?Object.keys(r.enum):r instanceof _s?Xs(r._def.innerType):r instanceof hs?[void 0]:r instanceof ps?[null]:null;class Xn extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return E(t,{code:_.invalid_type,expected:x.object,received:t.parsedType}),L;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);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}):(E(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Xs(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(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Xn({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...V(s)})}}function Ha(r,e){const t=Mt(r),s=Mt(e);if(r===e)return{valid:!0,data:r};if(t===x.object&&s===x.object){const n=X.objectKeys(e),a=X.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const u=Ha(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===x.array&&s===x.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],u=Ha(i,o);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return t===x.date&&s===x.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ms extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ga(a)||Ga(i))return L;const o=Ha(a.value,i.value);return o.valid?((Ja(a)||Ja(i))&&t.dirty(),{status:t.value,value:o.data}):(E(s,{code:_.invalid_intersection_types}),L)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ms.create=(r,e,t)=>new ms({left:r,right:e,typeName:R.ZodIntersection,...V(t)});class ut extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.array)return E(s,{code:_.invalid_type,expected:x.array,received:s.parsedType}),L;if(s.data.length<this._def.items.length)return E(s,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&s.data.length>this._def.items.length&&(E(s,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ct(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>Te.mergeArray(t,a)):Te.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ut({...this._def,rest:e})}}ut.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ut({items:r,typeName:R.ZodTuple,rest:null,...V(e)})};class ys extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.object)return E(s,{code:_.invalid_type,expected:x.object,received:s.parsedType}),L;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new ct(s,o,s.path,o)),value:i._parse(new ct(s,s.data[o],s.path,o))});return s.common.async?Te.mergeObjectAsync(t,n):Te.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof W?new ys({keyType:e,valueType:t,typeName:R.ZodRecord,...V(s)}):new ys({keyType:Ve.create(),valueType:e,typeName:R.ZodRecord,...V(t)})}}class zn extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.map)return E(s,{code:_.invalid_type,expected:x.map,received:s.parsedType}),L;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,u],l)=>({key:n._parse(new ct(s,o,s.path,[l,"key"])),value:a._parse(new ct(s,u,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}zn.create=(r,e,t)=>new zn({valueType:e,keyType:r,typeName:R.ZodMap,...V(t)});class sr extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.set)return E(s,{code:_.invalid_type,expected:x.set,received:s.parsedType}),L;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(E(s,{code:_.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(E(s,{code:_.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return L;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((u,l)=>a._parse(new ct(s,u,s.path,l)));return s.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new sr({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new sr({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}sr.create=(r,e)=>new sr({valueType:r,minSize:null,maxSize:null,typeName:R.ZodSet,...V(e)});class yr extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return E(t,{code:_.invalid_type,expected:x.function,received:t.parsedType}),L;function s(o,u){return Cn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,An(),us].filter(l=>!!l),issueData:{code:_.invalid_arguments,argumentsError:u}})}function n(o,u){return Cn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,An(),us].filter(l=>!!l),issueData:{code:_.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Or){const o=this;return Ce(async function(...u){const l=new We([]),h=await o._def.args.parseAsync(u,a).catch(Q=>{throw l.addIssue(s(u,Q)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(Q=>{throw l.addIssue(n(k,Q)),l})})}else{const o=this;return Ce(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new We([s(u,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new We([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new yr({...this._def,args:ut.create(e).rest(Jt.create())})}returns(e){return new yr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new yr({args:e||ut.create([]).rest(Jt.create()),returns:t||Jt.create(),typeName:R.ZodFunction,...V(s)})}}class gs extends W{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})}}gs.create=(r,e)=>new gs({getter:r,typeName:R.ZodLazy,...V(e)});class vs extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}}vs.create=(r,e)=>new vs({value:r,typeName:R.ZodLiteral,...V(e)});function qc(r,e){return new qt({values:r,typeName:R.ZodEnum,...V(e)})}class qt extends W{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{expected:X.joinValues(s),received:t.parsedType,code:_.invalid_type}),L}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{received:t.data,code:_.invalid_enum_value,options:s}),L}return Ce(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 qt.create(e)}exclude(e){return qt.create(this.options.filter(t=>!e.includes(t)))}}qt.create=qc;class ws extends W{_parse(e){const t=X.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==x.string&&s.parsedType!==x.number){const n=X.objectValues(t);return E(s,{expected:X.joinValues(n),received:s.parsedType,code:_.invalid_type}),L}if(t.indexOf(e.data)===-1){const n=X.objectValues(t);return E(s,{received:s.data,code:_.invalid_enum_value,options:n}),L}return Ce(e.data)}get enum(){return this._def.values}}ws.create=(r,e)=>new ws({values:r,typeName:R.ZodNativeEnum,...V(e)});class Or extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return E(t,{code:_.invalid_type,expected:x.promise,received:t.parsedType}),L;const s=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return Ce(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Or.create=(r,e)=>new Or({type:r,typeName:R.ZodPromise,...V(e)});class He extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{E(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const u=n.refinement(o,a);if(s.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(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ls(i))return i;const o=n.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:s.data,path:s.path,parent:s}).then(i=>ls(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);X.assertNever(n)}}He.create=(r,e,t)=>new He({schema:r,typeName:R.ZodEffects,effect:e,...V(t)});He.createWithPreprocess=(r,e,t)=>new He({schema:e,effect:{type:"preprocess",transform:r},typeName:R.ZodEffects,...V(t)});class Et extends W{_parse(e){return this._getType(e)===x.undefined?Ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Et.create=(r,e)=>new Et({innerType:r,typeName:R.ZodOptional,...V(e)});class nr extends W{_parse(e){return this._getType(e)===x.null?Ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}nr.create=(r,e)=>new nr({innerType:r,typeName:R.ZodNullable,...V(e)});class _s extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===x.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}_s.create=(r,e)=>new _s({innerType:r,typeName:R.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});class Pn extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return $n(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new We(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new We(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Pn.create=(r,e)=>new Pn({innerType:r,typeName:R.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});class Mn extends W{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.nan,received:t.parsedType}),L}return{status:"valid",value:e.data}}}Mn.create=r=>new Mn({typeName:R.ZodNaN,...V(r)});const wf=Symbol("zod_brand");class Kc extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Es extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),Vc(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Es({in:e,out:t,typeName:R.ZodPipeline})}}class Dn extends W{_parse(e){const t=this._def.innerType._parse(e);return ls(t)&&(t.value=Object.freeze(t.value)),t}}Dn.create=(r,e)=>new Dn({innerType:r,typeName:R.ZodReadonly,...V(e)});const Wc=(r,e={},t)=>r?Tr.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:u})}}):Tr.create(),_f={object:le.lazycreate};var R;(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"})(R||(R={}));const bf=(r,e={message:`Input not instance of ${r.name}`})=>Wc(t=>t instanceof r,e),Fc=Ve.create,Yc=Bt.create,kf=Mn.create,Tf=Vt.create,Gc=ds.create,Of=rr.create,xf=jn.create,Nf=hs.create,Sf=ps.create,Ef=Tr.create,Zf=Jt.create,If=At.create,Af=Rn.create,Cf=Fe.create,$f=le.create,jf=le.strictCreate,Rf=fs.create,zf=Xn.create,Pf=ms.create,Mf=ut.create,Df=ys.create,Lf=zn.create,Uf=sr.create,Bf=yr.create,Vf=gs.create,qf=vs.create,Kf=qt.create,Wf=ws.create,Ff=Or.create,mo=He.create,Yf=Et.create,Gf=nr.create,Jf=He.createWithPreprocess,Hf=Es.create,Xf=()=>Fc().optional(),Qf=()=>Yc().optional(),em=()=>Gc().optional(),tm={string:r=>Ve.create({...r,coerce:!0}),number:r=>Bt.create({...r,coerce:!0}),boolean:r=>ds.create({...r,coerce:!0}),bigint:r=>Vt.create({...r,coerce:!0}),date:r=>rr.create({...r,coerce:!0})},rm=L;var m=Object.freeze({__proto__:null,defaultErrorMap:us,setErrorMap:af,getErrorMap:An,makeIssue:Cn,EMPTY_PATH:of,addIssueToContext:E,ParseStatus:Te,INVALID:L,DIRTY:Vc,OK:Ce,isAborted:Ga,isDirty:Ja,isValid:ls,isAsync:$n,get util(){return X},get objectUtil(){return Ya},ZodParsedType:x,getParsedType:Mt,ZodType:W,ZodString:Ve,ZodNumber:Bt,ZodBigInt:Vt,ZodBoolean:ds,ZodDate:rr,ZodSymbol:jn,ZodUndefined:hs,ZodNull:ps,ZodAny:Tr,ZodUnknown:Jt,ZodNever:At,ZodVoid:Rn,ZodArray:Fe,ZodObject:le,ZodUnion:fs,ZodDiscriminatedUnion:Xn,ZodIntersection:ms,ZodTuple:ut,ZodRecord:ys,ZodMap:zn,ZodSet:sr,ZodFunction:yr,ZodLazy:gs,ZodLiteral:vs,ZodEnum:qt,ZodNativeEnum:ws,ZodPromise:Or,ZodEffects:He,ZodTransformer:He,ZodOptional:Et,ZodNullable:nr,ZodDefault:_s,ZodCatch:Pn,ZodNaN:Mn,BRAND:wf,ZodBranded:Kc,ZodPipeline:Es,ZodReadonly:Dn,custom:Wc,Schema:W,ZodSchema:W,late:_f,get ZodFirstPartyTypeKind(){return R},coerce:tm,any:Ef,array:Cf,bigint:Tf,boolean:Gc,date:Of,discriminatedUnion:zf,effect:mo,enum:Kf,function:Bf,instanceof:bf,intersection:Pf,lazy:Vf,literal:qf,map:Lf,nan:kf,nativeEnum:Wf,never:If,null:Sf,nullable:Gf,number:Yc,object:$f,oboolean:em,onumber:Qf,optional:Yf,ostring:Xf,pipeline:Hf,preprocess:Jf,promise:Ff,record:Df,set:Uf,strictObject:jf,string:Fc,symbol:xf,transformer:mo,tuple:Mf,undefined:Nf,union:Rf,unknown:Zf,void:Af,NEVER:rm,ZodIssueCode:_,quotelessJson:nf,ZodError:We});const _i=m.tuple([m.number(),m.number()]),Jc=m.object({width:m.number(),height:m.number()}),sm=m.object({signedWidth:m.number(),signedHeight:m.number()}),nm=["width","height"];m.enum(nm);const am=["start","center","end"],im=["signedWidth","signedHeight"];m.enum(im);const Ln=m.object({x:m.number(),y:m.number()}),om=m.object({clientX:m.number(),clientY:m.number()}),cm=["x","y"],Hc=m.enum(cm),Xc=["top","right","bottom","left"];m.enum(Xc);const um=["left","right"],Qc=m.enum(um),lm=["top","bottom"],eu=m.enum(lm),tu=["center"],yo=m.enum(tu),dm=[...Xc,...tu],ru=m.enum(dm);m.enum(am);const hm=["first","last"];m.enum(hm);const pm=m.object({lower:m.number(),upper:m.number()});m.union([pm,_i]);m.union([Hc,ru]);m.union([Hc,ru,m.instanceof(String)]);const Ar=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),fm(t)},fm=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var De=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y={},Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});function mm(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,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}Qn.default=mm;var ea={};Object.defineProperty(ea,"__esModule",{value:!0});function ym(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ea.default=ym;var ta={};Object.defineProperty(ta,"__esModule",{value:!0});function gm(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,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}ta.default=gm;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});function vm(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}bi.default=vm;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});function wm(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}ki.default=wm;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});function _m(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ti.default=_m;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});function bm(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,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Oi.default=bm;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});function km(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}xi.default=km;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});function Tm(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,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}ra.default=Tm;var Ni={},cr={};(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(s){return e instanceof s})}})(cr);var Om=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ni,"__esModule",{value:!0});var yt=cr;function Qs(r,e){if(e===void 0&&(e=yt.DefaultOption),!yt.isValidObject(r))return null;e=yt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(yt.isValidObject(n)?yt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Qs(n,e)):e.recursiveInArray&&yt.isArrayObject(n)&&(n=Om(n).map(function(i){var o=i;if(yt.isValidObject(i))yt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Qs(i,e));else if(yt.isArrayObject(i)){var u=Qs({key:i},e);o=u.key}return o}))),t[a]=n}),t}Ni.default=Qs;var Si={},xm=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Si,"__esModule",{value:!0});var gt=cr;function en(r,e){if(e===void 0&&(e=gt.DefaultOption),!gt.isValidObject(r))return null;e=gt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(gt.isValidObject(n)?gt.belongToTypes(n,e.keepTypesOnRecursion)||(n=en(n,e)):e.recursiveInArray&>.isArrayObject(n)&&(n=xm(n).map(function(i){var o=i;if(gt.isValidObject(i))gt.belongToTypes(o,e.keepTypesOnRecursion)||(o=en(i,e));else if(gt.isArrayObject(i)){var u=en({key:i},e);o=u.key}return o}))),t[a]=n}),t}Si.default=en;var Ei={},Nm=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ei,"__esModule",{value:!0});var vt=cr,Sm=Qn;function tn(r,e){if(e===void 0&&(e=vt.DefaultOption),!vt.isValidObject(r))return null;e=vt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Sm.default(s);e.recursive&&(vt.isValidObject(n)?vt.belongToTypes(n,e.keepTypesOnRecursion)||(n=tn(n,e)):e.recursiveInArray&&vt.isArrayObject(n)&&(n=Nm(n).map(function(i){var o=i;if(vt.isValidObject(i))vt.belongToTypes(o,e.keepTypesOnRecursion)||(o=tn(i,e));else if(vt.isArrayObject(i)){var u=tn({key:i},e);o=u.key}return o}))),t[a]=n}),t}Ei.default=tn;var Zi={},Em=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Zi,"__esModule",{value:!0});var wt=cr,Zm=ea;function rn(r,e){if(e===void 0&&(e=wt.DefaultOption),!wt.isValidObject(r))return null;e=wt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Zm.default(s);e.recursive&&(wt.isValidObject(n)?wt.belongToTypes(n,e.keepTypesOnRecursion)||(n=rn(n,e)):e.recursiveInArray&&wt.isArrayObject(n)&&(n=Em(n).map(function(i){var o=i;if(wt.isValidObject(i))wt.belongToTypes(o,e.keepTypesOnRecursion)||(o=rn(i,e));else if(wt.isArrayObject(i)){var u=rn({key:i},e);o=u.key}return o}))),t[a]=n}),t}Zi.default=rn;var Ii={},Im=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ii,"__esModule",{value:!0});var _t=cr,Am=ta;function sn(r,e){if(e===void 0&&(e=_t.DefaultOption),!_t.isValidObject(r))return null;e=_t.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Am.default(s);e.recursive&&(_t.isValidObject(n)?_t.belongToTypes(n,e.keepTypesOnRecursion)||(n=sn(n,e)):e.recursiveInArray&&_t.isArrayObject(n)&&(n=Im(n).map(function(i){var o=i;if(_t.isValidObject(i))_t.belongToTypes(o,e.keepTypesOnRecursion)||(o=sn(i,e));else if(_t.isArrayObject(i)){var u=sn({key:i},e);o=u.key}return o}))),t[a]=n}),t}Ii.default=sn;var Ai={},Cm=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ai,"__esModule",{value:!0});var bt=cr,$m=ra;function nn(r,e){if(e===void 0&&(e=bt.DefaultOption),!bt.isValidObject(r))return null;e=bt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=$m.default(s);e.recursive&&(bt.isValidObject(n)?bt.belongToTypes(n,e.keepTypesOnRecursion)||(n=nn(n,e)):e.recursiveInArray&&bt.isArrayObject(n)&&(n=Cm(n).map(function(i){var o=i;if(bt.isValidObject(i))bt.belongToTypes(o,e.keepTypesOnRecursion)||(o=nn(i,e));else if(bt.isArrayObject(i)){var u=nn({key:i},e);o=u.key}return o}))),t[a]=n}),t}Ai.default=nn;Object.defineProperty(Y,"__esModule",{value:!0});Y.kebabKeys=Y.pascalKeys=Y.snakeKeys=Y.camelKeys=Y.upperKeys=Y.lowerKeys=Y.toLowerCase=Y.toUpperCase=Y.toKebabCase=Y.toHeaderCase=Y.toSentenceCase=Y.toTextCase=Y.toPathCase=Y.toDotCase=Y.toPascalCase=Y.toSnakeCase=Y.toCamelCase=void 0;var su=Qn;Y.toCamelCase=su.default;var nu=ea;Y.toSnakeCase=nu.default;var au=ta;Y.toPascalCase=au.default;var iu=bi;Y.toDotCase=iu.default;var ou=ki;Y.toPathCase=ou.default;var cu=Ti;Y.toTextCase=cu.default;var uu=Oi;Y.toSentenceCase=uu.default;var lu=xi;Y.toHeaderCase=lu.default;var du=ra;Y.toKebabCase=du.default;var hu=Ni;Y.lowerKeys=hu.default;var pu=Si;Y.upperKeys=pu.default;var fu=Ei;Y.camelKeys=fu.default;var mu=Zi;Y.snakeKeys=mu.default;var yu=Ii;Y.pascalKeys=yu.default;var gu=Ai;Y.kebabKeys=gu.default;var vu=function(r){return String(r||"").toLowerCase()};Y.toLowerCase=vu;var wu=function(r){return String(r||"").toUpperCase()};Y.toUpperCase=wu;var jm={toCamelCase:su.default,toSnakeCase:nu.default,toPascalCase:au.default,toDotCase:iu.default,toPathCase:ou.default,toTextCase:cu.default,toSentenceCase:uu.default,toHeaderCase:lu.default,toKebabCase:du.default,toUpperCase:wu,toLowerCase:vu,lowerKeys:hu.default,upperKeys:pu.default,camelKeys:fu.default,snakeKeys:mu.default,pascalKeys:yu.default,kebabKeys:gu.default};Y.default=jm;var _u=Y;const bu={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Rm=r=>_u.snakeKeys(r,bu),zm=r=>_u.camelKeys(r,bu);var Un;(r=>{r.toSnake=Rm,r.toCamel=zm,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));m.object({x:Qc.or(yo),y:eu.or(yo)});const Pm=m.object({x:Qc,y:eu}),Mm=Object.freeze({x:"left",y:"top"}),Dm=(r,e)=>r.x===e.x&&r.y===e.y,go=m.union([m.number(),Ln,_i,Jc,sm,om]),Lm=(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}},vo={x:0,y:0},zs=m.union([m.number(),m.string()]);m.object({top:zs,left:zs,width:zs,height:zs});m.object({left:m.number(),top:m.number(),right:m.number(),bottom:m.number()});m.object({one:Ln,two:Ln,root:Pm});const Ci=(r,e,t=0,s=0,n)=>{const a={one:{...vo},two:{...vo},root:n??Mm};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+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??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+s}: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))},ga=r=>{const e=Ci(r);return{lower:e.one.x,upper:e.two.x}},va=r=>{const e=Ci(r);return{lower:e.one.y,upper:e.two.y}},Um=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Bm=m.object({signedWidth:m.number(),signedHeight:m.number()});m.union([Jc,Bm,Ln,_i]);const Vm=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);m.object({offset:go,scale:go});const qm=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],Km=r=>(e,t,s,n)=>[e,n?s/r:s*r],Wm=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,u=a-n,l=o-i;if(t==="dimension")return[r,s*(l/u)];const h=(s-n)*(l/u)+i;return[r,h]},Fm=r=>(e,t,s)=>[r,s],Ym=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},Gm=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=Vm(s,n,a),[e,s]},Xa=class Er{constructor(){p(this,"ops",[]),p(this,"currBounds",null),p(this,"currType",null),p(this,"reversed",!1),this.ops=[]}static translate(e){return new Er().translate(e)}static magnify(e){return new Er().magnify(e)}static scale(e,t){return new Er().scale(e,t)}translate(e){const t=this.new(),s=qm(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=Km(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=Ar(e,t),n=this.new(),a=Wm(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=Ar(e,t),n=this.new(),a=Gm(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=Ar(e,t),n=this.new(),a=Fm(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=Ym();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 Er;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};p(Xa,"IDENTITY",new Xa);let wo=Xa;const _o=class Tt{constructor(e=new wo,t=new wo,s=null){p(this,"x"),p(this,"y"),p(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new Tt().translate(e,t)}static translateX(e){return new Tt().translateX(e)}static translateY(e){return new Tt().translateY(e)}static clamp(e){return new Tt().clamp(e)}static magnify(e){return new Tt().magnify(e)}static scale(e){return new Tt().scale(e)}static reBound(e){return new Tt().reBound(e)}translate(e,t){const s=Lm(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}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(Um(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!Dm(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(ga(e)),t.y=t.y.scale(va(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(ga(e)),t.y=this.y.reBound(va(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(ga(e)),t.y=this.y.clamp(va(e)),t}copy(){const e=new Tt;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 Ci(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};p(_o,"IDENTITY",new _o);const ku=(r,e)=>{const t=new G(e);if(![ne.DAY,ne.HOUR,ne.MINUTE,ne.SECOND,ne.MILLISECOND,ne.MICROSECOND,ne.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof G?new G(s):new ne(s)},oe=class P{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=P.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*P.MILLISECOND.valueOf();else if(typeof e=="string")this.value=P.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=P.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=P.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=P.MAX:e=P.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new P(BigInt(n.getTime())*P.MILLISECOND.valueOf()).truncate(P.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=P.hours(parseInt(s??"00",10)).add(P.minutes(parseInt(n??"00",10))).add(P.seconds(parseInt(i??"00",10))).add(P.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(P.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return P.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new P(BigInt(s.getTime())*P.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(P.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new ne(BigInt(new Date().getTimezoneOffset())*P.MINUTE.valueOf())}static since(e){return new P().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new P(e).valueOf()}span(e){return this.range(e).span}range(e){return new ze(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 P(e).valueOf()}afterEq(e){return this.valueOf()>=new P(e).valueOf()}before(e){return this.valueOf()<new P(e).valueOf()}beforeEq(e){return this.valueOf()<=new P(e).valueOf()}add(e){return new P(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new P(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/P.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ku(this,e)}get isToday(){return this.truncate(ne.DAY).equals(P.now().truncate(ne.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new P(new Date)}static max(...e){let t=P.MIN;for(const s of e){const n=new P(s);n.after(t)&&(t=n)}return t}static min(...e){let t=P.MAX;for(const s of e){const n=new P(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new P(e)}static microseconds(e){return P.nanoseconds(e*1e3)}static milliseconds(e){return P.microseconds(e*1e3)}static seconds(e){return P.milliseconds(e*1e3)}static minutes(e){return P.seconds(e*60)}static hours(e){return P.minutes(e*60)}static days(e){return P.hours(e*24)}};p(oe,"NANOSECOND",oe.nanoseconds(1)),p(oe,"MICROSECOND",oe.microseconds(1)),p(oe,"MILLISECOND",oe.milliseconds(1)),p(oe,"SECOND",oe.seconds(1)),p(oe,"MINUTE",oe.minutes(1)),p(oe,"HOUR",oe.hours(1)),p(oe,"DAY",oe.days(1)),p(oe,"MAX",new oe((1n<<63n)-1n)),p(oe,"MIN",new oe(0)),p(oe,"ZERO",new oe(0)),p(oe,"z",m.union([m.object({value:m.bigint()}).transform(r=>new oe(r.value)),m.string().transform(r=>new oe(BigInt(r))),m.instanceof(Number).transform(r=>new oe(r)),m.number().transform(r=>new oe(r)),m.instanceof(oe)]));let G=oe;const ce=class te{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new te(e).valueOf()}greaterThan(e){return this.valueOf()>new te(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new te(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new te(e).valueOf()}remainder(e){return ku(this,e)}truncate(e){return new te(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(te.DAY),t=this.truncate(te.HOUR),s=this.truncate(te.MINUTE),n=this.truncate(te.SECOND),a=this.truncate(te.MILLISECOND),i=this.truncate(te.MICROSECOND),o=this.truncate(te.NANOSECOND),u=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),Q=a.sub(n),ye=i.sub(a),Re=o.sub(i);let de="";return u.isZero||(de+=`${u.days}d `),l.isZero||(de+=`${l.hours}h `),h.isZero||(de+=`${h.minutes}m `),k.isZero||(de+=`${k.seconds}s `),Q.isZero||(de+=`${Q.milliseconds}ms `),ye.isZero||(de+=`${ye.microseconds}µs `),Re.isZero||(de+=`${Re.nanoseconds}ns`),de.trim()}get days(){return Number(this.valueOf()/te.DAY.valueOf())}get hours(){return Number(this.valueOf()/te.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/te.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/te.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/te.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/te.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new te(e).valueOf()}add(e){return new te(this.valueOf()+new te(e).valueOf())}sub(e){return new te(this.valueOf()-new te(e).valueOf())}static nanoseconds(e=1){return new te(e)}static microseconds(e=1){return te.nanoseconds(e*1e3)}static milliseconds(e=1){return te.microseconds(e*1e3)}static seconds(e=1){return te.milliseconds(e*1e3)}static minutes(e){return te.seconds(e.valueOf()*60)}static hours(e){return te.minutes(e*60)}static days(e){return te.hours(e*24)}};p(ce,"NANOSECOND",ce.nanoseconds(1)),p(ce,"MICROSECOND",ce.microseconds(1)),p(ce,"MILLISECOND",ce.milliseconds(1)),p(ce,"SECOND",ce.seconds(1)),p(ce,"MINUTE",ce.minutes(1)),p(ce,"HOUR",ce.hours(1)),p(ce,"DAY",ce.days(1)),p(ce,"MAX",new ce((1n<<63n)-1n)),p(ce,"MIN",new ce(0)),p(ce,"ZERO",new ce(0)),p(ce,"z",m.union([m.object({value:m.bigint()}).transform(r=>new ce(r.value)),m.string().transform(r=>new ce(BigInt(r))),m.instanceof(Number).transform(r=>new ce(r)),m.number().transform(r=>new ce(r)),m.instanceof(ce)]));let ne=ce;const Zr=class an extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new an(e).valueOf()}get period(){return ne.seconds(1/this.valueOf())}sampleCount(e){return new ne(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ke(t).valueOf()}span(e){return ne.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new an(e)}static khz(e){return an.hz(e*1e3)}};p(Zr,"z",m.union([m.number().transform(r=>new Zr(r)),m.instanceof(Number).transform(r=>new Zr(r)),m.instanceof(Zr)]));let sa=Zr;const ve=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new bs(e*this.valueOf())}};p(ve,"UNKNOWN",new ve(0)),p(ve,"BIT128",new ve(16)),p(ve,"BIT64",new ve(8)),p(ve,"BIT32",new ve(4)),p(ve,"BIT16",new ve(2)),p(ve,"BIT8",new ve(1)),p(ve,"z",m.union([m.number().transform(r=>new ve(r)),m.instanceof(Number).transform(r=>new ve(r)),m.instanceof(ve)]));let ke=ve;const tt=class on{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new G(e.start),this.end=new G(e.end)):(this.start=new G(e),this.end=new G(t))}get span(){return new ne(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 on(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof on?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new on(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};p(tt,"MAX",new tt(G.MIN,G.MAX)),p(tt,"MIN",new tt(G.MAX,G.MIN)),p(tt,"ZERO",new tt(G.ZERO,G.ZERO)),p(tt,"z",m.union([m.object({start:G.z,end:G.z}).transform(r=>new tt(r.start,r.end)),m.instanceof(tt)]));let ze=tt;const y=class rt extends String{constructor(e){if(e instanceof rt||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=rt.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(rt.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=rt.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(rt.JSON)||this.equals(rt.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(rt.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=rt.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return rt.BIG_INT_TYPES.some(e=>e.equals(this))}};p(y,"UNKNOWN",new y("unknown")),p(y,"FLOAT64",new y("float64")),p(y,"FLOAT32",new y("float32")),p(y,"INT64",new y("int64")),p(y,"INT32",new y("int32")),p(y,"INT16",new y("int16")),p(y,"INT8",new y("int8")),p(y,"UINT64",new y("uint64")),p(y,"UINT32",new y("uint32")),p(y,"UINT16",new y("uint16")),p(y,"UINT8",new y("uint8")),p(y,"BOOLEAN",y.UINT8),p(y,"TIMESTAMP",new y("timestamp")),p(y,"UUID",new y("uuid")),p(y,"STRING",new y("string")),p(y,"JSON",new y("json")),p(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),p(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),p(y,"DENSITIES",new Map([[y.UINT8.toString(),ke.BIT8],[y.UINT16.toString(),ke.BIT16],[y.UINT32.toString(),ke.BIT32],[y.UINT64.toString(),ke.BIT64],[y.FLOAT32.toString(),ke.BIT32],[y.FLOAT64.toString(),ke.BIT64],[y.INT8.toString(),ke.BIT8],[y.INT16.toString(),ke.BIT16],[y.INT32.toString(),ke.BIT32],[y.INT64.toString(),ke.BIT64],[y.TIMESTAMP.toString(),ke.BIT64],[y.STRING.toString(),ke.UNKNOWN],[y.JSON.toString(),ke.UNKNOWN],[y.UUID.toString(),ke.BIT128]])),p(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),p(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),p(y,"z",m.union([m.string().transform(r=>new y(r)),m.instanceof(y)]));let re=y;const be=class pe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return pe.bytes(this.valueOf()+e.valueOf())}sub(e){return pe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new pe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return pe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/pe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/pe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/pe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/pe.TERABYTE.valueOf()}toString(){const e=this.truncate(pe.TERABYTE),t=this.truncate(pe.GIGABYTE),s=this.truncate(pe.MEGABYTE),n=this.truncate(pe.KILOBYTE),a=this.truncate(pe.BYTE),i=e,o=t.sub(e),u=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),u.isZero||(k+=`${u.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new pe(e)}static kilobytes(e=1){return pe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return pe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return pe.megabytes(e.valueOf()*1e3)}static terabytes(e){return pe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(be,"BYTE",new be(1)),p(be,"KILOBYTE",be.kilobytes(1)),p(be,"MEGABYTE",be.megabytes(1)),p(be,"GIGABYTE",be.gigabytes(1)),p(be,"TERABYTE",be.terabytes(1)),p(be,"ZERO",new be(0)),p(be,"z",m.union([m.number().transform(r=>new be(r)),m.instanceof(be)]));let bs=be;m.union([m.instanceof(Uint8Array),m.instanceof(Uint16Array),m.instanceof(Uint32Array),m.instanceof(BigUint64Array),m.instanceof(Float32Array),m.instanceof(Float64Array),m.instanceof(Int8Array),m.instanceof(Int16Array),m.instanceof(Int32Array),m.instanceof(BigInt64Array)]);const Tu=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof G||r instanceof ne||r instanceof Date},Jm=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(s):Ir(t,-s),Hm=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof Ee?!0:Tu(r),Ft=-1;class Ee{constructor(e){p(this,"key",""),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"_timeRange"),p(this,"alignment",0),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",Ft),p(this,"_refCount",0),p(this,"_cachedLength"),Hm(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:i=0,key:o=ef()}=e,{data:u}=e;if(u instanceof Ee){this.key=u.key,this.dataType=u.dataType,this.sampleOffset=u.sampleOffset,this.gl=u.gl,this._data=u._data,this._timeRange=u._timeRange,this.alignment=u.alignment,this._cachedMin=u._cachedMin,this._cachedMax=u._cachedMax,this.writePos=u.writePos,this._refCount=u._refCount,this._cachedLength=u._cachedLength;return}const l=Tu(u),h=Array.isArray(u);if(t!=null)this.dataType=new re(t);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(h||l){let k=u;if(!l){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");k=u[0]}if(typeof k=="string")this.dataType=re.STRING;else if(typeof k=="number")this.dataType=re.FLOAT64;else if(typeof k=="bigint")this.dataType=re.INT64;else if(typeof k=="boolean")this.dataType=re.BOOLEAN;else if(k instanceof G||k instanceof Date||k instanceof G)this.dataType=re.TIMESTAMP;else if(typeof k=="object")this.dataType=re.JSON;else throw new Error(`cannot infer data type of ${typeof k} when constructing a Series from a JS array`)}else this.dataType=new re(u)}if(!h&&!l)this._data=u;else{let k=l?[u]:u;const Q=k[0];(Q instanceof G||Q instanceof Date||Q instanceof ne)&&(k=k.map(ye=>new G(ye).valueOf())),this.dataType.equals(re.STRING)?(this._cachedLength=k.length,this._data=new TextEncoder().encode(k.join(`
|
|
1
|
+
"use strict";var td=Object.defineProperty;var sd=(s,e,t)=>e in s?td(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var d=(s,e,t)=>(sd(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod");var nd=Object.defineProperty,rd=(s,e,t)=>e in s?nd(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,le=(s,e,t)=>(rd(s,typeof e!="symbol"?e+"":e,t),t),Pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},sa={};Object.defineProperty(sa,"__esModule",{value:!0});function ad(s){return s===void 0&&(s=""),s?String(s).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()}):""}sa.default=ad;var na={};Object.defineProperty(na,"__esModule",{value:!0});function id(s){return s===void 0&&(s=""),s?String(s).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():""}na.default=id;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});function od(s){return s===void 0&&(s=""),s?String(s).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()}):""}ra.default=od;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});function cd(s){return s===void 0&&(s=""),s?String(s).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():""}Pi.default=cd;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});function ud(s){return s===void 0&&(s=""),s?String(s).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():""}Mi.default=ud;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});function ld(s){return s===void 0&&(s=""),s?String(s).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():""}Di.default=ld;var Li={};Object.defineProperty(Li,"__esModule",{value:!0});function dd(s){if(s===void 0&&(s=""),!s)return"";var e=String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,r){return n+"_"+r.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Li.default=dd;var Ui={};Object.defineProperty(Ui,"__esModule",{value:!0});function hd(s){return s===void 0&&(s=""),s?String(s).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,r){return t+n.charAt(0).toUpperCase()+n.slice(1)+r}):""}Ui.default=hd;var aa={};Object.defineProperty(aa,"__esModule",{value:!0});function pd(s){return s===void 0&&(s=""),s?String(s).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():""}aa.default=pd;var Bi={},ts={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.belongToTypes=s.isValidObject=s.isArrayObject=s.validateOptions=s.DefaultOption=void 0,s.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},s.validateOptions=function(e){return e===void 0&&(e=s.DefaultOption),e.recursive==null?e=s.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},s.isArrayObject=function(e){return e!=null&&Array.isArray(e)},s.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},s.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(ts);var fd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Bi,"__esModule",{value:!0});var at=ts;function Kn(s,e){if(e===void 0&&(e=at.DefaultOption),!at.isValidObject(s))return null;e=at.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toLowerCase();e.recursive&&(at.isValidObject(r)?at.belongToTypes(r,e.keepTypesOnRecursion)||(r=Kn(r,e)):e.recursiveInArray&&at.isArrayObject(r)&&(r=fd(r).map(function(i){var o=i;if(at.isValidObject(i))at.belongToTypes(o,e.keepTypesOnRecursion)||(o=Kn(i,e));else if(at.isArrayObject(i)){var u=Kn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Bi.default=Kn;var qi={},md=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(qi,"__esModule",{value:!0});var it=ts;function Wn(s,e){if(e===void 0&&(e=it.DefaultOption),!it.isValidObject(s))return null;e=it.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toUpperCase();e.recursive&&(it.isValidObject(r)?it.belongToTypes(r,e.keepTypesOnRecursion)||(r=Wn(r,e)):e.recursiveInArray&&it.isArrayObject(r)&&(r=md(r).map(function(i){var o=i;if(it.isValidObject(i))it.belongToTypes(o,e.keepTypesOnRecursion)||(o=Wn(i,e));else if(it.isArrayObject(i)){var u=Wn({key:i},e);o=u.key}return o}))),t[a]=r}),t}qi.default=Wn;var Vi={},yd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Vi,"__esModule",{value:!0});var ot=ts,gd=sa;function Fn(s,e){if(e===void 0&&(e=ot.DefaultOption),!ot.isValidObject(s))return null;e=ot.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=gd.default(n);e.recursive&&(ot.isValidObject(r)?ot.belongToTypes(r,e.keepTypesOnRecursion)||(r=Fn(r,e)):e.recursiveInArray&&ot.isArrayObject(r)&&(r=yd(r).map(function(i){var o=i;if(ot.isValidObject(i))ot.belongToTypes(o,e.keepTypesOnRecursion)||(o=Fn(i,e));else if(ot.isArrayObject(i)){var u=Fn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Vi.default=Fn;var Ki={},vd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Ki,"__esModule",{value:!0});var ct=ts,wd=na;function Yn(s,e){if(e===void 0&&(e=ct.DefaultOption),!ct.isValidObject(s))return null;e=ct.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=wd.default(n);e.recursive&&(ct.isValidObject(r)?ct.belongToTypes(r,e.keepTypesOnRecursion)||(r=Yn(r,e)):e.recursiveInArray&&ct.isArrayObject(r)&&(r=vd(r).map(function(i){var o=i;if(ct.isValidObject(i))ct.belongToTypes(o,e.keepTypesOnRecursion)||(o=Yn(i,e));else if(ct.isArrayObject(i)){var u=Yn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Ki.default=Yn;var Wi={},bd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Wi,"__esModule",{value:!0});var ut=ts,_d=ra;function Jn(s,e){if(e===void 0&&(e=ut.DefaultOption),!ut.isValidObject(s))return null;e=ut.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=_d.default(n);e.recursive&&(ut.isValidObject(r)?ut.belongToTypes(r,e.keepTypesOnRecursion)||(r=Jn(r,e)):e.recursiveInArray&&ut.isArrayObject(r)&&(r=bd(r).map(function(i){var o=i;if(ut.isValidObject(i))ut.belongToTypes(o,e.keepTypesOnRecursion)||(o=Jn(i,e));else if(ut.isArrayObject(i)){var u=Jn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Wi.default=Jn;var Fi={},kd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Fi,"__esModule",{value:!0});var lt=ts,Od=aa;function Gn(s,e){if(e===void 0&&(e=lt.DefaultOption),!lt.isValidObject(s))return null;e=lt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Od.default(n);e.recursive&&(lt.isValidObject(r)?lt.belongToTypes(r,e.keepTypesOnRecursion)||(r=Gn(r,e)):e.recursiveInArray&<.isArrayObject(r)&&(r=kd(r).map(function(i){var o=i;if(lt.isValidObject(i))lt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Gn(i,e));else if(lt.isArrayObject(i)){var u=Gn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Fi.default=Gn;Object.defineProperty(F,"__esModule",{value:!0});F.kebabKeys=F.pascalKeys=F.snakeKeys=F.camelKeys=F.upperKeys=F.lowerKeys=F.toLowerCase=F.toUpperCase=F.toKebabCase=F.toHeaderCase=F.toSentenceCase=F.toTextCase=F.toPathCase=F.toDotCase=F.toPascalCase=F.toSnakeCase=F.toCamelCase=void 0;var ac=sa;F.toCamelCase=ac.default;var ic=na;F.toSnakeCase=ic.default;var oc=ra;F.toPascalCase=oc.default;var cc=Pi;F.toDotCase=cc.default;var uc=Mi;F.toPathCase=uc.default;var lc=Di;F.toTextCase=lc.default;var dc=Li;F.toSentenceCase=dc.default;var hc=Ui;F.toHeaderCase=hc.default;var pc=aa;F.toKebabCase=pc.default;var fc=Bi;F.lowerKeys=fc.default;var mc=qi;F.upperKeys=mc.default;var yc=Vi;F.camelKeys=yc.default;var gc=Ki;F.snakeKeys=gc.default;var vc=Wi;F.pascalKeys=vc.default;var wc=Fi;F.kebabKeys=wc.default;var bc=function(s){return String(s||"").toLowerCase()};F.toLowerCase=bc;var _c=function(s){return String(s||"").toUpperCase()};F.toUpperCase=_c;var Td={toCamelCase:ac.default,toSnakeCase:ic.default,toPascalCase:oc.default,toDotCase:cc.default,toPathCase:uc.default,toTextCase:lc.default,toSentenceCase:dc.default,toHeaderCase:hc.default,toKebabCase:pc.default,toUpperCase:_c,toLowerCase:bc,lowerKeys:fc.default,upperKeys:mc.default,camelKeys:yc.default,snakeKeys:gc.default,pascalKeys:vc.default,kebabKeys:wc.default};F.default=Td;var kc=F;const Oc={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},xd=s=>kc.snakeKeys(s,Oc),Sd=s=>kc.camelKeys(s,Oc);var Q;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(Q||(Q={}));var Ha;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ha||(Ha={}));const O=Q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zt=s=>{switch(typeof s){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(s)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(s)?O.array:s===null?O.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?O.promise:typeof Map<"u"&&s instanceof Map?O.map:typeof Set<"u"&&s instanceof Set?O.set:typeof Date<"u"&&s instanceof Date?O.date:O.object;default:return O.unknown}},w=Q.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"]),Ed=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let qe=class 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:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(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 l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};qe.create=s=>new qe(s);const Ps=(s,e)=>{let t;switch(s.code){case w.invalid_type:s.received===O.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,Q.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${Q.joinValues(s.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Q.joinValues(s.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${Q.joinValues(s.options)}, received '${s.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:Q.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case w.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case w.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,Q.assertNever(s)}return{message:t}};let Tc=Ps;function Nd(s){Tc=s}function yr(){return Tc}const gr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},Id=[];function S(s,e){const t=gr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,yr(),Ps].filter(n=>!!n)});s.common.issues.push(t)}let Ce=class xc{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 r of t){if(r.status==="aborted")return M;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return xc.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return M;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const M=Object.freeze({status:"aborted"}),Sc=s=>({status:"dirty",value:s}),Ne=s=>({status:"valid",value:s}),Xa=s=>s.status==="aborted",Qa=s=>s.status==="dirty",Ms=s=>s.status==="valid",vr=s=>typeof Promise<"u"&&s instanceof Promise;var I;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));let st=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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 So=(s,e)=>{if(Ms(e))return{success:!0,data:e.value};if(!s.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 qe(s.common.issues);return this._error=t,this._error}}};function U(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;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:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let V=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 Zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ce,ctx:{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(vr(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 r={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:Zt(e)},a=this._parseSync({data:e,path:r.path,parent:r});return So(r,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:Zt(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(vr(r)?r:Promise.resolve(r));return So(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:w.custom,...n(r)});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,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Fe({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kt.create(this,this._def)}nullable(){return Yt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ft.create(this,this._def)}promise(){return hs.create(this,this._def)}or(e){return Ks.create([this,e],this._def)}and(e){return Ws.create(this,e,this._def)}transform(e){return new Fe({...U(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Gs({...U(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Cc({typeName:$.ZodBranded,type:this,...U(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Or({...U(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return $n.create(this,e)}readonly(){return xr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Zd=/^c[^\s-]{8,}$/i,Ad=/^[a-z][a-z0-9]*$/,Cd=/^[0-9A-HJKMNP-TV-Z]{26}$/,$d=/^[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,jd=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ia;const Rd=/^(((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}))$/,Pd=/^(([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})))$/,Md=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.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$"):s.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 Dd(s,e){return!!((e==="v4"||!e)&&Rd.test(s)||(e==="v6"||!e)&&Pd.test(s))}let ls=class Ss extends V{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.string,received:r.parsedType}),M}const t=new Ce;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?S(n,{code:w.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&S(n,{code:w.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")jd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"email",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")Ia||(Ia=new RegExp(zd,"u")),Ia.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"emoji",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")$d.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"uuid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")Zd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")Ad.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid2",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")Cd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ulid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),S(n,{validation:"url",code:w.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"regex",code:w.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?Md(r).test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?Dd(e.data,r.version)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ip",code:w.invalid_string,message:r.message}),t.dirty()):Q.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:w.invalid_string,...I.errToObj(n)})}_addCheck(e){return new Ss({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...I.errToObj(e)})}url(e){return this._addCheck({kind:"url",...I.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...I.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...I.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...I.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...I.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...I.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...I.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,...I.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...I.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...I.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...I.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...I.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...I.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...I.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...I.errToObj(t)})}nonempty(e){return this.min(1,I.errToObj(e))}trim(){return new Ss({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ss({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ss({...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}};ls.create=s=>{var e;return new ls({checks:[],typeName:$.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...U(s)})};function Ld(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let Ds=class ei extends V{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)!==O.number){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.number,received:r.parsedType}),M}let t;const n=new Ce;for(const r of this._def.checks)r.kind==="int"?Q.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?Ld(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_finite,message:r.message}),n.dirty()):Q.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,n,r){return new ei({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:I.toString(r)}]})}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:I.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:I.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.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"&&Q.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)}};Ds.create=s=>new Ds({checks:[],typeName:$.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...U(s)});let Ls=class ti extends V{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)!==O.bigint){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.bigint,received:r.parsedType}),M}let t;const n=new Ce;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Q.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,n,r){return new ti({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:I.toString(r)}]})}_addCheck(e){return new ti({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.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}};Ls.create=s=>{var e;return new Ls({checks:[],typeName:$.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...U(s)})};let Us=class extends V{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.boolean,received:t.parsedType}),M}return Ne(e.data)}};Us.create=s=>new Us({typeName:$.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...U(s)});let Bs=class Ec extends V{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.date,received:r.parsedType}),M}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_date}),M}const t=new Ce;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):Q.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ec({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.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}};Bs.create=s=>new Bs({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:$.ZodDate,...U(s)});class wr extends V{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.symbol,received:t.parsedType}),M}return Ne(e.data)}}wr.create=s=>new wr({typeName:$.ZodSymbol,...U(s)});let qs=class extends V{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.undefined,received:t.parsedType}),M}return Ne(e.data)}};qs.create=s=>new qs({typeName:$.ZodUndefined,...U(s)});let Vs=class extends V{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.null,received:t.parsedType}),M}return Ne(e.data)}};Vs.create=s=>new Vs({typeName:$.ZodNull,...U(s)});let ds=class extends V{constructor(){super(...arguments),this._any=!0}_parse(e){return Ne(e.data)}};ds.create=s=>new ds({typeName:$.ZodAny,...U(s)});let Bt=class extends V{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ne(e.data)}};Bt.create=s=>new Bt({typeName:$.ZodUnknown,...U(s)});let xt=class extends V{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.never,received:t.parsedType}),M}};xt.create=s=>new xt({typeName:$.ZodNever,...U(s)});class br extends V{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.void,received:t.parsedType}),M}return Ne(e.data)}}br.create=s=>new br({typeName:$.ZodVoid,...U(s)});let Ft=class Hn extends V{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==O.array)return S(t,{code:w.invalid_type,expected:O.array,received:t.parsedType}),M;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(S(t,{code:i?w.too_big:w.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(S(t,{code:w.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(S(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new st(t,i,t.path,o)))).then(i=>Ce.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new st(t,i,t.path,o)));return Ce.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Hn({...this._def,minLength:{value:e,message:I.toString(t)}})}max(e,t){return new Hn({...this._def,maxLength:{value:e,message:I.toString(t)}})}length(e,t){return new Hn({...this._def,exactLength:{value:e,message:I.toString(t)}})}nonempty(e){return this.min(1,e)}};Ft.create=(s,e)=>new Ft({type:s,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...U(e)});function rs(s){if(s instanceof Me){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=kt.create(rs(n))}return new Me({...s._def,shape:()=>e})}else return s instanceof Ft?new Ft({...s._def,type:rs(s.element)}):s instanceof kt?kt.create(rs(s.unwrap())):s instanceof Yt?Yt.create(rs(s.unwrap())):s instanceof $t?$t.create(s.items.map(e=>rs(e))):s}let Me=class Ue extends V{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=Q.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const u=this._getOrReturnCtx(e);return S(u,{code:w.invalid_type,expected:O.object,received:u.parsedType}),M}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof xt&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new st(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof xt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(S(n,{code:w.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 l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new st(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>Ce.mergeObjectSync(t,u)):Ce.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return I.errToObj,new Ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=I.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Ue({...this._def,unknownKeys:"strip"})}passthrough(){return new Ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ue({...this._def,catchall:e})}pick(e){const t={};return Q.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ue({...this._def,shape:()=>t})}omit(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ue({...this._def,shape:()=>t})}deepPartial(){return rs(this)}partial(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new Ue({...this._def,shape:()=>t})}required(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof kt;)r=r._def.innerType;t[n]=r}}),new Ue({...this._def,shape:()=>t})}keyof(){return Ac(Q.objectKeys(this.shape))}};Me.create=(s,e)=>new Me({shape:()=>s,unknownKeys:"strip",catchall:xt.create(),typeName:$.ZodObject,...U(e)});Me.strictCreate=(s,e)=>new Me({shape:()=>s,unknownKeys:"strict",catchall:xt.create(),typeName:$.ZodObject,...U(e)});Me.lazycreate=(s,e)=>new Me({shape:s,unknownKeys:"strip",catchall:xt.create(),typeName:$.ZodObject,...U(e)});let Ks=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(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 qe(o.ctx.common.issues));return S(t,{code:w.invalid_union,unionErrors:i}),M}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(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new qe(u));return S(t,{code:w.invalid_union,unionErrors:o}),M}}get options(){return this._def.options}};Ks.create=(s,e)=>new Ks({options:s,typeName:$.ZodUnion,...U(e)});const Xn=s=>s instanceof Fs?Xn(s.schema):s instanceof Fe?Xn(s.innerType()):s instanceof Ys?[s.value]:s instanceof Cn?s.options:s instanceof Js?Object.keys(s.enum):s instanceof Gs?Xn(s._def.innerType):s instanceof qs?[void 0]:s instanceof Vs?[null]:null;class ia extends V{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:w.invalid_type,expected:O.object,received:t.parsedType}),M;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);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}):(S(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),M)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=Xn(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ia({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...U(n)})}}function si(s,e){const t=Zt(s),n=Zt(e);if(s===e)return{valid:!0,data:s};if(t===O.object&&n===O.object){const r=Q.objectKeys(e),a=Q.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=si(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===O.array&&n===O.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=si(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===O.date&&n===O.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let Ws=class extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Xa(a)||Xa(i))return M;const o=si(a.value,i.value);return o.valid?((Qa(a)||Qa(i))&&t.dirty(),{status:t.value,value:o.data}):(S(n,{code:w.invalid_intersection_types}),M)};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])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ws.create=(s,e,t)=>new Ws({left:s,right:e,typeName:$.ZodIntersection,...U(t)});let $t=class Nc extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.array)return S(n,{code:w.invalid_type,expected:O.array,received:n.parsedType}),M;if(n.data.length<this._def.items.length)return S(n,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&n.data.length>this._def.items.length&&(S(n,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new st(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>Ce.mergeArray(t,a)):Ce.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Nc({...this._def,rest:e})}};$t.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $t({items:s,typeName:$.ZodTuple,rest:null,...U(e)})};let Ic=class ni extends V{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!==O.object)return S(n,{code:w.invalid_type,expected:O.object,received:n.parsedType}),M;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new st(n,o,n.path,o)),value:i._parse(new st(n,n.data[o],n.path,o))});return n.common.async?Ce.mergeObjectAsync(t,r):Ce.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof V?new ni({keyType:e,valueType:t,typeName:$.ZodRecord,...U(n)}):new ni({keyType:ls.create(),valueType:e,typeName:$.ZodRecord,...U(t)})}};class _r extends V{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!==O.map)return S(n,{code:w.invalid_type,expected:O.map,received:n.parsedType}),M;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new st(n,o,n.path,[l,"key"])),value:a._parse(new st(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}_r.create=(s,e,t)=>new _r({valueType:e,keyType:s,typeName:$.ZodMap,...U(t)});let kr=class ri extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.set)return S(n,{code:w.invalid_type,expected:O.set,received:n.parsedType}),M;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(S(n,{code:w.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(S(n,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return M;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new st(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new ri({...this._def,minSize:{value:e,message:I.toString(t)}})}max(e,t){return new ri({...this._def,maxSize:{value:e,message:I.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};kr.create=(s,e)=>new kr({valueType:s,minSize:null,maxSize:null,typeName:$.ZodSet,...U(e)});let Zc=class Qn extends V{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:w.invalid_type,expected:O.function,received:t.parsedType}),M;function n(o,u){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Ps].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:u}})}function r(o,u){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Ps].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof hs){const o=this;return Ne(async function(...u){const l=new qe([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ne(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new qe([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new qe([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Qn({...this._def,args:$t.create(e).rest(Bt.create())})}returns(e){return new Qn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Qn({args:e||$t.create([]).rest(Bt.create()),returns:t||Bt.create(),typeName:$.ZodFunction,...U(n)})}},Fs=class extends V{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})}};Fs.create=(s,e)=>new Fs({getter:s,typeName:$.ZodLazy,...U(e)});let Ys=class extends V{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ys.create=(s,e)=>new Ys({value:s,typeName:$.ZodLiteral,...U(e)});function Ac(s,e){return new Cn({values:s,typeName:$.ZodEnum,...U(e)})}let Cn=class ai extends V{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{expected:Q.joinValues(n),received:t.parsedType,code:w.invalid_type}),M}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{received:t.data,code:w.invalid_enum_value,options:n}),M}return Ne(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 ai.create(e)}exclude(e){return ai.create(this.options.filter(t=>!e.includes(t)))}};Cn.create=Ac;let Js=class extends V{_parse(e){const t=Q.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==O.string&&n.parsedType!==O.number){const r=Q.objectValues(t);return S(n,{expected:Q.joinValues(r),received:n.parsedType,code:w.invalid_type}),M}if(t.indexOf(e.data)===-1){const r=Q.objectValues(t);return S(n,{received:n.data,code:w.invalid_enum_value,options:r}),M}return Ne(e.data)}get enum(){return this._def.values}};Js.create=(s,e)=>new Js({values:s,typeName:$.ZodNativeEnum,...U(e)});let hs=class extends V{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:w.invalid_type,expected:O.promise,received:t.parsedType}),M;const n=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return Ne(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};hs.create=(s,e)=>new hs({type:s,typeName:$.ZodPromise,...U(e)});let Fe=class extends V{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{S(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.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(r.type==="refinement"){const i=o=>{const u=r.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"?M:(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"?M:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ms(i))return i;const o=r.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=>Ms(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Q.assertNever(r)}};Fe.create=(s,e,t)=>new Fe({schema:s,typeName:$.ZodEffects,effect:e,...U(t)});Fe.createWithPreprocess=(s,e,t)=>new Fe({schema:e,effect:{type:"preprocess",transform:s},typeName:$.ZodEffects,...U(t)});let kt=class extends V{_parse(e){return this._getType(e)===O.undefined?Ne(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};kt.create=(s,e)=>new kt({innerType:s,typeName:$.ZodOptional,...U(e)});let Yt=class extends V{_parse(e){return this._getType(e)===O.null?Ne(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Yt.create=(s,e)=>new Yt({innerType:s,typeName:$.ZodNullable,...U(e)});let Gs=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===O.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Gs.create=(s,e)=>new Gs({innerType:s,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...U(e)});class Or extends V{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vr(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qe(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new qe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Or.create=(s,e)=>new Or({innerType:s,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...U(e)});class Tr extends V{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.nan,received:t.parsedType}),M}return{status:"valid",value:e.data}}}Tr.create=s=>new Tr({typeName:$.ZodNaN,...U(s)});const Ud=Symbol("zod_brand");class Cc extends V{_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 $n extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?M:r.status==="dirty"?(t.dirty(),Sc(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?M:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new $n({in:e,out:t,typeName:$.ZodPipeline})}}class xr extends V{_parse(e){const t=this._def.innerType._parse(e);return Ms(t)&&(t.value=Object.freeze(t.value)),t}}xr.create=(s,e)=>new xr({innerType:s,typeName:$.ZodReadonly,...U(e)});const $c=(s,e={},t)=>s?ds.create().superRefine((n,r)=>{var a,i;if(!s(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,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):ds.create(),Bd={object:Me.lazycreate};var $;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})($||($={}));const qd=(s,e={message:`Input not instance of ${s.name}`})=>$c(t=>t instanceof s,e),jc=ls.create,zc=Ds.create,Vd=Tr.create,Kd=Ls.create,Rc=Us.create,Wd=Bs.create,Fd=wr.create,Yd=qs.create,Jd=Vs.create,Gd=ds.create,Hd=Bt.create,Xd=xt.create,Qd=br.create,eh=Ft.create,th=Me.create,sh=Me.strictCreate,nh=Ks.create,rh=ia.create,ah=Ws.create,ih=$t.create,oh=Ic.create,ch=_r.create,uh=kr.create,lh=Zc.create,dh=Fs.create,hh=Ys.create,ph=Cn.create,fh=Js.create,mh=hs.create,Eo=Fe.create,yh=kt.create,gh=Yt.create,vh=Fe.createWithPreprocess,wh=$n.create,bh=()=>jc().optional(),_h=()=>zc().optional(),kh=()=>Rc().optional(),Oh={string:s=>ls.create({...s,coerce:!0}),number:s=>Ds.create({...s,coerce:!0}),boolean:s=>Us.create({...s,coerce:!0}),bigint:s=>Ls.create({...s,coerce:!0}),date:s=>Bs.create({...s,coerce:!0})},Th=M;var p=Object.freeze({__proto__:null,defaultErrorMap:Ps,setErrorMap:Nd,getErrorMap:yr,makeIssue:gr,EMPTY_PATH:Id,addIssueToContext:S,ParseStatus:Ce,INVALID:M,DIRTY:Sc,OK:Ne,isAborted:Xa,isDirty:Qa,isValid:Ms,isAsync:vr,get util(){return Q},get objectUtil(){return Ha},ZodParsedType:O,getParsedType:Zt,ZodType:V,ZodString:ls,ZodNumber:Ds,ZodBigInt:Ls,ZodBoolean:Us,ZodDate:Bs,ZodSymbol:wr,ZodUndefined:qs,ZodNull:Vs,ZodAny:ds,ZodUnknown:Bt,ZodNever:xt,ZodVoid:br,ZodArray:Ft,ZodObject:Me,ZodUnion:Ks,ZodDiscriminatedUnion:ia,ZodIntersection:Ws,ZodTuple:$t,ZodRecord:Ic,ZodMap:_r,ZodSet:kr,ZodFunction:Zc,ZodLazy:Fs,ZodLiteral:Ys,ZodEnum:Cn,ZodNativeEnum:Js,ZodPromise:hs,ZodEffects:Fe,ZodTransformer:Fe,ZodOptional:kt,ZodNullable:Yt,ZodDefault:Gs,ZodCatch:Or,ZodNaN:Tr,BRAND:Ud,ZodBranded:Cc,ZodPipeline:$n,ZodReadonly:xr,custom:$c,Schema:V,ZodSchema:V,late:Bd,get ZodFirstPartyTypeKind(){return $},coerce:Oh,any:Gd,array:eh,bigint:Kd,boolean:Rc,date:Wd,discriminatedUnion:rh,effect:Eo,enum:ph,function:lh,instanceof:qd,intersection:ah,lazy:dh,literal:hh,map:ch,nan:Vd,nativeEnum:fh,never:Xd,null:Jd,nullable:gh,number:zc,object:th,oboolean:kh,onumber:_h,optional:yh,ostring:bh,pipeline:wh,preprocess:vh,promise:mh,record:oh,set:uh,strictObject:sh,string:jc,symbol:Fd,transformer:Eo,tuple:ih,undefined:Yd,union:nh,unknown:Hd,void:Qd,NEVER:Th,ZodIssueCode:w,quotelessJson:Ed,ZodError:qe});const oa=p.tuple([p.number(),p.number()]);p.tuple([p.bigint(),p.bigint()]);const Pc=p.object({width:p.number(),height:p.number()}),xh=p.object({signedWidth:p.number(),signedHeight:p.number()}),Sh=["width","height"];p.enum(Sh);const Eh=["start","center","end"],Nh=["signedWidth","signedHeight"];p.enum(Nh);const Sr=p.object({x:p.number(),y:p.number()}),Ih=p.object({clientX:p.number(),clientY:p.number()}),Zh=["x","y"],Mc=p.enum(Zh),Dc=["top","right","bottom","left"];p.enum(Dc);const Ah=["left","right"],Lc=p.enum(Ah),Ch=["top","bottom"],Uc=p.enum(Ch),Bc=["center"],No=p.enum(Bc),$h=[...Dc,...Bc],qc=p.enum($h);p.enum(Eh);const jh=["first","last"];p.enum(jh);const zh=p.object({lower:p.number(),upper:p.number()}),Rh=p.object({lower:p.bigint(),upper:p.bigint()});p.union([zh,oa]);p.union([Rh,oa]);p.union([Mc,qc]);p.union([Mc,qc,p.instanceof(String)]);const Za=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Io(s);return Io(t)},Io=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s;p.object({x:Lc.or(No),y:Uc.or(No)});const Ph=p.object({x:Lc,y:Uc}),Mh=Object.freeze({x:"left",y:"top"}),Dh=(s,e)=>s.x===e.x&&s.y===e.y,Zo=p.union([p.number(),Sr,oa,Pc,xh,Ih]),Lh=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},Ao=Object.freeze({x:0,y:0}),Bn=p.union([p.number(),p.string()]);p.object({top:Bn,left:Bn,width:Bn,height:Bn});p.object({left:p.number(),top:p.number(),right:p.number(),bottom:p.number()});p.object({one:Sr,two:Sr,root:Ph});const Yi=(s,e,t=0,n=0,r)=>{const a={one:{...Ao},two:{...Ao},root:r??Mh};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,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))},Aa=s=>{const e=Yi(s);return{lower:e.one.x,upper:e.two.x}},Ca=s=>{const e=Yi(s);return{lower:e.one.y,upper:e.two.y}},Uh=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,Bh=p.object({signedWidth:p.number(),signedHeight:p.number()});p.union([Pc,Bh,Sr,oa]);var qh=Object.defineProperty,Vh=(s,e,t)=>e in s?qh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bt=(s,e,t)=>(Vh(s,typeof e!="symbol"?e+"":e,t),t);const Kh=(s,e,t)=>(e!=null&&(s=Math.max(s,e)),t!=null&&(s=Math.min(s,t)),s);p.object({offset:Zo,scale:Zo});const Wh=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],Fh=s=>(e,t,n,r)=>[e,r?n/s:n*s],Yh=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:i,upper:o}=s,u=a-r,l=o-i;if(t==="dimension")return[s,n*(l/u)];const h=(n-r)*(l/u)+i;return[s,h]},Jh=s=>(e,t,n)=>[s,n],Gh=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Hh=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=Kh(n,r,a),[e,n]},ii=class Es{constructor(){bt(this,"ops",[]),bt(this,"currBounds",null),bt(this,"currType",null),bt(this,"reversed",!1),this.ops=[]}static translate(e){return new Es().translate(e)}static magnify(e){return new Es().magnify(e)}static scale(e,t){return new Es().scale(e,t)}translate(e){const t=this.new(),n=Wh(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Fh(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Za(e,t),r=this.new(),a=Yh(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=Za(e,t),r=this.new(),a=Hh(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=Za(e,t),r=this.new(),a=Jh(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Gh();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 Es;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([i,o])=>r>=i&&r<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}};bt(ii,"IDENTITY",new ii);let Co=ii;const $o=class gt{constructor(e=new Co,t=new Co,n=null){bt(this,"x"),bt(this,"y"),bt(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new gt().translate(e,t)}static translateX(e){return new gt().translateX(e)}static translateY(e){return new gt().translateY(e)}static clamp(e){return new gt().clamp(e)}static magnify(e){return new gt().magnify(e)}static scale(e){return new gt().scale(e)}static reBound(e){return new gt().reBound(e)}translate(e,t){const n=Lh(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}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(Uh(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Dh(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(Aa(e)),t.y=t.y.scale(Ca(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(Aa(e)),t.y=this.y.reBound(Ca(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Aa(e)),t.y=this.y.clamp(Ca(e)),t}copy(){const e=new gt;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 Yi(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};bt($o,"IDENTITY",new $o);var Xh=Object.defineProperty,Qh=(s,e,t)=>e in s?Xh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e,t)=>(Qh(s,typeof e!="symbol"?e+"":e,t),t);const Vc=(s,e)=>{const t=new we(e);if(![be.DAY,be.HOUR,be.MINUTE,be.SECOND,be.MILLISECOND,be.MICROSECOND,be.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof we?new we(n):new be(n)},ae=class R{constructor(e,t="UTC"){if(k(this,"value"),k(this,"encodeValue",!0),e==null)this.value=R.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*R.MILLISECOND.valueOf();else if(typeof e=="string")this.value=R.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=R.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=R.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=R.MAX:e=R.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new R(BigInt(r.getTime())*R.MILLISECOND.valueOf()).truncate(R.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=R.hours(parseInt(n??"00",10)).add(R.minutes(parseInt(r??"00",10))).add(R.seconds(parseInt(i??"00",10))).add(R.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(R.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return R.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new R(BigInt(n.getTime())*R.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(R.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"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new be(BigInt(new Date().getTimezoneOffset())*R.MINUTE.valueOf())}static since(e){return new R().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new R(e).valueOf()}span(e){return this.range(e).span}range(e){return new ep(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 R(e).valueOf()}afterEq(e){return this.valueOf()>=new R(e).valueOf()}before(e){return this.valueOf()<new R(e).valueOf()}beforeEq(e){return this.valueOf()<=new R(e).valueOf()}add(e){return new R(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new R(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/R.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Vc(this,e)}get isToday(){return this.truncate(be.DAY).equals(R.now().truncate(be.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new R(new Date)}static max(...e){let t=R.MIN;for(const n of e){const r=new R(n);r.after(t)&&(t=r)}return t}static min(...e){let t=R.MAX;for(const n of e){const r=new R(n);r.before(t)&&(t=r)}return t}static nanoseconds(e){return new R(e)}static microseconds(e){return R.nanoseconds(e*1e3)}static milliseconds(e){return R.microseconds(e*1e3)}static seconds(e){return R.milliseconds(e*1e3)}static minutes(e){return R.seconds(e*60)}static hours(e){return R.minutes(e*60)}static days(e){return R.hours(e*24)}};k(ae,"NANOSECOND",ae.nanoseconds(1)),k(ae,"MICROSECOND",ae.microseconds(1)),k(ae,"MILLISECOND",ae.milliseconds(1)),k(ae,"SECOND",ae.seconds(1)),k(ae,"MINUTE",ae.minutes(1)),k(ae,"HOUR",ae.hours(1)),k(ae,"DAY",ae.days(1)),k(ae,"MAX",new ae((1n<<63n)-1n)),k(ae,"MIN",new ae(0)),k(ae,"ZERO",new ae(0)),k(ae,"z",p.union([p.object({value:p.bigint()}).transform(s=>new ae(s.value)),p.string().transform(s=>new ae(BigInt(s))),p.instanceof(Number).transform(s=>new ae(s)),p.number().transform(s=>new ae(s)),p.instanceof(ae)]));let we=ae;const ie=class ne{constructor(e){k(this,"value"),k(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 ne(e).valueOf()}greaterThan(e){return this.valueOf()>new ne(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ne(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ne(e).valueOf()}remainder(e){return Vc(this,e)}truncate(e){return new ne(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(ne.DAY),t=this.truncate(ne.HOUR),n=this.truncate(ne.MINUTE),r=this.truncate(ne.SECOND),a=this.truncate(ne.MILLISECOND),i=this.truncate(ne.MICROSECOND),o=this.truncate(ne.NANOSECOND),u=e,l=t.sub(e),h=n.sub(t),g=r.sub(n),se=a.sub(r),ye=i.sub(a),ze=o.sub(i);let he="";return u.isZero||(he+=`${u.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),g.isZero||(he+=`${g.seconds}s `),se.isZero||(he+=`${se.milliseconds}ms `),ye.isZero||(he+=`${ye.microseconds}µs `),ze.isZero||(he+=`${ze.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/ne.DAY.valueOf())}get hours(){return Number(this.valueOf()/ne.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/ne.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/ne.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/ne.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/ne.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new ne(e).valueOf()}add(e){return new ne(this.valueOf()+new ne(e).valueOf())}sub(e){return new ne(this.valueOf()-new ne(e).valueOf())}static nanoseconds(e=1){return new ne(e)}static microseconds(e=1){return ne.nanoseconds(e*1e3)}static milliseconds(e=1){return ne.microseconds(e*1e3)}static seconds(e=1){return ne.milliseconds(e*1e3)}static minutes(e){return ne.seconds(e.valueOf()*60)}static hours(e){return ne.minutes(e*60)}static days(e){return ne.hours(e*24)}};k(ie,"NANOSECOND",ie.nanoseconds(1)),k(ie,"MICROSECOND",ie.microseconds(1)),k(ie,"MILLISECOND",ie.milliseconds(1)),k(ie,"SECOND",ie.seconds(1)),k(ie,"MINUTE",ie.minutes(1)),k(ie,"HOUR",ie.hours(1)),k(ie,"DAY",ie.days(1)),k(ie,"MAX",new ie((1n<<63n)-1n)),k(ie,"MIN",new ie(0)),k(ie,"ZERO",new ie(0)),k(ie,"z",p.union([p.object({value:p.bigint()}).transform(s=>new ie(s.value)),p.string().transform(s=>new ie(BigInt(s))),p.instanceof(Number).transform(s=>new ie(s)),p.number().transform(s=>new ie(s)),p.instanceof(ie)]));let be=ie;const qn=class er extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new er(e).valueOf()}get period(){return be.seconds(1/this.valueOf())}sampleCount(e){return new be(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Se(t).valueOf()}span(e){return be.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new er(e)}static khz(e){return er.hz(e*1e3)}};k(qn,"z",p.union([p.number().transform(s=>new qn(s)),p.instanceof(Number).transform(s=>new qn(s)),p.instanceof(qn)]));const ge=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new tp(e*this.valueOf())}};k(ge,"UNKNOWN",new ge(0)),k(ge,"BIT128",new ge(16)),k(ge,"BIT64",new ge(8)),k(ge,"BIT32",new ge(4)),k(ge,"BIT16",new ge(2)),k(ge,"BIT8",new ge(1)),k(ge,"z",p.union([p.number().transform(s=>new ge(s)),p.instanceof(Number).transform(s=>new ge(s)),p.instanceof(ge)]));let Se=ge;const Ge=class tr{constructor(e,t){k(this,"start"),k(this,"end"),typeof e=="object"&&"start"in e?(this.start=new we(e.start),this.end=new we(e.end)):(this.start=new we(e),this.end=new we(t))}get span(){return new be(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 tr(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=be.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 r=we.max(n.start,e.start),a=we.min(n.end,e.end);return a.before(r)?!1:new be(a.sub(r)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}contains(e){return e instanceof tr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new tr(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}};k(Ge,"MAX",new Ge(we.MIN,we.MAX)),k(Ge,"MIN",new Ge(we.MAX,we.MIN)),k(Ge,"ZERO",new Ge(we.ZERO,we.ZERO)),k(Ge,"z",p.union([p.object({start:we.z,end:we.z}).transform(s=>new Ge(s.start,s.end)),p.instanceof(Ge)]));let ep=Ge;const y=class He extends String{constructor(e){if(e instanceof He||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=He.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(He.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=He.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(He.JSON)||this.equals(He.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(He.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=He.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 He.BIG_INT_TYPES.some(e=>e.equals(this))}};k(y,"UNKNOWN",new y("unknown")),k(y,"FLOAT64",new y("float64")),k(y,"FLOAT32",new y("float32")),k(y,"INT64",new y("int64")),k(y,"INT32",new y("int32")),k(y,"INT16",new y("int16")),k(y,"INT8",new y("int8")),k(y,"UINT64",new y("uint64")),k(y,"UINT32",new y("uint32")),k(y,"UINT16",new y("uint16")),k(y,"UINT8",new y("uint8")),k(y,"BOOLEAN",y.UINT8),k(y,"TIMESTAMP",new y("timestamp")),k(y,"UUID",new y("uuid")),k(y,"STRING",new y("string")),k(y,"JSON",new y("json")),k(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),k(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),k(y,"DENSITIES",new Map([[y.UINT8.toString(),Se.BIT8],[y.UINT16.toString(),Se.BIT16],[y.UINT32.toString(),Se.BIT32],[y.UINT64.toString(),Se.BIT64],[y.FLOAT32.toString(),Se.BIT32],[y.FLOAT64.toString(),Se.BIT64],[y.INT8.toString(),Se.BIT8],[y.INT16.toString(),Se.BIT16],[y.INT32.toString(),Se.BIT32],[y.INT64.toString(),Se.BIT64],[y.TIMESTAMP.toString(),Se.BIT64],[y.STRING.toString(),Se.UNKNOWN],[y.JSON.toString(),Se.UNKNOWN],[y.UUID.toString(),Se.BIT128]])),k(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),k(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),k(y,"z",p.union([p.string().transform(s=>new y(s)),p.instanceof(y)]));const _e=class pe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return pe.bytes(this.valueOf()+e.valueOf())}sub(e){return pe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new pe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return pe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/pe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/pe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/pe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/pe.TERABYTE.valueOf()}toString(){const e=this.truncate(pe.TERABYTE),t=this.truncate(pe.GIGABYTE),n=this.truncate(pe.MEGABYTE),r=this.truncate(pe.KILOBYTE),a=this.truncate(pe.BYTE),i=e,o=t.sub(e),u=n.sub(t),l=r.sub(n),h=a.sub(r);let g="";return i.isZero||(g+=`${i.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),u.isZero||(g+=`${u.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!h.isZero||g==="")&&(g+=`${h.valueOf()}B`),g.trim()}static bytes(e=1){return new pe(e)}static kilobytes(e=1){return pe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return pe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return pe.megabytes(e.valueOf()*1e3)}static terabytes(e){return pe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};k(_e,"BYTE",new _e(1)),k(_e,"KILOBYTE",_e.kilobytes(1)),k(_e,"MEGABYTE",_e.megabytes(1)),k(_e,"GIGABYTE",_e.gigabytes(1)),k(_e,"TERABYTE",_e.terabytes(1)),k(_e,"ZERO",new _e(0)),k(_e,"z",p.union([p.number().transform(s=>new _e(s)),p.instanceof(_e)]));let tp=_e;p.union([p.instanceof(Uint8Array),p.instanceof(Uint16Array),p.instanceof(Uint32Array),p.instanceof(BigUint64Array),p.instanceof(Float32Array),p.instanceof(Float64Array),p.instanceof(Int8Array),p.instanceof(Int16Array),p.instanceof(Int32Array),p.instanceof(BigInt64Array)]);p.record(p.union([p.number(),p.string(),p.symbol()]),p.unknown());const sp=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Kc=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",np=Kc(),Wc=["MacOS","Windows","Linux","Docker"],rp=p.enum(Wc);let $a;const ap=()=>{if(typeof window>"u")return;const s=window.navigator.userAgent.toLowerCase();if(s.includes("mac"))return"MacOS";if(s.includes("win"))return"Windows";if(s.includes("linux"))return"Linux"},ip=(s={})=>{const{force:e,default:t}=s;return e??$a??($a=ap(),$a??t)},Fc=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Wc,RUNTIME:np,detect:Kc,getOS:ip,osZ:rp},Symbol.toStringTag,{value:"Module"}));var op=Object.defineProperty,cp=(s,e,t)=>e in s?op(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ns=(s,e,t)=>(cp(s,typeof e!="symbol"?e+"":e,t),t);const up=(...s)=>s.map(Yc).join(""),Yc=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),lp=s=>s.endsWith("/")?s.slice(0,-1):s,dp=(s,e="")=>s===null?"":"?"+Object.entries(s).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&"),oi=class ci{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Ns(this,"protocol"),Ns(this,"host"),Ns(this,"port"),Ns(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Yc(r)}replace(e){return new ci({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new ci({...this,pathPrefix:up(this.path,e)})}toString(){return lp(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Ns(oi,"UNKNOWN",new oi({host:"unknown",port:0}));let hp=oi;var pp=Object.defineProperty,fp=(s,e,t)=>e in s?pp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ja=(s,e,t)=>(fp(s,typeof e!="symbol"?e+"":e,t),t);let mp=class{constructor(){ja(this,"contentType","application/json"),ja(this,"decoder"),ja(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s)).buffer}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=Sd(JSON.parse(s));return e!=null?e.parse(t):t}encodeString(s){return JSON.stringify(xd(s),(e,t)=>ArrayBuffer.isView(t)?Array.from(t):sp(t)&&"encode_value"in t?typeof t.value=="bigint"?t.value.toString():t.value:typeof t=="bigint"?t.toString():t)}static registerCustomType(){}};new mp;const yp=p.string().regex(/^\d+\.\d+\.\d+$/);p.object({version:yp});var ee;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(ee||(ee={}));var ui;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(ui||(ui={}));const T=ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=s=>{switch(typeof s){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(s)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(s)?T.array:s===null?T.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?T.promise:typeof Map<"u"&&s instanceof Map?T.map:typeof Set<"u"&&s instanceof Set?T.set:typeof Date<"u"&&s instanceof Date?T.date:T.object;default:return T.unknown}},b=ee.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"]),gp=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let Ve=class 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:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(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 l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ve.create=s=>new Ve(s);const Hs=(s,e)=>{let t;switch(s.code){case b.invalid_type:s.received===T.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case b.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,ee.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:t=`Unrecognized key(s) in object: ${ee.joinValues(s.keys,", ")}`;break;case b.invalid_union:t="Invalid input";break;case b.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ee.joinValues(s.options)}`;break;case b.invalid_enum_value:t=`Invalid enum value. Expected ${ee.joinValues(s.options)}, received '${s.received}'`;break;case b.invalid_arguments:t="Invalid function arguments";break;case b.invalid_return_type:t="Invalid function return type";break;case b.invalid_date:t="Invalid date";break;case b.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:ee.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case b.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case b.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case b.custom:t="Invalid input";break;case b.invalid_intersection_types:t="Intersection results could not be merged";break;case b.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case b.not_finite:t="Number must be finite";break;default:t=e.defaultError,ee.assertNever(s)}return{message:t}};let Jc=Hs;function vp(s){Jc=s}function Er(){return Jc}const Nr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},wp=[];function E(s,e){const t=Nr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Er(),Hs].filter(n=>!!n)});s.common.issues.push(t)}let $e=class Gc{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 r of t){if(r.status==="aborted")return D;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return Gc.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return D;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const D=Object.freeze({status:"aborted"}),Hc=s=>({status:"dirty",value:s}),Ie=s=>({status:"valid",value:s}),li=s=>s.status==="aborted",di=s=>s.status==="dirty",Xs=s=>s.status==="valid",Ir=s=>typeof Promise<"u"&&s instanceof Promise;var Z;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Z||(Z={}));let nt=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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 jo=(s,e)=>{if(Xs(e))return{success:!0,data:e.value};if(!s.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 Ve(s.common.issues);return this._error=t,this._error}}};function B(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;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:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let K=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 At(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ir(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 r={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:At(e)},a=this._parseSync({data:e,path:r.path,parent:r});return jo(r,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:At(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(Ir(r)?r:Promise.resolve(r));return jo(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:b.custom,...n(r)});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,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Ye({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ot.create(this,this._def)}nullable(){return Gt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Jt.create(this,this._def)}promise(){return ms.create(this,this._def)}or(e){return an.create([this,e],this._def)}and(e){return on.create(this,e,this._def)}transform(e){return new Ye({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new dn({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new nu({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new jr({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ji.create(this,e)}readonly(){return Rr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bp=/^c[^\s-]{8,}$/i,_p=/^[a-z][a-z0-9]*$/,kp=/^[0-9A-HJKMNP-TV-Z]{26}$/,Op=/^[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,Tp=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let za;const Sp=/^(((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}))$/,Ep=/^(([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})))$/,Np=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.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$"):s.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 Ip(s,e){return!!((e==="v4"||!e)&&Sp.test(s)||(e==="v6"||!e)&&Ep.test(s))}let ps=class Is extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.string,received:r.parsedType}),D}const t=new $e;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?E(n,{code:b.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&E(n,{code:b.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")Tp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"email",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")za||(za=new RegExp(xp,"u")),za.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"emoji",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")Op.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"uuid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")bp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")_p.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid2",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")kp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ulid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),E(n,{validation:"url",code:b.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"regex",code:b.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?Np(r).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?Ip(e.data,r.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ip",code:b.invalid_string,message:r.message}),t.dirty()):ee.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:b.invalid_string,...Z.errToObj(n)})}_addCheck(e){return new Is({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.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,...Z.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Z.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new Is({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Is({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Is({...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}};ps.create=s=>{var e;return new ps({checks:[],typeName:j.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...B(s)})};function Zp(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let Qs=class hi extends K{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)!==T.number){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.number,received:r.parsedType}),D}let t;const n=new $e;for(const r of this._def.checks)r.kind==="int"?ee.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:b.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?Zp(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_finite,message:r.message}),n.dirty()):ee.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,n,r){return new hi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Z.toString(r)}]})}_addCheck(e){return new hi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.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"&&ee.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)}};Qs.create=s=>new Qs({checks:[],typeName:j.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...B(s)});let en=class pi extends K{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)!==T.bigint){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.bigint,received:r.parsedType}),D}let t;const n=new $e;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):ee.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,n,r){return new pi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Z.toString(r)}]})}_addCheck(e){return new pi({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.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}};en.create=s=>{var e;return new en({checks:[],typeName:j.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...B(s)})};let tn=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.boolean,received:t.parsedType}),D}return Ie(e.data)}};tn.create=s=>new tn({typeName:j.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...B(s)});let sn=class Xc extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.date,received:r.parsedType}),D}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_date}),D}const t=new $e;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):ee.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Z.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}};sn.create=s=>new sn({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:j.ZodDate,...B(s)});class Zr extends K{_parse(e){if(this._getType(e)!==T.symbol){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.symbol,received:t.parsedType}),D}return Ie(e.data)}}Zr.create=s=>new Zr({typeName:j.ZodSymbol,...B(s)});let nn=class extends K{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.undefined,received:t.parsedType}),D}return Ie(e.data)}};nn.create=s=>new nn({typeName:j.ZodUndefined,...B(s)});let rn=class extends K{_parse(e){if(this._getType(e)!==T.null){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.null,received:t.parsedType}),D}return Ie(e.data)}};rn.create=s=>new rn({typeName:j.ZodNull,...B(s)});let fs=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ie(e.data)}};fs.create=s=>new fs({typeName:j.ZodAny,...B(s)});let qt=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ie(e.data)}};qt.create=s=>new qt({typeName:j.ZodUnknown,...B(s)});let St=class extends K{_parse(e){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.never,received:t.parsedType}),D}};St.create=s=>new St({typeName:j.ZodNever,...B(s)});class Ar extends K{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.void,received:t.parsedType}),D}return Ie(e.data)}}Ar.create=s=>new Ar({typeName:j.ZodVoid,...B(s)});let Jt=class sr extends K{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==T.array)return E(t,{code:b.invalid_type,expected:T.array,received:t.parsedType}),D;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(E(t,{code:i?b.too_big:b.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(E(t,{code:b.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(E(t,{code:b.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new nt(t,i,t.path,o)))).then(i=>$e.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new nt(t,i,t.path,o)));return $e.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new sr({...this._def,minLength:{value:e,message:Z.toString(t)}})}max(e,t){return new sr({...this._def,maxLength:{value:e,message:Z.toString(t)}})}length(e,t){return new sr({...this._def,exactLength:{value:e,message:Z.toString(t)}})}nonempty(e){return this.min(1,e)}};Jt.create=(s,e)=>new Jt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function as(s){if(s instanceof De){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=Ot.create(as(n))}return new De({...s._def,shape:()=>e})}else return s instanceof Jt?new Jt({...s._def,type:as(s.element)}):s instanceof Ot?Ot.create(as(s.unwrap())):s instanceof Gt?Gt.create(as(s.unwrap())):s instanceof jt?jt.create(s.items.map(e=>as(e))):s}let De=class Be extends K{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=ee.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==T.object){const u=this._getOrReturnCtx(e);return E(u,{code:b.invalid_type,expected:T.object,received:u.parsedType}),D}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof St&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new nt(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof St){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(E(n,{code:b.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 l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new nt(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>$e.mergeObjectSync(t,u)):$e.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new Be({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=Z.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Be({...this._def,unknownKeys:"strip"})}passthrough(){return new Be({...this._def,unknownKeys:"passthrough"})}extend(e){return new Be({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Be({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Be({...this._def,catchall:e})}pick(e){const t={};return ee.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}omit(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new Be({...this._def,shape:()=>t})}required(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof Ot;)r=r._def.innerType;t[n]=r}}),new Be({...this._def,shape:()=>t})}keyof(){return su(ee.objectKeys(this.shape))}};De.create=(s,e)=>new De({shape:()=>s,unknownKeys:"strip",catchall:St.create(),typeName:j.ZodObject,...B(e)});De.strictCreate=(s,e)=>new De({shape:()=>s,unknownKeys:"strict",catchall:St.create(),typeName:j.ZodObject,...B(e)});De.lazycreate=(s,e)=>new De({shape:s,unknownKeys:"strip",catchall:St.create(),typeName:j.ZodObject,...B(e)});let an=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(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 Ve(o.ctx.common.issues));return E(t,{code:b.invalid_union,unionErrors:i}),D}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(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ve(u));return E(t,{code:b.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};an.create=(s,e)=>new an({options:s,typeName:j.ZodUnion,...B(e)});const nr=s=>s instanceof cn?nr(s.schema):s instanceof Ye?nr(s.innerType()):s instanceof un?[s.value]:s instanceof jn?s.options:s instanceof ln?Object.keys(s.enum):s instanceof dn?nr(s._def.innerType):s instanceof nn?[void 0]:s instanceof rn?[null]:null;class ca extends K{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return E(t,{code:b.invalid_type,expected:T.object,received:t.parsedType}),D;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);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}):(E(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=nr(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ca({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...B(n)})}}function fi(s,e){const t=At(s),n=At(e);if(s===e)return{valid:!0,data:s};if(t===T.object&&n===T.object){const r=ee.objectKeys(e),a=ee.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=fi(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===T.array&&n===T.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=fi(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===T.date&&n===T.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let on=class extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(li(a)||li(i))return D;const o=fi(a.value,i.value);return o.valid?((di(a)||di(i))&&t.dirty(),{status:t.value,value:o.data}):(E(n,{code:b.invalid_intersection_types}),D)};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])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};on.create=(s,e,t)=>new on({left:s,right:e,typeName:j.ZodIntersection,...B(t)});let jt=class Qc extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.array)return E(n,{code:b.invalid_type,expected:T.array,received:n.parsedType}),D;if(n.data.length<this._def.items.length)return E(n,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&n.data.length>this._def.items.length&&(E(n,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new nt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>$e.mergeArray(t,a)):$e.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Qc({...this._def,rest:e})}};jt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jt({items:s,typeName:j.ZodTuple,rest:null,...B(e)})};let eu=class mi extends K{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!==T.object)return E(n,{code:b.invalid_type,expected:T.object,received:n.parsedType}),D;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new nt(n,o,n.path,o)),value:i._parse(new nt(n,n.data[o],n.path,o))});return n.common.async?$e.mergeObjectAsync(t,r):$e.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof K?new mi({keyType:e,valueType:t,typeName:j.ZodRecord,...B(n)}):new mi({keyType:ps.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}};class Cr extends K{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!==T.map)return E(n,{code:b.invalid_type,expected:T.map,received:n.parsedType}),D;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new nt(n,o,n.path,[l,"key"])),value:a._parse(new nt(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}Cr.create=(s,e,t)=>new Cr({valueType:e,keyType:s,typeName:j.ZodMap,...B(t)});let $r=class yi extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.set)return E(n,{code:b.invalid_type,expected:T.set,received:n.parsedType}),D;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(E(n,{code:b.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(E(n,{code:b.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return D;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new nt(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new yi({...this._def,minSize:{value:e,message:Z.toString(t)}})}max(e,t){return new yi({...this._def,maxSize:{value:e,message:Z.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};$r.create=(s,e)=>new $r({valueType:s,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});let tu=class rr extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return E(t,{code:b.invalid_type,expected:T.function,received:t.parsedType}),D;function n(o,u){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Er(),Hs].filter(l=>!!l),issueData:{code:b.invalid_arguments,argumentsError:u}})}function r(o,u){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Er(),Hs].filter(l=>!!l),issueData:{code:b.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ms){const o=this;return Ie(async function(...u){const l=new Ve([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ie(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Ve([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new Ve([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new rr({...this._def,args:jt.create(e).rest(qt.create())})}returns(e){return new rr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new rr({args:e||jt.create([]).rest(qt.create()),returns:t||qt.create(),typeName:j.ZodFunction,...B(n)})}},cn=class extends K{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})}};cn.create=(s,e)=>new cn({getter:s,typeName:j.ZodLazy,...B(e)});let un=class extends K{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}};un.create=(s,e)=>new un({value:s,typeName:j.ZodLiteral,...B(e)});function su(s,e){return new jn({values:s,typeName:j.ZodEnum,...B(e)})}let jn=class gi extends K{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return E(t,{expected:ee.joinValues(n),received:t.parsedType,code:b.invalid_type}),D}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return E(t,{received:t.data,code:b.invalid_enum_value,options:n}),D}return Ie(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 gi.create(e)}exclude(e){return gi.create(this.options.filter(t=>!e.includes(t)))}};jn.create=su;let ln=class extends K{_parse(e){const t=ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==T.string&&n.parsedType!==T.number){const r=ee.objectValues(t);return E(n,{expected:ee.joinValues(r),received:n.parsedType,code:b.invalid_type}),D}if(t.indexOf(e.data)===-1){const r=ee.objectValues(t);return E(n,{received:n.data,code:b.invalid_enum_value,options:r}),D}return Ie(e.data)}get enum(){return this._def.values}};ln.create=(s,e)=>new ln({values:s,typeName:j.ZodNativeEnum,...B(e)});let ms=class extends K{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return E(t,{code:b.invalid_type,expected:T.promise,received:t.parsedType}),D;const n=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return Ie(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ms.create=(s,e)=>new ms({type:s,typeName:j.ZodPromise,...B(e)});let Ye=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{E(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.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(r.type==="refinement"){const i=o=>{const u=r.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"?D:(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"?D:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Xs(i))return i;const o=r.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=>Xs(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);ee.assertNever(r)}};Ye.create=(s,e,t)=>new Ye({schema:s,typeName:j.ZodEffects,effect:e,...B(t)});Ye.createWithPreprocess=(s,e,t)=>new Ye({schema:e,effect:{type:"preprocess",transform:s},typeName:j.ZodEffects,...B(t)});let Ot=class extends K{_parse(e){return this._getType(e)===T.undefined?Ie(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ot.create=(s,e)=>new Ot({innerType:s,typeName:j.ZodOptional,...B(e)});let Gt=class extends K{_parse(e){return this._getType(e)===T.null?Ie(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Gt.create=(s,e)=>new Gt({innerType:s,typeName:j.ZodNullable,...B(e)});let dn=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===T.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};dn.create=(s,e)=>new dn({innerType:s,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});class jr extends K{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ir(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}jr.create=(s,e)=>new jr({innerType:s,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});class zr extends K{_parse(e){if(this._getType(e)!==T.nan){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.nan,received:t.parsedType}),D}return{status:"valid",value:e.data}}}zr.create=s=>new zr({typeName:j.ZodNaN,...B(s)});const Ap=Symbol("zod_brand");class nu extends K{_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}}let Ji=class ru extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),Hc(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new ru({in:e,out:t,typeName:j.ZodPipeline})}};class Rr extends K{_parse(e){const t=this._def.innerType._parse(e);return Xs(t)&&(t.value=Object.freeze(t.value)),t}}Rr.create=(s,e)=>new Rr({innerType:s,typeName:j.ZodReadonly,...B(e)});const au=(s,e={},t)=>s?fs.create().superRefine((n,r)=>{var a,i;if(!s(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,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):fs.create(),Cp={object:De.lazycreate};var j;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(j||(j={}));const $p=(s,e={message:`Input not instance of ${s.name}`})=>au(t=>t instanceof s,e),iu=ps.create,ou=Qs.create,jp=zr.create,zp=en.create,cu=tn.create,Rp=sn.create,Pp=Zr.create,Mp=nn.create,Dp=rn.create,Lp=fs.create,Up=qt.create,Bp=St.create,qp=Ar.create,Vp=Jt.create,Kp=De.create,Wp=De.strictCreate,Fp=an.create,Yp=ca.create,Jp=on.create,Gp=jt.create,Hp=eu.create,Xp=Cr.create,Qp=$r.create,ef=tu.create,tf=cn.create,sf=un.create,nf=jn.create,rf=ln.create,af=ms.create,zo=Ye.create,of=Ot.create,cf=Gt.create,uf=Ye.createWithPreprocess,lf=Ji.create,df=()=>iu().optional(),hf=()=>ou().optional(),pf=()=>cu().optional(),ff={string:s=>ps.create({...s,coerce:!0}),number:s=>Qs.create({...s,coerce:!0}),boolean:s=>tn.create({...s,coerce:!0}),bigint:s=>en.create({...s,coerce:!0}),date:s=>sn.create({...s,coerce:!0})},mf=D;var wt=Object.freeze({__proto__:null,defaultErrorMap:Hs,setErrorMap:vp,getErrorMap:Er,makeIssue:Nr,EMPTY_PATH:wp,addIssueToContext:E,ParseStatus:$e,INVALID:D,DIRTY:Hc,OK:Ie,isAborted:li,isDirty:di,isValid:Xs,isAsync:Ir,get util(){return ee},get objectUtil(){return ui},ZodParsedType:T,getParsedType:At,ZodType:K,ZodString:ps,ZodNumber:Qs,ZodBigInt:en,ZodBoolean:tn,ZodDate:sn,ZodSymbol:Zr,ZodUndefined:nn,ZodNull:rn,ZodAny:fs,ZodUnknown:qt,ZodNever:St,ZodVoid:Ar,ZodArray:Jt,ZodObject:De,ZodUnion:an,ZodDiscriminatedUnion:ca,ZodIntersection:on,ZodTuple:jt,ZodRecord:eu,ZodMap:Cr,ZodSet:$r,ZodFunction:tu,ZodLazy:cn,ZodLiteral:un,ZodEnum:jn,ZodNativeEnum:ln,ZodPromise:ms,ZodEffects:Ye,ZodTransformer:Ye,ZodOptional:Ot,ZodNullable:Gt,ZodDefault:dn,ZodCatch:jr,ZodNaN:zr,BRAND:Ap,ZodBranded:nu,ZodPipeline:Ji,ZodReadonly:Rr,custom:au,Schema:K,ZodSchema:K,late:Cp,get ZodFirstPartyTypeKind(){return j},coerce:ff,any:Lp,array:Vp,bigint:zp,boolean:cu,date:Rp,discriminatedUnion:Yp,effect:zo,enum:nf,function:ef,instanceof:$p,intersection:Jp,lazy:tf,literal:sf,map:Xp,nan:jp,nativeEnum:rf,never:Bp,null:Dp,nullable:cf,number:ou,object:Kp,oboolean:pf,onumber:hf,optional:of,ostring:df,pipeline:lf,preprocess:uf,promise:af,record:Hp,set:Qp,strictObject:Wp,string:iu,symbol:Pp,transformer:zo,tuple:Gp,undefined:Mp,union:Fp,unknown:Up,void:qp,NEVER:mf,ZodIssueCode:b,quotelessJson:gp,ZodError:Ve});class ua extends Error{constructor(e,t){super(e),le(this,"discriminator","FreighterError"),le(this,"type"),this.type=t}}const yf=s=>{if(s==null||typeof s!="object")return!1;const e=s;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},vi="unknown",Ro="nil",la="freighter",zn=wt.object({type:wt.string(),data:wt.string()});class gf{constructor(){le(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ro,data:""};if(yf(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:vi,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ro)return null;if(e.type===vi)return new Po(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Po(e.data)}}const uu=new gf,lu=({encode:s,decode:e})=>uu.register({encode:s,decode:e}),Gi=s=>uu.decode(s);class Po extends ua{constructor(e){super(e,vi)}}const da="freighter.";let zt=class extends ua{constructor(){super("EOF",la)}};le(zt,"TYPE",da+"eof");let Ht=class extends ua{constructor(){super("StreamClosed",la)}};le(Ht,"TYPE",da+"stream_closed");let Rt=class extends ua{constructor(e={}){const{message:t="Unreachable",url:n=hp.UNKNOWN}=e;super(t,la),le(this,"url"),this.url=n}};le(Rt,"TYPE",da+"unreachable");const vf=s=>{if(s.type!==la)return null;if(s instanceof zt)return{type:zt.TYPE,data:"EOF"};if(s instanceof Ht)return{type:Ht.TYPE,data:"StreamClosed"};if(s instanceof Rt)return{type:Rt.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${s.type}: ${s.message}`)},wf=s=>{if(!s.type.startsWith(da))return null;switch(s.type){case zt.TYPE:return new zt;case Ht.TYPE:return new Ht;case Rt.TYPE:return new Rt;default:throw new Error(`Unknown error type: ${s.data}`)}};lu({encode:vf,decode:wf});class du{constructor(){le(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const r=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,r)};return await r(e)}}const hu="Content-Type",Mo=s=>{if(Fc.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(s==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(r,a)=>await e(r,{...a,agent:n})};class bf extends du{constructor(e,t,n=!1){return super(),le(this,"endpoint"),le(this,"encoder"),le(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Mo(this.endpoint.protocol),new Proxy(this,{get:(r,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(r,a,i)})}get headers(){return{[hu]:this.encoder.contentType}}async send(e,t,n,r){t=n==null?void 0:n.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const h={...l,params:{}};o.headers={...this.headers,...l.params};let g;try{g=await Mo(l.protocol)(l.target,o)}catch(ye){let ze=ye;return ze.message==="Load failed"&&(ze=new Rt({url:i})),[h,ze]}const se=await g.arrayBuffer();if(g!=null&&g.ok)return r!=null&&(a=this.encoder.decode(se,r)),[h,null];try{if(g.status!==400)return[h,new Error(g.statusText)];const ye=this.encoder.decode(se,zn),ze=Gi(ye);return[h,ze]}catch(ye){return[h,new Error(`[freighter] - failed to decode error: ${g.statusText}: ${ye.message}`)]}});return[a,u]}}const C=async(s,e,t,n,r)=>{const[a,i]=await s.send(e,t,n,r);if(i!=null)throw i;return a},_f=()=>Fc.RUNTIME!=="node"?s=>new WebSocket(s):s=>new(require("ws")).WebSocket(s,{rejectUnauthorized:!1}),kf=wt.object({type:wt.union([wt.literal("data"),wt.literal("close")]),payload:wt.unknown().optional(),error:wt.optional(zn)});class Of{constructor(e,t,n,r){le(this,"encoder"),le(this,"reqSchema"),le(this,"resSchema"),le(this,"ws"),le(this,"serverClosed"),le(this,"sendClosed"),le(this,"receiveDataQueue",[]),le(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new zt;if(this.sendClosed)throw new Ht;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=Gi(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(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,kf),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Nf(e)?new zt:new Ht}}}const Tf="freighterctx",xf=1e3,Sf=1001,Ef=[xf,Sf],Nf=s=>Ef.includes(s.code),pu=class fu extends du{constructor(e,t,n=!1){super(),le(this,"baseUrl"),le(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const r=_f();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const u=r(this.buildURL(e,o)),l={...o,params:{}};u.binaryType=fu.MESSAGE_TYPE;const h=await this.wrapSocket(u,t,n);return h instanceof Error?[l,h]:(a=h,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=dp({[hu]:this.encoder.contentType,...t.params},Tf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(r=>{e.onopen=()=>{r(new Of(e,this.encoder,t,n))},e.onerror=a=>{const i=a;r(new Error(i.message))}})}};le(pu,"MESSAGE_TYPE","arraybuffer");let If=pu;var Le=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y={},ha={};Object.defineProperty(ha,"__esModule",{value:!0});function Zf(s){return s===void 0&&(s=""),s?String(s).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()}):""}ha.default=Zf;var pa={};Object.defineProperty(pa,"__esModule",{value:!0});function Af(s){return s===void 0&&(s=""),s?String(s).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():""}pa.default=Af;var fa={};Object.defineProperty(fa,"__esModule",{value:!0});function Cf(s){return s===void 0&&(s=""),s?String(s).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()}):""}fa.default=Cf;var Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});function $f(s){return s===void 0&&(s=""),s?String(s).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():""}Hi.default=$f;var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});function jf(s){return s===void 0&&(s=""),s?String(s).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():""}Xi.default=jf;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});function zf(s){return s===void 0&&(s=""),s?String(s).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():""}Qi.default=zf;var eo={};Object.defineProperty(eo,"__esModule",{value:!0});function Rf(s){if(s===void 0&&(s=""),!s)return"";var e=String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,r){return n+"_"+r.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}eo.default=Rf;var to={};Object.defineProperty(to,"__esModule",{value:!0});function Pf(s){return s===void 0&&(s=""),s?String(s).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,r){return t+n.charAt(0).toUpperCase()+n.slice(1)+r}):""}to.default=Pf;var ma={};Object.defineProperty(ma,"__esModule",{value:!0});function Mf(s){return s===void 0&&(s=""),s?String(s).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():""}ma.default=Mf;var so={},ss={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.belongToTypes=s.isValidObject=s.isArrayObject=s.validateOptions=s.DefaultOption=void 0,s.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},s.validateOptions=function(e){return e===void 0&&(e=s.DefaultOption),e.recursive==null?e=s.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},s.isArrayObject=function(e){return e!=null&&Array.isArray(e)},s.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},s.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(ss);var Df=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(so,"__esModule",{value:!0});var dt=ss;function ar(s,e){if(e===void 0&&(e=dt.DefaultOption),!dt.isValidObject(s))return null;e=dt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toLowerCase();e.recursive&&(dt.isValidObject(r)?dt.belongToTypes(r,e.keepTypesOnRecursion)||(r=ar(r,e)):e.recursiveInArray&&dt.isArrayObject(r)&&(r=Df(r).map(function(i){var o=i;if(dt.isValidObject(i))dt.belongToTypes(o,e.keepTypesOnRecursion)||(o=ar(i,e));else if(dt.isArrayObject(i)){var u=ar({key:i},e);o=u.key}return o}))),t[a]=r}),t}so.default=ar;var no={},Lf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(no,"__esModule",{value:!0});var ht=ss;function ir(s,e){if(e===void 0&&(e=ht.DefaultOption),!ht.isValidObject(s))return null;e=ht.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toUpperCase();e.recursive&&(ht.isValidObject(r)?ht.belongToTypes(r,e.keepTypesOnRecursion)||(r=ir(r,e)):e.recursiveInArray&&ht.isArrayObject(r)&&(r=Lf(r).map(function(i){var o=i;if(ht.isValidObject(i))ht.belongToTypes(o,e.keepTypesOnRecursion)||(o=ir(i,e));else if(ht.isArrayObject(i)){var u=ir({key:i},e);o=u.key}return o}))),t[a]=r}),t}no.default=ir;var ro={},Uf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(ro,"__esModule",{value:!0});var pt=ss,Bf=ha;function or(s,e){if(e===void 0&&(e=pt.DefaultOption),!pt.isValidObject(s))return null;e=pt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Bf.default(n);e.recursive&&(pt.isValidObject(r)?pt.belongToTypes(r,e.keepTypesOnRecursion)||(r=or(r,e)):e.recursiveInArray&&pt.isArrayObject(r)&&(r=Uf(r).map(function(i){var o=i;if(pt.isValidObject(i))pt.belongToTypes(o,e.keepTypesOnRecursion)||(o=or(i,e));else if(pt.isArrayObject(i)){var u=or({key:i},e);o=u.key}return o}))),t[a]=r}),t}ro.default=or;var ao={},qf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(ao,"__esModule",{value:!0});var ft=ss,Vf=pa;function cr(s,e){if(e===void 0&&(e=ft.DefaultOption),!ft.isValidObject(s))return null;e=ft.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Vf.default(n);e.recursive&&(ft.isValidObject(r)?ft.belongToTypes(r,e.keepTypesOnRecursion)||(r=cr(r,e)):e.recursiveInArray&&ft.isArrayObject(r)&&(r=qf(r).map(function(i){var o=i;if(ft.isValidObject(i))ft.belongToTypes(o,e.keepTypesOnRecursion)||(o=cr(i,e));else if(ft.isArrayObject(i)){var u=cr({key:i},e);o=u.key}return o}))),t[a]=r}),t}ao.default=cr;var io={},Kf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(io,"__esModule",{value:!0});var mt=ss,Wf=fa;function ur(s,e){if(e===void 0&&(e=mt.DefaultOption),!mt.isValidObject(s))return null;e=mt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Wf.default(n);e.recursive&&(mt.isValidObject(r)?mt.belongToTypes(r,e.keepTypesOnRecursion)||(r=ur(r,e)):e.recursiveInArray&&mt.isArrayObject(r)&&(r=Kf(r).map(function(i){var o=i;if(mt.isValidObject(i))mt.belongToTypes(o,e.keepTypesOnRecursion)||(o=ur(i,e));else if(mt.isArrayObject(i)){var u=ur({key:i},e);o=u.key}return o}))),t[a]=r}),t}io.default=ur;var oo={},Ff=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(oo,"__esModule",{value:!0});var yt=ss,Yf=ma;function lr(s,e){if(e===void 0&&(e=yt.DefaultOption),!yt.isValidObject(s))return null;e=yt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Yf.default(n);e.recursive&&(yt.isValidObject(r)?yt.belongToTypes(r,e.keepTypesOnRecursion)||(r=lr(r,e)):e.recursiveInArray&&yt.isArrayObject(r)&&(r=Ff(r).map(function(i){var o=i;if(yt.isValidObject(i))yt.belongToTypes(o,e.keepTypesOnRecursion)||(o=lr(i,e));else if(yt.isArrayObject(i)){var u=lr({key:i},e);o=u.key}return o}))),t[a]=r}),t}oo.default=lr;Object.defineProperty(Y,"__esModule",{value:!0});Y.kebabKeys=Y.pascalKeys=Y.snakeKeys=Y.camelKeys=Y.upperKeys=Y.lowerKeys=Y.toLowerCase=Y.toUpperCase=Y.toKebabCase=Y.toHeaderCase=Y.toSentenceCase=Y.toTextCase=Y.toPathCase=Y.toDotCase=Y.toPascalCase=Y.toSnakeCase=Y.toCamelCase=void 0;var mu=ha;Y.toCamelCase=mu.default;var yu=pa;Y.toSnakeCase=yu.default;var gu=fa;Y.toPascalCase=gu.default;var vu=Hi;Y.toDotCase=vu.default;var wu=Xi;Y.toPathCase=wu.default;var bu=Qi;Y.toTextCase=bu.default;var _u=eo;Y.toSentenceCase=_u.default;var ku=to;Y.toHeaderCase=ku.default;var Ou=ma;Y.toKebabCase=Ou.default;var Tu=so;Y.lowerKeys=Tu.default;var xu=no;Y.upperKeys=xu.default;var Su=ro;Y.camelKeys=Su.default;var Eu=ao;Y.snakeKeys=Eu.default;var Nu=io;Y.pascalKeys=Nu.default;var Iu=oo;Y.kebabKeys=Iu.default;var Zu=function(s){return String(s||"").toLowerCase()};Y.toLowerCase=Zu;var Au=function(s){return String(s||"").toUpperCase()};Y.toUpperCase=Au;var Jf={toCamelCase:mu.default,toSnakeCase:yu.default,toPascalCase:gu.default,toDotCase:vu.default,toPathCase:wu.default,toTextCase:bu.default,toSentenceCase:_u.default,toHeaderCase:ku.default,toKebabCase:Ou.default,toUpperCase:Au,toLowerCase:Zu,lowerKeys:Tu.default,upperKeys:xu.default,camelKeys:Su.default,snakeKeys:Eu.default,pascalKeys:Nu.default,kebabKeys:Iu.default};Y.default=Jf;var Cu=Y;const $u={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Gf=s=>Cu.snakeKeys(s,$u),Pr=s=>Cu.camelKeys(s,$u),Hf=s=>s!=null&&typeof s=="object"&&"toString"in s,Xf=(s,e=!1)=>{const t=Hf(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Qf(n):n},Qf=s=>(e,t)=>s(t,e);var te;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(te||(te={}));var wi;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(wi||(wi={}));const x=te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ct=s=>{switch(typeof s){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(s)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(s)?x.array:s===null?x.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?x.promise:typeof Map<"u"&&s instanceof Map?x.map:typeof Set<"u"&&s instanceof Set?x.set:typeof Date<"u"&&s instanceof Date?x.date:x.object;default:return x.unknown}},_=te.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"]),em=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let Ke=class 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:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(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 l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,te.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ke.create=s=>new Ke(s);const hn=(s,e)=>{let t;switch(s.code){case _.invalid_type:s.received===x.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,te.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${te.joinValues(s.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${te.joinValues(s.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${te.joinValues(s.options)}, received '${s.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:te.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case _.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case _.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,te.assertNever(s)}return{message:t}};let ju=hn;function tm(s){ju=s}function Mr(){return ju}const Dr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},sm=[];function N(s,e){const t=Dr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Mr(),hn].filter(n=>!!n)});s.common.issues.push(t)}let je=class zu{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 r of t){if(r.status==="aborted")return L;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return zu.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return L;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const L=Object.freeze({status:"aborted"}),Ru=s=>({status:"dirty",value:s}),Ze=s=>({status:"valid",value:s}),bi=s=>s.status==="aborted",_i=s=>s.status==="dirty",pn=s=>s.status==="valid",Lr=s=>typeof Promise<"u"&&s instanceof Promise;var A;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));let rt=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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 Do=(s,e)=>{if(pn(e))return{success:!0,data:e.value};if(!s.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 Ke(s.common.issues);return this._error=t,this._error}}};function q(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;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:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let W=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 Ct(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Lr(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 r={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:Ct(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Do(r,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:Ct(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(Lr(r)?r:Promise.resolve(r));return Do(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:_.custom,...n(r)});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,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Je({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Tt.create(this,this._def)}nullable(){return Qt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this,this._def)}promise(){return vs.create(this,this._def)}or(e){return bn.create([this,e],this._def)}and(e){return _n.create(this,e,this._def)}transform(e){return new Je({...q(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new xn({...q(this._def),innerType:this,defaultValue:t,typeName:z.ZodDefault})}brand(){return new Bu({typeName:z.ZodBranded,type:this,...q(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Kr({...q(this._def),innerType:this,catchValue:t,typeName:z.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Rn.create(this,e)}readonly(){return Fr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const nm=/^c[^\s-]{8,}$/i,rm=/^[a-z][a-z0-9]*$/,am=/^[0-9A-HJKMNP-TV-Z]{26}$/,im=/^[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,om=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ra;const um=/^(((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}))$/,lm=/^(([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})))$/,dm=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.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$"):s.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 hm(s,e){return!!((e==="v4"||!e)&&um.test(s)||(e==="v6"||!e)&&lm.test(s))}let ys=class Zs extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.string,received:r.parsedType}),L}const t=new je;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?N(n,{code:_.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&N(n,{code:_.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")om.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"email",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")Ra||(Ra=new RegExp(cm,"u")),Ra.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"emoji",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")im.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"uuid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")nm.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"cuid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")rm.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"cuid2",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")am.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"ulid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),N(n,{validation:"url",code:_.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"regex",code:_.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?dm(r).test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?hm(e.data,r.version)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"ip",code:_.invalid_string,message:r.message}),t.dirty()):te.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:_.invalid_string,...A.errToObj(n)})}_addCheck(e){return new Zs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.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,...A.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new Zs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Zs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Zs({...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}};ys.create=s=>{var e;return new ys({checks:[],typeName:z.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...q(s)})};function pm(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let fn=class ki extends W{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)!==x.number){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.number,received:r.parsedType}),L}let t;const n=new je;for(const r of this._def.checks)r.kind==="int"?te.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:_.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?pm(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_finite,message:r.message}),n.dirty()):te.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,r){return new ki({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(r)}]})}_addCheck(e){return new ki({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.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"&&te.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)}};fn.create=s=>new fn({checks:[],typeName:z.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...q(s)});let mn=class Oi extends W{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)!==x.bigint){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.bigint,received:r.parsedType}),L}let t;const n=new je;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):te.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,r){return new Oi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(r)}]})}_addCheck(e){return new Oi({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.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}};mn.create=s=>{var e;return new mn({checks:[],typeName:z.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...q(s)})};let yn=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.boolean,received:t.parsedType}),L}return Ze(e.data)}};yn.create=s=>new yn({typeName:z.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...q(s)});let gn=class Pu extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.date,received:r.parsedType}),L}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_date}),L}const t=new je;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):te.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Pu({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.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}};gn.create=s=>new gn({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:z.ZodDate,...q(s)});class Ur extends W{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.symbol,received:t.parsedType}),L}return Ze(e.data)}}Ur.create=s=>new Ur({typeName:z.ZodSymbol,...q(s)});let vn=class extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.undefined,received:t.parsedType}),L}return Ze(e.data)}};vn.create=s=>new vn({typeName:z.ZodUndefined,...q(s)});let wn=class extends W{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.null,received:t.parsedType}),L}return Ze(e.data)}};wn.create=s=>new wn({typeName:z.ZodNull,...q(s)});let gs=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Ze(e.data)}};gs.create=s=>new gs({typeName:z.ZodAny,...q(s)});let Vt=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ze(e.data)}};Vt.create=s=>new Vt({typeName:z.ZodUnknown,...q(s)});let Et=class extends W{_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.never,received:t.parsedType}),L}};Et.create=s=>new Et({typeName:z.ZodNever,...q(s)});class Br extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.void,received:t.parsedType}),L}return Ze(e.data)}}Br.create=s=>new Br({typeName:z.ZodVoid,...q(s)});let Xt=class dr extends W{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==x.array)return N(t,{code:_.invalid_type,expected:x.array,received:t.parsedType}),L;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(N(t,{code:i?_.too_big:_.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(N(t,{code:_.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(N(t,{code:_.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new rt(t,i,t.path,o)))).then(i=>je.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new rt(t,i,t.path,o)));return je.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new dr({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new dr({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new dr({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}};Xt.create=(s,e)=>new Xt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...q(e)});function is(s){if(s instanceof ue){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=Tt.create(is(n))}return new ue({...s._def,shape:()=>e})}else return s instanceof Xt?new Xt({...s._def,type:is(s.element)}):s instanceof Tt?Tt.create(is(s.unwrap())):s instanceof Qt?Qt.create(is(s.unwrap())):s instanceof Pt?Pt.create(s.items.map(e=>is(e))):s}class ue extends W{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=te.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==x.object){const u=this._getOrReturnCtx(e);return N(u,{code:_.invalid_type,expected:x.object,received:u.parsedType}),L}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new rt(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Et){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(N(n,{code:_.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 l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new rt(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>je.mergeObjectSync(t,u)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=A.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:z.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(e){const t={};return te.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ue({...this._def,shape:()=>t})}omit(e){const t={};return te.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ue({...this._def,shape:()=>t})}deepPartial(){return is(this)}partial(e){const t={};return te.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new ue({...this._def,shape:()=>t})}required(e){const t={};return te.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof Tt;)r=r._def.innerType;t[n]=r}}),new ue({...this._def,shape:()=>t})}keyof(){return Uu(te.objectKeys(this.shape))}}ue.create=(s,e)=>new ue({shape:()=>s,unknownKeys:"strip",catchall:Et.create(),typeName:z.ZodObject,...q(e)});ue.strictCreate=(s,e)=>new ue({shape:()=>s,unknownKeys:"strict",catchall:Et.create(),typeName:z.ZodObject,...q(e)});ue.lazycreate=(s,e)=>new ue({shape:s,unknownKeys:"strip",catchall:Et.create(),typeName:z.ZodObject,...q(e)});class bn extends W{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(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 Ke(o.ctx.common.issues));return N(t,{code:_.invalid_union,unionErrors:i}),L}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(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ke(u));return N(t,{code:_.invalid_union,unionErrors:o}),L}}get options(){return this._def.options}}bn.create=(s,e)=>new bn({options:s,typeName:z.ZodUnion,...q(e)});const hr=s=>s instanceof kn?hr(s.schema):s instanceof Je?hr(s.innerType()):s instanceof On?[s.value]:s instanceof Mt?s.options:s instanceof Tn?Object.keys(s.enum):s instanceof xn?hr(s._def.innerType):s instanceof vn?[void 0]:s instanceof wn?[null]:null;class ya extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return N(t,{code:_.invalid_type,expected:x.object,received:t.parsedType}),L;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);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}):(N(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=hr(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(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ya({typeName:z.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...q(n)})}}function Ti(s,e){const t=Ct(s),n=Ct(e);if(s===e)return{valid:!0,data:s};if(t===x.object&&n===x.object){const r=te.objectKeys(e),a=te.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=Ti(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===x.array&&n===x.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=Ti(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===x.date&&n===x.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let _n=class extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(bi(a)||bi(i))return L;const o=Ti(a.value,i.value);return o.valid?((_i(a)||_i(i))&&t.dirty(),{status:t.value,value:o.data}):(N(n,{code:_.invalid_intersection_types}),L)};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])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};_n.create=(s,e,t)=>new _n({left:s,right:e,typeName:z.ZodIntersection,...q(t)});let Pt=class Mu extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.array)return N(n,{code:_.invalid_type,expected:x.array,received:n.parsedType}),L;if(n.data.length<this._def.items.length)return N(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new rt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>je.mergeArray(t,a)):je.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Mu({...this._def,rest:e})}};Pt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pt({items:s,typeName:z.ZodTuple,rest:null,...q(e)})};let Du=class xi extends W{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!==x.object)return N(n,{code:_.invalid_type,expected:x.object,received:n.parsedType}),L;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new rt(n,o,n.path,o)),value:i._parse(new rt(n,n.data[o],n.path,o))});return n.common.async?je.mergeObjectAsync(t,r):je.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof W?new xi({keyType:e,valueType:t,typeName:z.ZodRecord,...q(n)}):new xi({keyType:ys.create(),valueType:e,typeName:z.ZodRecord,...q(t)})}};class qr extends W{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!==x.map)return N(n,{code:_.invalid_type,expected:x.map,received:n.parsedType}),L;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new rt(n,o,n.path,[l,"key"])),value:a._parse(new rt(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}qr.create=(s,e,t)=>new qr({valueType:e,keyType:s,typeName:z.ZodMap,...q(t)});let Vr=class Si extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.set)return N(n,{code:_.invalid_type,expected:x.set,received:n.parsedType}),L;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(N(n,{code:_.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(N(n,{code:_.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return L;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new rt(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Si({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new Si({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Vr.create=(s,e)=>new Vr({valueType:s,minSize:null,maxSize:null,typeName:z.ZodSet,...q(e)});let Lu=class pr extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return N(t,{code:_.invalid_type,expected:x.function,received:t.parsedType}),L;function n(o,u){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mr(),hn].filter(l=>!!l),issueData:{code:_.invalid_arguments,argumentsError:u}})}function r(o,u){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mr(),hn].filter(l=>!!l),issueData:{code:_.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof vs){const o=this;return Ze(async function(...u){const l=new Ke([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ze(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Ke([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new Ke([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pr({...this._def,args:Pt.create(e).rest(Vt.create())})}returns(e){return new pr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new pr({args:e||Pt.create([]).rest(Vt.create()),returns:t||Vt.create(),typeName:z.ZodFunction,...q(n)})}},kn=class extends W{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})}};kn.create=(s,e)=>new kn({getter:s,typeName:z.ZodLazy,...q(e)});let On=class extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};On.create=(s,e)=>new On({value:s,typeName:z.ZodLiteral,...q(e)});function Uu(s,e){return new Mt({values:s,typeName:z.ZodEnum,...q(e)})}class Mt extends W{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{expected:te.joinValues(n),received:t.parsedType,code:_.invalid_type}),L}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{received:t.data,code:_.invalid_enum_value,options:n}),L}return Ze(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 Mt.create(e)}exclude(e){return Mt.create(this.options.filter(t=>!e.includes(t)))}}Mt.create=Uu;class Tn extends W{_parse(e){const t=te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==x.string&&n.parsedType!==x.number){const r=te.objectValues(t);return N(n,{expected:te.joinValues(r),received:n.parsedType,code:_.invalid_type}),L}if(t.indexOf(e.data)===-1){const r=te.objectValues(t);return N(n,{received:n.data,code:_.invalid_enum_value,options:r}),L}return Ze(e.data)}get enum(){return this._def.values}}Tn.create=(s,e)=>new Tn({values:s,typeName:z.ZodNativeEnum,...q(e)});let vs=class extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return N(t,{code:_.invalid_type,expected:x.promise,received:t.parsedType}),L;const n=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return Ze(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};vs.create=(s,e)=>new vs({type:s,typeName:z.ZodPromise,...q(e)});let Je=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{N(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.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(r.type==="refinement"){const i=o=>{const u=r.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"?L:(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"?L:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!pn(i))return i;const o=r.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=>pn(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);te.assertNever(r)}};Je.create=(s,e,t)=>new Je({schema:s,typeName:z.ZodEffects,effect:e,...q(t)});Je.createWithPreprocess=(s,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:s},typeName:z.ZodEffects,...q(t)});let Tt=class extends W{_parse(e){return this._getType(e)===x.undefined?Ze(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tt.create=(s,e)=>new Tt({innerType:s,typeName:z.ZodOptional,...q(e)});let Qt=class extends W{_parse(e){return this._getType(e)===x.null?Ze(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(s,e)=>new Qt({innerType:s,typeName:z.ZodNullable,...q(e)});class xn extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===x.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}xn.create=(s,e)=>new xn({innerType:s,typeName:z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...q(e)});class Kr extends W{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Lr(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Kr.create=(s,e)=>new Kr({innerType:s,typeName:z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...q(e)});class Wr extends W{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.nan,received:t.parsedType}),L}return{status:"valid",value:e.data}}}Wr.create=s=>new Wr({typeName:z.ZodNaN,...q(s)});const fm=Symbol("zod_brand");class Bu extends W{_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 Rn extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?L:r.status==="dirty"?(t.dirty(),Ru(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?L:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new Rn({in:e,out:t,typeName:z.ZodPipeline})}}class Fr extends W{_parse(e){const t=this._def.innerType._parse(e);return pn(t)&&(t.value=Object.freeze(t.value)),t}}Fr.create=(s,e)=>new Fr({innerType:s,typeName:z.ZodReadonly,...q(e)});const qu=(s,e={},t)=>s?gs.create().superRefine((n,r)=>{var a,i;if(!s(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,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):gs.create(),mm={object:ue.lazycreate};var z;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(z||(z={}));const ym=(s,e={message:`Input not instance of ${s.name}`})=>qu(t=>t instanceof s,e),Vu=ys.create,Ku=fn.create,gm=Wr.create,vm=mn.create,Wu=yn.create,wm=gn.create,bm=Ur.create,_m=vn.create,km=wn.create,Om=gs.create,Tm=Vt.create,xm=Et.create,Sm=Br.create,Em=Xt.create,Nm=ue.create,Im=ue.strictCreate,Zm=bn.create,Am=ya.create,Cm=_n.create,$m=Pt.create,jm=Du.create,zm=qr.create,Rm=Vr.create,Pm=Lu.create,Mm=kn.create,Dm=On.create,Lm=Mt.create,Um=Tn.create,Bm=vs.create,Lo=Je.create,qm=Tt.create,Vm=Qt.create,Km=Je.createWithPreprocess,Wm=Rn.create,Fm=()=>Vu().optional(),Ym=()=>Ku().optional(),Jm=()=>Wu().optional(),Gm={string:s=>ys.create({...s,coerce:!0}),number:s=>fn.create({...s,coerce:!0}),boolean:s=>yn.create({...s,coerce:!0}),bigint:s=>mn.create({...s,coerce:!0}),date:s=>gn.create({...s,coerce:!0})},Hm=L;var f=Object.freeze({__proto__:null,defaultErrorMap:hn,setErrorMap:tm,getErrorMap:Mr,makeIssue:Dr,EMPTY_PATH:sm,addIssueToContext:N,ParseStatus:je,INVALID:L,DIRTY:Ru,OK:Ze,isAborted:bi,isDirty:_i,isValid:pn,isAsync:Lr,get util(){return te},get objectUtil(){return wi},ZodParsedType:x,getParsedType:Ct,ZodType:W,ZodString:ys,ZodNumber:fn,ZodBigInt:mn,ZodBoolean:yn,ZodDate:gn,ZodSymbol:Ur,ZodUndefined:vn,ZodNull:wn,ZodAny:gs,ZodUnknown:Vt,ZodNever:Et,ZodVoid:Br,ZodArray:Xt,ZodObject:ue,ZodUnion:bn,ZodDiscriminatedUnion:ya,ZodIntersection:_n,ZodTuple:Pt,ZodRecord:Du,ZodMap:qr,ZodSet:Vr,ZodFunction:Lu,ZodLazy:kn,ZodLiteral:On,ZodEnum:Mt,ZodNativeEnum:Tn,ZodPromise:vs,ZodEffects:Je,ZodTransformer:Je,ZodOptional:Tt,ZodNullable:Qt,ZodDefault:xn,ZodCatch:Kr,ZodNaN:Wr,BRAND:fm,ZodBranded:Bu,ZodPipeline:Rn,ZodReadonly:Fr,custom:qu,Schema:W,ZodSchema:W,late:mm,get ZodFirstPartyTypeKind(){return z},coerce:Gm,any:Om,array:Em,bigint:vm,boolean:Wu,date:wm,discriminatedUnion:Am,effect:Lo,enum:Lm,function:Pm,instanceof:ym,intersection:Cm,lazy:Mm,literal:Dm,map:zm,nan:gm,nativeEnum:Um,never:xm,null:km,nullable:Vm,number:Ku,object:Nm,oboolean:Jm,onumber:Ym,optional:qm,ostring:Fm,pipeline:Wm,preprocess:Km,promise:Bm,record:jm,set:Rm,strictObject:Im,string:Vu,symbol:bm,transformer:Lo,tuple:$m,undefined:_m,union:Zm,unknown:Tm,void:Sm,NEVER:Hm,ZodIssueCode:_,quotelessJson:em,ZodError:Ke});const ga=f.tuple([f.number(),f.number()]);f.tuple([f.bigint(),f.bigint()]);const Fu=f.object({width:f.number(),height:f.number()}),Xm=f.object({signedWidth:f.number(),signedHeight:f.number()}),Qm=["width","height"];f.enum(Qm);const ey=["start","center","end"],ty=["signedWidth","signedHeight"];f.enum(ty);const Yr=f.object({x:f.number(),y:f.number()}),sy=f.object({clientX:f.number(),clientY:f.number()}),ny=["x","y"],Yu=f.enum(ny),Ju=["top","right","bottom","left"];f.enum(Ju);const ry=["left","right"],Gu=f.enum(ry),ay=["top","bottom"],Hu=f.enum(ay),Xu=["center"],Uo=f.enum(Xu),iy=[...Ju,...Xu],Qu=f.enum(iy);f.enum(ey);const oy=["first","last"];f.enum(oy);const cy=f.object({lower:f.number(),upper:f.number()}),uy=f.object({lower:f.bigint(),upper:f.bigint()});f.union([cy,ga]);f.union([uy,ga]);f.union([Yu,Qu]);f.union([Yu,Qu,f.instanceof(String)]);const zs=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Bo(s);return Bo(t)},Bo=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s;f.object({x:Gu.or(Uo),y:Hu.or(Uo)});const ly=f.object({x:Gu,y:Hu}),dy=Object.freeze({x:"left",y:"top"}),hy=(s,e)=>s.x===e.x&&s.y===e.y,qo=f.union([f.number(),Yr,ga,Fu,Xm,sy]),py=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},Vo=Object.freeze({x:0,y:0}),Vn=f.union([f.number(),f.string()]);f.object({top:Vn,left:Vn,width:Vn,height:Vn});f.object({left:f.number(),top:f.number(),right:f.number(),bottom:f.number()});f.object({one:Yr,two:Yr,root:ly});const co=(s,e,t=0,n=0,r)=>{const a={one:{...Vo},two:{...Vo},root:r??dy};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,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))},Pa=s=>{const e=co(s);return{lower:e.one.x,upper:e.two.x}},Ma=s=>{const e=co(s);return{lower:e.one.y,upper:e.two.y}},fy=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,my=f.object({signedWidth:f.number(),signedHeight:f.number()});f.union([Fu,my,Yr,ga]);var yy=Object.defineProperty,gy=(s,e,t)=>e in s?yy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_t=(s,e,t)=>(gy(s,typeof e!="symbol"?e+"":e,t),t);const vy=(s,e,t)=>(e!=null&&(s=Math.max(s,e)),t!=null&&(s=Math.min(s,t)),s);f.object({offset:qo,scale:qo});const wy=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],by=s=>(e,t,n,r)=>[e,r?n/s:n*s],_y=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:i,upper:o}=s,u=a-r,l=o-i;if(t==="dimension")return[s,n*(l/u)];const h=(n-r)*(l/u)+i;return[s,h]},ky=s=>(e,t,n)=>[s,n],Oy=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Ty=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=vy(n,r,a),[e,n]},Ei=class As{constructor(){_t(this,"ops",[]),_t(this,"currBounds",null),_t(this,"currType",null),_t(this,"reversed",!1),this.ops=[]}static translate(e){return new As().translate(e)}static magnify(e){return new As().magnify(e)}static scale(e,t){return new As().scale(e,t)}translate(e){const t=this.new(),n=wy(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=by(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=zs(e,t),r=this.new(),a=_y(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=zs(e,t),r=this.new(),a=Ty(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=zs(e,t),r=this.new(),a=ky(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Oy();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 As;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([i,o])=>r>=i&&r<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}};_t(Ei,"IDENTITY",new Ei);let Ko=Ei;const Wo=class vt{constructor(e=new Ko,t=new Ko,n=null){_t(this,"x"),_t(this,"y"),_t(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new vt().translate(e,t)}static translateX(e){return new vt().translateX(e)}static translateY(e){return new vt().translateY(e)}static clamp(e){return new vt().clamp(e)}static magnify(e){return new vt().magnify(e)}static scale(e){return new vt().scale(e)}static reBound(e){return new vt().reBound(e)}translate(e,t){const n=py(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}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(fy(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!hy(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(Pa(e)),t.y=t.y.scale(Ma(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(Pa(e)),t.y=this.y.reBound(Ma(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Pa(e)),t.y=this.y.clamp(Ma(e)),t}copy(){const e=new vt;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 co(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};_t(Wo,"IDENTITY",new Wo);var xy=Object.defineProperty,Sy=(s,e,t)=>e in s?xy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,v=(s,e,t)=>(Sy(s,typeof e!="symbol"?e+"":e,t),t);let Ey="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Ny=(s=21)=>{let e="",t=s;for(;t--;)e+=Ey[Math.random()*64|0];return e};const el=(s,e)=>{const t=new J(e);if(![X.DAY,X.HOUR,X.MINUTE,X.SECOND,X.MILLISECOND,X.MICROSECOND,X.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof J?new J(n):new X(n)},oe=class P{constructor(e,t="UTC"){if(v(this,"value"),v(this,"encodeValue",!0),e==null)this.value=P.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*P.MILLISECOND.valueOf();else if(typeof e=="string")this.value=P.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=P.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=P.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=P.MAX:e=P.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new P(BigInt(r.getTime())*P.MILLISECOND.valueOf()).truncate(P.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=P.hours(parseInt(n??"00",10)).add(P.minutes(parseInt(r??"00",10))).add(P.seconds(parseInt(i??"00",10))).add(P.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(P.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return P.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new P(BigInt(n.getTime())*P.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(P.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"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new X(BigInt(new Date().getTimezoneOffset())*P.MINUTE.valueOf())}static since(e){return new P().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new P(e).valueOf()}span(e){return this.range(e).span}range(e){return new Ee(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 P(e).valueOf()}afterEq(e){return this.valueOf()>=new P(e).valueOf()}before(e){return this.valueOf()<new P(e).valueOf()}beforeEq(e){return this.valueOf()<=new P(e).valueOf()}add(e){return new P(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new P(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/P.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return el(this,e)}get isToday(){return this.truncate(X.DAY).equals(P.now().truncate(X.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new P(new Date)}static max(...e){let t=P.MIN;for(const n of e){const r=new P(n);r.after(t)&&(t=r)}return t}static min(...e){let t=P.MAX;for(const n of e){const r=new P(n);r.before(t)&&(t=r)}return t}static nanoseconds(e){return new P(e)}static microseconds(e){return P.nanoseconds(e*1e3)}static milliseconds(e){return P.microseconds(e*1e3)}static seconds(e){return P.milliseconds(e*1e3)}static minutes(e){return P.seconds(e*60)}static hours(e){return P.minutes(e*60)}static days(e){return P.hours(e*24)}};v(oe,"NANOSECOND",oe.nanoseconds(1)),v(oe,"MICROSECOND",oe.microseconds(1)),v(oe,"MILLISECOND",oe.milliseconds(1)),v(oe,"SECOND",oe.seconds(1)),v(oe,"MINUTE",oe.minutes(1)),v(oe,"HOUR",oe.hours(1)),v(oe,"DAY",oe.days(1)),v(oe,"MAX",new oe((1n<<63n)-1n)),v(oe,"MIN",new oe(0)),v(oe,"ZERO",new oe(0)),v(oe,"z",f.union([f.object({value:f.bigint()}).transform(s=>new oe(s.value)),f.string().transform(s=>new oe(BigInt(s))),f.instanceof(Number).transform(s=>new oe(s)),f.number().transform(s=>new oe(s)),f.instanceof(oe)]));let J=oe;const ce=class re{constructor(e){v(this,"value"),v(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 re(e).valueOf()}greaterThan(e){return this.valueOf()>new re(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new re(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new re(e).valueOf()}remainder(e){return el(this,e)}truncate(e){return new re(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(re.DAY),t=this.truncate(re.HOUR),n=this.truncate(re.MINUTE),r=this.truncate(re.SECOND),a=this.truncate(re.MILLISECOND),i=this.truncate(re.MICROSECOND),o=this.truncate(re.NANOSECOND),u=e,l=t.sub(e),h=n.sub(t),g=r.sub(n),se=a.sub(r),ye=i.sub(a),ze=o.sub(i);let he="";return u.isZero||(he+=`${u.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),g.isZero||(he+=`${g.seconds}s `),se.isZero||(he+=`${se.milliseconds}ms `),ye.isZero||(he+=`${ye.microseconds}µs `),ze.isZero||(he+=`${ze.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/re.DAY.valueOf())}get hours(){return Number(this.valueOf()/re.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/re.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/re.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/re.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/re.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new re(e).valueOf()}add(e){return new re(this.valueOf()+new re(e).valueOf())}sub(e){return new re(this.valueOf()-new re(e).valueOf())}static nanoseconds(e=1){return new re(e)}static microseconds(e=1){return re.nanoseconds(e*1e3)}static milliseconds(e=1){return re.microseconds(e*1e3)}static seconds(e=1){return re.milliseconds(e*1e3)}static minutes(e){return re.seconds(e.valueOf()*60)}static hours(e){return re.minutes(e*60)}static days(e){return re.hours(e*24)}};v(ce,"NANOSECOND",ce.nanoseconds(1)),v(ce,"MICROSECOND",ce.microseconds(1)),v(ce,"MILLISECOND",ce.milliseconds(1)),v(ce,"SECOND",ce.seconds(1)),v(ce,"MINUTE",ce.minutes(1)),v(ce,"HOUR",ce.hours(1)),v(ce,"DAY",ce.days(1)),v(ce,"MAX",new ce((1n<<63n)-1n)),v(ce,"MIN",new ce(0)),v(ce,"ZERO",new ce(0)),v(ce,"z",f.union([f.object({value:f.bigint()}).transform(s=>new ce(s.value)),f.string().transform(s=>new ce(BigInt(s))),f.instanceof(Number).transform(s=>new ce(s)),f.number().transform(s=>new ce(s)),f.instanceof(ce)]));let X=ce;const Cs=class fr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new fr(e).valueOf()}get period(){return X.seconds(1/this.valueOf())}sampleCount(e){return new X(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Oe(t).valueOf()}span(e){return X.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new fr(e)}static khz(e){return fr.hz(e*1e3)}};v(Cs,"z",f.union([f.number().transform(s=>new Cs(s)),f.instanceof(Number).transform(s=>new Cs(s)),f.instanceof(Cs)]));let va=Cs;const ve=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Sn(e*this.valueOf())}};v(ve,"UNKNOWN",new ve(0)),v(ve,"BIT128",new ve(16)),v(ve,"BIT64",new ve(8)),v(ve,"BIT32",new ve(4)),v(ve,"BIT16",new ve(2)),v(ve,"BIT8",new ve(1)),v(ve,"z",f.union([f.number().transform(s=>new ve(s)),f.instanceof(Number).transform(s=>new ve(s)),f.instanceof(ve)]));let Oe=ve;const Xe=class mr{constructor(e,t){v(this,"start"),v(this,"end"),typeof e=="object"&&"start"in e?(this.start=new J(e.start),this.end=new J(e.end)):(this.start=new J(e),this.end=new J(t))}get span(){return new X(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 mr(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=X.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 r=J.max(n.start,e.start),a=J.min(n.end,e.end);return a.before(r)?!1:new X(a.sub(r)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}contains(e){return e instanceof mr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new mr(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}};v(Xe,"MAX",new Xe(J.MIN,J.MAX)),v(Xe,"MIN",new Xe(J.MAX,J.MIN)),v(Xe,"ZERO",new Xe(J.ZERO,J.ZERO)),v(Xe,"z",f.union([f.object({start:J.z,end:J.z}).transform(s=>new Xe(s.start,s.end)),f.instanceof(Xe)]));let Ee=Xe;const m=class Qe extends String{constructor(e){if(e instanceof Qe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=Qe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(Qe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Qe.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(Qe.JSON)||this.equals(Qe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Qe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Qe.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 Qe.BIG_INT_TYPES.some(e=>e.equals(this))}};v(m,"UNKNOWN",new m("unknown")),v(m,"FLOAT64",new m("float64")),v(m,"FLOAT32",new m("float32")),v(m,"INT64",new m("int64")),v(m,"INT32",new m("int32")),v(m,"INT16",new m("int16")),v(m,"INT8",new m("int8")),v(m,"UINT64",new m("uint64")),v(m,"UINT32",new m("uint32")),v(m,"UINT16",new m("uint16")),v(m,"UINT8",new m("uint8")),v(m,"BOOLEAN",m.UINT8),v(m,"TIMESTAMP",new m("timestamp")),v(m,"UUID",new m("uuid")),v(m,"STRING",new m("string")),v(m,"JSON",new m("json")),v(m,"ARRAY_CONSTRUCTORS",new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]])),v(m,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]])),v(m,"DENSITIES",new Map([[m.UINT8.toString(),Oe.BIT8],[m.UINT16.toString(),Oe.BIT16],[m.UINT32.toString(),Oe.BIT32],[m.UINT64.toString(),Oe.BIT64],[m.FLOAT32.toString(),Oe.BIT32],[m.FLOAT64.toString(),Oe.BIT64],[m.INT8.toString(),Oe.BIT8],[m.INT16.toString(),Oe.BIT16],[m.INT32.toString(),Oe.BIT32],[m.INT64.toString(),Oe.BIT64],[m.TIMESTAMP.toString(),Oe.BIT64],[m.STRING.toString(),Oe.UNKNOWN],[m.JSON.toString(),Oe.UNKNOWN],[m.UUID.toString(),Oe.BIT128]])),v(m,"ALL",[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON]),v(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),v(m,"z",f.union([f.string().transform(s=>new m(s)),f.instanceof(m)]));let G=m;const ke=class fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return fe.bytes(this.valueOf()+e.valueOf())}sub(e){return fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/fe.TERABYTE.valueOf()}toString(){const e=this.truncate(fe.TERABYTE),t=this.truncate(fe.GIGABYTE),n=this.truncate(fe.MEGABYTE),r=this.truncate(fe.KILOBYTE),a=this.truncate(fe.BYTE),i=e,o=t.sub(e),u=n.sub(t),l=r.sub(n),h=a.sub(r);let g="";return i.isZero||(g+=`${i.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),u.isZero||(g+=`${u.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!h.isZero||g==="")&&(g+=`${h.valueOf()}B`),g.trim()}static bytes(e=1){return new fe(e)}static kilobytes(e=1){return fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};v(ke,"BYTE",new ke(1)),v(ke,"KILOBYTE",ke.kilobytes(1)),v(ke,"MEGABYTE",ke.megabytes(1)),v(ke,"GIGABYTE",ke.gigabytes(1)),v(ke,"TERABYTE",ke.terabytes(1)),v(ke,"ZERO",new ke(0)),v(ke,"z",f.union([f.number().transform(s=>new ke(s)),f.instanceof(ke)]));let Sn=ke;f.union([f.instanceof(Uint8Array),f.instanceof(Uint16Array),f.instanceof(Uint32Array),f.instanceof(BigUint64Array),f.instanceof(Float32Array),f.instanceof(Float64Array),f.instanceof(Int8Array),f.instanceof(Int16Array),f.instanceof(Int32Array),f.instanceof(BigInt64Array)]);const tl=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof J||s instanceof X||s instanceof Date},Iy=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):$s(t,-n),Zy=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof Te?!0:tl(s),Ut=-1;class Te{constructor(e){v(this,"key",""),v(this,"isSynnaxSeries",!0),v(this,"dataType"),v(this,"sampleOffset"),v(this,"gl"),v(this,"_data"),v(this,"_timeRange"),v(this,"alignment",0n),v(this,"_cachedMin"),v(this,"_cachedMax"),v(this,"writePos",Ut),v(this,"_refCount",0),v(this,"_cachedLength"),Zy(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:i=0n,key:o=Ny()}=e,{data:u}=e;if(u instanceof Te||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const g=u;this.key=g.key,this.dataType=g.dataType,this.sampleOffset=g.sampleOffset,this.gl=g.gl,this._data=g._data,this._timeRange=g._timeRange,this.alignment=g.alignment,this._cachedMin=g._cachedMin,this._cachedMax=g._cachedMax,this.writePos=g.writePos,this._refCount=g._refCount,this._cachedLength=g._cachedLength;return}const l=tl(u),h=Array.isArray(u);if(t!=null)this.dataType=new G(t);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(h||l){let g=u;if(!l){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");g=u[0]}if(typeof g=="string")this.dataType=G.STRING;else if(typeof g=="number")this.dataType=G.FLOAT64;else if(typeof g=="bigint")this.dataType=G.INT64;else if(typeof g=="boolean")this.dataType=G.BOOLEAN;else if(g instanceof J||g instanceof Date||g instanceof J)this.dataType=G.TIMESTAMP;else if(typeof g=="object")this.dataType=G.JSON;else throw new Error(`cannot infer data type of ${typeof g} when constructing a Series from a JS array`)}else this.dataType=new G(u)}if(!h&&!l)this._data=u;else{let g=l?[u]:u;const se=g[0];(se instanceof J||se instanceof Date||se instanceof X)&&(g=g.map(ye=>new J(ye).valueOf())),this.dataType.equals(G.STRING)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(g.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`)):this.dataType.equals(
|
|
3
|
+
`)):this.dataType.equals(G.JSON)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(g.map(ye=>JSON.stringify(ye)).join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`)):this._data=new this.dataType.Array(
|
|
5
|
+
`)):this._data=new this.dataType.Array(g).buffer}this.key=o,this.alignment=i,this.sampleOffset=r??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const r=new new G(t).Array(e),a=new Te({data:r.buffer,dataType:t,...n});return a.writePos=0,a}static generateTimestamps(e,t,n){const r=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(n.add(t.span(i)).valueOf());return new Te({data:a,dataType:G.TIMESTAMP,timeRange:r})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`);return new
|
|
7
|
+
`);return new Te({data:n,dataType:G.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(r=>JSON.stringify(r)).join(`
|
|
8
8
|
`)+`
|
|
9
|
-
`);return new
|
|
10
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(
|
|
11
|
-
`).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new bs(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ft?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ft?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=Jm(this.dataType,e,this.data[n],t);return new Ee({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(re.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),Ir(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(re.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),Ir(this._cachedMin,this.sampleOffset))}get bounds(){return Ar(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Ir(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Ir(s,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let s=0,n=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){n=i;break}s=i+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(s,n);return this.dataType.equals(re.STRING)?new TextDecoder().decode(a):JSON.parse(new TextDecoder().decode(a))}binarySearch(e){let t=0,s=this.length-1;const n=rf(e);for(;t<=s;){const a=Math.floor((t+s)/2),i=n(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(re.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ft){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ft}as(e){if(e==="string"){if(!this.dataType.equals(re.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(re.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Ar(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Xm(this);return this.dataType.equals(re.JSON)?new Qm(e):e}return new ey(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const s=this.data.slice(e,t);return new Ee({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new Ee({data:this.buffer,dataType:this.dataType,timeRange:ze.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Xm{constructor(e){if(p(this,"series"),p(this,"index"),p(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}}var Ou;class Qm{constructor(e){p(this,"wrapped"),p(this,Ou,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:JSON.parse(e.value)}}[Symbol.iterator](){return this}}Ou=Symbol.toStringTag;var xu;class ey{constructor(e){p(this,"series"),p(this,"index"),p(this,xu,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}xu=Symbol.toStringTag;const Ir=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);class Nu{constructor(e){if(p(this,"series"),e.length!==0){const t=e[0].dataType;for(let s=1;s<e.length;s++)if(!e[s].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new re(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?re.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ze.ZERO:new ze(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const s of this.series){if(e<s.length)return s.at(e,t);e-=s.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new bs(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const s of this.series)e.set(s.data,t),t+=s.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new ty(this.series)}}var Su;class ty{constructor(e){p(this,"series"),p(this,"seriesIndex"),p(this,"internal"),p(this,Su,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}Su=Symbol.toStringTag;const $i=m.record(m.union([m.number(),m.string(),m.symbol()]),m.unknown()),Eu=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),ry=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";ry();const sy=["MacOS","Windows","Linux","Docker"];m.enum(sy);const ny=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}},bo=r=>[...new Set(r)],ay=(...r)=>r.map(Zu).join(""),Zu=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),iy=r=>r.endsWith("/")?r.slice(0,-1):r;var lr;let oy=(lr=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){p(this,"protocol"),p(this,"host"),p(this,"port"),p(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Zu(s)}replace(r){return new lr({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new lr({...this,pathPrefix:ay(this.path,r)})}toString(){return iy(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},p(lr,"UNKNOWN",new lr({host:"unknown",port:0})),lr);const se=r=>Array.isArray(r)?r:[r];class Iu{constructor(){p(this,"contentType","application/json"),p(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Un.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Eu(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=Un.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}}const cy=[new Iu],Au=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:cy,JSONEncoderDecoder:Iu},Symbol.toStringTag,{value:"Module"}));class uy{constructor(e){p(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,s)=>s(e))}}const Bn=Object.freeze(Object.defineProperty({__proto__:null,Observer:uy},Symbol.toStringTag,{value:"Module"})),ly=m.string().regex(/^\d+\.\d+\.\d+$/);m.object({version:ly});const xr=c.z.number(),Zs=c.z.object({name:c.z.string(),key:c.z.number(),rate:sa.z,dataType:re.z,leaseholder:c.z.number(),index:c.z.number(),isIndex:c.z.boolean(),alias:c.z.string().optional()}),Cu=Zs.extend({key:c.z.number().optional(),leaseholder:c.z.number().optional(),index:c.z.number().optional(),rate:sa.z.optional().default(0),isIndex:c.z.boolean().optional()}),dy=c.z.object({channels:Cu.array()}),hy=c.z.object({channels:Zs.array()}),py=c.z.object({keys:xr.array().optional(),names:c.z.string().array().optional()}),fy=c.z.object({}),my="/channel/create",yy="/channel/delete";let $u=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,my,{channels:e},dy,hy)).channels}async delete(e){await C(this.client,yy,e,py,fy)}};const gy=new Error("request for lock canceled");var vy=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function u(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,u)}l((s=s.apply(r,e||[])).next())})};class wy{constructor(e,t=gy){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,s)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:s}),this._dispatch()})}runExclusive(e,t=1){return vy(this,void 0,void 0,function*(){const[s,n]=yield this.acquire(t);try{return yield e(s)}finally{n()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const s=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!s)continue;const n=this._value,a=t;this._value-=t,t=this._value+1,s.resolve([n,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var _y=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function u(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,u)}l((s=s.apply(r,e||[])).next())})};class by{constructor(e){this._semaphore=new wy(1,e)}acquire(){return _y(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Ot="sy.api.";var $t=(r=>(r.General=Ot+"general",r.Parse=Ot+"parse",r.Auth=Ot+"auth",r.Unexpected=Ot+"unexpected",r.Validation=Ot+"validation",r.Query=Ot+"query",r.Route=Ot+"route",r))($t||{});class Kt extends Ns{constructor(e){super(e,Ot)}}class Ze extends Kt{constructor(t){var e=(...gb)=>(super(...gb),d(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(s=>`${s.field}: ${s.message}`).join(`
|
|
12
|
-
`)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class ju extends Kt{}class Ru extends Kt{}class ji extends Kt{}class ar extends Kt{constructor(e){super(`
|
|
9
|
+
`);return new Te({data:n,dataType:G.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Ut)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ut?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(G.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
10
|
+
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(G.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=G.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const r=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(r),i=>i.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(G.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
11
|
+
`).slice(0,-1).map(t=>e.parse(Pr(JSON.parse(t))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Sn(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ut?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ut?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=Iy(this.dataType,e,this.data[r],t);return new Te({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(G.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),$s(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(G.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),$s(this._cachedMin,this.sampleOffset))}get bounds(){return zs(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return $s(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return $s(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,r=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){r=i;break}n=i+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,r);return this.dataType.equals(G.STRING)?new TextDecoder().decode(a):Pr(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Xf(e);for(;t<=n;){const a=Math.floor((t+n)/2),i=r(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(G.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ut){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ut}as(e){if(e==="string"){if(!this.dataType.equals(G.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(G.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return zs(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Ay(this);return this.dataType.equals(G.JSON)?new Cy(e):e}return new $y(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new Te({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Te({data:this.buffer,dataType:this.dataType,timeRange:Ee.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Ay{constructor(e){if(v(this,"series"),v(this,"index"),v(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var sl;class Cy{constructor(e){v(this,"wrapped"),v(this,sl,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Pr(JSON.parse(e.value))}}[Symbol.iterator](){return this}}sl=Symbol.toStringTag;var nl;class $y{constructor(e){v(this,"series"),v(this,"index"),v(this,nl,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}nl=Symbol.toStringTag;const $s=(s,e)=>typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:e===0?s:s===0?e:Number(s)+Number(e);class rl{constructor(e){if(v(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new G(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?G.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?Ee.ZERO:new Ee(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new Sn(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new jy(this.series)}}var al;class jy{constructor(e){v(this,"series"),v(this,"seriesIndex"),v(this,"internal"),v(this,al,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}al=Symbol.toStringTag;const bs=c.z.number(),Pn=c.z.object({name:c.z.string(),key:c.z.number(),rate:va.z,dataType:G.z,leaseholder:c.z.number(),index:c.z.number(),isIndex:c.z.boolean(),alias:c.z.string().optional()}),il=Pn.extend({key:c.z.number().optional(),leaseholder:c.z.number().optional(),index:c.z.number().optional(),rate:va.z.optional().default(0),isIndex:c.z.boolean().optional(),virtual:c.z.boolean().optional().default(!1)}),zy=c.z.object({channels:il.array()}),Ry=c.z.object({channels:Pn.array()}),Py=c.z.object({keys:bs.array().optional(),names:c.z.string().array().optional()}),My=c.z.object({}),Dy="/channel/create",Ly="/channel/delete";let ol=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Dy,{channels:e},zy,Ry)).channels}async delete(e){await C(this.client,Ly,e,Py,My)}};const H=s=>Array.isArray(s)?s:[s],Uy=(s,e)=>{let t=null;return e===0?s:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>s(...n),e)}},By=new Error("request for lock canceled");var qy=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(n.next(h))}catch(g){i(g)}}function u(h){try{l(n.throw(h))}catch(g){i(g)}}function l(h){h.done?a(h.value):r(h.value).then(o,u)}l((n=n.apply(s,e||[])).next())})};class Vy{constructor(e,t=By){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{const a={resolve:n,reject:r,weight:e,priority:t},i=cl(this._queue,o=>t<=o.priority);i===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(i+1,0,a)})}runExclusive(e){return qy(this,arguments,void 0,function*(t,n=1,r=0){const[a,i]=yield this.acquire(n,r);try{return yield t(a)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ky(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const r=n.findIndex(a=>a.priority<=e);(r===-1?n:n.splice(0,r)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Ky(s,e){const t=cl(s,n=>e.priority<=n.priority);s.splice(t+1,0,e)}function cl(s,e){for(let t=s.length-1;t>=0;t--)if(e(s[t]))return t;return-1}var Wy=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(n.next(h))}catch(g){i(g)}}function u(h){try{l(n.throw(h))}catch(g){i(g)}}function l(h){h.done?a(h.value):r(h.value).then(o,u)}l((n=n.apply(s,e||[])).next())})};class Fy{constructor(e){this._semaphore=new Vy(1,e)}acquire(){return Wy(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const _s="sy.";class de extends Error{}d(de,"TYPE",_s+"validation");class Ni extends de{constructor(t,n){super(t+": "+n);d(this,"field");d(this,"message");this.field=t,this.message=n}}d(Ni,"TYPE",de.TYPE+".field");class ws extends Error{}d(ws,"TYPE",_s+"auth");class Jr extends ws{}d(Jr,"TYPE",ws.TYPE+".invalid-token");class Kt extends Error{constructor(e){super(`
|
|
13
12
|
Unexpected error encountered:
|
|
14
13
|
|
|
15
14
|
${e}
|
|
16
15
|
|
|
17
16
|
Please report this to the Synnax team.
|
|
18
|
-
`)}}class Xe extends Kt{}class ky extends Xe{}class Ty extends Xe{}class zu extends Kt{constructor(t,s){super(t);d(this,"path");this.path=s}}class Oy extends Kt{}const xy=r=>{if(!r.type.startsWith(Ot))return null;switch(r.type){case $t.General:return new ju(r.data);case $t.Parse:return new Ru(r.data);case $t.Auth:return new ji(r.data);case $t.Unexpected:return new ar(r.data);case $t.Validation:return new Ze(r.data);case $t.Query:return new Xe(r.data);case $t.Route:return new zu(r.data,r.data);default:return new ar(r.data)}},Ny=()=>{throw new Error("Not implemented")};Pc({encode:Ny,decode:xy});const Sy=async(r,e)=>{const[t,s]=await e(r);return s==null?[t,s]:s instanceof cs?[t,new cs({message:`Cannot reach cluster at ${s.url.host}:${s.url.port}`,url:s.url})]:[t,s]},Ey=c.z.object({leaseholder:c.z.number().optional(),keys:c.z.number().array().optional(),names:c.z.string().array().optional(),search:c.z.string().optional(),rangeKey:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional()}),Zy=c.z.object({channels:Zs.array()}),qn=class qn{constructor(e){d(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:s,normalized:n}=Ct(e);return await this.execute({[s]:n,rangeKey:t})}async page(e,t,s){return await this.execute({offset:e,limit:t,rangeKey:s})}async execute(e){const[t,s]=await this.client.send(qn.ENDPOINT,e,Ey,Zy);if(s!=null)throw s;return t.channels}};d(qn,"ENDPOINT","/channel/retrieve");let ks=qn;class Ri{constructor(e){d(this,"cache");d(this,"namesToKeys");d(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t}=Ct(e),s=[],n=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?s.push(o):n.push(i)}),n.length===0)return s;const a=await this.wrapped.retrieve(n);return this.updateCache(a),s.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const Ct=r=>{let e=se(r).filter(s=>s!==0),t="keys";return typeof e[0]=="string"&&(isNaN(parseInt(e[0]))?t="names":e=e.map(s=>parseInt(s))),{single:!Array.isArray(r),variant:t,normalized:e,actual:r}};class Pu{constructor(e,t){d(this,"mu",new by);d(this,"requests",new Map);d(this,"wrapped");d(this,"debouncedRun");this.wrapped=e,this.debouncedRun=ny(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t,variant:s}=Ct(e);return s==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,s)=>s.forEach(n=>e.add(n)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((s,n)=>s.resolve(t.filter(a=>n.includes(a.key))))}catch(t){this.requests.forEach(s=>s.reject(t))}finally{this.requests.clear()}})}}const Mu=async(r,e)=>{const{normalized:t}=Ct(e),s=await r.retrieve(t),n=[];if(t.forEach(a=>{s.find(i=>i.name===a||i.key===a)==null&&n.push(a)}),n.length>0)throw new Xe(`Could not find channels: ${JSON.stringify(n)}`);return s};class zi{constructor({dataType:e,rate:t,name:s,leaseholder:n=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:u,alias:l}){d(this,"_frameClient");d(this,"key");d(this,"name");d(this,"rate");d(this,"dataType");d(this,"leaseholder");d(this,"index");d(this,"isIndex");d(this,"alias");this.key=a,this.name=s,this.rate=new sa(t??0),this.dataType=new re(e),this.leaseholder=n,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new Ze("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Zs.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let Du=class{constructor(e,t,s,n){d(this,"frameClient");d(this,"client");d(this,"retriever");d(this,"writer");this.frameClient=e,this.retriever=t,this.client=s,this.writer=n}async create(e,t={}){const{retrieveIfNameExists:s=!1}=t,n=!Array.isArray(e);let a=se(e),i=[];if(s){const o=await this.retriever.retrieve(a.map(l=>l.name)),u=new Set(o.map(l=>l.name));a=a.filter(l=>!u.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(a))),n?i[0]:i}async retrieve(e,t){const{single:s,actual:n,normalized:a}=Ct(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!s)return i;if(i.length===0)throw new ky(`channel matching ${n} not found`);if(i.length>1)throw new Ty(`multiple channels matching ${n} found`);return i[0]}async delete(e){const{normalized:t,variant:s}=Ct(e);return s==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new Iy(this,e)}async page(e,t,s){return this.sugar(await this.retriever.page(e,t,s))}createDebouncedBatchRetriever(e=10){return new Ri(new Pu(new ks(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(s=>new zi({...s,frameClient:t}))}};class Iy{constructor(e,t){d(this,"client");d(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const Ay=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Ri,Channel:zi,Client:Du,ClusterRetriever:ks,DebouncedBatchRetriever:Pu,Writer:$u,analyzeParams:Ct,keyZ:xr,newPayload:Cu,payload:Zs,retrieveRequired:Mu},Symbol.toStringTag,{value:"Module"})),Cy=c.z.object({key:c.z.string(),username:c.z.string()}),$y=r=>async(e,t)=>{try{const s=await r();e.params.Authorization=`Bearer ${s}`}catch(s){return[e,s]}return await t(e)},jy=c.z.object({username:c.z.string(),password:c.z.string()}),Ry=c.z.object({token:c.z.string(),user:Cy}),zy="/auth/login";let Py=class{constructor(e,t){d(this,"token");d(this,"client");d(this,"authenticating");d(this,"authenticated");d(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,s)=>{this.client.send(zy,e,jy,Ry).then(([n,a])=>{if(a!=null)return s(a);this.token=n==null?void 0:n.token,this.user=n==null?void 0:n.user,this.authenticated=!0,t()}).catch(s)})}middleware(){return $y(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new ji("[auth] - attempting to authenticate without a token");return this.token})}};const My=["disconnected","connecting","connected","failed"],Lu=c.z.enum(My),Uu=c.z.object({status:Lu,error:c.z.instanceof(Error).optional(),message:c.z.string().optional(),clusterKey:c.z.string()}),Dy=c.z.object({clusterKey:c.z.string()}),ko={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},fr=class fr{constructor(e,t=ne.seconds(30),s){d(this,"_state");d(this,"pollFrequency",ne.seconds(30));d(this,"client");d(this,"name");d(this,"interval");d(this,"onChangeHandlers",[]);this._state={...ko},this.client=e,this.pollFrequency=t,this.name=s,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[s,n]=await this.client.send(fr.ENDPOINT,{},c.z.object({}),Dy);if(n!=null)throw n;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=s.clusterKey}catch(s){this._state.status="failed",this._state.error=s,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(s=>s(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};d(fr,"ENDPOINT","/connectivity/check"),d(fr,"DEFAULT",ko),d(fr,"connectionStateZ",Uu);let Ts=fr;const Ly=Object.freeze(Object.defineProperty({__proto__:null,Checker:Ts,state:Uu,status:Lu},Symbol.toStringTag,{value:"Module"})),To=r=>{const e=se(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Oo=(r,e)=>{const t=se(r);if(t.length===e.length)return;const s=To(r);throw To===null?new Ze("[Frame] - channel keys or names must be provided when constructing a frame."):new Ze(`[Frame] - ${s}s and arrays must be the same length.
|
|
19
|
-
Got ${t.length} ${
|
|
20
|
-
payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
|
|
21
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new
|
|
17
|
+
`)}}d(Kt,"TYPE",_s+"unexpected");class Re extends Error{}d(Re,"TYPE",_s+"query");class En extends Re{}d(En,"TYPE",Re.TYPE+".not_found");class Nn extends Re{}d(Nn,"TYPE",Re.TYPE+".multiple_results");class Gr extends Error{constructor(t,n){super(t);d(this,"path");this.path=n}}d(Gr,"TYPE",_s+"route");class Yy extends Error{}const Jy=s=>{if(!s.type.startsWith(_s))return null;if(s.type.startsWith(de.TYPE)){if(s.type===Ni.TYPE){const e=s.data.split(": ");return e.length<2?new de(s.data):new Ni(e[0],e[1])}return new de(s.data)}return s.type.startsWith(ws.TYPE)?s.type.startsWith(Jr.TYPE)?new Jr(s.data):new ws(s.data):s.type.startsWith(Kt.TYPE)?new Kt(s.data):s.type.startsWith(Re.TYPE)?s.type.startsWith(En.TYPE)?new En(s.data):s.type.startsWith(Nn.TYPE)?new Nn(s.data):new Re(s.data):s.type.startsWith(Gr.TYPE)?new Gr(s.data,s.data):new Kt(s.data)},Gy=()=>{throw new Error("Not implemented")};lu({encode:Gy,decode:Jy});const Hy=async(s,e)=>{const[t,n]=await e(s);return n==null?[t,n]:n instanceof Rt?[t,new Rt({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},uo=f.record(f.union([f.number(),f.string(),f.symbol()]),f.unknown()),ul=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Xy=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Xy();const Qy=["MacOS","Windows","Linux","Docker"];f.enum(Qy);const Fo=s=>[...new Set(s)];var eg=Object.defineProperty,tg=(s,e,t)=>e in s?eg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,js=(s,e,t)=>(tg(s,typeof e!="symbol"?e+"":e,t),t);const sg=(...s)=>s.map(ll).join(""),ll=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),ng=s=>s.endsWith("/")?s.slice(0,-1):s,Ii=class Zi{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){js(this,"protocol"),js(this,"host"),js(this,"port"),js(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=ll(r)}replace(e){return new Zi({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Zi({...this,pathPrefix:sg(this.path,e)})}toString(){return ng(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};js(Ii,"UNKNOWN",new Ii({host:"unknown",port:0}));let rg=Ii;var ag=Object.defineProperty,ig=(s,e,t)=>e in s?ag(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Da=(s,e,t)=>(ig(s,typeof e!="symbol"?e+"":e,t),t);let dl=class{constructor(){Da(this,"contentType","application/json"),Da(this,"decoder"),Da(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=Pr(JSON.parse(e));return t!=null?t.parse(n):n}encodeString(e){return JSON.stringify(Gf(e),(t,n)=>ArrayBuffer.isView(n)?Array.from(n):ul(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};const hl=new dl,og=[hl],Dt=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:og,JSONEncoderDecoder:dl,JSON_ECD:hl},Symbol.toStringTag,{value:"Module"}));var cg=Object.defineProperty,ug=(s,e,t)=>e in s?cg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ai=(s,e,t)=>(ug(s,typeof e!="symbol"?e+"":e,t),t);class lg{constructor(e,t){Ai(this,"handlers"),Ai(this,"transform"),this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[n,r]=this.transform(e);if(!r)return;t=n}this.handlers.forEach((n,r)=>r(t))}}let dg=class{constructor(e){Ai(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Hr=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:dg,Observer:lg},Symbol.toStringTag,{value:"Module"})),hg=f.string().regex(/^\d+\.\d+\.\d+$/);f.object({version:hg});const wa=(s,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(s);let r=H(s);const a=r[0],i=typeof a;let o;return i==="string"&&t&&!isNaN(parseInt(a))&&"number"in e?(o=e.number,r=r.map(u=>parseInt(u))):o=e[i],{single:n,variant:o,normalized:r,actual:s}},ba=(s,e,t,n)=>{if(n){if(t.length===0)throw new En(`${s} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new Nn(`Expected one ${s} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Mn=s=>c.z.union([c.z.null().transform(()=>[]),s.array()]),pg=c.z.object({leaseholder:c.z.number().optional(),keys:c.z.number().array().optional(),names:c.z.string().array().optional(),search:c.z.string().optional(),rangeKey:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional(),dataTypes:G.z.array().optional(),notDataTypes:G.z.array().optional(),virtual:c.z.boolean().optional(),isIndex:c.z.boolean().optional(),internal:c.z.boolean().optional()}),fg=c.z.object({channels:Mn(Pn)}),ns=s=>wa(s,{number:"keys",string:"names"}),ea=class ea{constructor(e){d(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){let{variant:n,normalized:r}=ns(e);return n==="keys"&&r.indexOf(0)!==-1&&(r=r.filter(a=>a!==0)),r.length===0?[]:await this.execute({[n]:r,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(ea.ENDPOINT,e,pg,fg);if(n!=null)throw n;return t.channels}};d(ea,"ENDPOINT","/channel/retrieve");let In=ea;class lo{constructor(e){d(this,"cache");d(this,"namesToKeys");d(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=wa(e,{string:"names",number:"keys"}),r=[],a=[];if(n.forEach(o=>{const u=this.getFromCache(o);u!=null?r.push(u):a.push(o)}),a.length===0)return r;const i=await this.wrapped.retrieve(a,t);return this.updateCache(i),r.concat(i)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}class pl{constructor(e,t){d(this,"mu",new Fy);d(this,"requests",new Map);d(this,"wrapped");d(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Uy(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=ns(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(r=>e.add(r)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,r)=>n.resolve(t.filter(a=>r.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const fl=async(s,e)=>{const{normalized:t}=ns(e),n=await s.retrieve(t),r=[];if(t.forEach(a=>{n.find(i=>i.name===a||i.key===a)==null&&r.push(a)}),r.length>0)throw new Re(`Could not find channels: ${JSON.stringify(r)}`);return n};class ho{constructor({dataType:e,rate:t,name:n,leaseholder:r=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:u,alias:l}){d(this,"_frameClient");d(this,"key");d(this,"name");d(this,"rate");d(this,"dataType");d(this,"leaseholder");d(this,"index");d(this,"isIndex");d(this,"alias");this.key=a,this.name=n,this.rate=new va(t??0),this.dataType=new G(e),this.leaseholder=r,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new de("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Pn.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let ml=class{constructor(e,t,n,r){d(this,"type","channel");d(this,"frameClient");d(this,"client");d(this,"retriever");d(this,"writer");this.frameClient=e,this.retriever=t,this.client=n,this.writer=r}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,r=!Array.isArray(e);let a=H(e),i=[];if(n){const o=await this.retriever.retrieve(a.map(l=>l.name)),u=new Set(o.map(l=>l.name));a=a.filter(l=>!u.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(a))),r?i[0]:i}async retrieve(e,t){const n=!Array.isArray(e),r=this.sugar(await this.retriever.retrieve(e,t));return ba("channel",e,r,n),n?r[0]:r}async search(e,t){return this.sugar(await this.retriever.search(e,t))}async delete(e){const{normalized:t,variant:n}=ns(e);return n==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new lo(new pl(new In(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new ho({...n,frameClient:t}))}};const mg=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:lo,Channel:ho,Client:ml,ClusterRetriever:In,DebouncedBatchRetriever:pl,Writer:ol,analyzeChannelParams:ns,keyZ:bs,newPayload:il,payload:Pn,retrieveRequired:fl},Symbol.toStringTag,{value:"Module"})),yg=c.z.object({key:c.z.string(),username:c.z.string()}),gg=c.z.object({username:c.z.string(),password:c.z.string()}),vg=c.z.object({token:c.z.string(),user:yg}),Yo="/auth/login",wg=3;let bg=class{constructor(e,t){d(this,"token");d(this,"client");d(this,"credentials");d(this,"authenticating");d(this,"authenticated");d(this,"user");d(this,"retryCount");this.client=e,this.authenticated=!1,this.credentials=t,this.retryCount=0}middleware(){const e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(Yo)){this.authenticating==null&&(this.authenticating=new Promise(async o=>{const[u,l]=await this.client.send(Yo,this.credentials,gg,vg);if(l!=null)return o(l);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}));const i=await this.authenticating;if(i!=null)return[t,i]}t.params.Authorization=`Bearer ${this.token}`;const[r,a]=await n(t);return a instanceof Jr&&this.retryCount<wg?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[r,a])};return e}};const _g=["disconnected","connecting","connected","failed"],yl=c.z.enum(_g),gl=c.z.object({status:yl,error:c.z.instanceof(Error).optional(),message:c.z.string().optional(),clusterKey:c.z.string()}),kg=c.z.object({clusterKey:c.z.string()}),Jo={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},os=class os{constructor(e,t=X.seconds(30),n){d(this,"_state");d(this,"pollFrequency",X.seconds(30));d(this,"client");d(this,"name");d(this,"interval");d(this,"onChangeHandlers",[]);this._state={...Jo},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,r]=await this.client.send(os.ENDPOINT,{},c.z.object({}),kg);if(r!=null)throw r;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};d(os,"ENDPOINT","/connectivity/check"),d(os,"DEFAULT",Jo),d(os,"connectionStateZ",gl);let Zn=os;const Og=Object.freeze(Object.defineProperty({__proto__:null,Checker:Zn,state:gl,status:yl},Symbol.toStringTag,{value:"Module"})),Go=s=>{const e=H(s);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ho=(s,e)=>{const t=H(s);if(t.length===e.length)return;const n=Go(s);throw Go===null?new de("[Frame] - channel keys or names must be provided when constructing a frame."):new de(`[Frame] - ${n}s and arrays must be the same length.
|
|
18
|
+
Got ${t.length} ${n}s and ${e.length} arrays.`)};class me{constructor(e=[],t=[]){d(this,"columns",[]);d(this,"series",[]);if(e instanceof me){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((r,a)=>this.push(a,...H(r)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const r=e,a=r.series.map(i=>wl(i));Ho(r.keys,a),r.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([r,a])=>{const i=parseInt(r);if(isNaN(i))this.push(r,...H(a));else return this.push(i,...H(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const r=H(t),a=H(e);Ho(a,r),r.forEach((i,o)=>this.push(a[o],i));return}throw new de(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
19
|
+
payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
|
|
20
|
+
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new Kt("colType is not key");return this.columns??[]}get uniqueKeys(){return Fo(this.keys)}get names(){if(this.colType==="key")throw new Kt("colType is not name");return this.columns??[]}get uniqueNames(){return Fo(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>bl(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return Ee.ZERO;const n=J.min(...this.series.map(a=>a.timeRange.start)),r=J.max(...this.series.map(a=>a.timeRange.end));return new Ee(n,r)}const t=this.get(e);return t==null?Ee.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new rl(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof me){if(this.colType!==null&&e.colType!==this.colType)throw new de("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new de("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new de("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new me([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new me;return this.forEach((n,r,a)=>t.push(...e(n,r,a))),t}forEach(e){this.columns.forEach((t,n)=>{const r=this.series[n];e(t,r,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(r=>{n[r]=this.get(r).at(e,t)}),n}filter(e){const t=new me;return this.columns.forEach((n,r)=>{const a=this.series[r];e(n,a,r)&&t.push(n,a)}),t}get byteLength(){return new Sn(this.series.reduce((e,t)=>e.add(t.byteLength),Sn.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const vl=c.z.object({timeRange:Ee.z.optional(),alignment:c.z.bigint().or(c.z.string().transform(s=>BigInt(s))).optional(),dataType:G.z,data:c.z.string().transform(s=>new Uint8Array(atob(s).split("").map(e=>e.charCodeAt(0))).buffer)}),_a=c.z.object({keys:c.z.union([c.z.null().transform(()=>[]),c.z.number().array().optional().default([])]),series:c.z.union([c.z.null().transform(()=>[]),vl.array().optional().default([])])}),wl=s=>{const{dataType:e,data:t,timeRange:n,alignment:r}=s;return new Te({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:r})},bl=s=>({timeRange:s._timeRange,dataType:s.dataType,data:new Uint8Array(s.data.buffer),alignment:s.alignment});class ka{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new ka(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=ns(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const r=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(i=>{const o=r.find(u=>u.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,r)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,r]}return[n,r]})}}class po{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new po(e);return await n.update(t),n}async update(e){const t=await fl(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new de(`
|
|
22
21
|
Received a single channel name or key but no series.
|
|
23
|
-
`);if(Array.isArray(t)){if(t.
|
|
22
|
+
`);if(Array.isArray(t)){if(t.some(u=>u instanceof Te||Array.isArray(u)))throw new de(`
|
|
24
23
|
Received a single channel name or key but multiple series.
|
|
25
|
-
`);t=t
|
|
24
|
+
`);t=t}const i=await this.fetchChannel(e),o=new Te({data:t,dataType:i.dataType});return new me(i.key,o)}if(Array.isArray(e)){if(t==null)throw new de(`
|
|
26
25
|
Received an array of channel names or keys but no series.
|
|
27
|
-
`);if(!Array.isArray(t))throw new
|
|
26
|
+
`);if(!Array.isArray(t))throw new de(`
|
|
28
27
|
Received an array of channel names or keys but no array of series.
|
|
29
|
-
`);const i=[],o=[];for(let u=0;u<e.length;u++){const l=await this.fetchChannel(e[u]);if(u>=t.length)throw new
|
|
28
|
+
`);const i=[],o=[];for(let u=0;u<e.length;u++){const l=await this.fetchChannel(e[u]);if(u>=t.length)throw new de(`
|
|
30
29
|
Received an array of channel names or keys but not enough series.
|
|
31
|
-
`);const h=new
|
|
30
|
+
`);const h=new Te({data:t[u],dataType:l.dataType});i.push(l.key),o.push(h)}return new me(i,o)}if(e instanceof me||e instanceof Map){const i=new me(e);if(this.adapter==null)return i;let o=[];return o=i.columns.map(u=>{var h;const l=typeof u=="string"?(h=this.adapter)==null?void 0:h.get(u):u;if(l==null)throw new de(`
|
|
32
31
|
Channel ${u} was not provided in the list of channels when opening the writer
|
|
33
|
-
`);return l}),new me(o,i.series)}const
|
|
34
|
-
Please report this error to the Synnax team.`);if(t==null)throw new ar(`${this.name} received unexpected null error on closure.
|
|
35
|
-
Please report this error to Synnax team.
|
|
36
|
-
`);if(!(t instanceof os))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Qa=new ne(-1);var Di=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Di||{}),Ku=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(Ku||{});const Uy=c.z.object({command:c.z.nativeEnum(Di),span:ne.z.optional(),bounds:ze.z.optional(),stamp:G.z.optional(),keys:c.z.number().array().optional()}),By=c.z.object({variant:c.z.nativeEnum(Ku),ack:c.z.boolean(),command:c.z.nativeEnum(Di),error:Ss.optional().nullable(),frame:na.optional()}),Cr=class Cr{constructor(e,t){d(this,"stream");d(this,"adapter");d(this,"value");this.stream=new Mi("Iterator",e),this.value=new me,this.adapter=t}static async _open(e,t,s,n){const a=await aa.open(s,t),i=await n.stream(Cr.ENDPOINT,Uy,By),o=new Cr(i,a);return await o.execute({command:0,keys:a.keys,bounds:new ze(e)}),o}async next(e=Qa){return await this.execute({command:1,span:new ne(e)})}async prev(e=Qa){return await this.execute({command:2,span:new ne(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new G(e)})}async seekGE(e){return await this.execute({command:6,stamp:new G(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Vy(this)}async execute(e){for(this.stream.send(e),this.value=new me;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new me(t.frame)))}}};d(Cr,"ENDPOINT","/frame/iterate");let Vn=Cr;class Vy{constructor(e){d(this,"iter");d(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const qy=c.z.object({start:G.z.optional(),keys:c.z.number().array()}),Ky=c.z.object({frame:na,error:Ss.optional().nullable()}),Wy="/frame/stream";class ia{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Mi("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:s,from:n}){const a=await aa.open(e,s),i=await t.stream(Wy,qy,Ky),o=new ia(i,a);return i.send({start:new G(n),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new me((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const jt=class jt extends Number{};d(jt,"Absolute",255),d(jt,"Default",1),d(jt,"z",c.z.union([c.z.instanceof(jt),c.z.number().int().min(0).max(255).transform(e=>new jt(e)),c.z.instanceof(Number).transform(e=>new jt(e))]));let ir=jt;const Li=c.z.object({name:c.z.string(),key:c.z.string()}),Fy=c.z.object({subject:Li,resource:c.z.number(),authority:ir.z}),Yy=(...r)=>e=>e.filter(t=>{let s=!1;return t.to!=null&&(s=r.includes(t.to.resource)),t.from!=null&&!s&&(s=r.includes(t.from.resource)),s}),Gy=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Ui{constructor(e){d(this,"states");d(this,"streamer");d(this,"ecd");d(this,"observer");d(this,"closePromise");this.states=new Map,this.ecd=new Au.JSONEncoderDecoder,this.observer=new Bn.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new Ui(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var Bi=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))(Bi||{}),Os=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Os||{});const Jy=new ne(-1),Hy=c.z.object({start:G.z.optional(),controlSubject:Li.optional(),keys:c.z.number().array().optional(),authorities:ir.z.array().optional(),mode:c.z.nativeEnum(Os).optional(),enableAutoCommit:c.z.boolean().optional(),autoIndexPersistInterval:ne.z.optional()}),Xy=c.z.object({command:c.z.nativeEnum(Bi),config:Hy.optional(),frame:na.optional()}),Qy=c.z.object({ack:c.z.boolean(),command:c.z.nativeEnum(Bi),error:Ss.optional().nullable()});var Ht;let Wu=(Ht=class{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Mi("Writer",e),this.adapter=t}static async _open(e,t,{channels:s,start:n=G.now(),authorities:a=ir.Absolute,controlSubject:i,mode:o=1,enableAutoCommit:u=!1,autoIndexPersistInterval:l=ne.SECOND}){const h=await Pi.open(e,s),k=await t.stream(Ht.ENDPOINT,Xy,Qy),Q=new Ht(k,h);return await Q.execute({command:0,config:{start:new G(n),keys:h.keys,controlSubject:i,authorities:se(a),mode:o,enableAutoCommit:u,autoIndexPersistInterval:l}}),Q}async write(e,t){const s=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:s.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(s=>Number(s)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?wi(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},d(Ht,"ENDPOINT","/frame/write"),Ht),Fu=class{constructor(e,t){d(this,"stream");d(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await Vn._open(e,t,this.retriever,this.stream)}async openWriter(e){return await Wu._open(this.retriever,this.stream,e)}async openStreamer(e){const t=typeof e=="object";return(Array.isArray(e)||!t)&&(e={channels:e}),await ia._open(this.retriever,this.stream,e)}async write(e,t,s){if(s==null){const a=t,i=await this.openWriter({start:e,channels:Object.keys(a),mode:Os.PersistOnly});try{await i.write(a),await i.commit()}finally{await i.close()}return}const n=await this.openWriter({start:e,channels:t,mode:Os.PersistOnly});try{await n.write(t,s),await n.commit()}finally{await n.close()}}async read(e,t){const{single:s}=Ct(t),n=await this.readFrame(e,t);return s?n.get(t):n}async readFrame(e,t){const s=await this.openIterator(e,t),n=new me;try{for await(const a of s)n.push(a)}finally{await s.close()}return n}};const eg=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:Jy,AUTO_SPAN:Qa,Client:Fu,Frame:me,Iterator:Vn,Streamer:ia,Writer:Wu,WriterMode:Os,frameZ:na,series:Bu,seriesFromPayload:Vu,seriesToPayload:qu},Symbol.toStringTag,{value:"Module"}));let Yu=class{constructor(e,t,s){d(this,"tasks");d(this,"racks");d(this,"devices");this.tasks=e,this.racks=t,this.devices=s}};const tg=Object.freeze(Object.defineProperty({__proto__:null,Client:Yu},Symbol.toStringTag,{value:"Module"})),Is=c.z.number(),Vi=c.z.object({key:Is,name:c.z.string()}),rg=Vi.partial({key:!0}),qi=c.z.string(),oa=c.z.object({key:qi,rack:Is,name:c.z.string(),make:c.z.string(),model:c.z.string(),location:c.z.string(),properties:c.z.string()});class As{constructor(e,t,s,n){d(this,"streamer");d(this,"decoder");d(this,"base");d(this,"closePromise");d(this,"deleteChannel");d(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new Bn.Observer,this.closePromise=this.stream(),this.deleteChannel=n,this.setChannel=s}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const s=e.get(this.deleteChannel);t.push(...s.series.flatMap(n=>this.decoder("delete",n)))}if(this.setChannel!=null){const s=e.get(this.setChannel);t.push(...s.series.flatMap(n=>this.decoder("set",n)))}this.base.notify(t)}}static async open(e,t,s,n){const a=await e.openStreamer([t,s]);return new As(a,n,t,s)}}const sg="sy_device_set",ng="sy_device_delete";let Gu=class{constructor(e,t,s){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=s}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(se(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await As.open(this.frameClient,sg,ng,ag)}};const ag=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(oa).map(t=>({variant:r,key:t.key,value:t})),wa="/hardware/device/retrieve",_a=c.z.object({search:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional(),keys:qi.array().optional()}),ba=c.z.object({devices:oa.array()});let Ju=class{constructor(e){d(this,"client");this.client=e}async search(e){return(await C(this.client,wa,{keys:[e]},_a,ba)).devices}async page(e,t){return(await C(this.client,wa,{offset:e,limit:t},_a,ba)).devices}async retrieve(e){return(await C(this.client,wa,{keys:e},_a,ba)).devices}};const ig="/hardware/device/create",og="/hardware/device/delete",cg=c.z.object({devices:oa.array()}),ug=c.z.object({devices:oa.array()}),lg=c.z.object({keys:qi.array()}),dg=c.z.object({});let Hu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,ig,{devices:e},cg,ug)).devices}async delete(e){await C(this.client,og,{keys:e},lg,dg)}};const hg=Object.freeze(Object.defineProperty({__proto__:null,Client:Gu,Retriever:Ju,Writer:Hu},Symbol.toStringTag,{value:"Module"}));let Xu=class{constructor(e,t,s,n,a){d(this,"retriever");d(this,"writer");d(this,"frameClient");d(this,"taskWriter");d(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=s,this.taskWriter=n,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const s=await this.retriever.page(e,t);return this.sugar(s)}async retrieve(e){const t=await this.retriever.retrieve(se(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Qu(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Qu{constructor(e,t,s,n){d(this,"key");d(this,"name");d(this,"writer");d(this,"tasks");this.key=e,this.name=t,this.writer=s,this.tasks=n}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const pg="/hardware/rack/create",fg="/hardware/rack/delete",mg=c.z.object({racks:rg.array()}),yg=c.z.object({racks:Vi.array()}),gg=c.z.object({keys:Is.array()}),vg=c.z.object({});let el=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,pg,{racks:e},mg,yg)).racks}async delete(e){await C(this.client,fg,{keys:e},gg,vg)}};const ka="/hardware/rack/retrieve",Ta=c.z.object({keys:Is.array().optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Oa=c.z.object({racks:Vi.array()});let tl=class{constructor(e){d(this,"client");this.client=e}async page(e,t){return(await C(this.client,ka,{offset:e,limit:t},Ta,Oa)).racks}async search(e){return(await C(this.client,ka,{search:e},Ta,Oa)).racks}async retrieve(e){return(await C(this.client,ka,{keys:e},Ta,Oa)).racks}};const wg=Object.freeze(Object.defineProperty({__proto__:null,Client:Xu,Rack:Qu,Retriever:tl,Writer:el},Symbol.toStringTag,{value:"Module"}));let rl=class{constructor(e,t){d(this,"retriever");d(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let s=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(s=!1,t.keys=[e]):t.keys=se(e);const n=await this.retriever.retrieve(t);return s?n:n[0]}};const Ki=c.z.union([c.z.string(),c.z.bigint().transform(r=>r.toString()),c.z.number().transform(r=>r.toString())]),Wi=c.z.object({key:Ki,name:c.z.string(),type:c.z.string(),config:c.z.record(c.z.unknown()).or(c.z.string().transform(r=>JSON.parse(r)))}),_g=Wi.omit({key:!0}).extend({key:Ki.transform(r=>r.toString()).optional(),config:c.z.unknown().transform(r=>JSON.stringify(r))}),xa=c.z.object({rack:Is.optional(),keys:c.z.string().array().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Na=c.z.object({tasks:c.z.union([Wi.array(),c.z.null().transform(()=>[])])}),Sa="/hardware/task/retrieve";let sl=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,Sa,e,xa,Na)).tasks}async search(e){return(await C(this.client,Sa,{keys:[e]},xa,Na)).tasks}async page(e,t){return(await C(this.client,Sa,{offset:e,limit:t},xa,Na)).tasks}};const bg="/hardware/task/create",kg="/hardware/task/delete",Tg=c.z.object({tasks:_g.array()}),Og=c.z.object({tasks:Wi.array()}),xg=c.z.object({keys:Ki.array()}),Ng=c.z.object({});let nl=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,bg,{tasks:e},Tg,Og)).tasks}async delete(e){await C(this.client,kg,{keys:e},xg,Ng)}};const Sg=Object.freeze(Object.defineProperty({__proto__:null,Client:rl,Retriever:sl,Writer:nl},Symbol.toStringTag,{value:"Module"}));class Eg{constructor(e,t){d(this,"key");d(this,"name");this.key=t,this.name=e}get ontologyID(){return new we({type:"group",key:this.key})}}const Zg=c.z.string().uuid(),Ig=c.z.object({key:Zg,name:c.z.string()}),al=c.z.union([c.z.literal("label"),c.z.literal("builtin"),c.z.literal("cluster"),c.z.literal("channel"),c.z.literal("node"),c.z.literal("group"),c.z.literal("range"),c.z.literal("range-alias"),c.z.literal("user"),c.z.literal("workspace"),c.z.literal("pid"),c.z.literal("lineplot"),c.z.literal("rack")]),Ye=c.z.object({type:al,key:c.z.string()}),il=c.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),ol=c.z.union([il,Ye]),mr=class mr{constructor(e){d(this,"type");d(this,"key");if(e instanceof mr)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,s]=e.split(":");this.type=t,this.key=s}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};d(mr,"z",c.z.union([ol,c.z.instanceof(mr)]).transform(e=>new mr(e)));let we=mr;const Ag=new we({type:"builtin",key:"root"}),cl=c.z.object({type:c.z.number()}),ul=c.z.object({type:al,fields:c.z.record(cl)}),ll=c.z.object({id:we.z,name:c.z.string(),schema:ul.optional(),data:c.z.record(c.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),Cg=c.z.object({from:we.z,type:c.z.string(),to:we.z}),ei=r=>{const[e,t,s]=r.split("->");return{from:new we(e),type:t,to:new we(s)}},$g=c.z.object({group:Ig}),jg=c.z.object({parent:Ye,name:c.z.string()}),Rg=c.z.object({key:c.z.string(),name:c.z.string()}),zg=c.z.object({keys:c.z.array(c.z.string())});var nt;let Pg=(nt=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const[s,n]=await this.client.send(nt.ENDPOINT,{parent:e,name:t},jg,$g);if(n!=null)throw n;return s.group}async rename(e,t){const s={key:e,name:t},[,n]=await this.client.send(nt.ENDPOINT_RENAME,s,Rg,c.z.object({}));if(n!=null)throw n}async delete(e){const t={keys:e},[,s]=await this.client.send(nt.ENDPOINT_DELETE,t,zg,c.z.object({}));if(s!=null)throw s}},d(nt,"ENDPOINT","/ontology/create-group"),d(nt,"ENDPOINT_RENAME","/ontology/rename-group"),d(nt,"ENDPOINT_DELETE","/ontology/delete-group"),nt),Mg=class{constructor(e){d(this,"creator");this.creator=new Pg(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new Eg(e.name,e.key)}};const Dg=c.z.object({ids:Ye.array().optional(),children:c.z.boolean().optional(),parents:c.z.boolean().optional(),includeSchema:c.z.boolean().optional(),includeFieldData:c.z.boolean().optional(),term:c.z.string().optional()}),Lg=c.z.object({resources:ll.array()});var gr;let Ug=(gr=class{constructor(e){d(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,s=!0){return await this.execute({ids:se(e).map(n=>new we(n).payload),includeFieldData:s,includeSchema:t})}async retrieveChildren(e,t=!0,s=!0){return await this.execute({ids:se(e).map(n=>new we(n).payload),children:!0,includeSchema:t,includeFieldData:s})}async retrieveParents(e,t=!0,s=!0){return await this.execute({ids:se(e).map(n=>new we(n).payload),parents:!0,includeSchema:t,includeFieldData:s})}async execute(e){return(await C(this.client,gr.ENDPOINT,e,Dg,Lg)).resources}},d(gr,"ENDPOINT","/ontology/retrieve"),gr);const Ea={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},xo=c.z.object({id:Ye,children:Ye.array()}),Bg=c.z.object({from:Ye,to:Ye,children:Ye.array()});let Vg=class{constructor(e){d(this,"client");this.client=e}async addChildren(e,...t){await C(this.client,Ea.ADD_CHILDREN,{id:e,children:t},xo,c.z.object({}))}async removeChildren(e,...t){await C(this.client,Ea.REMOVE_CHILDREN,{id:e,children:t},xo,c.z.object({}))}async moveChildren(e,t,...s){const n={from:e,to:t,children:s};await C(this.client,Ea.MOVE_CHILDREN,n,Bg,c.z.object({}))}};const No="sy_ontology_resource_set",So="sy_ontology_resource_delete",Eo="sy_ontology_relationship_set",Zo="sy_ontology_relationship_delete";class ca{constructor(e,t){d(this,"resourceObs");d(this,"relationshipObs");d(this,"relationships");d(this,"resources");d(this,"streamer");d(this,"retriever");d(this,"closePromise");this.relationshipObs=new Bn.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Bn.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),s=this.parseResourceDeletes(e);t.concat(s).length>0&&this.resourceObs.notify(t.concat(s));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(Eo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"set",key:ei(s),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Zo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:ei(s)}))}async parseResourceSets(e){const t=e.get(No);if(t.length===0)return[];const s=Array.from(t.as("string")).map(n=>new we(n));try{return(await this.retriever.retrieve(s)).map(a=>({variant:"set",key:a.id,value:a}))}catch(n){if(n instanceof Xe)return[];throw n}}parseResourceDeletes(e){const t=e.get(So);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:new we(s)}))}static async open(e,t){const s=await e.openStreamer([No,So,Eo,Zo]);return new ca(s,t)}}let dl=class{constructor(e,t){d(this,"groups");d(this,"retriever");d(this,"writer");d(this,"framer");this.retriever=new Ug(e),this.writer=new Vg(e),this.groups=new Mg(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,s){const n=await this.retriever.retrieve(e,t,s);if(Array.isArray(e))return n;if(n.length===0)throw new Xe(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t){return[]}async retrieveChildren(e,t,s){return await this.retriever.retrieveChildren(e,t,s)}async retrieveParents(e,t,s){return await this.retriever.retrieveParents(e,t,s)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...s){return await this.writer.moveChildren(e,t,...s)}async openChangeTracker(){return await ca.open(this.framer,this.retriever)}};const qg=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:ca,Client:dl,ID:we,Root:Ag,crudeIDZ:ol,idZ:Ye,parseRelationship:ei,relationshipSchemaZ:Cg,resourceSchemaZ:ll,schemaFieldZ:cl,schemaZ:ul,stringIDZ:il},Symbol.toStringTag,{value:"Module"})),Nr=c.z.string().uuid(),Cs=c.z.object({key:Nr,name:c.z.string().min(1),color:c.z.string()}),Kg=r=>new we({type:"label",key:r}),Wg=c.z.object({keys:Nr.array().optional(),for:Ye.optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Fg=c.z.object({labels:Cs.array().optional().default([])});var vr;let hl=(vr=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=se(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,s]=await this.client.send(vr.ENDPOINT,e,Wg,Fg);if(s!=null)throw s;return t.labels}},d(vr,"ENDPOINT","/label/retrieve"),vr);const pl=Cs.extend({key:Nr.optional()}),Yg=c.z.object({labels:pl.array()}),Gg=c.z.object({labels:Cs.array()}),Jg=c.z.object({keys:Nr.array()}),fl=c.z.object({id:Ye,labels:Nr.array()}),Hg=fl,Za=c.z.object({}),Xg="/label/create",Qg="/label/delete",ev="/label/set",tv="/label/remove";let ml=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Xg,{labels:se(e)},Yg,Gg)).labels}async delete(e){await C(this.client,Qg,{keys:se(e)},Jg,Za)}async set(e,t){await C(this.client,ev,{id:e,labels:t},fl,Za)}async remove(e,t){await C(this.client,tv,{id:e,labels:t},Hg,Za)}};const rv="sy_label_set",sv="sy_label_delete";let yl=class{constructor(e,t){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.writer=new ml(e),this.retriever=new hl(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await As.open(this.frameClient,rv,sv,nv)}};const nv=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(Cs).map(t=>({variant:r,key:t.key,value:t})),av=Object.freeze(Object.defineProperty({__proto__:null,Client:yl,Retriever:hl,Writer:ml,keyZ:Nr,labelZ:Cs,newLabelPayloadZ:pl,ontologyID:Kg},Symbol.toStringTag,{value:"Module"})),Oe=c.z.string().uuid(),$s=c.z.object({key:Oe,name:c.z.string().min(1),timeRange:ze.z}),gl=$s.extend({key:c.z.string().uuid().optional()}),Fi=r=>{const e=se(r);if(e.length===0)throw new Error("Range params must not be empty");const t=Oe.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},iv=c.z.object({}),ov=c.z.object({range:$s}),cv=c.z.object({range:Oe}),uv=c.z.object({range:Oe}),lv=c.z.object({}),dv="/range/set-active",hv="/range/retrieve-active",pv="/range/clear-active";class fv{constructor(e){d(this,"client");this.client=e}async setActive(e){await C(this.client,dv,{range:e},cv,iv)}async retrieveActive(){const[e,t]=await this.client.send(hv,{},c.z.object({}),ov);if(t instanceof Xe)return null;if(t!=null)throw t;return e.range}async clearActive(e){await C(this.client,pv,{range:e},uv,lv)}}const mv="sy_range_alias_set",yv="sy_range_alias_delete",gv=c.z.object({range:Oe,aliases:c.z.string().array()}),vv=c.z.object({aliases:c.z.record(c.z.string(),xr)}),wv=c.z.object({range:Oe,aliases:c.z.record(xr.or(c.z.string()),c.z.string())}),_v=c.z.unknown(),bv=c.z.object({range:Oe,channels:xr.array()}),kv=c.z.unknown(),Tv=c.z.object({range:Oe}),Ov=c.z.object({aliases:c.z.record(c.z.string(),c.z.string())}),st=class st{constructor(e,t,s){d(this,"frameClient");d(this,"cache",new Map);d(this,"client");d(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=s,this.frameClient=t}async resolve(e){const t=[],s=typeof e=="string",n={};if(s){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?n[i]=o:t.push(i)});if(t.length===0)return n;const a=await C(this.client,st.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},gv,vv);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),s?a.aliases[t[0]]:{...n,...a.aliases}}async set(e){await C(this.client,st.SET_ENDPOINT,{range:this.rangeKey,aliases:e},wv,_v)}async list(){return(await C(this.client,st.LIST_ENDPOINT,{range:this.rangeKey},Tv,Ov)).aliases}async delete(e){await C(this.client,st.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},bv,kv)}async openChangeTracker(){return await As.open(this.frameClient,mv,yv,Sv(this.rangeKey))}};d(st,"SET_ENDPOINT","/range/alias/set"),d(st,"RESOLVE_ENDPOINT","/range/alias/resolve"),d(st,"LIST_ENDPOINT","/range/alias/list"),d(st,"DELETE_ENDPOINT","/range/alias/delete");let ti=st;const xv=c.z.object({range:Oe,channel:xr,alias:c.z.string()}),Nv="---",Sv=r=>(e,t)=>e==="delete"?t.toStrings().filter(s=>s.split(Nv)[0]===r).map(s=>({variant:e,key:s,value:void 0})):t.parseJSON(xv).map(s=>({variant:e,key:s.alias,value:s})),Ev=c.z.object({range:Oe,keys:c.z.string().array()}),Zv=c.z.object({pairs:c.z.record(c.z.string(),c.z.string())}),Iv=c.z.object({range:Oe,pairs:c.z.record(c.z.string(),c.z.string())}),Av=c.z.object({range:Oe,keys:c.z.string().array()}),Rt=class Rt{constructor(e,t){d(this,"rangeKey");d(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,s]=await this.client.send(Rt.GET_ENDPOINT,{range:this.rangeKey,keys:se(e)},Ev,Zv);if(s!=null)throw s;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await C(this.client,Rt.SET_ENDPOINT,{range:this.rangeKey,pairs:Eu(e)?e:{[e]:t}},Iv,c.z.unknown())}async delete(e){await C(this.client,Rt.DELETE_ENDPOINT,{range:this.rangeKey,keys:se(e)},Av,c.z.unknown())}};d(Rt,"GET_ENDPOINT","/range/kv/get"),d(Rt,"SET_ENDPOINT","/range/kv/set"),d(Rt,"DELETE_ENDPOINT","/range/kv/delete");let ri=Rt;const Ia=r=>new we({type:"range",key:r});class vl{constructor(e,t=ze.ZERO,s,n,a,i,o,u){d(this,"key");d(this,"name");d(this,"kv");d(this,"timeRange");d(this,"channels");d(this,"aliaser");d(this,"frameClient");d(this,"labelClient");this.key=s,this.name=e,this.timeRange=t,this.frameClient=n,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=u}async setAlias(e,t){const s=await this.channels.retrieve(e);if(s.length===0)throw new Xe(`Channel ${e} does not exist`);await this.aliaser.set({[s[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ia(this.key))}async addLabel(...e){await this.labelClient.label(Ia(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ia(this.key),e)}}let wl=class{constructor(e,t,s,n,a,i){d(this,"frameClient");d(this,"retriever");d(this,"writer");d(this,"unaryClient");d(this,"channels");d(this,"active");d(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=s,this.unaryClient=n,this.channels=a,this.active=new fv(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),s=this.sugar(await this.writer.create(se(e)));return t?s[0]:s}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(se(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:s}=Fi(e),n=this.sugar(await this.retriever.retrieve(e));if(!t)return n;if(n.length===0)throw new Xe(`range matching ${s} not found`);if(n.length>1)throw new Xe(`multiple ranges matching ${s} found`);return n[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new vl(t.name,t.timeRange,t.key,this.frameClient,new ri(t.key,this.unaryClient),new ti(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const Cv=c.z.object({ranges:$s.array()}),$v=c.z.object({ranges:gl.array()}),jv=c.z.object({keys:Oe.array()}),Rv=c.z.object({}),zv=c.z.object({key:Oe,name:c.z.string()}),Pv=c.z.object({}),Mv="/range/create",Dv="/range/delete",Lv="/range/rename";let _l=class{constructor(e){d(this,"client");this.client=e}async rename(e,t){await C(this.client,Lv,{key:e,name:t},zv,Pv)}async create(e){return(await C(this.client,Mv,{ranges:e},$v,Cv)).ranges}async delete(e){await C(this.client,Dv,{keys:e},jv,Rv)}};const Uv=c.z.object({keys:Oe.array().optional(),names:c.z.array(c.z.string()).optional(),term:c.z.string().optional()}),Bv=c.z.object({ranges:c.z.array($s)});let bl=class{constructor(e){d(this,"ENDPOINT","/range/retrieve");d(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:s}=Fi(e);return await this.execute({[s]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,s]=await this.client.send(this.ENDPOINT,e,Uv,Bv);if(s!=null)throw s;return t.ranges}};const Vv=Object.freeze(Object.defineProperty({__proto__:null,Client:wl,Range:vl,Retriever:bl,Writer:_l,analyzeParams:Fi,keyZ:Oe,newPayloadZ:gl,payloadZ:$s},Symbol.toStringTag,{value:"Module"})),qv="/api/v1/";class Kv{constructor(e,t=!1){d(this,"url");d(this,"unary");d(this,"stream");d(this,"secure");this.secure=t,this.url=e.child(qv);const s=new Au.JSONEncoderDecoder;this.unary=new Up(this.url,s,this.secure),this.stream=new Jp(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Wt=c.z.string().uuid(),Yi=c.z.object({name:c.z.string(),key:Wt,layout:$i.or(c.z.string().transform(r=>JSON.parse(r)))}),Gi=Yi.omit({layout:!0}).extend({layout:c.z.string().transform(r=>JSON.parse(r))}),Ji=c.z.string().uuid(),Hi=c.z.object({key:c.z.string(),name:c.z.string(),data:$i.or(c.z.string().transform(r=>JSON.parse(r)))}),Wv=c.z.object({keys:c.z.string().array()}),Fv=c.z.object({linePlots:Hi.array()});let Yv=class{constructor(e){d(this,"ENDPOINT","/workspace/lineplot/retrieve");d(this,"client");this.client=e}async retrieve(e){const t=se(e);return(await C(this.client,this.ENDPOINT,{keys:t},Wv,Fv)).linePlots}};const Gv=Hi.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Jv=c.z.object({workspace:Wt,linePlots:Gv.array()}),Hv=c.z.object({linePlots:Hi.array()}),Xv=c.z.object({keys:Ji.array()}),Qv=c.z.object({}),ew=c.z.object({key:Ji,name:c.z.string()}),tw=c.z.object({}),rw=c.z.object({key:Ji,data:c.z.string()}),sw=c.z.object({}),nw="/workspace/lineplot/create",aw="/workspace/lineplot/delete",iw="/workspace/lineplot/rename",ow="/workspace/lineplot/set-data";let cw=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await C(this.client,nw,{workspace:e,linePlots:[s]},Jv,Hv)).linePlots[0]}async delete(e){const t=se(e);await C(this.client,aw,{keys:t},Xv,Qv)}async rename(e,t){await C(this.client,iw,{key:e,name:t},ew,tw)}async setData(e,t){await C(this.client,ow,{key:e,data:JSON.stringify(t)},rw,sw)}},uw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new cw(e),this.retriever=new Yv(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}};const ua=c.z.string().uuid(),lw=c.z.object({key:c.z.string(),name:c.z.string(),data:$i.or(c.z.string().transform(r=>JSON.parse(r))),snapshot:c.z.boolean()}),Xi=c.z.object({key:c.z.string(),name:c.z.string(),snapshot:c.z.boolean(),data:c.z.string().transform(r=>JSON.parse(r))}),dw=c.z.object({keys:c.z.string().array()}),hw=c.z.object({pids:Xi.array()});let pw=class{constructor(e){d(this,"ENDPOINT","/workspace/pid/retrieve");d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,this.ENDPOINT,{keys:se(e)},dw,hw)).pids}};const fw=lw.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),mw=c.z.object({workspace:Wt,pids:fw.array()}),yw=c.z.object({pids:Xi.array()}),gw=c.z.object({keys:ua.array()}),vw=c.z.object({}),ww=c.z.object({key:ua,name:c.z.string()}),Io=c.z.object({}),_w=c.z.object({key:ua,data:c.z.string()});c.z.object({});const bw=c.z.object({key:ua,name:c.z.string(),snapshot:c.z.boolean()}),kw=c.z.object({pid:Xi}),Tw="/workspace/pid/create",Ow="/workspace/pid/delete",xw="/workspace/pid/rename",Nw="/workspace/pid/set-data",Sw="/workspace/pid/copy";let Ew=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await C(this.client,Tw,{workspace:e,pids:[s]},mw,yw)).pids[0]}async copy(e,t,s){return(await C(this.client,Sw,{key:e,name:t,snapshot:s},bw,kw)).pid}async delete(e){const t=se(e);await C(this.client,Ow,{keys:t},gw,vw)}async rename(e,t){await C(this.client,xw,{key:e,name:t},ww,Io)}async setData(e,t){await C(this.client,Nw,{key:e,data:JSON.stringify(t)},_w,Io)}},Zw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new Ew(e),this.retriever=new pw(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,s){return await this.writer.copy(e,t,s)}};const Iw=c.z.object({keys:Wt.array().optional(),search:c.z.string().optional(),author:c.z.string().uuid().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Aw=c.z.object({workspaces:Gi.array()}),Kn=class Kn{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=se(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await C(this.client,Kn.ENDPOINT,e,Iw,Aw)).workspaces}};d(Kn,"ENDPOINT","/workspace/retrieve");let si=Kn;const Cw=Yi.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),$w=c.z.object({workspaces:Cw.array()}),jw=c.z.object({workspaces:Gi.array()}),Rw=c.z.object({keys:Wt.array()}),zw=c.z.object({}),Pw=c.z.object({key:Wt,name:c.z.string()}),Mw=c.z.object({}),Dw=c.z.object({key:Wt,layout:c.z.string()}),Lw=c.z.object({}),Uw="/workspace/create",Bw="/workspace/delete",Vw="/workspace/rename",qw="/workspace/set-layout";class Kw{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Uw,{workspaces:se(e)},$w,jw)).workspaces}async delete(e){await C(this.client,Bw,{keys:se(e)},Rw,zw)}async rename(e,t){await C(this.client,Vw,{key:e,name:t},Pw,Mw)}async setLayout(e,t){await C(this.client,qw,{key:e,layout:JSON.stringify(t)},Dw,Lw)}}class kl{constructor(e){d(this,"pid");d(this,"linePlot");d(this,"retriever");d(this,"writer");this.pid=new Zw(e),this.linePlot=new uw(e),this.retriever=new si(e),this.writer=new Kw(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const Ww=Object.freeze(Object.defineProperty({__proto__:null,Client:kl,keyZ:Wt,workspaceRemoteZ:Gi,workspaceZ:Yi},Symbol.toStringTag,{value:"Module"})),Tl=c.z.object({host:c.z.string().min(1),port:c.z.number().or(c.z.string()),username:c.z.string().optional(),password:c.z.string().optional(),connectivityPollFrequency:ne.z.default(ne.seconds(30)),secure:c.z.boolean().optional().default(!1),name:c.z.string().optional()});class Ol extends Fu{constructor(t){const s=Tl.parse(t),{host:n,port:a,username:i,password:o,connectivityPollFrequency:u,secure:l}=s,h=new Kv(new oy({host:n,port:Number(a)}),l);h.use(Sy);let k;if(i!=null&&o!=null){const El=new Py(h.unary,{username:i,password:o});h.use(El.middleware())}const Q=new Ri(new ks(h.unary)),ye=new $u(h.unary);super(h.stream,Q);d(this,"createdAt");d(this,"props");d(this,"ranges");d(this,"channels");d(this,"auth");d(this,"connectivity");d(this,"ontology");d(this,"workspaces");d(this,"labels");d(this,"hardware");d(this,"transport");this.createdAt=G.now(),this.props=s,this.auth=k,this.transport=h,this.channels=new Du(this,Q,h.unary,ye),this.connectivity=new Ts(h.unary,u,s.name),this.ontology=new dl(h.unary,this);const Re=new bl(h.unary),de=new _l(this.transport.unary);this.labels=new yl(this.transport.unary,this),this.ranges=new wl(this,Re,de,this.transport.unary,Q,this.labels),this.workspaces=new kl(this.transport.unary);const xl=new Gu(new Ju(this.transport.unary),new Hu(this.transport.unary),this),Qi=new sl(this.transport.unary),eo=new nl(this.transport.unary),Nl=new rl(Qi,eo),Sl=new Xu(new tl(this.transport.unary),new el(this.transport.unary),this,eo,Qi);this.hardware=new Yu(Nl,Sl,xl)}close(){this.connectivity.stopChecking()}}d(Ol,"connectivity",Ts);const Fw=Object.freeze(Object.defineProperty({__proto__:null,Authority:ir,StateTracker:Ui,filterTransfersByChannelKey:Yy,stateZ:Fy,subjectZ:Li,transferString:Gy},Symbol.toStringTag,{value:"Module"}));exports.AuthError=ji;exports.Authority=ir;exports.Channel=zi;exports.ContiguityError=Oy;exports.DataType=re;exports.Density=ke;exports.Frame=me;exports.GeneralError=ju;exports.MultiSeries=Nu;exports.ParseError=Ru;exports.QueryError=Xe;exports.Rate=sa;exports.RouteError=zu;exports.Series=Ee;exports.Synnax=Ol;exports.TimeRange=ze;exports.TimeSpan=ne;exports.TimeStamp=G;exports.UnexpectedError=ar;exports.ValidationError=Ze;exports.channel=Ay;exports.connection=Ly;exports.control=Fw;exports.device=hg;exports.framer=eg;exports.hardware=tg;exports.label=av;exports.ontology=qg;exports.rack=wg;exports.ranger=Vv;exports.synnaxPropsZ=Tl;exports.task=Sg;exports.workspace=Ww;
|
|
32
|
+
`);return l}),new me(o,i.series)}const n=[],r=[],a=Object.entries(e);for(let i=0;i<a.length;i++){const[o,u]=a[i],l=await this.fetchChannel(o),h=new Te({data:u,dataType:l.dataType});n.push(l.key),r.push(h)}return new me(n,r)}}class fo{constructor(e,t){d(this,"name");d(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
33
|
+
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(t instanceof zt)return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Ci=new X(-1);var mo=(s=>(s[s.Open=0]="Open",s[s.Next=1]="Next",s[s.Prev=2]="Prev",s[s.SeekFirst=3]="SeekFirst",s[s.SeekLast=4]="SeekLast",s[s.SeekLE=5]="SeekLE",s[s.SeekGE=6]="SeekGE",s[s.Valid=7]="Valid",s[s.Error=8]="Error",s))(mo||{}),_l=(s=>(s[s.None=0]="None",s[s.Ack=1]="Ack",s[s.Data=2]="Data",s))(_l||{});const Tg=c.z.object({command:c.z.nativeEnum(mo),span:X.z.optional(),bounds:Ee.z.optional(),stamp:J.z.optional(),keys:c.z.number().array().optional()}),xg=c.z.object({variant:c.z.nativeEnum(_l),ack:c.z.boolean(),command:c.z.nativeEnum(mo),error:zn.optional().nullable(),frame:_a.optional()}),Rs=class Rs{constructor(e,t){d(this,"stream");d(this,"adapter");d(this,"value");this.stream=new fo("Iterator",e),this.value=new me,this.adapter=t}static async _open(e,t,n,r){const a=await ka.open(n,t),i=await r.stream(Rs.ENDPOINT,Tg,xg),o=new Rs(i,a);return await o.execute({command:0,keys:a.keys,bounds:new Ee(e)}),o}async next(e=Ci){return await this.execute({command:1,span:new X(e)})}async prev(e=Ci){return await this.execute({command:2,span:new X(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new J(e)})}async seekGE(e){return await this.execute({command:6,stamp:new J(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Sg(this)}async execute(e){for(this.stream.send(e),this.value=new me;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new me(t.frame)))}}};d(Rs,"ENDPOINT","/frame/iterate");let Xr=Rs;class Sg{constructor(e){d(this,"iter");d(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Eg=c.z.object({start:J.z.optional(),keys:c.z.number().array()}),Ng=c.z.object({frame:_a,error:zn.optional().nullable()}),Ig="/frame/stream";class Oa{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new fo("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:r}){const a=await ka.open(e,n),i=await t.stream(Ig,Eg,Ng),o=new Oa(i,a);return i.send({start:new J(r),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new me((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class yo extends Hr.Observer{constructor(t,n){super(n);d(this,"streamer");d(this,"closePromise");this.streamer=t,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const t of this.streamer)this.notify(t)}}const Nt=class Nt extends Number{};d(Nt,"Absolute",255),d(Nt,"Default",1),d(Nt,"z",c.z.union([c.z.instanceof(Nt),c.z.number().int().min(0).max(255).transform(e=>new Nt(e)),c.z.instanceof(Number).transform(e=>new Nt(e))]));let es=Nt;const go=c.z.object({name:c.z.string(),key:c.z.string()}),Zg=c.z.object({subject:go,resource:c.z.number(),authority:es.z}),Ag=(...s)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=s.includes(t.to.resource)),t.from!=null&&!n&&(n=s.includes(t.from.resource)),n}),Cg=s=>{var e,t;return s.to==null?`${(e=s.from)==null?void 0:e.resource} - ${(t=s.from)==null?void 0:t.subject.name} -> released`:s.from==null?`${s.to.resource} - released -> ${s.to.subject.name} (${s.to.authority.toString()})`:`${s.to.resource} - ${s.from.subject.name} -> ${s.to.subject.name} (${s.to.authority.toString()})`};class vo{constructor(e){d(this,"states");d(this,"streamer");d(this,"ecd");d(this,"observer");d(this,"closePromise");this.states=new Map,this.ecd=new Dt.JSONEncoderDecoder,this.observer=new Hr.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new vo(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var wo=(s=>(s[s.Open=0]="Open",s[s.Write=1]="Write",s[s.Commit=2]="Commit",s[s.Error=3]="Error",s[s.SetAuthority=4]="SetAuthority",s[s.SetMode=5]="SetMode",s))(wo||{}),An=(s=>(s[s.PersistStream=1]="PersistStream",s[s.PersistOnly=2]="PersistOnly",s[s.StreamOnly=3]="StreamOnly",s))(An||{});const $g=new X(-1),jg=c.z.object({start:J.z.optional(),controlSubject:go.optional(),keys:c.z.number().array().optional(),authorities:es.z.array().optional(),mode:c.z.nativeEnum(An).optional(),enableAutoCommit:c.z.boolean().optional(),autoIndexPersistInterval:X.z.optional()}),zg=c.z.object({command:c.z.nativeEnum(wo),config:jg.optional(),frame:_a.optional()}),Rg=c.z.object({ack:c.z.boolean(),command:c.z.nativeEnum(wo),error:zn.optional().nullable()});var Wt;let kl=(Wt=class{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new fo("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:r=J.now(),authorities:a=es.Absolute,controlSubject:i,mode:o=1,enableAutoCommit:u=!1,autoIndexPersistInterval:l=X.SECOND}){const h=await po.open(e,n),g=await t.stream(Wt.ENDPOINT,zg,Rg),se=new Wt(g,h);return await se.execute({command:0,config:{start:new J(r),keys:h.keys,controlSubject:i,authorities:H(a),mode:o,enableAutoCommit:u,autoIndexPersistInterval:l}}),se}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?Gi(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},d(Wt,"ENDPOINT","/frame/write"),Wt),Ol=class{constructor(e,t){d(this,"stream");d(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await Xr._open(e,t,this.retriever,this.stream)}async openWriter(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await kl._open(this.retriever,this.stream,e)}async openStreamer(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await Oa._open(this.retriever,this.stream,e)}async write(e,t,n){if(n==null){const a=t,i=await this.openWriter({start:e,channels:Object.keys(a),mode:An.PersistOnly});try{await i.write(a),await i.commit()}finally{await i.close()}return}const r=await this.openWriter({start:e,channels:t,mode:An.PersistOnly});try{await r.write(t,n),await r.commit()}finally{await r.close()}}async read(e,t){const{single:n}=ns(t),r=await this.readFrame(e,t);return n?r.get(t):r}async readFrame(e,t){const n=await this.openIterator(e,t),r=new me;try{for await(const a of n)r.push(a)}finally{await n.close()}return r}};const Pg=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:$g,AUTO_SPAN:Ci,Client:Ol,Frame:me,Iterator:Xr,ObservableStreamer:yo,Streamer:Oa,Writer:kl,WriterMode:An,frameZ:_a,series:vl,seriesFromPayload:wl,seriesToPayload:bl},Symbol.toStringTag,{value:"Module"}));let Tl=class{constructor(e,t,n){d(this,"tasks");d(this,"racks");d(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const Mg=Object.freeze(Object.defineProperty({__proto__:null,Client:Tl},Symbol.toStringTag,{value:"Module"})),ks=c.z.number(),Ta=c.z.object({key:ks,name:c.z.string()}),xl=Ta.partial({key:!0}),La="/hardware/rack/retrieve",Dg="/hardware/rack/create",Lg="/hardware/rack/delete",Ua=c.z.object({keys:ks.array().optional(),names:c.z.string().array().optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Ba=c.z.object({racks:Mn(Ta)}),Ug=c.z.object({racks:xl.array()}),Bg=c.z.object({racks:Ta.array()}),qg=c.z.object({keys:ks.array()}),Vg=c.z.object({});let Sl=class{constructor(e,t,n){d(this,"type","rack");d(this,"client");d(this,"frameClient");d(this,"tasks");this.client=e,this.frameClient=t,this.tasks=n}async delete(e){await C(this.client,Lg,{keys:H(e)},qg,Vg)}async create(e){const t=!Array.isArray(e),n=await C(this.client,Dg,{racks:H(e)},Ug,Bg),r=this.sugar(n.racks);return t?r[0]:r}async search(e){const t=await C(this.client,La,{search:e},Ua,Ba);return this.sugar(t.racks)}async page(e,t){const n=await C(this.client,La,{offset:e,limit:t},Ua,Ba);return this.sugar(n.racks)}async retrieve(e){const{variant:t,normalized:n,single:r}=wa(e,{string:"names",number:"keys"}),a=await C(this.client,La,{[t]:n},Ua,Ba),i=this.sugar(a.racks);return ba("Rack",e,i,r),r?i[0]:i}sugar(e){return e.map(({key:t,name:n})=>new El(t,n,this.tasks))}};class El{constructor(e,t,n){d(this,"key");d(this,"name");d(this,"tasks");this.key=e,this.name=t,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const Dn=async(s,e,t,n)=>{const r=await s.openStreamer([e,t]),a=i=>{const o=[];return t!=null&&o.push(...i.get(t).series.flatMap(u=>n("delete",u))),e!=null&&o.push(...i.get(e).series.flatMap(u=>n("set",u))),[o,o.length>0]};return new yo(r,a)},Kg=Object.freeze(Object.defineProperty({__proto__:null,openObservable:Dn},Symbol.toStringTag,{value:"Module"})),Wg="sy_device_set",Fg="sy_device_delete",qa="/hardware/device/retrieve",Yg="/hardware/device/create",Jg="/hardware/device/delete",xa=c.z.string(),Ln=c.z.object({key:xa,rack:ks,name:c.z.string(),make:c.z.string(),model:c.z.string(),location:c.z.string(),configured:c.z.boolean().optional(),properties:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:Dt.JSON_ECD.decodeString(s)))}),Nl=Ln.extend({properties:c.z.unknown().transform(s=>Dt.JSON_ECD.encodeString(s))}),Gg=c.z.object({devices:Nl.array()}),Hg=c.z.object({devices:Ln.array()}),Xg=c.z.object({keys:xa.array()}),Qg=c.z.object({}),Va=c.z.object({search:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional(),keys:xa.array().optional(),names:c.z.string().array().optional(),makes:c.z.string().array().optional()}),Ka=c.z.object({devices:Mn(Ln)});let Il=class{constructor(e,t){d(this,"type","device");d(this,"client");d(this,"frameClient");this.client=e,this.frameClient=t}async retrieve(e,t){const n=!Array.isArray(e),r=await C(this.client,qa,{keys:H(e),...t},Va,Ka);return ba("Device",e,r.devices,n),n?r.devices[0]:r.devices}async search(e,t){return(await C(this.client,qa,{search:e,...t},Va,Ka)).devices}async page(e,t,n){return(await C(this.client,qa,{offset:e,limit:t,...n},Va,Ka)).devices}async create(e){const t=!Array.isArray(e),n=await C(this.client,Yg,{devices:H(e)},Gg,Hg);return t?n.devices[0]:n.devices}async delete(e){await C(this.client,Jg,{keys:H(e)},Xg,Qg)}async openDeviceTracker(){return await Dn(this.frameClient,Wg,Fg,ev)}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}};const ev=(s,e)=>s==="delete"?e.toStrings().map(t=>({variant:s,key:t,value:void 0})):e.parseJSON(Ln).map(t=>({variant:s,key:t.key,value:t})),tv=Object.freeze(Object.defineProperty({__proto__:null,Client:Il,deviceKeyZ:xa,deviceZ:Ln,newDeviceZ:Nl},Symbol.toStringTag,{value:"Module"})),sv=Object.freeze(Object.defineProperty({__proto__:null,Client:Sl,Rack:El,newRackZ:xl,rackKeyZ:ks,rackZ:Ta},Symbol.toStringTag,{value:"Module"}));let nv=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const Wa="sy_task_state",Xo="sy_task_cmd",Os=c.z.union([c.z.string(),c.z.bigint().transform(s=>s.toString()),c.z.number().transform(s=>s.toString())]),Qr=c.z.object({task:Os,variant:c.z.string(),key:c.z.string().optional(),details:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:JSON.parse(s))).or(c.z.array(c.z.unknown())).or(c.z.null())}),Sa=c.z.object({key:Os,name:c.z.string(),type:c.z.string(),config:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:Dt.JSON_ECD.decodeString(s))),state:Qr.optional().nullable()}),Zl=Sa.omit({key:!0}).extend({key:Os.transform(s=>s.toString()).optional(),config:c.z.unknown().transform(s=>Dt.JSON_ECD.encodeString(s))}),rv=c.z.object({task:Os,type:c.z.string(),key:c.z.string(),args:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:JSON.parse(s)))});class Al{constructor(e,t,n,r,a,i){d(this,"key");d(this,"name");d(this,"type");d(this,"config");d(this,"state");d(this,"frameClient");this.key=e,this.name=t,this.type=n,this.config=r,i!==null&&(this.state=i),this.frameClient=a}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state}}async executeCommand(e,t){const n=await this.frameClient.openWriter(Xo),r=nv();return await n.write(Xo,[{task:this.key,type:e,key:r,args:t}]),await n.close(),r}async executeCommandSync(e,t,n){const r=await this.frameClient.openStreamer(Wa),a=await this.executeCommand(e,t);let i;const o=new Promise(u=>setTimeout(()=>u(!1),new X(n).milliseconds));for(;;){const u=await Promise.any([r.read(),o]);if(u===!1)throw new Error("Command timed out");const l=Qr.safeParse(u.at(-1).sy_task_state);if(l.success){if(i=l.data,i.key===a)break}else console.error(l.error)}return r.close(),i}async openStateObserver(){return new yo(await this.frameClient.openStreamer(Wa),e=>{const t=e.get(Wa);if(t.length===0)return[null,!1];const n=Qr.safeParse(t.at(-1));if(!n.success)return[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}}const av=c.z.object({rack:ks.optional(),keys:c.z.string().array().optional(),names:c.z.string().array().optional(),offset:c.z.number().optional(),limit:c.z.number().optional(),includeState:c.z.boolean().optional()}),iv=c.z.object({tasks:Mn(Sa)}),ov="/hardware/task/retrieve",cv="/hardware/task/create",uv="/hardware/task/delete",lv=c.z.object({tasks:Zl.array()}),dv=c.z.object({tasks:Sa.array()}),hv=c.z.object({keys:Os.array()}),pv=c.z.object({});let Cl=class{constructor(e,t){d(this,"type","task");d(this,"client");d(this,"frameClient");this.client=e,this.frameClient=t}async create(e){const t=!Array.isArray(e),n=await C(this.client,cv,{tasks:H(e)},lv,dv),r=this.sugar(n.tasks);return t?r[0]:r}async delete(e){await C(this.client,uv,{keys:H(e)},hv,pv)}async search(e){return await this.execRetrieve({keys:[e]})}async page(e,t){return this.execRetrieve({offset:e,limit:t})}async retrieve(e,t){const{single:n,normalized:r,variant:a}=wa(e,{number:"rack",string:"keys"},{convertNumericStrings:!1});let i={...t};a==="rack"?i.rack=e:i.keys=r;const o=await this.execRetrieve(i),u=this.sugar(o);return n&&a!=="rack"?u[0]:u}async retrieveByName(e,t){const n=await this.execRetrieve({names:[e],rack:t});return ba("Task",e,n,!0),this.sugar(n)[0]}async execRetrieve(e){return(await C(this.client,ov,e,av,iv)).tasks}sugar(e){return e.map(({key:t,name:n,type:r,config:a,state:i})=>new Al(t,n,r,a,this.frameClient,i))}};const fv=Object.freeze(Object.defineProperty({__proto__:null,Client:Cl,Task:Al,commandZ:rv,newTaskZ:Zl,stateZ:Qr,taskKeyZ:Os,taskZ:Sa},Symbol.toStringTag,{value:"Module"}));class mv{constructor(e,t){d(this,"key");d(this,"name");this.key=t,this.name=e}get ontologyID(){return new Ae({type:"group",key:this.key})}}const yv=c.z.string().uuid(),gv=c.z.object({key:yv,name:c.z.string()}),$l=c.z.union([c.z.literal("label"),c.z.literal("builtin"),c.z.literal("cluster"),c.z.literal("channel"),c.z.literal("node"),c.z.literal("group"),c.z.literal("range"),c.z.literal("range-alias"),c.z.literal("user"),c.z.literal("workspace"),c.z.literal("schematic"),c.z.literal("lineplot"),c.z.literal("rack"),c.z.literal("device"),c.z.literal("task")]),We=c.z.object({type:$l,key:c.z.string()}),jl=c.z.string().transform(s=>{const[e,t]=s.split(":");return{type:e,key:t}}),zl=c.z.union([jl,We]),cs=class cs{constructor(e){d(this,"type");d(this,"key");if(e instanceof cs)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};d(cs,"z",c.z.union([zl,c.z.instanceof(cs)]).transform(e=>new cs(e)));let Ae=cs;const vv=new Ae({type:"builtin",key:"root"}),Rl=c.z.object({type:c.z.number()}),Pl=c.z.object({type:$l,fields:c.z.record(Rl)}),Ml=c.z.object({id:Ae.z,name:c.z.string(),schema:Pl.optional().nullable(),data:c.z.record(c.z.unknown()).optional().nullable()}).transform(s=>({key:s.id.toString(),...s})),wv=c.z.object({from:Ae.z,type:c.z.string(),to:Ae.z}),$i=s=>{const[e,t,n]=s.split("->");return{from:new Ae(e),type:t,to:new Ae(n)}},bv=c.z.object({group:gv}),_v=c.z.object({parent:We,name:c.z.string()}),kv=c.z.object({key:c.z.string(),name:c.z.string()}),Ov=c.z.object({keys:c.z.array(c.z.string())});var tt;let Tv=(tt=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const[n,r]=await this.client.send(tt.ENDPOINT,{parent:e,name:t},_v,bv);if(r!=null)throw r;return n.group}async rename(e,t){const n={key:e,name:t},[,r]=await this.client.send(tt.ENDPOINT_RENAME,n,kv,c.z.object({}));if(r!=null)throw r}async delete(e){const t={keys:e},[,n]=await this.client.send(tt.ENDPOINT_DELETE,t,Ov,c.z.object({}));if(n!=null)throw n}},d(tt,"ENDPOINT","/ontology/create-group"),d(tt,"ENDPOINT_RENAME","/ontology/rename-group"),d(tt,"ENDPOINT_DELETE","/ontology/delete-group"),tt),xv=class{constructor(e){d(this,"creator");this.creator=new Tv(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new mv(e.name,e.key)}};const Fa={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Qo=c.z.object({id:We,children:We.array()}),Sv=c.z.object({from:We,to:We,children:We.array()});let Ev=class{constructor(e){d(this,"client");this.client=e}async addChildren(e,...t){await C(this.client,Fa.ADD_CHILDREN,{id:e,children:t},Qo,c.z.object({}))}async removeChildren(e,...t){await C(this.client,Fa.REMOVE_CHILDREN,{id:e,children:t},Qo,c.z.object({}))}async moveChildren(e,t,...n){const r={from:e,to:t,children:n};await C(this.client,Fa.MOVE_CHILDREN,r,Sv,c.z.object({}))}};const Nv="/ontology/retrieve",Iv=c.z.object({ids:We.array().optional(),children:c.z.boolean().optional(),parents:c.z.boolean().optional(),includeSchema:c.z.boolean().optional(),excludeFieldData:c.z.boolean().optional(),term:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional()}),Zv=c.z.object({resources:Ml.array()}),Ya=s=>H(s).map(e=>new Ae(e).payload);let Dl=class{constructor(e,t){d(this,"type","ontology");d(this,"groups");d(this,"client");d(this,"writer");d(this,"framer");this.client=e,this.writer=new Ev(e),this.groups=new xv(e),this.framer=t}async search(e,t){return await this.execRetrieve({term:e,...t})}async retrieve(e,t){const n=await this.execRetrieve({ids:Ya(e),...t});if(Array.isArray(e))return n;if(n.length===0)throw new Re(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t,n){return await this.execRetrieve({offset:e,limit:t,...n})}async retrieveChildren(e,t){return await this.execRetrieve({ids:Ya(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:Ya(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await Ea.open(this.framer,this)}newSearcherWithOptions(e){return{type:this.type,search:t=>this.search(t,e),retrieve:t=>this.retrieve(t,e),page:(t,n)=>this.page(t,n,e)}}async execRetrieve(e){const{resources:t}=await C(this.client,Nv,e,Iv,Zv);return t}};const ec="sy_ontology_resource_set",tc="sy_ontology_resource_delete",sc="sy_ontology_relationship_set",nc="sy_ontology_relationship_delete";class Ea{constructor(e,t){d(this,"resourceObs");d(this,"relationshipObs");d(this,"relationships");d(this,"resources");d(this,"streamer");d(this,"client");d(this,"closePromise");this.relationshipObs=new Hr.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Hr.Observer,this.resources=this.resourceObs,this.client=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(sc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:$i(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(nc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:$i(n)}))}async parseResourceSets(e){const t=e.get(ec);if(t.length===0)return[];const n=Array.from(t.as("string")).map(r=>new Ae(r));try{return(await this.client.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(r){if(r instanceof Re)return[];throw r}}parseResourceDeletes(e){const t=e.get(tc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new Ae(n)}))}static async open(e,t){const n=await e.openStreamer([ec,tc,sc,nc]);return new Ea(n,t)}}const Av=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Ea,Client:Dl,ID:Ae,Root:vv,crudeIDZ:zl,idZ:We,parseRelationship:$i,relationshipSchemaZ:wv,resourceSchemaZ:Ml,schemaFieldZ:Rl,schemaZ:Pl,stringIDZ:jl},Symbol.toStringTag,{value:"Module"})),Ts=c.z.string().uuid(),Un=c.z.object({key:Ts,name:c.z.string().min(1),color:c.z.string()}),Cv=s=>new Ae({type:"label",key:s}),$v=c.z.object({keys:Ts.array().optional(),for:We.optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),jv=c.z.object({labels:Un.array().optional().default([])});var us;let Ll=(us=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=H(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(us.ENDPOINT,e,$v,jv);if(n!=null)throw n;return t.labels}},d(us,"ENDPOINT","/label/retrieve"),us);const Ul=Un.extend({key:Ts.optional()}),zv=c.z.object({labels:Ul.array()}),Rv=c.z.object({labels:Un.array()}),Pv=c.z.object({keys:Ts.array()}),Bl=c.z.object({id:We,labels:Ts.array()}),Mv=Bl,Ja=c.z.object({}),Dv="/label/create",Lv="/label/delete",Uv="/label/set",Bv="/label/remove";let ql=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Dv,{labels:H(e)},zv,Rv)).labels}async delete(e){await C(this.client,Lv,{keys:H(e)},Pv,Ja)}async set(e,t){await C(this.client,Uv,{id:e,labels:t},Bl,Ja)}async remove(e,t){await C(this.client,Bv,{id:e,labels:t},Mv,Ja)}};const qv="sy_label_set",Vv="sy_label_delete";let Vl=class{constructor(e,t){d(this,"type","label");d(this,"retriever");d(this,"writer");d(this,"frameClient");this.writer=new ql(e),this.retriever=new Ll(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await Dn(this.frameClient,qv,Vv,Kv)}};const Kv=(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t})):e.parseJSON(Un).map(t=>({variant:s,key:t.key,value:t})),Wv=Object.freeze(Object.defineProperty({__proto__:null,Client:Vl,Retriever:Ll,Writer:ql,keyZ:Ts,labelZ:Un,newLabelPayloadZ:Ul,ontologyID:Cv},Symbol.toStringTag,{value:"Module"})),xe=c.z.string().uuid(),xs=c.z.object({key:xe,name:c.z.string().min(1),timeRange:Ee.z,color:c.z.string().optional()}),Kl=xs.extend({key:c.z.string().uuid().optional()}),Wl=s=>{const e=H(s);if(e.length===0)throw new Error("Range params must not be empty");const t=xe.safeParse(e[0]).success;return{single:!Array.isArray(s),variant:t?"keys":"names",normalized:e,actual:s}},Fv=c.z.object({}),Yv=c.z.object({range:xs}),Jv=c.z.object({range:xe}),Gv=c.z.object({range:xe}),Hv=c.z.object({}),Xv="/range/set-active",Qv="/range/retrieve-active",ew="/range/clear-active";class tw{constructor(e){d(this,"client");this.client=e}async setActive(e){await C(this.client,Xv,{range:e},Jv,Fv)}async retrieveActive(){const[e,t]=await this.client.send(Qv,{},c.z.object({}),Yv);if(t instanceof Re)return null;if(t!=null)throw t;return e.range}async clearActive(e){await C(this.client,ew,{range:e},Gv,Hv)}}const sw="sy_range_alias_set",nw="sy_range_alias_delete",rw=c.z.object({range:xe,aliases:c.z.string().array()}),aw=c.z.object({aliases:c.z.record(c.z.string(),bs)}),iw=c.z.object({range:xe,aliases:c.z.record(bs.or(c.z.string()),c.z.string())}),ow=c.z.unknown(),cw=c.z.object({range:xe,channels:bs.array()}),uw=c.z.unknown(),lw=c.z.object({range:xe}),dw=c.z.object({aliases:c.z.record(c.z.string(),c.z.string())}),et=class et{constructor(e,t,n){d(this,"frameClient");d(this,"cache",new Map);d(this,"client");d(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",r={};if(n){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?r[i]=o:t.push(i)});if(t.length===0)return r;const a=await C(this.client,et.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},rw,aw);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),n?a.aliases[t[0]]:{...r,...a.aliases}}async set(e){await C(this.client,et.SET_ENDPOINT,{range:this.rangeKey,aliases:e},iw,ow)}async list(){return(await C(this.client,et.LIST_ENDPOINT,{range:this.rangeKey},lw,dw)).aliases}async delete(e){await C(this.client,et.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},cw,uw)}async openChangeTracker(){return await Dn(this.frameClient,sw,nw,fw(this.rangeKey))}};d(et,"SET_ENDPOINT","/range/alias/set"),d(et,"RESOLVE_ENDPOINT","/range/alias/resolve"),d(et,"LIST_ENDPOINT","/range/alias/list"),d(et,"DELETE_ENDPOINT","/range/alias/delete");let ji=et;const hw=c.z.object({range:xe,channel:bs,alias:c.z.string()}),pw="---",fw=s=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(pw)[0]===s).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(hw).map(n=>({variant:e,key:n.alias,value:n})),mw=c.z.object({range:xe,keys:c.z.string().array()}),yw=c.z.object({pairs:c.z.record(c.z.string(),c.z.string())}),gw=c.z.object({range:xe,pairs:c.z.record(c.z.string(),c.z.string())}),vw=c.z.object({range:xe,keys:c.z.string().array()}),It=class It{constructor(e,t){d(this,"rangeKey");d(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(It.GET_ENDPOINT,{range:this.rangeKey,keys:H(e)},mw,yw);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async list(){return this.get([])}async set(e,t=""){await C(this.client,It.SET_ENDPOINT,{range:this.rangeKey,pairs:ul(e)?e:{[e]:t}},gw,c.z.unknown())}async delete(e){await C(this.client,It.DELETE_ENDPOINT,{range:this.rangeKey,keys:H(e)},vw,c.z.unknown())}};d(It,"GET_ENDPOINT","/range/kv/get"),d(It,"SET_ENDPOINT","/range/kv/set"),d(It,"DELETE_ENDPOINT","/range/kv/delete");let zi=It;const Ga=s=>new Ae({type:"range",key:s});class Fl{constructor(e,t=Ee.ZERO,n,r,a,i,o,u,l){d(this,"key");d(this,"name");d(this,"kv");d(this,"timeRange");d(this,"color");d(this,"channels");d(this,"aliaser");d(this,"frameClient");d(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=a,this.color=r,this.kv=i,this.aliaser=o,this.channels=u,this.labelClient=l}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new Re(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ga(this.key))}async addLabel(...e){await this.labelClient.label(Ga(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ga(this.key),e)}}const ww=c.z.object({keys:xe.array().optional(),names:c.z.array(c.z.string()).optional(),term:c.z.string().optional(),overlapsWith:Ee.z.optional()}),bw="/range/retrieve",_w=c.z.object({ranges:Mn(xs)});let Yl=class{constructor(e,t,n,r,a){d(this,"type","range");d(this,"frameClient");d(this,"writer");d(this,"unaryClient");d(this,"channels");d(this,"active");d(this,"labelClient");this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=r,this.active=new tw(n),this.labelClient=a}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(H(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(H(e))}async search(e){return this.sugar(await this.execRetrieve({term:e}))}async page(e,t){return[]}async retrieve(e){if(typeof e=="object"&&"start"in e)return await this.execRetrieve({overlapsWith:new Ee(e)});const{single:t,actual:n,variant:r,normalized:a}=Wl(e),i=await this.execRetrieve({[r]:a});if(!t)return i;if(i.length===0)throw new En(`range matching ${n} not found`);if(i.length>1)throw new Nn(`multiple ranges matching ${n} found`);return i[0]}async execRetrieve(e){return this.sugar(await C(this.unaryClient,bw,e,ww,_w).then(t=>t.ranges))}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new Fl(t.name,t.timeRange,t.key,t.color,this.frameClient,new zi(t.key,this.unaryClient),new ji(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await Dn(this.frameClient,"sy_range_set","sy_range_delete",(e,t)=>e==="delete"?t.toStrings().map(r=>({variant:e,key:r,value:void 0})):this.sugar(t.parseJSON(xs)).map(r=>({variant:e,key:r.key,value:r})))}};const kw=c.z.object({ranges:xs.array()}),Ow=c.z.object({ranges:Kl.array()}),Tw=c.z.object({keys:xe.array()}),xw=c.z.object({}),Sw=c.z.object({key:xe,name:c.z.string()}),Ew=c.z.object({}),Nw="/range/create",Iw="/range/delete",Zw="/range/rename";let Jl=class{constructor(e){d(this,"client");this.client=e}async rename(e,t){await C(this.client,Zw,{key:e,name:t},Sw,Ew)}async create(e){return(await C(this.client,Nw,{ranges:e},Ow,kw)).ranges}async delete(e){await C(this.client,Iw,{keys:e},Tw,xw)}};const Aw=Object.freeze(Object.defineProperty({__proto__:null,Client:Yl,Range:Fl,Writer:Jl,analyzeParams:Wl,keyZ:xe,newPayloadZ:Kl,payloadZ:xs},Symbol.toStringTag,{value:"Module"})),Cw="/api/v1/";class $w{constructor(e,t=!1){d(this,"url");d(this,"unary");d(this,"stream");d(this,"secure");this.secure=t,this.url=e.child(Cw);const n=new Dt.JSONEncoderDecoder;this.unary=new bf(this.url,n,this.secure),this.stream=new If(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Lt=c.z.string().uuid(),bo=c.z.object({name:c.z.string(),key:Lt,layout:uo.or(c.z.string().transform(s=>Dt.JSON_ECD.decodeString(s)))}),_o=bo.omit({layout:!0}).extend({layout:c.z.string().transform(s=>Dt.JSON_ECD.decodeString(s))}),ko=c.z.string().uuid(),Oo=c.z.object({key:c.z.string(),name:c.z.string(),data:uo.or(c.z.string().transform(s=>JSON.parse(s)))}),jw=c.z.object({keys:c.z.string().array()}),zw=c.z.object({linePlots:Oo.array()});let Rw=class{constructor(e){d(this,"ENDPOINT","/workspace/lineplot/retrieve");d(this,"client");this.client=e}async retrieve(e){const t=H(e);return(await C(this.client,this.ENDPOINT,{keys:t},jw,zw)).linePlots}};const Pw=Oo.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Mw=c.z.object({workspace:Lt,linePlots:Pw.array()}),Dw=c.z.object({linePlots:Oo.array()}),Lw=c.z.object({keys:ko.array()}),Uw=c.z.object({}),Bw=c.z.object({key:ko,name:c.z.string()}),qw=c.z.object({}),Vw=c.z.object({key:ko,data:c.z.string()}),Kw=c.z.object({}),Ww="/workspace/lineplot/create",Fw="/workspace/lineplot/delete",Yw="/workspace/lineplot/rename",Jw="/workspace/lineplot/set-data";let Gw=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await C(this.client,Ww,{workspace:e,linePlots:[n]},Mw,Dw)).linePlots[0]}async delete(e){const t=H(e);await C(this.client,Fw,{keys:t},Lw,Uw)}async rename(e,t){await C(this.client,Yw,{key:e,name:t},Bw,qw)}async setData(e,t){await C(this.client,Jw,{key:e,data:JSON.stringify(t)},Vw,Kw)}},Hw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new Gw(e),this.retriever=new Rw(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Na=c.z.string().uuid(),Xw=c.z.object({key:c.z.string(),name:c.z.string(),data:uo.or(c.z.string().transform(s=>JSON.parse(s))),snapshot:c.z.boolean()}),To=c.z.object({key:c.z.string(),name:c.z.string(),snapshot:c.z.boolean(),data:c.z.string().transform(s=>JSON.parse(s))}),Qw=c.z.object({keys:c.z.string().array()}),eb=c.z.object({schematics:To.array()});let tb=class{constructor(e){d(this,"ENDPOINT","/workspace/schematic/retrieve");d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,this.ENDPOINT,{keys:H(e)},Qw,eb)).schematics}};const sb=Xw.partial({key:!0,snapshot:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),nb=c.z.object({workspace:Lt,schematics:sb.array()}),rb=c.z.object({schematics:To.array()}),ab=c.z.object({keys:Na.array()}),ib=c.z.object({}),ob=c.z.object({key:Na,name:c.z.string()}),rc=c.z.object({}),cb=c.z.object({key:Na,data:c.z.string()});c.z.object({});const ub=c.z.object({key:Na,name:c.z.string(),snapshot:c.z.boolean()}),lb=c.z.object({schematic:To}),db="/workspace/schematic/create",hb="/workspace/schematic/delete",pb="/workspace/schematic/rename",fb="/workspace/schematic/set-data",mb="/workspace/schematic/copy";let yb=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await C(this.client,db,{workspace:e,schematics:[n]},nb,rb)).schematics[0]}async copy(e,t,n){return(await C(this.client,mb,{key:e,name:t,snapshot:n},ub,lb)).schematic}async delete(e){const t=H(e);await C(this.client,hb,{keys:t},ab,ib)}async rename(e,t){await C(this.client,pb,{key:e,name:t},ob,rc)}async setData(e,t){await C(this.client,fb,{key:e,data:JSON.stringify(t)},cb,rc)}},gb=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new yb(e),this.retriever=new tb(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const vb=c.z.object({keys:Lt.array().optional(),search:c.z.string().optional(),author:c.z.string().uuid().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),wb=c.z.object({workspaces:_o.array()}),ta=class ta{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=H(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await C(this.client,ta.ENDPOINT,e,vb,wb)).workspaces}};d(ta,"ENDPOINT","/workspace/retrieve");let Ri=ta;const bb=bo.partial({key:!0}).transform(s=>({...s,layout:JSON.stringify(s.layout)})),_b=c.z.object({workspaces:bb.array()}),kb=c.z.object({workspaces:_o.array()}),Ob=c.z.object({keys:Lt.array()}),Tb=c.z.object({}),xb=c.z.object({key:Lt,name:c.z.string()}),Sb=c.z.object({}),Eb=c.z.object({key:Lt,layout:c.z.string()}),Nb=c.z.object({}),Ib="/workspace/create",Zb="/workspace/delete",Ab="/workspace/rename",Cb="/workspace/set-layout";class $b{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Ib,{workspaces:H(e)},_b,kb)).workspaces}async delete(e){await C(this.client,Zb,{keys:H(e)},Ob,Tb)}async rename(e,t){await C(this.client,Ab,{key:e,name:t},xb,Sb)}async setLayout(e,t){await C(this.client,Cb,{key:e,layout:JSON.stringify(t)},Eb,Nb)}}class Gl{constructor(e){d(this,"type","workspace");d(this,"schematic");d(this,"linePlot");d(this,"retriever");d(this,"writer");this.schematic=new gb(e),this.linePlot=new Hw(e),this.retriever=new Ri(e),this.writer=new $b(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const jb=Object.freeze(Object.defineProperty({__proto__:null,Client:Gl,keyZ:Lt,workspaceRemoteZ:_o,workspaceZ:bo},Symbol.toStringTag,{value:"Module"})),Hl=c.z.object({host:c.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:c.z.number({required_error:"Port is required"}).or(c.z.string({required_error:"Port is required"})),username:c.z.string().optional(),password:c.z.string().optional(),connectivityPollFrequency:X.z.default(X.seconds(30)),secure:c.z.boolean().optional().default(!1),name:c.z.string().optional()});class Xl extends Ol{constructor(t){const n=Hl.parse(t),{host:r,port:a,username:i,password:o,connectivityPollFrequency:u,secure:l}=n,h=new $w(new rg({host:r,port:Number(a)}),l);h.use(Hy);let g;if(i!=null&&o!=null){const ed=new bg(h.unary,{username:i,password:o});h.use(ed.middleware())}const se=new lo(new In(h.unary)),ye=new ol(h.unary);super(h.stream,se);d(this,"createdAt");d(this,"props");d(this,"ranges");d(this,"channels");d(this,"auth");d(this,"connectivity");d(this,"ontology");d(this,"workspaces");d(this,"labels");d(this,"hardware");d(this,"transport");this.createdAt=J.now(),this.props=n,this.auth=g,this.transport=h,this.channels=new ml(this,se,h.unary,ye),this.connectivity=new Zn(h.unary,u,n.name),this.ontology=new Dl(h.unary,this);const ze=new Jl(this.transport.unary);this.labels=new Vl(this.transport.unary,this),this.ranges=new Yl(this,ze,this.transport.unary,se,this.labels),this.workspaces=new Gl(this.transport.unary);const he=new Il(this.transport.unary,this),xo=new Cl(this.transport.unary,this),Ql=new Sl(this.transport.unary,this,xo);this.hardware=new Tl(xo,Ql,he)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}d(Xl,"connectivity",Zn);const zb=Object.freeze(Object.defineProperty({__proto__:null,Authority:es,StateTracker:vo,filterTransfersByChannelKey:Ag,stateZ:Zg,subjectZ:go,transferString:Cg},Symbol.toStringTag,{value:"Module"}));exports.AuthError=ws;exports.Authority=es;exports.Channel=ho;exports.ContiguityError=Yy;exports.DataType=G;exports.Density=Oe;exports.Frame=me;exports.MultiSeries=rl;exports.QueryError=Re;exports.Rate=va;exports.RouteError=Gr;exports.Series=Te;exports.Synnax=Xl;exports.TimeRange=Ee;exports.TimeSpan=X;exports.TimeStamp=J;exports.UnexpectedError=Kt;exports.ValidationError=de;exports.channel=mg;exports.connection=Og;exports.control=zb;exports.device=tv;exports.framer=Pg;exports.hardware=Mg;exports.label=Wv;exports.ontology=Av;exports.rack=sv;exports.ranger=Aw;exports.signals=Kg;exports.synnaxPropsZ=Hl;exports.task=fv;exports.workspace=jb;
|
|
37
34
|
//# sourceMappingURL=client.cjs.map
|