@synnaxlabs/drift 0.38.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/electron.cjs +1 -1
- package/dist/electron.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +11 -11
- package/dist/react.cjs +1 -1
- package/dist/react.js +2 -2
- package/dist/{selectors-CYHEOjO4.cjs → selectors-BOlMfPQR.cjs} +1 -1
- package/dist/{selectors-DwAh3Dt_.js → selectors-ChR2waHK.js} +1 -1
- package/dist/src/configureStore.d.ts.map +1 -1
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/electron/index.d.ts.map +1 -1
- package/dist/src/middleware.d.ts.map +1 -1
- package/dist/src/react/Provider.d.ts.map +1 -1
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/src/react/selectors.d.ts.map +1 -1
- package/dist/src/selectors.d.ts.map +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/state.d.ts.map +1 -1
- package/dist/src/sugar.d.ts.map +1 -1
- package/dist/src/sync.d.ts.map +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/state-5JemPjJN.cjs +13 -0
- package/dist/{state-B8DVhsB5.js → state-B4NiJdX7.js} +1248 -1209
- package/dist/tauri.cjs +1 -1
- package/dist/tauri.js +103 -100
- package/package.json +13 -12
- package/dist/state-Nl_4DIvw.cjs +0 -13
package/dist/state-Nl_4DIvw.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";const kr=require("@reduxjs/toolkit"),je=(n=!1,...e)=>{n&&console.log(...e)},Rn=(n=!1,...e)=>{n&&console.group(...e)},Dt=n=>{n&&console.groupEnd()},Ar=n=>{const e=n.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Mn=n=>{const e=(t,r=Ut)=>{if(typeof t=="string")return n(t);if(Array.isArray(t))return t.map(a=>e(a,r));if(!jt(t))return t;r=Cr(r);const s={},i=t;return Object.keys(i).forEach(a=>{let o=i[a];const c=n(a);r.recursive&&(jt(o)?yn(o,r.keepTypesOnRecursion)||(o=e(o,r)):r.recursiveInArray&&mn(o)&&(o=[...o].map(l=>{let m=l;return jt(l)?yn(m,r.keepTypesOnRecursion)||(m=e(l,r)):mn(l)&&(m=e({key:l},r).key),m}))),s[c]=o}),s};return e},jn=Mn(Ar),Er=n=>n.replace(/([a-z0-9])([A-Z])/g,(e,t,r)=>`${t}_${r.toLowerCase()}`),$r=Mn(Er),Ut={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Cr=(n=Ut)=>(n.recursive==null?n=Ut:n.recursiveInArray??(n.recursiveInArray=!1),n),mn=n=>n!=null&&Array.isArray(n),jt=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),yn=(n,e)=>(e||[]).some(t=>n instanceof t),Ye=n=>n!=null&&typeof n=="object"&&!Array.isArray(n);var Rr=Object.defineProperty,Mr=(n,e,t)=>e in n?Rr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ge=(n,e,t)=>Mr(n,typeof e!="symbol"?e+"":e,t);let jr=class{constructor(){Ge(this,"contentType","application/json"),Ge(this,"decoder"),Ge(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 r=JSON.parse(e),s=jn(r);return t!=null?t.parse(s):s}encodeString(e){const t=$r(e);return JSON.stringify(t,(r,s)=>ArrayBuffer.isView(s)?Array.from(s):Ye(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Zr=class{constructor(){Ge(this,"contentType","text/csv")}encode(e){const t=this.encodeString(e);return new TextEncoder().encode(t).buffer}decode(e,t){const r=new TextDecoder().decode(e);return this.decodeString(r,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Ye(e[0]))throw new Error("Payload must be an array of objects");const t=Object.keys(e[0]),r=[t.join(",")];return e.forEach(s=>{const i=t.map(a=>JSON.stringify(s[a]??""));r.push(i.join(","))}),r.join(`
|
|
2
|
-
`)}decodeString(e,t){const[r,...s]=e.trim().split(`
|
|
3
|
-
`).map(o=>o.trim());if(r.length===0)return t!=null?t.parse({}):{};const i=r.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),s.forEach(o=>{const c=o.split(",").map(l=>l.trim());i.forEach((l,m)=>{const g=this.parseValue(c[m]);g!=null&&a[l].push(g)})}),t!=null?t.parse(a):a}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},Br=class{constructor(){Ge(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const r=new TextDecoder().decode(e);return t!=null?t.parse(r):r}};const ht=new jr;new Zr;new Br;var S;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const i={};for(const a of s)i[a]=a;return i},n.getValidEnumValues=s=>{const i=n.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(const o of i)a[o]=s[o];return n.objectValues(a)},n.objectValues=s=>n.objectKeys(s).map(function(i){return s[i]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},n.find=(s,i)=>{for(const a of s)if(i(a))return a},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}n.joinValues=r,n.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var Pt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Pt||(Pt={}));const y=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),re=n=>{switch(typeof n){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(n)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(n)?y.array:n===null?y.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?y.promise:typeof Map<"u"&&n instanceof Map?y.map:typeof Set<"u"&&n instanceof Set?y.set:typeof Date<"u"&&n instanceof Date?y.date:y.object;default:return y.unknown}},h=S.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"]),Dr=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class L extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(t(a));else{let o=r,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof L))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}L.create=n=>new L(n);const $e=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===y.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,S.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${S.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${S.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${S.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:S.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,S.assertNever(n)}return{message:t}};let Zn=$e;function Ur(n){Zn=n}function bt(){return Zn}const xt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,i=[...t,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Pr=[];function p(n,e){const t=bt(),r=xt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===$e?void 0:$e].filter(s=>!!s)});n.common.issues.push(r)}class D{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const i=await s.key,a=await s.value;r.push({key:i,value:a})}return D.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return x;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}}const x=Object.freeze({status:"aborted"}),Ae=n=>({status:"dirty",value:n}),W=n=>({status:"valid",value:n}),Wt=n=>n.status==="aborted",Lt=n=>n.status==="dirty",_e=n=>n.status==="valid",Je=n=>typeof Promise<"u"&&n instanceof Promise;function _t(n,e,t,r){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Bn(n,e,t,r,s){if(typeof e=="function"?n!==e||!0:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Ze,Be;class K{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const gn=(n,e)=>{if(_e(e))return{success:!0,data:e.value};if(!n.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 L(n.common.issues);return this._error=t,this._error}}};function _(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,l;const{message:m}=n;return a.code==="invalid_enum_value"?{message:m??o.defaultError}:typeof o.data>"u"?{message:(c=m??r)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(l=m??t)!==null&&l!==void 0?l:o.defaultError}},description:s}}class O{get description(){return this._def.description}_getType(e){return re(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:re(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Je(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 r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)},i=this._parseSync({data:e,path:s.path,parent:s});return gn(s,i)}"~validate"(e){var t,r;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:re(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:s});return _e(i)?{value:i.value}:{issues:s.common.issues}}catch(i){!((r=(t=i==null?void 0:i.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(i=>_e(i)?{value:i.value}:{issues:s.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={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:re(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Je(s)?s:Promise.resolve(s));return gn(r,i)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const a=e(s),o=()=>i.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Y({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return X.create(this,this._def)}nullable(){return he.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return F.create(this)}promise(){return Re.create(this,this._def)}or(e){return Qe.create([this,e],this._def)}and(e){return et.create(this,e,this._def)}transform(e){return new Y({..._(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new it({..._(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new en({typeName:b.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new at({..._(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return lt.create(this,e)}readonly(){return ot.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wr=/^c[^\s-]{8,}$/i,Lr=/^[0-9a-z]+$/,zr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vr=/^[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,qr=/^[a-z0-9_-]{21}$/i,Fr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Jr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Zt;const Hr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Kr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,es=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ts=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Dn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ns=new RegExp(`^${Dn}$`);function Un(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function rs(n){return new RegExp(`^${Un(n)}$`)}function Pn(n){let e=`${Dn}T${Un(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ss(n,e){return!!((e==="v4"||!e)&&Hr.test(n)||(e==="v6"||!e)&&Kr.test(n))}function is(n,e){if(!Fr.test(n))return!1;try{const[t]=n.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function as(n,e){return!!((e==="v4"||!e)&&Xr.test(n)||(e==="v6"||!e)&&Qr.test(n))}class q extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.string,received:i.parsedType}),x}const r=new D;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?p(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&p(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Gr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Zt||(Zt=new RegExp(Jr,"u")),Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Vr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")qr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")Wr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")zr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:h.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:h.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Pn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ns.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?rs(i).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:h.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Yr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ss(e.data,i.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?is(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"jwt",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?as(e.data,i.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cidr",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?es.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ts.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64url",code:h.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...w.errToObj(r)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!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,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...w.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}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}}q.create=n=>{var e;return new q({checks:[],typeName:b.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};function os(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,i=parseInt(n.toFixed(s).replace(".","")),a=parseInt(e.toFixed(s).replace(".",""));return i%a/Math.pow(10,s)}class le extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.number,received:i.parsedType}),x}let r;const s=new D;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?os(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:b.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class de extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r;const s=new D;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),p(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.bigint,received:t.parsedType}),x}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,s){return new de({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(s)}]})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}de.create=n=>{var e;return new de({checks:[],typeName:b.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,..._(n)})};class He extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.boolean,received:r.parsedType}),x}return W(e.data)}}He.create=n=>new He({typeName:b.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,..._(n)});class Te extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_type,expected:y.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return p(i,{code:h.invalid_date}),x}const r=new D;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Te({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Te.create=n=>new Te({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:b.ZodDate,..._(n)});class Tt extends O{_parse(e){if(this._getType(e)!==y.symbol){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.symbol,received:r.parsedType}),x}return W(e.data)}}Tt.create=n=>new Tt({typeName:b.ZodSymbol,..._(n)});class Xe extends O{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.undefined,received:r.parsedType}),x}return W(e.data)}}Xe.create=n=>new Xe({typeName:b.ZodUndefined,..._(n)});class Ke extends O{_parse(e){if(this._getType(e)!==y.null){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.null,received:r.parsedType}),x}return W(e.data)}}Ke.create=n=>new Ke({typeName:b.ZodNull,..._(n)});class Ce extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return W(e.data)}}Ce.create=n=>new Ce({typeName:b.ZodAny,..._(n)});class we extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return W(e.data)}}we.create=n=>new we({typeName:b.ZodUnknown,..._(n)});class ie extends O{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:h.invalid_type,expected:y.never,received:t.parsedType}),x}}ie.create=n=>new ie({typeName:b.ZodNever,..._(n)});class Ot extends O{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.void,received:r.parsedType}),x}return W(e.data)}}Ot.create=n=>new Ot({typeName:b.ZodVoid,..._(n)});class F extends O{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==y.array)return p(t,{code:h.invalid_type,expected:y.array,received:t.parsedType}),x;if(s.exactLength!==null){const a=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(a||o)&&(p(t,{code:a?h.too_big:h.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>s.type._parseAsync(new K(t,a,t.path,o)))).then(a=>D.mergeArray(r,a));const i=[...t.data].map((a,o)=>s.type._parseSync(new K(t,a,t.path,o)));return D.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new F({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new F({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new F({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}F.create=(n,e)=>new F({type:n,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,..._(e)});function ke(n){if(n instanceof R){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=X.create(ke(r))}return new R({...n._def,shape:()=>e})}else return n instanceof F?new F({...n._def,type:ke(n.element)}):n instanceof X?X.create(ke(n.unwrap())):n instanceof he?he.create(ke(n.unwrap())):n instanceof Q?Q.create(n.items.map(e=>ke(e))):n}class R extends O{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=S.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return p(l,{code:h.invalid_type,expected:y.object,received:l.parsedType}),x}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const l in s.data)a.includes(l)||o.push(l);const c=[];for(const l of a){const m=i[l],g=s.data[l];c.push({key:{status:"valid",value:l},value:m._parse(new K(s,g,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof ie){const l=this._def.unknownKeys;if(l==="passthrough")for(const m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(l==="strict")o.length>0&&(p(s,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const m of o){const g=s.data[m];c.push({key:{status:"valid",value:m},value:l._parse(new K(s,g,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const l=[];for(const m of c){const g=await m.key,U=await m.value;l.push({key:g,value:U,alwaysSet:m.alwaysSet})}return l}).then(l=>D.mergeObjectSync(r,l)):D.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new R({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,i,a,o;const c=(a=(i=(s=this._def).errorMap)===null||i===void 0?void 0:i.call(s,t,r).message)!==null&&a!==void 0?a:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=w.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new R({...this._def,catchall:e})}pick(e){const t={};return S.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}omit(e){const t={};return S.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new R({...this._def,shape:()=>t})}deepPartial(){return ke(this)}partial(e){const t={};return S.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new R({...this._def,shape:()=>t})}required(e){const t={};return S.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof X;)i=i._def.innerType;t[r]=i}}),new R({...this._def,shape:()=>t})}keyof(){return Wn(S.objectKeys(this.shape))}}R.create=(n,e)=>new R({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,..._(e)});R.strictCreate=(n,e)=>new R({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:b.ZodObject,..._(e)});R.lazycreate=(n,e)=>new R({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,..._(e)});class Qe extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(o=>new L(o.ctx.common.issues));return p(t,{code:h.invalid_union,unionErrors:a}),x}if(t.common.async)return Promise.all(r.map(async i=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(s);{let i;const a=[];for(const c of r){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(c=>new L(c));return p(t,{code:h.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}}Qe.create=(n,e)=>new Qe({options:n,typeName:b.ZodUnion,..._(e)});const te=n=>n instanceof nt?te(n.schema):n instanceof Y?te(n.innerType()):n instanceof rt?[n.value]:n instanceof fe?n.options:n instanceof st?S.objectValues(n.enum):n instanceof it?te(n._def.innerType):n instanceof Xe?[void 0]:n instanceof Ke?[null]:n instanceof X?[void 0,...te(n.unwrap())]:n instanceof he?[null,...te(n.unwrap())]:n instanceof en||n instanceof ot?te(n.unwrap()):n instanceof at?te(n._def.innerType):[];class At extends O{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return p(t,{code:h.invalid_type,expected:y.object,received:t.parsedType}),x;const r=this.discriminator,s=t.data[r],i=this.optionsMap.get(s);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const i of t){const a=te(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new At({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._(r)})}}function zt(n,e){const t=re(n),r=re(e);if(n===e)return{valid:!0,data:n};if(t===y.object&&r===y.object){const s=S.objectKeys(e),i=S.objectKeys(n).filter(o=>s.indexOf(o)!==-1),a={...n,...e};for(const o of i){const c=zt(n[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(t===y.array&&r===y.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<n.length;i++){const a=n[i],o=e[i],c=zt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===y.date&&r===y.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class et extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Wt(i)||Wt(a))return x;const o=zt(i.value,a.value);return o.valid?((Lt(i)||Lt(a))&&t.dirty(),{status:t.value,value:o.data}):(p(r,{code:h.invalid_intersection_types}),x)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}et.create=(n,e,t)=>new et({left:n,right:e,typeName:b.ZodIntersection,..._(t)});class Q extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return p(r,{code:h.invalid_type,expected:y.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return p(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(p(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new K(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>D.mergeArray(t,a)):D.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Q({...this._def,rest:e})}}Q.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:n,typeName:b.ZodTuple,rest:null,..._(e)})};class tt extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return p(r,{code:h.invalid_type,expected:y.object,received:r.parsedType}),x;const s=[],i=this._def.keyType,a=this._def.valueType;for(const o in r.data)s.push({key:i._parse(new K(r,o,r.path,o)),value:a._parse(new K(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?D.mergeObjectAsync(t,s):D.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof O?new tt({keyType:e,valueType:t,typeName:b.ZodRecord,..._(r)}):new tt({keyType:q.create(),valueType:e,typeName:b.ZodRecord,..._(t)})}}class St extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return p(r,{code:h.invalid_type,expected:y.map,received:r.parsedType}),x;const s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([o,c],l)=>({key:s._parse(new K(r,o,r.path,[l,"key"])),value:i._parse(new K(r,c,r.path,[l,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of a){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return x;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of a){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return x;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}St.create=(n,e,t)=>new St({valueType:e,keyType:n,typeName:b.ZodMap,..._(t)});class Oe extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return p(r,{code:h.invalid_type,expected:y.set,received:r.parsedType}),x;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(p(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(p(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function a(c){const l=new Set;for(const m of c){if(m.status==="aborted")return x;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...r.data.values()].map((c,l)=>i._parse(new K(r,c,r.path,l)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,t){return new Oe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Oe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Oe.create=(n,e)=>new Oe({valueType:n,minSize:null,maxSize:null,typeName:b.ZodSet,..._(e)});class Ee extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return p(t,{code:h.invalid_type,expected:y.function,received:t.parsedType}),x;function r(o,c){return xt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bt(),$e].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function s(o,c){return xt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,bt(),$e].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Re){const o=this;return W(async function(...c){const l=new L([]),m=await o._def.args.parseAsync(c,i).catch(V=>{throw l.addIssue(r(c,V)),l}),g=await Reflect.apply(a,this,m);return await o._def.returns._def.type.parseAsync(g,i).catch(V=>{throw l.addIssue(s(g,V)),l})})}else{const o=this;return W(function(...c){const l=o._def.args.safeParse(c,i);if(!l.success)throw new L([r(c,l.error)]);const m=Reflect.apply(a,this,l.data),g=o._def.returns.safeParse(m,i);if(!g.success)throw new L([s(m,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ee({...this._def,args:Q.create(e).rest(we.create())})}returns(e){return new Ee({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Ee({args:e||Q.create([]).rest(we.create()),returns:t||we.create(),typeName:b.ZodFunction,..._(r)})}}class nt extends O{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})}}nt.create=(n,e)=>new nt({getter:n,typeName:b.ZodLazy,..._(e)});class rt extends O{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}rt.create=(n,e)=>new rt({value:n,typeName:b.ZodLiteral,..._(e)});function Wn(n,e){return new fe({values:n,typeName:b.ZodEnum,..._(e)})}class fe extends O{constructor(){super(...arguments),Ze.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return p(t,{expected:S.joinValues(r),received:t.parsedType,code:h.invalid_type}),x}if(_t(this,Ze)||Bn(this,Ze,new Set(this._def.values)),!_t(this,Ze).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return p(t,{received:t.data,code:h.invalid_enum_value,options:r}),x}return W(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,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ze=new WeakMap;fe.create=Wn;class st extends O{constructor(){super(...arguments),Be.set(this,void 0)}_parse(e){const t=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const s=S.objectValues(t);return p(r,{expected:S.joinValues(s),received:r.parsedType,code:h.invalid_type}),x}if(_t(this,Be)||Bn(this,Be,new Set(S.getValidEnumValues(this._def.values))),!_t(this,Be).has(e.data)){const s=S.objectValues(t);return p(r,{received:r.data,code:h.invalid_enum_value,options:s}),x}return W(e.data)}get enum(){return this._def.values}}Be=new WeakMap;st.create=(n,e)=>new st({values:n,typeName:b.ZodNativeEnum,..._(e)});class Re extends O{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&t.common.async===!1)return p(t,{code:h.invalid_type,expected:y.promise,received:t.parsedType}),x;const r=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return W(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Re.create=(n,e)=>new Re({type:n,typeName:b.ZodPromise,..._(e)});class Y extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{p(r,a),a.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async o=>{if(t.value==="aborted")return x;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Ae(c.value):c});{if(t.value==="aborted")return x;const o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||t.value==="dirty"?Ae(o.value):o}}if(s.type==="refinement"){const a=o=>{const c=s.refinement(o,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_e(a))return a;const o=s.transform(a.value,i);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:r.data,path:r.path,parent:r}).then(a=>_e(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:t.value,value:o})):a);S.assertNever(s)}}Y.create=(n,e,t)=>new Y({schema:n,typeName:b.ZodEffects,effect:e,..._(t)});Y.createWithPreprocess=(n,e,t)=>new Y({schema:e,effect:{type:"preprocess",transform:n},typeName:b.ZodEffects,..._(t)});class X extends O{_parse(e){return this._getType(e)===y.undefined?W(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(n,e)=>new X({innerType:n,typeName:b.ZodOptional,..._(e)});class he extends O{_parse(e){return this._getType(e)===y.null?W(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:b.ZodNullable,..._(e)});class it extends O{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}it.create=(n,e)=>new it({innerType:n,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class at extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Je(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new L(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new L(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}at.create=(n,e)=>new at({innerType:n,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class Nt extends O{_parse(e){if(this._getType(e)!==y.nan){const r=this._getOrReturnCtx(e);return p(r,{code:h.invalid_type,expected:y.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}}Nt.create=n=>new Nt({typeName:b.ZodNaN,..._(n)});const us=Symbol("zod_brand");class en extends O{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class lt extends O{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?x:i.status==="dirty"?(t.dirty(),Ae(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new lt({in:e,out:t,typeName:b.ZodPipeline})}}class ot extends O{_parse(e){const t=this._def.innerType._parse(e),r=s=>(_e(s)&&(s.value=Object.freeze(s.value)),s);return Je(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ot.create=(n,e)=>new ot({innerType:n,typeName:b.ZodReadonly,..._(e)});function Ln(n,e={},t){return n?Ce.create().superRefine((r,s)=>{var i,a;if(!n(r)){const o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(i=o.fatal)!==null&&i!==void 0?i:t)!==null&&a!==void 0?a:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Ce.create()}const cs={object:R.lazycreate};var b;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(b||(b={}));const ls=(n,e={message:`Input not instance of ${n.name}`})=>Ln(t=>t instanceof n,e),zn=q.create,Vn=le.create,ds=Nt.create,fs=de.create,qn=He.create,hs=Te.create,ps=Tt.create,ms=Xe.create,ys=Ke.create,gs=Ce.create,ws=we.create,vs=ie.create,bs=Ot.create,xs=F.create,_s=R.create,Ts=R.strictCreate,Os=Qe.create,Ss=At.create,Ns=et.create,Is=Q.create,ks=tt.create,As=St.create,Es=Oe.create,$s=Ee.create,Cs=nt.create,Rs=rt.create,Ms=fe.create,js=st.create,Zs=Re.create,wn=Y.create,Bs=X.create,Ds=he.create,Us=Y.createWithPreprocess,Ps=lt.create,Ws=()=>zn().optional(),Ls=()=>Vn().optional(),zs=()=>qn().optional(),Vs={string:n=>q.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>He.create({...n,coerce:!0}),bigint:n=>de.create({...n,coerce:!0}),date:n=>Te.create({...n,coerce:!0})},qs=x;var u=Object.freeze({__proto__:null,defaultErrorMap:$e,setErrorMap:Ur,getErrorMap:bt,makeIssue:xt,EMPTY_PATH:Pr,addIssueToContext:p,ParseStatus:D,INVALID:x,DIRTY:Ae,OK:W,isAborted:Wt,isDirty:Lt,isValid:_e,isAsync:Je,get util(){return S},get objectUtil(){return Pt},ZodParsedType:y,getParsedType:re,ZodType:O,datetimeRegex:Pn,ZodString:q,ZodNumber:le,ZodBigInt:de,ZodBoolean:He,ZodDate:Te,ZodSymbol:Tt,ZodUndefined:Xe,ZodNull:Ke,ZodAny:Ce,ZodUnknown:we,ZodNever:ie,ZodVoid:Ot,ZodArray:F,ZodObject:R,ZodUnion:Qe,ZodDiscriminatedUnion:At,ZodIntersection:et,ZodTuple:Q,ZodRecord:tt,ZodMap:St,ZodSet:Oe,ZodFunction:Ee,ZodLazy:nt,ZodLiteral:rt,ZodEnum:fe,ZodNativeEnum:st,ZodPromise:Re,ZodEffects:Y,ZodTransformer:Y,ZodOptional:X,ZodNullable:he,ZodDefault:it,ZodCatch:at,ZodNaN:Nt,BRAND:us,ZodBranded:en,ZodPipeline:lt,ZodReadonly:ot,custom:Ln,Schema:O,ZodSchema:O,late:cs,get ZodFirstPartyTypeKind(){return b},coerce:Vs,any:gs,array:xs,bigint:fs,boolean:qn,date:hs,discriminatedUnion:Ss,effect:wn,enum:Ms,function:$s,instanceof:ls,intersection:Ns,lazy:Cs,literal:Rs,map:As,nan:ds,nativeEnum:js,never:vs,null:ys,nullable:Ds,number:Vn,object:_s,oboolean:zs,onumber:Ls,optional:Bs,ostring:Ws,pipeline:Ps,preprocess:Us,promise:Zs,record:ks,set:Es,strictObject:Ts,string:zn,symbol:ps,transformer:wn,tuple:Is,undefined:ms,union:Os,unknown:ws,void:bs,NEVER:qs,ZodIssueCode:h,quotelessJson:Dr,ZodError:L});const Fs=n=>n!=null&&typeof n=="object"&&"toString"in n,Ys=(n,e=!1)=>{const t=Fs(n)?"stringer":typeof n;let r;switch(t){case"string":r=(s,i)=>s.localeCompare(i);break;case"stringer":r=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":r=(s,i)=>Number(s)-Number(i);break;case"bigint":r=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":r=(s,i)=>Number(s)-Number(i);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Gs(r):r},Gs=n=>(e,t)=>n(t,e),Et=u.tuple([u.number(),u.number()]);u.tuple([u.bigint(),u.bigint()]);const tn=u.object({width:u.number(),height:u.number()}),Js=u.object({signedWidth:u.number(),signedHeight:u.number()}),Hs=["width","height"];u.enum(Hs);const Xs=["start","center","end"],Ks=["signedWidth","signedHeight"];u.enum(Ks);const ut=u.object({x:u.number(),y:u.number()}),Fn=u.object({clientX:u.number(),clientY:u.number()}),Yn=["x","y"],Gn=u.enum(Yn),Jn=["top","right","bottom","left"];u.enum(Jn);const nn=["left","right"],Hn=u.enum(nn),rn=["top","bottom"],Xn=u.enum(rn),Kn=["center"],vn=u.enum(Kn),Qs=[...Jn,...Kn],Qn=u.enum(Qs);u.enum(Xs);const ei=["first","last"];u.enum(ei);const ti=u.object({lower:u.number(),upper:u.number()}),ni=u.object({lower:u.bigint(),upper:u.bigint()});u.union([ti,Et]);u.union([ni,Et]);u.union([Gn,Qn]);u.union([Gn,Qn,u.instanceof(String)]);const ri=n=>typeof n=="bigint"||n instanceof BigInt,Ne=(n,e)=>ri(n)?n.valueOf()*BigInt(e.valueOf()):n.valueOf()*Number(e.valueOf()),ve=(n,e)=>{const t={};if(typeof n=="number"||typeof n=="bigint")e!=null?(t.lower=n,t.upper=e):(t.lower=typeof n=="bigint"?0n:0,t.upper=n);else if(Array.isArray(n)){if(n.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=n}else return bn(n);return bn(t)},bn=n=>n.lower>n.upper?{lower:n.upper,upper:n.lower}:n,xn=(n,e)=>{const t=ve(n);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e},sn=n=>Yn.includes(n)?n:rn.includes(n)?"y":"x";u.object({x:Hn.or(vn),y:Xn.or(vn)});const si=u.object({x:Hn,y:Xn}),an=Object.freeze({x:"left",y:"top"}),ii=Object.freeze({x:"right",y:"top"}),er=Object.freeze({x:"left",y:"bottom"}),ai=Object.freeze({x:"right",y:"bottom"}),tr=(n,e)=>n.x===e.x&&n.y===e.y,oi=n=>[n.x,n.y],Vt=u.union([u.number(),ut,Et,tn,Js,Fn]),C=(n,e)=>{if(typeof n=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return n==="x"?{x:e,y:0}:{x:0,y:e}}return typeof n=="number"?{x:n,y:e??n}:Array.isArray(n)?{x:n[0],y:n[1]}:"signedWidth"in n?{x:n.signedWidth,y:n.signedHeight}:"clientX"in n?{x:n.clientX,y:n.clientY}:"width"in n?{x:n.width,y:n.height}:{x:n.x,y:n.y}},ee=Object.freeze({x:0,y:0}),nr=Object.freeze({x:1,y:1}),ui=Object.freeze({x:1/0,y:1/0}),ci=Object.freeze({x:NaN,y:NaN}),It=(n,e,t=0)=>{const r=C(n),s=C(e);return t===0?r.x===s.x&&r.y===s.y:Math.abs(r.x-s.x)<=t&&Math.abs(r.y-s.y)<=t},li=n=>It(n,ee),on=(n,e,t)=>{const r=C(n),s=C(e,t);return{x:r.x*s.x,y:r.y*s.y}},rr=(n,e)=>{const t=C(n);return{x:t.x+e,y:t.y}},sr=(n,e)=>{const t=C(n);return{x:t.x,y:t.y+e}},ct=(n,e,t,...r)=>typeof e=="string"&&typeof t=="number"?e==="x"?rr(n,t):sr(n,t):[n,e,t??ee,...r].reduce((s,i)=>{const a=C(i);return{x:s.x+a.x,y:s.y+a.y}},ee),di=(n,e,t)=>{const r=C(n);return e==="x"?{x:t,y:r.y}:{x:r.x,y:t}},fi=(n,e)=>{const t=C(n),r=C(e);return Math.sqrt((t.x-r.x)**2+(t.y-r.y)**2)},hi=(n,e)=>{const t=C(n),r=C(e);return{x:r.x-t.x,y:r.y-t.y}},pi=n=>{const e=C(n);return Number.isNaN(e.x)||Number.isNaN(e.y)},mi=n=>{const e=C(n);return Number.isFinite(e.x)&&Number.isFinite(e.y)},yi=n=>{const e=C(n);return[e.x,e.y]},gi=n=>{const e=C(n);return{left:e.x,top:e.y}},qt=(n,e=0)=>{const t=C(n);return{x:Number(t.x.toFixed(e)),y:Number(t.y.toFixed(e))}},De=(n,e)=>{const t=C(n),r=C(e);return{x:t.x-r.x,y:t.y-r.y}},Ue=n=>{const e=C(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:-e.y/t,y:e.x/t}},ir=n=>{const e=C(n),t=Math.hypot(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},ar=(...n)=>{const e=n.reduce((t,r)=>ct(t,r),ee);return on(e,1/n.length)},wi=(n,e)=>{const t=[];for(let r=0;r<n.length;r++){const s=n[r];let i,a,o,c;if(r===0){const l=n[r+1],m=De(l,s);a=Ue(m),o=a,c=e}else if(r===n.length-1){const l=n[r-1],m=De(s,l);i=Ue(m),o=i,c=e}else{const l=n[r-1],m=n[r+1],g=De(s,l),U=De(m,s);i=Ue(g),a=Ue(U);const V=Math.acos((g.x*U.x+g.y*U.y)/(Math.hypot(g.x,g.y)*Math.hypot(U.x,U.y))),Me=Math.sin(V/2);Me===0?c=e:c=e/Me,o=ir(ar(i,a))}t.push(on(o,c))}return t},kt=Object.freeze(Object.defineProperty({__proto__:null,INFINITY:ui,NAN:ci,ONE:nr,ZERO:ee,average:ar,calculateMiters:wi,clientXY:Fn,construct:C,couple:yi,crudeZ:Vt,css:gi,distance:fi,equals:It,isFinite:mi,isNan:pi,isZero:li,normal:Ue,normalize:ir,scale:on,set:di,sub:De,translate:ct,translateX:rr,translateY:sr,translation:hi,truncate:qt,xy:ut},Symbol.toStringTag,{value:"Module"})),ft=u.union([u.number(),u.string()]),vi=u.object({top:ft,left:ft,width:ft,height:ft}),bi=u.object({left:u.number(),top:u.number(),right:u.number(),bottom:u.number()}),xi=u.object({one:ut,two:ut,root:si}),or={one:ee,two:ee,root:an},_i={one:ee,two:nr,root:er},ur=(n,e)=>({one:n.one,two:n.two,root:e??n.root}),$=(n,e,t=0,r=0,s)=>{const i={one:{...ee},two:{...ee},root:s??an};if(typeof n=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:n,y:e},i.two={x:i.one.x+t,y:i.one.y+r},i}return"one"in n&&"two"in n&&"root"in n?{...n,root:s??n.root}:("getBoundingClientRect"in n&&(n=n.getBoundingClientRect()),"left"in n?(i.one={x:n.left,y:n.top},i.two={x:n.right,y:n.bottom},i):(i.one=n,e==null?i.two={x:i.one.x+t,y:i.one.y+r}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+t}:"width"in e?i.two={x:i.one.x+e.width,y:i.one.y+e.height}:"signedWidth"in e?i.two={x:i.one.x+e.signedWidth,y:i.one.y+e.signedHeight}:i.two=e,i))},Ti=(n,e,t)=>{const r=$(n);if(typeof e=="string"){if(t==null)throw new Error("Invalid arguments for resize");const s=sn(e);return $(r.one,void 0,s==="x"?t:pe(r),s==="y"?t:me(r),r.root)}return $(r.one,e,void 0,void 0,r.root)},Oi=(n,e,t=!0)=>{const r=$(n);let s=(i,a)=>i<a;return t&&(s=(i,a)=>i<=a),"one"in e?s(ue(r),ue(e))&&s(be(e),be(r))&&s(ce(r),ce(e))&&s(xe(e),xe(r)):s(ue(r),e.x)&&s(e.x,be(r))&&s(ce(r),e.y)&&s(e.y,xe(r))},Si=(n,e)=>It(n.one,e.one)&&It(n.two,e.two)&&tr(n.root,e.root),cr=n=>({width:pe(n),height:me(n)}),Ni=n=>({signedWidth:$t(n),signedHeight:Ct(n)}),Ii=n=>({top:ce(n),left:ue(n),width:pe(n),height:me(n)}),un=(n,e,t=!1)=>{const r=sn(e)==="y"?Ct(n):$t(n);return t?r:Math.abs(r)},dt=(n,e)=>{const t=$(n);return{x:e.x==="center"?Ft(t).x:Se(t,e.x),y:e.y==="center"?Ft(t).y:Se(t,e.y)}},Se=(n,e)=>{const t=$(n),r=oi(t.root).includes(e)?Math.min:Math.max;return nn.includes(e)?r(t.one.x,t.two.x):r(t.one.y,t.two.y)},ki=n=>n.one.x===n.two.x&&n.one.y===n.two.y,pe=n=>un(n,"x"),me=n=>un(n,"y"),$t=n=>{const e=$(n);return e.two.x-e.one.x},Ct=n=>{const e=$(n);return e.two.y-e.one.y},lr=n=>dt(n,an),Ai=n=>dt(n,ii),Ei=n=>dt(n,er),$i=n=>dt(n,ai),be=n=>Se(n,"right"),xe=n=>Se(n,"bottom"),ue=n=>Se(n,"left"),ce=n=>Se(n,"top"),Ft=n=>ct(lr(n),{x:$t(n)/2,y:Ct(n)/2}),cn=n=>{const e=$(n);return e.root.x==="left"?ue(e):be(e)},ln=n=>{const e=$(n);return e.root.y==="top"?ce(e):xe(e)},Ci=n=>({x:cn(n),y:ln(n)}),pt=n=>{const e=$(n);return{lower:e.one.x,upper:e.two.x}},mt=n=>{const e=$(n);return{lower:e.one.y,upper:e.two.y}},Ri=(n,e)=>ur(n,e),Mi=(n,e)=>{const t=$(n),r=nn.includes(e)?"x":rn.includes(e)?"y":null;if(r===null)throw new Error(`Invalid location: ${e}`);const s=e==="top"||e==="left"?Math.min:Math.max,i={...t.one},a={...t.two};return i[r]=s(t.one[r],t.two[r]),a[r]=s(t.one[r],t.two[r]),[i,a]},ji=(n,e)=>{const t=$(n),r=$(e),s=cn(r)+(pe(r)-pe(t))/2,i=ln(r)+(me(r)-me(t))/2;return $({x:s,y:i},cr(t))},dr=n=>typeof n!="object"||n==null?!1:"one"in n&&"two"in n&&"root"in n,Zi=n=>pe(n)/me(n),Bi=(n,e,t)=>{if(typeof e=="string"){if(t==null)throw new Error("Undefined amount passed into box.translate");const s=sn(e);e=C(s,t)}const r=$(n);return $(ct(r.one,e),ct(r.two,e),void 0,void 0,r.root)},Di=(n,e)=>{const t=Math.max(ue(n),ue(e)),r=Math.max(ce(n),ce(e)),s=Math.min(be(n),be(e)),i=Math.min(xe(n),xe(e));return t>s||r>i?or:$({x:t,y:r},{x:s,y:i},void 0,void 0,n.root)},Ui=n=>pe(n)*me(n),Pi=(n,e)=>{const t=$(n);return $(qt(t.one,e),qt(t.two,e),void 0,void 0,t.root)},Wi=(n,e,t,r,s,i)=>{const a={x:n,y:e},o={x:n+t,y:e+r};return s.x!==i.x&&(s.x==="center"?(a.x-=t/2,o.x-=t/2):(a.x-=t,o.x-=t)),s.y!==i.y&&(s.y==="center"?(a.y-=r/2,o.y-=r/2):(a.y-=r,o.y-=r)),$(a,o,void 0,void 0,i)},Pe=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:_i,ZERO:or,area:Ui,areaIsZero:ki,aspect:Zi,bottom:xe,bottomLeft:Ei,bottomRight:$i,box:xi,center:Ft,construct:$,constructWithAlternateRoot:Wi,contains:Oi,copy:ur,css:Ii,cssBox:vi,dim:un,dims:cr,domRect:bi,edgePoints:Mi,equals:Si,height:me,intersection:Di,isBox:dr,left:ue,loc:Se,positionInCenter:ji,reRoot:Ri,resize:Ti,right:be,root:Ci,signedDims:Ni,signedHeight:Ct,signedWidth:$t,top:ce,topLeft:lr,topRight:Ai,translate:Bi,truncate:Pi,width:pe,x:cn,xBounds:pt,xyLoc:dt,y:ln,yBounds:mt},Symbol.toStringTag,{value:"Module"})),fr=u.object({signedWidth:u.number(),signedHeight:u.number()}),Li=u.union([tn,fr,ut,Et]),zi={width:0,height:0},Vi={width:1,height:1},G=(n,e)=>typeof n=="number"?{width:n,height:e??n}:Array.isArray(n)?{width:n[0],height:n[1]}:"x"in n?{width:n.x,height:n.y}:"signedWidth"in n?{width:n.signedWidth,height:n.signedHeight}:{...n},qi=(n,e)=>{if(e==null)return!1;const t=G(n),r=G(e);return t.width===r.width&&t.height===r.height},Fi=n=>{const e=G(n);return{width:e.height,height:e.width}},Yi=n=>{const e=G(n);return`0 0 ${e.width} ${e.height}`},Gi=n=>{const e=G(n);return[e.width,e.height]},Ji=n=>({width:Math.max(...n.map(e=>G(e).width)),height:Math.max(...n.map(e=>G(e).height))}),Hi=n=>({width:Math.min(...n.map(e=>G(e).width)),height:Math.min(...n.map(e=>G(e).height))}),Xi=(n,e)=>{const t=G(n);return{width:t.width*e,height:t.height*e}},yt=Object.freeze(Object.defineProperty({__proto__:null,DECIMAL:Vi,ZERO:zi,construct:G,couple:Gi,crude:Li,dimensions:tn,equals:qi,max:Ji,min:Hi,scale:Xi,signed:fr,svgViewBox:Yi,swap:Fi},Symbol.toStringTag,{value:"Module"}));var Ki=Object.defineProperty,Qi=(n,e,t)=>e in n?Ki(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,se=(n,e,t)=>Qi(n,typeof e!="symbol"?e+"":e,t);const ea=(n,e,t)=>e!==void 0&&n<e?e:t!==void 0&&n>t?t:n;u.object({offset:Vt,scale:Vt});u.object({offset:u.number(),scale:u.number()});const ta=n=>(e,t,r,s)=>t==="dimension"?[e,r]:[e,s?r-n:r+n],na=n=>(e,t,r,s)=>[e,s?r/n:r*n],ra=n=>(e,t,r)=>{if(e===null)return[n,r];const{lower:s,upper:i}=e,{lower:a,upper:o}=n,c=i-s,l=o-a;if(t==="dimension")return[n,r*(l/c)];const m=(r-s)*(l/c)+a;return[n,m]},sa=n=>(e,t,r)=>[n,r],ia=()=>(n,e,t)=>{if(n===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[n,t];const{lower:r,upper:s}=n;return[n,s-(t-r)]},aa=n=>(e,t,r)=>{const{lower:s,upper:i}=n;return r=ea(r,s,i),[e,r]},Yt=class We{constructor(){se(this,"ops",[]),se(this,"currBounds",null),se(this,"currType",null),se(this,"reversed",!1),this.ops=[]}static translate(e){return new We().translate(e)}static magnify(e){return new We().magnify(e)}static scale(e,t){return new We().scale(e,t)}translate(e){const t=this.new(),r=ta(e);return r.type="translate",t.ops.push(r),t}magnify(e){const t=this.new(),r=na(e);return r.type="magnify",t.ops.push(r),t}scale(e,t){const r=ve(e,t),s=this.new(),i=ra(r);return i.type="scale",s.ops.push(i),s}clamp(e,t){const r=ve(e,t),s=this.new(),i=aa(r);return i.type="clamp",s.ops.push(i),s}reBound(e,t){const r=ve(e,t),s=this.new(),i=sa(r);return i.type="re-bound",s.ops.push(i),s}invert(){const e=ia();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 We;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([r,s],i)=>i(r,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((r,s)=>{if(r.type==="scale"||t.some(([a,o])=>s>=a&&s<=o))return;const i=e.ops.findIndex((a,o)=>a.type==="scale"&&o>s);i!==-1&&t.push([s,i])}),t.forEach(([r,s])=>{const i=e.ops.slice(r,s);i.unshift(e.ops[s]),e.ops.splice(r,s-r+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};se(Yt,"IDENTITY",new Yt);let _n=Yt;const Tn=class ne{constructor(e=new _n,t=new _n,r=null){se(this,"x"),se(this,"y"),se(this,"currRoot"),this.x=e,this.y=t,this.currRoot=r}static translate(e,t){return new ne().translate(e,t)}static translateX(e){return new ne().translateX(e)}static translateY(e){return new ne().translateY(e)}static clamp(e){return new ne().clamp(e)}static magnify(e){return new ne().magnify(e)}static scale(e){return new ne().scale(e)}static reBound(e){return new ne().reBound(e)}translate(e,t){const r=C(e,t),s=this.copy();return s.x=this.x.translate(r.x),s.y=this.y.translate(r.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(dr(e)){const r=this.currRoot;return t.currRoot=e.root,r!=null&&!tr(r,e.root)&&(r.x!==e.root.x&&(t.x=t.x.invert()),r.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(pt(e)),t.y=t.y.scale(mt(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(pt(e)),t.y=this.y.reBound(mt(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(pt(e)),t.y=this.y.clamp(mt(e)),t}copy(){const e=new ne;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)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return $(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};se(Tn,"IDENTITY",new Tn);const oa=(n,e,t=".")=>{const r=n.split(t);return r.map((s,i)=>{const a=e(s,i,r);return a==null?null:typeof a=="string"?a:a.join(t)}).filter(s=>s!=null).join(t)},hr=(n,e,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:r,getter:s=(o,c)=>o[c]}=t,i=e.split(t.separator);if(i.length===1&&i[0]==="")return n;let a=n;for(const o of i){const c=s(a,o);if(c==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${o} is null`)}a=c}return a},ua=(n,e,t)=>{const r=e.split(".");let s=n;for(let i=0;i<r.length-1;i++){const a=r[i];s[a]??(s[a]={}),s=s[a]}try{s[r[r.length-1]]=t}catch(i){throw console.error("failed to set value",t,"at path",e,"on object",n),i}},ca=(n,e)=>{const t=e.split(".");let r=n;for(let s=0;s<t.length-1;s++){const i=t[s];if(r[i]==null)return;r=r[i]}if(Array.isArray(r)){const s=parseInt(t[t.length-1]);if(isNaN(s))return;r.splice(s,1);return}delete r[t[t.length-1]]},la=(n,e)=>{const t=n.split(".");return e<0?t[t.length+e]:t[e]},da=(n,e)=>{try{return hr(n,e),!0}catch{return!1}},fa=(n,e)=>{if(e.length===0)return!0;const t=n.split("."),r=e.split(".");if(r.length>t.length)return!1;for(let s=0;s<r.length;s++){const i=t[s],a=r[s];if(a!=="*"&&i!==a)return!1}return!0},ha=u.bigint().or(u.string().transform(BigInt));var pa=Object.defineProperty,ma=(n,e,t)=>e in n?pa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,f=(n,e,t)=>ma(n,typeof e!="symbol"?e+"":e,t);let ya=(n,e=21)=>(t=e)=>{let r="",s=t|0;for(;s--;)r+=n[Math.random()*n.length|0];return r};const ga="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",pr=ya(ga,11),Gt=Object.freeze(Object.defineProperty({__proto__:null,id:pr},Symbol.toStringTag,{value:"Module"})),wa=u.enum(["static","dynamic"]),mr=(n,e)=>{const t=new E(e);if(![A.DAY,A.HOUR,A.MINUTE,A.SECOND,A.MILLISECOND,A.MICROSECOND,A.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=n.valueOf()%t.valueOf();return n instanceof E?new E(r):new A(r)},I=class v{constructor(e,t="UTC"){if(f(this,"value"),f(this,"encodeValue",!0),e==null)this.value=v.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*v.MILLISECOND.valueOf();else if(typeof e=="string")this.value=v.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=v.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(r=v.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=v.MAX:e=v.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,t=1,r=1]){const s=new Date(e,t-1,r,0,0,0,0);return new v(BigInt(s.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[r,s,i]=e.split(":");let a="00",o="00";i!=null&&([a,o]=i.split("."));let c=v.hours(parseInt(r??"00")).add(v.minutes(parseInt(s??"00"))).add(v.seconds(parseInt(a??"00"))).add(v.milliseconds(parseInt(o??"00")));return t==="local"&&(c=c.add(v.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new v(BigInt(r.getTime())*v.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();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(v.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const r=this.toISOString(t);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${t} ${r}`}static get utcOffset(){return new A(BigInt(new Date().getTimezoneOffset())*v.MINUTE.valueOf())}static since(e){return new v().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new v(e).valueOf()}span(e){return this.range(e).span}range(e){return new dn(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 v(e).valueOf()}afterEq(e){return this.valueOf()>=new v(e).valueOf()}before(e){return this.valueOf()<new v(e).valueOf()}beforeEq(e){return this.valueOf()<=new v(e).valueOf()}add(e){return new v(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new v(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new v(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new v(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new v(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new v(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new v(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new v(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new v(t)}toString(){return this.date().toISOString()}remainder(e){return mr(this,e)}get isToday(){return this.truncate(A.DAY).equals(v.now().truncate(A.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new v(new Date)}static max(...e){let t=v.MIN;for(const r of e){const s=new v(r);s.after(t)&&(t=s)}return t}static min(...e){let t=v.MAX;for(const r of e){const s=new v(r);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new v(e)}static microseconds(e){return v.nanoseconds(e*1e3)}static milliseconds(e){return v.microseconds(e*1e3)}static seconds(e){return v.milliseconds(e*1e3)}static minutes(e){return v.seconds(e*60)}static hours(e){return v.minutes(e*60)}static days(e){return v.hours(e*24)}};f(I,"NANOSECOND",I.nanoseconds(1)),f(I,"MICROSECOND",I.microseconds(1)),f(I,"MILLISECOND",I.milliseconds(1)),f(I,"SECOND",I.seconds(1)),f(I,"MINUTE",I.minutes(1)),f(I,"HOUR",I.hours(1)),f(I,"DAY",I.days(1)),f(I,"MAX",new I((1n<<63n)-1n)),f(I,"MIN",new I(0)),f(I,"ZERO",new I(0)),f(I,"z",u.union([u.object({value:u.bigint()}).transform(n=>new I(n.value)),u.string().transform(n=>new I(BigInt(n))),u.instanceof(Number).transform(n=>new I(n)),u.number().transform(n=>new I(n)),u.instanceof(I)]));let E=I;const k=class T{constructor(e){f(this,"value"),f(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof T?e:e instanceof On?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.seconds(e):new T(e)}static fromMilliseconds(e){return e instanceof T?e:e instanceof On?e.period:e instanceof E?new T(e):["number","bigint"].includes(typeof e)?T.milliseconds(e):new T(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new T(e).valueOf()}greaterThan(e){return this.valueOf()>new T(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new T(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new T(e).valueOf()}remainder(e){return mr(this,e)}truncate(e){return new T(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(T.DAY),t=this.truncate(T.HOUR),r=this.truncate(T.MINUTE),s=this.truncate(T.SECOND),i=this.truncate(T.MILLISECOND),a=this.truncate(T.MICROSECOND),o=this.truncate(T.NANOSECOND),c=e,l=t.sub(e),m=r.sub(t),g=s.sub(r),U=i.sub(s),V=a.sub(i),Me=o.sub(a);let ae="";return c.isZero||(ae+=`${c.days}d `),l.isZero||(ae+=`${l.hours}h `),m.isZero||(ae+=`${m.minutes}m `),g.isZero||(ae+=`${g.seconds}s `),U.isZero||(ae+=`${U.milliseconds}ms `),V.isZero||(ae+=`${V.microseconds}µs `),Me.isZero||(ae+=`${Me.nanoseconds}ns`),ae.trim()}mult(e){return new T(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new T(e).valueOf()}add(e){return new T(this.valueOf()+new T(e).valueOf())}sub(e){return new T(this.valueOf()-new T(e).valueOf())}static nanoseconds(e=1){return new T(e)}static microseconds(e=1){return T.nanoseconds(Ne(e,1e3))}static milliseconds(e=1){return T.microseconds(Ne(e,1e3))}static seconds(e=1){return T.milliseconds(Ne(e,1e3))}static minutes(e=1){return T.seconds(Ne(e,60))}static hours(e){return T.minutes(Ne(e,60))}static days(e){return T.hours(Ne(e,24))}};f(k,"NANOSECOND",k.nanoseconds(1)),f(k,"MICROSECOND",k.microseconds(1)),f(k,"MILLISECOND",k.milliseconds(1)),f(k,"SECOND",k.seconds(1)),f(k,"MINUTE",k.minutes(1)),f(k,"HOUR",k.hours(1)),f(k,"DAY",k.days(1)),f(k,"MAX",new k((1n<<63n)-1n)),f(k,"MIN",new k(0)),f(k,"ZERO",new k(0)),f(k,"z",u.union([u.object({value:u.bigint()}).transform(n=>new k(n.value)),u.string().transform(n=>new k(BigInt(n))),u.instanceof(Number).transform(n=>new k(n)),u.number().transform(n=>new k(n)),u.instanceof(k)]));let A=k;const Le=class gt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new gt(e).valueOf()}get period(){return A.seconds(1/this.valueOf())}sampleCount(e){return new A(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new P(t).valueOf()}span(e){return A.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new gt(e)}static khz(e){return gt.hz(e*1e3)}};f(Le,"z",u.union([u.number().transform(n=>new Le(n)),u.instanceof(Number).transform(n=>new Le(n)),u.instanceof(Le)]));let On=Le;const Z=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Jt(e*this.valueOf())}};f(Z,"UNKNOWN",new Z(0)),f(Z,"BIT128",new Z(16)),f(Z,"BIT64",new Z(8)),f(Z,"BIT32",new Z(4)),f(Z,"BIT16",new Z(2)),f(Z,"BIT8",new Z(1)),f(Z,"z",u.union([u.number().transform(n=>new Z(n)),u.instanceof(Number).transform(n=>new Z(n)),u.instanceof(Z)]));let P=Z;const J=class wt{constructor(e,t){f(this,"start"),f(this,"end"),typeof e=="object"&&"start"in e?(this.start=new E(e.start),this.end=new E(e.end)):(this.start=new E(e),this.end=new E(t))}get span(){return new A(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new wt(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=A.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const s=E.max(r.start,e.start),i=E.min(r.end,e.end);return i.before(s)?!1:new A(i.sub(s)).greaterThanOrEqual(t)}roughlyEquals(e,t){let r=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return r<0&&(r=-r),s<0&&(s=-s),r<=t.valueOf()&&s<=t.valueOf()}contains(e){return e instanceof wt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new wt(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}};f(J,"MAX",new J(E.MIN,E.MAX)),f(J,"MIN",new J(E.MAX,E.MIN)),f(J,"ZERO",new J(E.ZERO,E.ZERO)),f(J,"z",u.union([u.object({start:E.z,end:E.z}).transform(n=>new J(n.start,n.end)),u.instanceof(J)]));let dn=J;const d=class M extends String{constructor(e){if(e instanceof M||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=M.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(M.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=M.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()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(M.JSON)||this.equals(M.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(M.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=M.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsigned(){return this.equals(M.UINT8)||this.equals(M.UINT16)||this.equals(M.UINT32)||this.equals(M.UINT64)}get isSigned(){return this.equals(M.INT8)||this.equals(M.INT16)||this.equals(M.INT32)||this.equals(M.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsigned&&e.isSigned?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(M.INT32)&&e.equals(M.FLOAT64)||this.equals(M.INT8)&&e.equals(M.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsigned===e.isUnsigned:!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 M.BIG_INT_TYPES.some(e=>e.equals(this))}};f(d,"UNKNOWN",new d("unknown")),f(d,"FLOAT64",new d("float64")),f(d,"FLOAT32",new d("float32")),f(d,"INT64",new d("int64")),f(d,"INT32",new d("int32")),f(d,"INT16",new d("int16")),f(d,"INT8",new d("int8")),f(d,"UINT64",new d("uint64")),f(d,"UINT32",new d("uint32")),f(d,"UINT16",new d("uint16")),f(d,"UINT8",new d("uint8")),f(d,"BOOLEAN",d.UINT8),f(d,"TIMESTAMP",new d("timestamp")),f(d,"UUID",new d("uuid")),f(d,"STRING",new d("string")),f(d,"JSON",new d("json")),f(d,"ARRAY_CONSTRUCTORS",new Map([[d.UINT8.toString(),Uint8Array],[d.UINT16.toString(),Uint16Array],[d.UINT32.toString(),Uint32Array],[d.UINT64.toString(),BigUint64Array],[d.FLOAT32.toString(),Float32Array],[d.FLOAT64.toString(),Float64Array],[d.INT8.toString(),Int8Array],[d.INT16.toString(),Int16Array],[d.INT32.toString(),Int32Array],[d.INT64.toString(),BigInt64Array],[d.TIMESTAMP.toString(),BigInt64Array],[d.STRING.toString(),Uint8Array],[d.JSON.toString(),Uint8Array],[d.UUID.toString(),Uint8Array]])),f(d,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,d.UINT8],[Uint16Array.name,d.UINT16],[Uint32Array.name,d.UINT32],[BigUint64Array.name,d.UINT64],[Float32Array.name,d.FLOAT32],[Float64Array.name,d.FLOAT64],[Int8Array.name,d.INT8],[Int16Array.name,d.INT16],[Int32Array.name,d.INT32],[BigInt64Array.name,d.INT64]])),f(d,"DENSITIES",new Map([[d.UINT8.toString(),P.BIT8],[d.UINT16.toString(),P.BIT16],[d.UINT32.toString(),P.BIT32],[d.UINT64.toString(),P.BIT64],[d.FLOAT32.toString(),P.BIT32],[d.FLOAT64.toString(),P.BIT64],[d.INT8.toString(),P.BIT8],[d.INT16.toString(),P.BIT16],[d.INT32.toString(),P.BIT32],[d.INT64.toString(),P.BIT64],[d.TIMESTAMP.toString(),P.BIT64],[d.STRING.toString(),P.UNKNOWN],[d.JSON.toString(),P.UNKNOWN],[d.UUID.toString(),P.BIT128]])),f(d,"ALL",[d.UNKNOWN,d.FLOAT64,d.FLOAT32,d.INT64,d.INT32,d.INT16,d.INT8,d.UINT64,d.UINT32,d.UINT16,d.UINT8,d.TIMESTAMP,d.UUID,d.STRING,d.JSON]),f(d,"BIG_INT_TYPES",[d.INT64,d.UINT64,d.TIMESTAMP]),f(d,"z",u.union([u.string().transform(n=>new d(n)),u.instanceof(d)]));let N=d;const B=class j extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return j.bytes(this.valueOf()+e.valueOf())}sub(e){return j.bytes(this.valueOf()-e.valueOf())}truncate(e){return new j(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return j.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/j.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/j.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/j.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/j.TERABYTE.valueOf()}toString(){const e=this.truncate(j.TERABYTE),t=this.truncate(j.GIGABYTE),r=this.truncate(j.MEGABYTE),s=this.truncate(j.KILOBYTE),i=this.truncate(j.BYTE),a=e,o=t.sub(e),c=r.sub(t),l=s.sub(r),m=i.sub(s);let g="";return a.isZero||(g+=`${a.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),c.isZero||(g+=`${c.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!m.isZero||g==="")&&(g+=`${m.valueOf()}B`),g.trim()}static bytes(e=1){return new j(e)}static kilobytes(e=1){return j.bytes(e.valueOf()*1e3)}static megabytes(e=1){return j.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return j.megabytes(e.valueOf()*1e3)}static terabytes(e){return j.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};f(B,"BYTE",new B(1)),f(B,"KILOBYTE",B.kilobytes(1)),f(B,"MEGABYTE",B.megabytes(1)),f(B,"GIGABYTE",B.gigabytes(1)),f(B,"TERABYTE",B.terabytes(1)),f(B,"ZERO",new B(0)),f(B,"z",u.union([u.number().transform(n=>new B(n)),u.instanceof(B)]));let Jt=B;u.union([u.instanceof(Uint8Array),u.instanceof(Uint16Array),u.instanceof(Uint32Array),u.instanceof(BigUint64Array),u.instanceof(Float32Array),u.instanceof(Float64Array),u.instanceof(Int8Array),u.instanceof(Int16Array),u.instanceof(Int32Array),u.instanceof(BigInt64Array)]);const yr=n=>{const e=typeof n;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||n instanceof E||n instanceof A||n instanceof Date},va=(n,e,t,r=0)=>n.usesBigInt&&!e.usesBigInt?Number(t)-Number(r):!n.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(r.valueOf()):Ve(t,-r).valueOf(),ba=n=>n==null?!1:Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)&&!(n instanceof DataView)||n instanceof Ta?!0:yr(n),oe=-1,xa=u.string().transform(n=>new Uint8Array(atob(n).split("").map(e=>e.charCodeAt(0))).buffer),_a=u.union([u.null(),u.undefined()]).transform(()=>new Uint8Array().buffer),Ht=10,ze=class H{constructor(e){f(this,"key",""),f(this,"isSynnaxSeries",!0),f(this,"dataType"),f(this,"sampleOffset"),f(this,"gl"),f(this,"_data"),f(this,"_timeRange"),f(this,"alignment",0n),f(this,"_cachedMin"),f(this,"_cachedMax"),f(this,"writePos",oe),f(this,"_refCount",0),f(this,"_cachedLength"),f(this,"_cachedIndexes"),ba(e)&&(e={data:e});const{dataType:t,timeRange:r,sampleOffset:s=0,glBufferUsage:i="static",alignment:a=0n,key:o=pr()}=e,c=e.data??[];if(c instanceof H||typeof c=="object"&&"isSynnaxSeries"in c&&c.isSynnaxSeries===!0){const g=c;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=yr(c),m=Array.isArray(c);if(t!=null)this.dataType=new N(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||l){let g=c;if(!l){if(c.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=c[0]}if(typeof g=="string")this.dataType=N.STRING;else if(typeof g=="number")this.dataType=N.FLOAT64;else if(typeof g=="bigint")this.dataType=N.INT64;else if(typeof g=="boolean")this.dataType=N.BOOLEAN;else if(g instanceof E||g instanceof Date||g instanceof E)this.dataType=N.TIMESTAMP;else if(typeof g=="object")this.dataType=N.JSON;else throw new Error(`cannot infer data type of ${typeof g} when constructing a Series from a JS array`)}else this.dataType=new N(c)}if(!m&&!l)this._data=c;else{let g=l?[c]:c;const U=g[0];(U instanceof E||U instanceof Date||U instanceof A)&&(g=g.map(V=>new E(V).valueOf())),this.dataType.equals(N.STRING)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(`${g.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`).buffer):this.dataType.equals(N.JSON)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(`${g.map(V=>ht.encodeString(V)).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`).buffer):this._data=new this.dataType.Array(g).buffer}this.key=o,this.alignment=a,this.sampleOffset=s??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:t,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new N(t).Array(e),i=new H({data:s.buffer,dataType:t,...r});return i.writePos=0,i}static generateTimestamps(e,t,r){const s=r.spanRange(t.span(e)),i=new BigInt64Array(e);for(let a=0;a<e;a++)i[a]=BigInt(r.add(t.span(a)).valueOf());return new H({data:i,dataType:N.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const r=new TextEncoder().encode(`${e.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`);return new H({data:r,dataType:N.STRING,timeRange:t})}static fromJSON(e,t){const r=new TextEncoder().encode(`${e.map(s=>ht.encodeString(s)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`);return new H({data:r,dataType:N.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");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===oe)return 0;const t=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,t);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===oe)return 0;const t=this.capacity-this.writePos,r=e.sub(0,t);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===oe?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(N.STRING,N.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(N.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=N.UUID.density.valueOf(),t=Array(this.length);for(let r=0;r<this.length;r++){const s=this.underlyingData.slice(r*e,(r+1)*e),i=Array.from(new Uint8Array(s.buffer),a=>a.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[r]=i}return t}parseJSON(e){if(!this.dataType.equals(N.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
-
`).slice(0,-1).map(t=>e.parse(ht.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Jt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===oe?this.byteCapacity:this.dataType.isVariable?new Jt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===oe?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;const t=[0];return this.data.forEach((r,s)=>{r===Ht&&(e++,t.push(s+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let s=0;s<this.length;s++)r[s]=va(this.dataType,e,this.data[s],t);return new H({data:r.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(N.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,r)=>t>r?t:r)}else{const e=this.data;this._cachedMax=e.reduce((t,r)=>t>r?t:r)}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??(this._cachedMax=this.calcRawMax()),Ve(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(N.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,r)=>t<r?t:r)}else{const e=this.data;this._cachedMin=e.reduce((t,r)=>t<r?t:r)}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??(this._cachedMin=this.calcRawMin()),Ve(this._cachedMin,this.sampleOffset))}get bounds(){return ve(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 Ve(this.max,-this.min)}atAlignment(e,t){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Ve(r,this.sampleOffset)}atVariable(e,t){let r=0,s=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let a=0;a<this.data.length;a++)if(this.data[a]===Ht){if(e===0){s=a;break}r=a+1,e--}if(s===0&&(s=this.data.length),r>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const i=this.data.slice(r,s);return this.dataType.equals(N.STRING)?new TextDecoder().decode(i):jn(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,r=this.length-1;const s=Ys(e);for(;t<=r;){const i=Math.floor((t+r)/2),a=s(this.at(i,!0),e);if(a===0)return i;a<0?t=i+1:r=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(N.FLOAT32)&&!this.dataType.equals(N.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:t,bufferUsage:r,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==oe){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(s).valueOf(),a=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,a.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=oe}as(e){if(e==="string"){if(!this.dataType.equals(N.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(N.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:{lower:En(this.alignmentBounds.lower),upper:En(this.alignmentBounds.upper)},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 ve(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 Oa(this);return this.dataType.equals(N.JSON)?new Sa(e):e}return new Na(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new Sn(this,e,t??this.length)}subAlignmentIterator(e,t){return new Sn(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,t);return new H({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,r){if(t<=0&&(r==null||r>=this.length))return this;let s;return e?s=this.data.subarray(t,r):s=this.data.slice(t,r),new H({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new H({data:this.buffer,dataType:this.dataType,timeRange:dn.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};f(ze,"crudeZ",u.object({timeRange:dn.z.optional(),dataType:N.z,alignment:ha.optional(),data:u.union([xa,_a,u.instanceof(ArrayBuffer),u.instanceof(Uint8Array)]),glBufferUsage:wa.optional().default("static").optional()})),f(ze,"z",ze.crudeZ.transform(n=>new ze(n)));let Ta=ze;class Sn{constructor(e,t,r){f(this,"series"),f(this,"end"),f(this,"index"),this.series=e;const s=ve(0,e.length);this.end=xn(s,r),this.index=xn(s,t)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class Oa{constructor(e){if(f(this,"series"),f(this,"index"),f(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]!==Ht;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Nn,In;class Sa{constructor(e){f(this,"wrapped"),f(this,Nn,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:ht.decodeString(e.value)}}[(In=Symbol.iterator,Nn=Symbol.toStringTag,In)](){return this}}var kn,An;class Na{constructor(e){f(this,"series"),f(this,"index"),f(this,kn,"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)}}[(An=Symbol.iterator,kn=Symbol.toStringTag,An)](){return this}}const Ve=(n,e)=>typeof n=="bigint"&&typeof e=="bigint"||typeof n=="number"&&typeof e=="number"?n+e:e===0?n:n===0?e:Number(n)+Number(e),En=n=>{const e=n>>32n,t=n&0xffffffffn;return{domain:e,sample:t}},Ia=n=>JSON.parse(JSON.stringify(n)),ka=(n,...e)=>(e.forEach(t=>{let r=n;const s=t.split(".");s.forEach((i,a)=>{a===s.length-1?delete r[i]:i in r&&(r=r[i])})}),n),Aa=(n,e,t="")=>{const r={},s=(i,a,o)=>{if(typeof i!=typeof a||i===null||a===null){r[o]=[i,a];return}if(typeof i=="object"&&typeof a=="object")if(Array.isArray(i)&&Array.isArray(a)){if(i.length!==a.length){r[o]=[i,a];return}for(let c=0;c<i.length;c++)s(i[c],a[c],`${o}[${c}]`)}else new Set([...Object.keys(i),...Object.keys(a)]).forEach(c=>{s(i[c],a[c],o!==""?`${o}.${c}`:c)});else i!==a&&(r[o]=[i,a])};return s(n,e,t),r},Xt=(n,e)=>{const t=Array.isArray(n),r=Array.isArray(e);if(t!==r)return!1;if(t&&r){const a=n,o=e;if(a.length!==o.length)return!1;for(let c=0;c<a.length;c++)if(!Xt(a[c],o[c]))return!1;return!0}if(n==null||e==null||typeof n!="object"||typeof e!="object")return n===e;if("equals"in n)return n.equals(e);const s=Object.keys(n),i=Object.keys(e);if(s.length!==i.length)return!1;for(const a of s){const o=n[a],c=e[a];if(typeof o=="object"&&typeof c=="object"){if(!Xt(o,c))return!1}else if(o!==c)return!1}return!0},gr=(n,e)=>{if(typeof n!="object"||n==null)return n===e;const t=Object.keys(n),r=Object.keys(e);if(r.length>t.length)return!1;for(const s of r){const i=n[s],a=e[s];if(typeof i=="object"&&typeof a=="object"){if(!gr(i,a))return!1}else if(i!==a)return!1}return!0},Kt=(n,...e)=>{if(e.length===0)return n;const t=e.shift();if(Ye(n)&&Ye(t))for(const r in t)try{Ye(t[r])?(r in n||Object.assign(n,{[r]:{}}),Kt(n[r],t[r])):Object.assign(n,{[r]:t[r]})}catch(s){throw s instanceof TypeError?new TypeError(`.${r}: ${s.message}`):s}return Kt(n,...e)},Ea=(n,e,t)=>{const r=(s,i,a)=>{for(const o in i){const c=i[o];if(a!=null&&a.shape[o]){const l=a.shape[o].safeParse(c);l.success&&(s[o]=l.data)}else typeof c=="object"&&!Array.isArray(c)&&c!==null&&a&&a.shape&&a.shape[o]&&(s[o]||(s[o]={}),r(s[o],c,a.shape[o]))}return s};return r({...n},e,t)},fn=Object.freeze(Object.defineProperty({__proto__:null,copy:Ia,deleteD:ka,difference:Aa,element:la,equal:Xt,get:hr,has:da,override:Kt,overrideValidItems:Ea,partialEqual:gr,pathsMatch:fa,remove:ca,set:ua,transformPath:oa},Symbol.toStringTag,{value:"Module"}));u.object({key:u.string(),value:u.string()});u.record(u.union([u.number(),u.string(),u.symbol()]),u.unknown());const wr=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",$a=wr(),vr=["macOS","Windows","Linux"],Ca=["macos","windows","linux"],Ra={macos:"macOS",windows:"Windows",linux:"Linux"},Ma=u.enum(vr).or(u.enum(Ca).transform(n=>Ra[n])),ja=()=>{if(typeof window>"u")return;const n=window.navigator.userAgent.toLowerCase();if(n.includes("mac"))return"macOS";if(n.includes("win"))return"Windows";if(n.includes("linux"))return"Linux"};let Bt;const Za=(n={})=>{const{force:e,default:t}=n;return e??Bt??(Bt=ja(),Bt??t)},Ba=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:vr,RUNTIME:$a,detect:wr,getOS:Za,osZ:Ma},Symbol.toStringTag,{value:"Module"}));var Da=Object.defineProperty,Ua=(n,e,t)=>e in n?Da(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qe=(n,e,t)=>Ua(n,typeof e!="symbol"?e+"":e,t);const Pa=(...n)=>n.map(br).join(""),br=n=>(n.endsWith("/")||(n+="/"),n.startsWith("/")&&(n=n.slice(1)),n),Wa=n=>n.endsWith("/")?n.slice(0,-1):n,$n=class Qt{constructor({host:e,port:t,protocol:r="",pathPrefix:s=""}){qe(this,"protocol"),qe(this,"host"),qe(this,"port"),qe(this,"path"),this.protocol=r,this.host=e,this.port=t,this.path=br(s)}replace(e){return new Qt({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Qt({...this,pathPrefix:Pa(this.path,e)})}toString(){return Wa(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};qe($n,"UNKNOWN",new $n({host:"unknown",port:0}));var La=Object.defineProperty,za=(n,e,t)=>e in n?La(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,vt=(n,e,t)=>za(n,typeof e!="symbol"?e+"":e,t);u.object({interval:A.z.optional(),maxRetries:u.number().optional(),scale:u.number().optional()});const Ie=class extends Number{};vt(Ie,"Absolute",255),vt(Ie,"Default",1),vt(Ie,"z",u.union([u.instanceof(Ie),u.number().int().min(0).max(255).transform(n=>new Ie(n)),u.instanceof(Number).transform(n=>new Ie(n))]));u.object({name:u.string(),key:u.string()});const xr=class Fe extends Error{constructor(){super(Fe.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Fe.MESSAGE):e instanceof Fe||e.message.includes(Fe.MESSAGE)}};vt(xr,"MESSAGE","canceled");let Va=xr;new Va;u.string().regex(/^\d+\.\d+\.\d+$/);const ge="main",hn="prerender",Rt={stage:"creating",processCount:0,reserved:!1,focusCount:0,centerCount:0},_r={...Rt,key:hn,visible:!1},qa=u.object({key:u.string(),url:u.string().optional(),title:u.string().optional(),center:u.boolean().optional(),position:kt.xy.optional(),size:yt.dimensions.optional(),minSize:yt.dimensions.optional(),maxSize:yt.dimensions.optional(),resizable:u.boolean().optional(),fullscreen:u.boolean().optional(),focus:u.boolean().optional(),maximized:u.boolean().optional(),visible:u.boolean().optional(),minimized:u.boolean().optional(),decorations:u.boolean().optional(),skipTaskbar:u.boolean().optional(),fileDropEnabled:u.boolean().optional(),transparent:u.boolean().optional(),alwaysOnTop:u.boolean().optional()}),Fa=A.milliseconds(50),Tr=()=>setTimeout(()=>window.location.reload(),Fa.milliseconds),Or={label:ge,config:{enablePrerender:!0,debug:!1,defaultWindowProps:{}},windows:{main:{...Rt,key:ge,reserved:!0}},labelKeys:{main:ge},keyLabels:{main:ge}},Ya=(n,e)=>{if(n.type===Nr.type)return e.label!==ge||(n.payload.label=Gt.id(),n.payload.prerenderLabel=Gt.id()),n;if("label"in n.payload)return n;let t=e.label;const r=n.payload;return r.key!=null&&(r.key in e.windows?t=r.key:t=e.keyLabels[r.key]),n.payload={...n.payload,label:t},n},z=n=>(e,t)=>{if(!("label"in t.payload))throw new Error("Missing label");n(e,t)},ye=(n,e=!1)=>z((t,r)=>{let s=e;const i=t.windows[r.payload.label];if(i!=null){if(r.payload.value!=null)s=r.payload.value;else{const a=i[n];a!=null&&(s=!a)}t.windows[r.payload.label]={...i,[n]:s}}}),Mt=(n,e=!1)=>(t,r)=>{const s=t.windows[r.payload.label];s!=null&&(t.windows[r.payload.label]={...s,[n]:s[n]+(e?-1:1)})},Ga=n=>Object.values(n.windows).some(e=>e.key===hn&&!e.reserved),pn="drift",Ja=(n,e,t)=>n.position!=null&&n.size!=null&&e==null?Pe.topLeft(Pe.positionInCenter(Pe.construct(kt.ZERO,t??kt.ZERO),Pe.construct(n.position,n.size))):e,Ha=(n,{payload:e})=>{if(e.key===hn)return;const{key:t,label:r,prerenderLabel:s}=e;if(r==null||s==null)throw new Error("[drift] - bug - missing label and prerender label");console.log(n.config.debug),Rn(n.config.debug,"reducer create window");const i=n.windows.main;if(e.position=Ja(i,e.position,e.size),t in n.keyLabels){je(n.config.debug,"window already exists, un-minimize and focus it");const c=n.keyLabels[e.key];n.windows[c].visible=!0,n.windows[c].focusCount+=1,n.windows[c].minimized=!1,n.windows[c].position=e.position,Dt(n.config.debug);return}const[a,o]=Object.entries(n.windows).find(([,c])=>!c.reserved)??[null,null];a!=null?(je(n.config.debug,"using available pre-rendered window"),n.windows[a]={...o,visible:!0,reserved:!0,focusCount:1,focus:!0,...e},n.labelKeys[a]=e.key,n.keyLabels[e.key]=a):(je(n.config.debug,"creating new window"),n.windows[r]={...n.config.defaultWindowProps,...Rt,...e,reserved:!0},n.labelKeys[r]=t,n.keyLabels[t]=r),n.config.enablePrerender&&!Ga(n)&&(je(n.config.debug,"creating pre-render window"),n.windows[s]=fn.copy({...n.config.defaultWindowProps,..._r})),Dt(n.config.debug)},Xa=z((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.stage=e.payload.stage)}),Ka=z((n,{payload:{label:e}})=>{const t=n.windows[e];t==null||t.processCount>0||(t.stage="closing",delete n.windows[e],delete n.labelKeys[e],delete n.keyLabels[t.key])}),Qa=z((n,e)=>{const t=n.windows[e.payload.label];t==null||t.processCount>0||(t.stage="reloading",Tr())}),eo=z(Mt("processCount")),to=z((n,e)=>{Mt("processCount",!0)(n,e);const t=n.windows[e.payload.label];t!=null&&t.processCount===0&&(t.stage==="reloading"?Tr():(n.windows[e.payload.label].visible=!1,delete n.windows[e.payload.label],delete n.labelKeys[e.payload.label],delete n.keyLabels[t.key]))}),no=(n,e)=>{const t=n.windows[e.payload.key];t!=null&&(t.error=e.payload.message)},ro=z((n,e)=>{const t=n.windows[e.payload.label];t!=null&&(t.visible!==!0&&(t.visible=!0),Mt("focusCount")(n,e))}),so=ye("minimized"),io=ye("maximized"),ao=ye("visible",!0),oo=ye("fullscreen",!0),uo=z(Mt("centerCount")),co=z((n,e)=>{n.windows[e.payload.label].position=e.payload.position}),lo=z((n,e)=>{n.windows[e.payload.label].size=e.payload.size}),fo=z((n,e)=>{n.windows[e.payload.label].minSize=e.payload.size}),ho=z((n,e)=>{n.windows[e.payload.label].maxSize=e.payload.size}),po=ye("resizable"),mo=ye("skipTaskbar"),yo=ye("alwaysOnTop"),go=z((n,e)=>{n.windows[e.payload.label].title=e.payload.title}),wo=ye("decorations"),Cn=(n,e)=>{const t=n.windows[e.payload.label];fn.partialEqual(t,e.payload)||(n.windows[e.payload.label]={...t,...e.payload})},vo=(n,e)=>{if(n.config={...n.config,...e.payload},n.label=e.payload.label,n.label===ge&&n.config.enablePrerender){const t=Gt.id();n.windows[t]={...n.config.defaultWindowProps,..._r}}},Sr=kr.createSlice({name:pn,initialState:Or,reducers:{internalSetInitial:vo,createWindow:Ha,setWindowStage:Xa,closeWindow:Ka,registerProcess:eo,completeProcess:to,setWindowError:no,focusWindow:ro,reloadWindow:Qa,setWindowMinimized:so,setWindowMaximized:io,setWindowVisible:ao,setWindowFullscreen:oo,centerWindow:uo,setWindowPosition:co,setWindowSize:lo,setWindowMinSize:fo,setWindowMaxSize:ho,setWindowResizable:po,setWindowSkipTaskbar:mo,setWindowAlwaysOnTop:yo,setWindowTitle:go,setWindowDecorations:wo,runtimeSetWindowProps:Cn,setWindowProps:Cn}}),{actions:{runtimeSetWindowProps:bo,setWindowProps:xo,createWindow:Nr,internalSetInitial:Ir,setWindowStage:_o,closeWindow:To,registerProcess:Oo,completeProcess:So,setWindowError:No,focusWindow:Io,reloadWindow:ko,setWindowMinimized:Ao,setWindowMaximized:Eo,setWindowVisible:$o,setWindowFullscreen:Co,centerWindow:Xo,setWindowPosition:Ro,setWindowSize:Mo,setWindowMinSize:jo,setWindowMaxSize:Zo,setWindowResizable:Bo,setWindowSkipTaskbar:Do,setWindowAlwaysOnTop:Uo,setWindowTitle:Po,setWindowDecorations:Wo}}=Sr,Lo=Sr.reducer,zo=n=>n.startsWith(pn),Vo=[Ir.type],qo=(n,e)=>!n&&!Vo.includes(e);exports.G=kt;exports.INITIAL_WINDOW_STATE=Rt;exports.MAIN_WINDOW=ge;exports.S=Ba;exports.SLICE_NAME=pn;exports.Tt=Pe;exports.ZERO_SLICE_STATE=Or;exports._=yt;exports._$1=fn;exports.assignLabel=Ya;exports.closeWindow=To;exports.completeProcess=So;exports.createWindow=Nr;exports.focusWindow=Io;exports.group=Rn;exports.groupEnd=Dt;exports.internalSetInitial=Ir;exports.isDriftAction=zo;exports.log=je;exports.reducer=Lo;exports.registerProcess=Oo;exports.reloadWindow=ko;exports.runtimeSetWindowProps=bo;exports.setWindowAlwaysOnTop=Uo;exports.setWindowDecorations=Wo;exports.setWindowError=No;exports.setWindowFullscreen=Co;exports.setWindowMaxSize=Zo;exports.setWindowMaximized=Eo;exports.setWindowMinSize=jo;exports.setWindowMinimized=Ao;exports.setWindowPosition=Ro;exports.setWindowProps=xo;exports.setWindowResizable=Bo;exports.setWindowSize=Mo;exports.setWindowSkipTaskbar=Do;exports.setWindowStage=_o;exports.setWindowTitle=Po;exports.setWindowVisible=$o;exports.shouldEmit=qo;exports.w=A;exports.windowPropsZ=qa;
|