@synnaxlabs/client 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +7 -6
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +14 -4
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/creator.d.ts +1 -1
- package/dist/channel/creator.d.ts.map +1 -1
- package/dist/channel/external.d.ts +1 -1
- package/dist/channel/external.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +21 -8
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +6 -6
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +13 -1
- package/dist/channel/writer.d.ts.map +1 -1
- package/dist/client.cjs +17 -18
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5487 -13615
- package/dist/connection/checker.d.ts +4 -4
- package/dist/control/client.d.ts +9 -0
- package/dist/control/client.d.ts.map +1 -0
- package/dist/control/external.d.ts +1 -1
- package/dist/control/external.d.ts.map +1 -1
- package/dist/control/state.d.ts +17 -52
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +1 -1
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +7 -5
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +68 -0
- package/dist/framer/deleter.d.ts.map +1 -0
- package/dist/framer/deleter.spec.d.ts +2 -0
- package/dist/framer/deleter.spec.d.ts.map +1 -0
- package/dist/framer/frame.d.ts +45 -241
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/iterator.d.ts +1 -1
- package/dist/framer/iterator.d.ts.map +1 -1
- package/dist/framer/streamProxy.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +86 -231
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +9 -7
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +17 -14
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/external.d.ts +2 -2
- package/dist/label/external.d.ts.map +1 -1
- package/dist/label/writer.d.ts +4 -2
- package/dist/label/writer.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +8 -8
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/client.d.ts +1 -1
- package/dist/ontology/group/client.d.ts.map +1 -1
- package/dist/ontology/group/external.d.ts +1 -1
- package/dist/ontology/group/external.d.ts.map +1 -1
- package/dist/ontology/group/writer.d.ts +1 -1
- package/dist/ontology/group/writer.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +14 -26
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts.map +1 -1
- package/dist/ranger/active.d.ts +1 -1
- package/dist/ranger/active.d.ts.map +1 -1
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +16 -100
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/external.d.ts +2 -2
- package/dist/ranger/external.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +34 -270
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/range.d.ts +1 -1
- package/dist/ranger/range.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/util/retrieve.d.ts.map +1 -1
- package/dist/util/zod.d.ts.map +1 -1
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/external.d.ts +1 -1
- package/dist/workspace/external.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +1 -1
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/external.d.ts +1 -1
- package/dist/workspace/lineplot/external.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +2 -2
- package/dist/workspace/lineplot/retriever.d.ts.map +1 -1
- package/dist/workspace/lineplot/writer.d.ts +4 -4
- package/dist/workspace/lineplot/writer.d.ts.map +1 -1
- package/dist/workspace/payload.d.ts +6 -4
- package/dist/workspace/payload.d.ts.map +1 -1
- package/dist/workspace/retriever.d.ts.map +1 -1
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/external.d.ts +1 -1
- package/dist/workspace/schematic/external.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +2 -2
- package/dist/workspace/schematic/retriever.d.ts +1 -1
- package/dist/workspace/schematic/retriever.d.ts.map +1 -1
- package/dist/workspace/schematic/writer.d.ts +4 -4
- package/dist/workspace/schematic/writer.d.ts.map +1 -1
- package/dist/workspace/writer.d.ts +7 -5
- package/dist/workspace/writer.d.ts.map +1 -1
- package/eslint.config.js +12 -0
- package/examples/node/basicReadWrite.js +11 -2
- package/examples/node/liveStream.js +13 -4
- package/examples/node/seriesAndFrames.js +12 -3
- package/examples/node/streamWrite.js +15 -6
- package/package.json +11 -8
- package/src/auth/auth.spec.ts +7 -6
- package/src/auth/auth.ts +17 -13
- package/src/auth/index.ts +1 -1
- package/src/channel/batchRetriever.spec.ts +16 -5
- package/src/channel/channel.spec.ts +42 -4
- package/src/channel/client.ts +26 -9
- package/src/channel/creator.ts +2 -2
- package/src/channel/external.ts +2 -2
- package/src/channel/index.ts +1 -1
- package/src/channel/payload.ts +3 -1
- package/src/channel/retriever.ts +6 -4
- package/src/channel/writer.ts +23 -4
- package/src/client.ts +5 -3
- package/src/connection/checker.ts +1 -1
- package/src/connection/connection.spec.ts +1 -1
- package/src/connection/index.ts +1 -1
- package/src/control/client.ts +17 -0
- package/src/control/external.ts +2 -2
- package/src/control/index.ts +1 -1
- package/src/control/state.spec.ts +2 -3
- package/src/control/state.ts +20 -84
- package/src/errors.ts +18 -7
- package/src/framer/adapter.spec.ts +9 -0
- package/src/framer/adapter.ts +3 -3
- package/src/framer/client.spec.ts +1 -1
- package/src/framer/client.ts +30 -12
- package/src/framer/deleter.spec.ts +129 -0
- package/src/framer/deleter.ts +49 -0
- package/src/framer/external.ts +1 -1
- package/src/framer/frame.spec.ts +1 -1
- package/src/framer/frame.ts +14 -14
- package/src/framer/index.ts +1 -1
- package/src/framer/iterator.spec.ts +2 -2
- package/src/framer/iterator.ts +2 -2
- package/src/framer/streamProxy.ts +2 -4
- package/src/framer/streamer.spec.ts +2 -2
- package/src/framer/streamer.ts +6 -5
- package/src/framer/writer.spec.ts +18 -1
- package/src/framer/writer.ts +19 -27
- package/src/hardware/device/client.ts +2 -2
- package/src/hardware/device/index.ts +1 -1
- package/src/hardware/external.ts +1 -1
- package/src/hardware/index.ts +1 -1
- package/src/hardware/rack/rack.spec.ts +1 -1
- package/src/hardware/task/client.ts +3 -3
- package/src/hardware/task/task.spec.ts +2 -2
- package/src/index.ts +26 -25
- package/src/label/client.ts +2 -2
- package/src/label/external.ts +3 -3
- package/src/label/index.ts +1 -1
- package/src/label/label.spec.ts +1 -1
- package/src/label/payload.ts +1 -1
- package/src/label/retriever.ts +1 -1
- package/src/label/writer.ts +1 -1
- package/src/ontology/client.ts +7 -7
- package/src/ontology/external.ts +1 -1
- package/src/ontology/group/client.ts +3 -3
- package/src/ontology/group/external.ts +2 -2
- package/src/ontology/group/group.spec.ts +2 -2
- package/src/ontology/group/group.ts +1 -1
- package/src/ontology/group/index.ts +1 -1
- package/src/ontology/group/payload.ts +1 -1
- package/src/ontology/group/writer.ts +22 -6
- package/src/ontology/index.ts +1 -1
- package/src/ontology/ontology.spec.ts +2 -2
- package/src/ontology/payload.ts +3 -3
- package/src/ontology/writer.ts +2 -2
- package/src/ranger/active.ts +2 -2
- package/src/ranger/alias.ts +2 -2
- package/src/ranger/client.ts +15 -16
- package/src/ranger/external.ts +3 -3
- package/src/ranger/index.ts +1 -1
- package/src/ranger/kv.ts +2 -2
- package/src/ranger/payload.ts +1 -1
- package/src/ranger/range.ts +2 -2
- package/src/ranger/ranger.spec.ts +1 -1
- package/src/ranger/writer.ts +3 -3
- package/src/setupspecs.ts +1 -1
- package/src/signals/external.ts +1 -1
- package/src/signals/index.ts +1 -1
- package/src/signals/observable.ts +1 -1
- package/src/transport.ts +2 -2
- package/src/user/index.ts +1 -1
- package/src/user/payload.ts +1 -1
- package/src/util/retrieve.spec.ts +1 -1
- package/src/util/retrieve.ts +1 -1
- package/src/util/telem.ts +1 -1
- package/src/util/zod.ts +9 -0
- package/src/vite-env.d.ts +2 -2
- package/src/workspace/client.ts +2 -2
- package/src/workspace/external.ts +2 -2
- package/src/workspace/index.ts +1 -1
- package/src/workspace/lineplot/client.ts +2 -2
- package/src/workspace/lineplot/external.ts +2 -2
- package/src/workspace/lineplot/index.ts +1 -1
- package/src/workspace/lineplot/linePlot.spec.ts +2 -2
- package/src/workspace/lineplot/payload.ts +1 -1
- package/src/workspace/lineplot/retriever.ts +4 -10
- package/src/workspace/lineplot/writer.ts +4 -4
- package/src/workspace/payload.ts +3 -6
- package/src/workspace/retriever.ts +4 -8
- package/src/workspace/schematic/client.ts +2 -2
- package/src/workspace/schematic/external.ts +2 -2
- package/src/workspace/schematic/index.ts +1 -1
- package/src/workspace/schematic/payload.ts +1 -1
- package/src/workspace/schematic/retriever.ts +17 -18
- package/src/workspace/schematic/schematic.spec.ts +2 -2
- package/src/workspace/schematic/writer.ts +5 -5
- package/src/workspace/workspace.spec.ts +2 -2
- package/src/workspace/writer.ts +3 -3
- package/vite.config.ts +3 -4
- package/.eslintrc.cjs +0 -18
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/control/authority.d.ts +0 -8
- package/dist/control/authority.d.ts.map +0 -1
- package/src/control/authority.ts +0 -26
package/dist/client.cjs
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
"use strict";var td=Object.defineProperty;var sd=(s,e,t)=>e in s?td(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var d=(s,e,t)=>(sd(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("zod");var nd=Object.defineProperty,rd=(s,e,t)=>e in s?nd(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,le=(s,e,t)=>(rd(s,typeof e!="symbol"?e+"":e,t),t),Pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},sa={};Object.defineProperty(sa,"__esModule",{value:!0});function ad(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}sa.default=ad;var na={};Object.defineProperty(na,"__esModule",{value:!0});function id(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}na.default=id;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});function od(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}ra.default=od;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});function cd(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Pi.default=cd;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});function ud(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Mi.default=ud;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});function ld(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Di.default=ld;var Li={};Object.defineProperty(Li,"__esModule",{value:!0});function dd(s){if(s===void 0&&(s=""),!s)return"";var e=String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,r){return n+"_"+r.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Li.default=dd;var Ui={};Object.defineProperty(Ui,"__esModule",{value:!0});function hd(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,r){return t+n.charAt(0).toUpperCase()+n.slice(1)+r}):""}Ui.default=hd;var aa={};Object.defineProperty(aa,"__esModule",{value:!0});function pd(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}aa.default=pd;var Bi={},es={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.belongToTypes=s.isValidObject=s.isArrayObject=s.validateOptions=s.DefaultOption=void 0,s.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},s.validateOptions=function(e){return e===void 0&&(e=s.DefaultOption),e.recursive==null?e=s.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},s.isArrayObject=function(e){return e!=null&&Array.isArray(e)},s.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},s.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(es);var fd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Bi,"__esModule",{value:!0});var at=es;function Kn(s,e){if(e===void 0&&(e=at.DefaultOption),!at.isValidObject(s))return null;e=at.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toLowerCase();e.recursive&&(at.isValidObject(r)?at.belongToTypes(r,e.keepTypesOnRecursion)||(r=Kn(r,e)):e.recursiveInArray&&at.isArrayObject(r)&&(r=fd(r).map(function(i){var o=i;if(at.isValidObject(i))at.belongToTypes(o,e.keepTypesOnRecursion)||(o=Kn(i,e));else if(at.isArrayObject(i)){var u=Kn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Bi.default=Kn;var qi={},md=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(qi,"__esModule",{value:!0});var it=es;function Wn(s,e){if(e===void 0&&(e=it.DefaultOption),!it.isValidObject(s))return null;e=it.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toUpperCase();e.recursive&&(it.isValidObject(r)?it.belongToTypes(r,e.keepTypesOnRecursion)||(r=Wn(r,e)):e.recursiveInArray&&it.isArrayObject(r)&&(r=md(r).map(function(i){var o=i;if(it.isValidObject(i))it.belongToTypes(o,e.keepTypesOnRecursion)||(o=Wn(i,e));else if(it.isArrayObject(i)){var u=Wn({key:i},e);o=u.key}return o}))),t[a]=r}),t}qi.default=Wn;var Vi={},yd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Vi,"__esModule",{value:!0});var ot=es,gd=sa;function Fn(s,e){if(e===void 0&&(e=ot.DefaultOption),!ot.isValidObject(s))return null;e=ot.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=gd.default(n);e.recursive&&(ot.isValidObject(r)?ot.belongToTypes(r,e.keepTypesOnRecursion)||(r=Fn(r,e)):e.recursiveInArray&&ot.isArrayObject(r)&&(r=yd(r).map(function(i){var o=i;if(ot.isValidObject(i))ot.belongToTypes(o,e.keepTypesOnRecursion)||(o=Fn(i,e));else if(ot.isArrayObject(i)){var u=Fn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Vi.default=Fn;var Ki={},vd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Ki,"__esModule",{value:!0});var ct=es,wd=na;function Yn(s,e){if(e===void 0&&(e=ct.DefaultOption),!ct.isValidObject(s))return null;e=ct.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=wd.default(n);e.recursive&&(ct.isValidObject(r)?ct.belongToTypes(r,e.keepTypesOnRecursion)||(r=Yn(r,e)):e.recursiveInArray&&ct.isArrayObject(r)&&(r=vd(r).map(function(i){var o=i;if(ct.isValidObject(i))ct.belongToTypes(o,e.keepTypesOnRecursion)||(o=Yn(i,e));else if(ct.isArrayObject(i)){var u=Yn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Ki.default=Yn;var Wi={},bd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Wi,"__esModule",{value:!0});var ut=es,_d=ra;function Jn(s,e){if(e===void 0&&(e=ut.DefaultOption),!ut.isValidObject(s))return null;e=ut.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=_d.default(n);e.recursive&&(ut.isValidObject(r)?ut.belongToTypes(r,e.keepTypesOnRecursion)||(r=Jn(r,e)):e.recursiveInArray&&ut.isArrayObject(r)&&(r=bd(r).map(function(i){var o=i;if(ut.isValidObject(i))ut.belongToTypes(o,e.keepTypesOnRecursion)||(o=Jn(i,e));else if(ut.isArrayObject(i)){var u=Jn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Wi.default=Jn;var Fi={},kd=Pe&&Pe.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(Fi,"__esModule",{value:!0});var lt=es,Od=aa;function Gn(s,e){if(e===void 0&&(e=lt.DefaultOption),!lt.isValidObject(s))return null;e=lt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Od.default(n);e.recursive&&(lt.isValidObject(r)?lt.belongToTypes(r,e.keepTypesOnRecursion)||(r=Gn(r,e)):e.recursiveInArray&<.isArrayObject(r)&&(r=kd(r).map(function(i){var o=i;if(lt.isValidObject(i))lt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Gn(i,e));else if(lt.isArrayObject(i)){var u=Gn({key:i},e);o=u.key}return o}))),t[a]=r}),t}Fi.default=Gn;Object.defineProperty(F,"__esModule",{value:!0});F.kebabKeys=F.pascalKeys=F.snakeKeys=F.camelKeys=F.upperKeys=F.lowerKeys=F.toLowerCase=F.toUpperCase=F.toKebabCase=F.toHeaderCase=F.toSentenceCase=F.toTextCase=F.toPathCase=F.toDotCase=F.toPascalCase=F.toSnakeCase=F.toCamelCase=void 0;var ac=sa;F.toCamelCase=ac.default;var ic=na;F.toSnakeCase=ic.default;var oc=ra;F.toPascalCase=oc.default;var cc=Pi;F.toDotCase=cc.default;var uc=Mi;F.toPathCase=uc.default;var lc=Di;F.toTextCase=lc.default;var dc=Li;F.toSentenceCase=dc.default;var hc=Ui;F.toHeaderCase=hc.default;var pc=aa;F.toKebabCase=pc.default;var fc=Bi;F.lowerKeys=fc.default;var mc=qi;F.upperKeys=mc.default;var yc=Vi;F.camelKeys=yc.default;var gc=Ki;F.snakeKeys=gc.default;var vc=Wi;F.pascalKeys=vc.default;var wc=Fi;F.kebabKeys=wc.default;var bc=function(s){return String(s||"").toLowerCase()};F.toLowerCase=bc;var _c=function(s){return String(s||"").toUpperCase()};F.toUpperCase=_c;var Td={toCamelCase:ac.default,toSnakeCase:ic.default,toPascalCase:oc.default,toDotCase:cc.default,toPathCase:uc.default,toTextCase:lc.default,toSentenceCase:dc.default,toHeaderCase:hc.default,toKebabCase:pc.default,toUpperCase:_c,toLowerCase:bc,lowerKeys:fc.default,upperKeys:mc.default,camelKeys:yc.default,snakeKeys:gc.default,pascalKeys:vc.default,kebabKeys:wc.default};F.default=Td;var kc=F;const Oc={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},xd=s=>kc.snakeKeys(s,Oc),Sd=s=>kc.camelKeys(s,Oc);var Q;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(Q||(Q={}));var Ha;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ha||(Ha={}));const O=Q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zt=s=>{switch(typeof s){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(s)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(s)?O.array:s===null?O.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?O.promise:typeof Map<"u"&&s instanceof Map?O.map:typeof Set<"u"&&s instanceof Set?O.set:typeof Date<"u"&&s instanceof Date?O.date:O.object;default:return O.unknown}},w=Q.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ed=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let qe=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};qe.create=s=>new qe(s);const Ms=(s,e)=>{let t;switch(s.code){case w.invalid_type:s.received===O.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,Q.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${Q.joinValues(s.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Q.joinValues(s.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${Q.joinValues(s.options)}, received '${s.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:Q.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case w.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case w.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,Q.assertNever(s)}return{message:t}};let Tc=Ms;function Nd(s){Tc=s}function yr(){return Tc}const gr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},Id=[];function S(s,e){const t=gr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,yr(),Ms].filter(n=>!!n)});s.common.issues.push(t)}let Ce=class xc{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return M;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return xc.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return M;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const M=Object.freeze({status:"aborted"}),Sc=s=>({status:"dirty",value:s}),Ne=s=>({status:"valid",value:s}),Xa=s=>s.status==="aborted",Qa=s=>s.status==="dirty",Ds=s=>s.status==="valid",vr=s=>typeof Promise<"u"&&s instanceof Promise;var I;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));let st=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const So=(s,e)=>{if(Ds(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new qe(s.common.issues);return this._error=t,this._error}}};function U(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let V=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ce,ctx:{common:e.parent.common,data:e.data,parsedType:Zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(vr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zt(e)},a=this._parseSync({data:e,path:r.path,parent:r});return So(r,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Zt(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(vr(r)?r:Promise.resolve(r));return So(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:w.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Fe({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return kt.create(this,this._def)}nullable(){return Ft.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Wt.create(this,this._def)}promise(){return ds.create(this,this._def)}or(e){return Ws.create([this,e],this._def)}and(e){return Fs.create(this,e,this._def)}transform(e){return new Fe({...U(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Hs({...U(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Cc({typeName:$.ZodBranded,type:this,...U(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Or({...U(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return jn.create(this,e)}readonly(){return xr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Zd=/^c[^\s-]{8,}$/i,Ad=/^[a-z][a-z0-9]*$/,Cd=/^[0-9A-HJKMNP-TV-Z]{26}$/,$d=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jd=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ia;const Rd=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Pd=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Md=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Dd(s,e){return!!((e==="v4"||!e)&&Rd.test(s)||(e==="v6"||!e)&&Pd.test(s))}let us=class Es extends V{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.string,received:r.parsedType}),M}const t=new Ce;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?S(n,{code:w.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&S(n,{code:w.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")jd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"email",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")Ia||(Ia=new RegExp(zd,"u")),Ia.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"emoji",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")$d.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"uuid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")Zd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")Ad.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"cuid2",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")Cd.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ulid",code:w.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),S(n,{validation:"url",code:w.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"regex",code:w.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?Md(r).test(e.data)||(n=this._getOrReturnCtx(e,n),S(n,{code:w.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?Dd(e.data,r.version)||(n=this._getOrReturnCtx(e,n),S(n,{validation:"ip",code:w.invalid_string,message:r.message}),t.dirty()):Q.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:w.invalid_string,...I.errToObj(n)})}_addCheck(e){return new Es({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...I.errToObj(e)})}url(e){return this._addCheck({kind:"url",...I.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...I.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...I.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...I.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...I.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...I.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...I.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...I.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...I.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...I.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...I.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...I.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...I.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...I.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...I.errToObj(t)})}nonempty(e){return this.min(1,I.errToObj(e))}trim(){return new Es({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Es({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Es({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};us.create=s=>{var e;return new us({checks:[],typeName:$.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...U(s)})};function Ld(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let Ls=class ei extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.number,received:r.parsedType}),M}let t;const n=new Ce;for(const r of this._def.checks)r.kind==="int"?Q.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?Ld(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_finite,message:r.message}),n.dirty()):Q.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,n,r){return new ei({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:I.toString(r)}]})}_addCheck(e){return new ei({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:I.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:I.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Q.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Ls.create=s=>new Ls({checks:[],typeName:$.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...U(s)});let Us=class ti extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==O.bigint){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.bigint,received:r.parsedType}),M}let t;const n=new Ce;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Q.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,n,r){return new ti({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:I.toString(r)}]})}_addCheck(e){return new ti({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Us.create=s=>{var e;return new Us({checks:[],typeName:$.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...U(s)})};let Bs=class extends V{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.boolean,received:t.parsedType}),M}return Ne(e.data)}};Bs.create=s=>new Bs({typeName:$.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...U(s)});let qs=class Ec extends V{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_type,expected:O.date,received:r.parsedType}),M}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return S(r,{code:w.invalid_date}),M}const t=new Ce;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),S(n,{code:w.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):Q.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ec({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};qs.create=s=>new qs({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:$.ZodDate,...U(s)});class wr extends V{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.symbol,received:t.parsedType}),M}return Ne(e.data)}}wr.create=s=>new wr({typeName:$.ZodSymbol,...U(s)});let Vs=class extends V{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.undefined,received:t.parsedType}),M}return Ne(e.data)}};Vs.create=s=>new Vs({typeName:$.ZodUndefined,...U(s)});let Ks=class extends V{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.null,received:t.parsedType}),M}return Ne(e.data)}};Ks.create=s=>new Ks({typeName:$.ZodNull,...U(s)});let ls=class extends V{constructor(){super(...arguments),this._any=!0}_parse(e){return Ne(e.data)}};ls.create=s=>new ls({typeName:$.ZodAny,...U(s)});let Ut=class extends V{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ne(e.data)}};Ut.create=s=>new Ut({typeName:$.ZodUnknown,...U(s)});let xt=class extends V{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.never,received:t.parsedType}),M}};xt.create=s=>new xt({typeName:$.ZodNever,...U(s)});class br extends V{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.void,received:t.parsedType}),M}return Ne(e.data)}}br.create=s=>new br({typeName:$.ZodVoid,...U(s)});let Wt=class Hn extends V{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==O.array)return S(t,{code:w.invalid_type,expected:O.array,received:t.parsedType}),M;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(S(t,{code:i?w.too_big:w.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(S(t,{code:w.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(S(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new st(t,i,t.path,o)))).then(i=>Ce.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new st(t,i,t.path,o)));return Ce.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Hn({...this._def,minLength:{value:e,message:I.toString(t)}})}max(e,t){return new Hn({...this._def,maxLength:{value:e,message:I.toString(t)}})}length(e,t){return new Hn({...this._def,exactLength:{value:e,message:I.toString(t)}})}nonempty(e){return this.min(1,e)}};Wt.create=(s,e)=>new Wt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...U(e)});function ns(s){if(s instanceof Me){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=kt.create(ns(n))}return new Me({...s._def,shape:()=>e})}else return s instanceof Wt?new Wt({...s._def,type:ns(s.element)}):s instanceof kt?kt.create(ns(s.unwrap())):s instanceof Ft?Ft.create(ns(s.unwrap())):s instanceof $t?$t.create(s.items.map(e=>ns(e))):s}let Me=class Ue extends V{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Q.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const u=this._getOrReturnCtx(e);return S(u,{code:w.invalid_type,expected:O.object,received:u.parsedType}),M}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof xt&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new st(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof xt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(S(n,{code:w.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new st(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>Ce.mergeObjectSync(t,u)):Ce.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return I.errToObj,new Ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=I.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Ue({...this._def,unknownKeys:"strip"})}passthrough(){return new Ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ue({...this._def,catchall:e})}pick(e){const t={};return Q.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ue({...this._def,shape:()=>t})}omit(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ue({...this._def,shape:()=>t})}deepPartial(){return ns(this)}partial(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new Ue({...this._def,shape:()=>t})}required(e){const t={};return Q.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof kt;)r=r._def.innerType;t[n]=r}}),new Ue({...this._def,shape:()=>t})}keyof(){return Ac(Q.objectKeys(this.shape))}};Me.create=(s,e)=>new Me({shape:()=>s,unknownKeys:"strip",catchall:xt.create(),typeName:$.ZodObject,...U(e)});Me.strictCreate=(s,e)=>new Me({shape:()=>s,unknownKeys:"strict",catchall:xt.create(),typeName:$.ZodObject,...U(e)});Me.lazycreate=(s,e)=>new Me({shape:s,unknownKeys:"strip",catchall:xt.create(),typeName:$.ZodObject,...U(e)});let Ws=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new qe(o.ctx.common.issues));return S(t,{code:w.invalid_union,unionErrors:i}),M}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new qe(u));return S(t,{code:w.invalid_union,unionErrors:o}),M}}get options(){return this._def.options}};Ws.create=(s,e)=>new Ws({options:s,typeName:$.ZodUnion,...U(e)});const Xn=s=>s instanceof Ys?Xn(s.schema):s instanceof Fe?Xn(s.innerType()):s instanceof Js?[s.value]:s instanceof $n?s.options:s instanceof Gs?Object.keys(s.enum):s instanceof Hs?Xn(s._def.innerType):s instanceof Vs?[void 0]:s instanceof Ks?[null]:null;class ia extends V{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:w.invalid_type,expected:O.object,received:t.parsedType}),M;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(S(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),M)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=Xn(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ia({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...U(n)})}}function si(s,e){const t=Zt(s),n=Zt(e);if(s===e)return{valid:!0,data:s};if(t===O.object&&n===O.object){const r=Q.objectKeys(e),a=Q.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=si(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===O.array&&n===O.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=si(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===O.date&&n===O.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let Fs=class extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Xa(a)||Xa(i))return M;const o=si(a.value,i.value);return o.valid?((Qa(a)||Qa(i))&&t.dirty(),{status:t.value,value:o.data}):(S(n,{code:w.invalid_intersection_types}),M)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Fs.create=(s,e,t)=>new Fs({left:s,right:e,typeName:$.ZodIntersection,...U(t)});let $t=class Nc extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.array)return S(n,{code:w.invalid_type,expected:O.array,received:n.parsedType}),M;if(n.data.length<this._def.items.length)return S(n,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&n.data.length>this._def.items.length&&(S(n,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new st(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>Ce.mergeArray(t,a)):Ce.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Nc({...this._def,rest:e})}};$t.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $t({items:s,typeName:$.ZodTuple,rest:null,...U(e)})};let Ic=class ni extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.object)return S(n,{code:w.invalid_type,expected:O.object,received:n.parsedType}),M;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new st(n,o,n.path,o)),value:i._parse(new st(n,n.data[o],n.path,o))});return n.common.async?Ce.mergeObjectAsync(t,r):Ce.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof V?new ni({keyType:e,valueType:t,typeName:$.ZodRecord,...U(n)}):new ni({keyType:us.create(),valueType:e,typeName:$.ZodRecord,...U(t)})}};class _r extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.map)return S(n,{code:w.invalid_type,expected:O.map,received:n.parsedType}),M;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new st(n,o,n.path,[l,"key"])),value:a._parse(new st(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}_r.create=(s,e,t)=>new _r({valueType:e,keyType:s,typeName:$.ZodMap,...U(t)});let kr=class ri extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==O.set)return S(n,{code:w.invalid_type,expected:O.set,received:n.parsedType}),M;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(S(n,{code:w.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(S(n,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return M;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new st(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new ri({...this._def,minSize:{value:e,message:I.toString(t)}})}max(e,t){return new ri({...this._def,maxSize:{value:e,message:I.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};kr.create=(s,e)=>new kr({valueType:s,minSize:null,maxSize:null,typeName:$.ZodSet,...U(e)});let Zc=class Qn extends V{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:w.invalid_type,expected:O.function,received:t.parsedType}),M;function n(o,u){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Ms].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:u}})}function r(o,u){return gr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yr(),Ms].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ds){const o=this;return Ne(async function(...u){const l=new qe([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ne(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new qe([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new qe([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Qn({...this._def,args:$t.create(e).rest(Ut.create())})}returns(e){return new Qn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Qn({args:e||$t.create([]).rest(Ut.create()),returns:t||Ut.create(),typeName:$.ZodFunction,...U(n)})}},Ys=class extends V{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ys.create=(s,e)=>new Ys({getter:s,typeName:$.ZodLazy,...U(e)});let Js=class extends V{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:e.data}}get value(){return this._def.value}};Js.create=(s,e)=>new Js({value:s,typeName:$.ZodLiteral,...U(e)});function Ac(s,e){return new $n({values:s,typeName:$.ZodEnum,...U(e)})}let $n=class ai extends V{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{expected:Q.joinValues(n),received:t.parsedType,code:w.invalid_type}),M}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return S(t,{received:t.data,code:w.invalid_enum_value,options:n}),M}return Ne(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return ai.create(e)}exclude(e){return ai.create(this.options.filter(t=>!e.includes(t)))}};$n.create=Ac;let Gs=class extends V{_parse(e){const t=Q.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==O.string&&n.parsedType!==O.number){const r=Q.objectValues(t);return S(n,{expected:Q.joinValues(r),received:n.parsedType,code:w.invalid_type}),M}if(t.indexOf(e.data)===-1){const r=Q.objectValues(t);return S(n,{received:n.data,code:w.invalid_enum_value,options:r}),M}return Ne(e.data)}get enum(){return this._def.values}};Gs.create=(s,e)=>new Gs({values:s,typeName:$.ZodNativeEnum,...U(e)});let ds=class extends V{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:w.invalid_type,expected:O.promise,received:t.parsedType}),M;const n=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return Ne(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ds.create=(s,e)=>new ds({type:s,typeName:$.ZodPromise,...U(e)});let Fe=class extends V{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{S(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(r.type==="refinement"){const i=o=>{const u=r.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ds(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Ds(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Q.assertNever(r)}};Fe.create=(s,e,t)=>new Fe({schema:s,typeName:$.ZodEffects,effect:e,...U(t)});Fe.createWithPreprocess=(s,e,t)=>new Fe({schema:e,effect:{type:"preprocess",transform:s},typeName:$.ZodEffects,...U(t)});let kt=class extends V{_parse(e){return this._getType(e)===O.undefined?Ne(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};kt.create=(s,e)=>new kt({innerType:s,typeName:$.ZodOptional,...U(e)});let Ft=class extends V{_parse(e){return this._getType(e)===O.null?Ne(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ft.create=(s,e)=>new Ft({innerType:s,typeName:$.ZodNullable,...U(e)});let Hs=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===O.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Hs.create=(s,e)=>new Hs({innerType:s,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...U(e)});class Or extends V{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return vr(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qe(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new qe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Or.create=(s,e)=>new Or({innerType:s,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...U(e)});class Tr extends V{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.nan,received:t.parsedType}),M}return{status:"valid",value:e.data}}}Tr.create=s=>new Tr({typeName:$.ZodNaN,...U(s)});const Ud=Symbol("zod_brand");class Cc extends V{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class jn extends V{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?M:r.status==="dirty"?(t.dirty(),Sc(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?M:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new jn({in:e,out:t,typeName:$.ZodPipeline})}}class xr extends V{_parse(e){const t=this._def.innerType._parse(e);return Ds(t)&&(t.value=Object.freeze(t.value)),t}}xr.create=(s,e)=>new xr({innerType:s,typeName:$.ZodReadonly,...U(e)});const $c=(s,e={},t)=>s?ls.create().superRefine((n,r)=>{var a,i;if(!s(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):ls.create(),Bd={object:Me.lazycreate};var $;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})($||($={}));const qd=(s,e={message:`Input not instance of ${s.name}`})=>$c(t=>t instanceof s,e),jc=us.create,zc=Ls.create,Vd=Tr.create,Kd=Us.create,Rc=Bs.create,Wd=qs.create,Fd=wr.create,Yd=Vs.create,Jd=Ks.create,Gd=ls.create,Hd=Ut.create,Xd=xt.create,Qd=br.create,eh=Wt.create,th=Me.create,sh=Me.strictCreate,nh=Ws.create,rh=ia.create,ah=Fs.create,ih=$t.create,oh=Ic.create,ch=_r.create,uh=kr.create,lh=Zc.create,dh=Ys.create,hh=Js.create,ph=$n.create,fh=Gs.create,mh=ds.create,Eo=Fe.create,yh=kt.create,gh=Ft.create,vh=Fe.createWithPreprocess,wh=jn.create,bh=()=>jc().optional(),_h=()=>zc().optional(),kh=()=>Rc().optional(),Oh={string:s=>us.create({...s,coerce:!0}),number:s=>Ls.create({...s,coerce:!0}),boolean:s=>Bs.create({...s,coerce:!0}),bigint:s=>Us.create({...s,coerce:!0}),date:s=>qs.create({...s,coerce:!0})},Th=M;var p=Object.freeze({__proto__:null,defaultErrorMap:Ms,setErrorMap:Nd,getErrorMap:yr,makeIssue:gr,EMPTY_PATH:Id,addIssueToContext:S,ParseStatus:Ce,INVALID:M,DIRTY:Sc,OK:Ne,isAborted:Xa,isDirty:Qa,isValid:Ds,isAsync:vr,get util(){return Q},get objectUtil(){return Ha},ZodParsedType:O,getParsedType:Zt,ZodType:V,ZodString:us,ZodNumber:Ls,ZodBigInt:Us,ZodBoolean:Bs,ZodDate:qs,ZodSymbol:wr,ZodUndefined:Vs,ZodNull:Ks,ZodAny:ls,ZodUnknown:Ut,ZodNever:xt,ZodVoid:br,ZodArray:Wt,ZodObject:Me,ZodUnion:Ws,ZodDiscriminatedUnion:ia,ZodIntersection:Fs,ZodTuple:$t,ZodRecord:Ic,ZodMap:_r,ZodSet:kr,ZodFunction:Zc,ZodLazy:Ys,ZodLiteral:Js,ZodEnum:$n,ZodNativeEnum:Gs,ZodPromise:ds,ZodEffects:Fe,ZodTransformer:Fe,ZodOptional:kt,ZodNullable:Ft,ZodDefault:Hs,ZodCatch:Or,ZodNaN:Tr,BRAND:Ud,ZodBranded:Cc,ZodPipeline:jn,ZodReadonly:xr,custom:$c,Schema:V,ZodSchema:V,late:Bd,get ZodFirstPartyTypeKind(){return $},coerce:Oh,any:Gd,array:eh,bigint:Kd,boolean:Rc,date:Wd,discriminatedUnion:rh,effect:Eo,enum:ph,function:lh,instanceof:qd,intersection:ah,lazy:dh,literal:hh,map:ch,nan:Vd,nativeEnum:fh,never:Xd,null:Jd,nullable:gh,number:zc,object:th,oboolean:kh,onumber:_h,optional:yh,ostring:bh,pipeline:wh,preprocess:vh,promise:mh,record:oh,set:uh,strictObject:sh,string:jc,symbol:Fd,transformer:Eo,tuple:ih,undefined:Yd,union:nh,unknown:Hd,void:Qd,NEVER:Th,ZodIssueCode:w,quotelessJson:Ed,ZodError:qe});const oa=p.tuple([p.number(),p.number()]);p.tuple([p.bigint(),p.bigint()]);const Pc=p.object({width:p.number(),height:p.number()}),xh=p.object({signedWidth:p.number(),signedHeight:p.number()}),Sh=["width","height"];p.enum(Sh);const Eh=["start","center","end"],Nh=["signedWidth","signedHeight"];p.enum(Nh);const Sr=p.object({x:p.number(),y:p.number()}),Ih=p.object({clientX:p.number(),clientY:p.number()}),Zh=["x","y"],Mc=p.enum(Zh),Dc=["top","right","bottom","left"];p.enum(Dc);const Ah=["left","right"],Lc=p.enum(Ah),Ch=["top","bottom"],Uc=p.enum(Ch),Bc=["center"],No=p.enum(Bc),$h=[...Dc,...Bc],qc=p.enum($h);p.enum(Eh);const jh=["first","last"];p.enum(jh);const zh=p.object({lower:p.number(),upper:p.number()}),Rh=p.object({lower:p.bigint(),upper:p.bigint()});p.union([zh,oa]);p.union([Rh,oa]);p.union([Mc,qc]);p.union([Mc,qc,p.instanceof(String)]);const Za=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Io(s);return Io(t)},Io=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s;p.object({x:Lc.or(No),y:Uc.or(No)});const Ph=p.object({x:Lc,y:Uc}),Mh=Object.freeze({x:"left",y:"top"}),Dh=(s,e)=>s.x===e.x&&s.y===e.y,Zo=p.union([p.number(),Sr,oa,Pc,xh,Ih]),Lh=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},Ao=Object.freeze({x:0,y:0}),Bn=p.union([p.number(),p.string()]);p.object({top:Bn,left:Bn,width:Bn,height:Bn});p.object({left:p.number(),top:p.number(),right:p.number(),bottom:p.number()});p.object({one:Sr,two:Sr,root:Ph});const Yi=(s,e,t=0,n=0,r)=>{const a={one:{...Ao},two:{...Ao},root:r??Mh};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Aa=s=>{const e=Yi(s);return{lower:e.one.x,upper:e.two.x}},Ca=s=>{const e=Yi(s);return{lower:e.one.y,upper:e.two.y}},Uh=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,Bh=p.object({signedWidth:p.number(),signedHeight:p.number()});p.union([Pc,Bh,Sr,oa]);var qh=Object.defineProperty,Vh=(s,e,t)=>e in s?qh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,bt=(s,e,t)=>(Vh(s,typeof e!="symbol"?e+"":e,t),t);const Kh=(s,e,t)=>(e!=null&&(s=Math.max(s,e)),t!=null&&(s=Math.min(s,t)),s);p.object({offset:Zo,scale:Zo});const Wh=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],Fh=s=>(e,t,n,r)=>[e,r?n/s:n*s],Yh=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:i,upper:o}=s,u=a-r,l=o-i;if(t==="dimension")return[s,n*(l/u)];const h=(n-r)*(l/u)+i;return[s,h]},Jh=s=>(e,t,n)=>[s,n],Gh=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Hh=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=Kh(n,r,a),[e,n]},ii=class Ns{constructor(){bt(this,"ops",[]),bt(this,"currBounds",null),bt(this,"currType",null),bt(this,"reversed",!1),this.ops=[]}static translate(e){return new Ns().translate(e)}static magnify(e){return new Ns().magnify(e)}static scale(e,t){return new Ns().scale(e,t)}translate(e){const t=this.new(),n=Wh(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Fh(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Za(e,t),r=this.new(),a=Yh(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=Za(e,t),r=this.new(),a=Hh(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=Za(e,t),r=this.new(),a=Jh(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Gh();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Ns;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([i,o])=>r>=i&&r<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}};bt(ii,"IDENTITY",new ii);let Co=ii;const $o=class gt{constructor(e=new Co,t=new Co,n=null){bt(this,"x"),bt(this,"y"),bt(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new gt().translate(e,t)}static translateX(e){return new gt().translateX(e)}static translateY(e){return new gt().translateY(e)}static clamp(e){return new gt().clamp(e)}static magnify(e){return new gt().magnify(e)}static scale(e){return new gt().scale(e)}static reBound(e){return new gt().reBound(e)}translate(e,t){const n=Lh(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Uh(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Dh(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Aa(e)),t.y=t.y.scale(Ca(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Aa(e)),t.y=this.y.reBound(Ca(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Aa(e)),t.y=this.y.clamp(Ca(e)),t}copy(){const e=new gt;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Yi(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};bt($o,"IDENTITY",new $o);var Xh=Object.defineProperty,Qh=(s,e,t)=>e in s?Xh(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e,t)=>(Qh(s,typeof e!="symbol"?e+"":e,t),t);const Vc=(s,e)=>{const t=new we(e);if(![be.DAY,be.HOUR,be.MINUTE,be.SECOND,be.MILLISECOND,be.MICROSECOND,be.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof we?new we(n):new be(n)},ae=class R{constructor(e,t="UTC"){if(k(this,"value"),k(this,"encodeValue",!0),e==null)this.value=R.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*R.MILLISECOND.valueOf();else if(typeof e=="string")this.value=R.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=R.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=R.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=R.MAX:e=R.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new R(BigInt(r.getTime())*R.MILLISECOND.valueOf()).truncate(R.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=R.hours(parseInt(n??"00",10)).add(R.minutes(parseInt(r??"00",10))).add(R.seconds(parseInt(i??"00",10))).add(R.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(R.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return R.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new R(BigInt(n.getTime())*R.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(R.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new be(BigInt(new Date().getTimezoneOffset())*R.MINUTE.valueOf())}static since(e){return new R().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new R(e).valueOf()}span(e){return this.range(e).span}range(e){return new ep(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new R(e).valueOf()}afterEq(e){return this.valueOf()>=new R(e).valueOf()}before(e){return this.valueOf()<new R(e).valueOf()}beforeEq(e){return this.valueOf()<=new R(e).valueOf()}add(e){return new R(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new R(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/R.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Vc(this,e)}get isToday(){return this.truncate(be.DAY).equals(R.now().truncate(be.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new R(new Date)}static max(...e){let t=R.MIN;for(const n of e){const r=new R(n);r.after(t)&&(t=r)}return t}static min(...e){let t=R.MAX;for(const n of e){const r=new R(n);r.before(t)&&(t=r)}return t}static nanoseconds(e){return new R(e)}static microseconds(e){return R.nanoseconds(e*1e3)}static milliseconds(e){return R.microseconds(e*1e3)}static seconds(e){return R.milliseconds(e*1e3)}static minutes(e){return R.seconds(e*60)}static hours(e){return R.minutes(e*60)}static days(e){return R.hours(e*24)}};k(ae,"NANOSECOND",ae.nanoseconds(1)),k(ae,"MICROSECOND",ae.microseconds(1)),k(ae,"MILLISECOND",ae.milliseconds(1)),k(ae,"SECOND",ae.seconds(1)),k(ae,"MINUTE",ae.minutes(1)),k(ae,"HOUR",ae.hours(1)),k(ae,"DAY",ae.days(1)),k(ae,"MAX",new ae((1n<<63n)-1n)),k(ae,"MIN",new ae(0)),k(ae,"ZERO",new ae(0)),k(ae,"z",p.union([p.object({value:p.bigint()}).transform(s=>new ae(s.value)),p.string().transform(s=>new ae(BigInt(s))),p.instanceof(Number).transform(s=>new ae(s)),p.number().transform(s=>new ae(s)),p.instanceof(ae)]));let we=ae;const ie=class ne{constructor(e){k(this,"value"),k(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new ne(e).valueOf()}greaterThan(e){return this.valueOf()>new ne(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ne(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ne(e).valueOf()}remainder(e){return Vc(this,e)}truncate(e){return new ne(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(ne.DAY),t=this.truncate(ne.HOUR),n=this.truncate(ne.MINUTE),r=this.truncate(ne.SECOND),a=this.truncate(ne.MILLISECOND),i=this.truncate(ne.MICROSECOND),o=this.truncate(ne.NANOSECOND),u=e,l=t.sub(e),h=n.sub(t),g=r.sub(n),se=a.sub(r),ye=i.sub(a),ze=o.sub(i);let he="";return u.isZero||(he+=`${u.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),g.isZero||(he+=`${g.seconds}s `),se.isZero||(he+=`${se.milliseconds}ms `),ye.isZero||(he+=`${ye.microseconds}µs `),ze.isZero||(he+=`${ze.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/ne.DAY.valueOf())}get hours(){return Number(this.valueOf()/ne.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/ne.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/ne.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/ne.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/ne.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new ne(e).valueOf()}add(e){return new ne(this.valueOf()+new ne(e).valueOf())}sub(e){return new ne(this.valueOf()-new ne(e).valueOf())}static nanoseconds(e=1){return new ne(e)}static microseconds(e=1){return ne.nanoseconds(e*1e3)}static milliseconds(e=1){return ne.microseconds(e*1e3)}static seconds(e=1){return ne.milliseconds(e*1e3)}static minutes(e){return ne.seconds(e.valueOf()*60)}static hours(e){return ne.minutes(e*60)}static days(e){return ne.hours(e*24)}};k(ie,"NANOSECOND",ie.nanoseconds(1)),k(ie,"MICROSECOND",ie.microseconds(1)),k(ie,"MILLISECOND",ie.milliseconds(1)),k(ie,"SECOND",ie.seconds(1)),k(ie,"MINUTE",ie.minutes(1)),k(ie,"HOUR",ie.hours(1)),k(ie,"DAY",ie.days(1)),k(ie,"MAX",new ie((1n<<63n)-1n)),k(ie,"MIN",new ie(0)),k(ie,"ZERO",new ie(0)),k(ie,"z",p.union([p.object({value:p.bigint()}).transform(s=>new ie(s.value)),p.string().transform(s=>new ie(BigInt(s))),p.instanceof(Number).transform(s=>new ie(s)),p.number().transform(s=>new ie(s)),p.instanceof(ie)]));let be=ie;const qn=class er extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new er(e).valueOf()}get period(){return be.seconds(1/this.valueOf())}sampleCount(e){return new be(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Se(t).valueOf()}span(e){return be.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new er(e)}static khz(e){return er.hz(e*1e3)}};k(qn,"z",p.union([p.number().transform(s=>new qn(s)),p.instanceof(Number).transform(s=>new qn(s)),p.instanceof(qn)]));const ge=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new tp(e*this.valueOf())}};k(ge,"UNKNOWN",new ge(0)),k(ge,"BIT128",new ge(16)),k(ge,"BIT64",new ge(8)),k(ge,"BIT32",new ge(4)),k(ge,"BIT16",new ge(2)),k(ge,"BIT8",new ge(1)),k(ge,"z",p.union([p.number().transform(s=>new ge(s)),p.instanceof(Number).transform(s=>new ge(s)),p.instanceof(ge)]));let Se=ge;const Ge=class tr{constructor(e,t){k(this,"start"),k(this,"end"),typeof e=="object"&&"start"in e?(this.start=new we(e.start),this.end=new we(e.end)):(this.start=new we(e),this.end=new we(t))}get span(){return new be(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new tr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=be.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const r=we.max(n.start,e.start),a=we.min(n.end,e.end);return a.before(r)?!1:new be(a.sub(r)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}contains(e){return e instanceof tr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new tr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};k(Ge,"MAX",new Ge(we.MIN,we.MAX)),k(Ge,"MIN",new Ge(we.MAX,we.MIN)),k(Ge,"ZERO",new Ge(we.ZERO,we.ZERO)),k(Ge,"z",p.union([p.object({start:we.z,end:we.z}).transform(s=>new Ge(s.start,s.end)),p.instanceof(Ge)]));let ep=Ge;const y=class He extends String{constructor(e){if(e instanceof He||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=He.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(He.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=He.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(He.JSON)||this.equals(He.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(He.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=He.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return He.BIG_INT_TYPES.some(e=>e.equals(this))}};k(y,"UNKNOWN",new y("unknown")),k(y,"FLOAT64",new y("float64")),k(y,"FLOAT32",new y("float32")),k(y,"INT64",new y("int64")),k(y,"INT32",new y("int32")),k(y,"INT16",new y("int16")),k(y,"INT8",new y("int8")),k(y,"UINT64",new y("uint64")),k(y,"UINT32",new y("uint32")),k(y,"UINT16",new y("uint16")),k(y,"UINT8",new y("uint8")),k(y,"BOOLEAN",y.UINT8),k(y,"TIMESTAMP",new y("timestamp")),k(y,"UUID",new y("uuid")),k(y,"STRING",new y("string")),k(y,"JSON",new y("json")),k(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),k(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),k(y,"DENSITIES",new Map([[y.UINT8.toString(),Se.BIT8],[y.UINT16.toString(),Se.BIT16],[y.UINT32.toString(),Se.BIT32],[y.UINT64.toString(),Se.BIT64],[y.FLOAT32.toString(),Se.BIT32],[y.FLOAT64.toString(),Se.BIT64],[y.INT8.toString(),Se.BIT8],[y.INT16.toString(),Se.BIT16],[y.INT32.toString(),Se.BIT32],[y.INT64.toString(),Se.BIT64],[y.TIMESTAMP.toString(),Se.BIT64],[y.STRING.toString(),Se.UNKNOWN],[y.JSON.toString(),Se.UNKNOWN],[y.UUID.toString(),Se.BIT128]])),k(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),k(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),k(y,"z",p.union([p.string().transform(s=>new y(s)),p.instanceof(y)]));const _e=class pe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return pe.bytes(this.valueOf()+e.valueOf())}sub(e){return pe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new pe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return pe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/pe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/pe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/pe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/pe.TERABYTE.valueOf()}toString(){const e=this.truncate(pe.TERABYTE),t=this.truncate(pe.GIGABYTE),n=this.truncate(pe.MEGABYTE),r=this.truncate(pe.KILOBYTE),a=this.truncate(pe.BYTE),i=e,o=t.sub(e),u=n.sub(t),l=r.sub(n),h=a.sub(r);let g="";return i.isZero||(g+=`${i.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),u.isZero||(g+=`${u.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!h.isZero||g==="")&&(g+=`${h.valueOf()}B`),g.trim()}static bytes(e=1){return new pe(e)}static kilobytes(e=1){return pe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return pe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return pe.megabytes(e.valueOf()*1e3)}static terabytes(e){return pe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};k(_e,"BYTE",new _e(1)),k(_e,"KILOBYTE",_e.kilobytes(1)),k(_e,"MEGABYTE",_e.megabytes(1)),k(_e,"GIGABYTE",_e.gigabytes(1)),k(_e,"TERABYTE",_e.terabytes(1)),k(_e,"ZERO",new _e(0)),k(_e,"z",p.union([p.number().transform(s=>new _e(s)),p.instanceof(_e)]));let tp=_e;p.union([p.instanceof(Uint8Array),p.instanceof(Uint16Array),p.instanceof(Uint32Array),p.instanceof(BigUint64Array),p.instanceof(Float32Array),p.instanceof(Float64Array),p.instanceof(Int8Array),p.instanceof(Int16Array),p.instanceof(Int32Array),p.instanceof(BigInt64Array)]);p.record(p.union([p.number(),p.string(),p.symbol()]),p.unknown());const sp=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Kc=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",np=Kc(),Wc=["MacOS","Windows","Linux","Docker"],rp=p.enum(Wc);let $a;const ap=()=>{if(typeof window>"u")return;const s=window.navigator.userAgent.toLowerCase();if(s.includes("mac"))return"MacOS";if(s.includes("win"))return"Windows";if(s.includes("linux"))return"Linux"},ip=(s={})=>{const{force:e,default:t}=s;return e??$a??($a=ap(),$a??t)},Fc=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Wc,RUNTIME:np,detect:Kc,getOS:ip,osZ:rp},Symbol.toStringTag,{value:"Module"}));var op=Object.defineProperty,cp=(s,e,t)=>e in s?op(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Is=(s,e,t)=>(cp(s,typeof e!="symbol"?e+"":e,t),t);const up=(...s)=>s.map(Yc).join(""),Yc=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),lp=s=>s.endsWith("/")?s.slice(0,-1):s,dp=(s,e="")=>s===null?"":"?"+Object.entries(s).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&"),oi=class ci{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){Is(this,"protocol"),Is(this,"host"),Is(this,"port"),Is(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Yc(r)}replace(e){return new ci({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new ci({...this,pathPrefix:up(this.path,e)})}toString(){return lp(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Is(oi,"UNKNOWN",new oi({host:"unknown",port:0}));let hp=oi;var pp=Object.defineProperty,fp=(s,e,t)=>e in s?pp(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ja=(s,e,t)=>(fp(s,typeof e!="symbol"?e+"":e,t),t);let mp=class{constructor(){ja(this,"contentType","application/json"),ja(this,"decoder"),ja(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(s){return this.encoder.encode(this.encodeString(s)).buffer}decode(s,e){return this.decodeString(this.decoder.decode(s),e)}decodeString(s,e){const t=Sd(JSON.parse(s));return e!=null?e.parse(t):t}encodeString(s){return JSON.stringify(xd(s),(e,t)=>ArrayBuffer.isView(t)?Array.from(t):sp(t)&&"encode_value"in t?typeof t.value=="bigint"?t.value.toString():t.value:typeof t=="bigint"?t.toString():t)}static registerCustomType(){}};new mp;const yp=p.string().regex(/^\d+\.\d+\.\d+$/);p.object({version:yp});var ee;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(ee||(ee={}));var ui;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(ui||(ui={}));const T=ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=s=>{switch(typeof s){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(s)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(s)?T.array:s===null?T.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?T.promise:typeof Map<"u"&&s instanceof Map?T.map:typeof Set<"u"&&s instanceof Set?T.set:typeof Date<"u"&&s instanceof Date?T.date:T.object;default:return T.unknown}},b=ee.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gp=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let Ve=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ve.create=s=>new Ve(s);const Xs=(s,e)=>{let t;switch(s.code){case b.invalid_type:s.received===T.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case b.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,ee.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:t=`Unrecognized key(s) in object: ${ee.joinValues(s.keys,", ")}`;break;case b.invalid_union:t="Invalid input";break;case b.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ee.joinValues(s.options)}`;break;case b.invalid_enum_value:t=`Invalid enum value. Expected ${ee.joinValues(s.options)}, received '${s.received}'`;break;case b.invalid_arguments:t="Invalid function arguments";break;case b.invalid_return_type:t="Invalid function return type";break;case b.invalid_date:t="Invalid date";break;case b.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:ee.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case b.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case b.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case b.custom:t="Invalid input";break;case b.invalid_intersection_types:t="Intersection results could not be merged";break;case b.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case b.not_finite:t="Number must be finite";break;default:t=e.defaultError,ee.assertNever(s)}return{message:t}};let Jc=Xs;function vp(s){Jc=s}function Er(){return Jc}const Nr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},wp=[];function E(s,e){const t=Nr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Er(),Xs].filter(n=>!!n)});s.common.issues.push(t)}let $e=class Gc{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return D;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return Gc.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return D;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const D=Object.freeze({status:"aborted"}),Hc=s=>({status:"dirty",value:s}),Ie=s=>({status:"valid",value:s}),li=s=>s.status==="aborted",di=s=>s.status==="dirty",Qs=s=>s.status==="valid",Ir=s=>typeof Promise<"u"&&s instanceof Promise;var Z;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Z||(Z={}));let nt=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const jo=(s,e)=>{if(Qs(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ve(s.common.issues);return this._error=t,this._error}}};function B(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let K=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return At(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ir(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},a=this._parseSync({data:e,path:r.path,parent:r});return jo(r,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(Ir(r)?r:Promise.resolve(r));return jo(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:b.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Ye({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ot.create(this,this._def)}nullable(){return Jt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Yt.create(this,this._def)}promise(){return fs.create(this,this._def)}or(e){return on.create([this,e],this._def)}and(e){return cn.create(this,e,this._def)}transform(e){return new Ye({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new hn({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new nu({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new jr({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ji.create(this,e)}readonly(){return Rr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const bp=/^c[^\s-]{8,}$/i,_p=/^[a-z][a-z0-9]*$/,kp=/^[0-9A-HJKMNP-TV-Z]{26}$/,Op=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Tp=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let za;const Sp=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Ep=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Np=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Ip(s,e){return!!((e==="v4"||!e)&&Sp.test(s)||(e==="v6"||!e)&&Ep.test(s))}let hs=class Zs extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.string,received:r.parsedType}),D}const t=new $e;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?E(n,{code:b.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&E(n,{code:b.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")Tp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"email",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")za||(za=new RegExp(xp,"u")),za.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"emoji",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")Op.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"uuid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")bp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")_p.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"cuid2",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")kp.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ulid",code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),E(n,{validation:"url",code:b.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"regex",code:b.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?Np(r).test(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:b.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?Ip(e.data,r.version)||(n=this._getOrReturnCtx(e,n),E(n,{validation:"ip",code:b.invalid_string,message:r.message}),t.dirty()):ee.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:b.invalid_string,...Z.errToObj(n)})}_addCheck(e){return new Zs({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...Z.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Z.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new Zs({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Zs({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Zs({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};hs.create=s=>{var e;return new hs({checks:[],typeName:j.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...B(s)})};function Zp(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let en=class hi extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==T.number){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.number,received:r.parsedType}),D}let t;const n=new $e;for(const r of this._def.checks)r.kind==="int"?ee.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:b.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?Zp(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_finite,message:r.message}),n.dirty()):ee.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,n,r){return new hi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Z.toString(r)}]})}_addCheck(e){return new hi({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ee.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};en.create=s=>new en({checks:[],typeName:j.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...B(s)});let tn=class pi extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==T.bigint){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.bigint,received:r.parsedType}),D}let t;const n=new $e;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),E(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):ee.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,n,r){return new pi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Z.toString(r)}]})}_addCheck(e){return new pi({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};tn.create=s=>{var e;return new tn({checks:[],typeName:j.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...B(s)})};let sn=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.boolean,received:t.parsedType}),D}return Ie(e.data)}};sn.create=s=>new sn({typeName:j.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...B(s)});let nn=class Xc extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_type,expected:T.date,received:r.parsedType}),D}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return E(r,{code:b.invalid_date}),D}const t=new $e;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),E(n,{code:b.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):ee.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Xc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Z.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};nn.create=s=>new nn({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:j.ZodDate,...B(s)});class Zr extends K{_parse(e){if(this._getType(e)!==T.symbol){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.symbol,received:t.parsedType}),D}return Ie(e.data)}}Zr.create=s=>new Zr({typeName:j.ZodSymbol,...B(s)});let rn=class extends K{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.undefined,received:t.parsedType}),D}return Ie(e.data)}};rn.create=s=>new rn({typeName:j.ZodUndefined,...B(s)});let an=class extends K{_parse(e){if(this._getType(e)!==T.null){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.null,received:t.parsedType}),D}return Ie(e.data)}};an.create=s=>new an({typeName:j.ZodNull,...B(s)});let ps=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ie(e.data)}};ps.create=s=>new ps({typeName:j.ZodAny,...B(s)});let Bt=class extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ie(e.data)}};Bt.create=s=>new Bt({typeName:j.ZodUnknown,...B(s)});let St=class extends K{_parse(e){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.never,received:t.parsedType}),D}};St.create=s=>new St({typeName:j.ZodNever,...B(s)});class Ar extends K{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.void,received:t.parsedType}),D}return Ie(e.data)}}Ar.create=s=>new Ar({typeName:j.ZodVoid,...B(s)});let Yt=class sr extends K{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==T.array)return E(t,{code:b.invalid_type,expected:T.array,received:t.parsedType}),D;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(E(t,{code:i?b.too_big:b.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(E(t,{code:b.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(E(t,{code:b.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new nt(t,i,t.path,o)))).then(i=>$e.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new nt(t,i,t.path,o)));return $e.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new sr({...this._def,minLength:{value:e,message:Z.toString(t)}})}max(e,t){return new sr({...this._def,maxLength:{value:e,message:Z.toString(t)}})}length(e,t){return new sr({...this._def,exactLength:{value:e,message:Z.toString(t)}})}nonempty(e){return this.min(1,e)}};Yt.create=(s,e)=>new Yt({type:s,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function rs(s){if(s instanceof De){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=Ot.create(rs(n))}return new De({...s._def,shape:()=>e})}else return s instanceof Yt?new Yt({...s._def,type:rs(s.element)}):s instanceof Ot?Ot.create(rs(s.unwrap())):s instanceof Jt?Jt.create(rs(s.unwrap())):s instanceof jt?jt.create(s.items.map(e=>rs(e))):s}let De=class Be extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ee.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==T.object){const u=this._getOrReturnCtx(e);return E(u,{code:b.invalid_type,expected:T.object,received:u.parsedType}),D}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof St&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new nt(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof St){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(E(n,{code:b.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new nt(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>$e.mergeObjectSync(t,u)):$e.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new Be({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=Z.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Be({...this._def,unknownKeys:"strip"})}passthrough(){return new Be({...this._def,unknownKeys:"passthrough"})}extend(e){return new Be({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Be({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Be({...this._def,catchall:e})}pick(e){const t={};return ee.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}omit(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}deepPartial(){return rs(this)}partial(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new Be({...this._def,shape:()=>t})}required(e){const t={};return ee.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof Ot;)r=r._def.innerType;t[n]=r}}),new Be({...this._def,shape:()=>t})}keyof(){return su(ee.objectKeys(this.shape))}};De.create=(s,e)=>new De({shape:()=>s,unknownKeys:"strip",catchall:St.create(),typeName:j.ZodObject,...B(e)});De.strictCreate=(s,e)=>new De({shape:()=>s,unknownKeys:"strict",catchall:St.create(),typeName:j.ZodObject,...B(e)});De.lazycreate=(s,e)=>new De({shape:s,unknownKeys:"strip",catchall:St.create(),typeName:j.ZodObject,...B(e)});let on=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ve(o.ctx.common.issues));return E(t,{code:b.invalid_union,unionErrors:i}),D}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ve(u));return E(t,{code:b.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};on.create=(s,e)=>new on({options:s,typeName:j.ZodUnion,...B(e)});const nr=s=>s instanceof un?nr(s.schema):s instanceof Ye?nr(s.innerType()):s instanceof ln?[s.value]:s instanceof zn?s.options:s instanceof dn?Object.keys(s.enum):s instanceof hn?nr(s._def.innerType):s instanceof rn?[void 0]:s instanceof an?[null]:null;class ca extends K{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return E(t,{code:b.invalid_type,expected:T.object,received:t.parsedType}),D;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(E(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=nr(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ca({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...B(n)})}}function fi(s,e){const t=At(s),n=At(e);if(s===e)return{valid:!0,data:s};if(t===T.object&&n===T.object){const r=ee.objectKeys(e),a=ee.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=fi(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===T.array&&n===T.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=fi(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===T.date&&n===T.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let cn=class extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(li(a)||li(i))return D;const o=fi(a.value,i.value);return o.valid?((di(a)||di(i))&&t.dirty(),{status:t.value,value:o.data}):(E(n,{code:b.invalid_intersection_types}),D)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};cn.create=(s,e,t)=>new cn({left:s,right:e,typeName:j.ZodIntersection,...B(t)});let jt=class Qc extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.array)return E(n,{code:b.invalid_type,expected:T.array,received:n.parsedType}),D;if(n.data.length<this._def.items.length)return E(n,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&n.data.length>this._def.items.length&&(E(n,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new nt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>$e.mergeArray(t,a)):$e.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Qc({...this._def,rest:e})}};jt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jt({items:s,typeName:j.ZodTuple,rest:null,...B(e)})};let eu=class mi extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.object)return E(n,{code:b.invalid_type,expected:T.object,received:n.parsedType}),D;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new nt(n,o,n.path,o)),value:i._parse(new nt(n,n.data[o],n.path,o))});return n.common.async?$e.mergeObjectAsync(t,r):$e.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof K?new mi({keyType:e,valueType:t,typeName:j.ZodRecord,...B(n)}):new mi({keyType:hs.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}};class Cr extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.map)return E(n,{code:b.invalid_type,expected:T.map,received:n.parsedType}),D;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new nt(n,o,n.path,[l,"key"])),value:a._parse(new nt(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}Cr.create=(s,e,t)=>new Cr({valueType:e,keyType:s,typeName:j.ZodMap,...B(t)});let $r=class yi extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==T.set)return E(n,{code:b.invalid_type,expected:T.set,received:n.parsedType}),D;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(E(n,{code:b.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(E(n,{code:b.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return D;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new nt(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new yi({...this._def,minSize:{value:e,message:Z.toString(t)}})}max(e,t){return new yi({...this._def,maxSize:{value:e,message:Z.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};$r.create=(s,e)=>new $r({valueType:s,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});let tu=class rr extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return E(t,{code:b.invalid_type,expected:T.function,received:t.parsedType}),D;function n(o,u){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Er(),Xs].filter(l=>!!l),issueData:{code:b.invalid_arguments,argumentsError:u}})}function r(o,u){return Nr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Er(),Xs].filter(l=>!!l),issueData:{code:b.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof fs){const o=this;return Ie(async function(...u){const l=new Ve([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ie(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Ve([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new Ve([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new rr({...this._def,args:jt.create(e).rest(Bt.create())})}returns(e){return new rr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new rr({args:e||jt.create([]).rest(Bt.create()),returns:t||Bt.create(),typeName:j.ZodFunction,...B(n)})}},un=class extends K{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};un.create=(s,e)=>new un({getter:s,typeName:j.ZodLazy,...B(e)});let ln=class extends K{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}};ln.create=(s,e)=>new ln({value:s,typeName:j.ZodLiteral,...B(e)});function su(s,e){return new zn({values:s,typeName:j.ZodEnum,...B(e)})}let zn=class gi extends K{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return E(t,{expected:ee.joinValues(n),received:t.parsedType,code:b.invalid_type}),D}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return E(t,{received:t.data,code:b.invalid_enum_value,options:n}),D}return Ie(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return gi.create(e)}exclude(e){return gi.create(this.options.filter(t=>!e.includes(t)))}};zn.create=su;let dn=class extends K{_parse(e){const t=ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==T.string&&n.parsedType!==T.number){const r=ee.objectValues(t);return E(n,{expected:ee.joinValues(r),received:n.parsedType,code:b.invalid_type}),D}if(t.indexOf(e.data)===-1){const r=ee.objectValues(t);return E(n,{received:n.data,code:b.invalid_enum_value,options:r}),D}return Ie(e.data)}get enum(){return this._def.values}};dn.create=(s,e)=>new dn({values:s,typeName:j.ZodNativeEnum,...B(e)});let fs=class extends K{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return E(t,{code:b.invalid_type,expected:T.promise,received:t.parsedType}),D;const n=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return Ie(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};fs.create=(s,e)=>new fs({type:s,typeName:j.ZodPromise,...B(e)});let Ye=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{E(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(r.type==="refinement"){const i=o=>{const u=r.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Qs(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Qs(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);ee.assertNever(r)}};Ye.create=(s,e,t)=>new Ye({schema:s,typeName:j.ZodEffects,effect:e,...B(t)});Ye.createWithPreprocess=(s,e,t)=>new Ye({schema:e,effect:{type:"preprocess",transform:s},typeName:j.ZodEffects,...B(t)});let Ot=class extends K{_parse(e){return this._getType(e)===T.undefined?Ie(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ot.create=(s,e)=>new Ot({innerType:s,typeName:j.ZodOptional,...B(e)});let Jt=class extends K{_parse(e){return this._getType(e)===T.null?Ie(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Jt.create=(s,e)=>new Jt({innerType:s,typeName:j.ZodNullable,...B(e)});let hn=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===T.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};hn.create=(s,e)=>new hn({innerType:s,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});class jr extends K{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ir(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}jr.create=(s,e)=>new jr({innerType:s,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});class zr extends K{_parse(e){if(this._getType(e)!==T.nan){const t=this._getOrReturnCtx(e);return E(t,{code:b.invalid_type,expected:T.nan,received:t.parsedType}),D}return{status:"valid",value:e.data}}}zr.create=s=>new zr({typeName:j.ZodNaN,...B(s)});const Ap=Symbol("zod_brand");class nu extends K{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}let Ji=class ru extends K{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),Hc(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new ru({in:e,out:t,typeName:j.ZodPipeline})}};class Rr extends K{_parse(e){const t=this._def.innerType._parse(e);return Qs(t)&&(t.value=Object.freeze(t.value)),t}}Rr.create=(s,e)=>new Rr({innerType:s,typeName:j.ZodReadonly,...B(e)});const au=(s,e={},t)=>s?ps.create().superRefine((n,r)=>{var a,i;if(!s(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):ps.create(),Cp={object:De.lazycreate};var j;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(j||(j={}));const $p=(s,e={message:`Input not instance of ${s.name}`})=>au(t=>t instanceof s,e),iu=hs.create,ou=en.create,jp=zr.create,zp=tn.create,cu=sn.create,Rp=nn.create,Pp=Zr.create,Mp=rn.create,Dp=an.create,Lp=ps.create,Up=Bt.create,Bp=St.create,qp=Ar.create,Vp=Yt.create,Kp=De.create,Wp=De.strictCreate,Fp=on.create,Yp=ca.create,Jp=cn.create,Gp=jt.create,Hp=eu.create,Xp=Cr.create,Qp=$r.create,ef=tu.create,tf=un.create,sf=ln.create,nf=zn.create,rf=dn.create,af=fs.create,zo=Ye.create,of=Ot.create,cf=Jt.create,uf=Ye.createWithPreprocess,lf=Ji.create,df=()=>iu().optional(),hf=()=>ou().optional(),pf=()=>cu().optional(),ff={string:s=>hs.create({...s,coerce:!0}),number:s=>en.create({...s,coerce:!0}),boolean:s=>sn.create({...s,coerce:!0}),bigint:s=>tn.create({...s,coerce:!0}),date:s=>nn.create({...s,coerce:!0})},mf=D;var wt=Object.freeze({__proto__:null,defaultErrorMap:Xs,setErrorMap:vp,getErrorMap:Er,makeIssue:Nr,EMPTY_PATH:wp,addIssueToContext:E,ParseStatus:$e,INVALID:D,DIRTY:Hc,OK:Ie,isAborted:li,isDirty:di,isValid:Qs,isAsync:Ir,get util(){return ee},get objectUtil(){return ui},ZodParsedType:T,getParsedType:At,ZodType:K,ZodString:hs,ZodNumber:en,ZodBigInt:tn,ZodBoolean:sn,ZodDate:nn,ZodSymbol:Zr,ZodUndefined:rn,ZodNull:an,ZodAny:ps,ZodUnknown:Bt,ZodNever:St,ZodVoid:Ar,ZodArray:Yt,ZodObject:De,ZodUnion:on,ZodDiscriminatedUnion:ca,ZodIntersection:cn,ZodTuple:jt,ZodRecord:eu,ZodMap:Cr,ZodSet:$r,ZodFunction:tu,ZodLazy:un,ZodLiteral:ln,ZodEnum:zn,ZodNativeEnum:dn,ZodPromise:fs,ZodEffects:Ye,ZodTransformer:Ye,ZodOptional:Ot,ZodNullable:Jt,ZodDefault:hn,ZodCatch:jr,ZodNaN:zr,BRAND:Ap,ZodBranded:nu,ZodPipeline:Ji,ZodReadonly:Rr,custom:au,Schema:K,ZodSchema:K,late:Cp,get ZodFirstPartyTypeKind(){return j},coerce:ff,any:Lp,array:Vp,bigint:zp,boolean:cu,date:Rp,discriminatedUnion:Yp,effect:zo,enum:nf,function:ef,instanceof:$p,intersection:Jp,lazy:tf,literal:sf,map:Xp,nan:jp,nativeEnum:rf,never:Bp,null:Dp,nullable:cf,number:ou,object:Kp,oboolean:pf,onumber:hf,optional:of,ostring:df,pipeline:lf,preprocess:uf,promise:af,record:Hp,set:Qp,strictObject:Wp,string:iu,symbol:Pp,transformer:zo,tuple:Gp,undefined:Mp,union:Fp,unknown:Up,void:qp,NEVER:mf,ZodIssueCode:b,quotelessJson:gp,ZodError:Ve});class ua extends Error{constructor(e,t){super(e),le(this,"discriminator","FreighterError"),le(this,"type"),this.type=t}}const yf=s=>{if(s==null||typeof s!="object")return!1;const e=s;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},vi="unknown",Ro="nil",la="freighter",Rn=wt.object({type:wt.string(),data:wt.string()});class gf{constructor(){le(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Ro,data:""};if(yf(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:vi,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Ro)return null;if(e.type===vi)return new Po(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Po(e.data)}}const uu=new gf,lu=({encode:s,decode:e})=>uu.register({encode:s,decode:e}),Gi=s=>uu.decode(s);class Po extends ua{constructor(e){super(e,vi)}}const da="freighter.";let zt=class extends ua{constructor(){super("EOF",la)}};le(zt,"TYPE",da+"eof");let Gt=class extends ua{constructor(){super("StreamClosed",la)}};le(Gt,"TYPE",da+"stream_closed");let Rt=class extends ua{constructor(e={}){const{message:t="Unreachable",url:n=hp.UNKNOWN}=e;super(t,la),le(this,"url"),this.url=n}};le(Rt,"TYPE",da+"unreachable");const vf=s=>{if(s.type!==la)return null;if(s instanceof zt)return{type:zt.TYPE,data:"EOF"};if(s instanceof Gt)return{type:Gt.TYPE,data:"StreamClosed"};if(s instanceof Rt)return{type:Rt.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${s.type}: ${s.message}`)},wf=s=>{if(!s.type.startsWith(da))return null;switch(s.type){case zt.TYPE:return new zt;case Gt.TYPE:return new Gt;case Rt.TYPE:return new Rt;default:throw new Error(`Unknown error type: ${s.data}`)}};lu({encode:vf,decode:wf});class du{constructor(){le(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const r=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,r)};return await r(e)}}const hu="Content-Type",Mo=s=>{if(Fc.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(s==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(r,a)=>await e(r,{...a,agent:n})};class bf extends du{constructor(e,t,n=!1){return super(),le(this,"endpoint"),le(this,"encoder"),le(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Mo(this.endpoint.protocol),new Proxy(this,{get:(r,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(r,a,i)})}get headers(){return{[hu]:this.encoder.contentType}}async send(e,t,n,r){t=n==null?void 0:n.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const h={...l,params:{}};o.headers={...this.headers,...l.params};let g;try{g=await Mo(l.protocol)(l.target,o)}catch(ye){let ze=ye;return ze.message==="Load failed"&&(ze=new Rt({url:i})),[h,ze]}const se=await g.arrayBuffer();if(g!=null&&g.ok)return r!=null&&(a=this.encoder.decode(se,r)),[h,null];try{if(g.status!==400)return[h,new Error(g.statusText)];const ye=this.encoder.decode(se,Rn),ze=Gi(ye);return[h,ze]}catch(ye){return[h,new Error(`[freighter] - failed to decode error: ${g.statusText}: ${ye.message}`)]}});return[a,u]}}const C=async(s,e,t,n,r)=>{const[a,i]=await s.send(e,t,n,r);if(i!=null)throw i;return a},_f=()=>Fc.RUNTIME!=="node"?s=>new WebSocket(s):s=>new(require("ws")).WebSocket(s,{rejectUnauthorized:!1}),kf=wt.object({type:wt.union([wt.literal("data"),wt.literal("close")]),payload:wt.unknown().optional(),error:wt.optional(Rn)});class Of{constructor(e,t,n,r){le(this,"encoder"),le(this,"reqSchema"),le(this,"resSchema"),le(this,"ws"),le(this,"serverClosed"),le(this,"sendClosed"),le(this,"receiveDataQueue",[]),le(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=r,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new zt;if(this.sendClosed)throw new Gt;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Gi(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,kf),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Nf(e)?new zt:new Gt}}}const Tf="freighterctx",xf=1e3,Sf=1001,Ef=[xf,Sf],Nf=s=>Ef.includes(s.code),pu=class fu extends du{constructor(e,t,n=!1){super(),le(this,"baseUrl"),le(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const r=_f();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const u=r(this.buildURL(e,o)),l={...o,params:{}};u.binaryType=fu.MESSAGE_TYPE;const h=await this.wrapSocket(u,t,n);return h instanceof Error?[l,h]:(a=h,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=dp({[hu]:this.encoder.contentType,...t.params},Tf);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(r=>{e.onopen=()=>{r(new Of(e,this.encoder,t,n))},e.onerror=a=>{const i=a;r(new Error(i.message))}})}};le(pu,"MESSAGE_TYPE","arraybuffer");let If=pu;var Le=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y={},ha={};Object.defineProperty(ha,"__esModule",{value:!0});function Zf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}ha.default=Zf;var pa={};Object.defineProperty(pa,"__esModule",{value:!0});function Af(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}pa.default=Af;var fa={};Object.defineProperty(fa,"__esModule",{value:!0});function Cf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}fa.default=Cf;var Hi={};Object.defineProperty(Hi,"__esModule",{value:!0});function $f(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Hi.default=$f;var Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});function jf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Xi.default=jf;var Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});function zf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Qi.default=zf;var eo={};Object.defineProperty(eo,"__esModule",{value:!0});function Rf(s){if(s===void 0&&(s=""),!s)return"";var e=String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,r){return n+"_"+r.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}eo.default=Rf;var to={};Object.defineProperty(to,"__esModule",{value:!0});function Pf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,r){return t+n.charAt(0).toUpperCase()+n.slice(1)+r}):""}to.default=Pf;var ma={};Object.defineProperty(ma,"__esModule",{value:!0});function Mf(s){return s===void 0&&(s=""),s?String(s).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}ma.default=Mf;var so={},ts={};(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.belongToTypes=s.isValidObject=s.isArrayObject=s.validateOptions=s.DefaultOption=void 0,s.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},s.validateOptions=function(e){return e===void 0&&(e=s.DefaultOption),e.recursive==null?e=s.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},s.isArrayObject=function(e){return e!=null&&Array.isArray(e)},s.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},s.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(ts);var Df=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(so,"__esModule",{value:!0});var dt=ts;function ar(s,e){if(e===void 0&&(e=dt.DefaultOption),!dt.isValidObject(s))return null;e=dt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toLowerCase();e.recursive&&(dt.isValidObject(r)?dt.belongToTypes(r,e.keepTypesOnRecursion)||(r=ar(r,e)):e.recursiveInArray&&dt.isArrayObject(r)&&(r=Df(r).map(function(i){var o=i;if(dt.isValidObject(i))dt.belongToTypes(o,e.keepTypesOnRecursion)||(o=ar(i,e));else if(dt.isArrayObject(i)){var u=ar({key:i},e);o=u.key}return o}))),t[a]=r}),t}so.default=ar;var no={},Lf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(no,"__esModule",{value:!0});var ht=ts;function ir(s,e){if(e===void 0&&(e=ht.DefaultOption),!ht.isValidObject(s))return null;e=ht.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=n.toUpperCase();e.recursive&&(ht.isValidObject(r)?ht.belongToTypes(r,e.keepTypesOnRecursion)||(r=ir(r,e)):e.recursiveInArray&&ht.isArrayObject(r)&&(r=Lf(r).map(function(i){var o=i;if(ht.isValidObject(i))ht.belongToTypes(o,e.keepTypesOnRecursion)||(o=ir(i,e));else if(ht.isArrayObject(i)){var u=ir({key:i},e);o=u.key}return o}))),t[a]=r}),t}no.default=ir;var ro={},Uf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(ro,"__esModule",{value:!0});var pt=ts,Bf=ha;function or(s,e){if(e===void 0&&(e=pt.DefaultOption),!pt.isValidObject(s))return null;e=pt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Bf.default(n);e.recursive&&(pt.isValidObject(r)?pt.belongToTypes(r,e.keepTypesOnRecursion)||(r=or(r,e)):e.recursiveInArray&&pt.isArrayObject(r)&&(r=Uf(r).map(function(i){var o=i;if(pt.isValidObject(i))pt.belongToTypes(o,e.keepTypesOnRecursion)||(o=or(i,e));else if(pt.isArrayObject(i)){var u=or({key:i},e);o=u.key}return o}))),t[a]=r}),t}ro.default=or;var ao={},qf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(ao,"__esModule",{value:!0});var ft=ts,Vf=pa;function cr(s,e){if(e===void 0&&(e=ft.DefaultOption),!ft.isValidObject(s))return null;e=ft.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Vf.default(n);e.recursive&&(ft.isValidObject(r)?ft.belongToTypes(r,e.keepTypesOnRecursion)||(r=cr(r,e)):e.recursiveInArray&&ft.isArrayObject(r)&&(r=qf(r).map(function(i){var o=i;if(ft.isValidObject(i))ft.belongToTypes(o,e.keepTypesOnRecursion)||(o=cr(i,e));else if(ft.isArrayObject(i)){var u=cr({key:i},e);o=u.key}return o}))),t[a]=r}),t}ao.default=cr;var io={},Kf=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(io,"__esModule",{value:!0});var mt=ts,Wf=fa;function ur(s,e){if(e===void 0&&(e=mt.DefaultOption),!mt.isValidObject(s))return null;e=mt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Wf.default(n);e.recursive&&(mt.isValidObject(r)?mt.belongToTypes(r,e.keepTypesOnRecursion)||(r=ur(r,e)):e.recursiveInArray&&mt.isArrayObject(r)&&(r=Kf(r).map(function(i){var o=i;if(mt.isValidObject(i))mt.belongToTypes(o,e.keepTypesOnRecursion)||(o=ur(i,e));else if(mt.isArrayObject(i)){var u=ur({key:i},e);o=u.key}return o}))),t[a]=r}),t}io.default=ur;var oo={},Ff=Le&&Le.__spreadArrays||function(){for(var s=0,e=0,t=arguments.length;e<t;e++)s+=arguments[e].length;for(var n=Array(s),r=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,r++)n[r]=a[i];return n};Object.defineProperty(oo,"__esModule",{value:!0});var yt=ts,Yf=ma;function lr(s,e){if(e===void 0&&(e=yt.DefaultOption),!yt.isValidObject(s))return null;e=yt.validateOptions(e);var t={};return Object.keys(s).forEach(function(n){var r=s[n],a=Yf.default(n);e.recursive&&(yt.isValidObject(r)?yt.belongToTypes(r,e.keepTypesOnRecursion)||(r=lr(r,e)):e.recursiveInArray&&yt.isArrayObject(r)&&(r=Ff(r).map(function(i){var o=i;if(yt.isValidObject(i))yt.belongToTypes(o,e.keepTypesOnRecursion)||(o=lr(i,e));else if(yt.isArrayObject(i)){var u=lr({key:i},e);o=u.key}return o}))),t[a]=r}),t}oo.default=lr;Object.defineProperty(Y,"__esModule",{value:!0});Y.kebabKeys=Y.pascalKeys=Y.snakeKeys=Y.camelKeys=Y.upperKeys=Y.lowerKeys=Y.toLowerCase=Y.toUpperCase=Y.toKebabCase=Y.toHeaderCase=Y.toSentenceCase=Y.toTextCase=Y.toPathCase=Y.toDotCase=Y.toPascalCase=Y.toSnakeCase=Y.toCamelCase=void 0;var mu=ha;Y.toCamelCase=mu.default;var yu=pa;Y.toSnakeCase=yu.default;var gu=fa;Y.toPascalCase=gu.default;var vu=Hi;Y.toDotCase=vu.default;var wu=Xi;Y.toPathCase=wu.default;var bu=Qi;Y.toTextCase=bu.default;var _u=eo;Y.toSentenceCase=_u.default;var ku=to;Y.toHeaderCase=ku.default;var Ou=ma;Y.toKebabCase=Ou.default;var Tu=so;Y.lowerKeys=Tu.default;var xu=no;Y.upperKeys=xu.default;var Su=ro;Y.camelKeys=Su.default;var Eu=ao;Y.snakeKeys=Eu.default;var Nu=io;Y.pascalKeys=Nu.default;var Iu=oo;Y.kebabKeys=Iu.default;var Zu=function(s){return String(s||"").toLowerCase()};Y.toLowerCase=Zu;var Au=function(s){return String(s||"").toUpperCase()};Y.toUpperCase=Au;var Jf={toCamelCase:mu.default,toSnakeCase:yu.default,toPascalCase:gu.default,toDotCase:vu.default,toPathCase:wu.default,toTextCase:bu.default,toSentenceCase:_u.default,toHeaderCase:ku.default,toKebabCase:Ou.default,toUpperCase:Au,toLowerCase:Zu,lowerKeys:Tu.default,upperKeys:xu.default,camelKeys:Su.default,snakeKeys:Eu.default,pascalKeys:Nu.default,kebabKeys:Iu.default};Y.default=Jf;var Cu=Y;const $u={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Gf=s=>Cu.snakeKeys(s,$u),Pr=s=>Cu.camelKeys(s,$u),Hf=s=>s!=null&&typeof s=="object"&&"toString"in s,Xf=(s,e=!1)=>{const t=Hf(s)?"stringer":typeof s;let n;switch(t){case"string":n=(r,a)=>r.localeCompare(a);break;case"stringer":n=(r,a)=>r.toString().localeCompare(a.toString());break;case"number":n=(r,a)=>Number(r)-Number(a);break;case"bigint":n=(r,a)=>BigInt(r)-BigInt(a)>0n?1:-1;break;case"boolean":n=(r,a)=>Number(r)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Qf(n):n},Qf=s=>(e,t)=>s(t,e);var te;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(te||(te={}));var wi;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(wi||(wi={}));const x=te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ct=s=>{switch(typeof s){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(s)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(s)?x.array:s===null?x.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?x.promise:typeof Map<"u"&&s instanceof Map?x.map:typeof Set<"u"&&s instanceof Set?x.set:typeof Date<"u"&&s instanceof Date?x.date:x.object;default:return x.unknown}},_=te.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),em=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");let Ke=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){const l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return r(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,te.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Ke.create=s=>new Ke(s);const pn=(s,e)=>{let t;switch(s.code){case _.invalid_type:s.received===x.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,te.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${te.joinValues(s.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${te.joinValues(s.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${te.joinValues(s.options)}, received '${s.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:te.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case _.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case _.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,te.assertNever(s)}return{message:t}};let ju=pn;function tm(s){ju=s}function Mr(){return ju}const Dr=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(i,{data:e,defaultError:o}).message;return{...r,path:a,message:r.message||o}},sm=[];function N(s,e){const t=Dr({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,Mr(),pn].filter(n=>!!n)});s.common.issues.push(t)}let je=class zu{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return L;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t)n.push({key:await r.key,value:await r.value});return zu.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return L;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};const L=Object.freeze({status:"aborted"}),Ru=s=>({status:"dirty",value:s}),Ze=s=>({status:"valid",value:s}),bi=s=>s.status==="aborted",_i=s=>s.status==="dirty",fn=s=>s.status==="valid",Lr=s=>typeof Promise<"u"&&s instanceof Promise;var A;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));let rt=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Do=(s,e)=>{if(fn(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ke(s.common.issues);return this._error=t,this._error}}};function q(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:r}}let W=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Ct(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Ct(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Lr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ct(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Do(r,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ct(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(Lr(r)?r:Promise.resolve(r));return Do(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:_.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Je({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Tt.create(this,this._def)}nullable(){return Xt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ht.create(this,this._def)}promise(){return gs.create(this,this._def)}or(e){return _n.create([this,e],this._def)}and(e){return kn.create(this,e,this._def)}transform(e){return new Je({...q(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Sn({...q(this._def),innerType:this,defaultValue:t,typeName:z.ZodDefault})}brand(){return new Bu({typeName:z.ZodBranded,type:this,...q(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Kr({...q(this._def),innerType:this,catchValue:t,typeName:z.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Pn.create(this,e)}readonly(){return Fr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const nm=/^c[^\s-]{8,}$/i,rm=/^[a-z][a-z0-9]*$/,am=/^[0-9A-HJKMNP-TV-Z]{26}$/,im=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,om=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ra;const um=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,lm=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,dm=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function hm(s,e){return!!((e==="v4"||!e)&&um.test(s)||(e==="v6"||!e)&&lm.test(s))}let ms=class As extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.string,received:r.parsedType}),L}const t=new je;let n;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,i=e.data.length<r.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?N(n,{code:_.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):i&&N(n,{code:_.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")om.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"email",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")Ra||(Ra=new RegExp(cm,"u")),Ra.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"emoji",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")im.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"uuid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")nm.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"cuid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")rm.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"cuid2",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")am.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"ulid",code:_.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),N(n,{validation:"url",code:_.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"regex",code:_.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?dm(r).test(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:_.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="ip"?hm(e.data,r.version)||(n=this._getOrReturnCtx(e,n),N(n,{validation:"ip",code:_.invalid_string,message:r.message}),t.dirty()):te.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:_.invalid_string,...A.errToObj(n)})}_addCheck(e){return new As({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...A.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new As({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new As({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new As({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ms.create=s=>{var e;return new ms({checks:[],typeName:z.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...q(s)})};function pm(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}let mn=class ki extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==x.number){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.number,received:r.parsedType}),L}let t;const n=new je;for(const r of this._def.checks)r.kind==="int"?te.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:_.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind==="multipleOf"?pm(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_finite,message:r.message}),n.dirty()):te.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,r){return new ki({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(r)}]})}_addCheck(e){return new ki({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&te.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};mn.create=s=>new mn({checks:[],typeName:z.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...q(s)});let yn=class Oi extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==x.bigint){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.bigint,received:r.parsedType}),L}let t;const n=new je;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:_.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):te.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,n,r){return new Oi({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:A.toString(r)}]})}_addCheck(e){return new Oi({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};yn.create=s=>{var e;return new yn({checks:[],typeName:z.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...q(s)})};let gn=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.boolean,received:t.parsedType}),L}return Ze(e.data)}};gn.create=s=>new gn({typeName:z.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...q(s)});let vn=class Pu extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_type,expected:x.date,received:r.parsedType}),L}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return N(r,{code:_.invalid_date}),L}const t=new je;let n;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),N(n,{code:_.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):te.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Pu({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};vn.create=s=>new vn({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:z.ZodDate,...q(s)});class Ur extends W{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.symbol,received:t.parsedType}),L}return Ze(e.data)}}Ur.create=s=>new Ur({typeName:z.ZodSymbol,...q(s)});let wn=class extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.undefined,received:t.parsedType}),L}return Ze(e.data)}};wn.create=s=>new wn({typeName:z.ZodUndefined,...q(s)});let bn=class extends W{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.null,received:t.parsedType}),L}return Ze(e.data)}};bn.create=s=>new bn({typeName:z.ZodNull,...q(s)});let ys=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Ze(e.data)}};ys.create=s=>new ys({typeName:z.ZodAny,...q(s)});let qt=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ze(e.data)}};qt.create=s=>new qt({typeName:z.ZodUnknown,...q(s)});let Et=class extends W{_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.never,received:t.parsedType}),L}};Et.create=s=>new Et({typeName:z.ZodNever,...q(s)});class Br extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.void,received:t.parsedType}),L}return Ze(e.data)}}Br.create=s=>new Br({typeName:z.ZodVoid,...q(s)});let Ht=class dr extends W{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==x.array)return N(t,{code:_.invalid_type,expected:x.array,received:t.parsedType}),L;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(N(t,{code:i?_.too_big:_.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(N(t,{code:_.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(N(t,{code:_.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new rt(t,i,t.path,o)))).then(i=>je.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new rt(t,i,t.path,o)));return je.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new dr({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new dr({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new dr({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}};Ht.create=(s,e)=>new Ht({type:s,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...q(e)});function as(s){if(s instanceof ue){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=Tt.create(as(n))}return new ue({...s._def,shape:()=>e})}else return s instanceof Ht?new Ht({...s._def,type:as(s.element)}):s instanceof Tt?Tt.create(as(s.unwrap())):s instanceof Xt?Xt.create(as(s.unwrap())):s instanceof Pt?Pt.create(s.items.map(e=>as(e))):s}class ue extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=te.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==x.object){const u=this._getOrReturnCtx(e);return N(u,{code:_.invalid_type,expected:x.object,received:u.parsedType}),L}const{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||i.push(u);const o=[];for(const u of a){const l=r[u],h=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new rt(n,h,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Et){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")i.length>0&&(N(n,{code:_.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of i){const h=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new rt(n,h,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const h=await l.key;u.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>je.mergeObjectSync(t,u)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=A.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:z.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(e){const t={};return te.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new ue({...this._def,shape:()=>t})}omit(e){const t={};return te.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new ue({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return te.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new ue({...this._def,shape:()=>t})}required(e){const t={};return te.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof Tt;)r=r._def.innerType;t[n]=r}}),new ue({...this._def,shape:()=>t})}keyof(){return Uu(te.objectKeys(this.shape))}}ue.create=(s,e)=>new ue({shape:()=>s,unknownKeys:"strip",catchall:Et.create(),typeName:z.ZodObject,...q(e)});ue.strictCreate=(s,e)=>new ue({shape:()=>s,unknownKeys:"strict",catchall:Et.create(),typeName:z.ZodObject,...q(e)});ue.lazycreate=(s,e)=>new ue({shape:s,unknownKeys:"strip",catchall:Et.create(),typeName:z.ZodObject,...q(e)});class _n extends W{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ke(o.ctx.common.issues));return N(t,{code:_.invalid_union,unionErrors:i}),L}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new Ke(u));return N(t,{code:_.invalid_union,unionErrors:o}),L}}get options(){return this._def.options}}_n.create=(s,e)=>new _n({options:s,typeName:z.ZodUnion,...q(e)});const hr=s=>s instanceof On?hr(s.schema):s instanceof Je?hr(s.innerType()):s instanceof Tn?[s.value]:s instanceof Mt?s.options:s instanceof xn?Object.keys(s.enum):s instanceof Sn?hr(s._def.innerType):s instanceof wn?[void 0]:s instanceof bn?[null]:null;class ya extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return N(t,{code:_.invalid_type,expected:x.object,received:t.parsedType}),L;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(N(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const r=new Map;for(const a of t){const i=hr(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new ya({typeName:z.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...q(n)})}}function Ti(s,e){const t=Ct(s),n=Ct(e);if(s===e)return{valid:!0,data:s};if(t===x.object&&n===x.object){const r=te.objectKeys(e),a=te.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=Ti(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===x.array&&n===x.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=Ti(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===x.date&&n===x.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}let kn=class extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(bi(a)||bi(i))return L;const o=Ti(a.value,i.value);return o.valid?((_i(a)||_i(i))&&t.dirty(),{status:t.value,value:o.data}):(N(n,{code:_.invalid_intersection_types}),L)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};kn.create=(s,e,t)=>new kn({left:s,right:e,typeName:z.ZodIntersection,...q(t)});let Pt=class Mu extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.array)return N(n,{code:_.invalid_type,expected:x.array,received:n.parsedType}),L;if(n.data.length<this._def.items.length)return N(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new rt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(r).then(a=>je.mergeArray(t,a)):je.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Mu({...this._def,rest:e})}};Pt.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pt({items:s,typeName:z.ZodTuple,rest:null,...q(e)})};let Du=class xi extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.object)return N(n,{code:_.invalid_type,expected:x.object,received:n.parsedType}),L;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new rt(n,o,n.path,o)),value:i._parse(new rt(n,n.data[o],n.path,o))});return n.common.async?je.mergeObjectAsync(t,r):je.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof W?new xi({keyType:e,valueType:t,typeName:z.ZodRecord,...q(n)}):new xi({keyType:ms.create(),valueType:e,typeName:z.ZodRecord,...q(t)})}};class qr extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.map)return N(n,{code:_.invalid_type,expected:x.map,received:n.parsedType}),L;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:r._parse(new rt(n,o,n.path,[l,"key"])),value:a._parse(new rt(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}qr.create=(s,e,t)=>new qr({valueType:e,keyType:s,typeName:z.ZodMap,...q(t)});let Vr=class Si extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.set)return N(n,{code:_.invalid_type,expected:x.set,received:n.parsedType}),L;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(N(n,{code:_.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(N(n,{code:_.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(u){const l=new Set;for(const h of u){if(h.status==="aborted")return L;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new rt(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new Si({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new Si({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Vr.create=(s,e)=>new Vr({valueType:s,minSize:null,maxSize:null,typeName:z.ZodSet,...q(e)});let Lu=class pr extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return N(t,{code:_.invalid_type,expected:x.function,received:t.parsedType}),L;function n(o,u){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mr(),pn].filter(l=>!!l),issueData:{code:_.invalid_arguments,argumentsError:u}})}function r(o,u){return Dr({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Mr(),pn].filter(l=>!!l),issueData:{code:_.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof gs){const o=this;return Ze(async function(...u){const l=new Ke([]),h=await o._def.args.parseAsync(u,a).catch(se=>{throw l.addIssue(n(u,se)),l}),g=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(g,a).catch(se=>{throw l.addIssue(r(g,se)),l})})}else{const o=this;return Ze(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Ke([n(u,l.error)]);const h=Reflect.apply(i,this,l.data),g=o._def.returns.safeParse(h,a);if(!g.success)throw new Ke([r(h,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new pr({...this._def,args:Pt.create(e).rest(qt.create())})}returns(e){return new pr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new pr({args:e||Pt.create([]).rest(qt.create()),returns:t||qt.create(),typeName:z.ZodFunction,...q(n)})}},On=class extends W{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};On.create=(s,e)=>new On({getter:s,typeName:z.ZodLazy,...q(e)});let Tn=class extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};Tn.create=(s,e)=>new Tn({value:s,typeName:z.ZodLiteral,...q(e)});function Uu(s,e){return new Mt({values:s,typeName:z.ZodEnum,...q(e)})}class Mt extends W{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{expected:te.joinValues(n),received:t.parsedType,code:_.invalid_type}),L}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return N(t,{received:t.data,code:_.invalid_enum_value,options:n}),L}return Ze(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Mt.create(e)}exclude(e){return Mt.create(this.options.filter(t=>!e.includes(t)))}}Mt.create=Uu;class xn extends W{_parse(e){const t=te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==x.string&&n.parsedType!==x.number){const r=te.objectValues(t);return N(n,{expected:te.joinValues(r),received:n.parsedType,code:_.invalid_type}),L}if(t.indexOf(e.data)===-1){const r=te.objectValues(t);return N(n,{received:n.data,code:_.invalid_enum_value,options:r}),L}return Ze(e.data)}get enum(){return this._def.values}}xn.create=(s,e)=>new xn({values:s,typeName:z.ZodNativeEnum,...q(e)});let gs=class extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return N(t,{code:_.invalid_type,expected:x.promise,received:t.parsedType}),L;const n=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return Ze(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};gs.create=(s,e)=>new gs({type:s,typeName:z.ZodPromise,...q(e)});let Je=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{N(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(r.type==="refinement"){const i=o=>{const u=r.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fn(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>fn(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);te.assertNever(r)}};Je.create=(s,e,t)=>new Je({schema:s,typeName:z.ZodEffects,effect:e,...q(t)});Je.createWithPreprocess=(s,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:s},typeName:z.ZodEffects,...q(t)});let Tt=class extends W{_parse(e){return this._getType(e)===x.undefined?Ze(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tt.create=(s,e)=>new Tt({innerType:s,typeName:z.ZodOptional,...q(e)});let Xt=class extends W{_parse(e){return this._getType(e)===x.null?Ze(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xt.create=(s,e)=>new Xt({innerType:s,typeName:z.ZodNullable,...q(e)});class Sn extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===x.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Sn.create=(s,e)=>new Sn({innerType:s,typeName:z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...q(e)});class Kr extends W{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Lr(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Kr.create=(s,e)=>new Kr({innerType:s,typeName:z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...q(e)});class Wr extends W{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return N(t,{code:_.invalid_type,expected:x.nan,received:t.parsedType}),L}return{status:"valid",value:e.data}}}Wr.create=s=>new Wr({typeName:z.ZodNaN,...q(s)});const fm=Symbol("zod_brand");class Bu extends W{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Pn extends W{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?L:r.status==="dirty"?(t.dirty(),Ru(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?L:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new Pn({in:e,out:t,typeName:z.ZodPipeline})}}class Fr extends W{_parse(e){const t=this._def.innerType._parse(e);return fn(t)&&(t.value=Object.freeze(t.value)),t}}Fr.create=(s,e)=>new Fr({innerType:s,typeName:z.ZodReadonly,...q(e)});const qu=(s,e={},t)=>s?ys.create().superRefine((n,r)=>{var a,i;if(!s(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...l,fatal:u})}}):ys.create(),mm={object:ue.lazycreate};var z;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(z||(z={}));const ym=(s,e={message:`Input not instance of ${s.name}`})=>qu(t=>t instanceof s,e),Vu=ms.create,Ku=mn.create,gm=Wr.create,vm=yn.create,Wu=gn.create,wm=vn.create,bm=Ur.create,_m=wn.create,km=bn.create,Om=ys.create,Tm=qt.create,xm=Et.create,Sm=Br.create,Em=Ht.create,Nm=ue.create,Im=ue.strictCreate,Zm=_n.create,Am=ya.create,Cm=kn.create,$m=Pt.create,jm=Du.create,zm=qr.create,Rm=Vr.create,Pm=Lu.create,Mm=On.create,Dm=Tn.create,Lm=Mt.create,Um=xn.create,Bm=gs.create,Lo=Je.create,qm=Tt.create,Vm=Xt.create,Km=Je.createWithPreprocess,Wm=Pn.create,Fm=()=>Vu().optional(),Ym=()=>Ku().optional(),Jm=()=>Wu().optional(),Gm={string:s=>ms.create({...s,coerce:!0}),number:s=>mn.create({...s,coerce:!0}),boolean:s=>gn.create({...s,coerce:!0}),bigint:s=>yn.create({...s,coerce:!0}),date:s=>vn.create({...s,coerce:!0})},Hm=L;var f=Object.freeze({__proto__:null,defaultErrorMap:pn,setErrorMap:tm,getErrorMap:Mr,makeIssue:Dr,EMPTY_PATH:sm,addIssueToContext:N,ParseStatus:je,INVALID:L,DIRTY:Ru,OK:Ze,isAborted:bi,isDirty:_i,isValid:fn,isAsync:Lr,get util(){return te},get objectUtil(){return wi},ZodParsedType:x,getParsedType:Ct,ZodType:W,ZodString:ms,ZodNumber:mn,ZodBigInt:yn,ZodBoolean:gn,ZodDate:vn,ZodSymbol:Ur,ZodUndefined:wn,ZodNull:bn,ZodAny:ys,ZodUnknown:qt,ZodNever:Et,ZodVoid:Br,ZodArray:Ht,ZodObject:ue,ZodUnion:_n,ZodDiscriminatedUnion:ya,ZodIntersection:kn,ZodTuple:Pt,ZodRecord:Du,ZodMap:qr,ZodSet:Vr,ZodFunction:Lu,ZodLazy:On,ZodLiteral:Tn,ZodEnum:Mt,ZodNativeEnum:xn,ZodPromise:gs,ZodEffects:Je,ZodTransformer:Je,ZodOptional:Tt,ZodNullable:Xt,ZodDefault:Sn,ZodCatch:Kr,ZodNaN:Wr,BRAND:fm,ZodBranded:Bu,ZodPipeline:Pn,ZodReadonly:Fr,custom:qu,Schema:W,ZodSchema:W,late:mm,get ZodFirstPartyTypeKind(){return z},coerce:Gm,any:Om,array:Em,bigint:vm,boolean:Wu,date:wm,discriminatedUnion:Am,effect:Lo,enum:Lm,function:Pm,instanceof:ym,intersection:Cm,lazy:Mm,literal:Dm,map:zm,nan:gm,nativeEnum:Um,never:xm,null:km,nullable:Vm,number:Ku,object:Nm,oboolean:Jm,onumber:Ym,optional:qm,ostring:Fm,pipeline:Wm,preprocess:Km,promise:Bm,record:jm,set:Rm,strictObject:Im,string:Vu,symbol:bm,transformer:Lo,tuple:$m,undefined:_m,union:Zm,unknown:Tm,void:Sm,NEVER:Hm,ZodIssueCode:_,quotelessJson:em,ZodError:Ke});const ga=f.tuple([f.number(),f.number()]);f.tuple([f.bigint(),f.bigint()]);const Fu=f.object({width:f.number(),height:f.number()}),Xm=f.object({signedWidth:f.number(),signedHeight:f.number()}),Qm=["width","height"];f.enum(Qm);const ey=["start","center","end"],ty=["signedWidth","signedHeight"];f.enum(ty);const Yr=f.object({x:f.number(),y:f.number()}),sy=f.object({clientX:f.number(),clientY:f.number()}),ny=["x","y"],Yu=f.enum(ny),Ju=["top","right","bottom","left"];f.enum(Ju);const ry=["left","right"],Gu=f.enum(ry),ay=["top","bottom"],Hu=f.enum(ay),Xu=["center"],Uo=f.enum(Xu),iy=[...Ju,...Xu],Qu=f.enum(iy);f.enum(ey);const oy=["first","last"];f.enum(oy);const cy=f.object({lower:f.number(),upper:f.number()}),uy=f.object({lower:f.bigint(),upper:f.bigint()});f.union([cy,ga]);f.union([uy,ga]);f.union([Yu,Qu]);f.union([Yu,Qu,f.instanceof(String)]);const Rs=(s,e)=>{const t={};if(typeof s=="number"||typeof s=="bigint")e!=null?(t.lower=s,t.upper=e):(t.lower=typeof s=="bigint"?0n:0,t.upper=s);else if(Array.isArray(s)){if(s.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=s}else return Bo(s);return Bo(t)},Bo=s=>s.lower>s.upper?{lower:s.upper,upper:s.lower}:s;f.object({x:Gu.or(Uo),y:Hu.or(Uo)});const ly=f.object({x:Gu,y:Hu}),dy=Object.freeze({x:"left",y:"top"}),hy=(s,e)=>s.x===e.x&&s.y===e.y,qo=f.union([f.number(),Yr,ga,Fu,Xm,sy]),py=(s,e)=>{if(typeof s=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return s==="x"?{x:e,y:0}:{x:0,y:e}}return typeof s=="number"?{x:s,y:e??s}:Array.isArray(s)?{x:s[0],y:s[1]}:"signedWidth"in s?{x:s.signedWidth,y:s.signedHeight}:"clientX"in s?{x:s.clientX,y:s.clientY}:"width"in s?{x:s.width,y:s.height}:{x:s.x,y:s.y}},Vo=Object.freeze({x:0,y:0}),Vn=f.union([f.number(),f.string()]);f.object({top:Vn,left:Vn,width:Vn,height:Vn});f.object({left:f.number(),top:f.number(),right:f.number(),bottom:f.number()});f.object({one:Yr,two:Yr,root:ly});const co=(s,e,t=0,n=0,r)=>{const a={one:{...Vo},two:{...Vo},root:r??dy};if(typeof s=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:s,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in s&&"two"in s&&"root"in s?{...s,root:r??s.root}:("getBoundingClientRect"in s&&(s=s.getBoundingClientRect()),"left"in s?(a.one={x:s.left,y:s.top},a.two={x:s.right,y:s.bottom},a):(a.one=s,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Pa=s=>{const e=co(s);return{lower:e.one.x,upper:e.two.x}},Ma=s=>{const e=co(s);return{lower:e.one.y,upper:e.two.y}},fy=s=>typeof s!="object"||s==null?!1:"one"in s&&"two"in s&&"root"in s,my=f.object({signedWidth:f.number(),signedHeight:f.number()});f.union([Fu,my,Yr,ga]);var yy=Object.defineProperty,gy=(s,e,t)=>e in s?yy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_t=(s,e,t)=>(gy(s,typeof e!="symbol"?e+"":e,t),t);const vy=(s,e,t)=>(e!=null&&(s=Math.max(s,e)),t!=null&&(s=Math.min(s,t)),s);f.object({offset:qo,scale:qo});const wy=s=>(e,t,n,r)=>t==="dimension"?[e,n]:[e,r?n-s:n+s],by=s=>(e,t,n,r)=>[e,r?n/s:n*s],_y=s=>(e,t,n)=>{if(e===null)return[s,n];const{lower:r,upper:a}=e,{lower:i,upper:o}=s,u=a-r,l=o-i;if(t==="dimension")return[s,n*(l/u)];const h=(n-r)*(l/u)+i;return[s,h]},ky=s=>(e,t,n)=>[s,n],Oy=()=>(s,e,t)=>{if(s===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[s,t];const{lower:n,upper:r}=s;return[s,r-(t-n)]},Ty=s=>(e,t,n)=>{const{lower:r,upper:a}=s;return n=vy(n,r,a),[e,n]},Ei=class Cs{constructor(){_t(this,"ops",[]),_t(this,"currBounds",null),_t(this,"currType",null),_t(this,"reversed",!1),this.ops=[]}static translate(e){return new Cs().translate(e)}static magnify(e){return new Cs().magnify(e)}static scale(e,t){return new Cs().scale(e,t)}translate(e){const t=this.new(),n=wy(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=by(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Rs(e,t),r=this.new(),a=_y(n);return a.type="scale",r.ops.push(a),r}clamp(e,t){const n=Rs(e,t),r=this.new(),a=Ty(n);return a.type="clamp",r.ops.push(a),r}reBound(e,t){const n=Rs(e,t),r=this.new(),a=ky(n);return a.type="re-bound",r.ops.push(a),r}invert(){const e=Oy();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Cs;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,r],a)=>a(n,e,r,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,r)=>{if(n.type==="scale"||t.some(([i,o])=>r>=i&&r<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>r);a!==-1&&t.push([r,a])}),t.forEach(([n,r])=>{const a=e.ops.slice(n,r);a.unshift(e.ops[r]),e.ops.splice(n,r-n+1,...a)}),e.reversed=!e.reversed,e}};_t(Ei,"IDENTITY",new Ei);let Ko=Ei;const Wo=class vt{constructor(e=new Ko,t=new Ko,n=null){_t(this,"x"),_t(this,"y"),_t(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new vt().translate(e,t)}static translateX(e){return new vt().translateX(e)}static translateY(e){return new vt().translateY(e)}static clamp(e){return new vt().clamp(e)}static magnify(e){return new vt().magnify(e)}static scale(e){return new vt().scale(e)}static reBound(e){return new vt().reBound(e)}translate(e,t){const n=py(e,t),r=this.copy();return r.x=this.x.translate(n.x),r.y=this.y.translate(n.y),r}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(fy(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!hy(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Pa(e)),t.y=t.y.scale(Ma(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Pa(e)),t.y=this.y.reBound(Ma(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Pa(e)),t.y=this.y.clamp(Ma(e)),t}copy(){const e=new vt;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return co(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};_t(Wo,"IDENTITY",new Wo);var xy=Object.defineProperty,Sy=(s,e,t)=>e in s?xy(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,v=(s,e,t)=>(Sy(s,typeof e!="symbol"?e+"":e,t),t);let Ey="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Ny=(s=21)=>{let e="",t=s;for(;t--;)e+=Ey[Math.random()*64|0];return e};const el=(s,e)=>{const t=new J(e);if(![H.DAY,H.HOUR,H.MINUTE,H.SECOND,H.MILLISECOND,H.MICROSECOND,H.NANOSECOND].some(r=>r.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=s.valueOf()%t.valueOf();return s instanceof J?new J(n):new H(n)},oe=class P{constructor(e,t="UTC"){if(v(this,"value"),v(this,"encodeValue",!0),e==null)this.value=P.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*P.MILLISECOND.valueOf();else if(typeof e=="string")this.value=P.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=P.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=P.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=P.MAX:e=P.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const r=new Date(e,t-1,n,0,0,0,0);return new P(BigInt(r.getTime())*P.MILLISECOND.valueOf()).truncate(P.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,r,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let u=P.hours(parseInt(n??"00",10)).add(P.minutes(parseInt(r??"00",10))).add(P.seconds(parseInt(i??"00",10))).add(P.milliseconds(parseInt(o??"00",10)));return t==="local"&&(u=u.add(P.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return P.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new P(BigInt(n.getTime())*P.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(P.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new H(BigInt(new Date().getTimezoneOffset())*P.MINUTE.valueOf())}static since(e){return new P().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new P(e).valueOf()}span(e){return this.range(e).span}range(e){return new Ee(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new P(e).valueOf()}afterEq(e){return this.valueOf()>=new P(e).valueOf()}before(e){return this.valueOf()<new P(e).valueOf()}beforeEq(e){return this.valueOf()<=new P(e).valueOf()}add(e){return new P(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new P(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/P.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return el(this,e)}get isToday(){return this.truncate(H.DAY).equals(P.now().truncate(H.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new P(new Date)}static max(...e){let t=P.MIN;for(const n of e){const r=new P(n);r.after(t)&&(t=r)}return t}static min(...e){let t=P.MAX;for(const n of e){const r=new P(n);r.before(t)&&(t=r)}return t}static nanoseconds(e){return new P(e)}static microseconds(e){return P.nanoseconds(e*1e3)}static milliseconds(e){return P.microseconds(e*1e3)}static seconds(e){return P.milliseconds(e*1e3)}static minutes(e){return P.seconds(e*60)}static hours(e){return P.minutes(e*60)}static days(e){return P.hours(e*24)}};v(oe,"NANOSECOND",oe.nanoseconds(1)),v(oe,"MICROSECOND",oe.microseconds(1)),v(oe,"MILLISECOND",oe.milliseconds(1)),v(oe,"SECOND",oe.seconds(1)),v(oe,"MINUTE",oe.minutes(1)),v(oe,"HOUR",oe.hours(1)),v(oe,"DAY",oe.days(1)),v(oe,"MAX",new oe((1n<<63n)-1n)),v(oe,"MIN",new oe(0)),v(oe,"ZERO",new oe(0)),v(oe,"z",f.union([f.object({value:f.bigint()}).transform(s=>new oe(s.value)),f.string().transform(s=>new oe(BigInt(s))),f.instanceof(Number).transform(s=>new oe(s)),f.number().transform(s=>new oe(s)),f.instanceof(oe)]));let J=oe;const ce=class re{constructor(e){v(this,"value"),v(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new re(e).valueOf()}greaterThan(e){return this.valueOf()>new re(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new re(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new re(e).valueOf()}remainder(e){return el(this,e)}truncate(e){return new re(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(re.DAY),t=this.truncate(re.HOUR),n=this.truncate(re.MINUTE),r=this.truncate(re.SECOND),a=this.truncate(re.MILLISECOND),i=this.truncate(re.MICROSECOND),o=this.truncate(re.NANOSECOND),u=e,l=t.sub(e),h=n.sub(t),g=r.sub(n),se=a.sub(r),ye=i.sub(a),ze=o.sub(i);let he="";return u.isZero||(he+=`${u.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),g.isZero||(he+=`${g.seconds}s `),se.isZero||(he+=`${se.milliseconds}ms `),ye.isZero||(he+=`${ye.microseconds}µs `),ze.isZero||(he+=`${ze.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/re.DAY.valueOf())}get hours(){return Number(this.valueOf()/re.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/re.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/re.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/re.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/re.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new re(e).valueOf()}add(e){return new re(this.valueOf()+new re(e).valueOf())}sub(e){return new re(this.valueOf()-new re(e).valueOf())}static nanoseconds(e=1){return new re(e)}static microseconds(e=1){return re.nanoseconds(e*1e3)}static milliseconds(e=1){return re.microseconds(e*1e3)}static seconds(e=1){return re.milliseconds(e*1e3)}static minutes(e){return re.seconds(e.valueOf()*60)}static hours(e){return re.minutes(e*60)}static days(e){return re.hours(e*24)}};v(ce,"NANOSECOND",ce.nanoseconds(1)),v(ce,"MICROSECOND",ce.microseconds(1)),v(ce,"MILLISECOND",ce.milliseconds(1)),v(ce,"SECOND",ce.seconds(1)),v(ce,"MINUTE",ce.minutes(1)),v(ce,"HOUR",ce.hours(1)),v(ce,"DAY",ce.days(1)),v(ce,"MAX",new ce((1n<<63n)-1n)),v(ce,"MIN",new ce(0)),v(ce,"ZERO",new ce(0)),v(ce,"z",f.union([f.object({value:f.bigint()}).transform(s=>new ce(s.value)),f.string().transform(s=>new ce(BigInt(s))),f.instanceof(Number).transform(s=>new ce(s)),f.number().transform(s=>new ce(s)),f.instanceof(ce)]));let H=ce;const $s=class fr extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new fr(e).valueOf()}get period(){return H.seconds(1/this.valueOf())}sampleCount(e){return new H(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Oe(t).valueOf()}span(e){return H.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new fr(e)}static khz(e){return fr.hz(e*1e3)}};v($s,"z",f.union([f.number().transform(s=>new $s(s)),f.instanceof(Number).transform(s=>new $s(s)),f.instanceof($s)]));let va=$s;const ve=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new En(e*this.valueOf())}};v(ve,"UNKNOWN",new ve(0)),v(ve,"BIT128",new ve(16)),v(ve,"BIT64",new ve(8)),v(ve,"BIT32",new ve(4)),v(ve,"BIT16",new ve(2)),v(ve,"BIT8",new ve(1)),v(ve,"z",f.union([f.number().transform(s=>new ve(s)),f.instanceof(Number).transform(s=>new ve(s)),f.instanceof(ve)]));let Oe=ve;const Xe=class mr{constructor(e,t){v(this,"start"),v(this,"end"),typeof e=="object"&&"start"in e?(this.start=new J(e.start),this.end=new J(e.end)):(this.start=new J(e),this.end=new J(t))}get span(){return new H(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new mr(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=H.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const r=J.max(n.start,e.start),a=J.min(n.end,e.end);return a.before(r)?!1:new H(a.sub(r)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),r=this.end.sub(e.end).valueOf();return n<0&&(n=-n),r<0&&(r=-r),n<=t.valueOf()&&r<=t.valueOf()}contains(e){return e instanceof mr?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new mr(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};v(Xe,"MAX",new Xe(J.MIN,J.MAX)),v(Xe,"MIN",new Xe(J.MAX,J.MIN)),v(Xe,"ZERO",new Xe(J.ZERO,J.ZERO)),v(Xe,"z",f.union([f.object({start:J.z,end:J.z}).transform(s=>new Xe(s.start,s.end)),f.instanceof(Xe)]));let Ee=Xe;const m=class Qe extends String{constructor(e){if(e instanceof Qe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=Qe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(Qe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Qe.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(Qe.JSON)||this.equals(Qe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Qe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Qe.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Qe.BIG_INT_TYPES.some(e=>e.equals(this))}};v(m,"UNKNOWN",new m("unknown")),v(m,"FLOAT64",new m("float64")),v(m,"FLOAT32",new m("float32")),v(m,"INT64",new m("int64")),v(m,"INT32",new m("int32")),v(m,"INT16",new m("int16")),v(m,"INT8",new m("int8")),v(m,"UINT64",new m("uint64")),v(m,"UINT32",new m("uint32")),v(m,"UINT16",new m("uint16")),v(m,"UINT8",new m("uint8")),v(m,"BOOLEAN",m.UINT8),v(m,"TIMESTAMP",new m("timestamp")),v(m,"UUID",new m("uuid")),v(m,"STRING",new m("string")),v(m,"JSON",new m("json")),v(m,"ARRAY_CONSTRUCTORS",new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]])),v(m,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]])),v(m,"DENSITIES",new Map([[m.UINT8.toString(),Oe.BIT8],[m.UINT16.toString(),Oe.BIT16],[m.UINT32.toString(),Oe.BIT32],[m.UINT64.toString(),Oe.BIT64],[m.FLOAT32.toString(),Oe.BIT32],[m.FLOAT64.toString(),Oe.BIT64],[m.INT8.toString(),Oe.BIT8],[m.INT16.toString(),Oe.BIT16],[m.INT32.toString(),Oe.BIT32],[m.INT64.toString(),Oe.BIT64],[m.TIMESTAMP.toString(),Oe.BIT64],[m.STRING.toString(),Oe.UNKNOWN],[m.JSON.toString(),Oe.UNKNOWN],[m.UUID.toString(),Oe.BIT128]])),v(m,"ALL",[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON]),v(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),v(m,"z",f.union([f.string().transform(s=>new m(s)),f.instanceof(m)]));let G=m;const ke=class fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return fe.bytes(this.valueOf()+e.valueOf())}sub(e){return fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/fe.TERABYTE.valueOf()}toString(){const e=this.truncate(fe.TERABYTE),t=this.truncate(fe.GIGABYTE),n=this.truncate(fe.MEGABYTE),r=this.truncate(fe.KILOBYTE),a=this.truncate(fe.BYTE),i=e,o=t.sub(e),u=n.sub(t),l=r.sub(n),h=a.sub(r);let g="";return i.isZero||(g+=`${i.terabytes}TB `),o.isZero||(g+=`${o.gigabytes}GB `),u.isZero||(g+=`${u.megabytes}MB `),l.isZero||(g+=`${l.kilobytes}KB `),(!h.isZero||g==="")&&(g+=`${h.valueOf()}B`),g.trim()}static bytes(e=1){return new fe(e)}static kilobytes(e=1){return fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};v(ke,"BYTE",new ke(1)),v(ke,"KILOBYTE",ke.kilobytes(1)),v(ke,"MEGABYTE",ke.megabytes(1)),v(ke,"GIGABYTE",ke.gigabytes(1)),v(ke,"TERABYTE",ke.terabytes(1)),v(ke,"ZERO",new ke(0)),v(ke,"z",f.union([f.number().transform(s=>new ke(s)),f.instanceof(ke)]));let En=ke;f.union([f.instanceof(Uint8Array),f.instanceof(Uint16Array),f.instanceof(Uint32Array),f.instanceof(BigUint64Array),f.instanceof(Float32Array),f.instanceof(Float64Array),f.instanceof(Int8Array),f.instanceof(Int16Array),f.instanceof(Int32Array),f.instanceof(BigInt64Array)]);const tl=s=>{const e=typeof s;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||s instanceof J||s instanceof H||s instanceof Date},Iy=(s,e,t,n=0)=>s.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!s.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):js(t,-n),Zy=s=>s==null?!1:Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)&&!(s instanceof DataView)||s instanceof Te?!0:tl(s),Lt=-1;class Te{constructor(e){v(this,"key",""),v(this,"isSynnaxSeries",!0),v(this,"dataType"),v(this,"sampleOffset"),v(this,"gl"),v(this,"_data"),v(this,"_timeRange"),v(this,"alignment",0n),v(this,"_cachedMin"),v(this,"_cachedMax"),v(this,"writePos",Lt),v(this,"_refCount",0),v(this,"_cachedLength"),Zy(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:r=0,glBufferUsage:a="static",alignment:i=0n,key:o=Ny()}=e,{data:u}=e;if(u instanceof Te||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const g=u;this.key=g.key,this.dataType=g.dataType,this.sampleOffset=g.sampleOffset,this.gl=g.gl,this._data=g._data,this._timeRange=g._timeRange,this.alignment=g.alignment,this._cachedMin=g._cachedMin,this._cachedMax=g._cachedMax,this.writePos=g.writePos,this._refCount=g._refCount,this._cachedLength=g._cachedLength;return}const l=tl(u),h=Array.isArray(u);if(t!=null)this.dataType=new G(t);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(h||l){let g=u;if(!l){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");g=u[0]}if(typeof g=="string")this.dataType=G.STRING;else if(typeof g=="number")this.dataType=G.FLOAT64;else if(typeof g=="bigint")this.dataType=G.INT64;else if(typeof g=="boolean")this.dataType=G.BOOLEAN;else if(g instanceof J||g instanceof Date||g instanceof J)this.dataType=G.TIMESTAMP;else if(typeof g=="object")this.dataType=G.JSON;else throw new Error(`cannot infer data type of ${typeof g} when constructing a Series from a JS array`)}else this.dataType=new G(u)}if(!h&&!l)this._data=u;else{let g=l?[u]:u;const se=g[0];(se instanceof J||se instanceof Date||se instanceof H)&&(g=g.map(ye=>new J(ye).valueOf())),this.dataType.equals(G.STRING)?(this._cachedLength=g.length,this._data=new TextEncoder().encode(g.join(`
|
|
1
|
+
"use strict";var Ni=Object.defineProperty;var Ai=(r,e,t)=>e in r?Ni(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(Ai(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("zod");var te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},O={},Kt={};Object.defineProperty(Kt,"__esModule",{value:!0});function Ii(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Kt.default=Ii;var Vt={};Object.defineProperty(Vt,"__esModule",{value:!0});function ki(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Vt.default=ki;var Ft={};Object.defineProperty(Ft,"__esModule",{value:!0});function $i(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Ft.default=$i;var Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});function Ci(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Qr.default=Ci;var en={};Object.defineProperty(en,"__esModule",{value:!0});function Ri(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}en.default=Ri;var tn={};Object.defineProperty(tn,"__esModule",{value:!0});function ji(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}tn.default=ji;var rn={};Object.defineProperty(rn,"__esModule",{value:!0});function xi(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}rn.default=xi;var nn={};Object.defineProperty(nn,"__esModule",{value:!0});function Di(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}nn.default=Di;var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});function Pi(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Jt.default=Pi;var sn={},Ze={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Ze);var Zi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(sn,"__esModule",{value:!0});var ue=Ze;function Tt(r,e){if(e===void 0&&(e=ue.DefaultOption),!ue.isValidObject(r))return null;e=ue.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ue.isValidObject(a)?ue.belongToTypes(a,e.keepTypesOnRecursion)||(a=Tt(a,e)):e.recursiveInArray&&ue.isArrayObject(a)&&(a=Zi(a).map(function(o){var l=o;if(ue.isValidObject(o))ue.belongToTypes(l,e.keepTypesOnRecursion)||(l=Tt(o,e));else if(ue.isArrayObject(o)){var u=Tt({key:o},e);l=u.key}return l}))),t[i]=a}),t}sn.default=Tt;var an={},Mi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(an,"__esModule",{value:!0});var he=Ze;function zt(r,e){if(e===void 0&&(e=he.DefaultOption),!he.isValidObject(r))return null;e=he.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(he.isValidObject(a)?he.belongToTypes(a,e.keepTypesOnRecursion)||(a=zt(a,e)):e.recursiveInArray&&he.isArrayObject(a)&&(a=Mi(a).map(function(o){var l=o;if(he.isValidObject(o))he.belongToTypes(l,e.keepTypesOnRecursion)||(l=zt(o,e));else if(he.isArrayObject(o)){var u=zt({key:o},e);l=u.key}return l}))),t[i]=a}),t}an.default=zt;var on={},_i=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(on,"__esModule",{value:!0});var fe=Ze,Ui=Kt;function Et(r,e){if(e===void 0&&(e=fe.DefaultOption),!fe.isValidObject(r))return null;e=fe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ui.default(n);e.recursive&&(fe.isValidObject(a)?fe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Et(a,e)):e.recursiveInArray&&fe.isArrayObject(a)&&(a=_i(a).map(function(o){var l=o;if(fe.isValidObject(o))fe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Et(o,e));else if(fe.isArrayObject(o)){var u=Et({key:o},e);l=u.key}return l}))),t[i]=a}),t}on.default=Et;var cn={},Li=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(cn,"__esModule",{value:!0});var de=Ze,Bi=Vt;function St(r,e){if(e===void 0&&(e=de.DefaultOption),!de.isValidObject(r))return null;e=de.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Bi.default(n);e.recursive&&(de.isValidObject(a)?de.belongToTypes(a,e.keepTypesOnRecursion)||(a=St(a,e)):e.recursiveInArray&&de.isArrayObject(a)&&(a=Li(a).map(function(o){var l=o;if(de.isValidObject(o))de.belongToTypes(l,e.keepTypesOnRecursion)||(l=St(o,e));else if(de.isArrayObject(o)){var u=St({key:o},e);l=u.key}return l}))),t[i]=a}),t}cn.default=St;var ln={},qi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(ln,"__esModule",{value:!0});var ye=Ze,Yi=Ft;function Nt(r,e){if(e===void 0&&(e=ye.DefaultOption),!ye.isValidObject(r))return null;e=ye.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Yi.default(n);e.recursive&&(ye.isValidObject(a)?ye.belongToTypes(a,e.keepTypesOnRecursion)||(a=Nt(a,e)):e.recursiveInArray&&ye.isArrayObject(a)&&(a=qi(a).map(function(o){var l=o;if(ye.isValidObject(o))ye.belongToTypes(l,e.keepTypesOnRecursion)||(l=Nt(o,e));else if(ye.isArrayObject(o)){var u=Nt({key:o},e);l=u.key}return l}))),t[i]=a}),t}ln.default=Nt;var un={},Wi=te&&te.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(un,"__esModule",{value:!0});var pe=Ze,Ki=Jt;function At(r,e){if(e===void 0&&(e=pe.DefaultOption),!pe.isValidObject(r))return null;e=pe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=Ki.default(n);e.recursive&&(pe.isValidObject(a)?pe.belongToTypes(a,e.keepTypesOnRecursion)||(a=At(a,e)):e.recursiveInArray&&pe.isArrayObject(a)&&(a=Wi(a).map(function(o){var l=o;if(pe.isValidObject(o))pe.belongToTypes(l,e.keepTypesOnRecursion)||(l=At(o,e));else if(pe.isArrayObject(o)){var u=At({key:o},e);l=u.key}return l}))),t[i]=a}),t}un.default=At;Object.defineProperty(O,"__esModule",{value:!0});O.kebabKeys=O.pascalKeys=O.snakeKeys=O.camelKeys=O.upperKeys=O.lowerKeys=O.toLowerCase=O.toUpperCase=O.toKebabCase=O.toHeaderCase=O.toSentenceCase=O.toTextCase=O.toPathCase=O.toDotCase=O.toPascalCase=O.toSnakeCase=O.toCamelCase=void 0;var hs=Kt;O.toCamelCase=hs.default;var fs=Vt;O.toSnakeCase=fs.default;var ds=Ft;O.toPascalCase=ds.default;var ys=Qr;O.toDotCase=ys.default;var ps=en;O.toPathCase=ps.default;var gs=tn;O.toTextCase=gs.default;var ms=rn;O.toSentenceCase=ms.default;var ws=nn;O.toHeaderCase=ws.default;var vs=Jt;O.toKebabCase=vs.default;var bs=sn;O.lowerKeys=bs.default;var Os=an;O.upperKeys=Os.default;var Ts=on;O.camelKeys=Ts.default;var zs=cn;O.snakeKeys=zs.default;var Es=ln;O.pascalKeys=Es.default;var Ss=un;O.kebabKeys=Ss.default;var Ns=function(r){return String(r||"").toLowerCase()};O.toLowerCase=Ns;var As=function(r){return String(r||"").toUpperCase()};O.toUpperCase=As;var Vi={toCamelCase:hs.default,toSnakeCase:fs.default,toPascalCase:ds.default,toDotCase:ys.default,toPathCase:ps.default,toTextCase:gs.default,toSentenceCase:ms.default,toHeaderCase:ws.default,toKebabCase:vs.default,toUpperCase:As,toLowerCase:Ns,lowerKeys:bs.default,upperKeys:Os.default,camelKeys:Ts.default,snakeKeys:zs.default,pascalKeys:Es.default,kebabKeys:Ss.default};O.default=Vi;var Is=O;const ks={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Fi=r=>Is.snakeKeys(r,ks),Mt=r=>Is.camelKeys(r,ks),Ji=r=>r!=null&&typeof r=="object"&&"toString"in r,Gi=(r,e=!1)=>{const t=Ji(r)?"stringer":typeof r;let n;switch(t){case"string":n=(a,i)=>a.localeCompare(i);break;case"stringer":n=(a,i)=>a.toString().localeCompare(i.toString());break;case"number":n=(a,i)=>Number(a)-Number(i);break;case"bigint":n=(a,i)=>BigInt(a)-BigInt(i)>0n?1:-1;break;case"boolean":n=(a,i)=>Number(a)-Number(i);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Hi(n):n},Hi=r=>(e,t)=>r(t,e),Gt=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const $s=s.z.object({width:s.z.number(),height:s.z.number()}),Xi=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Qi=["width","height"];s.z.enum(Qi);const eo=["start","center","end"],to=["signedWidth","signedHeight"];s.z.enum(to);const _t=s.z.object({x:s.z.number(),y:s.z.number()}),ro=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),no=["x","y"],Cs=s.z.enum(no),Rs=["top","right","bottom","left"];s.z.enum(Rs);const so=["left","right"],js=s.z.enum(so),ao=["top","bottom"],xs=s.z.enum(ao),Ds=["center"],Mn=s.z.enum(Ds),io=[...Rs,...Ds],Ps=s.z.enum(io);s.z.enum(eo);const oo=["first","last"];s.z.enum(oo);const co=s.z.object({lower:s.z.number(),upper:s.z.number()}),lo=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([co,Gt]);s.z.union([lo,Gt]);s.z.union([Cs,Ps]);s.z.union([Cs,Ps,s.z.instanceof(String)]);const at=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return _n(r);return _n(t)},_n=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:js.or(Mn),y:xs.or(Mn)});const uo=s.z.object({x:js,y:xs}),ho=Object.freeze({x:"left",y:"top"}),fo=(r,e)=>r.x===e.x&&r.y===e.y,Un=s.z.union([s.z.number(),_t,Gt,$s,Xi,ro]),yo=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Ln=Object.freeze({x:0,y:0}),vt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:vt,left:vt,width:vt,height:vt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:_t,two:_t,root:uo});const hn=(r,e,t=0,n=0,a)=>{const i={one:{...Ln},two:{...Ln},root:a??ho};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}: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))},mr=r=>{const e=hn(r);return{lower:e.one.x,upper:e.two.x}},wr=r=>{const e=hn(r);return{lower:e.one.y,upper:e.two.y}},po=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,go=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([$s,go,_t,Gt]);var mo=Object.defineProperty,wo=(r,e,t)=>e in r?mo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ee=(r,e,t)=>(wo(r,typeof e!="symbol"?e+"":e,t),t);const vo=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Un,scale:Un});const bo=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Oo=r=>(e,t,n,a)=>[e,a?n/r:n*r],To=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},zo=r=>(e,t,n)=>[r,n],Eo=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},So=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=vo(n,a,i),[e,n]},Mr=class Qe{constructor(){Ee(this,"ops",[]),Ee(this,"currBounds",null),Ee(this,"currType",null),Ee(this,"reversed",!1),this.ops=[]}static translate(e){return new Qe().translate(e)}static magnify(e){return new Qe().magnify(e)}static scale(e,t){return new Qe().scale(e,t)}translate(e){const t=this.new(),n=bo(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Oo(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=at(e,t),a=this.new(),i=To(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=at(e,t),a=this.new(),i=So(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=at(e,t),a=this.new(),i=zo(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Eo();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 Qe;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Ee(Mr,"IDENTITY",new Mr);let Bn=Mr;const qn=class Te{constructor(e=new Bn,t=new Bn,n=null){Ee(this,"x"),Ee(this,"y"),Ee(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new Te().translate(e,t)}static translateX(e){return new Te().translateX(e)}static translateY(e){return new Te().translateY(e)}static clamp(e){return new Te().clamp(e)}static magnify(e){return new Te().magnify(e)}static scale(e){return new Te().scale(e)}static reBound(e){return new Te().reBound(e)}translate(e,t){const n=yo(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}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(po(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!fo(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(mr(e)),t.y=t.y.scale(wr(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(mr(e)),t.y=this.y.reBound(wr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(mr(e)),t.y=this.y.clamp(wr(e)),t}copy(){const e=new Te;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return hn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Ee(qn,"IDENTITY",new qn);var No=Object.defineProperty,Ao=(r,e,t)=>e in r?No(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e,t)=>(Ao(r,typeof e!="symbol"?e+"":e,t),t);let Io="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ko=(r=21)=>{let e="",t=r;for(;t--;)e+=Io[Math.random()*64|0];return e};const Zs=(r,e)=>{const t=new E(e);if(![N.DAY,N.HOUR,N.MINUTE,N.SECOND,N.MILLISECOND,N.MICROSECOND,N.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof E?new E(n):new N(n)},k=class v{constructor(e,t="UTC"){if(d(this,"value"),d(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 n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=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())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new v(BigInt(a.getTime())*v.MILLISECOND.valueOf()).truncate(v.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=v.hours(parseInt(n??"00",10)).add(v.minutes(parseInt(a??"00",10))).add(v.seconds(parseInt(o??"00",10))).add(v.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(v.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return v.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new v(BigInt(n.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 n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new N(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 J(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()))}milliseconds(){return Number(this.valueOf())/Number(v.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Zs(this,e)}get isToday(){return this.truncate(N.DAY).equals(v.now().truncate(N.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 n of e){const a=new v(n);a.after(t)&&(t=a)}return t}static min(...e){let t=v.MAX;for(const n of e){const a=new v(n);a.before(t)&&(t=a)}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)}};d(k,"NANOSECOND",k.nanoseconds(1)),d(k,"MICROSECOND",k.microseconds(1)),d(k,"MILLISECOND",k.milliseconds(1)),d(k,"SECOND",k.seconds(1)),d(k,"MINUTE",k.minutes(1)),d(k,"HOUR",k.hours(1)),d(k,"DAY",k.days(1)),d(k,"MAX",new k((1n<<63n)-1n)),d(k,"MIN",new k(0)),d(k,"ZERO",new k(0)),d(k,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new k(r.value)),s.z.string().transform(r=>new k(BigInt(r))),s.z.instanceof(Number).transform(r=>new k(r)),s.z.number().transform(r=>new k(r)),s.z.instanceof(k)]));let E=k;const $=class A{constructor(e){d(this,"value"),d(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new A(e).valueOf()}greaterThan(e){return this.valueOf()>new A(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new A(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new A(e).valueOf()}remainder(e){return Zs(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),t=this.truncate(A.HOUR),n=this.truncate(A.MINUTE),a=this.truncate(A.SECOND),i=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),l=this.truncate(A.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let P="";return u.isZero||(P+=`${u.days}d `),p.isZero||(P+=`${p.hours}h `),g.isZero||(P+=`${g.minutes}m `),y.isZero||(P+=`${y.seconds}s `),U.isZero||(P+=`${U.milliseconds}ms `),x.isZero||(P+=`${x.microseconds}µs `),Q.isZero||(P+=`${Q.nanoseconds}ns`),P.trim()}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(A.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(A.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new A(e).valueOf()}add(e){return new A(this.valueOf()+new A(e).valueOf())}sub(e){return new A(this.valueOf()-new A(e).valueOf())}static nanoseconds(e=1){return new A(e)}static microseconds(e=1){return A.nanoseconds(e*1e3)}static milliseconds(e=1){return A.microseconds(e*1e3)}static seconds(e=1){return A.milliseconds(e*1e3)}static minutes(e){return A.seconds(e.valueOf()*60)}static hours(e){return A.minutes(e*60)}static days(e){return A.hours(e*24)}};d($,"NANOSECOND",$.nanoseconds(1)),d($,"MICROSECOND",$.microseconds(1)),d($,"MILLISECOND",$.milliseconds(1)),d($,"SECOND",$.seconds(1)),d($,"MINUTE",$.minutes(1)),d($,"HOUR",$.hours(1)),d($,"DAY",$.days(1)),d($,"MAX",new $((1n<<63n)-1n)),d($,"MIN",new $(0)),d($,"ZERO",new $(0)),d($,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new $(r.value)),s.z.string().transform(r=>new $(BigInt(r))),s.z.instanceof(Number).transform(r=>new $(r)),s.z.number().transform(r=>new $(r)),s.z.instanceof($)]));let N=$;const et=class It extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new It(e).valueOf()}get period(){return N.seconds(1/this.valueOf())}sampleCount(e){return new N(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new V(t).valueOf()}span(e){return N.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new It(e)}static khz(e){return It.hz(e*1e3)}};d(et,"z",s.z.union([s.z.number().transform(r=>new et(r)),s.z.instanceof(Number).transform(r=>new et(r)),s.z.instanceof(et)]));let Ht=et;const L=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ot(e*this.valueOf())}};d(L,"UNKNOWN",new L(0)),d(L,"BIT128",new L(16)),d(L,"BIT64",new L(8)),d(L,"BIT32",new L(4)),d(L,"BIT16",new L(2)),d(L,"BIT8",new L(1)),d(L,"z",s.z.union([s.z.number().transform(r=>new L(r)),s.z.instanceof(Number).transform(r=>new L(r)),s.z.instanceof(L)]));let V=L;const se=class kt{constructor(e,t){d(this,"start"),d(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 N(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new kt(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=N.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const a=E.max(n.start,e.start),i=E.min(n.end,e.end);return i.before(a)?!1:new N(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof kt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new kt(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}};d(se,"MAX",new se(E.MIN,E.MAX)),d(se,"MIN",new se(E.MAX,E.MIN)),d(se,"ZERO",new se(E.ZERO,E.ZERO)),d(se,"z",s.z.union([s.z.object({start:E.z,end:E.z}).transform(r=>new se(r.start,r.end)),s.z.instanceof(se)]));let J=se;const h=class ae extends String{constructor(e){if(e instanceof ae||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=ae.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(ae.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ae.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(ae.JSON)||this.equals(ae.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ae.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ae.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return ae.BIG_INT_TYPES.some(e=>e.equals(this))}};d(h,"UNKNOWN",new h("unknown")),d(h,"FLOAT64",new h("float64")),d(h,"FLOAT32",new h("float32")),d(h,"INT64",new h("int64")),d(h,"INT32",new h("int32")),d(h,"INT16",new h("int16")),d(h,"INT8",new h("int8")),d(h,"UINT64",new h("uint64")),d(h,"UINT32",new h("uint32")),d(h,"UINT16",new h("uint16")),d(h,"UINT8",new h("uint8")),d(h,"BOOLEAN",h.UINT8),d(h,"TIMESTAMP",new h("timestamp")),d(h,"UUID",new h("uuid")),d(h,"STRING",new h("string")),d(h,"JSON",new h("json")),d(h,"ARRAY_CONSTRUCTORS",new Map([[h.UINT8.toString(),Uint8Array],[h.UINT16.toString(),Uint16Array],[h.UINT32.toString(),Uint32Array],[h.UINT64.toString(),BigUint64Array],[h.FLOAT32.toString(),Float32Array],[h.FLOAT64.toString(),Float64Array],[h.INT8.toString(),Int8Array],[h.INT16.toString(),Int16Array],[h.INT32.toString(),Int32Array],[h.INT64.toString(),BigInt64Array],[h.TIMESTAMP.toString(),BigInt64Array],[h.STRING.toString(),Uint8Array],[h.JSON.toString(),Uint8Array],[h.UUID.toString(),Uint8Array]])),d(h,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,h.UINT8],[Uint16Array.name,h.UINT16],[Uint32Array.name,h.UINT32],[BigUint64Array.name,h.UINT64],[Float32Array.name,h.FLOAT32],[Float64Array.name,h.FLOAT64],[Int8Array.name,h.INT8],[Int16Array.name,h.INT16],[Int32Array.name,h.INT32],[BigInt64Array.name,h.INT64]])),d(h,"DENSITIES",new Map([[h.UINT8.toString(),V.BIT8],[h.UINT16.toString(),V.BIT16],[h.UINT32.toString(),V.BIT32],[h.UINT64.toString(),V.BIT64],[h.FLOAT32.toString(),V.BIT32],[h.FLOAT64.toString(),V.BIT64],[h.INT8.toString(),V.BIT8],[h.INT16.toString(),V.BIT16],[h.INT32.toString(),V.BIT32],[h.INT64.toString(),V.BIT64],[h.TIMESTAMP.toString(),V.BIT64],[h.STRING.toString(),V.UNKNOWN],[h.JSON.toString(),V.UNKNOWN],[h.UUID.toString(),V.BIT128]])),d(h,"ALL",[h.UNKNOWN,h.FLOAT64,h.FLOAT32,h.INT64,h.INT32,h.INT16,h.INT8,h.UINT64,h.UINT32,h.UINT16,h.UINT8,h.TIMESTAMP,h.UUID,h.STRING,h.JSON]),d(h,"BIG_INT_TYPES",[h.INT64,h.UINT64,h.TIMESTAMP]),d(h,"z",s.z.union([s.z.string().transform(r=>new h(r)),s.z.instanceof(h)]));let S=h;const W=class Z extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Z.bytes(this.valueOf()+e.valueOf())}sub(e){return Z.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Z(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Z.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Z.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Z.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Z.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Z.TERABYTE.valueOf()}toString(){const e=this.truncate(Z.TERABYTE),t=this.truncate(Z.GIGABYTE),n=this.truncate(Z.MEGABYTE),a=this.truncate(Z.KILOBYTE),i=this.truncate(Z.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.trim()}static bytes(e=1){return new Z(e)}static kilobytes(e=1){return Z.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Z.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Z.megabytes(e.valueOf()*1e3)}static terabytes(e){return Z.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};d(W,"BYTE",new W(1)),d(W,"KILOBYTE",W.kilobytes(1)),d(W,"MEGABYTE",W.megabytes(1)),d(W,"GIGABYTE",W.gigabytes(1)),d(W,"TERABYTE",W.terabytes(1)),d(W,"ZERO",new W(0)),d(W,"z",s.z.union([s.z.number().transform(r=>new W(r)),s.z.instanceof(W)]));let ot=W;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const Ms=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof E||r instanceof N||r instanceof Date},$o=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):tt(t,-n),Co=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof F?!0:Ms(r),Re=-1;class F{constructor(e){d(this,"key",""),d(this,"isSynnaxSeries",!0),d(this,"dataType"),d(this,"sampleOffset"),d(this,"gl"),d(this,"_data"),d(this,"_timeRange"),d(this,"alignment",0n),d(this,"_cachedMin"),d(this,"_cachedMax"),d(this,"writePos",Re),d(this,"_refCount",0),d(this,"_cachedLength"),Co(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:a=0,glBufferUsage:i="static",alignment:o=0n,key:l=ko()}=e,{data:u}=e;if(u instanceof F||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){const y=u;this.key=y.key,this.dataType=y.dataType,this.sampleOffset=y.sampleOffset,this.gl=y.gl,this._data=y._data,this._timeRange=y._timeRange,this.alignment=y.alignment,this._cachedMin=y._cachedMin,this._cachedMax=y._cachedMax,this.writePos=y.writePos,this._refCount=y._refCount,this._cachedLength=y._cachedLength;return}const p=Ms(u),g=Array.isArray(u);if(t!=null)this.dataType=new S(t);else{if(u instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(g||p){let y=u;if(!p){if(u.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");y=u[0]}if(typeof y=="string")this.dataType=S.STRING;else if(typeof y=="number")this.dataType=S.FLOAT64;else if(typeof y=="bigint")this.dataType=S.INT64;else if(typeof y=="boolean")this.dataType=S.BOOLEAN;else if(y instanceof E||y instanceof Date||y instanceof E)this.dataType=S.TIMESTAMP;else if(typeof y=="object")this.dataType=S.JSON;else throw new Error(`cannot infer data type of ${typeof y} when constructing a Series from a JS array`)}else this.dataType=new S(u)}if(!g&&!p)this._data=u;else{let y=p?[u]:u;const U=y[0];(U instanceof E||U instanceof Date||U instanceof N)&&(y=y.map(x=>new E(x).valueOf())),this.dataType.equals(S.STRING)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(y.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`)):this.dataType.equals(
|
|
3
|
+
`)):this.dataType.equals(S.JSON)?(this._cachedLength=y.length,this._data=new TextEncoder().encode(y.map(x=>JSON.stringify(x)).join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`)):this._data=new this.dataType.Array(
|
|
5
|
+
`)):this._data=new this.dataType.Array(y).buffer}this.key=l,this.alignment=o,this.sampleOffset=a??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:i}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const a=new new S(t).Array(e),i=new F({data:a.buffer,dataType:t,...n});return i.writePos=0,i}static generateTimestamps(e,t,n){const a=n.spanRange(t.span(e)),i=new BigInt64Array(e);for(let o=0;o<e;o++)i[o]=BigInt(n.add(t.span(o)).valueOf());return new F({data:i,dataType:S.TIMESTAMP,timeRange:a})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`);return new
|
|
7
|
+
`);return new F({data:n,dataType:S.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(a=>JSON.stringify(a)).join(`
|
|
8
8
|
`)+`
|
|
9
|
-
`);return new
|
|
10
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(
|
|
11
|
-
`).slice(0,-1).map(t=>e.parse(Pr(JSON.parse(t))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new En(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Lt?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Lt?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let r=0;r<this.length;r++)n[r]=Iy(this.dataType,e,this.data[r],t);return new Te({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(G.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),js(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(G.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),js(this._cachedMin,this.sampleOffset))}get bounds(){return Rs(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 js(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return js(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,r=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){r=i;break}n=i+1,e--}if(r===0&&(r=this.data.length),n>=r||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,r);return this.dataType.equals(G.STRING)?new TextDecoder().decode(a):Pr(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const r=Xf(e);for(;t<=n;){const a=Math.floor((t+n)/2),i=r(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(G.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:r}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==r)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Lt){r===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(r).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Lt}as(e){if(e==="string"){if(!this.dataType.equals(G.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(G.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Rs(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Ay(this);return this.dataType.equals(G.JSON)?new Cy(e):e}return new $y(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new Te({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new Te({data:this.buffer,dataType:this.dataType,timeRange:Ee.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Ay{constructor(e){if(v(this,"series"),v(this,"index"),v(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var sl;class Cy{constructor(e){v(this,"wrapped"),v(this,sl,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Pr(JSON.parse(e.value))}}[Symbol.iterator](){return this}}sl=Symbol.toStringTag;var nl;class $y{constructor(e){v(this,"series"),v(this,"index"),v(this,nl,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}nl=Symbol.toStringTag;const js=(s,e)=>typeof s=="bigint"&&typeof e=="bigint"||typeof s=="number"&&typeof e=="number"?s+e:e===0?s:s===0?e:Number(s)+Number(e);class rl{constructor(e){if(v(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new G(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?G.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?Ee.ZERO:new Ee(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new En(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new jy(this.series)}}var al;class jy{constructor(e){v(this,"series"),v(this,"seriesIndex"),v(this,"internal"),v(this,al,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}al=Symbol.toStringTag;const ws=c.z.number(),Mn=c.z.object({name:c.z.string(),key:c.z.number(),rate:va.z,dataType:G.z,leaseholder:c.z.number(),index:c.z.number(),isIndex:c.z.boolean(),alias:c.z.string().optional()}),il=Mn.extend({key:c.z.number().optional(),leaseholder:c.z.number().optional(),index:c.z.number().optional(),rate:va.z.optional().default(0),isIndex:c.z.boolean().optional(),virtual:c.z.boolean().optional().default(!1)}),zy=c.z.object({channels:il.array()}),Ry=c.z.object({channels:Mn.array()}),Py=c.z.object({keys:ws.array().optional(),names:c.z.string().array().optional()}),My=c.z.object({}),Dy="/channel/create",Ly="/channel/delete";let ol=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Dy,{channels:e},zy,Ry)).channels}async delete(e){await C(this.client,Ly,e,Py,My)}};const X=s=>Array.isArray(s)?s:[s],Uy=(s,e)=>{let t=null;return e===0?s:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>s(...n),e)}},By=new Error("request for lock canceled");var qy=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(n.next(h))}catch(g){i(g)}}function u(h){try{l(n.throw(h))}catch(g){i(g)}}function l(h){h.done?a(h.value):r(h.value).then(o,u)}l((n=n.apply(s,e||[])).next())})};class Vy{constructor(e,t=By){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,r)=>{const a={resolve:n,reject:r,weight:e,priority:t},i=cl(this._queue,o=>t<=o.priority);i===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(i+1,0,a)})}runExclusive(e){return qy(this,arguments,void 0,function*(t,n=1,r=0){const[a,i]=yield this.acquire(n,r);try{return yield t(a)}finally{i()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Ky(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const r=n.findIndex(a=>a.priority<=e);(r===-1?n:n.splice(0,r)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Ky(s,e){const t=cl(s,n=>e.priority<=n.priority);s.splice(t+1,0,e)}function cl(s,e){for(let t=s.length-1;t>=0;t--)if(e(s[t]))return t;return-1}var Wy=function(s,e,t,n){function r(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(n.next(h))}catch(g){i(g)}}function u(h){try{l(n.throw(h))}catch(g){i(g)}}function l(h){h.done?a(h.value):r(h.value).then(o,u)}l((n=n.apply(s,e||[])).next())})};class Fy{constructor(e){this._semaphore=new Vy(1,e)}acquire(){return Wy(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const bs="sy.";class de extends Error{}d(de,"TYPE",bs+"validation");class Ni extends de{constructor(t,n){super(t+": "+n);d(this,"field");d(this,"message");this.field=t,this.message=n}}d(Ni,"TYPE",de.TYPE+".field");class vs extends Error{}d(vs,"TYPE",bs+"auth");class Jr extends vs{}d(Jr,"TYPE",vs.TYPE+".invalid-token");class Vt extends Error{constructor(e){super(`
|
|
9
|
+
`);return new F({data:n,dataType:S.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Re)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Re?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(S.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
10
|
+
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(S.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=S.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const a=this.buffer.slice(n*e,(n+1)*e),i=Array.from(new Uint8Array(a),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=i}return t}parseJSON(e){if(!this.dataType.equals(S.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
11
|
+
`).slice(0,-1).map(t=>e.parse(Mt(JSON.parse(t))))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new ot(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Re?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Re?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let a=0;a<this.length;a++)n[a]=$o(this.dataType,e,this.data[a],t);return new F({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),tt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(S.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),tt(this._cachedMin,this.sampleOffset))}get bounds(){return at(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 tt(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return tt(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,a=0;for(let o=0;o<this.data.length;o++)if(this.data[o]===10){if(e===0){a=o;break}n=o+1,e--}if(a===0&&(a=this.data.length),n>=a||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const i=this.data.slice(n,a);return this.dataType.equals(S.STRING)?new TextDecoder().decode(i):Mt(JSON.parse(new TextDecoder().decode(i)))}binarySearch(e){let t=0,n=this.length-1;const a=Gi(e);for(;t<=n;){const i=Math.floor((t+n)/2),o=a(this.at(i,!0),e);if(o===0)return i;o<0?t=i+1:n=i-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(S.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:a}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==a)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Re){a===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const i=this.dataType.density.size(a).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,i,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Re}as(e){if(e==="string"){if(!this.dataType.equals(S.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(S.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return at(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 Ro(this);return this.dataType.equals(S.JSON)?new jo(e):e}return new xo(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new F({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(e){return new F({data:this.buffer,dataType:this.dataType,timeRange:J.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Ro{constructor(e){if(d(this,"series"),d(this,"index"),d(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var _s;let jo=class{constructor(e){d(this,"wrapped"),d(this,_s,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:Mt(JSON.parse(e.value))}}[Symbol.iterator](){return this}};_s=Symbol.toStringTag;var Us;let xo=class{constructor(e){d(this,"series"),d(this,"index"),d(this,Us,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};Us=Symbol.toStringTag;const tt=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);let Ls=class{constructor(e){if(d(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new S(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?S.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?J.ZERO:new J(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new ot(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const n of this.series)e.set(n.data,t),t+=n.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Do(this.series)}};var Bs;let Do=class{constructor(e){d(this,"series"),d(this,"seriesIndex"),d(this,"internal"),d(this,Bs,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}};Bs=Symbol.toStringTag;const z=r=>Array.isArray(r)?r:[r],$e=s.z.number(),yt=s.z.object({name:s.z.string(),key:s.z.number(),rate:Ht.z,dataType:S.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),alias:s.z.string().optional()}),qs=yt.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:Ht.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),Po=(r,e)=>{let t=null;return e===0?r:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...n),e)}},Zo=new Error("request for lock canceled");var Mo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class _o{constructor(e,t=Zo){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,a)=>{const i={resolve:n,reject:a,weight:e,priority:t},o=Ys(this._queue,l=>t<=l.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return Mo(this,arguments,void 0,function*(t,n=1,a=0){const[i,o]=yield this.acquire(n,a);try{return yield t(i)}finally{o()}})}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Uo(this._weightedWaiters[e-1],{resolve:n,priority:t})})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach(e=>e.reject(this._cancelError)),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const a=n.findIndex(i=>i.priority<=e);(a===-1?n:n.splice(0,a)).forEach(i=>i.resolve())}}}_couldLockImmediately(e,t){return(this._queue.length===0||this._queue[0].priority<t)&&e<=this._value}}function Uo(r,e){const t=Ys(r,n=>e.priority<=n.priority);r.splice(t+1,0,e)}function Ys(r,e){for(let t=r.length-1;t>=0;t--)if(e(r[t]))return t;return-1}var Lo=function(r,e,t,n){function a(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function l(g){try{p(n.next(g))}catch(y){o(y)}}function u(g){try{p(n.throw(g))}catch(y){o(y)}}function p(g){g.done?i(g.value):a(g.value).then(l,u)}p((n=n.apply(r,e||[])).next())})};class Bo{constructor(e){this._semaphore=new _o(1,e)}acquire(){return Lo(this,arguments,void 0,function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t})}runExclusive(e,t=0){return this._semaphore.runExclusive(()=>e(),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var qo=Object.defineProperty,Yo=(r,e,t)=>e in r?qo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e,t)=>(Yo(r,typeof e!="symbol"?e+"":e,t),t),re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},T={},Xt={};Object.defineProperty(Xt,"__esModule",{value:!0});function Wo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Xt.default=Wo;var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0});function Ko(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Qt.default=Ko;var er={};Object.defineProperty(er,"__esModule",{value:!0});function Vo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}er.default=Vo;var fn={};Object.defineProperty(fn,"__esModule",{value:!0});function Fo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}fn.default=Fo;var dn={};Object.defineProperty(dn,"__esModule",{value:!0});function Jo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}dn.default=Jo;var yn={};Object.defineProperty(yn,"__esModule",{value:!0});function Go(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}yn.default=Go;var pn={};Object.defineProperty(pn,"__esModule",{value:!0});function Ho(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,a){return n+"_"+a.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}pn.default=Ho;var gn={};Object.defineProperty(gn,"__esModule",{value:!0});function Xo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,a){return t+n.charAt(0).toUpperCase()+n.slice(1)+a}):""}gn.default=Xo;var tr={};Object.defineProperty(tr,"__esModule",{value:!0});function Qo(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}tr.default=Qo;var mn={},Me={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(Me);var ec=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(mn,"__esModule",{value:!0});var ge=Me;function $t(r,e){if(e===void 0&&(e=ge.DefaultOption),!ge.isValidObject(r))return null;e=ge.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toLowerCase();e.recursive&&(ge.isValidObject(a)?ge.belongToTypes(a,e.keepTypesOnRecursion)||(a=$t(a,e)):e.recursiveInArray&&ge.isArrayObject(a)&&(a=ec(a).map(function(o){var l=o;if(ge.isValidObject(o))ge.belongToTypes(l,e.keepTypesOnRecursion)||(l=$t(o,e));else if(ge.isArrayObject(o)){var u=$t({key:o},e);l=u.key}return l}))),t[i]=a}),t}mn.default=$t;var wn={},tc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(wn,"__esModule",{value:!0});var me=Me;function Ct(r,e){if(e===void 0&&(e=me.DefaultOption),!me.isValidObject(r))return null;e=me.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=n.toUpperCase();e.recursive&&(me.isValidObject(a)?me.belongToTypes(a,e.keepTypesOnRecursion)||(a=Ct(a,e)):e.recursiveInArray&&me.isArrayObject(a)&&(a=tc(a).map(function(o){var l=o;if(me.isValidObject(o))me.belongToTypes(l,e.keepTypesOnRecursion)||(l=Ct(o,e));else if(me.isArrayObject(o)){var u=Ct({key:o},e);l=u.key}return l}))),t[i]=a}),t}wn.default=Ct;var vn={},rc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(vn,"__esModule",{value:!0});var we=Me,nc=Xt;function Rt(r,e){if(e===void 0&&(e=we.DefaultOption),!we.isValidObject(r))return null;e=we.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=nc.default(n);e.recursive&&(we.isValidObject(a)?we.belongToTypes(a,e.keepTypesOnRecursion)||(a=Rt(a,e)):e.recursiveInArray&&we.isArrayObject(a)&&(a=rc(a).map(function(o){var l=o;if(we.isValidObject(o))we.belongToTypes(l,e.keepTypesOnRecursion)||(l=Rt(o,e));else if(we.isArrayObject(o)){var u=Rt({key:o},e);l=u.key}return l}))),t[i]=a}),t}vn.default=Rt;var bn={},sc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(bn,"__esModule",{value:!0});var ve=Me,ac=Qt;function jt(r,e){if(e===void 0&&(e=ve.DefaultOption),!ve.isValidObject(r))return null;e=ve.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=ac.default(n);e.recursive&&(ve.isValidObject(a)?ve.belongToTypes(a,e.keepTypesOnRecursion)||(a=jt(a,e)):e.recursiveInArray&&ve.isArrayObject(a)&&(a=sc(a).map(function(o){var l=o;if(ve.isValidObject(o))ve.belongToTypes(l,e.keepTypesOnRecursion)||(l=jt(o,e));else if(ve.isArrayObject(o)){var u=jt({key:o},e);l=u.key}return l}))),t[i]=a}),t}bn.default=jt;var On={},ic=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(On,"__esModule",{value:!0});var be=Me,oc=er;function xt(r,e){if(e===void 0&&(e=be.DefaultOption),!be.isValidObject(r))return null;e=be.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=oc.default(n);e.recursive&&(be.isValidObject(a)?be.belongToTypes(a,e.keepTypesOnRecursion)||(a=xt(a,e)):e.recursiveInArray&&be.isArrayObject(a)&&(a=ic(a).map(function(o){var l=o;if(be.isValidObject(o))be.belongToTypes(l,e.keepTypesOnRecursion)||(l=xt(o,e));else if(be.isArrayObject(o)){var u=xt({key:o},e);l=u.key}return l}))),t[i]=a}),t}On.default=xt;var Tn={},cc=re&&re.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),a=0,e=0;e<t;e++)for(var i=arguments[e],o=0,l=i.length;o<l;o++,a++)n[a]=i[o];return n};Object.defineProperty(Tn,"__esModule",{value:!0});var Oe=Me,lc=tr;function Dt(r,e){if(e===void 0&&(e=Oe.DefaultOption),!Oe.isValidObject(r))return null;e=Oe.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var a=r[n],i=lc.default(n);e.recursive&&(Oe.isValidObject(a)?Oe.belongToTypes(a,e.keepTypesOnRecursion)||(a=Dt(a,e)):e.recursiveInArray&&Oe.isArrayObject(a)&&(a=cc(a).map(function(o){var l=o;if(Oe.isValidObject(o))Oe.belongToTypes(l,e.keepTypesOnRecursion)||(l=Dt(o,e));else if(Oe.isArrayObject(o)){var u=Dt({key:o},e);l=u.key}return l}))),t[i]=a}),t}Tn.default=Dt;Object.defineProperty(T,"__esModule",{value:!0});T.kebabKeys=T.pascalKeys=T.snakeKeys=T.camelKeys=T.upperKeys=T.lowerKeys=T.toLowerCase=T.toUpperCase=T.toKebabCase=T.toHeaderCase=T.toSentenceCase=T.toTextCase=T.toPathCase=T.toDotCase=T.toPascalCase=T.toSnakeCase=T.toCamelCase=void 0;var Ws=Xt;T.toCamelCase=Ws.default;var Ks=Qt;T.toSnakeCase=Ks.default;var Vs=er;T.toPascalCase=Vs.default;var Fs=fn;T.toDotCase=Fs.default;var Js=dn;T.toPathCase=Js.default;var Gs=yn;T.toTextCase=Gs.default;var Hs=pn;T.toSentenceCase=Hs.default;var Xs=gn;T.toHeaderCase=Xs.default;var Qs=tr;T.toKebabCase=Qs.default;var ea=mn;T.lowerKeys=ea.default;var ta=wn;T.upperKeys=ta.default;var ra=vn;T.camelKeys=ra.default;var na=bn;T.snakeKeys=na.default;var sa=On;T.pascalKeys=sa.default;var aa=Tn;T.kebabKeys=aa.default;var ia=function(r){return String(r||"").toLowerCase()};T.toLowerCase=ia;var oa=function(r){return String(r||"").toUpperCase()};T.toUpperCase=oa;var uc={toCamelCase:Ws.default,toSnakeCase:Ks.default,toPascalCase:Vs.default,toDotCase:Fs.default,toPathCase:Js.default,toTextCase:Gs.default,toSentenceCase:Hs.default,toHeaderCase:Xs.default,toKebabCase:Qs.default,toUpperCase:oa,toLowerCase:ia,lowerKeys:ea.default,upperKeys:ta.default,camelKeys:ra.default,snakeKeys:na.default,pascalKeys:sa.default,kebabKeys:aa.default};T.default=uc;var ca=T;const la={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},hc=r=>ca.snakeKeys(r,la),fc=r=>ca.camelKeys(r,la),dc=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var yc=Object.defineProperty,pc=(r,e,t)=>e in r?yc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vr=(r,e,t)=>(pc(r,typeof e!="symbol"?e+"":e,t),t);let gc=class{constructor(){vr(this,"contentType","application/json"),vr(this,"decoder"),vr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(r){return this.encoder.encode(this.encodeString(r)).buffer}decode(r,e){return this.decodeString(this.decoder.decode(r),e)}decodeString(r,e){const t=fc(JSON.parse(r));return e!=null?e.parse(t):t}encodeString(r){return JSON.stringify(hc(r),(e,t)=>ArrayBuffer.isView(t)?Array.from(t):dc(t)&&"encode_value"in t?typeof t.value=="bigint"?t.value.toString():t.value:typeof t=="bigint"?t.toString():t)}static registerCustomType(){}};new gc;const rr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ua=s.z.object({width:s.z.number(),height:s.z.number()}),mc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),wc=["width","height"];s.z.enum(wc);const vc=["start","center","end"],bc=["signedWidth","signedHeight"];s.z.enum(bc);const Ut=s.z.object({x:s.z.number(),y:s.z.number()}),Oc=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Tc=["x","y"],ha=s.z.enum(Tc),fa=["top","right","bottom","left"];s.z.enum(fa);const zc=["left","right"],da=s.z.enum(zc),Ec=["top","bottom"],ya=s.z.enum(Ec),pa=["center"],Yn=s.z.enum(pa),Sc=[...fa,...pa],ga=s.z.enum(Sc);s.z.enum(vc);const Nc=["first","last"];s.z.enum(Nc);const Ac=s.z.object({lower:s.z.number(),upper:s.z.number()}),Ic=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Ac,rr]);s.z.union([Ic,rr]);s.z.union([ha,ga]);s.z.union([ha,ga,s.z.instanceof(String)]);const br=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return Wn(r);return Wn(t)},Wn=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;s.z.object({x:da.or(Yn),y:ya.or(Yn)});const kc=s.z.object({x:da,y:ya}),$c=Object.freeze({x:"left",y:"top"}),Cc=(r,e)=>r.x===e.x&&r.y===e.y,Kn=s.z.union([s.z.number(),Ut,rr,ua,mc,Oc]),Rc=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Vn=Object.freeze({x:0,y:0}),bt=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:bt,left:bt,width:bt,height:bt});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:Ut,two:Ut,root:kc});const zn=(r,e,t=0,n=0,a)=>{const i={one:{...Vn},two:{...Vn},root:a??$c};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:r,y:e},i.two={x:i.one.x+t,y:i.one.y+n},i}return"one"in r&&"two"in r&&"root"in r?{...r,root:a??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(i.one={x:r.left,y:r.top},i.two={x:r.right,y:r.bottom},i):(i.one=r,e==null?i.two={x:i.one.x+t,y:i.one.y+n}: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))},Or=r=>{const e=zn(r);return{lower:e.one.x,upper:e.two.x}},Tr=r=>{const e=zn(r);return{lower:e.one.y,upper:e.two.y}},jc=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r;var xc=Object.defineProperty,Dc=(r,e,t)=>e in r?xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Se=(r,e,t)=>(Dc(r,typeof e!="symbol"?e+"":e,t),t);const Pc=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);s.z.object({offset:Kn,scale:Kn});const Zc=r=>(e,t,n,a)=>t==="dimension"?[e,n]:[e,a?n-r:n+r],Mc=r=>(e,t,n,a)=>[e,a?n/r:n*r],_c=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:a,upper:i}=e,{lower:o,upper:l}=r,u=i-a,p=l-o;if(t==="dimension")return[r,n*(p/u)];const g=(n-a)*(p/u)+o;return[r,g]},Uc=r=>(e,t,n)=>[r,n],Lc=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:a}=r;return[r,a-(t-n)]},Bc=r=>(e,t,n)=>{const{lower:a,upper:i}=r;return n=Pc(n,a,i),[e,n]},_r=class rt{constructor(){Se(this,"ops",[]),Se(this,"currBounds",null),Se(this,"currType",null),Se(this,"reversed",!1),this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,t){return new rt().scale(e,t)}translate(e){const t=this.new(),n=Zc(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Mc(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=br(e,t),a=this.new(),i=_c(n);return i.type="scale",a.ops.push(i),a}clamp(e,t){const n=br(e,t),a=this.new(),i=Bc(n);return i.type="clamp",a.ops.push(i),a}reBound(e,t){const n=br(e,t),a=this.new(),i=Uc(n);return i.type="re-bound",a.ops.push(i),a}invert(){const e=Lc();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,a],i)=>i(n,e,a,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,a)=>{if(n.type==="scale"||t.some(([o,l])=>a>=o&&a<=l))return;const i=e.ops.findIndex((o,l)=>o.type==="scale"&&l>a);i!==-1&&t.push([a,i])}),t.forEach(([n,a])=>{const i=e.ops.slice(n,a);i.unshift(e.ops[a]),e.ops.splice(n,a-n+1,...i)}),e.reversed=!e.reversed,e}};Se(_r,"IDENTITY",new _r);let Fn=_r;const Jn=class ze{constructor(e=new Fn,t=new Fn,n=null){Se(this,"x"),Se(this,"y"),Se(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new ze().translate(e,t)}static translateX(e){return new ze().translateX(e)}static translateY(e){return new ze().translateY(e)}static clamp(e){return new ze().clamp(e)}static magnify(e){return new ze().magnify(e)}static scale(e){return new ze().scale(e)}static reBound(e){return new ze().reBound(e)}translate(e,t){const n=Rc(e,t),a=this.copy();return a.x=this.x.translate(n.x),a.y=this.y.translate(n.y),a}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(jc(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Cc(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Or(e)),t.y=t.y.scale(Tr(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(Or(e)),t.y=this.y.reBound(Tr(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Or(e)),t.y=this.y.clamp(Tr(e)),t}copy(){const e=new ze;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return zn(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Se(Jn,"IDENTITY",new Jn);s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const ma=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",qc=ma(),wa=["MacOS","Windows","Linux","Docker"],Yc=s.z.enum(wa);let zr;const Wc=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Kc=(r={})=>{const{force:e,default:t}=r;return e??zr??(zr=Wc(),zr??t)},va=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wa,RUNTIME:qc,detect:ma,getOS:Kc,osZ:Yc},Symbol.toStringTag,{value:"Module"})),Vc=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ua,Vc,Ut,rr]);var Fc=Object.defineProperty,Jc=(r,e,t)=>e in r?Fc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e,t)=>(Jc(r,typeof e!="symbol"?e+"":e,t),t);const ba=(r,e)=>{const t=new q(e);if(![Y.DAY,Y.HOUR,Y.MINUTE,Y.SECOND,Y.MILLISECOND,Y.MICROSECOND,Y.NANOSECOND].some(a=>a.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof q?new q(n):new Y(n)},C=class b{constructor(e,t="UTC"){if(m(this,"value"),m(this,"encodeValue",!0),e==null)this.value=b.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*b.MILLISECOND.valueOf();else if(typeof e=="string")this.value=b.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=b.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=b.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=b.MAX:e=b.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const a=new Date(e,t-1,n,0,0,0,0);return new b(BigInt(a.getTime())*b.MILLISECOND.valueOf()).truncate(b.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,a,i]=e.split(":");let o="00",l="00";i!=null&&([o,l]=i.split("."));let u=b.hours(parseInt(n??"00",10)).add(b.minutes(parseInt(a??"00",10))).add(b.seconds(parseInt(o??"00",10))).add(b.milliseconds(parseInt(l??"00",10)));return t==="local"&&(u=u.add(b.utcOffset)),u.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return b.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new b(BigInt(n.getTime())*b.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(b.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new Y(BigInt(new Date().getTimezoneOffset())*b.MINUTE.valueOf())}static since(e){return new b().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new b(e).valueOf()}span(e){return this.range(e).span}range(e){return new Gc(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 b(e).valueOf()}afterEq(e){return this.valueOf()>=new b(e).valueOf()}before(e){return this.valueOf()<new b(e).valueOf()}beforeEq(e){return this.valueOf()<=new b(e).valueOf()}add(e){return new b(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new b(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(b.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ba(this,e)}get isToday(){return this.truncate(Y.DAY).equals(b.now().truncate(Y.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new b(new Date)}static max(...e){let t=b.MIN;for(const n of e){const a=new b(n);a.after(t)&&(t=a)}return t}static min(...e){let t=b.MAX;for(const n of e){const a=new b(n);a.before(t)&&(t=a)}return t}static nanoseconds(e){return new b(e)}static microseconds(e){return b.nanoseconds(e*1e3)}static milliseconds(e){return b.microseconds(e*1e3)}static seconds(e){return b.milliseconds(e*1e3)}static minutes(e){return b.seconds(e*60)}static hours(e){return b.minutes(e*60)}static days(e){return b.hours(e*24)}};m(C,"NANOSECOND",C.nanoseconds(1)),m(C,"MICROSECOND",C.microseconds(1)),m(C,"MILLISECOND",C.milliseconds(1)),m(C,"SECOND",C.seconds(1)),m(C,"MINUTE",C.minutes(1)),m(C,"HOUR",C.hours(1)),m(C,"DAY",C.days(1)),m(C,"MAX",new C((1n<<63n)-1n)),m(C,"MIN",new C(0)),m(C,"ZERO",new C(0)),m(C,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new C(r.value)),s.z.string().transform(r=>new C(BigInt(r))),s.z.instanceof(Number).transform(r=>new C(r)),s.z.number().transform(r=>new C(r)),s.z.instanceof(C)]));let q=C;const R=class I{constructor(e){m(this,"value"),m(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return ba(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),t=this.truncate(I.HOUR),n=this.truncate(I.MINUTE),a=this.truncate(I.SECOND),i=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),l=this.truncate(I.NANOSECOND),u=e,p=t.sub(e),g=n.sub(t),y=a.sub(n),U=i.sub(a),x=o.sub(i),Q=l.sub(o);let P="";return u.isZero||(P+=`${u.days}d `),p.isZero||(P+=`${p.hours}h `),g.isZero||(P+=`${g.minutes}m `),y.isZero||(P+=`${y.seconds}s `),U.isZero||(P+=`${U.milliseconds}ms `),x.isZero||(P+=`${x.microseconds}µs `),Q.isZero||(P+=`${Q.nanoseconds}ns`),P.trim()}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(e*1e3)}static milliseconds(e=1){return I.microseconds(e*1e3)}static seconds(e=1){return I.milliseconds(e*1e3)}static minutes(e){return I.seconds(e.valueOf()*60)}static hours(e){return I.minutes(e*60)}static days(e){return I.hours(e*24)}};m(R,"NANOSECOND",R.nanoseconds(1)),m(R,"MICROSECOND",R.microseconds(1)),m(R,"MILLISECOND",R.milliseconds(1)),m(R,"SECOND",R.seconds(1)),m(R,"MINUTE",R.minutes(1)),m(R,"HOUR",R.hours(1)),m(R,"DAY",R.days(1)),m(R,"MAX",new R((1n<<63n)-1n)),m(R,"MIN",new R(0)),m(R,"ZERO",new R(0)),m(R,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(r=>new R(r.value)),s.z.string().transform(r=>new R(BigInt(r))),s.z.instanceof(Number).transform(r=>new R(r)),s.z.number().transform(r=>new R(r)),s.z.instanceof(R)]));let Y=R;const Ot=class Pt extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Pt(e).valueOf()}get period(){return Y.seconds(1/this.valueOf())}sampleCount(e){return new Y(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new H(t).valueOf()}span(e){return Y.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Pt(e)}static khz(e){return Pt.hz(e*1e3)}};m(Ot,"z",s.z.union([s.z.number().transform(r=>new Ot(r)),s.z.instanceof(Number).transform(r=>new Ot(r)),s.z.instanceof(Ot)]));const B=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new Hc(r*this.valueOf())}};m(B,"UNKNOWN",new B(0)),m(B,"BIT128",new B(16)),m(B,"BIT64",new B(8)),m(B,"BIT32",new B(4)),m(B,"BIT16",new B(2)),m(B,"BIT8",new B(1)),m(B,"z",s.z.union([s.z.number().transform(r=>new B(r)),s.z.instanceof(Number).transform(r=>new B(r)),s.z.instanceof(B)]));let H=B;const ie=class Zt{constructor(e,t){m(this,"start"),m(this,"end"),typeof e=="object"&&"start"in e?(this.start=new q(e.start),this.end=new q(e.end)):(this.start=new q(e),this.end=new q(t))}get span(){return new Y(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Zt(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=Y.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const a=q.max(n.start,e.start),i=q.min(n.end,e.end);return i.before(a)?!1:new Y(i.sub(a)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),a=this.end.sub(e.end).valueOf();return n<0&&(n=-n),a<0&&(a=-a),n<=t.valueOf()&&a<=t.valueOf()}contains(e){return e instanceof Zt?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Zt(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};m(ie,"MAX",new ie(q.MIN,q.MAX)),m(ie,"MIN",new ie(q.MAX,q.MIN)),m(ie,"ZERO",new ie(q.ZERO,q.ZERO)),m(ie,"z",s.z.union([s.z.object({start:q.z,end:q.z}).transform(r=>new ie(r.start,r.end)),s.z.instanceof(ie)]));let Gc=ie;const f=class oe extends String{constructor(e){if(e instanceof oe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=oe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(oe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=oe.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(oe.JSON)||this.equals(oe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(oe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=oe.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return oe.BIG_INT_TYPES.some(e=>e.equals(this))}};m(f,"UNKNOWN",new f("unknown")),m(f,"FLOAT64",new f("float64")),m(f,"FLOAT32",new f("float32")),m(f,"INT64",new f("int64")),m(f,"INT32",new f("int32")),m(f,"INT16",new f("int16")),m(f,"INT8",new f("int8")),m(f,"UINT64",new f("uint64")),m(f,"UINT32",new f("uint32")),m(f,"UINT16",new f("uint16")),m(f,"UINT8",new f("uint8")),m(f,"BOOLEAN",f.UINT8),m(f,"TIMESTAMP",new f("timestamp")),m(f,"UUID",new f("uuid")),m(f,"STRING",new f("string")),m(f,"JSON",new f("json")),m(f,"ARRAY_CONSTRUCTORS",new Map([[f.UINT8.toString(),Uint8Array],[f.UINT16.toString(),Uint16Array],[f.UINT32.toString(),Uint32Array],[f.UINT64.toString(),BigUint64Array],[f.FLOAT32.toString(),Float32Array],[f.FLOAT64.toString(),Float64Array],[f.INT8.toString(),Int8Array],[f.INT16.toString(),Int16Array],[f.INT32.toString(),Int32Array],[f.INT64.toString(),BigInt64Array],[f.TIMESTAMP.toString(),BigInt64Array],[f.STRING.toString(),Uint8Array],[f.JSON.toString(),Uint8Array],[f.UUID.toString(),Uint8Array]])),m(f,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,f.UINT8],[Uint16Array.name,f.UINT16],[Uint32Array.name,f.UINT32],[BigUint64Array.name,f.UINT64],[Float32Array.name,f.FLOAT32],[Float64Array.name,f.FLOAT64],[Int8Array.name,f.INT8],[Int16Array.name,f.INT16],[Int32Array.name,f.INT32],[BigInt64Array.name,f.INT64]])),m(f,"DENSITIES",new Map([[f.UINT8.toString(),H.BIT8],[f.UINT16.toString(),H.BIT16],[f.UINT32.toString(),H.BIT32],[f.UINT64.toString(),H.BIT64],[f.FLOAT32.toString(),H.BIT32],[f.FLOAT64.toString(),H.BIT64],[f.INT8.toString(),H.BIT8],[f.INT16.toString(),H.BIT16],[f.INT32.toString(),H.BIT32],[f.INT64.toString(),H.BIT64],[f.TIMESTAMP.toString(),H.BIT64],[f.STRING.toString(),H.UNKNOWN],[f.JSON.toString(),H.UNKNOWN],[f.UUID.toString(),H.BIT128]])),m(f,"ALL",[f.UNKNOWN,f.FLOAT64,f.FLOAT32,f.INT64,f.INT32,f.INT16,f.INT8,f.UINT64,f.UINT32,f.UINT16,f.UINT8,f.TIMESTAMP,f.UUID,f.STRING,f.JSON]),m(f,"BIG_INT_TYPES",[f.INT64,f.UINT64,f.TIMESTAMP]),m(f,"z",s.z.union([s.z.string().transform(r=>new f(r)),s.z.instanceof(f)]));const K=class M extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return M.bytes(this.valueOf()+e.valueOf())}sub(e){return M.bytes(this.valueOf()-e.valueOf())}truncate(e){return new M(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return M.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/M.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/M.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/M.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/M.TERABYTE.valueOf()}toString(){const e=this.truncate(M.TERABYTE),t=this.truncate(M.GIGABYTE),n=this.truncate(M.MEGABYTE),a=this.truncate(M.KILOBYTE),i=this.truncate(M.BYTE),o=e,l=t.sub(e),u=n.sub(t),p=a.sub(n),g=i.sub(a);let y="";return o.isZero||(y+=`${o.terabytes}TB `),l.isZero||(y+=`${l.gigabytes}GB `),u.isZero||(y+=`${u.megabytes}MB `),p.isZero||(y+=`${p.kilobytes}KB `),(!g.isZero||y==="")&&(y+=`${g.valueOf()}B`),y.trim()}static bytes(e=1){return new M(e)}static kilobytes(e=1){return M.bytes(e.valueOf()*1e3)}static megabytes(e=1){return M.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return M.megabytes(e.valueOf()*1e3)}static terabytes(e){return M.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};m(K,"BYTE",new K(1)),m(K,"KILOBYTE",K.kilobytes(1)),m(K,"MEGABYTE",K.megabytes(1)),m(K,"GIGABYTE",K.gigabytes(1)),m(K,"TERABYTE",K.terabytes(1)),m(K,"ZERO",new K(0)),m(K,"z",s.z.union([s.z.number().transform(r=>new K(r)),s.z.instanceof(K)]));let Hc=K;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);var Xc=Object.defineProperty,Qc=(r,e,t)=>e in r?Xc(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nt=(r,e,t)=>(Qc(r,typeof e!="symbol"?e+"":e,t),t);const el=(...r)=>r.map(Oa).join(""),Oa=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),tl=r=>r.endsWith("/")?r.slice(0,-1):r,rl=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&"),Ur=class Lr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){nt(this,"protocol"),nt(this,"host"),nt(this,"port"),nt(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Oa(a)}replace(e){return new Lr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Lr({...this,pathPrefix:el(this.path,e)})}toString(){return tl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};nt(Ur,"UNKNOWN",new Ur({host:"unknown",port:0}));let nl=Ur;var sl=Object.defineProperty,al=(r,e,t)=>e in r?sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Er=(r,e,t)=>(al(r,typeof e!="symbol"?e+"":e,t),t);const Ue=class extends Number{};Er(Ue,"Absolute",255),Er(Ue,"Default",1),Er(Ue,"z",s.z.union([s.z.instanceof(Ue),s.z.number().int().min(0).max(255).transform(r=>new Ue(r)),s.z.instanceof(Number).transform(r=>new Ue(r))]));s.z.object({name:s.z.string(),key:s.z.string()});const il=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:il});class nr extends Error{constructor(e,t){super(e),j(this,"discriminator","FreighterError"),j(this,"type"),this.type=t}}const ol=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Br="unknown",Gn="nil",sr="freighter",pt=s.z.object({type:s.z.string(),data:s.z.string()});class cl{constructor(){j(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Gn,data:""};if(ol(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Br,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Gn)return null;if(e.type===Br)return new Hn(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Hn(e.data)}}const Ta=new cl,za=({encode:r,decode:e})=>Ta.register({encode:r,decode:e}),En=r=>Ta.decode(r);class Hn extends nr{constructor(e){super(e,Br)}}const ar="freighter.";class Ne extends nr{constructor(){super("EOF",sr)}}j(Ne,"TYPE",ar+"eof");class Pe extends nr{constructor(){super("StreamClosed",sr)}}j(Pe,"TYPE",ar+"stream_closed");class Ie extends nr{constructor(e={}){const{message:t="Unreachable",url:n=nl.UNKNOWN}=e;super(t,sr),j(this,"url"),this.url=n}}j(Ie,"TYPE",ar+"unreachable");const ll=r=>{if(r.type!==sr)return null;if(r instanceof Ne)return{type:Ne.TYPE,data:"EOF"};if(r instanceof Pe)return{type:Pe.TYPE,data:"StreamClosed"};if(r instanceof Ie)return{type:Ie.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},ul=r=>{if(!r.type.startsWith(ar))return null;switch(r.type){case Ne.TYPE:return new Ne;case Pe.TYPE:return new Pe;case Ie.TYPE:return new Ie;default:throw new Error(`Unknown error type: ${r.data}`)}};za({encode:ll,decode:ul});class Ea{constructor(){j(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const a=async i=>{if(n===this.middleware.length)return await t(i);const o=this.middleware[n];return n++,await o(i,a)};return await a(e)}}const Sa="Content-Type",Xn=r=>{if(va.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(a,i)=>await e(a,{...i,agent:n})};class hl extends Ea{constructor(e,t,n=!1){return super(),j(this,"endpoint"),j(this,"encoder"),j(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Xn(this.endpoint.protocol),new Proxy(this,{get:(a,i,o)=>i==="endpoint"?this.endpoint:Reflect.get(a,i,o)})}get headers(){return{[Sa]:this.encoder.contentType}}async send(e,t,n,a){t=n==null?void 0:n.parse(t);let i=null;const o=this.endpoint.child(e),l={};l.method="POST",l.body=this.encoder.encode(t??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async p=>{const g={...p,params:{}};l.headers={...this.headers,...p.params};let y;try{y=await Xn(p.protocol)(p.target,l)}catch(x){let Q=x;return Q.message==="Load failed"&&(Q=new Ie({url:o})),[g,Q]}const U=await y.arrayBuffer();if(y!=null&&y.ok)return a!=null&&(i=this.encoder.decode(U,a)),[g,null];try{if(y.status!==400)return[g,new Error(y.statusText)];const x=this.encoder.decode(U,pt),Q=En(x);return[g,Q]}catch(x){return[g,new Error(`[freighter] - failed to decode error: ${y.statusText}: ${x.message}`)]}});return[i,u]}}const w=async(r,e,t,n,a)=>{const[i,o]=await r.send(e,t,n,a);if(o!=null)throw o;return i},fl=()=>va.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),dl=s.z.object({type:s.z.union([s.z.literal("data"),s.z.literal("close")]),payload:s.z.unknown().optional(),error:s.z.optional(pt)});class yl{constructor(e,t,n,a){j(this,"encoder"),j(this,"reqSchema"),j(this,"resSchema"),j(this,"ws"),j(this,"serverClosed"),j(this,"sendClosed"),j(this,"receiveDataQueue",[]),j(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=a,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ne;if(this.sendClosed)throw new Pe;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=En(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,dl)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:vl(e)?Ne.TYPE:Pe.TYPE,data:""}})}}const pl="freighterctx",gl=1e3,ml=1001,wl=[gl,ml],vl=r=>wl.includes(r.code),Na=class Aa extends Ea{constructor(e,t,n=!1){super(),j(this,"baseUrl"),j(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const a=fl();let i;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async l=>{const u=a(this.buildURL(e,l)),p={...l,params:{}};u.binaryType=Aa.MESSAGE_TYPE;const g=await this.wrapSocket(u,t,n);return g instanceof Error?[p,g]:(i=g,[p,null])});if(o!=null)throw o;return i}buildURL(e,t){const n=rl({[Sa]:this.encoder.contentType,...t.params},pl);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(a=>{e.onopen=()=>{a(new yl(e,this.encoder,t,n))},e.onerror=i=>{const o=i;a(new Error(o.message))}})}};j(Na,"MESSAGE_TYPE","arraybuffer");let bl=Na;const _e="sy.";class D extends Error{}c(D,"TYPE",_e+"validation");class qr extends D{constructor(t,n){super(t+": "+n);c(this,"field");c(this,"message");this.field=t,this.message=n}}c(qr,"TYPE",D.TYPE+".field");class We extends Error{}c(We,"TYPE",_e+"auth");class Lt extends We{}c(Lt,"TYPE",We.TYPE+".invalid-token");class xe extends Error{constructor(e){super(`
|
|
12
12
|
Unexpected error encountered:
|
|
13
13
|
|
|
14
14
|
${e}
|
|
15
15
|
|
|
16
16
|
Please report this to the Synnax team.
|
|
17
|
-
`)}}d(Vt,"TYPE",bs+"unexpected");class Re extends Error{}d(Re,"TYPE",bs+"query");class Nn extends Re{}d(Nn,"TYPE",Re.TYPE+".not_found");class In extends Re{}d(In,"TYPE",Re.TYPE+".multiple_results");class Gr extends Error{constructor(t,n){super(t);d(this,"path");this.path=n}}d(Gr,"TYPE",bs+"route");class Yy extends Error{}const Jy=s=>{if(!s.type.startsWith(bs))return null;if(s.type.startsWith(de.TYPE)){if(s.type===Ni.TYPE){const e=s.data.split(": ");return e.length<2?new de(s.data):new Ni(e[0],e[1])}return new de(s.data)}return s.type.startsWith(vs.TYPE)?s.type.startsWith(Jr.TYPE)?new Jr(s.data):new vs(s.data):s.type.startsWith(Vt.TYPE)?new Vt(s.data):s.type.startsWith(Re.TYPE)?s.type.startsWith(Nn.TYPE)?new Nn(s.data):s.type.startsWith(In.TYPE)?new In(s.data):new Re(s.data):s.type.startsWith(Gr.TYPE)?new Gr(s.data,s.data):new Vt(s.data)},Gy=()=>{throw new Error("Not implemented")};lu({encode:Gy,decode:Jy});const Hy=async(s,e)=>{const[t,n]=await e(s);return n==null?[t,n]:n instanceof Rt?[t,new Rt({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},uo=f.record(f.union([f.number(),f.string(),f.symbol()]),f.unknown()),ul=s=>s!=null&&typeof s=="object"&&!Array.isArray(s),Xy=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Xy();const Qy=["MacOS","Windows","Linux","Docker"];f.enum(Qy);const Fo=s=>[...new Set(s)];var eg=Object.defineProperty,tg=(s,e,t)=>e in s?eg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,zs=(s,e,t)=>(tg(s,typeof e!="symbol"?e+"":e,t),t);const sg=(...s)=>s.map(ll).join(""),ll=s=>(s.endsWith("/")||(s+="/"),s.startsWith("/")&&(s=s.slice(1)),s),ng=s=>s.endsWith("/")?s.slice(0,-1):s,Ii=class Zi{constructor({host:e,port:t,protocol:n="",pathPrefix:r=""}){zs(this,"protocol"),zs(this,"host"),zs(this,"port"),zs(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=ll(r)}replace(e){return new Zi({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Zi({...this,pathPrefix:sg(this.path,e)})}toString(){return ng(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};zs(Ii,"UNKNOWN",new Ii({host:"unknown",port:0}));let rg=Ii;var ag=Object.defineProperty,ig=(s,e,t)=>e in s?ag(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Da=(s,e,t)=>(ig(s,typeof e!="symbol"?e+"":e,t),t);let dl=class{constructor(){Da(this,"contentType","application/json"),Da(this,"decoder"),Da(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const n=Pr(JSON.parse(e));return t!=null?t.parse(n):n}encodeString(e){return JSON.stringify(Gf(e),(t,n)=>ArrayBuffer.isView(n)?Array.from(n):ul(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};const hl=new dl,og=[hl],_s=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:og,JSONEncoderDecoder:dl,JSON_ECD:hl},Symbol.toStringTag,{value:"Module"}));var cg=Object.defineProperty,ug=(s,e,t)=>e in s?cg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ai=(s,e,t)=>(ug(s,typeof e!="symbol"?e+"":e,t),t);class lg{constructor(e,t){Ai(this,"handlers"),Ai(this,"transform"),this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[n,r]=this.transform(e);if(!r)return;t=n}this.handlers.forEach((n,r)=>r(t))}}let dg=class{constructor(e){Ai(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Hr=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:dg,Observer:lg},Symbol.toStringTag,{value:"Module"})),hg=f.string().regex(/^\d+\.\d+\.\d+$/);f.object({version:hg});const wa=(s,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(s);let r=X(s);const a=r[0],i=typeof a;let o;return i==="string"&&t&&!isNaN(parseInt(a))&&"number"in e?(o=e.number,r=r.map(u=>parseInt(u))):o=e[i],{single:n,variant:o,normalized:r,actual:s}},ba=(s,e,t,n)=>{if(n){if(t.length===0)throw new Nn(`${s} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new In(`Expected one ${s} matching ${JSON.stringify(e)}, but found ${t.length}`)}},ks=s=>c.z.union([c.z.null().transform(()=>[]),s.array()]),pg=c.z.object({leaseholder:c.z.number().optional(),keys:c.z.number().array().optional(),names:c.z.string().array().optional(),search:c.z.string().optional(),rangeKey:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional(),dataTypes:G.z.array().optional(),notDataTypes:G.z.array().optional(),virtual:c.z.boolean().optional(),isIndex:c.z.boolean().optional(),internal:c.z.boolean().optional()}),fg=c.z.object({channels:ks(Mn)}),ss=s=>wa(s,{number:"keys",string:"names"}),ea=class ea{constructor(e){d(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){let{variant:n,normalized:r}=ss(e);return n==="keys"&&r.indexOf(0)!==-1&&(r=r.filter(a=>a!==0)),r.length===0?[]:await this.execute({[n]:r,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(ea.ENDPOINT,e,pg,fg);if(n!=null)throw n;return t.channels}};d(ea,"ENDPOINT","/channel/retrieve");let Zn=ea;class lo{constructor(e){d(this,"cache");d(this,"namesToKeys");d(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=wa(e,{string:"names",number:"keys"}),r=[],a=[];if(n.forEach(o=>{const u=this.getFromCache(o);u!=null?r.push(u):a.push(o)}),a.length===0)return r;const i=await this.wrapped.retrieve(a,t);return this.updateCache(i),r.concat(i)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}class pl{constructor(e,t){d(this,"mu",new Fy);d(this,"requests",new Map);d(this,"wrapped");d(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Uy(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=ss(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(r=>e.add(r)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,r)=>n.resolve(t.filter(a=>r.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const fl=async(s,e)=>{const{normalized:t}=ss(e),n=await s.retrieve(t),r=[];if(t.forEach(a=>{n.find(i=>i.name===a||i.key===a)==null&&r.push(a)}),r.length>0)throw new Re(`Could not find channels: ${JSON.stringify(r)}`);return n};class ho{constructor({dataType:e,rate:t,name:n,leaseholder:r=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:u,alias:l}){d(this,"_frameClient");d(this,"key");d(this,"name");d(this,"rate");d(this,"dataType");d(this,"leaseholder");d(this,"index");d(this,"isIndex");d(this,"alias");this.key=a,this.name=n,this.rate=new va(t??0),this.dataType=new G(e),this.leaseholder=r,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new de("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Mn.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let ml=class{constructor(e,t,n,r){d(this,"type","channel");d(this,"frameClient");d(this,"client");d(this,"retriever");d(this,"writer");this.frameClient=e,this.retriever=t,this.client=n,this.writer=r}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,r=!Array.isArray(e);let a=X(e),i=[];if(n){const o=await this.retriever.retrieve(a.map(l=>l.name)),u=new Set(o.map(l=>l.name));a=a.filter(l=>!u.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(a))),r?i[0]:i}async retrieve(e,t){const n=!Array.isArray(e),r=this.sugar(await this.retriever.retrieve(e,t));return ba("channel",e,r,n),n?r[0]:r}async search(e,t){return this.sugar(await this.retriever.search(e,t))}async delete(e){const{normalized:t,variant:n}=ss(e);return n==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new lo(new pl(new Zn(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new ho({...n,frameClient:t}))}};const mg=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:lo,Channel:ho,Client:ml,ClusterRetriever:Zn,DebouncedBatchRetriever:pl,Writer:ol,analyzeChannelParams:ss,keyZ:ws,newPayload:il,payload:Mn,retrieveRequired:fl},Symbol.toStringTag,{value:"Module"})),yg=c.z.object({key:c.z.string(),username:c.z.string()}),gg=c.z.object({username:c.z.string(),password:c.z.string()}),vg=c.z.object({token:c.z.string(),user:yg}),Yo="/auth/login",wg=3;let bg=class{constructor(e,t){d(this,"token");d(this,"client");d(this,"credentials");d(this,"authenticating");d(this,"authenticated");d(this,"user");d(this,"retryCount");this.client=e,this.authenticated=!1,this.credentials=t,this.retryCount=0}middleware(){const e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(Yo)){this.authenticating==null&&(this.authenticating=new Promise(async o=>{const[u,l]=await this.client.send(Yo,this.credentials,gg,vg);if(l!=null)return o(l);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}));const i=await this.authenticating;if(i!=null)return[t,i]}t.params.Authorization=`Bearer ${this.token}`;const[r,a]=await n(t);return a instanceof Jr&&this.retryCount<wg?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[r,a])};return e}};const _g=["disconnected","connecting","connected","failed"],yl=c.z.enum(_g),gl=c.z.object({status:yl,error:c.z.instanceof(Error).optional(),message:c.z.string().optional(),clusterKey:c.z.string()}),kg=c.z.object({clusterKey:c.z.string()}),Jo={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},is=class is{constructor(e,t=H.seconds(30),n){d(this,"_state");d(this,"pollFrequency",H.seconds(30));d(this,"client");d(this,"name");d(this,"interval");d(this,"onChangeHandlers",[]);this._state={...Jo},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,r]=await this.client.send(is.ENDPOINT,{},c.z.object({}),kg);if(r!=null)throw r;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};d(is,"ENDPOINT","/connectivity/check"),d(is,"DEFAULT",Jo),d(is,"connectionStateZ",gl);let An=is;const Og=Object.freeze(Object.defineProperty({__proto__:null,Checker:An,state:gl,status:yl},Symbol.toStringTag,{value:"Module"})),Go=s=>{const e=X(s);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Ho=(s,e)=>{const t=X(s);if(t.length===e.length)return;const n=Go(s);throw Go===null?new de("[Frame] - channel keys or names must be provided when constructing a frame."):new de(`[Frame] - ${n}s and arrays must be the same length.
|
|
18
|
-
Got ${t.length} ${n}s and ${e.length} arrays.`)};class
|
|
17
|
+
`)}}c(xe,"TYPE",_e+"unexpected");class ee extends Error{}c(ee,"TYPE",_e+"query");class ct extends ee{}c(ct,"TYPE",ee.TYPE+".not_found");class lt extends ee{}c(lt,"TYPE",ee.TYPE+".multiple_results");class Bt extends Error{constructor(t,n){super(t);c(this,"path");this.path=n}}c(Bt,"TYPE",_e+"route");class ut extends Error{}c(ut,"TYPE",_e+"control");class Yr extends ut{}c(Yr,"TYPE",ut.TYPE+".unauthorized");class Ol extends Error{}const Tl=r=>{if(!r.type.startsWith(_e))return null;if(r.type.startsWith(D.TYPE)){if(r.type===qr.TYPE){const e=r.data.split(": ");return e.length<2?new D(r.data):new qr(e[0],e[1])}return new D(r.data)}return r.type.startsWith(We.TYPE)?r.type.startsWith(Lt.TYPE)?new Lt(r.data):new We(r.data):r.type.startsWith(xe.TYPE)?new xe(r.data):r.type.startsWith(ee.TYPE)?r.type.startsWith(ct.TYPE)?new ct(r.data):r.type.startsWith(lt.TYPE)?new lt(r.data):new ee(r.data):r.type.startsWith(ut.TYPE)?r.type.startsWith(Yr.TYPE)?new Yr(r.data):new ut(r.data):r.type.startsWith(Bt.TYPE)?new Bt(r.data,r.data):new xe(r.data)},zl=()=>{throw new Error("Not implemented")};za({encode:zl,decode:Tl});const El=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Ie?[t,new Ie({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},Ia=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var Sl=Object.defineProperty,Nl=(r,e,t)=>e in r?Sl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sr=(r,e,t)=>(Nl(r,typeof e!="symbol"?e+"":e,t),t);let ka=class{constructor(){Sr(this,"contentType","application/json"),Sr(this,"decoder"),Sr(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const n=Mt(JSON.parse(e));return t!=null?t.parse(n):n}encodeString(e){return JSON.stringify(Fi(e),(t,n)=>ArrayBuffer.isView(n)?Array.from(n):Ia(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n)}static registerCustomType(){}};const $a=new ka,Al=[$a],Ve=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Al,JSONEncoderDecoder:ka,JSON_ECD:$a},Symbol.toStringTag,{value:"Module"}));var Il=Object.defineProperty,kl=(r,e,t)=>e in r?Il(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wr=(r,e,t)=>(kl(r,typeof e!="symbol"?e+"":e,t),t);class $l{constructor(e,t){Wr(this,"handlers"),Wr(this,"transform"),this.transform=e,this.handlers=t??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let t=e;if(this.transform!=null){const[n,a]=this.transform(e);if(!a)return;t=n}this.handlers.forEach((n,a)=>a(t))}}let Cl=class{constructor(e){Wr(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Kr=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Cl,Observer:$l},Symbol.toStringTag,{value:"Module"})),Sn=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),Rl=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Rl();const jl=["MacOS","Windows","Linux","Docker"];s.z.enum(jl);const Qn=r=>[...new Set(r)];var xl=Object.defineProperty,Dl=(r,e,t)=>e in r?xl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e,t)=>(Dl(r,typeof e!="symbol"?e+"":e,t),t);const Pl=(...r)=>r.map(Ca).join(""),Ca=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Zl=r=>r.endsWith("/")?r.slice(0,-1):r,Vr=class Fr{constructor({host:e,port:t,protocol:n="",pathPrefix:a=""}){st(this,"protocol"),st(this,"host"),st(this,"port"),st(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=Ca(a)}replace(e){return new Fr({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Fr({...this,pathPrefix:Pl(this.path,e)})}toString(){return Zl(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};st(Vr,"UNKNOWN",new Vr({host:"unknown",port:0}));let Ml=Vr;var _l=Object.defineProperty,Ul=(r,e,t)=>e in r?_l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nr=(r,e,t)=>(Ul(r,typeof e!="symbol"?e+"":e,t),t);const je=class extends Number{};Nr(je,"Absolute",255),Nr(je,"Default",1),Nr(je,"z",s.z.union([s.z.instanceof(je),s.z.number().int().min(0).max(255).transform(r=>new je(r)),s.z.instanceof(Number).transform(r=>new je(r))]));let Ra=je;const ja=s.z.object({name:s.z.string(),key:s.z.string()}),Ll=r=>s.z.object({subject:ja,resource:r,authority:Ra.z}),Bl=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),Ke=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ra,filterTransfersByChannelKey:Bl,stateZ:Ll,subjectZ:ja},Symbol.toStringTag,{value:"Module"})),ql=s.z.string().regex(/^\d+\.\d+\.\d+$/);s.z.object({version:ql});const ir=(r,e,{convertNumericStrings:t=!0}={})=>{const n=!Array.isArray(r);let a=z(r);const i=a[0],o=typeof i;let l;return o==="string"&&t&&!isNaN(parseInt(i))&&"number"in e?(l=e.number,a=a.map(u=>parseInt(u))):l=e[o],{single:n,variant:l,normalized:a,actual:r}},or=(r,e,t,n)=>{if(n){if(t.length===0)throw new ct(`${r} not found matching ${JSON.stringify(e)}`);if(t.length>1)throw new lt(`Expected one ${r} matching ${JSON.stringify(e)}, but found ${t.length}`)}},Fe=r=>s.z.union([s.z.null().transform(()=>[]),r.array()]),Yl=s.z.object({leaseholder:s.z.number().optional(),keys:s.z.number().array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:S.z.array().optional(),notDataTypes:S.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),Wl=s.z.object({channels:Fe(yt)}),ke=r=>ir(r,{number:"keys",string:"names"}),Wt=class Wt{constructor(e){c(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,...t})}async retrieve(e,t){const n=ke(e),{variant:a}=n;let{normalized:i}=n;return a==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[a]:i,...t})}async page(e,t,n){return await this.execute({offset:e,limit:t,...n})}async execute(e){const[t,n]=await this.client.send(Wt.ENDPOINT,e,Yl,Wl);if(n!=null)throw n;return t.channels}};c(Wt,"ENDPOINT","/channel/retrieve");let ht=Wt;class Nn{constructor(e){c(this,"cache");c(this,"namesToKeys");c(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e,t){const{normalized:n}=ir(e,{string:"names",number:"keys"}),a=[],i=[];if(n.forEach(l=>{const u=this.getFromCache(l);u!=null?a.push(u):i.push(l)}),i.length===0)return a;const o=await this.wrapped.retrieve(i,t);return this.updateCache(o),a.concat(o)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}class xa{constructor(e,t){c(this,"mu",new Bo);c(this,"requests",new Map);c(this,"wrapped");c(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Po(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=ke(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((i,o)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:i,reject:o}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(a=>e.add(a)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,a)=>n.resolve(t.filter(i=>a.includes(i.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const Da=async(r,e)=>{const{normalized:t}=ke(e),n=await r.retrieve(t),a=[];if(t.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&a.push(i)}),a.length>0)throw new ee(`Could not find channels: ${JSON.stringify(a)}`);return n};class An{constructor({dataType:e,rate:t,name:n,leaseholder:a=0,key:i=0,isIndex:o=!1,index:l=0,internal:u=!1,frameClient:p,alias:g}){c(this,"_frameClient");c(this,"key");c(this,"name");c(this,"rate");c(this,"dataType");c(this,"leaseholder");c(this,"index");c(this,"isIndex");c(this,"internal");c(this,"alias");this.key=i,this.name=n,this.rate=new Ht(t??0),this.dataType=new S(e),this.leaseholder=a,this.index=l,this.isIndex=o,this.internal=u,this.alias=g,this._frameClient=p??null}get framer(){if(this._frameClient==null)throw new D("cannot read from a channel that has not been created");return this._frameClient}get payload(){return yt.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let Pa=class{constructor(e,t,n,a){c(this,"type","channel");c(this,"frameClient");c(this,"client");c(this,"retriever");c(this,"writer");this.frameClient=e,this.retriever=t,this.client=n,this.writer=a}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,a=!Array.isArray(e);let i=z(e),o=[];if(n){const l=await this.retriever.retrieve(i.map(p=>p.name)),u=new Set(l.map(p=>p.name));i=i.filter(p=>!u.has(p.name)),o=this.sugar(l)}return o=o.concat(this.sugar(await this.writer.create(i))),a?o[0]:o}async retrieve(e,t){const n=!Array.isArray(e),a=this.sugar(await this.retriever.retrieve(e,t));return or("channel",e,a,n),n?a[0]:a}async search(e,t){return this.sugar(await this.retriever.search(e,t))}async delete(e){const{normalized:t,variant:n}=ke(e);return n==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}async rename(e,t){return await this.writer.rename(z(e),z(t))}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new Nn(new xa(new ht(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new An({...n,frameClient:t}))}};const Kl=s.z.object({channels:qs.array()}),Vl=s.z.object({channels:yt.array()}),Fl=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional()}),Jl=s.z.object({}),Gl=s.z.object({keys:$e.array(),names:s.z.string().array()}),Hl=s.z.object({}),Xl="/channel/create",Ql="/channel/delete",eu="/channel/rename";let Za=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Xl,{channels:e},Kl,Vl)).channels}async delete(e){await w(this.client,Ql,e,Fl,Jl)}async rename(e,t){await w(this.client,eu,{keys:e,names:t},Gl,Hl)}};const tu=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Nn,Channel:An,Client:Pa,ClusterRetriever:ht,DebouncedBatchRetriever:xa,Writer:Za,analyzeChannelParams:ke,keyZ:$e,newPayload:qs,payload:yt,retrieveRequired:Da},Symbol.toStringTag,{value:"Module"})),ru=s.z.object({key:s.z.string(),username:s.z.string()}),nu=s.z.object({username:s.z.string(),password:s.z.string()}),su=s.z.object({token:s.z.string(),user:ru}),es="/auth/login",au=3;let iu=class{constructor(e,t){c(this,"token");c(this,"client");c(this,"credentials");c(this,"authenticating");c(this,"authenticated");c(this,"user");c(this,"retryCount");this.client=e,this.authenticated=!1,this.credentials=t,this.retryCount=0}middleware(){const e=async(t,n)=>{if(!this.authenticated&&!t.target.endsWith(es)){this.authenticating==null&&(this.authenticating=new Promise((l,u)=>{this.client.send(es,this.credentials,nu,su).then(([p,g])=>{if(g!=null)return l(g);this.token=p==null?void 0:p.token,this.user=p==null?void 0:p.user,this.authenticated=!0,l(null)}).catch(u)}));const o=await this.authenticating;if(o!=null)return[t,o]}t.params.Authorization=`Bearer ${this.token}`;const[a,i]=await n(t);return i instanceof Lt&&this.retryCount<au?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,e(t,n)):(this.retryCount=0,[a,i])};return e}};const ou=["disconnected","connecting","connected","failed"],Ma=s.z.enum(ou),_a=s.z.object({status:Ma,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string()}),cu=s.z.object({clusterKey:s.z.string()}),ts={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},Le=class Le{constructor(e,t=N.seconds(30),n){c(this,"_state");c(this,"pollFrequency",N.seconds(30));c(this,"client");c(this,"name");c(this,"interval");c(this,"onChangeHandlers",[]);this._state={...ts},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,a]=await this.client.send(Le.ENDPOINT,{},s.z.object({}),cu);if(a!=null)throw a;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};c(Le,"ENDPOINT","/connectivity/check"),c(Le,"DEFAULT",ts),c(Le,"connectionStateZ",_a);let ft=Le;const lu=Object.freeze(Object.defineProperty({__proto__:null,Checker:ft,state:_a,status:Ma},Symbol.toStringTag,{value:"Module"})),rs=r=>{const e=z(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ns=(r,e)=>{const t=z(r);if(t.length===e.length)return;const n=rs(r);throw rs===null?new D("[Frame] - channel keys or names must be provided when constructing a frame."):new D(`[Frame] - ${n}s and arrays must be the same length.
|
|
18
|
+
Got ${t.length} ${n}s and ${e.length} arrays.`)};class _{constructor(e=[],t=[]){c(this,"columns",[]);c(this,"series",[]);if(e instanceof _){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((a,i)=>this.push(i,...z(a)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const a=e,i=a.series.map(o=>La(o));ns(a.keys,i),a.keys.forEach((o,l)=>this.push(o,i[l]))}else Object.entries(e).forEach(([a,i])=>{const o=parseInt(a);if(isNaN(o))this.push(a,...z(i));else return this.push(o,...z(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const a=z(t),i=z(e);ns(i,a),a.forEach((o,l)=>this.push(i[l],o));return}throw new D(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
19
19
|
payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
|
|
20
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new
|
|
20
|
+
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new xe("colType is not key");return this.columns??[]}get uniqueKeys(){return Qn(this.keys)}get names(){if(this.colType==="key")throw new xe("colType is not name");return this.columns??[]}get uniqueNames(){return Qn(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Ba(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return J.ZERO;const n=E.min(...this.series.map(i=>i.timeRange.start)),a=E.max(...this.series.map(i=>i.timeRange.end));return new J(n,a)}const t=this.get(e);return t==null?J.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Ls(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof _){if(this.colType!==null&&e.colType!==this.colType)throw new D("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new D("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new D("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new _([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new _;return this.forEach((n,a,i)=>t.push(...e(n,a,i))),t}forEach(e){this.columns.forEach((t,n)=>{const a=this.series[n];e(t,a,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(a=>{n[a]=this.get(a).at(e,t)}),n}filter(e){const t=new _;return this.columns.forEach((n,a)=>{const i=this.series[a];e(n,i,a)&&t.push(n,i)}),t}get byteLength(){return new ot(this.series.reduce((e,t)=>e.add(t.byteLength),ot.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const Ua=s.z.object({timeRange:J.z.optional(),alignment:s.z.bigint().or(s.z.string().transform(r=>BigInt(r))).optional(),dataType:S.z,data:s.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),cr=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),Ua.array().optional().default([])])}),La=r=>{const{dataType:e,data:t,timeRange:n,alignment:a}=r;return new F({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:a})},Ba=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class lr{constructor(e){c(this,"adapter");c(this,"retriever");c(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new lr(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=ke(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const a=await this.retriever.retrieve(n),i=new Map;this.adapter=i,n.forEach(o=>{const l=a.find(u=>u.name===o);if(l==null)throw new Error(`Channel ${o} not found`);i.set(l.key,l.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,a)=>{if(typeof n=="number"){const i=t.get(n);if(i==null)throw new Error(`Channel ${n} not found`);return[i,a]}return[n,a]})}}class In{constructor(e){c(this,"adapter");c(this,"retriever");c(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new In(e);return await n.update(t),n}async update(e){const t=await Da(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new D(`
|
|
21
21
|
Received a single channel name or key but no series.
|
|
22
|
-
`);if(Array.isArray(t)){if(t.some(u=>u instanceof
|
|
22
|
+
`);if(Array.isArray(t)){if(t.some(u=>u instanceof F||Array.isArray(u)))throw new D(`
|
|
23
23
|
Received a single channel name or key but multiple series.
|
|
24
|
-
`);t=t}const
|
|
24
|
+
`);t=t}const o=await this.fetchChannel(e),l=new F({data:t,dataType:o.dataType});return new _(o.key,l)}if(Array.isArray(e)){if(t==null)throw new D(`
|
|
25
25
|
Received an array of channel names or keys but no series.
|
|
26
|
-
`);if(!Array.isArray(t))throw new
|
|
26
|
+
`);if(!Array.isArray(t))throw new D(`
|
|
27
27
|
Received an array of channel names or keys but no array of series.
|
|
28
|
-
`);const
|
|
28
|
+
`);const o=[],l=[];for(let u=0;u<e.length;u++){const p=await this.fetchChannel(e[u]);if(u>=t.length)throw new D(`
|
|
29
29
|
Received an array of channel names or keys but not enough series.
|
|
30
|
-
`);const
|
|
30
|
+
`);const g=new F({data:t[u],dataType:p.dataType});o.push(p.key),l.push(g)}return new _(o,l)}if(e instanceof _||e instanceof Map){const o=new _(e);if(this.adapter==null)return o;let l=[];return l=o.columns.map(u=>{var g;const p=typeof u=="string"?(g=this.adapter)==null?void 0:g.get(u):u;if(p==null)throw new D(`
|
|
31
31
|
Channel ${u} was not provided in the list of channels when opening the writer
|
|
32
|
-
`);return
|
|
33
|
-
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(t instanceof zt)return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Ci=new H(-1);var mo=(s=>(s[s.Open=0]="Open",s[s.Next=1]="Next",s[s.Prev=2]="Prev",s[s.SeekFirst=3]="SeekFirst",s[s.SeekLast=4]="SeekLast",s[s.SeekLE=5]="SeekLE",s[s.SeekGE=6]="SeekGE",s[s.Valid=7]="Valid",s[s.Error=8]="Error",s))(mo||{}),_l=(s=>(s[s.None=0]="None",s[s.Ack=1]="Ack",s[s.Data=2]="Data",s))(_l||{});const Tg=c.z.object({command:c.z.nativeEnum(mo),span:H.z.optional(),bounds:Ee.z.optional(),stamp:J.z.optional(),keys:c.z.number().array().optional()}),xg=c.z.object({variant:c.z.nativeEnum(_l),ack:c.z.boolean(),command:c.z.nativeEnum(mo),error:Rn.optional().nullable(),frame:_a.optional()}),Ps=class Ps{constructor(e,t){d(this,"stream");d(this,"adapter");d(this,"value");this.stream=new fo("Iterator",e),this.value=new me,this.adapter=t}static async _open(e,t,n,r){const a=await ka.open(n,t),i=await r.stream(Ps.ENDPOINT,Tg,xg),o=new Ps(i,a);return await o.execute({command:0,keys:a.keys,bounds:new Ee(e)}),o}async next(e=Ci){return await this.execute({command:1,span:new H(e)})}async prev(e=Ci){return await this.execute({command:2,span:new H(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new J(e)})}async seekGE(e){return await this.execute({command:6,stamp:new J(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Sg(this)}async execute(e){for(this.stream.send(e),this.value=new me;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new me(t.frame)))}}};d(Ps,"ENDPOINT","/frame/iterate");let Xr=Ps;class Sg{constructor(e){d(this,"iter");d(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Eg=c.z.object({start:J.z.optional(),keys:c.z.number().array()}),Ng=c.z.object({frame:_a,error:Rn.optional().nullable()}),Ig="/frame/stream";class Oa{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new fo("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:r}){const a=await ka.open(e,n),i=await t.stream(Ig,Eg,Ng),o=new Oa(i,a);return i.send({start:new J(r),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new me((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class yo extends Hr.Observer{constructor(t,n){super(n);d(this,"streamer");d(this,"closePromise");this.streamer=t,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const t of this.streamer)this.notify(t)}}const Nt=class Nt extends Number{};d(Nt,"Absolute",255),d(Nt,"Default",1),d(Nt,"z",c.z.union([c.z.instanceof(Nt),c.z.number().int().min(0).max(255).transform(e=>new Nt(e)),c.z.instanceof(Number).transform(e=>new Nt(e))]));let Qt=Nt;const go=c.z.object({name:c.z.string(),key:c.z.string()}),Zg=c.z.object({subject:go,resource:c.z.number(),authority:Qt.z}),Ag=(...s)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=s.includes(t.to.resource)),t.from!=null&&!n&&(n=s.includes(t.from.resource)),n}),Cg=s=>{var e,t;return s.to==null?`${(e=s.from)==null?void 0:e.resource} - ${(t=s.from)==null?void 0:t.subject.name} -> released`:s.from==null?`${s.to.resource} - released -> ${s.to.subject.name} (${s.to.authority.toString()})`:`${s.to.resource} - ${s.from.subject.name} -> ${s.to.subject.name} (${s.to.authority.toString()})`};class vo{constructor(e){d(this,"states");d(this,"streamer");d(this,"ecd");d(this,"observer");d(this,"closePromise");this.states=new Map,this.ecd=new _s.JSONEncoderDecoder,this.observer=new Hr.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new vo(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var wo=(s=>(s[s.Open=0]="Open",s[s.Write=1]="Write",s[s.Commit=2]="Commit",s[s.Error=3]="Error",s[s.SetAuthority=4]="SetAuthority",s[s.SetMode=5]="SetMode",s))(wo||{}),Cn=(s=>(s[s.PersistStream=1]="PersistStream",s[s.PersistOnly=2]="PersistOnly",s[s.StreamOnly=3]="StreamOnly",s))(Cn||{});const $g=new H(-1),jg=c.z.object({start:J.z.optional(),controlSubject:go.optional(),keys:c.z.number().array().optional(),authorities:Qt.z.array().optional(),mode:c.z.nativeEnum(Cn).optional(),enableAutoCommit:c.z.boolean().optional(),autoIndexPersistInterval:H.z.optional()}),zg=c.z.object({command:c.z.nativeEnum(wo),config:jg.optional(),frame:_a.optional()}),Rg=c.z.object({ack:c.z.boolean(),command:c.z.nativeEnum(wo),error:Rn.optional().nullable()});var Kt;let kl=(Kt=class{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new fo("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:r=J.now(),authorities:a=Qt.Absolute,controlSubject:i,mode:o=1,enableAutoCommit:u=!1,autoIndexPersistInterval:l=H.SECOND}){const h=await po.open(e,n),g=await t.stream(Kt.ENDPOINT,zg,Rg),se=new Kt(g,h);return await se.execute({command:0,config:{start:new J(r),keys:h.keys,controlSubject:i,authorities:X(a),mode:o,enableAutoCommit:u,autoIndexPersistInterval:l}}),se}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?Gi(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},d(Kt,"ENDPOINT","/frame/write"),Kt),Ol=class{constructor(e,t){d(this,"stream");d(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await Xr._open(e,t,this.retriever,this.stream)}async openWriter(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await kl._open(this.retriever,this.stream,e)}async openStreamer(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await Oa._open(this.retriever,this.stream,e)}async write(e,t,n){if(n==null){const a=t,i=await this.openWriter({start:e,channels:Object.keys(a),mode:Cn.PersistOnly});try{await i.write(a),await i.commit()}finally{await i.close()}return}const r=await this.openWriter({start:e,channels:t,mode:Cn.PersistOnly,enableAutoCommit:!0,autoIndexPersistInterval:H.MAX});try{await r.write(t,n)}finally{await r.close()}}async read(e,t){const{single:n}=ss(t),r=await this.readFrame(e,t);return n?r.get(t):r}async readFrame(e,t){const n=await this.openIterator(e,t),r=new me;try{for await(const a of n)r.push(a)}finally{await n.close()}return r}};const Pg=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:$g,AUTO_SPAN:Ci,Client:Ol,Frame:me,Iterator:Xr,ObservableStreamer:yo,Streamer:Oa,Writer:kl,WriterMode:Cn,frameZ:_a,series:vl,seriesFromPayload:wl,seriesToPayload:bl},Symbol.toStringTag,{value:"Module"}));let Tl=class{constructor(e,t,n){d(this,"tasks");d(this,"racks");d(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const Mg=Object.freeze(Object.defineProperty({__proto__:null,Client:Tl},Symbol.toStringTag,{value:"Module"})),Os=c.z.number(),Ta=c.z.object({key:Os,name:c.z.string()}),xl=Ta.partial({key:!0}),La="/hardware/rack/retrieve",Dg="/hardware/rack/create",Lg="/hardware/rack/delete",Ua=c.z.object({keys:Os.array().optional(),names:c.z.string().array().optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),Ba=c.z.object({racks:ks(Ta)}),Ug=c.z.object({racks:xl.array()}),Bg=c.z.object({racks:Ta.array()}),qg=c.z.object({keys:Os.array()}),Vg=c.z.object({});let Sl=class{constructor(e,t,n){d(this,"type","rack");d(this,"client");d(this,"frameClient");d(this,"tasks");this.client=e,this.frameClient=t,this.tasks=n}async delete(e){await C(this.client,Lg,{keys:X(e)},qg,Vg)}async create(e){const t=!Array.isArray(e),n=await C(this.client,Dg,{racks:X(e)},Ug,Bg),r=this.sugar(n.racks);return t?r[0]:r}async search(e){const t=await C(this.client,La,{search:e},Ua,Ba);return this.sugar(t.racks)}async page(e,t){const n=await C(this.client,La,{offset:e,limit:t},Ua,Ba);return this.sugar(n.racks)}async retrieve(e){const{variant:t,normalized:n,single:r}=wa(e,{string:"names",number:"keys"}),a=await C(this.client,La,{[t]:n},Ua,Ba),i=this.sugar(a.racks);return ba("Rack",e,i,r),r?i[0]:i}sugar(e){return e.map(({key:t,name:n})=>new El(t,n,this.tasks))}};class El{constructor(e,t,n){d(this,"key");d(this,"name");d(this,"tasks");this.key=e,this.name=t,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const Dn=async(s,e,t,n)=>{const r=await s.openStreamer([e,t]),a=i=>{const o=[];return t!=null&&o.push(...i.get(t).series.flatMap(u=>n("delete",u))),e!=null&&o.push(...i.get(e).series.flatMap(u=>n("set",u))),[o,o.length>0]};return new yo(r,a)},Kg=Object.freeze(Object.defineProperty({__proto__:null,openObservable:Dn},Symbol.toStringTag,{value:"Module"})),Wg="sy_device_set",Fg="sy_device_delete",qa="/hardware/device/retrieve",Yg="/hardware/device/create",Jg="/hardware/device/delete",xa=c.z.string(),Ln=c.z.object({key:xa,rack:Os,name:c.z.string(),make:c.z.string(),model:c.z.string(),location:c.z.string(),configured:c.z.boolean().optional(),properties:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:_s.JSON_ECD.decodeString(s)))}),Nl=Ln.extend({properties:c.z.unknown().transform(s=>_s.JSON_ECD.encodeString(s))}),Gg=c.z.object({devices:Nl.array()}),Hg=c.z.object({devices:Ln.array()}),Xg=c.z.object({keys:xa.array()}),Qg=c.z.object({}),Va=c.z.object({search:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional(),keys:xa.array().optional(),names:c.z.string().array().optional(),makes:c.z.string().array().optional()}),Ka=c.z.object({devices:ks(Ln)});let Il=class{constructor(e,t){d(this,"type","device");d(this,"client");d(this,"frameClient");this.client=e,this.frameClient=t}async retrieve(e,t){const n=!Array.isArray(e),r=await C(this.client,qa,{keys:X(e),...t},Va,Ka);return ba("Device",e,r.devices,n),n?r.devices[0]:r.devices}async search(e,t){return(await C(this.client,qa,{search:e,...t},Va,Ka)).devices}async page(e,t,n){return(await C(this.client,qa,{offset:e,limit:t,...n},Va,Ka)).devices}async create(e){const t=!Array.isArray(e),n=await C(this.client,Yg,{devices:X(e)},Gg,Hg);return t?n.devices[0]:n.devices}async delete(e){await C(this.client,Jg,{keys:X(e)},Xg,Qg)}async openDeviceTracker(){return await Dn(this.frameClient,Wg,Fg,ev)}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}};const ev=(s,e)=>s==="delete"?e.toStrings().map(t=>({variant:s,key:t,value:void 0})):e.parseJSON(Ln).map(t=>({variant:s,key:t.key,value:t})),tv=Object.freeze(Object.defineProperty({__proto__:null,Client:Il,deviceKeyZ:xa,deviceZ:Ln,newDeviceZ:Nl},Symbol.toStringTag,{value:"Module"})),sv=Object.freeze(Object.defineProperty({__proto__:null,Client:Sl,Rack:El,newRackZ:xl,rackKeyZ:Os,rackZ:Ta},Symbol.toStringTag,{value:"Module"}));let nv=(s=21)=>crypto.getRandomValues(new Uint8Array(s)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const Wa="sy_task_state",Xo="sy_task_cmd",Ts=c.z.union([c.z.string(),c.z.bigint().transform(s=>s.toString()),c.z.number().transform(s=>s.toString())]),Qr=c.z.object({task:Ts,variant:c.z.string(),key:c.z.string().optional(),details:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:JSON.parse(s))).or(c.z.array(c.z.unknown())).or(c.z.null())}),Sa=c.z.object({key:Ts,name:c.z.string(),type:c.z.string(),config:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:_s.JSON_ECD.decodeString(s))),state:Qr.optional().nullable()}),Zl=Sa.omit({key:!0}).extend({key:Ts.transform(s=>s.toString()).optional(),config:c.z.unknown().transform(s=>_s.JSON_ECD.encodeString(s))}),rv=c.z.object({task:Ts,type:c.z.string(),key:c.z.string(),args:c.z.record(c.z.unknown()).or(c.z.string().transform(s=>s===""?{}:JSON.parse(s)))});class Al{constructor(e,t,n,r,a,i){d(this,"key");d(this,"name");d(this,"type");d(this,"config");d(this,"state");d(this,"frameClient");this.key=e,this.name=t,this.type=n,this.config=r,i!==null&&(this.state=i),this.frameClient=a}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state}}async executeCommand(e,t){const n=await this.frameClient.openWriter(Xo),r=nv();return await n.write(Xo,[{task:this.key,type:e,key:r,args:t}]),await n.close(),r}async executeCommandSync(e,t,n){const r=await this.frameClient.openStreamer(Wa),a=await this.executeCommand(e,t);let i;const o=new Promise(u=>setTimeout(()=>u(!1),new H(n).milliseconds));for(;;){const u=await Promise.any([r.read(),o]);if(u===!1)throw new Error("Command timed out");const l=Qr.safeParse(u.at(-1).sy_task_state);if(l.success){if(i=l.data,i.key===a)break}else console.error(l.error)}return r.close(),i}async openStateObserver(){return new yo(await this.frameClient.openStreamer(Wa),e=>{const t=e.get(Wa);if(t.length===0)return[null,!1];const n=Qr.safeParse(t.at(-1));if(!n.success)return[null,!1];const r=n.data;return r.task!==this.key?[null,!1]:[r,!0]})}}const av=c.z.object({rack:Os.optional(),keys:c.z.string().array().optional(),names:c.z.string().array().optional(),offset:c.z.number().optional(),limit:c.z.number().optional(),includeState:c.z.boolean().optional()}),iv=c.z.object({tasks:ks(Sa)}),ov="/hardware/task/retrieve",cv="/hardware/task/create",uv="/hardware/task/delete",lv=c.z.object({tasks:Zl.array()}),dv=c.z.object({tasks:Sa.array()}),hv=c.z.object({keys:Ts.array()}),pv=c.z.object({});let Cl=class{constructor(e,t){d(this,"type","task");d(this,"client");d(this,"frameClient");this.client=e,this.frameClient=t}async create(e){const t=!Array.isArray(e),n=await C(this.client,cv,{tasks:X(e)},lv,dv),r=this.sugar(n.tasks);return t?r[0]:r}async delete(e){await C(this.client,uv,{keys:X(e)},hv,pv)}async search(e){return await this.execRetrieve({keys:[e]})}async page(e,t){return this.execRetrieve({offset:e,limit:t})}async retrieve(e,t){const{single:n,normalized:r,variant:a}=wa(e,{number:"rack",string:"keys"},{convertNumericStrings:!1});let i={...t};a==="rack"?i.rack=e:i.keys=r;const o=await this.execRetrieve(i),u=this.sugar(o);return n&&a!=="rack"?u[0]:u}async retrieveByName(e,t){const n=await this.execRetrieve({names:[e],rack:t});return ba("Task",e,n,!0),this.sugar(n)[0]}async execRetrieve(e){return(await C(this.client,ov,e,av,iv)).tasks}sugar(e){return e.map(({key:t,name:n,type:r,config:a,state:i})=>new Al(t,n,r,a,this.frameClient,i))}};const fv=Object.freeze(Object.defineProperty({__proto__:null,Client:Cl,Task:Al,commandZ:rv,newTaskZ:Zl,stateZ:Qr,taskKeyZ:Ts,taskZ:Sa},Symbol.toStringTag,{value:"Module"}));class mv{constructor(e,t){d(this,"key");d(this,"name");this.key=t,this.name=e}get ontologyID(){return new Ae({type:"group",key:this.key})}}const yv=c.z.string().uuid(),gv=c.z.object({key:yv,name:c.z.string()}),$l=c.z.union([c.z.literal("label"),c.z.literal("builtin"),c.z.literal("cluster"),c.z.literal("channel"),c.z.literal("node"),c.z.literal("group"),c.z.literal("range"),c.z.literal("range-alias"),c.z.literal("user"),c.z.literal("workspace"),c.z.literal("schematic"),c.z.literal("lineplot"),c.z.literal("rack"),c.z.literal("device"),c.z.literal("task")]),We=c.z.object({type:$l,key:c.z.string()}),jl=c.z.string().transform(s=>{const[e,t]=s.split(":");return{type:e,key:t}}),zl=c.z.union([jl,We]),os=class os{constructor(e){d(this,"type");d(this,"key");if(e instanceof os)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};d(os,"z",c.z.union([zl,c.z.instanceof(os)]).transform(e=>new os(e)));let Ae=os;const vv=new Ae({type:"builtin",key:"root"}),Rl=c.z.object({type:c.z.number()}),Pl=c.z.object({type:$l,fields:c.z.record(Rl)}),Ml=c.z.object({id:Ae.z,name:c.z.string(),schema:Pl.optional().nullable(),data:c.z.record(c.z.unknown()).optional().nullable()}).transform(s=>({key:s.id.toString(),...s})),wv=c.z.object({from:Ae.z,type:c.z.string(),to:Ae.z}),$i=s=>{const[e,t,n]=s.split("->");return{from:new Ae(e),type:t,to:new Ae(n)}},bv=c.z.object({group:gv}),_v=c.z.object({parent:We,name:c.z.string()}),kv=c.z.object({key:c.z.string(),name:c.z.string()}),Ov=c.z.object({keys:c.z.array(c.z.string())});var tt;let Tv=(tt=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const[n,r]=await this.client.send(tt.ENDPOINT,{parent:e,name:t},_v,bv);if(r!=null)throw r;return n.group}async rename(e,t){const n={key:e,name:t},[,r]=await this.client.send(tt.ENDPOINT_RENAME,n,kv,c.z.object({}));if(r!=null)throw r}async delete(e){const t={keys:e},[,n]=await this.client.send(tt.ENDPOINT_DELETE,t,Ov,c.z.object({}));if(n!=null)throw n}},d(tt,"ENDPOINT","/ontology/create-group"),d(tt,"ENDPOINT_RENAME","/ontology/rename-group"),d(tt,"ENDPOINT_DELETE","/ontology/delete-group"),tt),xv=class{constructor(e){d(this,"creator");this.creator=new Tv(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new mv(e.name,e.key)}};const Fa={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Qo=c.z.object({id:We,children:We.array()}),Sv=c.z.object({from:We,to:We,children:We.array()});let Ev=class{constructor(e){d(this,"client");this.client=e}async addChildren(e,...t){await C(this.client,Fa.ADD_CHILDREN,{id:e,children:t},Qo,c.z.object({}))}async removeChildren(e,...t){await C(this.client,Fa.REMOVE_CHILDREN,{id:e,children:t},Qo,c.z.object({}))}async moveChildren(e,t,...n){const r={from:e,to:t,children:n};await C(this.client,Fa.MOVE_CHILDREN,r,Sv,c.z.object({}))}};const Nv="/ontology/retrieve",Iv=c.z.object({ids:We.array().optional(),children:c.z.boolean().optional(),parents:c.z.boolean().optional(),includeSchema:c.z.boolean().optional(),excludeFieldData:c.z.boolean().optional(),term:c.z.string().optional(),limit:c.z.number().optional(),offset:c.z.number().optional()}),Zv=c.z.object({resources:Ml.array()}),Ya=s=>X(s).map(e=>new Ae(e).payload);let Dl=class{constructor(e,t){d(this,"type","ontology");d(this,"groups");d(this,"client");d(this,"writer");d(this,"framer");this.client=e,this.writer=new Ev(e),this.groups=new xv(e),this.framer=t}async search(e,t){return await this.execRetrieve({term:e,...t})}async retrieve(e,t){const n=await this.execRetrieve({ids:Ya(e),...t});if(Array.isArray(e))return n;if(n.length===0)throw new Re(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t,n){return await this.execRetrieve({offset:e,limit:t,...n})}async retrieveChildren(e,t){return await this.execRetrieve({ids:Ya(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:Ya(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await Ea.open(this.framer,this)}newSearcherWithOptions(e){return{type:this.type,search:t=>this.search(t,e),retrieve:t=>this.retrieve(t,e),page:(t,n)=>this.page(t,n,e)}}async execRetrieve(e){const{resources:t}=await C(this.client,Nv,e,Iv,Zv);return t}};const ec="sy_ontology_resource_set",tc="sy_ontology_resource_delete",sc="sy_ontology_relationship_set",nc="sy_ontology_relationship_delete";class Ea{constructor(e,t){d(this,"resourceObs");d(this,"relationshipObs");d(this,"relationships");d(this,"resources");d(this,"streamer");d(this,"client");d(this,"closePromise");this.relationshipObs=new Hr.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Hr.Observer,this.resources=this.resourceObs,this.client=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(sc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:$i(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(nc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:$i(n)}))}async parseResourceSets(e){const t=e.get(ec);if(t.length===0)return[];const n=Array.from(t.as("string")).map(r=>new Ae(r));try{return(await this.client.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(r){if(r instanceof Re)return[];throw r}}parseResourceDeletes(e){const t=e.get(tc);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new Ae(n)}))}static async open(e,t){const n=await e.openStreamer([ec,tc,sc,nc]);return new Ea(n,t)}}const Av=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Ea,Client:Dl,ID:Ae,Root:vv,crudeIDZ:zl,idZ:We,parseRelationship:$i,relationshipSchemaZ:wv,resourceSchemaZ:Ml,schemaFieldZ:Rl,schemaZ:Pl,stringIDZ:jl},Symbol.toStringTag,{value:"Module"})),xs=c.z.string().uuid(),Un=c.z.object({key:xs,name:c.z.string().min(1),color:c.z.string()}),Cv=s=>new Ae({type:"label",key:s}),$v=c.z.object({keys:xs.array().optional(),for:We.optional(),search:c.z.string().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),jv=c.z.object({labels:Un.array().optional().default([])});var cs;let Ll=(cs=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=X(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(cs.ENDPOINT,e,$v,jv);if(n!=null)throw n;return t.labels}},d(cs,"ENDPOINT","/label/retrieve"),cs);const Ul=Un.extend({key:xs.optional()}),zv=c.z.object({labels:Ul.array()}),Rv=c.z.object({labels:Un.array()}),Pv=c.z.object({keys:xs.array()}),Bl=c.z.object({id:We,labels:xs.array()}),Mv=Bl,Ja=c.z.object({}),Dv="/label/create",Lv="/label/delete",Uv="/label/set",Bv="/label/remove";let ql=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Dv,{labels:X(e)},zv,Rv)).labels}async delete(e){await C(this.client,Lv,{keys:X(e)},Pv,Ja)}async set(e,t){await C(this.client,Uv,{id:e,labels:t},Bl,Ja)}async remove(e,t){await C(this.client,Bv,{id:e,labels:t},Mv,Ja)}};const qv="sy_label_set",Vv="sy_label_delete";let Vl=class{constructor(e,t){d(this,"type","label");d(this,"retriever");d(this,"writer");d(this,"frameClient");this.writer=new ql(e),this.retriever=new Ll(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await Dn(this.frameClient,qv,Vv,Kv)}};const Kv=(s,e)=>s==="delete"?e.toUUIDs().map(t=>({variant:s,key:t})):e.parseJSON(Un).map(t=>({variant:s,key:t.key,value:t})),Wv=Object.freeze(Object.defineProperty({__proto__:null,Client:Vl,Retriever:Ll,Writer:ql,keyZ:xs,labelZ:Un,newLabelPayloadZ:Ul,ontologyID:Cv},Symbol.toStringTag,{value:"Module"})),xe=c.z.string().uuid(),Ss=c.z.object({key:xe,name:c.z.string().min(1),timeRange:Ee.z,color:c.z.string().optional()}),Kl=Ss.extend({key:c.z.string().uuid().optional()}),Wl=s=>{const e=X(s);if(e.length===0)throw new Error("Range params must not be empty");const t=xe.safeParse(e[0]).success;return{single:!Array.isArray(s),variant:t?"keys":"names",normalized:e,actual:s}},Fv=c.z.object({}),Yv=c.z.object({range:Ss}),Jv=c.z.object({range:xe}),Gv=c.z.object({range:xe}),Hv=c.z.object({}),Xv="/range/set-active",Qv="/range/retrieve-active",ew="/range/clear-active";class tw{constructor(e){d(this,"client");this.client=e}async setActive(e){await C(this.client,Xv,{range:e},Jv,Fv)}async retrieveActive(){const[e,t]=await this.client.send(Qv,{},c.z.object({}),Yv);if(t instanceof Re)return null;if(t!=null)throw t;return e.range}async clearActive(e){await C(this.client,ew,{range:e},Gv,Hv)}}const sw="sy_range_alias_set",nw="sy_range_alias_delete",rw=c.z.object({range:xe,aliases:c.z.string().array()}),aw=c.z.object({aliases:c.z.record(c.z.string(),ws)}),iw=c.z.object({range:xe,aliases:c.z.record(ws.or(c.z.string()),c.z.string())}),ow=c.z.unknown(),cw=c.z.object({range:xe,channels:ws.array()}),uw=c.z.unknown(),lw=c.z.object({range:xe}),dw=c.z.object({aliases:c.z.record(c.z.string(),c.z.string())}),et=class et{constructor(e,t,n){d(this,"frameClient");d(this,"cache",new Map);d(this,"client");d(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",r={};if(n){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?r[i]=o:t.push(i)});if(t.length===0)return r;const a=await C(this.client,et.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},rw,aw);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),n?a.aliases[t[0]]:{...r,...a.aliases}}async set(e){await C(this.client,et.SET_ENDPOINT,{range:this.rangeKey,aliases:e},iw,ow)}async list(){return(await C(this.client,et.LIST_ENDPOINT,{range:this.rangeKey},lw,dw)).aliases}async delete(e){await C(this.client,et.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},cw,uw)}async openChangeTracker(){return await Dn(this.frameClient,sw,nw,fw(this.rangeKey))}};d(et,"SET_ENDPOINT","/range/alias/set"),d(et,"RESOLVE_ENDPOINT","/range/alias/resolve"),d(et,"LIST_ENDPOINT","/range/alias/list"),d(et,"DELETE_ENDPOINT","/range/alias/delete");let ji=et;const hw=c.z.object({range:xe,channel:ws,alias:c.z.string()}),pw="---",fw=s=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(pw)[0]===s).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(hw).map(n=>({variant:e,key:n.alias,value:n})),mw=c.z.object({range:xe,keys:c.z.string().array()}),yw=c.z.object({pairs:c.z.record(c.z.string(),c.z.string())}),gw=c.z.object({range:xe,pairs:c.z.record(c.z.string(),c.z.string())}),vw=c.z.object({range:xe,keys:c.z.string().array()}),It=class It{constructor(e,t){d(this,"rangeKey");d(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(It.GET_ENDPOINT,{range:this.rangeKey,keys:X(e)},mw,yw);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async list(){return this.get([])}async set(e,t=""){await C(this.client,It.SET_ENDPOINT,{range:this.rangeKey,pairs:ul(e)?e:{[e]:t}},gw,c.z.unknown())}async delete(e){await C(this.client,It.DELETE_ENDPOINT,{range:this.rangeKey,keys:X(e)},vw,c.z.unknown())}};d(It,"GET_ENDPOINT","/range/kv/get"),d(It,"SET_ENDPOINT","/range/kv/set"),d(It,"DELETE_ENDPOINT","/range/kv/delete");let zi=It;const Ga=s=>new Ae({type:"range",key:s});class Fl{constructor(e,t=Ee.ZERO,n,r,a,i,o,u,l){d(this,"key");d(this,"name");d(this,"kv");d(this,"timeRange");d(this,"color");d(this,"channels");d(this,"aliaser");d(this,"frameClient");d(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=a,this.color=r,this.kv=i,this.aliaser=o,this.channels=u,this.labelClient=l}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new Re(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ga(this.key))}async addLabel(...e){await this.labelClient.label(Ga(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ga(this.key),e)}}const ww=c.z.object({keys:xe.array().optional(),names:c.z.array(c.z.string()).optional(),term:c.z.string().optional(),overlapsWith:Ee.z.optional()}),bw="/range/retrieve",_w=c.z.object({ranges:ks(Ss)});let Yl=class{constructor(e,t,n,r,a){d(this,"type","range");d(this,"frameClient");d(this,"writer");d(this,"unaryClient");d(this,"channels");d(this,"active");d(this,"labelClient");this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=r,this.active=new tw(n),this.labelClient=a}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(X(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(X(e))}async search(e){return this.sugar(await this.execRetrieve({term:e}))}async page(e,t){return[]}async retrieve(e){if(typeof e=="object"&&"start"in e)return await this.execRetrieve({overlapsWith:new Ee(e)});const{single:t,actual:n,variant:r,normalized:a}=Wl(e),i=await this.execRetrieve({[r]:a});if(!t)return i;if(i.length===0)throw new Nn(`range matching ${n} not found`);if(i.length>1)throw new In(`multiple ranges matching ${n} found`);return i[0]}async execRetrieve(e){return this.sugar(await C(this.unaryClient,bw,e,ww,_w).then(t=>t.ranges))}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new Fl(t.name,t.timeRange,t.key,t.color,this.frameClient,new zi(t.key,this.unaryClient),new ji(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await Dn(this.frameClient,"sy_range_set","sy_range_delete",(e,t)=>e==="delete"?t.toStrings().map(r=>({variant:e,key:r,value:void 0})):this.sugar(t.parseJSON(Ss)).map(r=>({variant:e,key:r.key,value:r})))}};const kw=c.z.object({ranges:Ss.array()}),Ow=c.z.object({ranges:Kl.array()}),Tw=c.z.object({keys:xe.array()}),xw=c.z.object({}),Sw=c.z.object({key:xe,name:c.z.string()}),Ew=c.z.object({}),Nw="/range/create",Iw="/range/delete",Zw="/range/rename";let Jl=class{constructor(e){d(this,"client");this.client=e}async rename(e,t){await C(this.client,Zw,{key:e,name:t},Sw,Ew)}async create(e){return(await C(this.client,Nw,{ranges:e},Ow,kw)).ranges}async delete(e){await C(this.client,Iw,{keys:e},Tw,xw)}};const Aw=Object.freeze(Object.defineProperty({__proto__:null,Client:Yl,Range:Fl,Writer:Jl,analyzeParams:Wl,keyZ:xe,newPayloadZ:Kl,payloadZ:Ss},Symbol.toStringTag,{value:"Module"})),Cw="/api/v1/";class $w{constructor(e,t=!1){d(this,"url");d(this,"unary");d(this,"stream");d(this,"secure");this.secure=t,this.url=e.child(Cw);const n=new _s.JSONEncoderDecoder;this.unary=new bf(this.url,n,this.secure),this.stream=new If(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Dt=c.z.string().uuid(),bo=c.z.object({name:c.z.string(),key:Dt,layout:uo.or(c.z.string().transform(s=>JSON.parse(s)))}),_o=bo.omit({layout:!0}).extend({layout:c.z.string().transform(s=>JSON.parse(s))}),ko=c.z.string().uuid(),Oo=c.z.object({key:c.z.string(),name:c.z.string(),data:uo.or(c.z.string().transform(s=>JSON.parse(s)))}),jw=c.z.object({keys:c.z.string().array()}),zw=c.z.object({linePlots:Oo.array()});let Rw=class{constructor(e){d(this,"ENDPOINT","/workspace/lineplot/retrieve");d(this,"client");this.client=e}async retrieve(e){const t=X(e);return(await C(this.client,this.ENDPOINT,{keys:t},jw,zw)).linePlots}};const Pw=Oo.partial({key:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),Mw=c.z.object({workspace:Dt,linePlots:Pw.array()}),Dw=c.z.object({linePlots:Oo.array()}),Lw=c.z.object({keys:ko.array()}),Uw=c.z.object({}),Bw=c.z.object({key:ko,name:c.z.string()}),qw=c.z.object({}),Vw=c.z.object({key:ko,data:c.z.string()}),Kw=c.z.object({}),Ww="/workspace/lineplot/create",Fw="/workspace/lineplot/delete",Yw="/workspace/lineplot/rename",Jw="/workspace/lineplot/set-data";let Gw=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await C(this.client,Ww,{workspace:e,linePlots:[n]},Mw,Dw)).linePlots[0]}async delete(e){const t=X(e);await C(this.client,Fw,{keys:t},Lw,Uw)}async rename(e,t){await C(this.client,Yw,{key:e,name:t},Bw,qw)}async setData(e,t){await C(this.client,Jw,{key:e,data:JSON.stringify(t)},Vw,Kw)}},Hw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new Gw(e),this.retriever=new Rw(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Na=c.z.string().uuid(),Xw=c.z.object({key:c.z.string(),name:c.z.string(),data:uo.or(c.z.string().transform(s=>JSON.parse(s))),snapshot:c.z.boolean()}),To=c.z.object({key:c.z.string(),name:c.z.string(),snapshot:c.z.boolean(),data:c.z.string().transform(s=>JSON.parse(s))}),Qw=c.z.object({keys:c.z.string().array()}),eb=c.z.object({schematics:To.array()});let tb=class{constructor(e){d(this,"ENDPOINT","/workspace/schematic/retrieve");d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,this.ENDPOINT,{keys:X(e)},Qw,eb)).schematics}};const sb=Xw.partial({key:!0,snapshot:!0}).transform(s=>({...s,data:JSON.stringify(s.data)})),nb=c.z.object({workspace:Dt,schematics:sb.array()}),rb=c.z.object({schematics:To.array()}),ab=c.z.object({keys:Na.array()}),ib=c.z.object({}),ob=c.z.object({key:Na,name:c.z.string()}),rc=c.z.object({}),cb=c.z.object({key:Na,data:c.z.string()});c.z.object({});const ub=c.z.object({key:Na,name:c.z.string(),snapshot:c.z.boolean()}),lb=c.z.object({schematic:To}),db="/workspace/schematic/create",hb="/workspace/schematic/delete",pb="/workspace/schematic/rename",fb="/workspace/schematic/set-data",mb="/workspace/schematic/copy";let yb=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await C(this.client,db,{workspace:e,schematics:[n]},nb,rb)).schematics[0]}async copy(e,t,n){return(await C(this.client,mb,{key:e,name:t,snapshot:n},ub,lb)).schematic}async delete(e){const t=X(e);await C(this.client,hb,{keys:t},ab,ib)}async rename(e,t){await C(this.client,pb,{key:e,name:t},ob,rc)}async setData(e,t){await C(this.client,fb,{key:e,data:JSON.stringify(t)},cb,rc)}},gb=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new yb(e),this.retriever=new tb(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const vb=c.z.object({keys:Dt.array().optional(),search:c.z.string().optional(),author:c.z.string().uuid().optional(),offset:c.z.number().optional(),limit:c.z.number().optional()}),wb=c.z.object({workspaces:ks(_o)}),ta=class ta{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=X(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await C(this.client,ta.ENDPOINT,e,vb,wb)).workspaces}};d(ta,"ENDPOINT","/workspace/retrieve");let Ri=ta;const bb=bo.partial({key:!0}).transform(s=>({...s,layout:JSON.stringify(s.layout)})),_b=c.z.object({workspaces:bb.array()}),kb=c.z.object({workspaces:_o.array()}),Ob=c.z.object({keys:Dt.array()}),Tb=c.z.object({}),xb=c.z.object({key:Dt,name:c.z.string()}),Sb=c.z.object({}),Eb=c.z.object({key:Dt,layout:c.z.string()}),Nb=c.z.object({}),Ib="/workspace/create",Zb="/workspace/delete",Ab="/workspace/rename",Cb="/workspace/set-layout";class $b{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Ib,{workspaces:X(e)},_b,kb)).workspaces}async delete(e){await C(this.client,Zb,{keys:X(e)},Ob,Tb)}async rename(e,t){await C(this.client,Ab,{key:e,name:t},xb,Sb)}async setLayout(e,t){await C(this.client,Cb,{key:e,layout:JSON.stringify(t)},Eb,Nb)}}class Gl{constructor(e){d(this,"type","workspace");d(this,"schematic");d(this,"linePlot");d(this,"retriever");d(this,"writer");this.schematic=new gb(e),this.linePlot=new Hw(e),this.retriever=new Ri(e),this.writer=new $b(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const jb=Object.freeze(Object.defineProperty({__proto__:null,Client:Gl,keyZ:Dt,workspaceRemoteZ:_o,workspaceZ:bo},Symbol.toStringTag,{value:"Module"})),Hl=c.z.object({host:c.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:c.z.number({required_error:"Port is required"}).or(c.z.string({required_error:"Port is required"})),username:c.z.string().optional(),password:c.z.string().optional(),connectivityPollFrequency:H.z.default(H.seconds(30)),secure:c.z.boolean().optional().default(!1),name:c.z.string().optional()});class Xl extends Ol{constructor(t){const n=Hl.parse(t),{host:r,port:a,username:i,password:o,connectivityPollFrequency:u,secure:l}=n,h=new $w(new rg({host:r,port:Number(a)}),l);h.use(Hy);let g;if(i!=null&&o!=null){const ed=new bg(h.unary,{username:i,password:o});h.use(ed.middleware())}const se=new lo(new Zn(h.unary)),ye=new ol(h.unary);super(h.stream,se);d(this,"createdAt");d(this,"props");d(this,"ranges");d(this,"channels");d(this,"auth");d(this,"connectivity");d(this,"ontology");d(this,"workspaces");d(this,"labels");d(this,"hardware");d(this,"transport");this.createdAt=J.now(),this.props=n,this.auth=g,this.transport=h,this.channels=new ml(this,se,h.unary,ye),this.connectivity=new An(h.unary,u,n.name),this.ontology=new Dl(h.unary,this);const ze=new Jl(this.transport.unary);this.labels=new Vl(this.transport.unary,this),this.ranges=new Yl(this,ze,this.transport.unary,se,this.labels),this.workspaces=new Gl(this.transport.unary);const he=new Il(this.transport.unary,this),xo=new Cl(this.transport.unary,this),Ql=new Sl(this.transport.unary,this,xo);this.hardware=new Tl(xo,Ql,he)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}d(Xl,"connectivity",An);const zb=Object.freeze(Object.defineProperty({__proto__:null,Authority:Qt,StateTracker:vo,filterTransfersByChannelKey:Ag,stateZ:Zg,subjectZ:go,transferString:Cg},Symbol.toStringTag,{value:"Module"}));exports.AuthError=vs;exports.Authority=Qt;exports.Channel=ho;exports.ContiguityError=Yy;exports.DataType=G;exports.Density=Oe;exports.Frame=me;exports.MultiSeries=rl;exports.QueryError=Re;exports.Rate=va;exports.RouteError=Gr;exports.Series=Te;exports.Synnax=Xl;exports.TimeRange=Ee;exports.TimeSpan=H;exports.TimeStamp=J;exports.UnexpectedError=Vt;exports.ValidationError=de;exports.channel=mg;exports.connection=Og;exports.control=zb;exports.device=tv;exports.framer=Pg;exports.hardware=Mg;exports.label=Wv;exports.ontology=Av;exports.rack=sv;exports.ranger=Aw;exports.signals=Kg;exports.synnaxPropsZ=Hl;exports.task=fv;exports.workspace=jb;
|
|
34
|
-
//# sourceMappingURL=client.cjs.map
|
|
32
|
+
`);return p}),new _(l,o.series)}const n=[],a=[],i=Object.entries(e);for(let o=0;o<i.length;o++){const[l,u]=i[o],p=await this.fetchChannel(l),g=new F({data:u,dataType:p.dataType});n.push(p.key),a.push(g)}return new _(n,a)}}class kn{constructor(e,t){c(this,"name");c(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,t]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
33
|
+
Please report this error to the Synnax team. ${JSON.stringify(e)}`),t!=null){if(t instanceof Ne)return;throw t}}}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Jr=new N(-1);var $n=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))($n||{}),qa=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(qa||{});const uu=s.z.object({command:s.z.nativeEnum($n),span:N.z.optional(),bounds:J.z.optional(),stamp:E.z.optional(),keys:s.z.number().array().optional()}),hu=s.z.object({variant:s.z.nativeEnum(qa),ack:s.z.boolean(),command:s.z.nativeEnum($n),error:pt.optional().nullable(),frame:cr.optional()}),it=class it{constructor(e,t){c(this,"stream");c(this,"adapter");c(this,"value");this.stream=new kn("Iterator",e),this.value=new _,this.adapter=t}static async _open(e,t,n,a){const i=await lr.open(n,t),o=await a.stream(it.ENDPOINT,uu,hu),l=new it(o,i);return await l.execute({command:0,keys:i.keys,bounds:new J(e)}),l}async next(e=Jr){return await this.execute({command:1,span:new N(e)})}async prev(e=Jr){return await this.execute({command:2,span:new N(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new E(e)})}async seekGE(e){return await this.execute({command:6,stamp:new E(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new fu(this)}async execute(e){for(this.stream.send(e),this.value=new _;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new _(t.frame)))}}};c(it,"ENDPOINT","/frame/iterate");let qt=it;class fu{constructor(e){c(this,"iter");c(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const du=s.z.object({start:E.z.optional(),keys:s.z.number().array()}),yu=s.z.object({frame:cr,error:pt.optional().nullable()}),pu="/frame/stream";class ur{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:a}){const i=await lr.open(e,n),o=await t.stream(pu,du,yu),l=new ur(o,i);return o.send({start:new E(a),keys:i.keys}),l}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(e instanceof Ne)return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new _((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class hr extends Kr.Observer{constructor(t,n){super(n);c(this,"streamer");c(this,"closePromise");this.streamer=t,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const t of this.streamer)this.notify(t)}}var Cn=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r))(Cn||{}),dt=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(dt||{});const gu=new N(-1),mu=s.z.object({start:E.z.optional(),controlSubject:Ke.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:Ke.Authority.z.array().optional(),mode:s.z.nativeEnum(dt).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:N.z.optional()}),wu=s.z.object({command:s.z.nativeEnum(Cn),config:mu.optional(),frame:cr.optional()}),vu=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(Cn),error:pt.optional().nullable()});var De;let Ya=(De=class{constructor(e,t){c(this,"stream");c(this,"adapter");this.stream=new kn("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:a=E.now(),authorities:i=Ke.Authority.Absolute,controlSubject:o,mode:l=1,errOnUnauthorized:u=!1,enableAutoCommit:p=!1,autoIndexPersistInterval:g=N.SECOND}){const y=await In.open(e,n),U=await t.stream(De.ENDPOINT,wu,vu),x=new De(U,y);return await x.execute({command:0,config:{start:new E(a),keys:y.keys,controlSubject:o,authorities:z(i),mode:l,errOnUnauthorized:u,enableAutoCommit:p,autoIndexPersistInterval:g}}),x}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?En(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},c(De,"ENDPOINT","/frame/write"),De);const bu=s.z.object({keys:$e.array().optional(),names:s.z.string().array().optional(),bounds:J.z}),Ou=s.z.object({}),Tu="/frame/delete";class zu{constructor(e){c(this,"client");this.client=e}async delete(e){await w(this.client,Tu,e,bu,Ou)}}let Wa=class{constructor(e,t,n){c(this,"streamClient");c(this,"retriever");c(this,"deleter");this.streamClient=e,this.retriever=n,this.deleter=new zu(t)}async openIterator(e,t){return await qt._open(e,t,this.retriever,this.streamClient)}async openWriter(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await Ya._open(this.retriever,this.streamClient,e)}async openStreamer(e){return(Array.isArray(e)||typeof e!="object")&&(e={channels:e}),await ur._open(this.retriever,this.streamClient,e)}async write(e,t,n){if(n==null){const i=t,o=await this.openWriter({start:e,channels:Object.keys(i),mode:dt.PersistOnly});try{await o.write(i),await o.commit()}finally{await o.close()}return}const a=await this.openWriter({start:e,channels:t,mode:dt.PersistOnly,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:N.MAX});try{await a.write(t,n)}finally{await a.close()}}async read(e,t){const{single:n}=ke(t),a=await this.readFrame(e,t);return n?a.get(t):a}async readFrame(e,t){const n=await this.openIterator(e,t),a=new _;try{for await(const i of n)a.push(i)}finally{await n.close()}return a}async delete(e,t){const{normalized:n,variant:a}=ke(e);return a==="keys"?await this.deleter.delete({keys:n,bounds:t}):await this.deleter.delete({names:n,bounds:t})}};const Eu=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:gu,AUTO_SPAN:Jr,Client:Wa,Frame:_,Iterator:qt,ObservableStreamer:hr,Streamer:ur,Writer:Ya,WriterMode:dt,frameZ:cr,series:Ua,seriesFromPayload:La,seriesToPayload:Ba},Symbol.toStringTag,{value:"Module"})),Su=Ke.Authority,Nu=Ke.stateZ(s.z.number()),Au=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Ka extends hr{constructor(t){super(t,n=>{const a=this.ecd.decode(n.series[0].buffer);return this.merge(a),[a.transfers,!0]});c(this,"states");c(this,"ecd");this.states=new Map,this.ecd=new Ve.JSONEncoderDecoder}subjects(){const t=new Map;return this.states.forEach(n=>t.set(n.subject.key,n.subject)),Array.from(t.values())}merge(t){t.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const Iu="sy_node_1_control";let Va=class{constructor(e){c(this,"framer");this.framer=e}async openStateTracker(){const e=await this.framer.openStreamer(Iu);return new Ka(e)}};const ku=Object.freeze(Object.defineProperty({__proto__:null,Authority:Su,Client:Va,StateTracker:Ka,stateZ:Nu,transferString:Au},Symbol.toStringTag,{value:"Module"}));let Fa=class{constructor(e,t,n){c(this,"tasks");c(this,"racks");c(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const $u=Object.freeze(Object.defineProperty({__proto__:null,Client:Fa},Symbol.toStringTag,{value:"Module"})),Je=s.z.number(),fr=s.z.object({key:Je,name:s.z.string()}),Ja=fr.partial({key:!0}),Ar="/hardware/rack/retrieve",Cu="/hardware/rack/create",Ru="/hardware/rack/delete",Ir=s.z.object({keys:Je.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),kr=s.z.object({racks:Fe(fr)}),ju=s.z.object({racks:Ja.array()}),xu=s.z.object({racks:fr.array()}),Du=s.z.object({keys:Je.array()}),Pu=s.z.object({});let Ga=class{constructor(e,t,n){c(this,"type","rack");c(this,"client");c(this,"frameClient");c(this,"tasks");this.client=e,this.frameClient=t,this.tasks=n}async delete(e){await w(this.client,Ru,{keys:z(e)},Du,Pu)}async create(e){const t=!Array.isArray(e),n=await w(this.client,Cu,{racks:z(e)},ju,xu),a=this.sugar(n.racks);return t?a[0]:a}async search(e){const t=await w(this.client,Ar,{search:e},Ir,kr);return this.sugar(t.racks)}async page(e,t){const n=await w(this.client,Ar,{offset:e,limit:t},Ir,kr);return this.sugar(n.racks)}async retrieve(e){const{variant:t,normalized:n,single:a}=ir(e,{string:"names",number:"keys"}),i=await w(this.client,Ar,{[t]:n},Ir,kr),o=this.sugar(i.racks);return or("Rack",e,o,a),a?o[0]:o}sugar(e){return e.map(({key:t,name:n})=>new Ha(t,n,this.tasks))}};class Ha{constructor(e,t,n){c(this,"key");c(this,"name");c(this,"tasks");this.key=e,this.name=t,this.tasks=n}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const gt=async(r,e,t,n)=>{const a=await r.openStreamer([e,t]),i=o=>{const l=[];return t!=null&&l.push(...o.get(t).series.flatMap(u=>n("delete",u))),e!=null&&l.push(...o.get(e).series.flatMap(u=>n("set",u))),[l,l.length>0]};return new hr(a,i)},Zu=Object.freeze(Object.defineProperty({__proto__:null,openObservable:gt},Symbol.toStringTag,{value:"Module"})),Mu="sy_device_set",_u="sy_device_delete",$r="/hardware/device/retrieve",Uu="/hardware/device/create",Lu="/hardware/device/delete",dr=s.z.string(),mt=s.z.object({key:dr,rack:Je,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:Ve.JSON_ECD.decodeString(r)))}),Xa=mt.extend({properties:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Bu=s.z.object({devices:Xa.array()}),qu=s.z.object({devices:mt.array()}),Yu=s.z.object({keys:dr.array()}),Wu=s.z.object({}),Cr=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:dr.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),Rr=s.z.object({devices:Fe(mt)});let Qa=class{constructor(e,t){c(this,"type","device");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async retrieve(e,t){const n=!Array.isArray(e),a=await w(this.client,$r,{keys:z(e),...t},Cr,Rr);return or("Device",e,a.devices,n),n?a.devices[0]:a.devices}async search(e,t){return(await w(this.client,$r,{search:e,...t},Cr,Rr)).devices}async page(e,t,n){return(await w(this.client,$r,{offset:e,limit:t,...n},Cr,Rr)).devices}async create(e){const t=!Array.isArray(e),n=await w(this.client,Uu,{devices:z(e)},Bu,qu);return t?n.devices[0]:n.devices}async delete(e){await w(this.client,Lu,{keys:z(e)},Yu,Wu)}async openDeviceTracker(){return await gt(this.frameClient,Mu,_u,Ku)}newSearcherWithOptions(e){return{type:this.type,search:async t=>await this.search(t,e),retrieve:async t=>await this.retrieve(t,e),page:async(t,n)=>await this.page(t,n,e)}}};const Ku=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(mt).map(t=>({variant:r,key:t.key,value:t})),Vu=Object.freeze(Object.defineProperty({__proto__:null,Client:Qa,deviceKeyZ:dr,deviceZ:mt,newDeviceZ:Xa},Symbol.toStringTag,{value:"Module"})),Fu=Object.freeze(Object.defineProperty({__proto__:null,Client:Ga,Rack:Ha,newRackZ:Ja,rackKeyZ:Je,rackZ:fr},Symbol.toStringTag,{value:"Module"}));if(process.env.NODE_ENV!=="production"){if(typeof navigator<"u"&&navigator.product==="ReactNative"&&!self.crypto)throw new Error("React Native does not have a built-in secure random generator. If you don’t need unpredictable IDs, you can use `nanoid/non-secure`. For secure IDs, import `react-native-get-random-values` before Nano ID.");if(typeof self<"u"&&self.msCrypto&&!self.crypto)throw new Error("Add self.crypto = self.msCrypto before Nano ID to fix IE 11 support");if(typeof self>"u"||!self.crypto)throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.")}let Ju=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;){let n=t[r]&63;n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n<63?e+="_":e+="-"}return e};const jr="sy_task_state",ss="sy_task_cmd",Ge=s.z.union([s.z.string(),s.z.bigint().transform(r=>r.toString()),s.z.number().transform(r=>r.toString())]),Yt=s.z.object({task:Ge,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r))).or(s.z.array(s.z.unknown())).or(s.z.null())}),yr=s.z.object({key:Ge,name:s.z.string(),type:s.z.string(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:Ve.JSON_ECD.decodeString(r))),state:Yt.optional().nullable()}),ei=yr.omit({key:!0}).extend({key:Ge.transform(r=>r.toString()).optional(),config:s.z.unknown().transform(r=>Ve.JSON_ECD.encodeString(r))}),Gu=s.z.object({task:Ge,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(r=>r===""?{}:JSON.parse(r)))});class ti{constructor(e,t,n,a,i,o){c(this,"key");c(this,"name");c(this,"type");c(this,"config");c(this,"state");c(this,"frameClient");this.key=e,this.name=t,this.type=n,this.config=a,o!==null&&(this.state=o),this.frameClient=i}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,state:this.state}}async executeCommand(e,t){const n=await this.frameClient.openWriter(ss),a=Ju();return await n.write(ss,[{task:this.key,type:e,key:a,args:t}]),await n.close(),a}async executeCommandSync(e,t,n){const a=await this.frameClient.openStreamer(jr),i=await this.executeCommand(e,t);let o;const l=new Promise(u=>setTimeout(()=>u(!1),new N(n).milliseconds));for(;;){const u=await Promise.any([a.read(),l]);if(u===!1)throw new Error("Command timed out");const p=Yt.safeParse(u.at(-1).sy_task_state);if(p.success){if(o=p.data,o.key===i)break}else console.error(p.error)}return a.close(),o}async openStateObserver(){return new hr(await this.frameClient.openStreamer(jr),e=>{const t=e.get(jr);if(t.length===0)return[null,!1];const n=Yt.safeParse(t.at(-1));if(!n.success)return[null,!1];const a=n.data;return a.task!==this.key?[null,!1]:[a,!0]})}}const Hu=s.z.object({rack:Je.optional(),keys:s.z.string().array().optional(),names:s.z.string().array().optional(),offset:s.z.number().optional(),limit:s.z.number().optional(),includeState:s.z.boolean().optional()}),Xu=s.z.object({tasks:Fe(yr)}),Qu="/hardware/task/retrieve",eh="/hardware/task/create",th="/hardware/task/delete",rh=s.z.object({tasks:ei.array()}),nh=s.z.object({tasks:yr.array()}),sh=s.z.object({keys:Ge.array()}),ah=s.z.object({});let ri=class{constructor(e,t){c(this,"type","task");c(this,"client");c(this,"frameClient");this.client=e,this.frameClient=t}async create(e){const t=!Array.isArray(e),n=await w(this.client,eh,{tasks:z(e)},rh,nh),a=this.sugar(n.tasks);return t?a[0]:a}async delete(e){await w(this.client,th,{keys:z(e)},sh,ah)}async search(e){return await this.execRetrieve({keys:[e]})}async page(e,t){return this.execRetrieve({offset:e,limit:t})}async retrieve(e,t){const{single:n,normalized:a,variant:i}=ir(e,{number:"rack",string:"keys"},{convertNumericStrings:!1}),o={...t};i==="rack"?o.rack=e:o.keys=a;const l=await this.execRetrieve(o),u=this.sugar(l);return n&&i!=="rack"?u[0]:u}async retrieveByName(e,t){const n=await this.execRetrieve({names:[e],rack:t});return or("Task",e,n,!0),this.sugar(n)[0]}async execRetrieve(e){return(await w(this.client,Qu,e,Hu,Xu)).tasks}sugar(e){return e.map(({key:t,name:n,type:a,config:i,state:o})=>new ti(t,n,a,i,this.frameClient,o))}};const ih=Object.freeze(Object.defineProperty({__proto__:null,Client:ri,Task:ti,commandZ:Gu,newTaskZ:ei,stateZ:Yt,taskKeyZ:Ge,taskZ:yr},Symbol.toStringTag,{value:"Module"}));class oh{constructor(e,t){c(this,"key");c(this,"name");this.key=t,this.name=e}get ontologyID(){return new X({type:"group",key:this.key})}}const ch=s.z.string().uuid(),lh=s.z.object({key:ch,name:s.z.string()}),ni=s.z.union([s.z.literal("label"),s.z.literal("builtin"),s.z.literal("cluster"),s.z.literal("channel"),s.z.literal("node"),s.z.literal("group"),s.z.literal("range"),s.z.literal("range-alias"),s.z.literal("user"),s.z.literal("workspace"),s.z.literal("schematic"),s.z.literal("lineplot"),s.z.literal("rack"),s.z.literal("device"),s.z.literal("task")]),ne=s.z.object({type:ni,key:s.z.string()}),si=s.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),ai=s.z.union([si,ne]),Be=class Be{constructor(e){c(this,"type");c(this,"key");if(e instanceof Be)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};c(Be,"z",s.z.union([ai,s.z.instanceof(Be)]).transform(e=>new Be(e)));let X=Be;const uh=new X({type:"builtin",key:"root"}),ii=s.z.object({type:s.z.number()}),oi=s.z.object({type:ni,fields:s.z.record(ii)}),ci=s.z.object({id:X.z,name:s.z.string(),schema:oi.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(r=>({key:r.id.toString(),...r})),hh=s.z.object({from:X.z,type:s.z.string(),to:X.z}),Gr=r=>{const[e,t,n]=r.split("->");return{from:new X(e),type:t,to:new X(n)}},fh=s.z.object({group:lh}),dh=s.z.object({parent:ne,key:s.z.string().uuid().optional(),name:s.z.string()}),yh=s.z.object({key:s.z.string(),name:s.z.string()}),ph=s.z.object({keys:s.z.array(s.z.string())});var le;let gh=(le=class{constructor(e){c(this,"client");this.client=e}async create(e,t,n){const[a,i]=await this.client.send(le.ENDPOINT,{parent:e,name:t,key:n},dh,fh);if(i!=null)throw i;return a.group}async rename(e,t){const n={key:e,name:t},[,a]=await this.client.send(le.ENDPOINT_RENAME,n,yh,s.z.object({}));if(a!=null)throw a}async delete(e){const t={keys:e},[,n]=await this.client.send(le.ENDPOINT_DELETE,t,ph,s.z.object({}));if(n!=null)throw n}},c(le,"ENDPOINT","/ontology/create-group"),c(le,"ENDPOINT_RENAME","/ontology/rename-group"),c(le,"ENDPOINT_DELETE","/ontology/delete-group"),le),mh=class{constructor(e){c(this,"creator");this.creator=new gh(e)}async create(e,t,n){return this.sugar(await this.creator.create(e,t,n))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new oh(e.name,e.key)}};const xr={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},as=s.z.object({id:ne,children:ne.array()}),wh=s.z.object({from:ne,to:ne,children:ne.array()});let vh=class{constructor(e){c(this,"client");this.client=e}async addChildren(e,...t){await w(this.client,xr.ADD_CHILDREN,{id:e,children:t},as,s.z.object({}))}async removeChildren(e,...t){await w(this.client,xr.REMOVE_CHILDREN,{id:e,children:t},as,s.z.object({}))}async moveChildren(e,t,...n){const a={from:e,to:t,children:n};await w(this.client,xr.MOVE_CHILDREN,a,wh,s.z.object({}))}};const bh="/ontology/retrieve",Oh=s.z.object({ids:ne.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional()}),Th=s.z.object({resources:ci.array()}),Dr=r=>z(r).map(e=>new X(e).payload);let li=class{constructor(e,t){c(this,"type","ontology");c(this,"groups");c(this,"client");c(this,"writer");c(this,"framer");this.client=e,this.writer=new vh(e),this.groups=new mh(e),this.framer=t}async search(e,t){return await this.execRetrieve({term:e,...t})}async retrieve(e,t){const n=await this.execRetrieve({ids:Dr(e),...t});if(Array.isArray(e))return n;if(n.length===0)throw new ee(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t,n){return await this.execRetrieve({offset:e,limit:t,...n})}async retrieveChildren(e,t){return await this.execRetrieve({ids:Dr(e),children:!0,...t})}async retrieveParents(e,t){return await this.execRetrieve({ids:Dr(e),parents:!0,...t})}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await pr.open(this.framer,this)}newSearcherWithOptions(e){return{type:this.type,search:t=>this.search(t,e),retrieve:t=>this.retrieve(t,e),page:(t,n)=>this.page(t,n,e)}}async execRetrieve(e){const{resources:t}=await w(this.client,bh,e,Oh,Th);return t}};const is="sy_ontology_resource_set",os="sy_ontology_resource_delete",cs="sy_ontology_relationship_set",ls="sy_ontology_relationship_delete";class pr{constructor(e,t){c(this,"resourceObs");c(this,"relationshipObs");c(this,"relationships");c(this,"resources");c(this,"streamer");c(this,"client");c(this,"closePromise");this.relationshipObs=new Kr.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Kr.Observer,this.resources=this.resourceObs,this.client=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const i=this.parseRelationshipSets(e),o=this.parseRelationshipDeletes(e);i.concat(o).length>0&&this.relationshipObs.notify(i.concat(o))}parseRelationshipSets(e){const t=e.get(cs);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:Gr(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(ls);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:Gr(n)}))}async parseResourceSets(e){const t=e.get(is);if(t.length===0)return[];const n=Array.from(t.as("string")).map(a=>new X(a));try{return(await this.client.retrieve(n)).map(i=>({variant:"set",key:i.id,value:i}))}catch(a){if(a instanceof ee)return[];throw a}}parseResourceDeletes(e){const t=e.get(os);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new X(n)}))}static async open(e,t){const n=await e.openStreamer([is,os,cs,ls]);return new pr(n,t)}}const zh=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:pr,Client:li,ID:X,Root:uh,crudeIDZ:ai,idZ:ne,parseRelationship:Gr,relationshipSchemaZ:hh,resourceSchemaZ:ci,schemaFieldZ:ii,schemaZ:oi,stringIDZ:si},Symbol.toStringTag,{value:"Module"})),He=s.z.string().uuid(),wt=s.z.object({key:He,name:s.z.string().min(1),color:s.z.string()}),Eh=r=>new X({type:"label",key:r}),Sh=s.z.object({keys:He.array().optional(),for:ne.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Nh=s.z.object({labels:wt.array().optional().default([])});var qe;let ui=(qe=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(qe.ENDPOINT,e,Sh,Nh);if(n!=null)throw n;return t.labels}},c(qe,"ENDPOINT","/label/retrieve"),qe);const hi=wt.extend({key:He.optional()}),Ah=s.z.object({labels:hi.array()}),Ih=s.z.object({labels:wt.array()}),kh=s.z.object({keys:He.array()}),fi=s.z.object({id:ne,labels:He.array()}),$h=fi,Pr=s.z.object({}),Ch="/label/create",Rh="/label/delete",jh="/label/set",xh="/label/remove";let di=class{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,Ch,{labels:z(e)},Ah,Ih)).labels}async delete(e){await w(this.client,Rh,{keys:z(e)},kh,Pr)}async set(e,t){await w(this.client,jh,{id:e,labels:t},fi,Pr)}async remove(e,t){await w(this.client,xh,{id:e,labels:t},$h,Pr)}};const Dh="sy_label_set",Ph="sy_label_delete";let yi=class{constructor(e,t){c(this,"type","label");c(this,"retriever");c(this,"writer");c(this,"frameClient");this.writer=new di(e),this.retriever=new ui(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await gt(this.frameClient,Dh,Ph,Zh)}};const Zh=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(wt).map(t=>({variant:r,key:t.key,value:t})),Mh=Object.freeze(Object.defineProperty({__proto__:null,Client:yi,Retriever:ui,Writer:di,keyZ:He,labelZ:wt,newLabelPayloadZ:hi,ontologyID:Eh},Symbol.toStringTag,{value:"Module"})),G=s.z.string().uuid(),Xe=s.z.object({key:G,name:s.z.string().min(1),timeRange:J.z,color:s.z.string().optional()}),pi=Xe.extend({key:s.z.string().uuid().optional()}),gi=r=>{const e=z(r);if(e.length===0)throw new Error("Range params must not be empty");const t=G.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},_h=s.z.object({}),Uh=s.z.object({range:Xe}),Lh=s.z.object({range:G}),Bh=s.z.object({range:G}),qh=s.z.object({}),Yh="/range/set-active",Wh="/range/retrieve-active",Kh="/range/clear-active";class Vh{constructor(e){c(this,"client");this.client=e}async setActive(e){await w(this.client,Yh,{range:e},Lh,_h)}async retrieveActive(){const[e,t]=await this.client.send(Wh,{},s.z.object({}),Uh);if(t instanceof ee)return null;if(t!=null)throw t;return e.range}async clearActive(e){await w(this.client,Kh,{range:e},Bh,qh)}}const Fh="sy_range_alias_set",Jh="sy_range_alias_delete",Gh=s.z.object({range:G,aliases:s.z.string().array()}),Hh=s.z.object({aliases:s.z.record(s.z.string(),$e)}),Xh=s.z.object({range:G,aliases:s.z.record($e.or(s.z.string()),s.z.string())}),Qh=s.z.unknown(),ef=s.z.object({range:G,channels:$e.array()}),tf=s.z.unknown(),rf=s.z.object({range:G}),nf=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),ce=class ce{constructor(e,t,n){c(this,"frameClient");c(this,"cache",new Map);c(this,"client");c(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",a={};if(n){const o=this.cache.get(e);if(o!=null)return o;t.push(e)}else e.forEach(o=>{const l=this.cache.get(o);l!=null?a[o]=l:t.push(o)});if(t.length===0)return a;const i=await w(this.client,ce.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},Gh,Hh);return Object.entries(i.aliases).forEach(([o,l])=>this.cache.set(o,l)),n?i.aliases[t[0]]:{...a,...i.aliases}}async set(e){await w(this.client,ce.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Xh,Qh)}async list(){return(await w(this.client,ce.LIST_ENDPOINT,{range:this.rangeKey},rf,nf)).aliases}async delete(e){await w(this.client,ce.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},ef,tf)}async openChangeTracker(){return await gt(this.frameClient,Fh,Jh,of(this.rangeKey))}};c(ce,"SET_ENDPOINT","/range/alias/set"),c(ce,"RESOLVE_ENDPOINT","/range/alias/resolve"),c(ce,"LIST_ENDPOINT","/range/alias/list"),c(ce,"DELETE_ENDPOINT","/range/alias/delete");let Hr=ce;const sf=s.z.object({range:G,channel:$e,alias:s.z.string()}),af="---",of=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(af)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(sf).map(n=>({variant:e,key:n.alias,value:n})),cf=s.z.object({range:G,keys:s.z.string().array()}),lf=s.z.object({pairs:s.z.record(s.z.string(),s.z.string())}),uf=s.z.object({range:G,pairs:s.z.record(s.z.string(),s.z.string())}),hf=s.z.object({range:G,keys:s.z.string().array()}),Ae=class Ae{constructor(e,t){c(this,"rangeKey");c(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(Ae.GET_ENDPOINT,{range:this.rangeKey,keys:z(e)},cf,lf);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async list(){return this.get([])}async set(e,t=""){await w(this.client,Ae.SET_ENDPOINT,{range:this.rangeKey,pairs:Ia(e)?e:{[e]:t}},uf,s.z.unknown())}async delete(e){await w(this.client,Ae.DELETE_ENDPOINT,{range:this.rangeKey,keys:z(e)},hf,s.z.unknown())}};c(Ae,"GET_ENDPOINT","/range/kv/get"),c(Ae,"SET_ENDPOINT","/range/kv/set"),c(Ae,"DELETE_ENDPOINT","/range/kv/delete");let Xr=Ae;const Zr=r=>new X({type:"range",key:r});class mi{constructor(e,t=J.ZERO,n,a,i,o,l,u,p){c(this,"key");c(this,"name");c(this,"kv");c(this,"timeRange");c(this,"color");c(this,"channels");c(this,"aliaser");c(this,"frameClient");c(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=i,this.color=a,this.kv=o,this.aliaser=l,this.channels=u,this.labelClient=p}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new ee(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Zr(this.key))}async addLabel(...e){await this.labelClient.label(Zr(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Zr(this.key),e)}}const ff=s.z.object({keys:G.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:J.z.optional()}),df="/range/retrieve",yf=s.z.object({ranges:Fe(Xe)});let wi=class{constructor(e,t,n,a,i){c(this,"type","range");c(this,"frameClient");c(this,"writer");c(this,"unaryClient");c(this,"channels");c(this,"active");c(this,"labelClient");this.frameClient=e,this.writer=t,this.unaryClient=n,this.channels=a,this.active=new Vh(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(z(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(z(e))}async search(e){return this.sugar(await this.execRetrieve({term:e}))}async page(){return[]}async retrieve(e){if(typeof e=="object"&&"start"in e)return await this.execRetrieve({overlapsWith:new J(e)});const{single:t,actual:n,variant:a,normalized:i}=gi(e),o=await this.execRetrieve({[a]:i});if(!t)return o;if(o.length===0)throw new ct(`range matching ${n} not found`);if(o.length>1)throw new lt(`multiple ranges matching ${n} found`);return o[0]}async execRetrieve(e){const{ranges:t}=await w(this.unaryClient,df,e,ff,yf);return this.sugar(t)}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new mi(t.name,t.timeRange,t.key,t.color,this.frameClient,new Xr(t.key,this.unaryClient),new Hr(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}async openTracker(){return await gt(this.frameClient,"sy_range_set","sy_range_delete",(e,t)=>e==="delete"?t.toStrings().map(a=>({variant:e,key:a,value:void 0})):this.sugar(t.parseJSON(Xe)).map(a=>({variant:e,key:a.key,value:a})))}};const pf=s.z.object({ranges:Xe.array()}),gf=s.z.object({ranges:pi.array()}),mf=s.z.object({keys:G.array()}),wf=s.z.object({}),vf=s.z.object({key:G,name:s.z.string()}),bf=s.z.object({}),Of="/range/create",Tf="/range/delete",zf="/range/rename";let vi=class{constructor(e){c(this,"client");this.client=e}async rename(e,t){await w(this.client,zf,{key:e,name:t},vf,bf)}async create(e){return(await w(this.client,Of,{ranges:e},gf,pf)).ranges}async delete(e){await w(this.client,Tf,{keys:e},mf,wf)}};const Ef=Object.freeze(Object.defineProperty({__proto__:null,Client:wi,Range:mi,Writer:vi,analyzeParams:gi,keyZ:G,newPayloadZ:pi,payloadZ:Xe},Symbol.toStringTag,{value:"Module"})),Sf="/api/v1/";class Nf{constructor(e,t=!1){c(this,"url");c(this,"unary");c(this,"stream");c(this,"secure");this.secure=t,this.url=e.child(Sf);const n=new Ve.JSONEncoderDecoder;this.unary=new hl(this.url,n,this.secure),this.stream=new bl(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Rn=s.z.string().uuid(),jn=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r)))}),Af=s.z.object({keys:s.z.string().array()}),If=s.z.object({linePlots:jn.array()});let kf=class{constructor(e){c(this,"ENDPOINT","/workspace/lineplot/retrieve");c(this,"client");this.client=e}async retrieve(e){const t=z(e);return(await w(this.client,this.ENDPOINT,{keys:t},Af,If)).linePlots}};const Ce=s.z.string().uuid(),bi=r=>JSON.parse(r),xn=s.z.object({name:s.z.string(),key:Ce,layout:Sn.or(s.z.string().transform(r=>bi(r)))}),Dn=xn.omit({layout:!0}).extend({layout:s.z.string().transform(r=>bi(r))}),$f=jn.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Cf=s.z.object({workspace:Ce,linePlots:$f.array()}),Rf=s.z.object({linePlots:jn.array()}),jf=s.z.object({keys:Rn.array()}),xf=s.z.object({}),Df=s.z.object({key:Rn,name:s.z.string()}),Pf=s.z.object({}),Zf=s.z.object({key:Rn,data:s.z.string()}),Mf=s.z.object({}),_f="/workspace/lineplot/create",Uf="/workspace/lineplot/delete",Lf="/workspace/lineplot/rename",Bf="/workspace/lineplot/set-data";let qf=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,_f,{workspace:e,linePlots:[n]},Cf,Rf)).linePlots[0]}async delete(e){const t=z(e);await w(this.client,Uf,{keys:t},jf,xf)}async rename(e,t){await w(this.client,Lf,{key:e,name:t},Df,Pf)}async setData(e,t){await w(this.client,Bf,{key:e,data:JSON.stringify(t)},Zf,Mf)}},Yf=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new qf(e),this.retriever=new kf(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Wf=s.z.object({keys:Ce.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Kf=s.z.object({workspaces:Fe(Dn)});var Ye;let Vf=(Ye=class{constructor(e){c(this,"client");this.client=e}async retrieve(e){const t=z(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await w(this.client,Ye.ENDPOINT,e,Wf,Kf)).workspaces}},c(Ye,"ENDPOINT","/workspace/retrieve"),Ye);const gr=s.z.string().uuid(),Ff=s.z.object({key:s.z.string(),name:s.z.string(),data:Sn.or(s.z.string().transform(r=>JSON.parse(r))),snapshot:s.z.boolean()}),Pn=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(r=>JSON.parse(r))}),Jf=s.z.object({keys:s.z.string().array()}),Gf=s.z.object({schematics:Pn.array()});class Hf{constructor(e){c(this,"ENDPOINT","/workspace/schematic/retrieve");c(this,"client");this.client=e}async retrieve(e){return(await w(this.client,this.ENDPOINT,{keys:z(e)},Jf,Gf)).schematics}}const Xf=Ff.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Qf=s.z.object({workspace:Ce,schematics:Xf.array()}),ed=s.z.object({schematics:Pn.array()}),td=s.z.object({keys:gr.array()}),rd=s.z.object({}),nd=s.z.object({key:gr,name:s.z.string()}),us=s.z.object({}),sd=s.z.object({key:gr,data:s.z.string()});s.z.object({});const ad=s.z.object({key:gr,name:s.z.string(),snapshot:s.z.boolean()}),id=s.z.object({schematic:Pn}),od="/workspace/schematic/create",cd="/workspace/schematic/delete",ld="/workspace/schematic/rename",ud="/workspace/schematic/set-data",hd="/workspace/schematic/copy";let fd=class{constructor(e){c(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await w(this.client,od,{workspace:e,schematics:[n]},Qf,ed)).schematics[0]}async copy(e,t,n){return(await w(this.client,hd,{key:e,name:t,snapshot:n},ad,id)).schematic}async delete(e){const t=z(e);await w(this.client,cd,{keys:t},td,rd)}async rename(e,t){await w(this.client,ld,{key:e,name:t},nd,us)}async setData(e,t){await w(this.client,ud,{key:e,data:JSON.stringify(t)},sd,us)}},dd=class{constructor(e){c(this,"writer");c(this,"retriever");this.writer=new fd(e),this.retriever=new Hf(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const yd=xn.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),pd=s.z.object({workspaces:yd.array()}),gd=s.z.object({workspaces:Dn.array()}),md=s.z.object({keys:Ce.array()}),wd=s.z.object({}),vd=s.z.object({key:Ce,name:s.z.string()}),bd=s.z.object({}),Od=s.z.object({key:Ce,layout:s.z.string()}),Td=s.z.object({}),zd="/workspace/create",Ed="/workspace/delete",Sd="/workspace/rename",Nd="/workspace/set-layout";class Ad{constructor(e){c(this,"client");this.client=e}async create(e){return(await w(this.client,zd,{workspaces:z(e)},pd,gd)).workspaces}async delete(e){await w(this.client,Ed,{keys:z(e)},md,wd)}async rename(e,t){await w(this.client,Sd,{key:e,name:t},vd,bd)}async setLayout(e,t){await w(this.client,Nd,{key:e,layout:JSON.stringify(t)},Od,Td)}}class Oi{constructor(e){c(this,"type","workspace");c(this,"schematic");c(this,"linePlot");c(this,"retriever");c(this,"writer");this.schematic=new dd(e),this.linePlot=new Yf(e),this.retriever=new Vf(e),this.writer=new Ad(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const Id=Object.freeze(Object.defineProperty({__proto__:null,Client:Oi,keyZ:Ce,workspaceRemoteZ:Dn,workspaceZ:xn},Symbol.toStringTag,{value:"Module"})),Ti=s.z.object({host:s.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:s.z.number({required_error:"Port is required"}).or(s.z.string({required_error:"Port is required"})),username:s.z.string().optional(),password:s.z.string().optional(),connectivityPollFrequency:N.z.default(N.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class zi extends Wa{constructor(t){const n=Ti.parse(t),{host:a,port:i,username:o,password:l,connectivityPollFrequency:u,secure:p}=n,g=new Nf(new Ml({host:a,port:Number(i)}),p);g.use(El);let y;if(o!=null&&l!=null){const Si=new iu(g.unary,{username:o,password:l});g.use(Si.middleware())}const U=new Nn(new ht(g.unary)),x=new Za(g.unary);super(g.stream,g.unary,U);c(this,"createdAt");c(this,"props");c(this,"ranges");c(this,"channels");c(this,"auth");c(this,"connectivity");c(this,"ontology");c(this,"workspaces");c(this,"labels");c(this,"hardware");c(this,"control");c(this,"transport");this.createdAt=E.now(),this.props=n,this.auth=y,this.transport=g,this.channels=new Pa(this,U,g.unary,x),this.connectivity=new ft(g.unary,u,n.name),this.control=new Va(this),this.ontology=new li(g.unary,this);const Q=new vi(this.transport.unary);this.labels=new yi(this.transport.unary,this),this.ranges=new wi(this,Q,this.transport.unary,U,this.labels),this.workspaces=new Oi(this.transport.unary);const P=new Qa(this.transport.unary,this),Zn=new ri(this.transport.unary,this),Ei=new Ga(this.transport.unary,this,Zn);this.hardware=new Fa(Zn,Ei,P)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}c(zi,"connectivity",ft);const kd=Ke.Authority;exports.AuthError=We;exports.Authority=kd;exports.Channel=An;exports.ContiguityError=Ol;exports.DataType=S;exports.Density=V;exports.Frame=_;exports.MultiSeries=Ls;exports.QueryError=ee;exports.Rate=Ht;exports.RouteError=Bt;exports.Series=F;exports.Synnax=zi;exports.TimeRange=J;exports.TimeSpan=N;exports.TimeStamp=E;exports.UnexpectedError=xe;exports.ValidationError=D;exports.channel=tu;exports.connection=lu;exports.control=ku;exports.device=Vu;exports.framer=Eu;exports.hardware=$u;exports.label=Mh;exports.ontology=zh;exports.rack=Fu;exports.ranger=Ef;exports.signals=Zu;exports.synnaxPropsZ=Ti;exports.task=ih;exports.workspace=Id;
|