@synnaxlabs/pluto 0.50.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Animated-eavjaVoD.js → Animated-BbeJdao0.js} +2 -2
- package/dist/{Animated-DxBr38YY.js → Animated-C4xrEVd-.js} +3 -3
- package/dist/{Animated-DpzwlYqX.cjs → Animated-Dvm2k_z_.cjs} +1 -1
- package/dist/{Animated-Bm-WM4BW.cjs → Animated-umWjgTzy.cjs} +1 -1
- package/dist/{Button-Cj2hR9EM.cjs → Button-BSek5HG5.cjs} +1 -1
- package/dist/{Button-DulIBpNI.js → Button-DLtxKGH5.js} +4 -4
- package/dist/{Dialog-DJJQBUgw.cjs → Dialog-BpjxXSmw.cjs} +1 -1
- package/dist/{Dialog-CwTHvHHD.js → Dialog-BspO7uo8.js} +1 -1
- package/dist/{Haul-CofQrOeX.js → Haul-DBy-2ds_.js} +1 -1
- package/dist/{Haul-gTF4QDh3.cjs → Haul-WgPKptr9.cjs} +1 -1
- package/dist/{Items-DjAwxhhi.cjs → Items-07R286kW.cjs} +2 -2
- package/dist/{Items-B5aeU-Pt.js → Items-CX11yLMf.js} +7 -5
- package/dist/{Menu-BqfIul2o.cjs → Menu-58O-OOPJ.cjs} +1 -1
- package/dist/{Menu-Bjfeoaln.js → Menu-GBo3ayoP.js} +4 -4
- package/dist/Provider-BA3zQVbv.cjs +1 -0
- package/dist/{Provider-BoQtgQtU.js → Provider-BkxUzTWS.js} +54 -51
- package/dist/Tags-DWsEZD9t.cjs +1 -0
- package/dist/{Tags-C38F7I5z.js → Tags-V7sNuGZv.js} +41 -36
- package/dist/{Text-IFQH97iK.cjs → Text-DW5FpCk9.cjs} +1 -1
- package/dist/{Text-TzKJ38En.js → Text-XeD58Fq8.js} +444 -439
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/color.cjs +1 -1
- package/dist/color.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{eraser-DZxY0pWe.cjs → eraser-Bocga8Eb.cjs} +1 -1
- package/dist/{eraser-Bd14L_5k.js → eraser-DuAfpO0P.js} +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +6 -6
- package/dist/{external-D4rp1QBE.cjs → external-5_uHky7w.cjs} +1 -1
- package/dist/{external-6HkYP0wd.js → external-B-JsNciM.js} +4 -4
- package/dist/{external-BIW55htp.cjs → external-B9omdiDK.cjs} +1 -1
- package/dist/{external-CkwpcNCW.cjs → external-BIbdeWQE.cjs} +1 -1
- package/dist/{external-D7qXEQQM.cjs → external-BRA_zA83.cjs} +1 -1
- package/dist/{external-BWI-FZRf.cjs → external-Bjh6lsVm.cjs} +1 -1
- package/dist/{external-DPow1FDR.cjs → external-BwRkgEyo.cjs} +1 -1
- package/dist/{external-BKkDVUP_.js → external-CLQdSLv0.js} +2 -2
- package/dist/{external-CVzhqlPH.js → external-CdHyPhLI.js} +1 -1
- package/dist/{external-DKc3PiyN.js → external-Ct1k30Nd.js} +3 -3
- package/dist/{external-DlHNhR1y.cjs → external-Ct2A_YCT.cjs} +1 -1
- package/dist/{external-Bl8zTvKt.js → external-DNbIzfVy.js} +43 -42
- package/dist/{external-CUHCzUJE.cjs → external-DT82RBon.cjs} +1 -1
- package/dist/{external-gDa9Z0SY.js → external-DXWEyk9d.js} +2 -2
- package/dist/{external-BU5fnKG8.cjs → external-DojNoICL.cjs} +1 -1
- package/dist/{external-DqaHmzvp.js → external-Dp5OkGYV.js} +5 -5
- package/dist/{external-BoAcV4dI.js → external-DxmgAHkn.js} +3 -3
- package/dist/{external-DAmwuDsu.cjs → external-DyTk_hS7.cjs} +1 -1
- package/dist/{external-B0R_yw6F.cjs → external-PXU0gc_j.cjs} +1 -1
- package/dist/{external-BsdKmL37.js → external-g_vt4Lku.js} +10 -10
- package/dist/{external-DCZMzNZX.js → external-sYHm9OG8.js} +3 -3
- package/dist/{external-DrcMI5oa.js → external-xfkS0zGI.js} +8 -8
- package/dist/{fontString-BtjO8Met.js → fontString-CSWLcJcC.js} +1 -1
- package/dist/{fontString-CeR_vHX_.cjs → fontString-TocVNWmy.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/{hooks-Ddqh5NVY.js → hooks-BeSuo_di.js} +1 -1
- package/dist/{hooks-Dxvxse16.cjs → hooks-Eb94kuDd.cjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2718 -2713
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/list.cjs +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.cjs +1 -1
- package/dist/menu.js +1 -1
- package/dist/pluto.css +1 -1
- package/dist/{provider-CfFukcDe.js → provider-D0K9E52u.js} +88 -79
- package/dist/{provider-BmDwHwF4.cjs → provider-DksyuJua.cjs} +6 -6
- package/dist/src/flux/list.d.ts.map +1 -1
- package/dist/src/form/useField.d.ts.map +1 -1
- package/dist/src/icon/registry.d.ts +1 -0
- package/dist/src/icon/registry.d.ts.map +1 -1
- package/dist/src/list/Frame.d.ts.map +1 -1
- package/dist/src/select/Frame.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +63 -0
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/base/theme.d.ts +39 -0
- package/dist/src/theming/base/theme.d.ts.map +1 -1
- package/dist/src/theming/css.d.ts.map +1 -1
- package/dist/src/tree/external.d.ts +1 -0
- package/dist/src/tree/external.d.ts.map +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/theme.css +135 -123
- package/dist/theming.cjs +1 -1
- package/dist/theming.js +2 -2
- package/dist/tree.cjs +1 -1
- package/dist/tree.js +1 -1
- package/dist/triggers.cjs +1 -1
- package/dist/triggers.js +1 -1
- package/dist/{value-C-e017qO.js → value-BmuhX6zs.js} +3 -3
- package/dist/{value-0g5Cxim9.cjs → value-CZfzRi_x.cjs} +1 -1
- package/package.json +7 -7
- package/dist/Provider-CKROy_xK.cjs +0 -1
- package/dist/Tags-B3m_Kzbp.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const a=require("zod"),x=require("./css-D3NdC2sx.cjs"),Qe=require("./types-C0tUDfsz.cjs"),zd=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},vo=t=>{const e=(r,n=cs)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Rn(r))return r;n=Sd(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(Rn(c)?ui(c)||(c=e(c,n)):n.recursiveInArray&&li(c)&&(c=[...c].map(u=>{let h=u;return Rn(u)?ui(h)||(h=e(u,n)):li(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},zo=vo(zd),Od=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Td=vo(Od),kd=[Number,String,Uint8Array],cs={recursive:!0,recursiveInArray:!0},Sd=(t=cs)=>(t.recursive==null?t=cs:t.recursiveInArray??=!1,t),li=t=>t!=null&&Array.isArray(t),Rn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ui=t=>kd.some(e=>t instanceof e);let Nd=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=zo(r);return e!=null?e.parse(n):n}encodeString(t){const e=Td(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const ls=new Nd,we=t=>t!=null&&typeof t=="object"&&"value"in t;class Gt{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Ed=t=>t!=null&&typeof t=="object"&&"toString"in t,Ad=(t,e=!1)=>{const r=Ed(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?xd(n):n},xd=t=>(e,r)=>t(r,e);let Oo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const To="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Id=`0123456789${To}`,Cd=11,jd=Oo(To,1),$d=Oo(Id,Cd-1),Md=()=>`${jd()}${$d()}`,_d=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Zd=2**12-1,us=2n**63n-1n,Ud=2**63-1,yn=t=>(e,r)=>{if(typeof e=="bigint"){if(Pd(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},xr=yn((t,e)=>t-e),wt=yn((t,e)=>t+e),Pd=t=>typeof t=="bigint"?!0:Number.isInteger(t),je=yn((t,e)=>t*e),mn=yn((t,e)=>t/e),ko=a.z.tuple([a.z.number(),a.z.number()]),So=a.z.object({width:a.z.number(),height:a.z.number()}),Rd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Ld=["start","center","end"],pr=a.z.object({x:a.z.number(),y:a.z.number()}),Dd=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Bd=["x","y"],No=a.z.enum(Bd),Eo=["top","right","bottom","left"];a.z.enum(Eo);const Fd=["left","right"],Ao=a.z.enum(Fd),qd=["top","bottom"],xo=a.z.enum(qd),Io=["center"],hi=a.z.enum(Io),Yd=[...Eo,...Io],Co=a.z.enum(Yd);a.z.enum(Ld);const Vd=["first","last"];a.z.enum(Vd);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...No.options,...Co.options]);a.z.union([No,Co,a.z.instanceof(String)]);const bt=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?Hd(n):n},Hd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,di=(t,e)=>{const r=bt(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};a.z.object({x:Ao.or(hi),y:xo.or(hi)});const jo=a.z.object({x:Ao,y:xo}),Wd=Object.freeze({x:"left",y:"top"}),Gd=(t,e)=>t.x===e.x&&t.y===e.y,fi=a.z.union([a.z.number(),pr,ko,So,Rd,Dd]),Kd=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},pi=Object.freeze({x:0,y:0}),Yr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Yr,left:Yr,width:Yr,height:Yr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:pr,two:pr,root:jo});const Xs=(t,e,r=0,n=0,s)=>{const i={one:{...pi},two:{...pi},root:s??Wd};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"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))},Ln=t=>{const e=Xs(t);return{lower:e.one.x,upper:e.two.x}},Dn=t=>{const e=Xs(t);return{lower:e.one.y,upper:e.two.y}},Jd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Xd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([So,Xd,pr,ko]);const Qd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:fi,scale:fi});a.z.object({offset:a.z.number(),scale:a.z.number()});const ef=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],tf=t=>(e,r,n,s)=>[e,s?n/t:n*t],rf=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},nf=t=>(e,r,n)=>[t,n],sf=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},af=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Qd(n,s,i),[e,n]};class rt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,r){return new rt().scale(e,r)}translate(e){const r=this.new(),n=ef(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=tf(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=bt(e,r),s=this.new(),i=rf(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=bt(e,r),s=this.new(),i=af(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=bt(e,r),s=this.new(),i=nf(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=sf();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new rt}class Ie{x;y;currRoot;constructor(e=new rt,r=new rt,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ie().translate(e,r)}static translateX(e){return new Ie().translateX(e)}static translateY(e){return new Ie().translateY(e)}static clamp(e){return new Ie().clamp(e)}static magnify(e){return new Ie().magnify(e)}static scale(e){return new Ie().scale(e)}static reBound(e){return new Ie().reBound(e)}translate(e,r){const n=Kd(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Jd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Gd(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Ln(e)),r.y=r.y.scale(Dn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Ln(e)),r.y=this.y.reBound(Dn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Ln(e)),r.y=this.y.clamp(Dn(e)),r}copy(){const e=new Ie;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return Xs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new Ie}const of=pr.extend({root:jo,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});of.partial({root:!0,units:!0});const cf=a.z.enum(["static","dynamic"]),yi=365,Vr=30,lf=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),$o=(t,e)=>{const r=new R(e);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof R?new R(n):new g(n)};let R=class T extends Gt{constructor(e,r="UTC"){if(e==null)super(T.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*T.MILLISECOND.valueOf());else if(typeof e=="string")super(T.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(T.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Ud?e=us:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),we(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(s.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=T.hours(parseInt(n??"00")).add(T.minutes(parseInt(s??"00"))).add(T.seconds(parseInt(o??"00"))).add(T.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(T.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*T.MILLISECOND.valueOf(),l=BigInt(i)*T.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new cr(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(wt(this.valueOf(),new g(e).valueOf()))}sub(e){return new T(xr(this.valueOf(),new g(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new T(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new T(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new T(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new T(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new T(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new T(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new T(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new T(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return $o(this,e)}get isToday(){return this.truncate(g.DAY).equals(T.now().truncate(g.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(g.days(30))?"shortDate":e.greaterThanOrEqual(g.DAY)?"dateTime":e.greaterThanOrEqual(g.HOUR)?"time":e.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const s=new T(n);s.after(r)&&(r=s)}return r}static min(...e){let r=T.MAX;for(const n of e){const s=new T(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new T(e,r)}static NANOSECOND=T.nanoseconds(1);static microseconds(e,r="UTC"){return T.nanoseconds(e*1e3,r)}static MICROSECOND=T.microseconds(1);static milliseconds(e,r="UTC"){return T.microseconds(e*1e3,r)}static MILLISECOND=T.milliseconds(1);static seconds(e,r="UTC"){return T.milliseconds(e*1e3,r)}static SECOND=T.seconds(1);static minutes(e,r="UTC"){return T.seconds(e*60,r)}static MINUTE=T.minutes(1);static hours(e,r="UTC"){return T.minutes(e*60,r)}static HOUR=T.hours(1);static days(e,r="UTC"){return T.hours(e*24,r)}static DAY=T.days(1);static MAX=new T(us);static MIN=new T(0);static ZERO=new T(0);static z=a.z.union([a.z.instanceof(T),a.z.object({value:a.z.bigint()}).transform(e=>new T(e.value)),a.z.string().transform(e=>new T(BigInt(e))),a.z.number().transform(e=>new T(e)),a.z.bigint().transform(e=>new T(e)),a.z.date().transform(e=>new T(e)),a.z.custom(e=>e instanceof g).transform(e=>new T(e)),lf.transform(e=>new T(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}};class g extends Gt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),we(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.seconds(e):new g(e))}static fromMilliseconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return $o(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(g.DAY),n=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),l=this.truncate(g.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),z=o.sub(i),I=c.sub(o),j=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),z.isZero||(b+=`${z.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),j.isZero||(b+=`${j.nanoseconds}ns`),b.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new g(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(g.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/yi),u=Math.floor(s/Vr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),z=Math.floor(o),I=Math.floor(c),j=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const v=Math.floor(s%yi/Vr);v>0&&(b+=` ${v}mo`)}return j+b}if(h>=1&&s<Vr&&s%7===0){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(u>=1){let b=`${u}mo`;if(u<3){const v=Math.floor(s%Vr);v>0&&(b+=` ${v}d`)}return j+b}if(h>=1){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(f>=1){let b=`${f}d`;const v=Math.floor(i-f*24);return f<2&&v>0&&(b+=` ${v}h`),j+b}if(d>=1){let b=`${d}h`;if(d<3){const v=Math.floor(o-d*60);v>0&&(b+=` ${v}m`)}return j+b}if(z>=1){let b=`${z}m`;if(z<5){const v=Math.floor(c-z*60);v>0&&(b+=` ${v}s`)}return j+b}return`${j}${I}s`}mult(e){return new g(je(this.valueOf(),e))}div(e){return new g(mn(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static NANOSECOND=g.nanoseconds(1);static microseconds(e=1){return g.nanoseconds(je(e,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(e=1){return g.microseconds(je(e,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(e=1){return g.milliseconds(je(e,1e3))}static SECOND=g.seconds(1);static minutes(e=1){return g.seconds(je(e,60))}static MINUTE=g.minutes(1);static hours(e){return g.minutes(je(e,60))}static HOUR=g.hours(1);static days(e){return g.hours(je(e,24))}static DAY=g.days(1);static MAX=new g(us);static MIN=new g(0);static ZERO=new g(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new g(e.value)),a.z.string().transform(e=>new g(BigInt(e))),a.z.number().transform(e=>new g(e)),a.z.bigint().transform(e=>new g(e)),a.z.instanceof(g),a.z.instanceof(R).transform(e=>new g(e)),a.z.custom(e=>e instanceof Bn).transform(e=>new g(e))])}let Bn=class ye extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ye(e).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(e){return new g(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new te(r).valueOf()}span(e){return g.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new te(r).valueOf())}add(e){return new ye(wt(this.valueOf(),new ye(e).valueOf()))}sub(e){return new ye(xr(this.valueOf(),new ye(e).valueOf()))}mult(e){return new ye(je(this.valueOf(),e))}div(e){return new ye(mn(this.valueOf(),e))}static hz(e){return new ye(e)}static khz(e){return ye.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new ye(e)),a.z.instanceof(ye)])},te=class se extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new hs(e*this.valueOf())}add(e){return new se(wt(this.valueOf(),new se(e).valueOf()))}sub(e){return new se(xr(this.valueOf(),new se(e).valueOf()))}mult(e){return new se(je(this.valueOf(),e))}div(e){return new se(mn(this.valueOf(),e))}static UNKNOWN=new se(0);static BIT128=new se(16);static BIT64=new se(8);static BIT32=new se(4);static BIT16=new se(2);static BIT8=new se(1);static z=a.z.union([a.z.number().transform(e=>new se(e)),a.z.instanceof(se)])},cr=class Te{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new R(e.start),this.end=new R(e.end)):(this.start=new R(e),this.end=new R(r))}get span(){return new g(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Te(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=g.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=g.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=R.max(n.start,e.start),i=R.min(n.end,e.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof Te?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Te(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new Te(R.min(...e.map(r=>r.start)),R.max(...e.map(r=>r.end)))}static MAX=new Te(R.MIN,R.MAX);static ZERO=new Te(R.ZERO,R.ZERO);static z=a.z.union([a.z.object({start:R.z,end:R.z}).transform(e=>new Te(e.start,e.end)),a.z.instanceof(Te)]);static sort(e,r){return R.sort(e.start,r.start)||R.sort(e.end,r.end)}static merge(...e){return Te.max(...e.map(r=>new Te(r).makeValid()))}},Y=class y extends Gt{constructor(e){if(we(e)&&(e=e.value),e instanceof y||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=y.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=y.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?y.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(y.JSON)||this.equals(y.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(y.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=y.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(y.UINT8)||this.equals(y.UINT16)||this.equals(y.UINT32)||this.equals(y.UINT64)}get isSignedInteger(){return this.equals(y.INT8)||this.equals(y.INT16)||this.equals(y.INT32)||this.equals(y.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(y.INT32)&&e.equals(y.FLOAT64)||this.equals(y.INT8)&&e.equals(y.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return y.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new y("unknown");static FLOAT64=new y("float64");static FLOAT32=new y("float32");static INT64=new y("int64");static INT32=new y("int32");static INT16=new y("int16");static INT8=new y("int8");static UINT64=new y("uint64");static UINT32=new y("uint32");static UINT16=new y("uint16");static UINT8=new y("uint8");static BOOLEAN=new y("boolean");static TIMESTAMP=new y("timestamp");static UUID=new y("uuid");static STRING=new y("string");static JSON=new y("json");static 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]]);static 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]]);static DENSITIES=new Map([[y.UINT8.toString(),te.BIT8],[y.UINT16.toString(),te.BIT16],[y.UINT32.toString(),te.BIT32],[y.UINT64.toString(),te.BIT64],[y.FLOAT32.toString(),te.BIT32],[y.FLOAT64.toString(),te.BIT64],[y.INT8.toString(),te.BIT8],[y.INT16.toString(),te.BIT16],[y.INT32.toString(),te.BIT32],[y.INT64.toString(),te.BIT64],[y.TIMESTAMP.toString(),te.BIT64],[y.STRING.toString(),te.UNKNOWN],[y.JSON.toString(),te.UNKNOWN],[y.UUID.toString(),te.BIT128]]);static 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];static SHORT_STRINGS=new Map([[y.UINT8.toString(),"u8"],[y.UINT16.toString(),"u16"],[y.UINT32.toString(),"u32"],[y.UINT64.toString(),"u64"],[y.INT8.toString(),"i8"],[y.INT16.toString(),"i16"],[y.INT32.toString(),"i32"],[y.INT64.toString(),"i64"],[y.FLOAT32.toString(),"f32"],[y.FLOAT64.toString(),"f64"],[y.BOOLEAN.toString(),"bool"],[y.TIMESTAMP.toString(),"ts"],[y.UUID.toString(),"uuid"],[y.STRING.toString(),"str"],[y.JSON.toString(),"json"]]);static BIG_INT_TYPES=[y.INT64,y.UINT64,y.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new y(e)),a.z.instanceof(y)])},hs=class $ extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return we(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return we(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return we(e)&&(e=e.value),new $(wt(this.valueOf(),e.valueOf()))}sub(e){return we(e)&&(e=e.value),new $(xr(this.valueOf(),e.valueOf()))}mult(e){return new $(je(this.valueOf(),e))}div(e){return new $(mn(this.valueOf(),e))}truncate(e){return new $(Math.trunc(this.valueOf()/new $(e).valueOf())*new $(e).valueOf())}remainder(e){return $.bytes(this.valueOf()%new $(e).valueOf())}get gigabytes(){return this.valueOf()/$.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/$.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/$.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/$.TERABYTE.valueOf()}toString(){const e=this.truncate($.TERABYTE),r=this.truncate($.GIGABYTE),n=this.truncate($.MEGABYTE),s=this.truncate($.KILOBYTE),i=this.truncate($.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new $(e)}static BYTE=new $(1);static kilobytes(e=1){return $.bytes(new $(e).valueOf()*1e3)}static KILOBYTE=$.kilobytes(1);static megabytes(e=1){return $.kilobytes(new $(e).valueOf()*1e3)}static MEGABYTE=$.megabytes(1);static gigabytes(e=1){return $.megabytes(new $(e).valueOf()*1e3)}static GIGABYTE=$.gigabytes(1);static terabytes(e){return $.gigabytes(new $(e).valueOf()*1e3)}static TERABYTE=$.terabytes(1);static ZERO=new $(0);static z=a.z.union([a.z.number().transform(e=>new $(e)),a.z.instanceof($)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Mo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof R||t instanceof g||t instanceof Date},uf=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):xr(r,n),hf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function df(t){return typeof t=="string"&&hf.test(t)}const Q=[];for(let t=0;t<256;++t)Q.push((t+256).toString(16).slice(1));function ff(t,e=0){return(Q[t[e+0]]+Q[t[e+1]]+Q[t[e+2]]+Q[t[e+3]]+"-"+Q[t[e+4]]+Q[t[e+5]]+"-"+Q[t[e+6]]+Q[t[e+7]]+"-"+Q[t[e+8]]+Q[t[e+9]]+"-"+Q[t[e+10]]+Q[t[e+11]]+Q[t[e+12]]+Q[t[e+13]]+Q[t[e+14]]+Q[t[e+15]]).toLowerCase()}function pf(t,e=0){const r=ff(t,e);if(!df(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const _o=(t,e)=>pf(t,e),Ge=-1,yf=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),mf=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),ds=10,gf=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Zo="sy_x_telem_series";let Uo=class et{key;discriminator=Zo;dataType;sampleOffset;gl;_data;timeRange=cr.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ge;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:cr.z.optional(),dataType:Y.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([yf,mf,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:cf.default("static").optional()});static z=et.crudeZ.transform(e=>new et(e));constructor(e){wf(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=Md(),data:u}=e;if(bf(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=Mo(u),f=Array.isArray(u);if(r!=null)this.dataType=new Y(r);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(f||h){let d=u;if(!h){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.");d=u[0]}if(typeof d=="string")this.dataType=Y.STRING;else if(typeof d=="number")this.dataType=Y.FLOAT64;else if(typeof d=="bigint")this.dataType=Y.INT64;else if(typeof d=="boolean")this.dataType=Y.BOOLEAN;else if(d instanceof R||d instanceof Date||d instanceof R)this.dataType=Y.TIMESTAMP;else if(typeof d=="object")this.dataType=Y.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new Y(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof R||z instanceof Date||z instanceof g)&&(d=d.map(I=>new R(I).valueOf())),this.dataType.equals(Y.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
1
|
+
"use strict";const a=require("zod"),A=require("./css-D3NdC2sx.cjs"),Qe=require("./types-C0tUDfsz.cjs"),zd=t=>{const e=t.replace(/_[a-z]/g,r=>r[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},vo=t=>{const e=(r,n=cs)=>{if(typeof r=="string")return t(r);if(Array.isArray(r))return r.map(o=>e(o,n));if(!Rn(r))return r;n=Sd(n);const s={},i=r;return"toJSON"in i&&typeof i.toJSON=="function"?e(i.toJSON(),n):(Object.keys(i).forEach(o=>{let c=i[o];const l=t(o);n.recursive&&(Rn(c)?ui(c)||(c=e(c,n)):n.recursiveInArray&&li(c)&&(c=[...c].map(u=>{let h=u;return Rn(u)?ui(h)||(h=e(u,n)):li(u)&&(h=e({key:u},n).key),h}))),s[l]=c}),s)};return e},zo=vo(zd),Od=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,r,n)=>`${r}_${n.toLowerCase()}`),Td=vo(Od),kd=[Number,String,Uint8Array],cs={recursive:!0,recursiveInArray:!0},Sd=(t=cs)=>(t.recursive==null?t=cs:t.recursiveInArray??=!1,t),li=t=>t!=null&&Array.isArray(t),Rn=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),ui=t=>kd.some(e=>t instanceof e);let Nd=class{contentType="application/json";decoder;encoder;constructor(){this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t))}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const r=JSON.parse(t),n=zo(r);return e!=null?e.parse(n):n}encodeString(t){const e=Td(t);return JSON.stringify(e,(r,n)=>ArrayBuffer.isView(n)?Array.from(n):typeof n=="bigint"?n.toString():n)}};const ls=new Nd,we=t=>t!=null&&typeof t=="object"&&"value"in t;class Gt{value;constructor(e){this.value=e}valueOf(){return this.value}toJSON(){return this.value}toString(){return this.value.toString()}}const Ed=t=>t!=null&&typeof t=="object"&&"toString"in t,Ad=(t,e=!1)=>{const r=Ed(t)?"stringer":typeof t;let n;switch(r){case"string":n=(s,i)=>s.localeCompare(i);break;case"stringer":n=(s,i)=>s.toString().localeCompare(i.toString());break;case"number":n=(s,i)=>Number(s)-Number(i);break;case"bigint":n=(s,i)=>BigInt(s)-BigInt(i)>0n?1:-1;break;case"boolean":n=(s,i)=>Number(s)-Number(i);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${r}`),()=>-1}return e?xd(n):n},xd=t=>(e,r)=>t(r,e);let Oo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};const To="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Id=`0123456789${To}`,Cd=11,jd=Oo(To,1),$d=Oo(Id,Cd-1),Md=()=>`${jd()}${$d()}`,_d=(t,e)=>r=>r instanceof e||typeof r=="object"&&r!==null&&"discriminator"in r&&r.discriminator===t,Zd=2**12-1,us=2n**63n-1n,Ud=2**63-1,yn=t=>(e,r)=>{if(typeof e=="bigint"){if(Pd(r))return t(e,BigInt(r));const n=t(Number(e),Number(r));return typeof n=="number"?BigInt(Math.round(n)):n}return t(Number(e),Number(r))},xr=yn((t,e)=>t-e),wt=yn((t,e)=>t+e),Pd=t=>typeof t=="bigint"?!0:Number.isInteger(t),je=yn((t,e)=>t*e),mn=yn((t,e)=>t/e),ko=a.z.tuple([a.z.number(),a.z.number()]),So=a.z.object({width:a.z.number(),height:a.z.number()}),Rd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()}),Ld=["start","center","end"],pr=a.z.object({x:a.z.number(),y:a.z.number()}),Dd=a.z.object({clientX:a.z.number(),clientY:a.z.number()}),Bd=["x","y"],No=a.z.enum(Bd),Eo=["top","right","bottom","left"];a.z.enum(Eo);const Fd=["left","right"],Ao=a.z.enum(Fd),qd=["top","bottom"],xo=a.z.enum(qd),Io=["center"],hi=a.z.enum(Io),Yd=[...Eo,...Io],Co=a.z.enum(Yd);a.z.enum(Ld);const Vd=["first","last"];a.z.enum(Vd);a.z.object({lower:a.z.number(),upper:a.z.number()});a.z.enum([...No.options,...Co.options]);a.z.union([No,Co,a.z.instanceof(String)]);const bt=(t,e,r)=>{const n={};if(typeof e=="object"&&(r=e,e=void 0),r={makeValid:!0,...r},typeof t=="number"||typeof t=="bigint")e!=null?(n.lower=t,n.upper=e):(n.lower=typeof t=="bigint"?0n:0,n.upper=t);else if(Array.isArray(t)){if(t.length!==2)throw new Error("bounds: expected array of length 2");[n.lower,n.upper]=t}else n.lower=t.lower,n.upper=t.upper;return r?.makeValid?Hd(n):n},Hd=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,di=(t,e)=>{const r=bt(t);return e<r.lower?r.lower:e>=r.upper?r.upper-(typeof r.upper=="number"?1:1n):e};a.z.object({x:Ao.or(hi),y:xo.or(hi)});const jo=a.z.object({x:Ao,y:xo}),Wd=Object.freeze({x:"left",y:"top"}),Gd=(t,e)=>t.x===e.x&&t.y===e.y,fi=a.z.union([a.z.number(),pr,ko,So,Rd,Dd]),Kd=(t,e)=>{if(typeof t=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return t==="x"?{x:e,y:0}:{x:0,y:e}}return typeof t=="number"?{x:t,y:e??t}:Array.isArray(t)?{x:t[0],y:t[1]}:"signedWidth"in t?{x:t.signedWidth,y:t.signedHeight}:"clientX"in t?{x:t.clientX,y:t.clientY}:"width"in t?{x:t.width,y:t.height}:{x:t.x,y:t.y}},pi=Object.freeze({x:0,y:0}),Yr=a.z.union([a.z.number(),a.z.string()]);a.z.object({top:Yr,left:Yr,width:Yr,height:Yr});a.z.object({left:a.z.number(),top:a.z.number(),right:a.z.number(),bottom:a.z.number()});a.z.object({one:pr,two:pr,root:jo});const Xs=(t,e,r=0,n=0,s)=>{const i={one:{...pi},two:{...pi},root:s??Wd};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return i.one={x:t,y:e},i.two={x:i.one.x+r,y:i.one.y+n},i}return"one"in t&&"two"in t&&"root"in t?{...t,root:s??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(i.one={x:t.left,y:t.top},i.two={x:t.right,y:t.bottom},i):(i.one=t,e==null?i.two={x:i.one.x+r,y:i.one.y+n}:typeof e=="number"?i.two={x:i.one.x+e,y:i.one.y+r}:"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))},Ln=t=>{const e=Xs(t);return{lower:e.one.x,upper:e.two.x}},Dn=t=>{const e=Xs(t);return{lower:e.one.y,upper:e.two.y}},Jd=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t,Xd=a.z.object({signedWidth:a.z.number(),signedHeight:a.z.number()});a.z.union([So,Xd,pr,ko]);const Qd=(t,e,r)=>e!==void 0&&t<e?e:r!==void 0&&t>r?r:t;a.z.object({offset:fi,scale:fi});a.z.object({offset:a.z.number(),scale:a.z.number()});const ef=t=>(e,r,n,s)=>r==="dimension"?[e,n]:[e,s?n-t:n+t],tf=t=>(e,r,n,s)=>[e,s?n/t:n*t],rf=t=>(e,r,n)=>{if(e===null)return[t,n];const{lower:s,upper:i}=e,{lower:o,upper:c}=t,l=i-s,u=c-o;if(r==="dimension")return[t,n*(u/l)];const h=(n-s)*(u/l)+o;return[t,h]},nf=t=>(e,r,n)=>[t,n],sf=()=>(t,e,r)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,r];const{lower:n,upper:s}=t;return[t,s-(r-n)]},af=t=>(e,r,n)=>{const{lower:s,upper:i}=t;return n=Qd(n,s,i),[e,n]};class rt{ops=[];currBounds=null;currType=null;reversed=!1;constructor(){this.ops=[]}static translate(e){return new rt().translate(e)}static magnify(e){return new rt().magnify(e)}static scale(e,r){return new rt().scale(e,r)}translate(e){const r=this.new(),n=ef(e);return n.type="translate",r.ops.push(n),r}magnify(e){const r=this.new(),n=tf(e);return n.type="magnify",r.ops.push(n),r}scale(e,r){const n=bt(e,r),s=this.new(),i=rf(n);return i.type="scale",s.ops.push(i),s}clamp(e,r){const n=bt(e,r),s=this.new(),i=af(n);return i.type="clamp",s.ops.push(i),s}reBound(e,r){const n=bt(e,r),s=this.new(),i=nf(n);return i.type="re-bound",s.ops.push(i),s}invert(){const e=sf();e.type="invert";const r=this.new();return r.ops.push(e),r}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new rt;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,r){return this.currBounds=null,this.ops.reduce(([n,s],i)=>i(n,e,s,this.reversed),[null,r])[1]}reverse(){const e=this.new();e.ops.reverse();const r=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||r.some(([o,c])=>s>=o&&s<=c))return;const i=e.ops.findIndex((o,c)=>o.type==="scale"&&c>s);i!==-1&&r.push([s,i])}),r.forEach(([n,s])=>{const i=e.ops.slice(n,s);i.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...i)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}static IDENTITY=new rt}class Ie{x;y;currRoot;constructor(e=new rt,r=new rt,n=null){this.x=e,this.y=r,this.currRoot=n}static translate(e,r){return new Ie().translate(e,r)}static translateX(e){return new Ie().translateX(e)}static translateY(e){return new Ie().translateY(e)}static clamp(e){return new Ie().clamp(e)}static magnify(e){return new Ie().magnify(e)}static scale(e){return new Ie().scale(e)}static reBound(e){return new Ie().reBound(e)}translate(e,r){const n=Kd(e,r),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const r=this.copy();return r.x=this.x.translate(e),r}translateY(e){const r=this.copy();return r.y=this.y.translate(e),r}magnify(e){const r=this.copy();return r.x=this.x.magnify(e.x),r.y=this.y.magnify(e.y),r}scale(e){const r=this.copy();if(Jd(e)){const n=this.currRoot;return r.currRoot=e.root,n!=null&&!Gd(n,e.root)&&(n.x!==e.root.x&&(r.x=r.x.invert()),n.y!==e.root.y&&(r.y=r.y.invert())),r.x=r.x.scale(Ln(e)),r.y=r.y.scale(Dn(e)),r}return r.x=r.x.scale(e.width),r.y=r.y.scale(e.height),r}reBound(e){const r=this.copy();return r.x=this.x.reBound(Ln(e)),r.y=this.y.reBound(Dn(e)),r}clamp(e){const r=this.copy();return r.x=this.x.clamp(Ln(e)),r.y=this.y.clamp(Dn(e)),r}copy(){const e=new Ie;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return Xs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}static IDENTITY=new Ie}const of=pr.extend({root:jo,units:a.object({x:a.enum(["px","decimal"]),y:a.enum(["px","decimal"])})});of.partial({root:!0,units:!0});const cf=a.z.enum(["static","dynamic"]),yi=365,Vr=30,lf=a.z.union([a.z.tuple([a.z.int()]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12)]),a.z.tuple([a.z.int(),a.z.int().min(1).max(12),a.z.int().min(1).max(31)])]),$o=(t,e)=>{const r=new R(e);if(![g.DAY,g.HOUR,g.MINUTE,g.SECOND,g.MILLISECOND,g.MICROSECOND,g.NANOSECOND].some(s=>s.equals(r)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=t.valueOf()%r.valueOf();return t instanceof R?new R(n):new g(n)};let R=class T extends Gt{constructor(e,r="UTC"){if(e==null)super(T.now().valueOf());else if(e instanceof Date)super(BigInt(e.getTime())*T.MILLISECOND.valueOf());else if(typeof e=="string")super(T.parseDateTimeString(e,r).valueOf());else if(Array.isArray(e))super(T.parseDate(e));else{let n=0n;e instanceof Number&&(e=e.valueOf()),r==="local"&&(n=T.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e===Ud?e=us:e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=T.MAX:e=T.MIN)),we(e)&&(e=e.value),super(BigInt(e.valueOf())+n)}}static parseDate([e=1970,r=1,n=1]){const s=new Date(e,r-1,n,0,0,0,0);return new T(BigInt(s.getTime())*T.MILLISECOND.valueOf()).truncate(T.DAY).valueOf()}valueOf(){return this.value}static parseTimeString(e,r="UTC"){const[n,s,i]=e.split(":");let o="00",c="00";i!=null&&([o,c]=i.split("."));let l=T.hours(parseInt(n??"00")).add(T.minutes(parseInt(s??"00"))).add(T.seconds(parseInt(o??"00"))).add(T.milliseconds(parseInt(c??"00")));return r==="local"&&(l=l.add(T.utcOffset)),l.valueOf()}static parseDateTimeString(e,r="UTC"){if(!e.includes("/")&&!e.includes("-"))return T.parseTimeString(e,r);if(e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,3})?$/)!=null){let s=e,i=0;if(e.includes(".")){const u=e.split(".");s=u[0];const h=u[1]||"0";i=parseInt(h.padEnd(3,"0").slice(0,3))}const o=r==="local"?new Date(s.replace("T"," ")):new Date(`${s}Z`),c=BigInt(o.getTime())*T.MILLISECOND.valueOf(),l=BigInt(i)*T.MILLISECOND.valueOf();return c+l}const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new T(BigInt(n.getTime())*T.MILLISECOND.valueOf(),r).valueOf()}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(T.utcOffset).date().toISOString()}timeString(e=!1,r="UTC"){const n=this.toISOString(r);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),r=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${r} ${n}`}static get utcOffset(){return new g(BigInt(new Date().getTimezoneOffset())*T.MINUTE.valueOf())}static since(e){return new T().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new T(e).valueOf()}span(e){return this.range(e).span}range(e){return new cr(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===0n}after(e){return this.valueOf()>new T(e).valueOf()}afterEq(e){return this.valueOf()>=new T(e).valueOf()}before(e){return this.valueOf()<new T(e).valueOf()}beforeEq(e){return this.valueOf()<=new T(e).valueOf()}add(e){return new T(wt(this.valueOf(),new g(e).valueOf()))}sub(e){return new T(xr(this.valueOf(),new g(e).valueOf()))}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(T.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(T.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get year(){return this.date().getUTCFullYear()}setYear(e){const r=this.date();return r.setUTCFullYear(e),new T(r)}get month(){return this.date().getUTCMonth()}setMonth(e){const r=this.date();return r.setUTCMonth(e),new T(r)}get day(){return this.date().getUTCDate()}setDay(e){const r=this.date();return r.setUTCDate(e),new T(r)}get hour(){return this.date().getUTCHours()}get localHour(){return this.date().getHours()}setLocalHour(e){const r=this.date();return r.setHours(e),new T(r)}setHour(e){const r=this.date();return r.setUTCHours(e),new T(r)}get minute(){return this.date().getUTCMinutes()}setMinute(e){const r=this.date();return r.setUTCMinutes(e),new T(r)}get second(){return this.date().getUTCSeconds()}setSecond(e){const r=this.date();return r.setUTCSeconds(e),new T(r)}get millisecond(){return this.date().getUTCMilliseconds()}setMillisecond(e){const r=this.date();return r.setUTCMilliseconds(e),new T(r)}toString(e="ISO",r="UTC"){switch(e){case"ISODate":return this.toISOString(r).slice(0,10);case"ISOTime":return this.toISOString(r).slice(11,23);case"time":return this.timeString(!1,r);case"preciseTime":return this.timeString(!0,r);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,r)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,r)}`;default:return this.toISOString(r)}}remainder(e){return $o(this,e)}get isToday(){return this.truncate(g.DAY).equals(T.now().truncate(g.DAY))}truncate(e){return this.sub(this.remainder(e))}formatBySpan(e){return e.greaterThanOrEqual(g.days(30))?"shortDate":e.greaterThanOrEqual(g.DAY)?"dateTime":e.greaterThanOrEqual(g.HOUR)?"time":e.greaterThanOrEqual(g.SECOND)?"preciseTime":"ISOTime"}static now(){return new T(new Date)}static max(...e){let r=T.MIN;for(const n of e){const s=new T(n);s.after(r)&&(r=s)}return r}static min(...e){let r=T.MAX;for(const n of e){const s=new T(n);s.before(r)&&(r=s)}return r}static nanoseconds(e,r="UTC"){return new T(e,r)}static NANOSECOND=T.nanoseconds(1);static microseconds(e,r="UTC"){return T.nanoseconds(e*1e3,r)}static MICROSECOND=T.microseconds(1);static milliseconds(e,r="UTC"){return T.microseconds(e*1e3,r)}static MILLISECOND=T.milliseconds(1);static seconds(e,r="UTC"){return T.milliseconds(e*1e3,r)}static SECOND=T.seconds(1);static minutes(e,r="UTC"){return T.seconds(e*60,r)}static MINUTE=T.minutes(1);static hours(e,r="UTC"){return T.minutes(e*60,r)}static HOUR=T.hours(1);static days(e,r="UTC"){return T.hours(e*24,r)}static DAY=T.days(1);static MAX=new T(us);static MIN=new T(0);static ZERO=new T(0);static z=a.z.union([a.z.instanceof(T),a.z.object({value:a.z.bigint()}).transform(e=>new T(e.value)),a.z.string().transform(e=>new T(BigInt(e))),a.z.number().transform(e=>new T(e)),a.z.bigint().transform(e=>new T(e)),a.z.date().transform(e=>new T(e)),a.z.custom(e=>e instanceof g).transform(e=>new T(e)),lf.transform(e=>new T(e))]);static sort(e,r){return Number(e.valueOf()-r.valueOf())}};class g extends Gt{constructor(e){typeof e=="number"&&(e=Math.trunc(e.valueOf())),we(e)&&(e=e.value),super(BigInt(e.valueOf()))}static fromSeconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.seconds(e):new g(e))}static fromMilliseconds(e){return e instanceof g?e:e instanceof Bn?e.period:e instanceof R?new g(e):(we(e)&&(e=e.value),["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e))}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return $o(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(e="full"){if(e==="semantic")return this.toSemanticString();const r=this.truncate(g.DAY),n=this.truncate(g.HOUR),s=this.truncate(g.MINUTE),i=this.truncate(g.SECOND),o=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),l=this.truncate(g.NANOSECOND),u=r,h=n.sub(r),f=s.sub(n),d=i.sub(s),z=o.sub(i),I=c.sub(o),j=l.sub(c);let b="";return u.isZero||(b+=`${u.days}d `),h.isZero||(b+=`${h.hours}h `),f.isZero||(b+=`${f.minutes}m `),d.isZero||(b+=`${d.seconds}s `),z.isZero||(b+=`${z.milliseconds}ms `),I.isZero||(b+=`${I.microseconds}µs `),j.isZero||(b+=`${j.nanoseconds}ns`),b.trim()}toSemanticString(){const e=this.valueOf()<0n?-this.valueOf():this.valueOf(),r=new g(e),n=this.valueOf()<0n;if(r.valueOf()===0n)return"0s";if(r.lessThan(g.SECOND))return"< 1s";const s=r.days,i=r.hours,o=r.minutes,c=r.seconds,l=Math.floor(s/yi),u=Math.floor(s/Vr),h=Math.floor(s/7),f=Math.floor(s),d=Math.floor(i),z=Math.floor(o),I=Math.floor(c),j=n?"-":"";if(l>=1){let b=`${l}y`;if(l<2){const v=Math.floor(s%yi/Vr);v>0&&(b+=` ${v}mo`)}return j+b}if(h>=1&&s<Vr&&s%7===0){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(u>=1){let b=`${u}mo`;if(u<3){const v=Math.floor(s%Vr);v>0&&(b+=` ${v}d`)}return j+b}if(h>=1){let b=`${h}w`;const v=Math.floor(s%7),S=Math.floor(i-h*7*24);return h<2&&(v>0?b+=` ${v}d`:S>0&&S<24&&(b+=` ${S}h`)),j+b}if(f>=1){let b=`${f}d`;const v=Math.floor(i-f*24);return f<2&&v>0&&(b+=` ${v}h`),j+b}if(d>=1){let b=`${d}h`;if(d<3){const v=Math.floor(o-d*60);v>0&&(b+=` ${v}m`)}return j+b}if(z>=1){let b=`${z}m`;if(z<5){const v=Math.floor(c-z*60);v>0&&(b+=` ${v}s`)}return j+b}return`${j}${I}s`}mult(e){return new g(je(this.valueOf(),e))}div(e){return new g(mn(this.valueOf(),e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===0n}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static NANOSECOND=g.nanoseconds(1);static microseconds(e=1){return g.nanoseconds(je(e,1e3))}static MICROSECOND=g.microseconds(1);static milliseconds(e=1){return g.microseconds(je(e,1e3))}static MILLISECOND=g.milliseconds(1);static seconds(e=1){return g.milliseconds(je(e,1e3))}static SECOND=g.seconds(1);static minutes(e=1){return g.seconds(je(e,60))}static MINUTE=g.minutes(1);static hours(e){return g.minutes(je(e,60))}static HOUR=g.hours(1);static days(e){return g.hours(je(e,24))}static DAY=g.days(1);static MAX=new g(us);static MIN=new g(0);static ZERO=new g(0);static z=a.z.union([a.z.object({value:a.z.bigint()}).transform(e=>new g(e.value)),a.z.string().transform(e=>new g(BigInt(e))),a.z.number().transform(e=>new g(e)),a.z.bigint().transform(e=>new g(e)),a.z.instanceof(g),a.z.instanceof(R).transform(e=>new g(e)),a.z.custom(e=>e instanceof Bn).transform(e=>new g(e))])}let Bn=class ye extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ye(e).valueOf()}get period(){return g.seconds(1/this.valueOf())}sampleCount(e){return new g(e).seconds*this.valueOf()}byteCount(e,r){return this.sampleCount(e)*new te(r).valueOf()}span(e){return g.seconds(e/this.valueOf())}byteSpan(e,r){return this.span(e.valueOf()/new te(r).valueOf())}add(e){return new ye(wt(this.valueOf(),new ye(e).valueOf()))}sub(e){return new ye(xr(this.valueOf(),new ye(e).valueOf()))}mult(e){return new ye(je(this.valueOf(),e))}div(e){return new ye(mn(this.valueOf(),e))}static hz(e){return new ye(e)}static khz(e){return ye.hz(e*1e3)}static z=a.z.union([a.z.number().transform(e=>new ye(e)),a.z.instanceof(ye)])},te=class se extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}length(e){return e.valueOf()/this.valueOf()}size(e){return new hs(e*this.valueOf())}add(e){return new se(wt(this.valueOf(),new se(e).valueOf()))}sub(e){return new se(xr(this.valueOf(),new se(e).valueOf()))}mult(e){return new se(je(this.valueOf(),e))}div(e){return new se(mn(this.valueOf(),e))}static UNKNOWN=new se(0);static BIT128=new se(16);static BIT64=new se(8);static BIT32=new se(4);static BIT16=new se(2);static BIT8=new se(1);static z=a.z.union([a.z.number().transform(e=>new se(e)),a.z.instanceof(se)])},cr=class Te{start;end;constructor(e,r){typeof e=="object"&&"start"in e?(this.start=new R(e.start),this.end=new R(e.end)):(this.start=new R(e),this.end=new R(r))}get span(){return new g(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.start.isZero&&this.end.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Te(this.end,this.start)}get numericBounds(){return{lower:Number(this.start.valueOf()),upper:Number(this.end.valueOf())}}equals(e,r=g.ZERO){if(r.isZero)return this.start.equals(e.start)&&this.end.equals(e.end);let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=r.valueOf()&&s<=r.valueOf()}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.toString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,r=g.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=R.max(n.start,e.start),i=R.min(n.end,e.end);return i.before(s)?!1:new g(i.sub(s)).greaterThanOrEqual(r)}contains(e){return e instanceof Te?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const r=new Te(this.start,this.end);return e.start.after(this.start)&&(r.start=e.start),e.start.after(this.end)&&(r.end=e.start),e.end.before(this.end)&&(r.end=e.end),e.end.before(this.start)&&(r.start=e.end),r}static max(...e){return new Te(R.min(...e.map(r=>r.start)),R.max(...e.map(r=>r.end)))}static MAX=new Te(R.MIN,R.MAX);static ZERO=new Te(R.ZERO,R.ZERO);static z=a.z.union([a.z.object({start:R.z,end:R.z}).transform(e=>new Te(e.start,e.end)),a.z.instanceof(Te)]);static sort(e,r){return R.sort(e.start,r.start)||R.sort(e.end,r.end)}static merge(...e){return Te.max(...e.map(r=>new Te(r).makeValid()))}},Y=class y extends Gt{constructor(e){if(we(e)&&(e=e.value),e instanceof y||typeof e=="string"||typeof e.valueOf()=="string")super(e.valueOf());else{const r=y.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(r==null)throw new Error(`unable to find data type for ${e.toString()}`);super(r.valueOf())}}get Array(){const e=y.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(r=>this.equals(r))}toString(e=!1){return e?y.SHORT_STRINGS.get(this.valueOf())??this.valueOf():this.valueOf()}get isVariable(){return this.equals(y.JSON)||this.equals(y.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(y.UUID)}get isInteger(){const e=this.toString();return e.startsWith("int")||e.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=y.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}get isUnsignedInteger(){return this.equals(y.UINT8)||this.equals(y.UINT16)||this.equals(y.UINT32)||this.equals(y.UINT64)}get isSignedInteger(){return this.equals(y.INT8)||this.equals(y.INT16)||this.equals(y.INT32)||this.equals(y.INT64)}canSafelyCastTo(e){return this.equals(e)?!0:!this.isNumeric||!e.isNumeric||this.isVariable||e.isVariable||this.isUnsignedInteger&&e.isSignedInteger?!1:this.isFloat?e.isFloat&&this.density.valueOf()<=e.density.valueOf():this.equals(y.INT32)&&e.equals(y.FLOAT64)||this.equals(y.INT8)&&e.equals(y.FLOAT32)?!0:this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf()&&this.isUnsignedInteger===e.isUnsignedInteger:!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}get usesBigInt(){return y.BIG_INT_TYPES.some(e=>e.equals(this))}static UNKNOWN=new y("unknown");static FLOAT64=new y("float64");static FLOAT32=new y("float32");static INT64=new y("int64");static INT32=new y("int32");static INT16=new y("int16");static INT8=new y("int8");static UINT64=new y("uint64");static UINT32=new y("uint32");static UINT16=new y("uint16");static UINT8=new y("uint8");static BOOLEAN=new y("boolean");static TIMESTAMP=new y("timestamp");static UUID=new y("uuid");static STRING=new y("string");static JSON=new y("json");static 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]]);static 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]]);static DENSITIES=new Map([[y.UINT8.toString(),te.BIT8],[y.UINT16.toString(),te.BIT16],[y.UINT32.toString(),te.BIT32],[y.UINT64.toString(),te.BIT64],[y.FLOAT32.toString(),te.BIT32],[y.FLOAT64.toString(),te.BIT64],[y.INT8.toString(),te.BIT8],[y.INT16.toString(),te.BIT16],[y.INT32.toString(),te.BIT32],[y.INT64.toString(),te.BIT64],[y.TIMESTAMP.toString(),te.BIT64],[y.STRING.toString(),te.UNKNOWN],[y.JSON.toString(),te.UNKNOWN],[y.UUID.toString(),te.BIT128]]);static 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];static SHORT_STRINGS=new Map([[y.UINT8.toString(),"u8"],[y.UINT16.toString(),"u16"],[y.UINT32.toString(),"u32"],[y.UINT64.toString(),"u64"],[y.INT8.toString(),"i8"],[y.INT16.toString(),"i16"],[y.INT32.toString(),"i32"],[y.INT64.toString(),"i64"],[y.FLOAT32.toString(),"f32"],[y.FLOAT64.toString(),"f64"],[y.BOOLEAN.toString(),"bool"],[y.TIMESTAMP.toString(),"ts"],[y.UUID.toString(),"uuid"],[y.STRING.toString(),"str"],[y.JSON.toString(),"json"]]);static BIG_INT_TYPES=[y.INT64,y.UINT64,y.TIMESTAMP];static z=a.z.union([a.z.string().transform(e=>new y(e)),a.z.instanceof(y)])},hs=class $ extends Gt{constructor(e){we(e)&&(e=e.value),super(e.valueOf())}largerThan(e){return we(e)&&(e=e.value),this.valueOf()>e.valueOf()}smallerThan(e){return we(e)&&(e=e.value),this.valueOf()<e.valueOf()}add(e){return we(e)&&(e=e.value),new $(wt(this.valueOf(),e.valueOf()))}sub(e){return we(e)&&(e=e.value),new $(xr(this.valueOf(),e.valueOf()))}mult(e){return new $(je(this.valueOf(),e))}div(e){return new $(mn(this.valueOf(),e))}truncate(e){return new $(Math.trunc(this.valueOf()/new $(e).valueOf())*new $(e).valueOf())}remainder(e){return $.bytes(this.valueOf()%new $(e).valueOf())}get gigabytes(){return this.valueOf()/$.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/$.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/$.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/$.TERABYTE.valueOf()}toString(){const e=this.truncate($.TERABYTE),r=this.truncate($.GIGABYTE),n=this.truncate($.MEGABYTE),s=this.truncate($.KILOBYTE),i=this.truncate($.BYTE),o=e,c=r.sub(e),l=n.sub(r),u=s.sub(n),h=i.sub(s);let f="";return o.isZero||(f+=`${o.terabytes}TB `),c.isZero||(f+=`${c.gigabytes}GB `),l.isZero||(f+=`${l.megabytes}MB `),u.isZero||(f+=`${u.kilobytes}KB `),(!h.isZero||f==="")&&(f+=`${h.valueOf()}B`),f.trim()}static bytes(e=1){return new $(e)}static BYTE=new $(1);static kilobytes(e=1){return $.bytes(new $(e).valueOf()*1e3)}static KILOBYTE=$.kilobytes(1);static megabytes(e=1){return $.kilobytes(new $(e).valueOf()*1e3)}static MEGABYTE=$.megabytes(1);static gigabytes(e=1){return $.megabytes(new $(e).valueOf()*1e3)}static GIGABYTE=$.gigabytes(1);static terabytes(e){return $.gigabytes(new $(e).valueOf()*1e3)}static TERABYTE=$.terabytes(1);static ZERO=new $(0);static z=a.z.union([a.z.number().transform(e=>new $(e)),a.z.instanceof($)]);get isZero(){return this.valueOf()===0}};a.z.object({start:a.z.number(),end:a.z.number()});a.z.union([a.z.instanceof(Uint8Array),a.z.instanceof(Uint16Array),a.z.instanceof(Uint32Array),a.z.instanceof(BigUint64Array),a.z.instanceof(Float32Array),a.z.instanceof(Float64Array),a.z.instanceof(Int8Array),a.z.instanceof(Int16Array),a.z.instanceof(Int32Array),a.z.instanceof(BigInt64Array)]);const Mo=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof R||t instanceof g||t instanceof Date},uf=(t,e,r,n=0)=>t.usesBigInt&&!e.usesBigInt?Number(r)-Number(n):!t.usesBigInt&&e.usesBigInt?BigInt(r.valueOf())-BigInt(n.valueOf()):xr(r,n),hf=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function df(t){return typeof t=="string"&&hf.test(t)}const Q=[];for(let t=0;t<256;++t)Q.push((t+256).toString(16).slice(1));function ff(t,e=0){return(Q[t[e+0]]+Q[t[e+1]]+Q[t[e+2]]+Q[t[e+3]]+"-"+Q[t[e+4]]+Q[t[e+5]]+"-"+Q[t[e+6]]+Q[t[e+7]]+"-"+Q[t[e+8]]+Q[t[e+9]]+"-"+Q[t[e+10]]+Q[t[e+11]]+Q[t[e+12]]+Q[t[e+13]]+Q[t[e+14]]+Q[t[e+15]]).toLowerCase()}function pf(t,e=0){const r=ff(t,e);if(!df(r))throw TypeError("Stringified UUID is invalid");return r}typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const _o=(t,e)=>pf(t,e),Ge=-1,yf=a.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),mf=a.z.union([a.z.null(),a.z.undefined()]).transform(()=>new Uint8Array().buffer),ds=10,gf=(t,e)=>{if(t==="number"&&!e.isNumeric)throw new Error(`cannot convert series of type ${e.toString()} to number`);if(t==="bigint"&&!e.usesBigInt)throw new Error(`cannot convert series of type ${e.toString()} to bigint`)},Zo="sy_x_telem_series";let Uo=class et{key;discriminator=Zo;dataType;sampleOffset;gl;_data;timeRange=cr.ZERO;alignment=0n;alignmentMultiple=1n;cachedMin;cachedMax;writePos=Ge;_refCount=0;cachedLength;_cachedIndexes;static crudeZ=a.z.object({timeRange:cr.z.optional(),dataType:Y.z,alignment:a.z.coerce.bigint().optional(),data:a.z.union([yf,mf,a.z.instanceof(ArrayBuffer),a.z.instanceof(Uint8Array)]),glBufferUsage:cf.default("static").optional()});static z=et.crudeZ.transform(e=>new et(e));constructor(e){wf(e)&&(e={data:e}),e.data??=[];const{dataType:r,timeRange:n,sampleOffset:s=0,glBufferUsage:i="static",alignment:o=0n,alignmentMultiple:c=1n,key:l=Md(),data:u}=e;if(bf(u)){const d=u;this.key=d.key,this.dataType=d.dataType,this.sampleOffset=d.sampleOffset,this.gl=d.gl,this._data=d._data,this.timeRange=d.timeRange,this.alignment=d.alignment,this.alignmentMultiple=d.alignmentMultiple,this.cachedMin=d.cachedMin,this.cachedMax=d.cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this.cachedLength=d.cachedLength;return}const h=Mo(u),f=Array.isArray(u);if(r!=null)this.dataType=new Y(r);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(f||h){let d=u;if(!h){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.");d=u[0]}if(typeof d=="string")this.dataType=Y.STRING;else if(typeof d=="number")this.dataType=Y.FLOAT64;else if(typeof d=="bigint")this.dataType=Y.INT64;else if(typeof d=="boolean")this.dataType=Y.BOOLEAN;else if(d instanceof R||d instanceof Date||d instanceof R)this.dataType=Y.TIMESTAMP;else if(typeof d=="object")this.dataType=Y.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new Y(u)}if(!f&&!h)this._data=u;else if(f&&u.length===0)this._data=new this.dataType.Array([]).buffer;else{let d=h?[u]:u;const z=d[0];(z instanceof R||z instanceof Date||z instanceof g)&&(d=d.map(I=>new R(I).valueOf())),this.dataType.equals(Y.STRING)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
2
2
|
`)}
|
|
3
3
|
`).buffer):this.dataType.equals(Y.JSON)?(this.cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(I=>ls.encodeString(I)).join(`
|
|
4
4
|
`)}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
${e}
|
|
19
19
|
|
|
20
20
|
Please report this to the Synnax team.
|
|
21
|
-
`)}}class ot extends Ue.sub("query"){}class Tt extends ot.sub("not_found"){}class cn extends ot.sub("multiple_results"){}class Ii extends Ue.sub("route"){path;constructor(e,r){super(e),this.path=r}}class $s extends Ue.sub("control"){}class Ci extends $s.sub("unauthorized"){}class tw extends Ue.sub("disconnected"){constructor(e="Operation failed because no Core is connected."){super(e)}}class FA extends Ue.sub("contiguity"){}const rw=t=>t.type.startsWith(Ue.TYPE)?t.type.startsWith(W.TYPE)?t.type===wr.TYPE?wr.decode(t):new W(t.data):t.type.startsWith(br.TYPE)?t.type.startsWith(Cs.TYPE)?new Cs(t.data):t.type.startsWith(js.TYPE)?new js(t.data):new br(t.data):t.type.startsWith(ie.TYPE)?new ie(t.data):t.type.startsWith(ot.TYPE)?t.type.startsWith(Tt.TYPE)?new Tt(t.data):t.type.startsWith(cn.TYPE)?new cn(t.data):new ot(t.data):t.type.startsWith($s.TYPE)?t.type.startsWith(Ci.TYPE)?new Ci(t.data):new $s(t.data):t.type.startsWith(Ii.TYPE)?new Ii(t.data,t.data):new ie(t.data):null,nw=()=>{throw new He.NotImplemented};He.register({encode:nw,decode:rw});const sw=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof it?[r,new it({message:`Cannot reach Core at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},wn=a.z.enum(["label","log","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","role","table","arc","schematic_symbol","status","view"]),hl=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:wn.parse(e),key:r??""}}),F=a.z.object({type:wn,key:a.z.string()}).or(hl),aw={type:"builtin",key:"root"},K=t=>{const e=r=>({type:t,key:Rp.isZero(r)?"":r.toString()});return(r=>Array.isArray(r)?r.map(e):e(r))},Ze=(t=>(typeof t=="string"&&(t=hl.parse(t)),Array.isArray(t)?t.map(e=>Ze(e)):`${t.type}:${t.key}`)),iw=(t,e)=>t.type===e.type&&t.key===e.key,dl=t=>{const e=O.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>F.parse(r))},fl=a.z.object({id:F,name:a.z.string(),data:ze.unknownZ.optional().nullable()}).transform(t=>({key:Ze(t.id),...t})),ow=t=>t==="to"?"from":"to",cw=a.z.object({from:F,type:a.z.string(),to:F}).or(a.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:F.parse(e),type:r,to:F.parse(n)}})),lw=t=>`${Ze(t.from)}->${t.type}->${Ze(t.to)}`,uw="parent",hw=(t,e)=>!(e.type!=null&&e.type!==t.type||e.from?.type!=null&&e.from.type!==t.from.type||e.to?.type!=null&&e.to.type!==t.to.type||e.from?.key!=null&&e.from.key!==t.from.key||e.to?.key!=null&&e.to.key!==t.to.key),Zr=a.z.uuid(),pl=a.z.string(),bn=a.z.object({key:Zr,name:pl}),dw=K("group"),fw="sy_group_set",pw="sy_group_delete",yw=a.object({group:bn}),mw=a.object({parent:F,key:Zr.optional(),name:a.string()}),gw=a.object({key:Zr,name:a.string()}),ww=a.object({keys:a.array(Zr)});let yl=class{client;constructor(t){this.client=t}async create(t){return(await w(this.client,"/ontology/create-group",t,mw,yw)).group}async rename(t,e){await w(this.client,"/ontology/rename-group",{key:t,name:e},gw,a.object({}))}async delete(t){await w(this.client,"/ontology/delete-group",{keys:O.toArray(t)},ww,a.object({}))}};const bw=Object.freeze(Object.defineProperty({__proto__:null,Client:yl,DELETE_CHANNEL_NAME:pw,SET_CHANNEL_NAME:fw,groupZ:bn,keyZ:Zr,nameZ:pl,ontologyID:dw},Symbol.toStringTag,{value:"Module"})),ji=a.z.object({id:F,children:F.array()}),vw=a.z.object({from:F,to:F,children:F.array()}),Wn=a.z.object({});let zw=class{client;constructor(t){this.client=t}async addChildren(t,...e){await w(this.client,"/ontology/add-children",{id:t,children:e},ji,Wn)}async removeChildren(t,...e){await w(this.client,"/ontology/remove-children",{id:t,children:e},ji,Wn)}async moveChildren(t,e,...r){await w(this.client,"/ontology/move-children",{from:t,to:e,children:r},vw,Wn)}};const Ow=a.z.object({ids:F.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),types:wn.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional()}),Tw=a.z.object({resources:fl.array()});let ml=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new zw(t),this.groups=new yl(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=dl(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new ot(`No resource found with ID ${Is.naturalLanguageJoin(r.map(s=>Ze(s)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:O.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:O.toArray(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async execRetrieve(t){const{resources:e}=await w(this.client,"/ontology/retrieve",t,Ow,Tw);return e}};const kw="sy_ontology_resource_set",Sw="sy_ontology_resource_delete",Nw="sy_ontology_relationship_set",Ew="sy_ontology_relationship_delete",Aw=Object.freeze(Object.defineProperty({__proto__:null,Client:ml,PARENT_OF_RELATIONSHIP_TYPE:uw,RELATIONSHIP_DELETE_CHANNEL_NAME:Ew,RELATIONSHIP_SET_CHANNEL_NAME:Nw,RESOURCE_DELETE_CHANNEL_NAME:Sw,RESOURCE_SET_CHANNEL_NAME:kw,ROOT_ID:aw,createIDFactory:K,idToString:Ze,idZ:F,idsEqual:iw,matchRelationship:hw,oppositeRelationshipDirection:ow,parseIDs:dl,relationshipToString:lw,relationshipZ:cw,resourceTypeZ:wn,resourceZ:fl},Symbol.toStringTag,{value:"Module"})),Jt=a.z.uuid(),Na=a.z.object({key:Jt,name:a.z.string(),objects:O.nullableZ(F),actions:O.nullableZ(Sa),internal:a.z.boolean()}),Ea=a.z.object({key:Jt.optional(),name:a.z.string(),objects:_e.toArray(F),actions:_e.toArray(Sa)}),gl=K("policy"),xw=gl(""),Iw="sy_policy_set",Cw="sy_policy_delete",jw=a.z.object({keys:Jt.array().optional(),subjects:F.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),$w=a.z.object({key:Jt}).transform(({key:t})=>({keys:[t]})),Mw=a.z.union([a.z.object({for:F}).transform(({for:t})=>({subjects:[t]})),a.z.object({for:F.array()}).transform(({for:t})=>({subjects:t})),jw]),_w=a.z.union([$w,Mw]),Zw=a.z.object({policies:O.nullableZ(Na)}),Uw=Ea.transform(t=>({policies:[t]})),wl=Ea.array().transform(t=>({policies:t})),bl=a.z.union([Uw,wl]),Pw=a.z.object({policies:Na.array()}),Rw=a.z.object({keys:Jt.array()}),Lw=a.z.object({});let vl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/policy/create",t,bl,Pw);return e?r.policies:r.policies[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/policy/retrieve",t,_w,Zw);return e?r.policies[0]:r.policies}async delete(t){await w(this.client,"/access/policy/delete",{keys:O.toArray(t)},Rw,Lw)}};const Dw=Object.freeze(Object.defineProperty({__proto__:null,Client:vl,DELETE_CHANNEL_NAME:Cw,SET_CHANNEL_NAME:Iw,TYPE_ONTOLOGY_ID:xw,createArgsZ:bl,keyZ:Jt,multipleCreateArgsZ:wl,newZ:Ea,ontologyID:gl,policyZ:Na},Symbol.toStringTag,{value:"Module"})),ct=a.z.uuid(),vn=a.z.object({key:ct,name:a.z.string(),description:a.z.string().optional(),internal:a.z.boolean().optional()}),Aa=vn.partial({key:!0}),zl=K("role"),Bw=zl(""),Pe=a.z.uuid(),Ur=a.z.object({key:Pe,username:a.z.string().min(1,"Username is required"),firstName:a.z.string().default(""),lastName:a.z.string().default(""),rootUser:a.z.boolean().default(!1)}),Ol=Ur.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:a.z.string().min(1)}),Fw=a.z.object({keys:Pe.array().optional(),usernames:a.z.string().array().optional()}),qw=a.z.object({key:Pe}).transform(({key:t})=>({keys:[t]})),Yw=a.z.object({username:a.z.string()}).transform(({username:t})=>({usernames:[t]})),Vw=a.z.object({usernames:a.z.string().array()}).transform(({usernames:t})=>({usernames:t})),Hw=a.z.union([qw,Yw,Vw,Fw]),Ww=a.z.object({users:O.nullableZ(Ur)}),Gw=a.z.object({users:Ol.array()}),Kw=a.z.object({users:Ur.array()}),Jw=a.z.object({key:Pe,username:a.z.string().min(1)}),Xw=a.z.object({}),Qw=a.z.object({key:Pe,firstName:a.z.string().optional(),lastName:a.z.string().optional()}),eb=a.z.object({}),tb=a.z.object({keys:Pe.array()}),rb=a.z.object({}),nb="sy_user_set",sb="sy_user_delete";let Tl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/user/create",{users:O.toArray(t)},Gw,Kw);return e?r.users:r.users[0]}async changeUsername(t,e){await w(this.client,"/user/change-username",{key:t,username:e},Jw,Xw)}async retrieve(t){const e="key"in t||"username"in t,r=await w(this.client,"/user/retrieve",t,Hw,Ww);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Tt(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new cn(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await w(this.client,"/user/rename",{key:t,firstName:e,lastName:r},Qw,eb)}async delete(t){await w(this.client,"/user/delete",{keys:O.toArray(t)},tb,rb)}};const kl=K("user"),ab=kl(""),ib=Object.freeze(Object.defineProperty({__proto__:null,Client:Tl,DELETE_CHANNEL_NAME:sb,SET_CHANNEL_NAME:nb,TYPE_ONTOLOGY_ID:ab,keyZ:Pe,newZ:Ol,ontologyID:kl,userZ:Ur},Symbol.toStringTag,{value:"Module"})),ob=a.z.object({keys:ct.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),cb=a.z.object({key:ct}).transform(({key:t})=>({keys:[t]})),lb=Aa.transform(t=>({roles:[t]})),Sl=Aa.array().transform(t=>({roles:t})),Nl=a.z.union([lb,Sl]),ub=a.z.object({roles:vn.array()}),hb=a.z.object({roles:O.nullableZ(vn)}),El=a.z.union([cb,ob]),db=a.z.object({}),fb=ct.transform(t=>({keys:[t]})).or(ct.array().transform(t=>({keys:t}))),pb=a.z.object({user:Pe,role:ct}),yb=a.z.object({}),mb=a.z.object({user:Pe,role:ct}),gb=a.z.object({}),wb="sy_role_set",bb="sy_role_delete";let Al=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/role/create",t,Nl,ub);return e?r.roles:r.roles[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/role/retrieve",t,El,hb);return e?r.roles[0]:r.roles}async delete(t){await w(this.client,"/access/role/delete",t,fb,db)}async assign(t){await w(this.client,"/access/role/assign",t,pb,yb)}async unassign(t){await w(this.client,"/access/role/unassign",t,mb,gb)}};const vb=Object.freeze(Object.defineProperty({__proto__:null,Client:Al,DELETE_CHANNEL_NAME:bb,SET_CHANNEL_NAME:wb,TYPE_ONTOLOGY_ID:Bw,createArgsZ:Nl,keyZ:ct,multipleCreateArgsZ:Sl,newZ:Aa,ontologyID:zl,retrieveArgsZ:El,roleZ:vn},Symbol.toStringTag,{value:"Module"}));let xl=class{policies;roles;constructor(t){this.policies=new vl(t),this.roles=new Al(t)}};const zb=(t,e)=>{const r=O.toArray(t.objects),{action:n}=t;for(const s of r){let i=!1;for(const o of e)if(o.actions.includes(n)){for(const c of o.objects)if(c.key===""){if(c.type===s.type){i=!0;break}}else if(c.type===s.type&&c.key===s.key){i=!0;break}if(i)break}if(!i)return!1}return!0},Ob=Object.freeze(Object.defineProperty({__proto__:null,Client:xl,actionZ:Sa,allowRequest:zb,policy:Dw,role:vb},Symbol.toStringTag,{value:"Module"}));function p(t,e,r){function n(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(t))return;c._zod.traits.add(t),e(c,l);const u=o.prototype,h=Object.keys(u);for(let f=0;f<h.length;f++){const d=h[f];d in c||(c[d]=u[d].bind(c))}}const s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(c){var l;const u=r?.Parent?new i:this;n(u,c),(l=u._zod).deferred??(l.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class Dt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Il extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Cl={};function kt(t){return Cl}function Tb(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,n])=>e.indexOf(+r)===-1).map(([r,n])=>n)}function Ms(t,e){return typeof e=="bigint"?e.toString():e}function xa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ia(t){return t==null}function Ca(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function kb(t,e){const r=(t.toString().split(".")[1]||"").length,n=e.toString();let s=(n.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(s=Number.parseInt(l[1]))}const i=r>s?r:s,o=Number.parseInt(t.toFixed(i).replace(".","")),c=Number.parseInt(e.toFixed(i).replace(".",""));return o%c/10**i}const $i=Symbol("evaluating");function L(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==$i)return n===void 0&&(n=$i,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function xt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function It(...t){const e={};for(const r of t){const n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function Mi(t){return JSON.stringify(t)}function Sb(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const jl="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Nb=xa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function vr(t){if(ln(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const r=e.prototype;return!(ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function $l(t){return vr(t)?{...t}:Array.isArray(t)?[...t]:t}const Eb=new Set(["string","number","symbol"]);function Yt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function A(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ab(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const xb={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ib(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(s[i]=r.shape[i])}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function Cb(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete s[i]}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function jb(t,e){if(!vr(e))throw new Error("Invalid input to extend: expected a plain object");const r=t._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function $b(t,e){if(!vr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return xt(this,"shape",n),n},checks:t._zod.def.checks};return ut(t,r)}function Mb(t,e){const r=It(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e._zod.def.shape};return xt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return ut(t,r)}function _b(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=t?new t({type:"optional",innerType:s[o]}):s[o])}else for(const o in s)i[o]=t?new t({type:"optional",innerType:s[o]}):s[o];return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Zb(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Ut(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Ml(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Xr(t){return typeof t=="string"?t:t?.message}function St(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Xr(t.inst?._zod.def?.error?.(t))??Xr(e?.error?.(t))??Xr(r.customError?.(t))??Xr(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function ja(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function zr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const _l=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Ms,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Zl=p("$ZodError",_l),Ul=p("$ZodError",_l,{Parent:Error});function Ub(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function Pb(t,e=r=>r.message){const r={_errors:[]},n=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>n({issues:o}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(e(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(t),r}const $a=t=>(e,r,n,s)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Dt;if(o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},Ma=t=>async(e,r,n,s)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},zn=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Dt;return i.issues.length?{success:!1,error:new(t??Zl)(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Rb=zn(Ul),On=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Lb=On(Ul),Db=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $a(t)(e,r,s)},Bb=t=>(e,r,n)=>$a(t)(e,r,n),Fb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ma(t)(e,r,s)},qb=t=>async(e,r,n)=>Ma(t)(e,r,n),Yb=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return zn(t)(e,r,s)},Vb=t=>(e,r,n)=>zn(t)(e,r,n),Hb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return On(t)(e,r,s)},Wb=t=>async(e,r,n)=>On(t)(e,r,n),Gb=/^[cC][^\s-]{8,}$/,Kb=/^[0-9a-z]+$/,Jb=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xb=/^[0-9a-vA-V]{20}$/,Qb=/^[A-Za-z0-9]{27}$/,ev=/^[a-zA-Z0-9_-]{21}$/,tv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rv=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_i=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,sv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function av(){return new RegExp(sv,"u")}const iv=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ov=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cv=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,lv=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pl=/^[A-Za-z0-9_-]*$/,hv=/^\+(?:[0-9]){6,14}[0-9]$/,Rl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",dv=new RegExp(`^${Rl}$`);function Ll(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fv(t){return new RegExp(`^${Ll(t)}$`)}function pv(t){const e=Ll({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Rl}T(?:${n})$`)}const yv=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},mv=/^-?\d+$/,gv=/^-?\d+(?:\.\d+)?/,wv=/^(?:true|false)$/i,bv=/^[^A-Z]*$/,vv=/^[^a-z]*$/,oe=p("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Dl={number:"number",bigint:"bigint",object:"date"},Bl=p("$ZodCheckLessThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Fl=p("$ZodCheckGreaterThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),zv=p("$ZodCheckMultipleOf",(t,e)=>{oe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):kb(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Ov=p("$ZodCheckNumberFormat",(t,e)=>{oe.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,i]=xb[e.format];t._zod.onattach.push(o=>{const c=o._zod.bag;c.format=e.format,c.minimum=s,c.maximum=i,r&&(c.pattern=mv)}),t._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}c<s&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),c>i&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:t})}}),Tv=p("$ZodCheckMaxLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=ja(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),kv=p("$ZodCheckMinLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=ja(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Sv=p("$ZodCheckLengthEquals",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,i=s.length;if(i===e.length)return;const o=ja(s),c=i>e.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Tn=p("$ZodCheckStringFormat",(t,e)=>{var r,n;oe.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Nv=p("$ZodCheckRegex",(t,e)=>{Tn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Ev=p("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=bv),Tn.init(t,e)}),Av=p("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=vv),Tn.init(t,e)}),xv=p("$ZodCheckIncludes",(t,e)=>{oe.init(t,e);const r=Yt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),Iv=p("$ZodCheckStartsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`^${Yt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Cv=p("$ZodCheckEndsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`.*${Yt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),jv=p("$ZodCheckOverwrite",(t,e)=>{oe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class $v{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
21
|
+
`)}}class ot extends Ue.sub("query"){}class Tt extends ot.sub("not_found"){}class cn extends ot.sub("multiple_results"){}class Ii extends Ue.sub("route"){path;constructor(e,r){super(e),this.path=r}}class $s extends Ue.sub("control"){}class Ci extends $s.sub("unauthorized"){}class tw extends Ue.sub("disconnected"){constructor(e="Operation failed because no Core is connected."){super(e)}}class FA extends Ue.sub("contiguity"){}const rw=t=>t.type.startsWith(Ue.TYPE)?t.type.startsWith(W.TYPE)?t.type===wr.TYPE?wr.decode(t):new W(t.data):t.type.startsWith(br.TYPE)?t.type.startsWith(Cs.TYPE)?new Cs(t.data):t.type.startsWith(js.TYPE)?new js(t.data):new br(t.data):t.type.startsWith(ie.TYPE)?new ie(t.data):t.type.startsWith(ot.TYPE)?t.type.startsWith(Tt.TYPE)?new Tt(t.data):t.type.startsWith(cn.TYPE)?new cn(t.data):new ot(t.data):t.type.startsWith($s.TYPE)?t.type.startsWith(Ci.TYPE)?new Ci(t.data):new $s(t.data):t.type.startsWith(Ii.TYPE)?new Ii(t.data,t.data):new ie(t.data):null,nw=()=>{throw new He.NotImplemented};He.register({encode:nw,decode:rw});const sw=async(t,e)=>{const[r,n]=await e(t);return n==null?[r,n]:n instanceof it?[r,new it({message:`Cannot reach Core at ${n.url.host}:${n.url.port}`,url:n.url})]:[r,n]},wn=a.z.enum(["label","log","builtin","cluster","channel","node","group","range","framer","range-alias","user","workspace","schematic","lineplot","rack","device","task","policy","role","table","arc","schematic_symbol","status","view"]),hl=a.z.string().transform(t=>{const[e,r]=t.split(":");return{type:wn.parse(e),key:r??""}}),F=a.z.object({type:wn,key:a.z.string()}).or(hl),aw={type:"builtin",key:"root"},K=t=>{const e=r=>({type:t,key:Rp.isZero(r)?"":r.toString()});return(r=>Array.isArray(r)?r.map(e):e(r))},Ze=(t=>(typeof t=="string"&&(t=hl.parse(t)),Array.isArray(t)?t.map(e=>Ze(e)):`${t.type}:${t.key}`)),iw=(t,e)=>t.type===e.type&&t.key===e.key,dl=t=>{const e=O.toArray(t);return e.length===0?[]:typeof e[0]=="object"&&"id"in e[0]?e.map(({id:r})=>r):e.map(r=>F.parse(r))},fl=a.z.object({id:F,name:a.z.string(),data:ze.unknownZ.optional().nullable()}).transform(t=>({key:Ze(t.id),...t})),ow=t=>t==="to"?"from":"to",cw=a.z.object({from:F,type:a.z.string(),to:F}).or(a.z.string().transform(t=>{const[e,r,n]=t.split("->");return{from:F.parse(e),type:r,to:F.parse(n)}})),lw=t=>`${Ze(t.from)}->${t.type}->${Ze(t.to)}`,uw="parent",hw=(t,e)=>!(e.type!=null&&e.type!==t.type||e.from?.type!=null&&e.from.type!==t.from.type||e.to?.type!=null&&e.to.type!==t.to.type||e.from?.key!=null&&e.from.key!==t.from.key||e.to?.key!=null&&e.to.key!==t.to.key),Zr=a.z.uuid(),pl=a.z.string(),bn=a.z.object({key:Zr,name:pl}),dw=K("group"),fw="sy_group_set",pw="sy_group_delete",yw=a.object({group:bn}),mw=a.object({parent:F,key:Zr.optional(),name:a.string()}),gw=a.object({key:Zr,name:a.string()}),ww=a.object({keys:a.array(Zr)});let yl=class{client;constructor(t){this.client=t}async create(t){return(await w(this.client,"/ontology/create-group",t,mw,yw)).group}async rename(t,e){await w(this.client,"/ontology/rename-group",{key:t,name:e},gw,a.object({}))}async delete(t){await w(this.client,"/ontology/delete-group",{keys:O.toArray(t)},ww,a.object({}))}};const bw=Object.freeze(Object.defineProperty({__proto__:null,Client:yl,DELETE_CHANNEL_NAME:pw,SET_CHANNEL_NAME:fw,groupZ:bn,keyZ:Zr,nameZ:pl,ontologyID:dw},Symbol.toStringTag,{value:"Module"})),ji=a.z.object({id:F,children:F.array()}),vw=a.z.object({from:F,to:F,children:F.array()}),Wn=a.z.object({});let zw=class{client;constructor(t){this.client=t}async addChildren(t,...e){await w(this.client,"/ontology/add-children",{id:t,children:e},ji,Wn)}async removeChildren(t,...e){await w(this.client,"/ontology/remove-children",{id:t,children:e},ji,Wn)}async moveChildren(t,e,...r){await w(this.client,"/ontology/move-children",{from:t,to:e,children:r},vw,Wn)}};const Ow=a.z.object({ids:F.array().optional(),children:a.z.boolean().optional(),parents:a.z.boolean().optional(),excludeFieldData:a.z.boolean().optional(),types:wn.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional()}),Tw=a.z.object({resources:fl.array()});let ml=class{type="ontology";groups;client;writer;framer;constructor(t,e){this.client=t,this.writer=new zw(t),this.groups=new yl(t),this.framer=e}async retrieve(t,e){if(!Array.isArray(t)&&typeof t=="object"&&!("key"in t))return this.execRetrieve(t);const r=dl(t),n=await this.execRetrieve({ids:r,...e});if(Array.isArray(t))return n;if(n.length===0)throw new ot(`No resource found with ID ${Is.naturalLanguageJoin(r.map(s=>Ze(s)))}`);return n[0]}async retrieveChildren(t,e){return await this.execRetrieve({ids:O.toArray(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:O.toArray(t),parents:!0,...e})}async addChildren(t,...e){return await this.writer.addChildren(t,...e)}async removeChildren(t,...e){return await this.writer.removeChildren(t,...e)}async moveChildren(t,e,...r){return await this.writer.moveChildren(t,e,...r)}async execRetrieve(t){const{resources:e}=await w(this.client,"/ontology/retrieve",t,Ow,Tw);return e}};const kw="sy_ontology_resource_set",Sw="sy_ontology_resource_delete",Nw="sy_ontology_relationship_set",Ew="sy_ontology_relationship_delete",Aw=Object.freeze(Object.defineProperty({__proto__:null,Client:ml,PARENT_OF_RELATIONSHIP_TYPE:uw,RELATIONSHIP_DELETE_CHANNEL_NAME:Ew,RELATIONSHIP_SET_CHANNEL_NAME:Nw,RESOURCE_DELETE_CHANNEL_NAME:Sw,RESOURCE_SET_CHANNEL_NAME:kw,ROOT_ID:aw,createIDFactory:K,idToString:Ze,idZ:F,idsEqual:iw,matchRelationship:hw,oppositeRelationshipDirection:ow,parseIDs:dl,relationshipToString:lw,relationshipZ:cw,resourceTypeZ:wn,resourceZ:fl},Symbol.toStringTag,{value:"Module"})),Jt=a.z.uuid(),Na=a.z.object({key:Jt,name:a.z.string(),objects:O.nullableZ(F),actions:O.nullableZ(Sa),internal:a.z.boolean()}),Ea=a.z.object({key:Jt.optional(),name:a.z.string(),objects:_e.toArray(F),actions:_e.toArray(Sa)}),gl=K("policy"),xw=gl(""),Iw="sy_policy_set",Cw="sy_policy_delete",jw=a.z.object({keys:Jt.array().optional(),subjects:F.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),$w=a.z.object({key:Jt}).transform(({key:t})=>({keys:[t]})),Mw=a.z.union([a.z.object({for:F}).transform(({for:t})=>({subjects:[t]})),a.z.object({for:F.array()}).transform(({for:t})=>({subjects:t})),jw]),_w=a.z.union([$w,Mw]),Zw=a.z.object({policies:O.nullableZ(Na)}),Uw=Ea.transform(t=>({policies:[t]})),wl=Ea.array().transform(t=>({policies:t})),bl=a.z.union([Uw,wl]),Pw=a.z.object({policies:Na.array()}),Rw=a.z.object({keys:Jt.array()}),Lw=a.z.object({});let vl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/policy/create",t,bl,Pw);return e?r.policies:r.policies[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/policy/retrieve",t,_w,Zw);return e?r.policies[0]:r.policies}async delete(t){await w(this.client,"/access/policy/delete",{keys:O.toArray(t)},Rw,Lw)}};const Dw=Object.freeze(Object.defineProperty({__proto__:null,Client:vl,DELETE_CHANNEL_NAME:Cw,SET_CHANNEL_NAME:Iw,TYPE_ONTOLOGY_ID:xw,createArgsZ:bl,keyZ:Jt,multipleCreateArgsZ:wl,newZ:Ea,ontologyID:gl,policyZ:Na},Symbol.toStringTag,{value:"Module"})),ct=a.z.uuid(),vn=a.z.object({key:ct,name:a.z.string(),description:a.z.string().optional(),internal:a.z.boolean().optional()}),Aa=vn.partial({key:!0}),zl=K("role"),Bw=zl(""),Pe=a.z.uuid(),Ur=a.z.object({key:Pe,username:a.z.string().min(1,"Username is required"),firstName:a.z.string().default(""),lastName:a.z.string().default(""),rootUser:a.z.boolean().default(!1)}),Ol=Ur.omit({rootUser:!0}).partial({key:!0,firstName:!0,lastName:!0}).extend({password:a.z.string().min(1)}),Fw=a.z.object({keys:Pe.array().optional(),usernames:a.z.string().array().optional()}),qw=a.z.object({key:Pe}).transform(({key:t})=>({keys:[t]})),Yw=a.z.object({username:a.z.string()}).transform(({username:t})=>({usernames:[t]})),Vw=a.z.object({usernames:a.z.string().array()}).transform(({usernames:t})=>({usernames:t})),Hw=a.z.union([qw,Yw,Vw,Fw]),Ww=a.z.object({users:O.nullableZ(Ur)}),Gw=a.z.object({users:Ol.array()}),Kw=a.z.object({users:Ur.array()}),Jw=a.z.object({key:Pe,username:a.z.string().min(1)}),Xw=a.z.object({}),Qw=a.z.object({key:Pe,firstName:a.z.string().optional(),lastName:a.z.string().optional()}),eb=a.z.object({}),tb=a.z.object({keys:Pe.array()}),rb=a.z.object({}),nb="sy_user_set",sb="sy_user_delete";let Tl=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/user/create",{users:O.toArray(t)},Gw,Kw);return e?r.users:r.users[0]}async changeUsername(t,e){await w(this.client,"/user/change-username",{key:t,username:e},Jw,Xw)}async retrieve(t){const e="key"in t||"username"in t,r=await w(this.client,"/user/retrieve",t,Hw,Ww);if(!e)return r.users;if(r.users.length===0){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new Tt(`No user with ${n} found`)}if(r.users.length>1){const n="key"in t?`key ${t.key}`:`username ${t.username}`;throw new cn(`Multiple users found with ${n}`)}return r.users[0]}async rename(t,e,r){await w(this.client,"/user/rename",{key:t,firstName:e,lastName:r},Qw,eb)}async delete(t){await w(this.client,"/user/delete",{keys:O.toArray(t)},tb,rb)}};const kl=K("user"),ab=kl(""),ib=Object.freeze(Object.defineProperty({__proto__:null,Client:Tl,DELETE_CHANNEL_NAME:sb,SET_CHANNEL_NAME:nb,TYPE_ONTOLOGY_ID:ab,keyZ:Pe,newZ:Ol,ontologyID:kl,userZ:Ur},Symbol.toStringTag,{value:"Module"})),ob=a.z.object({keys:ct.array().optional(),limit:a.z.number().optional(),offset:a.z.number().optional(),internal:a.z.boolean().optional()}),cb=a.z.object({key:ct}).transform(({key:t})=>({keys:[t]})),lb=Aa.transform(t=>({roles:[t]})),Sl=Aa.array().transform(t=>({roles:t})),Nl=a.z.union([lb,Sl]),ub=a.z.object({roles:vn.array()}),hb=a.z.object({roles:O.nullableZ(vn)}),El=a.z.union([cb,ob]),db=a.z.object({}),fb=ct.transform(t=>({keys:[t]})).or(ct.array().transform(t=>({keys:t}))),pb=a.z.object({user:Pe,role:ct}),yb=a.z.object({}),mb=a.z.object({user:Pe,role:ct}),gb=a.z.object({}),wb="sy_role_set",bb="sy_role_delete";let Al=class{client;constructor(t){this.client=t}async create(t){const e=Array.isArray(t),r=await w(this.client,"/access/role/create",t,Nl,ub);return e?r.roles:r.roles[0]}async retrieve(t){const e="key"in t,r=await w(this.client,"/access/role/retrieve",t,El,hb);return e?r.roles[0]:r.roles}async delete(t){await w(this.client,"/access/role/delete",t,fb,db)}async assign(t){await w(this.client,"/access/role/assign",t,pb,yb)}async unassign(t){await w(this.client,"/access/role/unassign",t,mb,gb)}};const vb=Object.freeze(Object.defineProperty({__proto__:null,Client:Al,DELETE_CHANNEL_NAME:bb,SET_CHANNEL_NAME:wb,TYPE_ONTOLOGY_ID:Bw,createArgsZ:Nl,keyZ:ct,multipleCreateArgsZ:Sl,newZ:Aa,ontologyID:zl,retrieveArgsZ:El,roleZ:vn},Symbol.toStringTag,{value:"Module"}));let xl=class{policies;roles;constructor(t){this.policies=new vl(t),this.roles=new Al(t)}};const zb=(t,e)=>{const r=O.toArray(t.objects),{action:n}=t;for(const s of r){let i=!1;for(const o of e)if(o.actions.includes(n)){for(const c of o.objects)if(c.key===""){if(c.type===s.type){i=!0;break}}else if(c.type===s.type&&c.key===s.key){i=!0;break}if(i)break}if(!i)return!1}return!0},Ob=Object.freeze(Object.defineProperty({__proto__:null,Client:xl,actionZ:Sa,allowRequest:zb,policy:Dw,role:vb},Symbol.toStringTag,{value:"Module"}));function p(t,e,r){function n(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),c._zod.traits.has(t))return;c._zod.traits.add(t),e(c,l);const u=o.prototype,h=Object.keys(u);for(let f=0;f<h.length;f++){const d=h[f];d in c||(c[d]=u[d].bind(c))}}const s=r?.Parent??Object;class i extends s{}Object.defineProperty(i,"name",{value:t});function o(c){var l;const u=r?.Parent?new i:this;n(u,c),(l=u._zod).deferred??(l.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class Dt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Il extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Cl={};function kt(t){return Cl}function Tb(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,n])=>e.indexOf(+r)===-1).map(([r,n])=>n)}function Ms(t,e){return typeof e=="bigint"?e.toString():e}function xa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Ia(t){return t==null}function Ca(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function kb(t,e){const r=(t.toString().split(".")[1]||"").length,n=e.toString();let s=(n.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(s=Number.parseInt(l[1]))}const i=r>s?r:s,o=Number.parseInt(t.toFixed(i).replace(".","")),c=Number.parseInt(e.toFixed(i).replace(".",""));return o%c/10**i}const $i=Symbol("evaluating");function L(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==$i)return n===void 0&&(n=$i,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function xt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function It(...t){const e={};for(const r of t){const n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function Mi(t){return JSON.stringify(t)}function Sb(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const jl="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Nb=xa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function vr(t){if(ln(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const r=e.prototype;return!(ln(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function $l(t){return vr(t)?{...t}:Array.isArray(t)?[...t]:t}const Eb=new Set(["string","number","symbol"]);function Yt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ut(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function x(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ab(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const xb={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ib(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&(s[i]=r.shape[i])}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function Cb(t,e){const r=t._zod.def,n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape};for(const i in e){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);e[i]&&delete s[i]}return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function jb(t,e){if(!vr(e))throw new Error("Invalid input to extend: expected a plain object");const r=t._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=It(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return xt(this,"shape",s),s},checks:[]});return ut(t,n)}function $b(t,e){if(!vr(e))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return xt(this,"shape",n),n},checks:t._zod.def.checks};return ut(t,r)}function Mb(t,e){const r=It(t._zod.def,{get shape(){const n={...t._zod.def.shape,...e._zod.def.shape};return xt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:[]});return ut(t,r)}function _b(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=t?new t({type:"optional",innerType:s[o]}):s[o])}else for(const o in s)i[o]=t?new t({type:"optional",innerType:s[o]}):s[o];return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Zb(t,e,r){const n=It(e._zod.def,{get shape(){const s=e._zod.def.shape,i={...s};if(r)for(const o in r){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(i[o]=new t({type:"nonoptional",innerType:s[o]}))}else for(const o in s)i[o]=new t({type:"nonoptional",innerType:s[o]});return xt(this,"shape",i),i},checks:[]});return ut(e,n)}function Ut(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Ml(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Xr(t){return typeof t=="string"?t:t?.message}function St(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Xr(t.inst?._zod.def?.error?.(t))??Xr(e?.error?.(t))??Xr(r.customError?.(t))??Xr(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function ja(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function zr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const _l=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Ms,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Zl=p("$ZodError",_l),Ul=p("$ZodError",_l,{Parent:Error});function Ub(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function Pb(t,e=r=>r.message){const r={_errors:[]},n=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>n({issues:o}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(e(i));else{let o=r,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(e(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(t),r}const $a=t=>(e,r,n,s)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new Dt;if(o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},Ma=t=>async(e,r,n,s)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new(s?.Err??t)(o.issues.map(l=>St(l,i,kt())));throw jl(c,s?.callee),c}return o.value},zn=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Dt;return i.issues.length?{success:!1,error:new(t??Zl)(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Rb=zn(Ul),On=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new t(i.issues.map(o=>St(o,s,kt())))}:{success:!0,data:i.value}},Lb=On(Ul),Db=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $a(t)(e,r,s)},Bb=t=>(e,r,n)=>$a(t)(e,r,n),Fb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ma(t)(e,r,s)},qb=t=>async(e,r,n)=>Ma(t)(e,r,n),Yb=t=>(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return zn(t)(e,r,s)},Vb=t=>(e,r,n)=>zn(t)(e,r,n),Hb=t=>async(e,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return On(t)(e,r,s)},Wb=t=>async(e,r,n)=>On(t)(e,r,n),Gb=/^[cC][^\s-]{8,}$/,Kb=/^[0-9a-z]+$/,Jb=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xb=/^[0-9a-vA-V]{20}$/,Qb=/^[A-Za-z0-9]{27}$/,ev=/^[a-zA-Z0-9_-]{21}$/,tv=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,rv=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_i=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nv=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,sv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function av(){return new RegExp(sv,"u")}const iv=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ov=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cv=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,lv=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uv=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pl=/^[A-Za-z0-9_-]*$/,hv=/^\+(?:[0-9]){6,14}[0-9]$/,Rl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",dv=new RegExp(`^${Rl}$`);function Ll(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fv(t){return new RegExp(`^${Ll(t)}$`)}function pv(t){const e=Ll({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Rl}T(?:${n})$`)}const yv=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},mv=/^-?\d+$/,gv=/^-?\d+(?:\.\d+)?/,wv=/^(?:true|false)$/i,bv=/^[^A-Z]*$/,vv=/^[^a-z]*$/,oe=p("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Dl={number:"number",bigint:"bigint",object:"date"},Bl=p("$ZodCheckLessThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Fl=p("$ZodCheckGreaterThan",(t,e)=>{oe.init(t,e);const r=Dl[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,i=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),zv=p("$ZodCheckMultipleOf",(t,e)=>{oe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):kb(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Ov=p("$ZodCheckNumberFormat",(t,e)=>{oe.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,i]=xb[e.format];t._zod.onattach.push(o=>{const c=o._zod.bag;c.format=e.format,c.minimum=s,c.maximum=i,r&&(c.pattern=mv)}),t._zod.check=o=>{const c=o.value;if(r){if(!Number.isInteger(c)){o.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?o.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}c<s&&o.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),c>i&&o.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:t})}}),Tv=p("$ZodCheckMaxLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=ja(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),kv=p("$ZodCheckMinLength",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=ja(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Sv=p("$ZodCheckLengthEquals",(t,e)=>{var r;oe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ia(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,i=s.length;if(i===e.length)return;const o=ja(s),c=i>e.length;n.issues.push({origin:o,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Tn=p("$ZodCheckStringFormat",(t,e)=>{var r,n;oe.init(t,e),t._zod.onattach.push(s=>{const i=s._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Nv=p("$ZodCheckRegex",(t,e)=>{Tn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Ev=p("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=bv),Tn.init(t,e)}),Av=p("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=vv),Tn.init(t,e)}),xv=p("$ZodCheckIncludes",(t,e)=>{oe.init(t,e);const r=Yt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),Iv=p("$ZodCheckStartsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`^${Yt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Cv=p("$ZodCheckEndsWith",(t,e)=>{oe.init(t,e);const r=new RegExp(`.*${Yt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),jv=p("$ZodCheckOverwrite",(t,e)=>{oe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class $v{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
22
22
|
`).filter(i=>i),n=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const e=Function,r=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,n.join(`
|
|
23
23
|
`))}}const Mv={major:4,minor:1,patch:13},H=p("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Mv;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const i of s._zod.onattach)i(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(o,c,l)=>{let u=Ut(o),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(o))continue}else if(u)continue;const d=o.issues.length,z=f._zod.check(o);if(z instanceof Promise&&l?.async===!1)throw new Dt;if(h||z instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await z,o.issues.length!==d&&(u||(u=Ut(o,d)))});else{if(o.issues.length===d)continue;u||(u=Ut(o,d))}}return h?h.then(()=>o):o},i=(o,c,l)=>{if(Ut(o))return o.aborted=!0,o;const u=s(c,n,l);if(u instanceof Promise){if(l.async===!1)throw new Dt;return u.then(h=>t._zod.parse(h,l))}return t._zod.parse(u,l)};t._zod.run=(o,c)=>{if(c.skipChecks)return t._zod.parse(o,c);if(c.direction==="backward"){const u=t._zod.parse({value:o.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>i(h,o,c)):i(u,o,c)}const l=t._zod.parse(o,c);if(l instanceof Promise){if(c.async===!1)throw new Dt;return l.then(u=>s(u,n,c))}return s(l,n,c)}}t["~standard"]={validate:s=>{try{const i=Rb(t,s);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Lb(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),_a=p("$ZodString",(t,e)=>{H.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??yv(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),q=p("$ZodStringFormat",(t,e)=>{Tn.init(t,e),_a.init(t,e)}),_v=p("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=rv),q.init(t,e)}),Zv=p("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=_i(r))}else e.pattern??(e.pattern=_i());q.init(t,e)}),Uv=p("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=nv),q.init(t,e)}),Pv=p("$ZodURL",(t,e)=>{q.init(t,e),t._zod.check=r=>{try{const n=r.value.trim(),s=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=s.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Rv=p("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=av()),q.init(t,e)}),Lv=p("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=ev),q.init(t,e)}),Dv=p("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Gb),q.init(t,e)}),Bv=p("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Kb),q.init(t,e)}),Fv=p("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Jb),q.init(t,e)}),qv=p("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Xb),q.init(t,e)}),Yv=p("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Qb),q.init(t,e)}),Vv=p("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=pv(e)),q.init(t,e)}),Hv=p("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=dv),q.init(t,e)}),Wv=p("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=fv(e)),q.init(t,e)}),Gv=p("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=tv),q.init(t,e)}),Kv=p("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=iv),q.init(t,e),t._zod.bag.format="ipv4"}),Jv=p("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=ov),q.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Xv=p("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=cv),q.init(t,e)}),Qv=p("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=lv),q.init(t,e),t._zod.check=r=>{const n=r.value.split("/");try{if(n.length!==2)throw new Error;const[s,i]=n;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${s}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function ql(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const ez=p("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=uv),q.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{ql(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function tz(t){if(!Pl.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return ql(r)}const rz=p("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Pl),q.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{tz(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),nz=p("$ZodE164",(t,e)=>{e.pattern??(e.pattern=hv),q.init(t,e)});function sz(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const az=p("$ZodJWT",(t,e)=>{q.init(t,e),t._zod.check=r=>{sz(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Yl=p("$ZodNumber",(t,e)=>{H.init(t,e),t._zod.pattern=t._zod.bag.pattern??gv,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const i=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...i?{received:i}:{}}),r}}),iz=p("$ZodNumberFormat",(t,e)=>{Ov.init(t,e),Yl.init(t,e)}),oz=p("$ZodBoolean",(t,e)=>{H.init(t,e),t._zod.pattern=wv,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),cz=p("$ZodUnknown",(t,e)=>{H.init(t,e),t._zod.parse=r=>r}),lz=p("$ZodNever",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Zi(t,e,r){t.issues.length&&e.issues.push(...Ml(r,t.issues)),e.value[r]=t.value}const uz=p("$ZodArray",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const i=[];for(let o=0;o<s.length;o++){const c=s[o],l=e.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(u=>Zi(u,r,o))):Zi(l,r,o)}return i.length?Promise.all(i).then(()=>r):r}});function un(t,e,r,n){t.issues.length&&e.issues.push(...Ml(r,t.issues)),t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}function Vl(t){const e=Object.keys(t.shape);for(const n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const r=Ab(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function Hl(t,e,r,n,s,i){const o=[],c=s.keySet,l=s.catchall._zod,u=l.def.type;for(const h in e){if(c.has(h))continue;if(u==="never"){o.push(h);continue}const f=l.run({value:e[h],issues:[]},n);f instanceof Promise?t.push(f.then(d=>un(d,r,h,e))):un(f,r,h,e)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:i}),t.length?Promise.all(t).then(()=>r):r}const hz=p("$ZodObject",(t,e)=>{if(H.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const o=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...o};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=xa(()=>Vl(e));L(t._zod,"propValues",()=>{const o=e.shape,c={};for(const l in o){const u=o[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const h of u.values)c[l].add(h)}}return c});const n=ln,s=e.catchall;let i;t._zod.parse=(o,c)=>{i??(i=r.value);const l=o.value;if(!n(l))return o.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),o;o.value={};const u=[],h=i.shape;for(const f of i.keys){const d=h[f]._zod.run({value:l[f],issues:[]},c);d instanceof Promise?u.push(d.then(z=>un(z,o,f,l))):un(d,o,f,l)}return s?Hl(u,l,o,c,r.value,t):u.length?Promise.all(u).then(()=>o):o}}),dz=p("$ZodObjectJIT",(t,e)=>{hz.init(t,e);const r=t._zod.parse,n=xa(()=>Vl(e)),s=f=>{const d=new $v(["shape","payload","ctx"]),z=n.value,I=S=>{const U=Mi(S);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};d.write("const input = payload.value;");const j=Object.create(null);let b=0;for(const S of z.keys)j[S]=`key_${b++}`;d.write("const newResult = {};");for(const S of z.keys){const U=j[S],P=Mi(S);d.write(`const ${U} = ${I(S)};`),d.write(`
|
|
24
24
|
if (${U}.issues.length) {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
newResult[${P}] = ${U}.value;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
`)}d.write("payload.value = newResult;"),d.write("return payload;");const v=d.compile();return(S,U)=>v(f,S,U)};let i;const o=ln,c=!Cl.jitless,l=c&&Nb.value,u=e.catchall;let h;t._zod.parse=(f,d)=>{h??(h=n.value);const z=f.value;return o(z)?c&&l&&d?.async===!1&&d.jitless!==!0?(i||(i=s(e.shape)),f=i(f,d),u?Hl([],z,f,d,h,t):f):r(f,d):(f.issues.push({expected:"object",code:"invalid_type",input:z,inst:t}),f)}});function Ui(t,e,r,n){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!Ut(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(i=>i.issues.map(o=>St(o,n,kt())))}),e)}const fz=p("$ZodUnion",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),L(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),L(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),L(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Ca(i.source)).join("|")})$`)}});const r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(r)return n(s,i);let o=!1;const c=[];for(const l of e.options){const u=l._zod.run({value:s.value,issues:[]},i);if(u instanceof Promise)c.push(u),o=!0;else{if(u.issues.length===0)return u;c.push(u)}}return o?Promise.all(c).then(l=>Ui(l,s,t,i)):Ui(c,s,t,i)}}),pz=p("$ZodIntersection",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>Pi(r,c,l)):Pi(r,i,o)}});function _s(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(vr(t)&&vr(e)){const r=Object.keys(e),n=Object.keys(t).filter(i=>r.indexOf(i)!==-1),s={...t,...e};for(const i of n){const o=_s(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],i=e[n],o=_s(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Pi(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ut(t))return t;const n=_s(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const yz=p("$ZodEnum",(t,e)=>{H.init(t,e);const r=Tb(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>Eb.has(typeof s)).map(s=>typeof s=="string"?Yt(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:r,input:o,inst:t}),s}}),mz=p("$ZodLiteral",(t,e)=>{if(H.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Yt(n):n?Yt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,s)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),n}}),gz=p("$ZodTransform",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Dt;return r.value=s,r}});function Ri(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const wz=p("$ZodOptional",(t,e)=>{H.init(t,e),t._zod.optin="optional",t._zod.optout="optional",L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ri(i,r.value)):Ri(s,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),bz=p("$ZodNullable",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)}|null)$`):void 0}),L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),vz=p("$ZodDefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Li(i,e)):Li(s,e)}});function Li(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const zz=p("$ZodPrefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Oz=p("$ZodNonOptional",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Di(i,t)):Di(s,t)}});function Di(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Tz=p("$ZodCatch",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>St(o,n,kt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>St(i,n,kt()))},input:r.value}),r.issues=[]),r)}}),kz=p("$ZodPipe",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>e.in._zod.values),L(t._zod,"optin",()=>e.in._zod.optin),L(t._zod,"optout",()=>e.out._zod.optout),L(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=e.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Qr(o,e.in,n)):Qr(i,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Qr(i,e.out,n)):Qr(s,e.out,n)}});function Qr(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}const Sz=p("$ZodReadonly",(t,e)=>{H.init(t,e),L(t._zod,"propValues",()=>e.innerType._zod.propValues),L(t._zod,"values",()=>e.innerType._zod.values),L(t._zod,"optin",()=>e.innerType?._zod?.optin),L(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Bi):Bi(s)}});function Bi(t){return t.value=Object.freeze(t.value),t}const Nz=p("$ZodCustom",(t,e)=>{oe.init(t,e),H.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>Fi(i,r,n,t));Fi(s,r,n,t)}});function Fi(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(zr(s))}}var qi;class Ez{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Az(){return new Ez}(qi=globalThis).__zod_globalRegistry??(qi.__zod_globalRegistry=Az());const en=globalThis.__zod_globalRegistry;function xz(t,e){return new t({type:"string",...A(e)})}function Iz(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...A(e)})}function Yi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...A(e)})}function Wl(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...A(e)})}function Cz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(e)})}function jz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(e)})}function $z(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(e)})}function Mz(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...A(e)})}function _z(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...A(e)})}function Zz(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(e)})}function Uz(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...A(e)})}function Pz(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(e)})}function Rz(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...A(e)})}function Lz(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...A(e)})}function Dz(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(e)})}function Bz(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(e)})}function Fz(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(e)})}function qz(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(e)})}function Yz(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(e)})}function Vz(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...A(e)})}function Hz(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...A(e)})}function Wz(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...A(e)})}function Gz(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...A(e)})}function Kz(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(e)})}function Jz(t,e){return new t({type:"string",format:"date",check:"string_format",...A(e)})}function Xz(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...A(e)})}function Qz(t,e){return new t({type:"string",format:"duration",check:"string_format",...A(e)})}function eO(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...A(e)})}function tO(t,e){return new t({type:"boolean",...A(e)})}function rO(t){return new t({type:"unknown"})}function nO(t,e){return new t({type:"never",...A(e)})}function Vi(t,e){return new Bl({check:"less_than",...A(e),value:t,inclusive:!1})}function Gn(t,e){return new Bl({check:"less_than",...A(e),value:t,inclusive:!0})}function Hi(t,e){return new Fl({check:"greater_than",...A(e),value:t,inclusive:!1})}function Kn(t,e){return new Fl({check:"greater_than",...A(e),value:t,inclusive:!0})}function Wi(t,e){return new zv({check:"multiple_of",...A(e),value:t})}function Gl(t,e){return new Tv({check:"max_length",...A(e),maximum:t})}function hn(t,e){return new kv({check:"min_length",...A(e),minimum:t})}function Kl(t,e){return new Sv({check:"length_equals",...A(e),length:t})}function sO(t,e){return new Nv({check:"string_format",format:"regex",...A(e),pattern:t})}function aO(t){return new Ev({check:"string_format",format:"lowercase",...A(t)})}function iO(t){return new Av({check:"string_format",format:"uppercase",...A(t)})}function oO(t,e){return new xv({check:"string_format",format:"includes",...A(e),includes:t})}function cO(t,e){return new Iv({check:"string_format",format:"starts_with",...A(e),prefix:t})}function lO(t,e){return new Cv({check:"string_format",format:"ends_with",...A(e),suffix:t})}function Xt(t){return new jv({check:"overwrite",tx:t})}function uO(t){return Xt(e=>e.normalize(t))}function hO(){return Xt(t=>t.trim())}function dO(){return Xt(t=>t.toLowerCase())}function fO(){return Xt(t=>t.toUpperCase())}function pO(){return Xt(t=>Sb(t))}function yO(t,e,r){return new t({type:"array",element:e,...A(r)})}function mO(t,e,r){return new t({type:"custom",check:"custom",fn:e,...A(r)})}function gO(t){const e=wO(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(zr(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(zr(s))}},t(r.value,r)));return e}function wO(t,e){const r=new oe({check:"custom",...A(e)});return r._zod.check=t,r}const bO=p("ZodISODateTime",(t,e)=>{Vv.init(t,e),V.init(t,e)});function vO(t){return Kz(bO,t)}const zO=p("ZodISODate",(t,e)=>{Hv.init(t,e),V.init(t,e)});function OO(t){return Jz(zO,t)}const TO=p("ZodISOTime",(t,e)=>{Wv.init(t,e),V.init(t,e)});function kO(t){return Xz(TO,t)}const SO=p("ZodISODuration",(t,e)=>{Gv.init(t,e),V.init(t,e)});function NO(t){return Qz(SO,t)}const EO=(t,e)=>{Zl.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Pb(t,r)},flatten:{value:r=>Ub(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Ms,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Ms,2)}},isEmpty:{get(){return t.issues.length===0}}})},Oe=p("ZodError",EO,{Parent:Error}),AO=$a(Oe),xO=Ma(Oe),IO=zn(Oe),CO=On(Oe),jO=Db(Oe),$O=Bb(Oe),MO=Fb(Oe),_O=qb(Oe),ZO=Yb(Oe),UO=Vb(Oe),PO=Hb(Oe),RO=Wb(Oe),G=p("ZodType",(t,e)=>(H.init(t,e),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone(It(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),t.clone=(r,n)=>ut(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>AO(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>IO(t,r,n),t.parseAsync=async(r,n)=>xO(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>CO(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>jO(t,r,n),t.decode=(r,n)=>$O(t,r,n),t.encodeAsync=async(r,n)=>MO(t,r,n),t.decodeAsync=async(r,n)=>_O(t,r,n),t.safeEncode=(r,n)=>ZO(t,r,n),t.safeDecode=(r,n)=>UO(t,r,n),t.safeEncodeAsync=async(r,n)=>PO(t,r,n),t.safeDecodeAsync=async(r,n)=>RO(t,r,n),t.refine=(r,n)=>t.check($T(r,n)),t.superRefine=r=>t.check(MT(r)),t.overwrite=r=>t.check(Xt(r)),t.optional=()=>Ji(t),t.nullable=()=>Xi(t),t.nullish=()=>Ji(Xi(t)),t.nonoptional=r=>NT(t,r),t.array=()=>dT(t),t.or=r=>Ua([t,r]),t.and=r=>mT(t,r),t.transform=r=>Qi(t,vT(r)),t.default=r=>TT(t,r),t.prefault=r=>ST(t,r),t.catch=r=>AT(t,r),t.pipe=r=>Qi(t,r),t.readonly=()=>CT(t),t.describe=r=>{const n=t.clone();return en.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return en.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return en.get(t);const n=t.clone();return en.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Jl=p("_ZodString",(t,e)=>{_a.init(t,e),G.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(sO(...n)),t.includes=(...n)=>t.check(oO(...n)),t.startsWith=(...n)=>t.check(cO(...n)),t.endsWith=(...n)=>t.check(lO(...n)),t.min=(...n)=>t.check(hn(...n)),t.max=(...n)=>t.check(Gl(...n)),t.length=(...n)=>t.check(Kl(...n)),t.nonempty=(...n)=>t.check(hn(1,...n)),t.lowercase=n=>t.check(aO(n)),t.uppercase=n=>t.check(iO(n)),t.trim=()=>t.check(hO()),t.normalize=(...n)=>t.check(uO(...n)),t.toLowerCase=()=>t.check(dO()),t.toUpperCase=()=>t.check(fO()),t.slugify=()=>t.check(pO())}),LO=p("ZodString",(t,e)=>{_a.init(t,e),Jl.init(t,e),t.email=r=>t.check(Iz(DO,r)),t.url=r=>t.check(Mz(FO,r)),t.jwt=r=>t.check(Gz(sT,r)),t.emoji=r=>t.check(_z(qO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.uuid=r=>t.check(Wl(fr,r)),t.uuidv4=r=>t.check(Cz(fr,r)),t.uuidv6=r=>t.check(jz(fr,r)),t.uuidv7=r=>t.check($z(fr,r)),t.nanoid=r=>t.check(Zz(YO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.cuid=r=>t.check(Uz(VO,r)),t.cuid2=r=>t.check(Pz(HO,r)),t.ulid=r=>t.check(Rz(WO,r)),t.base64=r=>t.check(Vz(tT,r)),t.base64url=r=>t.check(Hz(rT,r)),t.xid=r=>t.check(Lz(GO,r)),t.ksuid=r=>t.check(Dz(KO,r)),t.ipv4=r=>t.check(Bz(JO,r)),t.ipv6=r=>t.check(Fz(XO,r)),t.cidrv4=r=>t.check(qz(QO,r)),t.cidrv6=r=>t.check(Yz(eT,r)),t.e164=r=>t.check(Wz(nT,r)),t.datetime=r=>t.check(vO(r)),t.date=r=>t.check(OO(r)),t.time=r=>t.check(kO(r)),t.duration=r=>t.check(NO(r))});function ve(t){return xz(LO,t)}const V=p("ZodStringFormat",(t,e)=>{q.init(t,e),Jl.init(t,e)}),DO=p("ZodEmail",(t,e)=>{Uv.init(t,e),V.init(t,e)}),Gi=p("ZodGUID",(t,e)=>{_v.init(t,e),V.init(t,e)}),fr=p("ZodUUID",(t,e)=>{Zv.init(t,e),V.init(t,e)});function BO(t){return Wl(fr,t)}const FO=p("ZodURL",(t,e)=>{Pv.init(t,e),V.init(t,e)}),qO=p("ZodEmoji",(t,e)=>{Rv.init(t,e),V.init(t,e)}),YO=p("ZodNanoID",(t,e)=>{Lv.init(t,e),V.init(t,e)}),VO=p("ZodCUID",(t,e)=>{Dv.init(t,e),V.init(t,e)}),HO=p("ZodCUID2",(t,e)=>{Bv.init(t,e),V.init(t,e)}),WO=p("ZodULID",(t,e)=>{Fv.init(t,e),V.init(t,e)}),GO=p("ZodXID",(t,e)=>{qv.init(t,e),V.init(t,e)}),KO=p("ZodKSUID",(t,e)=>{Yv.init(t,e),V.init(t,e)}),JO=p("ZodIPv4",(t,e)=>{Kv.init(t,e),V.init(t,e)}),XO=p("ZodIPv6",(t,e)=>{Jv.init(t,e),V.init(t,e)}),QO=p("ZodCIDRv4",(t,e)=>{Xv.init(t,e),V.init(t,e)}),eT=p("ZodCIDRv6",(t,e)=>{Qv.init(t,e),V.init(t,e)}),tT=p("ZodBase64",(t,e)=>{ez.init(t,e),V.init(t,e)}),rT=p("ZodBase64URL",(t,e)=>{rz.init(t,e),V.init(t,e)}),nT=p("ZodE164",(t,e)=>{nz.init(t,e),V.init(t,e)}),sT=p("ZodJWT",(t,e)=>{az.init(t,e),V.init(t,e)}),aT=p("ZodNumber",(t,e)=>{Yl.init(t,e),G.init(t,e),t.gt=(n,s)=>t.check(Hi(n,s)),t.gte=(n,s)=>t.check(Kn(n,s)),t.min=(n,s)=>t.check(Kn(n,s)),t.lt=(n,s)=>t.check(Vi(n,s)),t.lte=(n,s)=>t.check(Gn(n,s)),t.max=(n,s)=>t.check(Gn(n,s)),t.int=n=>t.check(dn(n)),t.safe=n=>t.check(dn(n)),t.positive=n=>t.check(Hi(0,n)),t.nonnegative=n=>t.check(Kn(0,n)),t.negative=n=>t.check(Vi(0,n)),t.nonpositive=n=>t.check(Gn(0,n)),t.multipleOf=(n,s)=>t.check(Wi(n,s)),t.step=(n,s)=>t.check(Wi(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null}),iT=p("ZodNumberFormat",(t,e)=>{iz.init(t,e),aT.init(t,e)});function dn(t){return eO(iT,t)}const oT=p("ZodBoolean",(t,e)=>{oz.init(t,e),G.init(t,e)});function Za(t){return tO(oT,t)}const cT=p("ZodUnknown",(t,e)=>{cz.init(t,e),G.init(t,e)});function Ki(){return rO(cT)}const lT=p("ZodNever",(t,e)=>{lz.init(t,e),G.init(t,e)});function uT(t){return nO(lT,t)}const hT=p("ZodArray",(t,e)=>{uz.init(t,e),G.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(hn(r,n)),t.nonempty=r=>t.check(hn(1,r)),t.max=(r,n)=>t.check(Gl(r,n)),t.length=(r,n)=>t.check(Kl(r,n)),t.unwrap=()=>t.element});function dT(t,e){return yO(hT,t,e)}const fT=p("ZodObject",(t,e)=>{dz.init(t,e),G.init(t,e),L(t,"shape",()=>e.shape),t.keyof=()=>Xl(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ki()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ki()}),t.strict=()=>t.clone({...t._zod.def,catchall:uT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>jb(t,r),t.safeExtend=r=>$b(t,r),t.merge=r=>Mb(t,r),t.pick=r=>Ib(t,r),t.omit=r=>Cb(t,r),t.partial=(...r)=>_b(Ql,t,r[0]),t.required=(...r)=>Zb(eu,t,r[0])});function ne(t,e){const r={type:"object",shape:t??{},...A(e)};return new fT(r)}const pT=p("ZodUnion",(t,e)=>{fz.init(t,e),G.init(t,e),t.options=e.options});function Ua(t,e){return new pT({type:"union",options:t,...A(e)})}const yT=p("ZodIntersection",(t,e)=>{pz.init(t,e),G.init(t,e)});function mT(t,e){return new yT({type:"intersection",left:t,right:e})}const Zs=p("ZodEnum",(t,e)=>{yz.init(t,e),G.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const i={};for(const o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...A(s),entries:i})},t.exclude=(n,s)=>{const i={...e.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...A(s),entries:i})}});function Xl(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Zs({type:"enum",entries:r,...A(e)})}const gT=p("ZodLiteral",(t,e)=>{mz.init(t,e),G.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function wT(t,e){return new gT({type:"literal",values:Array.isArray(t)?t:[t],...A(e)})}const bT=p("ZodTransform",(t,e)=>{gz.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(zr(i,r.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),r.issues.push(zr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});function vT(t){return new bT({type:"transform",transform:t})}const Ql=p("ZodOptional",(t,e)=>{wz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ji(t){return new Ql({type:"optional",innerType:t})}const zT=p("ZodNullable",(t,e)=>{bz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Xi(t){return new zT({type:"nullable",innerType:t})}const OT=p("ZodDefault",(t,e)=>{vz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function TT(t,e){return new OT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const kT=p("ZodPrefault",(t,e)=>{zz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ST(t,e){return new kT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const eu=p("ZodNonOptional",(t,e)=>{Oz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function NT(t,e){return new eu({type:"nonoptional",innerType:t,...A(e)})}const ET=p("ZodCatch",(t,e)=>{Tz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function AT(t,e){return new ET({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const xT=p("ZodPipe",(t,e)=>{kz.init(t,e),G.init(t,e),t.in=e.in,t.out=e.out});function Qi(t,e){return new xT({type:"pipe",in:t,out:e})}const IT=p("ZodReadonly",(t,e)=>{Sz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function CT(t){return new IT({type:"readonly",innerType:t})}const jT=p("ZodCustom",(t,e)=>{Nz.init(t,e),G.init(t,e)});function $T(t,e={}){return mO(jT,t,e)}function MT(t){return gO(t)}const Re=t=>t?JSON.parse(t):{},Pa=ne({key:ve(),type:ve(),config:ze.unknownZ.or(ve().transform(Re))}),tu=Pa.extend({position:ga.xy}),Us=ne({param:ve(),node:ve()}),Ra=ne({source:Us,target:Us}),_T=ne({nodes:Pa.array(),edges:Ra.array()}),ru=ne({nodes:tu.array(),edges:Ra.array()}),nu=ne({raw:ve()}),Pr=BO(),su=Xl(["graph","text"]).or(wT("").transform(()=>"graph")),kn=ne({key:Pr,name:ve(),graph:ru,text:nu,version:ve(),mode:su}),au=kn.partial({key:!0,mode:!0}),ZT="arc",iu=K("arc"),UT=iu(""),PT=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=O.toArray(t);const i=s[0],o=typeof i;let c;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(c=e.number,s=s.map(l=>parseInt(l))):c=e[o],{single:n,variant:c,normalized:s,actual:t}},ce=(t,e,r,n)=>{if(n){if(r.length===0)throw new Tt(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new cn(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},RT="sy_arc_set",LT="sy_arc_delete",DT=ne({keys:Pr.array().optional(),names:ve().array().optional(),searchTerm:ve().optional(),limit:dn().optional(),offset:dn().optional(),includeStatus:Za().optional()}),BT=ne({arcs:au.array()}),FT=ne({keys:Pr.array()}),qT=ne({arcs:O.nullableZ(kn)}),YT=ne({arcs:kn.array()}),VT=ne({}),Ps=ne({content:ve()}),HT=ne({key:Pr,includeStatus:Za().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),WT=ne({name:ve(),includeStatus:Za().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),ou=Ua([HT,WT]),GT=Ua([ou,DT]);let cu=class{client;streamClient;constructor(t,e){this.client=t,this.streamClient=e}async create(t){const e=Array.isArray(t),r=await w(this.client,"/arc/create",{arcs:O.toArray(t)},BT,YT);return e?r.arcs:r.arcs[0]}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/arc/retrieve",t,GT,qT);return ce("Arc",t,r.arcs,e),e?r.arcs[0]:r.arcs}async delete(t){await w(this.client,"/arc/delete",{keys:O.toArray(t)},FT,VT)}async openLSP(){return await this.streamClient.stream("/arc/lsp",Ps,Ps)}};const KT=Object.freeze(Object.defineProperty({__proto__:null,Client:cu,DELETE_CHANNEL_NAME:LT,ONTOLOGY_TYPE:ZT,SET_CHANNEL_NAME:RT,TYPE_ONTOLOGY_ID:UT,arcZ:kn,edgeZ:Ra,graphNodeZ:tu,graphZ:ru,handleZ:Us,irNodeZ:Pa,irZ:_T,keyZ:Pr,lspMessageZ:Ps,modeZ:su,newZ:au,ontologyID:iu,singleRetrieveArgsZ:ou,textZ:nu},Symbol.toStringTag,{value:"Module"})),eo="Channel key must be a valid uint32.",D=a.z.uint32().or(a.z.string().refine(t=>!isNaN(Number(t)),{message:eo}).transform(Number).refine(t=>t<Os.MAX_UINT32,{message:eo})),lu=/^[a-zA-Z_][a-zA-Z0-9_]*$/,Ve=a.z.string().min(1,"Name must not be empty").regex(lu,"Name can only contain letters, digits, and underscores, and cannot start with a digit"),uu=["min","max","avg","none"],hu=a.z.enum(uu),La=a.z.object({type:hu,resetChannel:D.optional(),duration:E.z.optional()}),du=lt.statusZ(),fu=a.z.object({channel:D}),JT=lt.statusZ(fu),XT=t=>Ze(Sn(t)),Qt=a.z.object({name:a.z.string(),key:D,dataType:_.z,leaseholder:_e.uint12,index:D,isIndex:a.z.boolean(),internal:a.z.boolean(),virtual:a.z.boolean(),alias:a.z.string().optional(),expression:a.z.string().default(""),status:du.optional(),operations:O.nullableZ(La)}),pu=Qt.extend({key:D.optional(),name:Ve,leaseholder:_e.uint12.optional(),index:D.optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().default(!1),virtual:a.z.boolean().default(!1),expression:a.z.string().default(""),operations:O.nullableZ(La).optional()}),Ct=a.z.union([_e.toArray(D),_e.toArray(Ve),_e.toArray(Qt).transform(t=>t.map(e=>e.key))]),Sn=K("channel"),QT=Sn(0),ek=/[a-zA-Z0-9_]/,tk=(t,e=!1)=>{if(t==="")return e?"_":"";if(t.match(lu))return t;let r="";for(const n of t)n.match(ek)?r+=n:r+="_";return r[0].match(/^\d/)&&(r=`_${r}`),r},rk=new Error("request for lock canceled");var nk=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class sk{constructor(e,r=rk){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=yu(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return nk(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),ak(this._weightedWaiters[e-1],{resolve:n,priority:r})})}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 r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function ak(t,e){const r=yu(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function yu(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var ik=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class ok{constructor(e){this._semaphore=new sk(1,e)}acquire(){return ik(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}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 ht=rl.keyZ,Rr=rl.labelZ,ck="labeled_by",lk="sy_label_set",uk="sy_label_delete",mu=Rr.extend({key:ht.optional()}),hk=a.object({labels:mu.array()}),dk=a.object({labels:Rr.array()}),fk=a.object({keys:ht.array()}),gu=a.object({id:F,labels:ht.array(),replace:a.boolean().optional()}),pk=gu.omit({replace:!0}),Jn=a.object({}),yk=a.object({keys:ht.array().optional(),names:a.string().array().optional(),for:F.optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional()}),mk=a.object({key:ht}).transform(({key:t})=>({keys:[t]})),gk=a.union([mk,yk]),wk=a.object({labels:O.nullableZ(Rr)});let wu=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/label/retrieve",t,gk,wk);return ce("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await w(this.client,"/label/set",{id:t,labels:e,replace:r.replace},gu,Jn)}async remove(t,e){await w(this.client,"/label/remove",{id:t,labels:e},pk,Jn)}async create(t){const e=Array.isArray(t),r=await w(this.client,"/label/create",{labels:O.toArray(t)},hk,dk);return e?r.labels:r.labels[0]}async delete(t){await w(this.client,"/label/delete",{keys:O.toArray(t)},fk,Jn)}};const bu=K("label"),bk=bu(""),vk=Object.freeze(Object.defineProperty({__proto__:null,Client:wu,DELETE_CHANNEL_NAME:uk,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:ck,SET_CHANNEL_NAME:lk,TYPE_ONTOLOGY_ID:bk,keyZ:ht,labelZ:Rr,newZ:mu,ontologyID:bu},Symbol.toStringTag,{value:"Module"})),X=a.z.uuid(),Da=a.z.string().min(1),Lr=a.z.object({key:X,name:Da,timeRange:B.z.refine(({isValid:t})=>t,{error:"Time range start time must be before or equal to time range end time"}).refine(({end:t})=>t.valueOf()<=Os.MAX_INT64,{error:"Time range end time must be less than or equal to the maximum value of an int64"}).refine(({start:t})=>t.valueOf()>=Os.MIN_INT64,{error:"Time range start time must be greater than or equal to the minimum value of an int64"}),color:a.z.string().optional(),labels:Rr.array().or(a.z.null().transform(()=>{})).optional(),get parent(){return Lr.optional().nullable().transform(t=>t===void 0?null:t)}}),vu=Lr.omit({parent:!0,labels:!0}).partial({key:!0}),zk=a.z.object({nodeKey:_e.uint12.optional(),keys:D.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),rangeKey:X.optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),dataTypes:_.z.array().optional(),notDataTypes:_.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional(),legacyCalculated:a.z.boolean().optional()}),Ok=a.z.object({channels:O.nullableZ(Qt)}),Ne=t=>(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"?t=t.map(e=>e.key):typeof t=="object"&&"key"in t&&(t=[t.key]),PT(t,{number:"keys",string:"names"}));class Ba{client;constructor(e){this.client=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.execute(e);const n=Ne(e),{variant:s}=n;let{normalized:i}=n;return s==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[s]:i,...r})}async execute(e){return(await w(this.client,"/channel/retrieve",e,zk,Ok)).channels}}class Fa{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:n}=Ne(e),s=[],i=[];if(n.forEach(c=>{const l=this.get(c);l!=null?s.push(...l):i.push(c)}),i.length===0)return s;const o=await this.wrapped.retrieve(i,r);return this.set(o),s.concat(o)}delete(e){const{variant:r,normalized:n}=Ne(e);r==="names"?n.forEach(s=>{const i=this.namesToKeys.get(s);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(s))}):n.forEach(s=>{const i=this.cache.get(s);i!=null&&(this.cache.delete(s),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,s)=>{const i=r[s],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const l=this.namesToKeys.get(i);l==null?this.namesToKeys.set(i,new Set([n])):l.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const s=this.cache.get(e);return s==null?void 0:[s]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(s=>{const i=this.cache.get(s);i!=null&&n.push(i)}),n.length!==0)return n}}class zu{mu=new ok;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=eg(()=>{this.run()},r)}async retrieve(e){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:r,variant:n}=Ne(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((s,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:s,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(s=>e.add(s)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(r.filter(i=>s.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Ou=async(t,e)=>{const{normalized:r}=Ne(e),n=await t.retrieve(r),s=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&s.push(i)}),s.length>0)throw new ot(`Could not find channels: ${JSON.stringify(s)}`);return n},Tk="sy_channel_set",kk="sy_channel_delete";class Rs{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;status;constructor({dataType:e,name:r,leaseholder:n=0,key:s=0,isIndex:i=!1,index:o=0,internal:c=!1,virtual:l=!1,frameClient:u,alias:h,status:f,expression:d="",operations:z=[]}){this.key=D.parse(s),this.name=r,this.dataType=new _(e),this.leaseholder=n,this.index=D.parse(o),this.isIndex=i,this.internal=c,this.alias=h,this.virtual=l,this.expression=d,this.operations=z,f!=null&&(this.status=lt.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Qt.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return ku(this.payload)}get ontologyID(){return Sn(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const Sk=a.z.object({}),Nk=a.z.object({group:bn});let Tu=class{frameClient;client;retriever;writer;constructor(t,e,r,n){this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let s=O.toArray(t),i=[];if(r){const o=await this.retriever.retrieve(s.map(l=>l.name)),c=new Set(o.map(l=>l.name));s=s.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(s))),n?i[0]:i}async retrieve(t,e){if(typeof t=="object"&&!Array.isArray(t))return this.sugar(await this.retriever.retrieve(t));const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return ce("channel",t,n,r),r?n[0]:n}async delete(t){const{normalized:e,variant:r}=Ne(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(O.toArray(t),O.toArray(e))}createDebouncedBatchRetriever(t=10){return new Fa(new zu(new Ba(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new Rs({...r,frameClient:e})):new Rs({...t,frameClient:e})}async retrieveGroup(){return(await w(this.client,"/channel/retrieve-group",{},Sk,Nk)).group}};const ku=({virtual:t,expression:e})=>t&&e!=="",Ek=a.z.object({channels:pu.array()}),Ak=a.z.object({channels:Qt.array()}),xk=a.z.object({keys:D.array().optional(),names:Ve.array().optional()}),Ik=a.z.object({}),Ck=a.z.object({keys:D.array(),names:Ve.array()}),jk=a.z.object({});let Su=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,"/channel/create",{channels:t.map(r=>({...r,dataType:r.dataType}))},Ek,Ak);return this.cache.set(e),e}async delete(t){const e=D.array().parse(t.keys??[]);await w(this.client,"/channel/delete",t,xk,Ik),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,"/channel/rename",{keys:t,names:e},Ck,jk),this.cache.rename(t,e)}};const $k=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Fa,Channel:Rs,Client:Tu,ClusterRetriever:Ba,DELETE_CHANNEL_NAME:kk,DebouncedBatchRetriever:zu,OPERATION_TYPES:uu,SET_CHANNEL_NAME:Tk,TYPE_ONTOLOGY_ID:QT,Writer:Su,analyzeParams:Ne,calculationStatusDetailsZ:fu,calculationStatusZ:JT,escapeInvalidName:tk,isCalculated:ku,keyZ:D,nameZ:Ve,newZ:pu,ontologyID:Sn,operationType:hu,operationZ:La,paramsZ:Ct,payloadZ:Qt,retrieveRequired:Ou,statusKey:XT,statusZ:du},Symbol.toStringTag,{value:"Module"})),Mk=a.z.object({username:a.z.string(),password:a.z.string()}),_k=a.z.object({token:a.z.string(),user:Ur}),to="/auth/login",Zk=3,Uk=a.z.object({username:a.z.string(),password:a.z.string(),newPassword:a.z.string().min(1)}),Pk=a.z.object({}),Rk=[Cs,js];let Lk=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(t,e){this.client=t,this.credentials=e,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;const{authState:t}=this;if(!t.authenticated)throw new Error("Authentication failed: user not available");return t.user}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,"/auth/change-password",{username:this.credentials.username,password:this.credentials.password,newPassword:t},Uk,Pk),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(to)){this.authenticating??=new Promise((o,c)=>{this.client.send(to,this.credentials,Mk,_k).then(([l,u])=>{if(u!=null)return o(u);if(l==null)return o(new Error("No response from login"));this.authState={authenticated:!0,user:l.user,token:l.token},o(null)}).catch(c)});const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,s]=await r(e);return Rk.some(i=>i.matches(s))&&this.retryCount<Zk?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const Dk=a.z.enum(["disconnected","connecting","connected","failed"]),Bk=a.z.object({status:Dk,error:a.z.instanceof(Error).optional(),message:a.z.string().optional(),clusterKey:a.z.string(),clientVersion:a.z.string(),clientServerCompatible:a.z.boolean(),nodeVersion:a.z.string().optional()}),Fk=a.z.object({clusterKey:a.z.string(),nodeVersion:a.z.string().optional()}),qk=a.z.void(),ro={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.50.0"},no=(t,e,r)=>{const n=r?"Core":"client";return`Synnax Core version ${t!=null?`${t} `:""}is too ${r?"old":"new"} for client version ${e}.
|
|
40
|
+
`)}d.write("payload.value = newResult;"),d.write("return payload;");const v=d.compile();return(S,U)=>v(f,S,U)};let i;const o=ln,c=!Cl.jitless,l=c&&Nb.value,u=e.catchall;let h;t._zod.parse=(f,d)=>{h??(h=n.value);const z=f.value;return o(z)?c&&l&&d?.async===!1&&d.jitless!==!0?(i||(i=s(e.shape)),f=i(f,d),u?Hl([],z,f,d,h,t):f):r(f,d):(f.issues.push({expected:"object",code:"invalid_type",input:z,inst:t}),f)}});function Ui(t,e,r,n){for(const i of t)if(i.issues.length===0)return e.value=i.value,e;const s=t.filter(i=>!Ut(i));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(i=>i.issues.map(o=>St(o,n,kt())))}),e)}const fz=p("$ZodUnion",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.options.some(s=>s._zod.optin==="optional")?"optional":void 0),L(t._zod,"optout",()=>e.options.some(s=>s._zod.optout==="optional")?"optional":void 0),L(t._zod,"values",()=>{if(e.options.every(s=>s._zod.values))return new Set(e.options.flatMap(s=>Array.from(s._zod.values)))}),L(t._zod,"pattern",()=>{if(e.options.every(s=>s._zod.pattern)){const s=e.options.map(i=>i._zod.pattern);return new RegExp(`^(${s.map(i=>Ca(i.source)).join("|")})$`)}});const r=e.options.length===1,n=e.options[0]._zod.run;t._zod.parse=(s,i)=>{if(r)return n(s,i);let o=!1;const c=[];for(const l of e.options){const u=l._zod.run({value:s.value,issues:[]},i);if(u instanceof Promise)c.push(u),o=!0;else{if(u.issues.length===0)return u;c.push(u)}}return o?Promise.all(c).then(l=>Ui(l,s,t,i)):Ui(c,s,t,i)}}),pz=p("$ZodIntersection",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,i=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([c,l])=>Pi(r,c,l)):Pi(r,i,o)}});function _s(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(vr(t)&&vr(e)){const r=Object.keys(e),n=Object.keys(t).filter(i=>r.indexOf(i)!==-1),s={...t,...e};for(const i of n){const o=_s(t[i],e[i]);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};s[i]=o.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],i=e[n],o=_s(s,i);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Pi(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ut(t))return t;const n=_s(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const yz=p("$ZodEnum",(t,e)=>{H.init(t,e);const r=Tb(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(s=>Eb.has(typeof s)).map(s=>typeof s=="string"?Yt(s):s.toString()).join("|")})$`),t._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:r,input:o,inst:t}),s}}),mz=p("$ZodLiteral",(t,e)=>{if(H.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?Yt(n):n?Yt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,s)=>{const i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:e.values,input:i,inst:t}),n}}),gz=p("$ZodTransform",(t,e)=>{H.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Dt;return r.value=s,r}});function Ri(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const wz=p("$ZodOptional",(t,e)=>{H.init(t,e),t._zod.optin="optional",t._zod.optout="optional",L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Ri(i,r.value)):Ri(s,r.value)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),bz=p("$ZodNullable",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${Ca(r.source)}|null)$`):void 0}),L(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),vz=p("$ZodDefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Li(i,e)):Li(s,e)}});function Li(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const zz=p("$ZodPrefault",(t,e)=>{H.init(t,e),t._zod.optin="optional",L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Oz=p("$ZodNonOptional",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Di(i,t)):Di(s,t)}});function Di(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Tz=p("$ZodCatch",(t,e)=>{H.init(t,e),L(t._zod,"optin",()=>e.innerType._zod.optin),L(t._zod,"optout",()=>e.innerType._zod.optout),L(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>(r.value=i.value,i.issues.length&&(r.value=e.catchValue({...r,error:{issues:i.issues.map(o=>St(o,n,kt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>St(i,n,kt()))},input:r.value}),r.issues=[]),r)}}),kz=p("$ZodPipe",(t,e)=>{H.init(t,e),L(t._zod,"values",()=>e.in._zod.values),L(t._zod,"optin",()=>e.in._zod.optin),L(t._zod,"optout",()=>e.out._zod.optout),L(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){const i=e.out._zod.run(r,n);return i instanceof Promise?i.then(o=>Qr(o,e.in,n)):Qr(i,e.in,n)}const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(i=>Qr(i,e.out,n)):Qr(s,e.out,n)}});function Qr(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}const Sz=p("$ZodReadonly",(t,e)=>{H.init(t,e),L(t._zod,"propValues",()=>e.innerType._zod.propValues),L(t._zod,"values",()=>e.innerType._zod.values),L(t._zod,"optin",()=>e.innerType?._zod?.optin),L(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Bi):Bi(s)}});function Bi(t){return t.value=Object.freeze(t.value),t}const Nz=p("$ZodCustom",(t,e)=>{oe.init(t,e),H.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(i=>Fi(i,r,n,t));Fi(s,r,n,t)}});function Fi(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(zr(s))}}var qi;class Ez{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};delete n.id;const s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Az(){return new Ez}(qi=globalThis).__zod_globalRegistry??(qi.__zod_globalRegistry=Az());const en=globalThis.__zod_globalRegistry;function xz(t,e){return new t({type:"string",...x(e)})}function Iz(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...x(e)})}function Yi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...x(e)})}function Wl(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...x(e)})}function Cz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(e)})}function jz(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(e)})}function $z(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(e)})}function Mz(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...x(e)})}function _z(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...x(e)})}function Zz(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(e)})}function Uz(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...x(e)})}function Pz(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(e)})}function Rz(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...x(e)})}function Lz(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...x(e)})}function Dz(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(e)})}function Bz(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(e)})}function Fz(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(e)})}function qz(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(e)})}function Yz(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(e)})}function Vz(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...x(e)})}function Hz(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...x(e)})}function Wz(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...x(e)})}function Gz(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...x(e)})}function Kz(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(e)})}function Jz(t,e){return new t({type:"string",format:"date",check:"string_format",...x(e)})}function Xz(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...x(e)})}function Qz(t,e){return new t({type:"string",format:"duration",check:"string_format",...x(e)})}function eO(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...x(e)})}function tO(t,e){return new t({type:"boolean",...x(e)})}function rO(t){return new t({type:"unknown"})}function nO(t,e){return new t({type:"never",...x(e)})}function Vi(t,e){return new Bl({check:"less_than",...x(e),value:t,inclusive:!1})}function Gn(t,e){return new Bl({check:"less_than",...x(e),value:t,inclusive:!0})}function Hi(t,e){return new Fl({check:"greater_than",...x(e),value:t,inclusive:!1})}function Kn(t,e){return new Fl({check:"greater_than",...x(e),value:t,inclusive:!0})}function Wi(t,e){return new zv({check:"multiple_of",...x(e),value:t})}function Gl(t,e){return new Tv({check:"max_length",...x(e),maximum:t})}function hn(t,e){return new kv({check:"min_length",...x(e),minimum:t})}function Kl(t,e){return new Sv({check:"length_equals",...x(e),length:t})}function sO(t,e){return new Nv({check:"string_format",format:"regex",...x(e),pattern:t})}function aO(t){return new Ev({check:"string_format",format:"lowercase",...x(t)})}function iO(t){return new Av({check:"string_format",format:"uppercase",...x(t)})}function oO(t,e){return new xv({check:"string_format",format:"includes",...x(e),includes:t})}function cO(t,e){return new Iv({check:"string_format",format:"starts_with",...x(e),prefix:t})}function lO(t,e){return new Cv({check:"string_format",format:"ends_with",...x(e),suffix:t})}function Xt(t){return new jv({check:"overwrite",tx:t})}function uO(t){return Xt(e=>e.normalize(t))}function hO(){return Xt(t=>t.trim())}function dO(){return Xt(t=>t.toLowerCase())}function fO(){return Xt(t=>t.toUpperCase())}function pO(){return Xt(t=>Sb(t))}function yO(t,e,r){return new t({type:"array",element:e,...x(r)})}function mO(t,e,r){return new t({type:"custom",check:"custom",fn:e,...x(r)})}function gO(t){const e=wO(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(zr(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(zr(s))}},t(r.value,r)));return e}function wO(t,e){const r=new oe({check:"custom",...x(e)});return r._zod.check=t,r}const bO=p("ZodISODateTime",(t,e)=>{Vv.init(t,e),V.init(t,e)});function vO(t){return Kz(bO,t)}const zO=p("ZodISODate",(t,e)=>{Hv.init(t,e),V.init(t,e)});function OO(t){return Jz(zO,t)}const TO=p("ZodISOTime",(t,e)=>{Wv.init(t,e),V.init(t,e)});function kO(t){return Xz(TO,t)}const SO=p("ZodISODuration",(t,e)=>{Gv.init(t,e),V.init(t,e)});function NO(t){return Qz(SO,t)}const EO=(t,e)=>{Zl.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Pb(t,r)},flatten:{value:r=>Ub(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Ms,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Ms,2)}},isEmpty:{get(){return t.issues.length===0}}})},Oe=p("ZodError",EO,{Parent:Error}),AO=$a(Oe),xO=Ma(Oe),IO=zn(Oe),CO=On(Oe),jO=Db(Oe),$O=Bb(Oe),MO=Fb(Oe),_O=qb(Oe),ZO=Yb(Oe),UO=Vb(Oe),PO=Hb(Oe),RO=Wb(Oe),G=p("ZodType",(t,e)=>(H.init(t,e),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone(It(e,{checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]})),t.clone=(r,n)=>ut(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>AO(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>IO(t,r,n),t.parseAsync=async(r,n)=>xO(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>CO(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>jO(t,r,n),t.decode=(r,n)=>$O(t,r,n),t.encodeAsync=async(r,n)=>MO(t,r,n),t.decodeAsync=async(r,n)=>_O(t,r,n),t.safeEncode=(r,n)=>ZO(t,r,n),t.safeDecode=(r,n)=>UO(t,r,n),t.safeEncodeAsync=async(r,n)=>PO(t,r,n),t.safeDecodeAsync=async(r,n)=>RO(t,r,n),t.refine=(r,n)=>t.check($T(r,n)),t.superRefine=r=>t.check(MT(r)),t.overwrite=r=>t.check(Xt(r)),t.optional=()=>Ji(t),t.nullable=()=>Xi(t),t.nullish=()=>Ji(Xi(t)),t.nonoptional=r=>NT(t,r),t.array=()=>dT(t),t.or=r=>Ua([t,r]),t.and=r=>mT(t,r),t.transform=r=>Qi(t,vT(r)),t.default=r=>TT(t,r),t.prefault=r=>ST(t,r),t.catch=r=>AT(t,r),t.pipe=r=>Qi(t,r),t.readonly=()=>CT(t),t.describe=r=>{const n=t.clone();return en.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return en.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return en.get(t);const n=t.clone();return en.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Jl=p("_ZodString",(t,e)=>{_a.init(t,e),G.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(sO(...n)),t.includes=(...n)=>t.check(oO(...n)),t.startsWith=(...n)=>t.check(cO(...n)),t.endsWith=(...n)=>t.check(lO(...n)),t.min=(...n)=>t.check(hn(...n)),t.max=(...n)=>t.check(Gl(...n)),t.length=(...n)=>t.check(Kl(...n)),t.nonempty=(...n)=>t.check(hn(1,...n)),t.lowercase=n=>t.check(aO(n)),t.uppercase=n=>t.check(iO(n)),t.trim=()=>t.check(hO()),t.normalize=(...n)=>t.check(uO(...n)),t.toLowerCase=()=>t.check(dO()),t.toUpperCase=()=>t.check(fO()),t.slugify=()=>t.check(pO())}),LO=p("ZodString",(t,e)=>{_a.init(t,e),Jl.init(t,e),t.email=r=>t.check(Iz(DO,r)),t.url=r=>t.check(Mz(FO,r)),t.jwt=r=>t.check(Gz(sT,r)),t.emoji=r=>t.check(_z(qO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.uuid=r=>t.check(Wl(fr,r)),t.uuidv4=r=>t.check(Cz(fr,r)),t.uuidv6=r=>t.check(jz(fr,r)),t.uuidv7=r=>t.check($z(fr,r)),t.nanoid=r=>t.check(Zz(YO,r)),t.guid=r=>t.check(Yi(Gi,r)),t.cuid=r=>t.check(Uz(VO,r)),t.cuid2=r=>t.check(Pz(HO,r)),t.ulid=r=>t.check(Rz(WO,r)),t.base64=r=>t.check(Vz(tT,r)),t.base64url=r=>t.check(Hz(rT,r)),t.xid=r=>t.check(Lz(GO,r)),t.ksuid=r=>t.check(Dz(KO,r)),t.ipv4=r=>t.check(Bz(JO,r)),t.ipv6=r=>t.check(Fz(XO,r)),t.cidrv4=r=>t.check(qz(QO,r)),t.cidrv6=r=>t.check(Yz(eT,r)),t.e164=r=>t.check(Wz(nT,r)),t.datetime=r=>t.check(vO(r)),t.date=r=>t.check(OO(r)),t.time=r=>t.check(kO(r)),t.duration=r=>t.check(NO(r))});function ve(t){return xz(LO,t)}const V=p("ZodStringFormat",(t,e)=>{q.init(t,e),Jl.init(t,e)}),DO=p("ZodEmail",(t,e)=>{Uv.init(t,e),V.init(t,e)}),Gi=p("ZodGUID",(t,e)=>{_v.init(t,e),V.init(t,e)}),fr=p("ZodUUID",(t,e)=>{Zv.init(t,e),V.init(t,e)});function BO(t){return Wl(fr,t)}const FO=p("ZodURL",(t,e)=>{Pv.init(t,e),V.init(t,e)}),qO=p("ZodEmoji",(t,e)=>{Rv.init(t,e),V.init(t,e)}),YO=p("ZodNanoID",(t,e)=>{Lv.init(t,e),V.init(t,e)}),VO=p("ZodCUID",(t,e)=>{Dv.init(t,e),V.init(t,e)}),HO=p("ZodCUID2",(t,e)=>{Bv.init(t,e),V.init(t,e)}),WO=p("ZodULID",(t,e)=>{Fv.init(t,e),V.init(t,e)}),GO=p("ZodXID",(t,e)=>{qv.init(t,e),V.init(t,e)}),KO=p("ZodKSUID",(t,e)=>{Yv.init(t,e),V.init(t,e)}),JO=p("ZodIPv4",(t,e)=>{Kv.init(t,e),V.init(t,e)}),XO=p("ZodIPv6",(t,e)=>{Jv.init(t,e),V.init(t,e)}),QO=p("ZodCIDRv4",(t,e)=>{Xv.init(t,e),V.init(t,e)}),eT=p("ZodCIDRv6",(t,e)=>{Qv.init(t,e),V.init(t,e)}),tT=p("ZodBase64",(t,e)=>{ez.init(t,e),V.init(t,e)}),rT=p("ZodBase64URL",(t,e)=>{rz.init(t,e),V.init(t,e)}),nT=p("ZodE164",(t,e)=>{nz.init(t,e),V.init(t,e)}),sT=p("ZodJWT",(t,e)=>{az.init(t,e),V.init(t,e)}),aT=p("ZodNumber",(t,e)=>{Yl.init(t,e),G.init(t,e),t.gt=(n,s)=>t.check(Hi(n,s)),t.gte=(n,s)=>t.check(Kn(n,s)),t.min=(n,s)=>t.check(Kn(n,s)),t.lt=(n,s)=>t.check(Vi(n,s)),t.lte=(n,s)=>t.check(Gn(n,s)),t.max=(n,s)=>t.check(Gn(n,s)),t.int=n=>t.check(dn(n)),t.safe=n=>t.check(dn(n)),t.positive=n=>t.check(Hi(0,n)),t.nonnegative=n=>t.check(Kn(0,n)),t.negative=n=>t.check(Vi(0,n)),t.nonpositive=n=>t.check(Gn(0,n)),t.multipleOf=(n,s)=>t.check(Wi(n,s)),t.step=(n,s)=>t.check(Wi(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null}),iT=p("ZodNumberFormat",(t,e)=>{iz.init(t,e),aT.init(t,e)});function dn(t){return eO(iT,t)}const oT=p("ZodBoolean",(t,e)=>{oz.init(t,e),G.init(t,e)});function Za(t){return tO(oT,t)}const cT=p("ZodUnknown",(t,e)=>{cz.init(t,e),G.init(t,e)});function Ki(){return rO(cT)}const lT=p("ZodNever",(t,e)=>{lz.init(t,e),G.init(t,e)});function uT(t){return nO(lT,t)}const hT=p("ZodArray",(t,e)=>{uz.init(t,e),G.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(hn(r,n)),t.nonempty=r=>t.check(hn(1,r)),t.max=(r,n)=>t.check(Gl(r,n)),t.length=(r,n)=>t.check(Kl(r,n)),t.unwrap=()=>t.element});function dT(t,e){return yO(hT,t,e)}const fT=p("ZodObject",(t,e)=>{dz.init(t,e),G.init(t,e),L(t,"shape",()=>e.shape),t.keyof=()=>Xl(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ki()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ki()}),t.strict=()=>t.clone({...t._zod.def,catchall:uT()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>jb(t,r),t.safeExtend=r=>$b(t,r),t.merge=r=>Mb(t,r),t.pick=r=>Ib(t,r),t.omit=r=>Cb(t,r),t.partial=(...r)=>_b(Ql,t,r[0]),t.required=(...r)=>Zb(eu,t,r[0])});function ne(t,e){const r={type:"object",shape:t??{},...x(e)};return new fT(r)}const pT=p("ZodUnion",(t,e)=>{fz.init(t,e),G.init(t,e),t.options=e.options});function Ua(t,e){return new pT({type:"union",options:t,...x(e)})}const yT=p("ZodIntersection",(t,e)=>{pz.init(t,e),G.init(t,e)});function mT(t,e){return new yT({type:"intersection",left:t,right:e})}const Zs=p("ZodEnum",(t,e)=>{yz.init(t,e),G.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const i={};for(const o of n)if(r.has(o))i[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...x(s),entries:i})},t.exclude=(n,s)=>{const i={...e.entries};for(const o of n)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Zs({...e,checks:[],...x(s),entries:i})}});function Xl(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Zs({type:"enum",entries:r,...x(e)})}const gT=p("ZodLiteral",(t,e)=>{mz.init(t,e),G.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function wT(t,e){return new gT({type:"literal",values:Array.isArray(t)?t:[t],...x(e)})}const bT=p("ZodTransform",(t,e)=>{gz.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Il(t.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(zr(i,r.value,e));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),r.issues.push(zr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(i=>(r.value=i,r)):(r.value=s,r)}});function vT(t){return new bT({type:"transform",transform:t})}const Ql=p("ZodOptional",(t,e)=>{wz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ji(t){return new Ql({type:"optional",innerType:t})}const zT=p("ZodNullable",(t,e)=>{bz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Xi(t){return new zT({type:"nullable",innerType:t})}const OT=p("ZodDefault",(t,e)=>{vz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function TT(t,e){return new OT({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const kT=p("ZodPrefault",(t,e)=>{zz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ST(t,e){return new kT({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():$l(e)}})}const eu=p("ZodNonOptional",(t,e)=>{Oz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function NT(t,e){return new eu({type:"nonoptional",innerType:t,...x(e)})}const ET=p("ZodCatch",(t,e)=>{Tz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function AT(t,e){return new ET({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const xT=p("ZodPipe",(t,e)=>{kz.init(t,e),G.init(t,e),t.in=e.in,t.out=e.out});function Qi(t,e){return new xT({type:"pipe",in:t,out:e})}const IT=p("ZodReadonly",(t,e)=>{Sz.init(t,e),G.init(t,e),t.unwrap=()=>t._zod.def.innerType});function CT(t){return new IT({type:"readonly",innerType:t})}const jT=p("ZodCustom",(t,e)=>{Nz.init(t,e),G.init(t,e)});function $T(t,e={}){return mO(jT,t,e)}function MT(t){return gO(t)}const Re=t=>t?JSON.parse(t):{},Pa=ne({key:ve(),type:ve(),config:ze.unknownZ.or(ve().transform(Re))}),tu=Pa.extend({position:ga.xy}),Us=ne({param:ve(),node:ve()}),Ra=ne({source:Us,target:Us}),_T=ne({nodes:Pa.array(),edges:Ra.array()}),ru=ne({nodes:tu.array(),edges:Ra.array()}),nu=ne({raw:ve()}),Pr=BO(),su=Xl(["graph","text"]).or(wT("").transform(()=>"graph")),kn=ne({key:Pr,name:ve(),graph:ru,text:nu,version:ve(),mode:su}),au=kn.partial({key:!0,mode:!0}),ZT="arc",iu=K("arc"),UT=iu(""),PT=(t,e,{convertNumericStrings:r=!0}={})=>{const n=!Array.isArray(t);let s=O.toArray(t);const i=s[0],o=typeof i;let c;return o==="string"&&r&&!isNaN(parseInt(i))&&"number"in e?(c=e.number,s=s.map(l=>parseInt(l))):c=e[o],{single:n,variant:c,normalized:s,actual:t}},ce=(t,e,r,n)=>{if(n){if(r.length===0)throw new Tt(`${t} not found matching ${JSON.stringify(e)}`);if(r.length>1)throw new cn(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${r.length}`)}},RT="sy_arc_set",LT="sy_arc_delete",DT=ne({keys:Pr.array().optional(),names:ve().array().optional(),searchTerm:ve().optional(),limit:dn().optional(),offset:dn().optional(),includeStatus:Za().optional()}),BT=ne({arcs:au.array()}),FT=ne({keys:Pr.array()}),qT=ne({arcs:O.nullableZ(kn)}),YT=ne({arcs:kn.array()}),VT=ne({}),Ps=ne({content:ve()}),HT=ne({key:Pr,includeStatus:Za().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),WT=ne({name:ve(),includeStatus:Za().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),ou=Ua([HT,WT]),GT=Ua([ou,DT]);let cu=class{client;streamClient;constructor(t,e){this.client=t,this.streamClient=e}async create(t){const e=Array.isArray(t),r=await w(this.client,"/arc/create",{arcs:O.toArray(t)},BT,YT);return e?r.arcs:r.arcs[0]}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/arc/retrieve",t,GT,qT);return ce("Arc",t,r.arcs,e),e?r.arcs[0]:r.arcs}async delete(t){await w(this.client,"/arc/delete",{keys:O.toArray(t)},FT,VT)}async openLSP(){return await this.streamClient.stream("/arc/lsp",Ps,Ps)}};const KT=Object.freeze(Object.defineProperty({__proto__:null,Client:cu,DELETE_CHANNEL_NAME:LT,ONTOLOGY_TYPE:ZT,SET_CHANNEL_NAME:RT,TYPE_ONTOLOGY_ID:UT,arcZ:kn,edgeZ:Ra,graphNodeZ:tu,graphZ:ru,handleZ:Us,irNodeZ:Pa,irZ:_T,keyZ:Pr,lspMessageZ:Ps,modeZ:su,newZ:au,ontologyID:iu,singleRetrieveArgsZ:ou,textZ:nu},Symbol.toStringTag,{value:"Module"})),eo="Channel key must be a valid uint32.",D=a.z.uint32().or(a.z.string().refine(t=>!isNaN(Number(t)),{message:eo}).transform(Number).refine(t=>t<Os.MAX_UINT32,{message:eo})),lu=/^[a-zA-Z_][a-zA-Z0-9_]*$/,Ve=a.z.string().min(1,"Name must not be empty").regex(lu,"Name can only contain letters, digits, and underscores, and cannot start with a digit"),uu=["min","max","avg","none"],hu=a.z.enum(uu),La=a.z.object({type:hu,resetChannel:D.optional(),duration:E.z.optional()}),du=lt.statusZ(),fu=a.z.object({channel:D}),JT=lt.statusZ(fu),XT=t=>Ze(Sn(t)),Qt=a.z.object({name:a.z.string(),key:D,dataType:_.z,leaseholder:_e.uint12,index:D,isIndex:a.z.boolean(),internal:a.z.boolean(),virtual:a.z.boolean(),alias:a.z.string().optional(),expression:a.z.string().default(""),status:du.optional(),operations:O.nullableZ(La)}),pu=Qt.extend({key:D.optional(),name:Ve,leaseholder:_e.uint12.optional(),index:D.optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().default(!1),virtual:a.z.boolean().default(!1),expression:a.z.string().default(""),operations:O.nullableZ(La).optional()}),Ct=a.z.union([_e.toArray(D),_e.toArray(Ve),_e.toArray(Qt).transform(t=>t.map(e=>e.key))]),Sn=K("channel"),QT=Sn(0),ek=/[a-zA-Z0-9_]/,tk=(t,e=!1)=>{if(t==="")return e?"_":"";if(t.match(lu))return t;let r="";for(const n of t)n.match(ek)?r+=n:r+="_";return r[0].match(/^\d/)&&(r=`_${r}`),r},rk=new Error("request for lock canceled");var nk=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class sk{constructor(e,r=rk){this._value=e,this._cancelError=r,this._queue=[],this._weightedWaiters=[]}acquire(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((n,s)=>{const i={resolve:n,reject:s,weight:e,priority:r},o=yu(this._queue,c=>r<=c.priority);o===-1&&e<=this._value?this._dispatchItem(i):this._queue.splice(o+1,0,i)})}runExclusive(e){return nk(this,arguments,void 0,function*(r,n=1,s=0){const[i,o]=yield this.acquire(n,s);try{return yield r(i)}finally{o()}})}waitForUnlock(e=1,r=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,r)?Promise.resolve():new Promise(n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),ak(this._weightedWaiters[e-1],{resolve:n,priority:r})})}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 r=this._value;this._value-=e.weight,e.resolve([r,this._newReleaser(e.weight)])}_newReleaser(e){let r=!1;return()=>{r||(r=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const r=this._weightedWaiters[e-1];r&&(r.forEach(n=>n.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let r=this._value;r>0;r--){const n=this._weightedWaiters[r-1];if(!n)continue;const s=n.findIndex(i=>i.priority<=e);(s===-1?n:n.splice(0,s)).forEach((i=>i.resolve()))}}}_couldLockImmediately(e,r){return(this._queue.length===0||this._queue[0].priority<r)&&e<=this._value}}function ak(t,e){const r=yu(t,n=>e.priority<=n.priority);t.splice(r+1,0,e)}function yu(t,e){for(let r=t.length-1;r>=0;r--)if(e(t[r]))return r;return-1}var ik=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function c(h){try{u(n.next(h))}catch(f){o(f)}}function l(h){try{u(n.throw(h))}catch(f){o(f)}}function u(h){h.done?i(h.value):s(h.value).then(c,l)}u((n=n.apply(t,e||[])).next())})};class ok{constructor(e){this._semaphore=new sk(1,e)}acquire(){return ik(this,arguments,void 0,function*(e=0){const[,r]=yield this._semaphore.acquire(1,e);return r})}runExclusive(e,r=0){return this._semaphore.runExclusive(()=>e(),1,r)}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 ht=rl.keyZ,Rr=rl.labelZ,ck="labeled_by",lk="sy_label_set",uk="sy_label_delete",mu=Rr.extend({key:ht.optional()}),hk=a.object({labels:mu.array()}),dk=a.object({labels:Rr.array()}),fk=a.object({keys:ht.array()}),gu=a.object({id:F,labels:ht.array(),replace:a.boolean().optional()}),pk=gu.omit({replace:!0}),Jn=a.object({}),yk=a.object({keys:ht.array().optional(),names:a.string().array().optional(),for:F.optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional()}),mk=a.object({key:ht}).transform(({key:t})=>({keys:[t]})),gk=a.union([mk,yk]),wk=a.object({labels:O.nullableZ(Rr)});let wu=class{type="label";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/label/retrieve",t,gk,wk);return ce("Label",t,r.labels,e),e?r.labels[0]:r.labels}async label(t,e,r={}){await w(this.client,"/label/set",{id:t,labels:e,replace:r.replace},gu,Jn)}async remove(t,e){await w(this.client,"/label/remove",{id:t,labels:e},pk,Jn)}async create(t){const e=Array.isArray(t),r=await w(this.client,"/label/create",{labels:O.toArray(t)},hk,dk);return e?r.labels:r.labels[0]}async delete(t){await w(this.client,"/label/delete",{keys:O.toArray(t)},fk,Jn)}};const bu=K("label"),bk=bu(""),vk=Object.freeze(Object.defineProperty({__proto__:null,Client:wu,DELETE_CHANNEL_NAME:uk,LABELED_BY_ONTOLOGY_RELATIONSHIP_TYPE:ck,SET_CHANNEL_NAME:lk,TYPE_ONTOLOGY_ID:bk,keyZ:ht,labelZ:Rr,newZ:mu,ontologyID:bu},Symbol.toStringTag,{value:"Module"})),X=a.z.uuid(),Da=a.z.string().min(1),Lr=a.z.object({key:X,name:Da,timeRange:B.z.refine(({isValid:t})=>t,{error:"Time range start time must be before or equal to time range end time"}).refine(({end:t})=>t.valueOf()<=Os.MAX_INT64,{error:"Time range end time must be less than or equal to the maximum value of an int64"}).refine(({start:t})=>t.valueOf()>=Os.MIN_INT64,{error:"Time range start time must be greater than or equal to the minimum value of an int64"}),color:a.z.string().optional(),labels:Rr.array().or(a.z.null().transform(()=>{})).optional(),get parent(){return Lr.optional().nullable().transform(t=>t===void 0?null:t)}}),vu=Lr.omit({parent:!0,labels:!0}).partial({key:!0}),zk=a.z.object({nodeKey:_e.uint12.optional(),keys:D.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),rangeKey:X.optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),dataTypes:_.z.array().optional(),notDataTypes:_.z.array().optional(),virtual:a.z.boolean().optional(),isIndex:a.z.boolean().optional(),internal:a.z.boolean().optional(),legacyCalculated:a.z.boolean().optional()}),Ok=a.z.object({channels:O.nullableZ(Qt)}),Ne=t=>(Array.isArray(t)&&t.length>0&&typeof t[0]=="object"?t=t.map(e=>e.key):typeof t=="object"&&"key"in t&&(t=[t.key]),PT(t,{number:"keys",string:"names"}));class Ba{client;constructor(e){this.client=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.execute(e);const n=Ne(e),{variant:s}=n;let{normalized:i}=n;return s==="keys"&&i.indexOf(0)!==-1&&(i=i.filter(o=>o!==0)),i.length===0?[]:await this.execute({[s]:i,...r})}async execute(e){return(await w(this.client,"/channel/retrieve",e,zk,Ok)).channels}}class Fa{cache;namesToKeys;wrapped;constructor(e){this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async retrieve(e,r){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:n}=Ne(e),s=[],i=[];if(n.forEach(c=>{const l=this.get(c);l!=null?s.push(...l):i.push(c)}),i.length===0)return s;const o=await this.wrapped.retrieve(i,r);return this.set(o),s.concat(o)}delete(e){const{variant:r,normalized:n}=Ne(e);r==="names"?n.forEach(s=>{const i=this.namesToKeys.get(s);i!=null&&(i.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(s))}):n.forEach(s=>{const i=this.cache.get(s);i!=null&&(this.cache.delete(s),this.namesToKeys.delete(i.name))})}rename(e,r){e.forEach((n,s)=>{const i=r[s],o=this.cache.get(n);if(o==null)return;this.cache.delete(n);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(n),c.size===0&&this.namesToKeys.delete(o.name)),o.name=i,this.cache.set(n,o);const l=this.namesToKeys.get(i);l==null?this.namesToKeys.set(i,new Set([n])):l.add(n)})}set(e){e.forEach(r=>{this.cache.set(r.key,r);const n=this.namesToKeys.get(r.name);n==null?this.namesToKeys.set(r.name,new Set([r.key])):n.add(r.key)})}get(e){if(typeof e=="number"){const s=this.cache.get(e);return s==null?void 0:[s]}const r=this.namesToKeys.get(e);if(r==null)return;const n=[];if(r.forEach(s=>{const i=this.cache.get(s);i!=null&&n.push(i)}),n.length!==0)return n}}class zu{mu=new ok;requests=new Map;wrapped;debouncedRun;constructor(e,r){this.wrapped=e,this.debouncedRun=eg(()=>{this.run()},r)}async retrieve(e){if(!Array.isArray(e)&&typeof e=="object")return await this.wrapped.retrieve(e);const{normalized:r,variant:n}=Ne(e);return n==="names"?await this.wrapped.retrieve(r):await new Promise((s,i)=>{this.mu.runExclusive(()=>{this.requests.set(r,{resolve:s,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((r,n)=>n.forEach(s=>e.add(s)));try{const r=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(r.filter(i=>s.includes(i.key))))}catch(r){this.requests.forEach(n=>n.reject(r))}finally{this.requests.clear()}})}}const Ou=async(t,e)=>{const{normalized:r}=Ne(e),n=await t.retrieve(r),s=[];if(r.forEach(i=>{n.find(o=>o.name===i||o.key===i)==null&&s.push(i)}),s.length>0)throw new ot(`Could not find channels: ${JSON.stringify(s)}`);return n},Tk="sy_channel_set",kk="sy_channel_delete";class Rs{_frameClient;key;name;dataType;leaseholder;index;isIndex;internal;alias;virtual;expression;operations;status;constructor({dataType:e,name:r,leaseholder:n=0,key:s=0,isIndex:i=!1,index:o=0,internal:c=!1,virtual:l=!1,frameClient:u,alias:h,status:f,expression:d="",operations:z=[]}){this.key=D.parse(s),this.name=r,this.dataType=new _(e),this.leaseholder=n,this.index=D.parse(o),this.isIndex=i,this.internal=c,this.alias=h,this.virtual=l,this.expression=d,this.operations=z,f!=null&&(this.status=lt.create(f)),this._frameClient=u??null}get framer(){if(this._frameClient==null)throw new W("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Qt.parse({key:this.key,name:this.name,dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal,virtual:this.virtual,expression:this.expression,status:this.status,operations:this.operations})}get isCalculated(){return ku(this.payload)}get ontologyID(){return Sn(this.key)}async read(e){return await this.framer.read(e,this.key)}async write(e,r){return await this.framer.write(e,this.key,r)}}const Sk=a.z.object({}),Nk=a.z.object({group:bn});let Tu=class{frameClient;client;retriever;writer;constructor(t,e,r,n){this.frameClient=t,this.retriever=e,this.client=r,this.writer=n}async create(t,e={}){const{retrieveIfNameExists:r=!1}=e,n=!Array.isArray(t);let s=O.toArray(t),i=[];if(r){const o=await this.retriever.retrieve(s.map(l=>l.name)),c=new Set(o.map(l=>l.name));s=s.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(s))),n?i[0]:i}async retrieve(t,e){if(typeof t=="object"&&!Array.isArray(t))return this.sugar(await this.retriever.retrieve(t));const r=!Array.isArray(t),n=this.sugar(await this.retriever.retrieve(t,e));return ce("channel",t,n,r),r?n[0]:n}async delete(t){const{normalized:e,variant:r}=Ne(t);return r==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(O.toArray(t),O.toArray(e))}createDebouncedBatchRetriever(t=10){return new Fa(new zu(new Ba(this.client),t))}sugar(t){const{frameClient:e}=this;return Array.isArray(t)?t.map(r=>new Rs({...r,frameClient:e})):new Rs({...t,frameClient:e})}async retrieveGroup(){return(await w(this.client,"/channel/retrieve-group",{},Sk,Nk)).group}};const ku=({virtual:t,expression:e})=>t&&e!=="",Ek=a.z.object({channels:pu.array()}),Ak=a.z.object({channels:Qt.array()}),xk=a.z.object({keys:D.array().optional(),names:Ve.array().optional()}),Ik=a.z.object({}),Ck=a.z.object({keys:D.array(),names:Ve.array()}),jk=a.z.object({});let Su=class{client;cache;constructor(t,e){this.client=t,this.cache=e}async create(t){const{channels:e}=await w(this.client,"/channel/create",{channels:t.map(r=>({...r,dataType:r.dataType}))},Ek,Ak);return this.cache.set(e),e}async delete(t){const e=D.array().parse(t.keys??[]);await w(this.client,"/channel/delete",t,xk,Ik),e.length>0&&this.cache.delete(e),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await w(this.client,"/channel/rename",{keys:t,names:e},Ck,jk),this.cache.rename(t,e)}};const $k=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Fa,Channel:Rs,Client:Tu,ClusterRetriever:Ba,DELETE_CHANNEL_NAME:kk,DebouncedBatchRetriever:zu,OPERATION_TYPES:uu,SET_CHANNEL_NAME:Tk,TYPE_ONTOLOGY_ID:QT,Writer:Su,analyzeParams:Ne,calculationStatusDetailsZ:fu,calculationStatusZ:JT,escapeInvalidName:tk,isCalculated:ku,keyZ:D,nameZ:Ve,newZ:pu,ontologyID:Sn,operationType:hu,operationZ:La,paramsZ:Ct,payloadZ:Qt,retrieveRequired:Ou,statusKey:XT,statusZ:du},Symbol.toStringTag,{value:"Module"})),Mk=a.z.object({username:a.z.string(),password:a.z.string()}),_k=a.z.object({token:a.z.string(),user:Ur}),to="/auth/login",Zk=3,Uk=a.z.object({username:a.z.string(),password:a.z.string(),newPassword:a.z.string().min(1)}),Pk=a.z.object({}),Rk=[Cs,js];let Lk=class{client;credentials;authState={authenticated:!1};authenticating;retryCount;constructor(t,e){this.client=t,this.credentials=e,this.retryCount=0}get authenticated(){return this.authState.authenticated}get user(){return this.authState.authenticated?this.authState.user:void 0}get token(){return this.authState.authenticated?this.authState.token:void 0}async retrieveUser(){this.authState.authenticated||await this.authenticating;const{authState:t}=this;if(!t.authenticated)throw new Error("Authentication failed: user not available");return t.user}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await w(this.client,"/auth/change-password",{username:this.credentials.username,password:this.credentials.password,newPassword:t},Uk,Pk),this.credentials.password=t}middleware(){const t=async(e,r)=>{if(!this.authenticated&&!e.target.endsWith(to)){this.authenticating??=new Promise((o,c)=>{this.client.send(to,this.credentials,Mk,_k).then(([l,u])=>{if(u!=null)return o(u);if(l==null)return o(new Error("No response from login"));this.authState={authenticated:!0,user:l.user,token:l.token},o(null)}).catch(c)});const i=await this.authenticating;if(i!=null)return[e,i]}e.params.Authorization=`Bearer ${this.token}`;const[n,s]=await r(e);return Rk.some(i=>i.matches(s))&&this.retryCount<Zk?(this.authState={authenticated:!1},this.authenticating=void 0,this.retryCount+=1,t(e,r)):(this.retryCount=0,[n,s])};return t}};const Dk=a.z.enum(["disconnected","connecting","connected","failed"]),Bk=a.z.object({status:Dk,error:a.z.instanceof(Error).optional(),message:a.z.string().optional(),clusterKey:a.z.string(),clientVersion:a.z.string(),clientServerCompatible:a.z.boolean(),nodeVersion:a.z.string().optional()}),Fk=a.z.object({clusterKey:a.z.string(),nodeVersion:a.z.string().optional()}),qk=a.z.void(),ro={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.50.0"},no=(t,e,r)=>{const n=r?"Core":"client";return`Synnax Core version ${t!=null?`${t} `:""}is too ${r?"old":"new"} for client version ${e}.
|
|
41
41
|
This may cause compatibility issues. We recommend updating the ${n}. For more information, see
|
|
42
42
|
https://docs.synnaxlabs.com/reference/client/resources/troubleshooting#old-${n}-version`};class Ls{static DEFAULT=ro;_state;pollFrequency=E.seconds(30);client;name;interval;clientVersion;onChangeHandlers=[];static connectionStateZ=Bk;versionWarned=!1;constructor(e,r=E.seconds(30),n,s){this._state={...ro},this.client=e,this.pollFrequency=r,this.clientVersion=n,this.name=s,this.check(),this.start()}stop(){this.interval!=null&&clearInterval(this.interval)}async check(){const e=this._state.status;try{const r=await w(this.client,"/connectivity/check",void 0,qk,Fk),n=r.nodeVersion,s=this.clientVersion,i=this.versionWarned;n==null?(this._state.clientServerCompatible=!1,i||(console.warn(no(null,s,!0)),this.versionWarned=!0)):Ai.versionsEqual(s,n,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,i||(console.warn(no(n,s,Ai.semVerNewer(s,n))),this.versionWarned=!0)),this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=r.clusterKey,this._state.nodeVersion=r.nodeVersion,this._state.clientVersion=this.clientVersion}catch(r){this._state.status="failed",this._state.error=r,this._state.message=this.state.error?.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}start(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}}const Yk=a.z.object({keys:D.array().optional(),bounds:B.z,names:Ve.array().optional()}),Vk=a.z.object({});class Hk{client;constructor(e){this.client=e}async delete(e){await w(this.client,"/frame/delete",e,Yk,Vk)}}const so=t=>{const e=O.toArray(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ao=(t,e)=>{const r=O.toArray(t);if(r.length===e.length)return;const n=so(t);throw so===null?new W("[Frame] - channel keys or names must be provided when constructing a frame."):new W(`[Frame] - ${n}s and series must be the same length.
|
|
43
43
|
Got ${r.length} ${n}s and ${e.length} series.`)};let ue=class ft{columns=[];series=[];constructor(e=[],r=[]){if(e instanceof ft){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,s)=>this.push(s,...O.toArray(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e;n.series??=[],n.keys??=[];const s=n.series.map(i=>Nu(i));ao(n.keys,s),n.keys.forEach((i,o)=>this.push(i,s[o]))}else Object.entries(e).forEach(([n,s])=>{const i=parseInt(n);if(!isNaN(i))return this.push(i,...O.toArray(s));this.push(n,...O.toArray(s))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=O.toArray(r),s=O.toArray(e);ao(s,n),n.forEach((i,o)=>this.push(s[o],i));return}throw new W(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
`:`
|
|
65
65
|
`,s=new TextEncoder;let i=!1,o=!1;const c=aS(e),{columns:l,columnsByIndexKey:u,emptyGroupStrings:h}=iS(e,c,r);let f=[],d=0,z=[];const I=b=>{for(const[v]of c){const S=b.get(v);if(S.length===0)continue;const U=(u.get(v)??[]).map(P=>b.get(P.key));for(let P=0;P<S.length;P++){const de=S.at(P,!0),fe=U.map(pe=>Ei.formatValue(pe.at(P,!0)));z.push({time:de,values:fe,indexKey:v})}}},j=(b,v=!1)=>{z.length>0&&(z.sort((P,de)=>Number(P.time-de.time)),d>0&&(f=f.slice(d),d=0),f=oS(f,z),z=[]);const S=[],U=f.length;for(;d<U&&S.length<b;){const P=f[d].time;if(!v&&f[U-1].time===P)break;const de=new Map;for(;d<U&&f[d].time===P;){const pe=f[d++];de.set(pe.indexKey,pe)}const fe=[];for(const[pe]of c){const De=de.get(pe);fe.push(De?.values.join(",")??h.get(pe)??"")}S.push(fe.join(","))}return S};return new ReadableStream({async pull(b){try{if(o||(await t.seekFirst(),o=!0),!i){const S=l.map(U=>Ei.formatValue(U.header)).join(",");b.enqueue(s.encode(`${S}${n}`)),i=!0}f.length-d+z.length<po&&await t.next()&&I(t.value);const v=j(po);if(v.length>0&&b.enqueue(s.encode(`${v.join(n)}${n}`)),f.length-d===0||z.length===0){if(!await t.next()){const S=j(1/0,!0);S.length>0&&b.enqueue(s.encode(`${S.join(n)}${n}`)),await t.close(),b.close();return}I(t.value)}}catch(v){await t.close(),b.error(v)}},async cancel(){await t.close()}})},aS=t=>{const e=new Map;for(const r of t){if(r.index===0)continue;let n=e.get(r.index);n==null&&(n=[r.index],e.set(r.index,n)),!r.isIndex&&!n.includes(r.key)&&n.push(r.key)}return e},iS=(t,e,r)=>{const n=new Map(t.map(c=>[c.key,c])),s=[],i=new Map,o=new Map;for(const[c,l]of e){const u=[];for(const h of l){const f=n.get(h);if(f==null)throw new ie(`Channel ${h} not found`);const d={key:h,header:r?.[h]??r?.[f.name]??f.name};s.push(d),u.push(d)}i.set(c,u),o.set(c,",".repeat(u.length-1))}return{columns:s,columnsByIndexKey:i,emptyGroupStrings:o}},oS=(t,e)=>{const r=[];let n=0,s=0;for(;n<t.length&&s<e.length;)t[n].time<=e[s].time?r.push(t[n++]):r.push(e[s++]);return r.push(...t.slice(n),...e.slice(s)),r},po=1e3,cS=a.z.object({keys:a.z.number().array(),downsampleFactor:a.z.int(),throttleRate:vt.z.optional()}),lS=a.z.object({frame:Nn}),yo=a.z.object({channels:Ct,downsampleFactor:a.z.int().default(1),throttleRate:vt.z.default(new vt(0)),useHighPerformanceCodec:a.z.boolean().default(!0)}),Ha=yo.or(Ct.transform(t=>yo.parse({channels:t}))),$u=(t,e)=>async r=>{const n=Ha.parse(r),s=await En.open(t,n.channels);n.useHighPerformanceCodec&&(e=e.withCodec(new eS(s.codec)));const i=await e.stream("/frame/stream",cS,lS),o=new uS(i,s,n.downsampleFactor,n.throttleRate);i.send({keys:Array.from(s.keys),downsampleFactor:n.downsampleFactor,throttleRate:n.throttleRate});const[,c]=await i.receive();if(c!=null)throw c;return o},Mu=async(t,e,r)=>await $u(t,e)(r);class uS{stream;adapter;downsampleFactor;throttleRate;constructor(e,r,n=1,s=new vt(0)){this.stream=new Iu("Streamer",e),this.adapter=r,this.downsampleFactor=n,this.throttleRate=s}get keys(){return Array.from(this.adapter.keys)}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Ee.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ue((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e)&&this.stream.send({keys:Array.from(this.adapter.keys),downsampleFactor:this.downsampleFactor,throttleRate:this.throttleRate})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class An{wrapped_=null;breaker;opener;config;constructor(e,r,n={}){this.opener=e,this.config=Ha.parse(r);const{maxRetries:s=5e3,baseInterval:i=E.seconds(1),scale:o=1}=n??{};this.breaker=new va.Breaker({maxRetries:s,baseInterval:i,scale:o})}static async open(e,r,n){const s=new An(e,r,n);return await s.runStreamer(),s}async runStreamer(){for(;;)try{this.wrapped_!=null&&this.wrapped_.close(),this.wrapped_=await this.opener(this.config),this.breaker.reset();return}catch(e){if(this.wrapped_=null,!await this.breaker.wait())throw e;console.error("failed to open streamer",e);continue}}get wrapped(){if(this.wrapped_==null)throw new Error("stream closed");return this.wrapped_}async update(e){this.config.channels=Ct.parse(e);try{await this.wrapped.update(e)}catch{return await this.runStreamer(),await this.update(e)}}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(Ee.matches(e))return{done:!0,value:void 0};throw e}}async read(){try{const e=await this.wrapped.read();return this.breaker.reset(),e}catch(e){if(Ee.matches(e))throw e;return await this.runStreamer(),await this.read()}}close(){this.wrapped.close()}get keys(){return this.wrapped.keys}[Symbol.asyncIterator](){return this}}class _u extends Ng.Observer{streamer;closePromise;constructor(e,r){super(r),this.streamer=e,this.closePromise=this.stream()}async update(e){await this.streamer.update(e)}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var Or=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Or||{});const hS=new E(-1);class Ds extends Ue.sub("writer_closed"){constructor(){super("WriterClosed")}}const dS=a.z.enum(Or).or(a.z.enum(["persist","stream","persistStream"]).transform(t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1}})),Zu=a.z.object({start:C.z.optional(),controlSubject:be.subjectZ.optional(),authorities:a.z.union([be.authorityZ.transform(t=>[t]),be.authorityZ.array()]).default([be.ABSOLUTE_AUTHORITY]),mode:dS.default(1),errOnUnauthorized:a.z.boolean().default(!1),enableAutoCommit:a.z.boolean().default(!0),autoIndexPersistInterval:E.z.default(E.SECOND),useHighPerformanceCodec:a.z.boolean().default(!0)}),fS=Zu.extend({keys:D.array().optional()}),mo=Zu.extend({channels:Ct}),Uu=mo.or(Ct.transform(t=>mo.parse({channels:t,start:C.now()}))),pS=a.z.object({command:a.z.enum(Me),config:fS.optional(),frame:Nn.optional(),buffer:a.z.instanceof(Uint8Array).optional()}),yS=a.z.object({command:a.z.enum(Me),end:C.z,err:He.payloadZ.optional()}),mS=a.z.tuple([a.z.union([a.z.record(D.or(Ve),be.authorityZ),D.or(Ve),be.authorityZ]),be.authorityZ.optional()]).transform(([t,e])=>{if(be.authorityZ.safeParse(t).success)return{keys:[],authorities:[t]};if(D.or(Ve).safeParse(t).success){if(e==null)throw new Error("authority is required when setting authority for a single channel");return{keys:[t],authorities:[e]}}const r=t;return{keys:Object.keys(r),authorities:Object.values(r)}});let Pu=class Ru{stream;adapter;closeErr=null;constructor(e,r){this.stream=e,this.adapter=r}static async _open(e,r,n){const s=Uu.parse(n),i=await Ya.open(e,s.channels);s.useHighPerformanceCodec&&(r=r.withCodec(new Qk(i.codec)));const o=await r.stream("/frame/write",pS,yS),c=new Ru(o,i);return await c.execute({command:Me.Open,config:{...s,keys:i.keys}}),c}async write(e,r){if(this.closeErr!=null)throw this.closeErr;if(this.stream.received())return await this.close();const n=await this.adapter.adapt(e,r);this.stream.send({command:Me.Write,frame:n.toPayload()})}async setAuthority(e,r){if(this.closeErr!=null)throw this.closeErr;const n=mS.parse([e,r]),s={keys:await this.adapter.adaptParams(n.keys),authorities:n.authorities};await this.execute({command:Me.SetAuthority,config:s})}async commit(){if(this.closeErr!=null)throw this.closeErr;return this.stream.received()?(await this.closeInternal(null),C.ZERO):(await this.execute({command:Me.Commit})).end}async close(){await this.closeInternal(null)}async closeInternal(e){if(this.closeErr!=null)throw this.closeErr;for(this.closeErr=e,this.stream.closeSend();;){if(this.closeErr!=null){if(Ds.matches(this.closeErr))return null;throw this.closeErr}const[r,n]=await this.stream.receive();n!=null?this.closeErr=Ee.matches(n)?new Ds:n:this.closeErr=He.decode(r?.err)}}async execute(e){const r=this.stream.send(e);for(r!=null&&await this.closeInternal(r);;){const[n,s]=await this.stream.receive();s!=null&&await this.closeInternal(s);const i=He.decode(n?.err);if(i!=null&&await this.closeInternal(i),n?.command==e.command)return n}}};const Lu=K("framer"),gS=Lu("");let Du=class{streamClient;retriever;deleter;reader;constructor(t,e,r){this.streamClient=t,this.retriever=r,this.deleter=new Hk(e),this.reader=new ju(r,t)}async openIterator(t,e,r){return await Dr._open(t,e,this.retriever,this.streamClient,r)}async openWriter(t){return await Pu._open(this.retriever,this.streamClient,t)}async openStreamer(t){return await Mu(this.retriever,this.streamClient,t)}async write(t,e,r){if(r==null){const s=e,i=await this.openWriter({start:t,channels:Object.keys(s),mode:Or.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:E.MAX});return await i.write(s),await i.close()}const n=await this.openWriter({start:t,channels:e,mode:Or.Persist,errOnUnauthorized:!0,autoIndexPersistInterval:E.MAX});await n.write(e,r),await n.close()}async read(t,e){if(!("start"in t))return this.reader.read(t);const{single:r}=Ne(e),n=await this.readFrame(t,e);return r?n.get(e):n}async readFrame(t,e){const r=await this.openIterator(t,e),n=new ue;try{for await(const s of r)n.push(s)}finally{await r.close()}return n}async readLatest(t,e=1){const{single:r}=Ne(t),n=await this.readLatestNFrame(t,e);return r?n.get(t):n}async readLatestNFrame(t,e){const r=await this.openIterator(B.MAX,t,{chunkSize:e}),n=new ue;if(e>0)try{await r.seekLast(),await r.prev(fn),n.push(r.value)}finally{await r.close()}return n}async delete(t,e){const{normalized:r,variant:n}=Ne(t),s=new B(e);return n==="keys"?await this.deleter.delete({keys:r,bounds:s}):await this.deleter.delete({names:r,bounds:s})}};const wS=Object.freeze(Object.defineProperty({__proto__:null,ALWAYS_INDEX_PERSIST_ON_AUTO_COMMIT:hS,AUTO_SPAN:fn,Client:Du,Frame:ue,HardenedStreamer:An,Iterator:Dr,ObservableStreamer:_u,Reader:ju,TYPE_ONTOLOGY_ID:gS,Writer:Pu,WriterClosedError:Ds,WriterCommand:Me,WriterMode:Or,createStreamOpener:$u,frameZ:Nn,ontologyID:Lu,openStreamer:Mu,seriesFromPayload:Nu,seriesToPayload:Eu,streamerConfigZ:Ha,writerConfigZ:Uu},Symbol.toStringTag,{value:"Module"})),bS=be.ABSOLUTE_AUTHORITY,vS=be.ZERO_AUTHORITY,zS=be.stateZ(a.z.number()),OS=t=>t.to==null?`${t.from?.resource} - ${t.from?.subject.name} -> released`:t.from==null?`${t.to.resource} - released -> ${t.to.subject.name} (${t.to.authority.toString()})`:`${t.to.resource} - ${t.from.subject.name} -> ${t.to.subject.name} (${t.to.authority.toString()})`,TS=a.z.object({transfers:a.z.array(be.transferZ(D))});class Bu extends _u{states;codec;constructor(e){super(e,r=>{const n=this.codec.decode(r.series[0].buffer,TS);return this.merge(n),[n.transfers,!0]}),this.states=new Map,this.codec=new Nt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(r=>e.set(r.subject.key,r.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(r=>{r.from==null&&r.to==null&&console.warn("Invalid transfer: ",r),r.to==null?this.states.delete(r.from.resource):this.states.set(r.to.resource,r.to)})}}const Fu="sy_node_1_control";let qu=class{framer;constructor(t){this.framer=t}async openStateTracker(){const t=await An.open(async e=>await this.framer.openStreamer(e),Fu);return new Bu(t)}};const kS=Object.freeze(Object.defineProperty({__proto__:null,ABSOLUTE_AUTHORITY:bS,CONTROL_STATE_CHANNEL_NAME:Fu,Client:qu,StateTracker:Bu,ZERO_AUTHORITY:vS,stateZ:zS,transferString:OS},Symbol.toStringTag,{value:"Module"})),Ae=a.z.uint32(),Yu=a.z.object({rack:Ae}),Vu=lt.statusZ(Yu),xn=a.z.object({key:Ae,name:a.z.string(),status:_e.nullToUndefined(Vu)}),Hu=xn.partial({key:!0}),Wu=t=>t?Nt.JSON_CODEC.decodeString(t,ze.unknownZ):{},er=a.z.string(),Gu=a.z.object({rack:Ae,device:er}),Ku=lt.statusZ(Gu),In=a.z.object({key:er,rack:Ae.min(1,"Must select a location to connect from"),name:a.z.string().min(1,"Name is required"),make:a.z.string().min(1,"Make is required"),model:a.z.string().min(1,"Model is required"),location:a.z.string().min(1,"Location is required"),configured:a.z.boolean().optional(),properties:ze.unknownZ.or(a.z.string().transform(Wu)),status:_e.nullToUndefined(Ku)}),Ju=In.extend({properties:a.z.unknown().transform(t=>Nt.JSON_CODEC.encodeString(t))}),SS="sy_device_set",NS="sy_device_delete",ES=a.z.object({devices:Ju.array()}),AS=a.z.object({devices:In.array()}),xS=a.z.object({keys:er.array()}),IS=a.z.object({}),CS=a.z.object({keys:er.array().optional(),names:a.z.string().array().optional(),makes:a.z.string().array().optional(),models:a.z.string().array().optional(),locations:a.z.string().array().optional(),racks:Ae.array().optional(),searchTerm:a.z.string().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),jS=a.z.object({devices:O.nullableZ(In)}),$S=a.z.object({key:er,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),MS=a.z.union([$S,CS]);let Xu=class{client;constructor(t){this.client=t}async retrieve(t){const e=typeof t=="object"&&"key"in t,r=await w(this.client,"/device/retrieve",t,MS,jS);ce("Device",t,r.devices,e);const n=r.devices;return e?n[0]:n}async create(t){const e=!Array.isArray(t),r=(await w(this.client,"/device/create",{devices:O.toArray(t)},ES,AS)).devices;return e?r[0]:r}async delete(t){await w(this.client,"/device/delete",{keys:O.toArray(t)},xS,IS)}};const Wa=K("device"),_S=Wa(""),ZS=t=>Ze(Wa(t)),US=Object.freeze(Object.defineProperty({__proto__:null,Client:Xu,DELETE_CHANNEL_NAME:NS,SET_CHANNEL_NAME:SS,TYPE_ONTOLOGY_ID:_S,deviceZ:In,keyZ:er,newZ:Ju,ontologyID:Wa,statusDetailsZ:Gu,statusKey:ZS,statusZ:Ku},Symbol.toStringTag,{value:"Module"})),PS="sy_rack_set",RS="sy_rack_delete",LS=a.z.object({keys:Ae.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),embedded:a.z.boolean().optional(),hostIsNode:a.z.boolean().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeStatus:a.z.boolean().optional()}),DS=a.z.object({racks:O.nullableZ(xn)}),BS=a.z.union([a.z.object({key:Ae,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e}))]),FS=LS,qS=a.z.union([BS,FS]),YS=a.z.object({racks:Hu.array()}),VS=a.z.object({racks:xn.array()}),HS=a.z.object({keys:Ae.array()}),WS=a.z.object({});let Qu=class{client;tasks;constructor(t,e){this.client=t,this.tasks=e}async delete(t){await w(this.client,"/rack/delete",{keys:O.toArray(t)},HS,WS)}async create(t){const e=!Array.isArray(t),r=await w(this.client,"/rack/create",{racks:O.toArray(t)},YS,VS),n=this.sugar(r.racks);return e?n[0]:n}async retrieve(t){const e="key"in t||"name"in t,r=await w(this.client,"/rack/retrieve",t,qS,DS),n=this.sugar(r.racks);return ce("Rack",t,n,e),e?n[0]:n}sugar(t){const e=!Array.isArray(t),r=O.toArray(t).map(({key:n,name:s,status:i})=>new eh(n,s,this.tasks,i));return e?r[0]:r}};class eh{key;name;status;tasks;constructor(e,r,n,s){this.key=e,this.name=r,this.tasks=n,this.status=s}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async createTask(e,r){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e,r)}async deleteTask(e){await this.tasks.delete([e])}get payload(){return{key:this.key,name:this.name,status:this.status}}}const Ga=K("rack"),GS=Ga(0),KS=t=>Ze(Ga(t)),JS=Object.freeze(Object.defineProperty({__proto__:null,Client:Qu,DELETE_CHANNEL_NAME:RS,Rack:eh,SET_CHANNEL_NAME:PS,TYPE_ONTOLOGY_ID:GS,keyZ:Ae,newZ:Hu,ontologyID:Ga,rackZ:xn,statusDetailsZ:Yu,statusKey:KS,statusZ:Vu},Symbol.toStringTag,{value:"Module"})),XS="sy_range_alias_set",QS="sy_range_alias_delete",e0=a.z.object({range:X,aliases:a.z.string().array()}),t0=a.z.object({aliases:a.z.record(a.z.string(),D)}),r0=a.z.object({range:X,aliases:a.z.record(D,a.z.string())}),n0=a.z.unknown(),s0=a.z.object({range:X,channels:D.array()}),a0=a.z.unknown(),i0=a.z.object({range:X}),o0=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())}),c0=a.z.object({range:X,channels:D.array()}),l0=a.z.object({aliases:a.z.record(a.z.string(),a.z.string())});class pt{cache=new Map;client;rangeKey;constructor(e,r){this.rangeKey=e,this.cache=new Map,this.client=r}async resolve(e){const r=[],n=typeof e=="string",s={};if(n){const o=this.cache.get(e);if(o!=null)return o;r.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?s[o]=c:r.push(o)});if(r.length===0)return s;const i=await w(this.client,"/range/alias/resolve",{range:this.rangeKey,aliases:r},e0,t0);return Object.entries(i.aliases).forEach(([o,c])=>this.cache.set(o,c)),n?i.aliases[r[0]]:{...s,...i.aliases}}async set(e){await w(this.client,"/range/alias/set",{range:this.rangeKey,aliases:e},r0,n0)}async list(){return(await w(this.client,"/range/alias/list",{range:this.rangeKey},i0,o0)).aliases}async retrieve(e){const r=typeof e=="number",n=await w(this.client,"/range/alias/retrieve",{range:this.rangeKey,channels:O.toArray(e)},c0,l0);return r?n.aliases[e]:n.aliases}async delete(e){await w(this.client,"/range/alias/delete",{range:this.rangeKey,channels:O.toArray(e)},s0,a0)}}const u0=a.z.object({alias:a.z.string().optional(),channel:D,range:X}),th="---",h0=t=>`${t.range}${th}${t.channel}`,d0=t=>{const[e,r]=t.split(th);return{range:e,channel:Number(r)}},f0="sy_range_kv_set",p0="sy_range_kv_delete",Ka=a.z.object({range:X,key:a.z.string(),value:a.z.string()}),y0=({range:t,key:e})=>`${t}<--->${e}`,m0=a.z.object({range:X,keys:a.z.string().array()}),g0=a.z.object({pairs:O.nullableZ(Ka)}),w0=a.z.object({range:X,pairs:Ka.array()}),b0=a.z.object({range:X,keys:a.z.string().array()});class Bs{rangeKey;client;constructor(e,r){this.rangeKey=e,this.client=r}async get(e){const r=await w(this.client,"/range/kv/get",{range:this.rangeKey,keys:O.toArray(e)},m0,g0);return typeof e=="string"?r.pairs[0].value:Object.fromEntries(r.pairs.map(n=>[n.key,n.value]))}async list(){return this.get([])}async set(e,r=""){let n;typeof e=="string"?n=[{range:this.rangeKey,key:e,value:r}]:n=Object.entries(e).map(([s,i])=>({range:this.rangeKey,key:s,value:i})),await w(this.client,"/range/kv/set",{range:this.rangeKey,pairs:n},w0,a.z.unknown())}async delete(e){await w(this.client,"/range/kv/delete",{range:this.rangeKey,keys:O.toArray(e)},b0,a.z.unknown())}}const v0="sy_range_set",z0="sy_range_delete";class rh{key;name;kv;timeRange;color;parent;labels;channels;aliaser;frameClient;labelClient;ontologyClient;rangeClient;constructor({name:e,timeRange:r=B.ZERO,key:n,color:s,parent:i,labels:o},{frameClient:c,kv:l,aliaser:u,channels:h,labelClient:f,ontologyClient:d,rangeClient:z}){this.key=n,this.name=e,this.timeRange=r,this.parent=i,this.labels=o,this.frameClient=c,this.color=s,this.kv=l,this.aliaser=u,this.channels=h,this.labelClient=f,this.ontologyClient=d,this.rangeClient=z}get ontologyID(){return yt(this.key)}get payload(){let e=null;return this.parent!=null&&("payload"in this.parent?e=this.parent.payload:e=this.parent),{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color,labels:this.labels,parent:e}}async setAlias(e,r){const n=await this.channels.retrieve(e);if(n.length===0)throw new ot(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:r})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async resolveAlias(e){return await this.aliaser.resolve(e)}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(r=>r.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async retrieveLabels(){return await this.labelClient.retrieve({for:yt(this.key)})}async addLabel(...e){await this.labelClient.label(yt(this.key),e)}async removeLabel(...e){await this.labelClient.remove(yt(this.key),e)}static sort(e,r){return B.sort(e.timeRange,r.timeRange)}}const O0=a.z.object({keys:X.array().optional(),names:a.z.string().array().optional(),searchTerm:a.z.string().optional(),overlapsWith:B.z.optional(),hasLabels:ht.array().optional(),limit:a.z.int().optional(),offset:a.z.int().optional(),includeLabels:a.z.boolean().optional(),includeParent:a.z.boolean().optional()}),T0=O0.or(X.array().transform(t=>({keys:t}))).or(X.transform(t=>({keys:[t]}))).or(a.z.string().transform(t=>({names:[t]}))).or(a.z.string().array().transform(t=>({names:t}))).or(B.z.transform(t=>({overlapsWith:t}))),k0=a.z.object({ranges:O.nullableZ(Lr)});let nh=class{type="range";frameClient;writer;unaryClient;channels;labelClient;ontologyClient;constructor(t,e,r,n,s,i){this.frameClient=t,this.writer=e,this.unaryClient=r,this.channels=n,this.labelClient=s,this.ontologyClient=i}async create(t,e){const r=!Array.isArray(t),n=this.sugarMany(await this.writer.create(O.toArray(t),e));return r?n[0]:n}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(O.toArray(t))}async retrieve(t){const e=typeof t=="string",{ranges:r}=await w(this.unaryClient,"/range/retrieve",t,T0,k0);return ce("Range",t,r,e),e?this.sugarMany(r)[0]:this.sugarMany(r)}getKV(t){return new Bs(t,this.unaryClient)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents(yt(t));if(e.length===0)return null;const r=e[0];return r.id.type!=="range"?null:await this.retrieve(r.id.key)}sugarOntologyResource(t){return this.sugarOne(sh(t))}async retrieveAlias(t,e){return await new pt(t,this.unaryClient).retrieve(e)}async retrieveAliases(t,e){return await new pt(t,this.unaryClient).retrieve(e)}async listAliases(t){return await new pt(t,this.unaryClient).list()}async setAlias(t,e,r){await new pt(t,this.unaryClient).set({[e]:r})}async deleteAlias(t,e){await new pt(t,this.unaryClient).delete(e)}sugarOne(t){return new rh(t,{frameClient:this.frameClient,kv:new Bs(t.key,this.unaryClient),aliaser:new pt(t.key,this.unaryClient),channels:this.channels,labelClient:this.labelClient,ontologyClient:this.ontologyClient,rangeClient:this})}sugarMany(t){return t.map(e=>this.sugarOne(e))}resourceToRange(t){return this.sugarOne({key:t.id.key,name:t.data?.name,timeRange:new B(t.data?.timeRange),color:t.data?.color,labels:[],parent:null})}};const yt=K("range"),S0=yt(""),N0=t=>({type:"range-alias",key:t}),sh=({data:t,id:{key:e},name:r})=>{const n=B.z.parse(t?.timeRange);return{key:e,name:r,timeRange:n,color:typeof t?.color=="string"?t.color:void 0,labels:[],parent:null}},E0=a.z.object({ranges:Lr.array()}),A0=a.z.object({parent:F.optional(),ranges:vu.array()}),x0=a.z.object({keys:X.array()}),I0=a.z.object({}),C0=a.z.object({key:X,name:Da}),j0=a.z.object({});class ah{client;constructor(e){this.client=e}async rename(e,r){await w(this.client,"/range/rename",{key:e,name:r},C0,j0)}async create(e,r){return(await w(this.client,"/range/create",{ranges:e,...r},A0,E0)).ranges}async delete(e){await w(this.client,"/range/delete",{keys:e},x0,I0)}}const $0=Object.freeze(Object.defineProperty({__proto__:null,Aliaser:pt,Client:nh,DELETE_ALIAS_CHANNEL_NAME:QS,DELETE_CHANNEL_NAME:z0,KV:Bs,KV_DELETE_CHANNEL:p0,KV_SET_CHANNEL:f0,Range:rh,SET_ALIAS_CHANNEL_NAME:XS,SET_CHANNEL_NAME:v0,TYPE_ONTOLOGY_ID:S0,Writer:ah,aliasKey:h0,aliasOntologyID:N0,aliasZ:u0,convertOntologyResourceToPayload:sh,decodeDeleteAliasChange:d0,keyZ:X,kvPairKey:y0,kvPairZ:Ka,nameZ:Da,newZ:vu,ontologyID:yt,payloadZ:Lr},Symbol.toStringTag,{value:"Module"})),Cn=a.z.string(),jn=t=>lt.statusZ(t),ih=t=>jn(t).omit({labels:!0}).partial({key:!0}),Fs="sy_status_set",M0="sy_status_delete",oh=K("status"),_0=oh(""),Z0=t=>a.object({parent:F.optional(),statuses:ih(t).array()}),U0=t=>a.object({statuses:jn(t).array()}),P0=a.object({keys:Cn.array()}),R0=a.object({}),L0=a.object({keys:Cn.array().optional(),searchTerm:a.string().optional(),offset:a.int().optional(),limit:a.int().optional(),includeLabels:a.boolean().optional(),hasLabels:ht.array().optional()}),D0=a.object({key:Cn,includeLabels:a.boolean().optional()}).transform(({key:t,includeLabels:e})=>({keys:[t],includeLabels:e})),B0=a.union([D0,L0]),F0=t=>a.object({statuses:O.nullableZ(jn(t))});let ch=class{type="status";client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/status/retrieve",t,B0,F0(t.detailsSchema));ce("Status",t,r.statuses,e);const n=r.statuses;return e?n[0]:n}async set(t,e={}){const r=Array.isArray(t),n=(await w(this.client,"/status/set",{statuses:O.toArray(t),parent:e.parent},Z0(e.detailsSchema),U0(e.detailsSchema))).statuses;return r?n:n[0]}async delete(t){await w(this.client,"/status/delete",{keys:O.toArray(t)},P0,R0)}};const q0=Object.freeze(Object.defineProperty({__proto__:null,Client:ch,DELETE_CHANNEL_NAME:M0,SET_CHANNEL_NAME:Fs,TYPE_ONTOLOGY_ID:_0,keyZ:Cn,newZ:ih,ontologyID:oh,statusZ:jn},Symbol.toStringTag,{value:"Module"})),We=a.z.union([a.z.string(),a.z.bigint().transform(t=>t.toString()),a.z.number().transform(t=>t.toString())]),Ja=t=>a.z.object({task:We,running:a.z.boolean(),data:t,cmd:a.z.string().optional()}),Xa=t=>lt.statusZ(Ja(t)),Y0=t=>Ja(t).partial({task:!0}),lh=t=>lt.statusZ(Y0(t)).partial({key:!0,name:!0}),Br=(t={typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()})=>a.z.object({key:We,name:a.z.string(),type:t.typeSchema,internal:a.z.boolean().optional(),config:a.z.string().transform(Wu).or(t.configSchema),status:Xa(t.statusDataSchema).optional().nullable(),snapshot:a.z.boolean().optional()}),uh=t=>Br(t).omit({key:!0,status:!0}).extend({key:We.transform(e=>e.toString()).optional(),config:a.z.unknown().transform(e=>Nt.JSON_CODEC.encodeString(e)),status:lh(t?.statusDataSchema??a.z.unknown()).optional().nullable()}),V0=a.z.object({task:We,type:a.z.string(),key:a.z.string(),args:ze.unknownZ.or(a.z.string().transform(Re)).or(a.z.array(a.z.unknown())).or(a.z.null()).optional()}),H0=t=>Number(BigInt(t)>>32n),W0=(t,e=0)=>((BigInt(t)<<32n)+BigInt(e)).toString(),qs="sy_task_cmd",G0="sy_task_set",K0="sy_task_delete",mt=new Error("Task not created"),hh=async(t,e)=>{const r=await e.retrieveParents(Fr(t));return r.length===0?null:r[0]};class dh{key;name;internal;type;snapshot;config;status;schemas;frameClient_;ontologyClient_;rangeClient_;get frameClient(){if(this.frameClient_==null)throw mt;return this.frameClient_}get ontologyClient(){if(this.ontologyClient_==null)throw mt;return this.ontologyClient_}get rangeClient(){if(this.rangeClient_==null)throw mt;return this.rangeClient_}constructor({key:e,type:r,name:n,config:s,internal:i=!1,snapshot:o=!1,status:c},l,u,h,f){this.key=e,this.name=n,this.type=r,this.config=s,this.schemas=l??{typeSchema:a.z.string(),configSchema:a.z.unknown(),statusDataSchema:a.z.unknown()},this.internal=i,this.snapshot=o,this.status=c,this.frameClient_=u,this.ontologyClient_=h,this.rangeClient_=f}get payload(){return{key:this.key,name:this.name,type:this.type,config:this.config,status:this.status,internal:this.internal}}get ontologyID(){return Fr(this.key)}async executeCommand(e){return await yh({...e,frameClient:this.frameClient,task:this.key})}async executeCommandSync(e){return await mh({...e,frameClient:this.frameClient,task:this.key,name:this.name,statusDataZ:this.schemas?.statusDataSchema})}async start(){await this.executeCommand({type:"start"})}async stop(){await this.executeCommand({type:"stop"})}async run(e){await this.start();try{return await e()}finally{await this.stop()}}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw mt;return this.snapshot?await hh(this.key,this.ontologyClient):null}}const J0=a.z.object({rack:Ae.optional(),keys:We.array().optional(),names:a.z.string().array().optional(),types:a.z.string().array().optional(),includeStatus:a.z.boolean().optional(),internal:a.z.boolean().optional(),snapshot:a.z.boolean().optional(),searchTerm:a.z.string().optional(),offset:a.z.int().optional(),limit:a.z.int().optional()}),fh=a.z.union([a.z.object({key:We,includeStatus:a.z.boolean().optional()}).transform(({key:t,includeStatus:e})=>({keys:[t],includeStatus:e})),a.z.object({name:a.z.string(),includeStatus:a.z.boolean().optional()}).transform(({name:t,includeStatus:e})=>({names:[t],includeStatus:e})),a.z.object({type:a.z.string(),rack:Ae.optional()}).transform(({type:t,rack:e})=>({types:[t],rack:e}))]),X0=J0,Q0=a.z.union([fh,X0]),eN=t=>a.z.object({tasks:O.nullableZ(Br(t))}),tN=t=>a.z.object({tasks:uh(t).array()}),rN=t=>a.z.object({tasks:Br(t).array()}),nN=a.z.object({keys:We.array()}),sN=a.z.object({}),aN=a.z.object({key:We,name:a.z.string(),snapshot:a.z.boolean()}),iN=t=>a.z.object({task:Br(t)});let ph=class{type="task";client;frameClient;ontologyClient;rangeClient;constructor(t,e,r,n){this.client=t,this.frameClient=e,this.ontologyClient=r,this.rangeClient=n}async create(t,e){const r=!Array.isArray(t),n=tN(e),s=rN(e),i=await w(this.client,"/task/create",{tasks:O.toArray(t)},n,s),o=this.sugar(i.tasks,e);return r?o[0]:o}async delete(t){await w(this.client,"/task/delete",{keys:O.toArray(t)},nN,sN)}async retrieve({schemas:t,...e}){const r=fh.safeParse(e).success,n=(await w(this.client,"/task/retrieve",e,Q0,eN(t))).tasks,s=this.sugar(n,t);return ce("Task",e,s,r),r?s[0]:s}async copy(t,e,r){const n=iN(),s=await w(this.client,"/task/copy",{key:t,name:e,snapshot:r},aN,n);return this.sugar(s.task)}async list(t){const e={internal:!1};return t!==void 0&&(e.rack=t),await this.retrieve(e)}async retrieveSnapshottedTo(t){if(this.ontologyClient==null)throw mt;return await hh(t,this.ontologyClient)}sugar(t,e){const r=!Array.isArray(t),n=O.toArray(t).map(({key:s,name:i,type:o,config:c,status:l,internal:u,snapshot:h})=>new dh({key:s,name:i,type:o,config:c,internal:u,snapshot:h,status:l},e,this.frameClient,this.ontologyClient,this.rangeClient));return r?n[0]:n}async executeCommand(t){return"commands"in t?await Qa({...t,frameClient:this.frameClient}):await yh({...t,frameClient:this.frameClient})}async executeCommandSync(t){if("commands"in t){const r=async()=>{const{commands:n}=t;return(await this.retrieve({keys:n.map(s=>s.task)})).map(s=>s.name)};return await gh({...t,frameClient:this.frameClient,name:r})}const e=async()=>{const{task:r}=t;return(await this.retrieve({key:r})).name};return await mh({frameClient:this.frameClient,name:e,...t})}};const Fr=K("task"),oN=Fr(""),cN=t=>Ze(Fr(t)),yh=async({frameClient:t,task:e,type:r,args:n})=>(await Qa({frameClient:t,commands:[{args:n,task:e,type:r}]}))[0],Qa=async({frameClient:t,commands:e})=>{if(t==null)throw mt;const r=await t.openWriter(qs),n=e.map(s=>({...s,key:Jp.create()}));return await r.write(qs,n),await r.close(),n.map(s=>s.key)},mh=async({frameClient:t,task:e,type:r,timeout:n,name:s,statusDataZ:i,args:o})=>(await gh({frameClient:t,commands:[{args:o,task:e,type:r}],timeout:n,statusDataZ:i,name:s}))[0],gh=async({frameClient:t,commands:e,timeout:r=E.seconds(10),statusDataZ:n,name:s})=>{if(t==null)throw mt;const i=await t.openStreamer(Fs),o=await Qa({frameClient:t,commands:e}),c=new E(r);let l=[],u;const h=new Promise((f,d)=>{u=setTimeout(()=>{(async()=>{const z=e.map(I=>I.task);d(await lN("command",s,c,z))})()},c.milliseconds)});try{for(;;){const f=await Promise.race([i.read(),h]),d=Xa(n).safeParse(f.at(-1)[Fs]);if(!d.success)continue;const z=d.data;if(!(z.details.cmd==null||!o.includes(z.details.cmd))&&(l=[...l.filter(I=>I.key!==z.key),z],l.length===o.length))return l}}finally{clearTimeout(u),i.close()}},lN=async(t,e,r,n)=>{const s=$p.capitalize(t),i=r.toString();try{let o;typeof e=="string"?o=[e]:Array.isArray(e)?o=e:o=O.toArray(await e());const c=Is.naturalLanguageJoin(o);return new Error(`${s} command to ${c} timed out after ${i}`)}catch(o){return console.error("Failed to retrieve task name for timeout error:",o),new Error(`${s} command to task with key ${Is.naturalLanguageJoin(n)} timed out after ${i}`)}},uN=Object.freeze(Object.defineProperty({__proto__:null,COMMAND_CHANNEL_NAME:qs,Client:ph,DELETE_CHANNEL_NAME:K0,SET_CHANNEL_NAME:G0,TYPE_ONTOLOGY_ID:oN,Task:dh,commandZ:V0,keyZ:We,newKey:W0,newStatusZ:lh,newZ:uh,ontologyID:Fr,rackKey:H0,statusDetailsZ:Ja,statusKey:cN,statusZ:Xa,taskZ:Br},Symbol.toStringTag,{value:"Module"}));class wh{url;unary;stream;secure;constructor(e,r={},n=!1){this.secure=n,this.url=e.child("/api/v1/");const s=new Nt.JSONCodec;this.unary=mp(new yp(this.url,s,this.secure),r),this.stream=new zp(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const tr=a.uuid(),$n=a.object({key:tr,name:a.string(),type:a.string(),query:ze.unknownZ}),bh=$n.extend({key:tr.optional()}),hN="sy_view_set",dN="sy_view_delete",fN=a.z.object({views:bh.array()}),pN=a.z.object({views:$n.array()}),yN=a.z.object({keys:tr.array()}),mN=a.z.object({}),gN=a.z.object({keys:tr.array().optional(),types:a.z.string().array().optional(),searchTerm:a.z.string().optional(),offset:a.z.number().optional(),limit:a.z.number().optional()}),wN=a.z.object({key:tr}).transform(({key:t})=>({keys:[t]})),bN=a.z.union([wN,gN]),vN=a.z.object({views:O.nullableZ($n)});let vh=class{client;constructor(t){this.client=t}async retrieve(t){const e="key"in t,r=await w(this.client,"/view/retrieve",t,bN,vN);return ce("View",t,r.views,e),e?r.views[0]:r.views}async create(t){const e=Array.isArray(t),r=await w(this.client,"/view/create",{views:O.toArray(t)},fN,pN);return e?r.views:r.views[0]}async delete(t){await w(this.client,"/view/delete",{keys:O.toArray(t)},yN,mN)}};const zh=t=>({type:"view",key:t}),zN=zh(""),ON=Object.freeze(Object.defineProperty({__proto__:null,Client:vh,DELETE_CHANNEL_NAME:dN,SET_CHANNEL_NAME:hN,TYPE_ONTOLOGY_ID:zN,keyZ:tr,newZ:bh,ontologyID:zh,viewZ:$n},Symbol.toStringTag,{value:"Module"})),jt=a.z.uuid(),Mn=a.z.object({key:jt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),Oh=Mn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Le=a.z.uuid(),_n=a.z.object({key:Le,name:a.z.string().min(1,"Name is required"),layout:ze.unknownZ.or(a.z.string().transform(Re))}),Th=_n.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),kh=_n.omit({layout:!0}).extend({layout:a.z.string().transform(Re)}),TN=a.z.object({key:jt,name:a.z.string()}),kN=a.z.object({key:jt,data:a.z.string()}),SN=a.z.object({keys:jt.array()}),NN=a.z.object({keys:jt.array()}),Sh=a.z.object({key:jt}).transform(({key:t})=>({keys:[t]})),Nh=a.z.union([Sh,NN]),EN=a.z.object({linePlots:O.nullableZ(Mn)}),AN=a.z.object({workspace:Le,linePlots:Oh.array()}),xN=a.z.object({linePlots:Mn.array()}),es=a.z.object({});let Eh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/lineplot/create",{workspace:t,linePlots:O.toArray(e)},AN,xN);return r?n.linePlots:n.linePlots[0]}async rename(t,e){await w(this.client,"/workspace/lineplot/rename",{key:t,name:e},TN,es)}async setData(t,e){await w(this.client,"/workspace/lineplot/set-data",{key:t,data:JSON.stringify(e)},kN,es)}async retrieve(t){const e=Sh.safeParse(t).success,r=await w(this.client,"/workspace/lineplot/retrieve",t,Nh,EN);return ce("LinePlot",t,r.linePlots,e),e?r.linePlots[0]:r.linePlots}async delete(t){await w(this.client,"/workspace/lineplot/delete",{keys:O.toArray(t)},SN,es)}};const Ah=K("lineplot"),IN=Ah(""),CN=Object.freeze(Object.defineProperty({__proto__:null,Client:Eh,TYPE_ONTOLOGY_ID:IN,keyZ:jt,linePlotZ:Mn,newZ:Oh,ontologyID:Ah,retrieveArgsZ:Nh},Symbol.toStringTag,{value:"Module"})),$t=a.z.uuid(),Zn=a.z.object({key:$t,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),xh=Zn.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),jN=a.z.object({key:$t,name:a.z.string()}),$N=a.z.object({key:$t,data:a.z.string()}),MN=a.z.object({keys:$t.array()}),_N=a.z.object({keys:$t.array()}),Ih=a.z.object({key:$t}).transform(({key:t})=>({keys:[t]})),Ch=a.z.union([Ih,_N]),ZN=a.z.object({logs:O.nullableZ(Zn)}),UN=a.z.object({workspace:Le,logs:xh.array()}),PN=a.z.object({logs:Zn.array()}),ts=a.z.object({});let jh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/log/create",{workspace:t,logs:O.toArray(e)},UN,PN);return r?n.logs:n.logs[0]}async rename(t,e){await w(this.client,"/workspace/log/rename",{key:t,name:e},jN,ts)}async setData(t,e){await w(this.client,"/workspace/log/set-data",{key:t,data:JSON.stringify(e)},$N,ts)}async retrieve(t){const e=Ih.safeParse(t).success,r=await w(this.client,"/workspace/log/retrieve",t,Ch,ZN);return ce("Log",t,r.logs,e),e?r.logs[0]:r.logs}async delete(t){await w(this.client,"/workspace/log/delete",{keys:O.toArray(t)},MN,ts)}};const $h=K("log"),RN=$h(""),LN=Object.freeze(Object.defineProperty({__proto__:null,Client:jh,TYPE_ONTOLOGY_ID:RN,keyZ:$t,logZ:Zn,newZ:xh,ontologyID:$h,retrieveArgsZ:Ch},Symbol.toStringTag,{value:"Module"})),dt=a.z.uuid(),Un=a.z.object({key:dt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re)),snapshot:a.z.boolean()}),Mh=Un.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ei=Un.extend({data:a.z.string().transform(Re)}),rr=a.z.uuid(),_h=a.z.object({key:a.z.string(),name:a.z.string(),selectors:a.z.string().array().default([]),strokeColor:a.z.string().optional(),fillColor:a.z.string().optional()}),Zh=a.z.object({key:a.z.string(),name:a.z.string(),regions:_h.array()}),Uh=a.z.object({key:a.z.string(),position:ga.xy,orientation:Yy.outer}),DN=a.z.object({zoom:a.z.number().positive().default(1),position:ga.xy}),Ph=a.z.object({svg:a.z.string().min(1,"SVG is required"),states:Zh.array(),variant:a.z.string().min(1,"Variant is required"),handles:Uh.array(),scale:a.z.number().positive().default(1),scaleStroke:a.z.boolean().default(!1),previewViewport:DN.default({zoom:1,position:{x:0,y:0}})}),Pn=a.z.object({key:rr,version:a.z.literal(1).default(1),name:a.z.string().min(1,"Name is required"),data:Ph}),Rh=Pn.partial({key:!0}),BN=a.z.object({symbols:Rh.array(),parent:F}),FN=a.z.object({key:rr,name:a.z.string()}),qN=a.z.object({keys:rr.array()}),YN=a.z.object({keys:rr.array().optional(),searchTerm:a.z.string().optional()}),VN=a.z.object({key:rr}).transform(({key:t})=>({keys:[t]})),HN=a.z.union([VN,YN]),WN=a.z.object({symbols:O.nullableZ(Pn)}),GN=a.z.object({symbols:Pn.array()}),go=a.z.object({}),KN=a.z.object({}),JN=a.z.object({group:bn}),XN="sy_schematic_symbol_set",QN="sy_schematic_symbol_delete";let Lh=class{client;constructor(t){this.client=t}async create(t){const e="symbols"in t,r=e?t.symbols:[t],n=await w(this.client,"/workspace/schematic/symbol/create",{symbols:r,parent:t.parent},BN,GN);return e?n.symbols:n.symbols[0]}async rename(t,e){await w(this.client,"/workspace/schematic/symbol/rename",{key:t,name:e},FN,go)}async retrieve(t){const e="key"in t,r=await w(this.client,"/workspace/schematic/symbol/retrieve",t,HN,WN);return ce("Schematic Symbol",t,r.symbols,e),e?r.symbols[0]:r.symbols}async delete(t){await w(this.client,"/workspace/schematic/symbol/delete",{keys:O.toArray(t)},qN,go)}async retrieveGroup(){return(await w(this.client,"/workspace/schematic/symbol/retrieve_group",{},KN,JN)).group}};const eE=K("schematic_symbol"),tE=Object.freeze(Object.defineProperty({__proto__:null,Client:Lh,DELETE_CHANNEL_NAME:QN,SET_CHANNEL_NAME:XN,handleZ:Uh,keyZ:rr,newZ:Rh,ontologyID:eE,regionZ:_h,specZ:Ph,stateZ:Zh,symbolZ:Pn},Symbol.toStringTag,{value:"Module"})),rE=a.z.object({key:dt,name:a.z.string()}),nE=a.z.object({key:dt,data:a.z.string()}),sE=a.z.object({keys:dt.array()}),aE=a.z.object({key:dt,name:a.z.string(),snapshot:a.z.boolean()}),iE=a.z.object({keys:dt.array()}),Dh=a.z.object({key:dt}).transform(({key:t})=>({keys:[t]})),Bh=a.z.union([Dh,iE]),oE=a.z.object({schematics:O.nullableZ(ei)}),cE=a.z.object({workspace:Le,schematics:Mh.array()}),lE=a.z.object({schematics:ei.array()}),uE=a.z.object({schematic:Un}),rs=a.z.object({});let Fh=class{symbols;client;constructor(t){this.client=t,this.symbols=new Lh(t)}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/schematic/create",{workspace:t,schematics:O.toArray(e)},cE,lE);return r?n.schematics:n.schematics[0]}async rename(t,e){await w(this.client,"/workspace/schematic/rename",{key:t,name:e},rE,rs)}async setData(t,e){await w(this.client,"/workspace/schematic/set-data",{key:t,data:JSON.stringify(e)},nE,rs)}async retrieve(t){const e=Dh.safeParse(t).success,r=await w(this.client,"/workspace/schematic/retrieve",t,Bh,oE);return ce("Schematic",t,r.schematics,e),e?r.schematics[0]:r.schematics}async delete(t){await w(this.client,"/workspace/schematic/delete",{keys:O.toArray(t)},sE,rs)}async copy(t){return(await w(this.client,"/workspace/schematic/copy",t,aE,uE)).schematic}};const qh=K("schematic"),hE=qh(""),dE=Object.freeze(Object.defineProperty({__proto__:null,Client:Fh,TYPE_ONTOLOGY_ID:hE,keyZ:dt,newZ:Mh,ontologyID:qh,remoteZ:ei,retrieveArgsZ:Bh,schematicZ:Un,symbol:tE},Symbol.toStringTag,{value:"Module"})),Mt=a.z.uuid(),ti=a.z.object({key:Mt,name:a.z.string(),data:ze.unknownZ.or(a.z.string().transform(Re))}),Yh=ti.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),ri=ti.extend({data:a.z.string().transform(Re)}),fE=a.z.object({key:Mt,name:a.z.string()}),pE=a.z.object({key:Mt,data:a.z.string()}),yE=a.z.object({keys:Mt.array()}),mE=a.z.object({keys:Mt.array()}),Vh=a.z.object({key:Mt}).transform(({key:t})=>({keys:[t]})),Hh=a.z.union([Vh,mE]),gE=a.z.object({tables:O.nullableZ(ri)}),wE=a.z.object({workspace:Le,tables:Yh.array()}),bE=a.z.object({tables:ri.array()}),ns=a.z.object({});let Wh=class{client;constructor(t){this.client=t}async create(t,e){const r=Array.isArray(e),n=await w(this.client,"/workspace/table/create",{workspace:t,tables:O.toArray(e)},wE,bE);return r?n.tables:n.tables[0]}async rename(t,e){await w(this.client,"/workspace/table/rename",{key:t,name:e},fE,ns)}async setData(t,e){await w(this.client,"/workspace/table/set-data",{key:t,data:JSON.stringify(e)},pE,ns)}async retrieve(t){const e=Vh.safeParse(t).success,r=await w(this.client,"/workspace/table/retrieve",t,Hh,gE);return ce("Table",t,r.tables,e),e?r.tables[0]:r.tables}async delete(t){await w(this.client,"/workspace/table/delete",{keys:O.toArray(t)},yE,ns)}};const Gh=K("table"),vE=Gh(""),zE=Object.freeze(Object.defineProperty({__proto__:null,Client:Wh,TYPE_ONTOLOGY_ID:vE,keyZ:Mt,newZ:Yh,ontologyID:Gh,remoteZ:ri,retrieveArgsZ:Hh,tableZ:ti},Symbol.toStringTag,{value:"Module"})),OE=a.z.object({keys:Le.array().optional(),searchTerm:a.z.string().optional(),author:Pe.optional(),offset:a.z.int().optional(),limit:a.z.int().optional()}),TE=a.z.object({workspaces:Th.array()}),kE=a.z.object({key:Le,name:a.z.string()}),SE=a.z.object({key:Le,layout:ze.unknownZ.transform(t=>JSON.stringify(t))}),NE=a.z.object({keys:Le.array()}),EE=a.z.object({workspaces:O.nullableZ(_n)}),AE=a.z.object({workspaces:kh.array()}),ss=a.z.object({}),xE="sy_workspace_set",IE="sy_workspace_delete";class Kh{schematics;lineplots;logs;tables;client;constructor(e){this.client=e,this.schematics=new Fh(e),this.lineplots=new Eh(e),this.logs=new jh(e),this.tables=new Wh(e)}async create(e){const r=Array.isArray(e),n=await w(this.client,"/workspace/create",{workspaces:O.toArray(e)},TE,AE);return r?n.workspaces:n.workspaces[0]}async rename(e,r){await w(this.client,"/workspace/rename",{key:e,name:r},kE,ss)}async setLayout(e,r){await w(this.client,"/workspace/set-layout",{key:e,layout:r},SE,ss)}async retrieve(e){let r;const n=typeof e!="string";typeof e=="string"||Array.isArray(e)?r={keys:O.toArray(e)}:r=e;const s=await w(this.client,"/workspace/retrieve",r,OE,EE);return n?s.workspaces:s.workspaces[0]}async delete(e){await w(this.client,"/workspace/delete",{keys:O.toArray(e)},NE,ss)}}const Jh=K("workspace"),CE=Jh(""),jE=Object.freeze(Object.defineProperty({__proto__:null,Client:Kh,DELETE_CHANNEL_NAME:IE,SET_CHANNEL_NAME:xE,TYPE_ONTOLOGY_ID:CE,keyZ:Le,newZ:Th,ontologyID:Jh,remoteZ:kh,workspaceZ:_n},Symbol.toStringTag,{value:"Module"})),Xh=a.z.object({host:a.z.string({error:"Host is required"}).min(1,"Host is required"),port:a.z.number({error:"Port is required"}).or(a.z.string({error:"Port is required"})),username:a.z.string().min(1,"Username is required"),password:a.z.string().min(1,"Password is required"),connectivityPollFrequency:E.z.default(E.seconds(30)),secure:a.z.boolean().default(!1),name:a.z.string().optional(),retry:va.breakerConfigZ.optional()});class $E extends Du{createdAt;params;ranges;channels;auth;users;access;connectivity;ontology;workspaces;labels;statuses;tasks;racks;devices;control;arcs;views;static connectivity=Ls;transport;clientVersion="0.50.0";constructor(e){const r=Xh.parse(e),{host:n,port:s,username:i,password:o,connectivityPollFrequency:c,secure:l,retry:u}=r,h=new wh(new Lt({host:n,port:Number(s)}),u,l);h.use(sw);const f=new Fa(new Ba(h.unary));super(h.stream,h.unary,f),this.auth=new Lk(h.unary,{username:i,password:o}),h.use(this.auth.middleware());const d=new Su(h.unary,f);this.createdAt=C.now(),this.params=r,this.transport=h,this.channels=new Tu(this,f,h.unary,d),this.connectivity=new Ls(h.unary,c,this.clientVersion,r.name),this.control=new qu(this),this.ontology=new ml(h.unary,this);const z=new ah(this.transport.unary);this.labels=new wu(this.transport.unary),this.statuses=new ch(this.transport.unary),this.ranges=new nh(this,z,this.transport.unary,f,this.labels,this.ontology),this.access=new xl(this.transport.unary),this.users=new Tl(this.transport.unary),this.workspaces=new Kh(this.transport.unary),this.tasks=new ph(this.transport.unary,this,this.ontology,this.ranges),this.racks=new Qu(this.transport.unary,this.tasks),this.devices=new Xu(this.transport.unary),this.arcs=new cu(this.transport.unary,this.transport.stream),this.views=new vh(this.transport.unary)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stop()}}const ME=async t=>await Qh(t).check(),Qh=t=>{const{host:e,port:r,secure:n,name:s,retry:i}=t,o=va.breakerConfigZ.optional().parse(i),c=new Lt({host:e,port:Number(r)}),l=new wh(c,o,n);return new Ls(l.unary,void 0,"0.50.0",s)};E.seconds(1);class Vt{_noop=!1;key;path;serviceName;constructor(e,r,n="",s=!1){this.key=e,this.path=r,this.serviceName=n,this._noop=s}child(e){return new Vt(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new Vt("","","")}const Ys=["debug","info","warn","error"],ed=t=>{const e=Ys.indexOf(t);return({level:r})=>Ys.indexOf(r)>=e},_E=t=>{const{include:e,exclude:r}=t;return({path:n})=>!(e!=null&&!e.some(s=>n.startsWith(s))||r!=null&&r.some(s=>n.startsWith(s)))};class Ht{meta=Vt.NOOP;filters;constructor(e={}){const{filters:r=[]}=e;this.filters=r}filter(e){return!this.meta.noop&&this.filters.every(r=>r({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const r=new Ht({filters:this.filters});return r.meta=e,r}debug(e,r,n=!1){!this.filter("debug")&&!n||(r==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,tn(r)))}info(e,r,n=!1){!this.filter("info")&&!n||(r==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,tn(r)))}warn(e,r,n=!1){!this.filter("warn")&&!n||(r==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,tn(r)))}error(e,r,n=!1){!this.filter("error")&&!n||(r==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,tn(r)))}static NOOP=new Ht}const tn=t=>typeof t=="function"?t():t;var ZE=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},gt="1.9.0",wo=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function UE(t){var e=new Set([t]),r=new Set,n=t.match(wo);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(c){return c===t};function i(c){return r.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(wo);if(!l)return i(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||s.major!==u.major?i(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?o(c):i(c):s.minor<=u.minor?o(c):i(c)}}var PE=UE(gt),RE=gt.split(".")[0],Tr=Symbol.for("opentelemetry.js.api."+RE),kr=ZE;function ni(t,e,r,n){var s;n===void 0&&(n=!1);var i=kr[Tr]=(s=kr[Tr])!==null&&s!==void 0?s:{version:gt};if(!n&&i[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(i.version!==gt){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+t+" does not match previously registered API v"+gt);return r.error(o.stack||o.message),!1}return i[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+gt+"."),!0}function Sr(t){var e,r,n=(e=kr[Tr])===null||e===void 0?void 0:e.version;if(!(!n||!PE(n)))return(r=kr[Tr])===null||r===void 0?void 0:r[t]}function si(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+gt+".");var r=kr[Tr];r&&delete r[t]}var LE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},DE=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},BE=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return nr("verbose",this._namespace,e)},t})();function nr(t,e,r){var n=Sr("diag");if(n)return r.unshift(e),n[t].apply(n,DE([],LE(r),!1))}var le;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(le||(le={}));function FE(t,e){t<le.NONE?t=le.NONE:t>le.ALL&&(t=le.ALL),e=e||{};function r(n,s){var i=e[n];return typeof i=="function"&&t>=s?i.bind(e):function(){}}return{error:r("error",le.ERROR),warn:r("warn",le.WARN),info:r("info",le.INFO),debug:r("debug",le.DEBUG),verbose:r("verbose",le.VERBOSE)}}var qE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},YE=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},VE="diag",Nr=(function(){function t(){function e(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var c=Sr("diag");if(c)return c[s].apply(c,YE([],qE(i),!1))}}var r=this,n=function(s,i){var o,c,l;if(i===void 0&&(i={logLevel:le.INFO}),s===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=u.stack)!==null&&o!==void 0?o:u.message),!1}typeof i=="number"&&(i={logLevel:i});var h=Sr("diag"),f=FE((c=i.logLevel)!==null&&c!==void 0?c:le.INFO,s);if(h&&!i.suppressOverrideMessage){var d=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";h.warn("Current logger will be overwritten from "+d),f.warn("Current logger will overwrite one already registered from "+d)}return ni("diag",f,r,!0)};r.setLogger=n,r.disable=function(){si(VE,r)},r.createComponentLogger=function(s){return new BE(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})(),HE=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},WE=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},GE=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=HE(e,2),n=r[0],s=r[1];return[n,s]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var i=new t(this._entries);try{for(var o=WE(n),c=o.next();!c.done;c=o.next()){var l=c.value;i._entries.delete(l)}}catch(u){e={error:u}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return i},t.prototype.clear=function(){return new t},t})();Nr.instance();function KE(t){return t===void 0&&(t={}),new GE(new Map(Object.entries(t)))}function JE(t){return Symbol.for(t)}var XE=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var i=new t(r._currentContext);return i._currentContext.set(n,s),i},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t})(),QE=new XE,eA={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},tA={set:function(t,e,r){t!=null&&(t[e]=r)}},rA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},nA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},sA=(function(){function t(){}return t.prototype.active=function(){return QE},t.prototype.with=function(e,r,n){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return r.call.apply(r,nA([n],rA(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})(),aA=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,i=[],o;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i},iA=function(t,e,r){if(arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},as="context",oA=new sA,td=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return ni(as,e,Nr.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,iA([e,r,n],aA(i),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return Sr(as)||oA},t.prototype.disable=function(){this._getContextManager().disable(),si(as,Nr.instance())},t})(),Vs;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Vs||(Vs={}));var cA=td.getInstance(),lA=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})(),ai=JE("OpenTelemetry Baggage Key");function rd(t){return t.getValue(ai)||void 0}function uA(){return rd(td.getInstance().active())}function hA(t,e){return t.setValue(ai,e)}function dA(t){return t.deleteValue(ai)}var is="propagation",fA=new lA,pA=(function(){function t(){this.createBaggage=KE,this.getBaggage=rd,this.getActiveBaggage=uA,this.setBaggage=hA,this.deleteBaggage=dA}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return ni(is,e,Nr.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=tA),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=eA),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){si(is,Nr.instance())},t.prototype._getGlobalPropagator=function(){return Sr(is)||fA},t})(),yA=pA.getInstance();const bo=["bench","debug","prod"],mA=t=>e=>bo.indexOf(e)>=bo.indexOf(t);class Er{meta=Vt.NOOP;otelTracer;filter;constructor(e,r=mA("debug")){this.otelTracer=e,this.filter=r}child(e){const r=new Er(this.otelTracer,this.filter);return r.meta=e,r}debug(e,r){return this.trace(e,"debug",r)}bench(e,r){return this.trace(e,"bench",r)}prod(e,r){return this.trace(e,"prod",r)}trace(e,r,n){const s=this.meta.noop||!this.filter(r)||this.otelTracer==null;if(n==null){if(s)return()=>{};const i=new Hs(e,this.otelTracer.startSpan(e));return i.start(),()=>i.end()}return s?n(new nd(e)):this.otelTracer.startActiveSpan(e,i=>{const o=new Hs(e,i);return n(o)})}propagate(e){if(this.meta.noop)return;const r=cA.active();yA.inject(r,e,{set:(n,s,i)=>{n[s]=i}})}static NOOP=new Er}class Hs{key;otel;constructor(e,r){this.key=e,this.otel=r}set(e,r){this.otel.setAttribute(e,r)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:Vs.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);const e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class nd{key;constructor(e){this.key=e}set(){}recordError(e){}}class Wt{meta;T;L;constructor({key:e="",serviceName:r="",logger:n=Ht.NOOP,tracer:s=Er.NOOP,noop:i=!1,__meta:o}){this.meta=o??new Vt(e,e,r,i),this.T=s.child(this.meta),this.L=n.child(this.meta)}child(e){const r=this.meta.child(e);return new Wt({__meta:r,tracer:this.T,logger:this.L})}static NOOP=new Wt({noop:!0})}const gA=Wt.NOOP,sd=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:Wt,LOG_LEVELS:Ys,Logger:Ht,NOOP:gA,NoopSpan:nd,Tracer:Er,_Span:Hs,logLevelKeyFiler:_E,logThresholdFilter:ed},Symbol.toStringTag,{value:"Module"})),Ws=(t,e,r="")=>{try{return t.parse(e)}catch(n){if(n instanceof a.z.ZodError){const s=n.issues.map(i=>i.path.length===0?i.message:`${i.path.join(".")}: ${i.message}`);throw new Error(`${r} - ${s.join(`
|
|
66
66
|
`)}`)}else throw n}},os=(t,e)=>t instanceof Error?(t.message=`[${e}] - ${t.message}`,t):new Error(e??"unknown error",{cause:t}),ii=t=>{const e=t._zod.def.output;return e instanceof a.z.ZodVoid||e instanceof a.z.ZodNever||e instanceof a.z.ZodUnknown};class oi{type;key;sender;_internalState;_state;_prevState;_deleted=!1;parentCtxValues;childCtxValues;childCtxChangedKeys;instrumentation;schema=void 0;methods=void 0;_methodImplementations=null;constructor({key:e,type:r,sender:n,instrumentation:s,parentCtxValues:i}){this.type=r,this.key=e,this.sender=n,this._internalState={},this.instrumentation=s.child(this.toString()),this.parentCtxValues=new Map,i?.forEach((o,c)=>this.parentCtxValues.set(c,o)),this.childCtxValues=new Map,this.childCtxChangedKeys=new Set}initializeMethods(){if(!(this.methods==null||this._methodImplementations!=null)){this._methodImplementations={};for(const[e,r]of Object.entries(this.methods)){const n=this[e];if(typeof n!="function")throw new Error(`Method ${e} is not a function`);this._methodImplementations[e]=ii(r)?r.implement(n.bind(this)):r.implementAsync(n.bind(this))}}}get _schema(){if(this.schema==null)throw new W(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
67
|
-
Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const r=Qe.executeSetter(e,this.state);this._prevState=
|
|
67
|
+
Make sure to define a property 'schema' on the class.`);return this.schema}setState(e){const r=Qe.executeSetter(e,this.state);this._prevState=A.il.copy(this._state),this._state=Ws(this._schema,r,`${this.toString()}`),this.sender.send({variant:"update",key:this.key,state:this._state})}get state(){if(this._state==null)throw new ie(`[AetherLeaf] - state not defined in ${this.toString()}`);return this._state}get internal(){return this._internalState}get prevState(){if(this._prevState===void 0)throw new Error("prevState not defined");return this._prevState}get deleted(){return this._deleted}get ctx(){return{get:e=>{const r=this.parentCtxValues.get(e);if(r===void 0)throw new Tt(`Context value for ${e} not found on ${this.toString()}`);return r},getOptional:e=>this.parentCtxValues.get(e),has:e=>this.parentCtxValues.has(e),wasSetPreviously:e=>this.childCtxValues.has(e),set:(e,r,n=!0)=>{this.childCtxValues.set(e,r),n&&this.childCtxChangedKeys.add(e)}}}toString(){return`${this.type}(${this.key})`}_updateState({path:e,state:r}){if(!this.deleted)try{this.initializeMethods();const n=this.instrumentation.T.debug(`${this.toString()}:updateState`);this.validatePath(e);const s=Ws(this._schema,r,`${this.toString()}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:A.Vu.difference(this.state,s)})):this.instrumentation.L.debug("setting initial state",{state:r,path:e}),this._prevState=this._state??s,this._state=s,this.afterUpdate(this.ctx),n()}catch(n){throw os(n,`${this.toString()}.updateState`)}}_updateContext(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:updateContext`);e.forEach((n,s)=>this.parentCtxValues.set(s,n)),this.afterUpdate(this.ctx),r()}catch(r){throw os(r,`${this.type}.${this.key}.updateContext`)}}_delete(e){try{const r=this.instrumentation.T.debug(`${this.toString()}:delete`);this.validatePath(e),this._deleted=!0,this.afterDelete(this.ctx),r()}catch(r){throw os(r,`[${this.toString()}:delete]`)}}afterUpdate(e){}afterDelete(e){}validatePath(e){if(e.length===0)throw new ie(`[Leaf.setState] - ${this.toString()} received an empty path`);const r=e[e.length-1];if(e.length>1)throw new ie(`[Leaf.setState] - ${this.toString()} received a subPath ${e.join(".")} but is a leaf`);if(r!==this.key)throw new ie(`[Leaf.setState] - ${this.toString()} received a key ${r} but expected ${this.key}`)}handleInvokeError({method:e,key:r,args:n},s){if(!(r!=null))return console.error(`Error in fire and forget method ${e} on ${this.toString()}`,s);const o=s instanceof Error?s:new Error(String(s));this.sender.send({variant:"invoke_response",key:r,result:void 0,error:{name:o.name,message:`Failed to execute ${e}(${r}) with args ${JSON.stringify(n)} on ${this.toString()}: ${o.message}`,stack:o.stack??""}})}_invokeMethod(e){if(this.deleted)return;const{method:r,key:n,args:s}=e,i=n!=null,o=this._methodImplementations?.[r];if(o==null)return this.handleInvokeError(e,new Error(`Method ${r} not found on ${this.toString()}`));try{const c=o(...s);c instanceof Promise&&c.then(l=>{i&&this.sender.send({variant:"invoke_response",key:n,result:l})}).catch(l=>this.handleInvokeError(e,l))}catch(c){this.handleInvokeError(e,c)}}}class qr extends oi{_children=new Map;get children(){return Array.from(this._children.values())}getChild(e){return this._children.get(e)??null}childrenOfType(...e){return this.children.filter(r=>e.includes(r.type))}_updateState(e){const{path:r,type:n,create:s}=e;if(this.deleted)return;const i=this.parsePath(r);if(i.length===0){if(this.childCtxChangedKeys.clear(),super._updateState(e),this.childCtxChangedKeys.size==0)return;this.updateChildContexts();return}const c=i[0],l=this.getChild(c);if(l!=null)return l._updateState({...e,path:i});if(i.length>1){const h=r.slice(0,r.indexOf(c)+1).join("."),f=r.join(".");throw new ie(`Child of ${this.toString()} at path ${h} does not exist,
|
|
68
68
|
but an extended path ${f} was provided. This means that the aether
|
|
69
69
|
tree is attempting to create a new child of type ${n} (or nested children)
|
|
70
70
|
on a child that does not exist.
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
Children present: ${this.children.map(d=>`${d.type}:${d.key}`).join(".")}
|
|
73
73
|
|
|
74
74
|
`)}const u=s(this.childCtx());u._updateState({...e,path:i}),this._children.set(c,u)}_updateContext(e){super._updateContext(e),this.updateChildContexts()}childCtx(){return{get:e=>this.childCtxValues.get(e)??this.parentCtxValues.get(e),forEach:e=>{this.childCtxValues.forEach((r,n)=>e(r,n,this.childCtxValues)),this.parentCtxValues.forEach((r,n)=>{this.childCtxValues.has(n)||e(r,n,this.parentCtxValues)})}}}updateChildContexts(){const e=this.childCtx();this.children.forEach(r=>r._updateContext(e))}_delete(e){const r=this.parsePath(e);if(r.length===0){for(const s of this.children)s._delete([s.key]);this._children.clear(),super._delete([this.key])}const n=this.getChild(r[0]);if(n!=null){if(r.length>1)return n._delete(r);this._children.delete(n.key),n._delete(r)}}findChildAtPath(e){if(e.length===0)return null;const[r,...n]=e,s=this.getChild(r);return s==null?null:n.length===0?s:"findChildAtPath"in s&&typeof s.findChildAtPath=="function"?s.findChildAtPath(n):null}parsePath(e,r){const[n,...s]=e;if(n==null)throw new Error(`Composite ${this.toString()} received an empty path${r!=null?` for ${r}`:""}`);if(n!==this.key)throw new ie(`[Composite.getRequiredKey] - ${this.toString()} received a key ${n} but expected ${this.key}`);return s}}const wA=a.z.object({}),bA=()=>{throw new Error("should not call create")};class $e extends qr{static TYPE="root";static KEY="root";comms;registry;schema=wA;constructor({comms:e,instrumentation:r=sd.Instrumentation.NOOP,registry:n}){super({key:$e.KEY,type:$e.TYPE,sender:e,instrumentation:r,parentCtxValues:null}),this.comms=e,this.registry=n}static render(e){const r=new $e(e);return r._updateState({path:[$e.KEY],type:"",state:{},create:bA}),r.comms.handle(n=>{try{r.handle(n)}catch(s){const i={name:"unknown",message:JSON.stringify(s),stack:"unknown"};s instanceof Error&&(i.name=s.name,i.message=s.message,i.stack=s.stack),r.comms.send({variant:"error",error:i})}}),r}handle(e){const{variant:r}=e;if(r==="invoke_request"){this.invokeAtPath(e);return}const{path:n,type:s}=e;if(r==="delete"){this._delete(n);return}const{state:i}=e;this._updateState({path:n,type:s,state:i,create:o=>{const c=n[n.length-1];return this.create({key:c,type:s,parentCtxValues:o})}})}invokeAtPath(e){const{path:r}=e,[n,...s]=r;if(n!==$e.KEY){this.handleInvokeError(e,new Error(`Invalid path: expected root key '${$e.KEY}', got '${n}'`));return}if(s.length===0){this._invokeMethod(e);return}const i=this.findChildAtPath(s);if(i==null){this.handleInvokeError(e,new Tt(`Component at path ${r.join(".")} not found`));return}i._invokeMethod(e)}create({key:e,type:r,parentCtxValues:n}){const s=this.registry[r];if(s==null)throw new ie(`[Root.create] - ${r} not found in registry`);return new s({key:e,type:r,sender:this.comms,instrumentation:this.instrumentation,parentCtxValues:n})}}const ad=$e.render.bind($e),vA=Object.freeze(Object.defineProperty({__proto__:null,Composite:qr,Leaf:oi,Root:$e,isFireAndForget:ii,render:ad},Symbol.toStringTag,{value:"Module"})),zA=(t,e)=>Array.isArray(e)?e.some(r=>r.matches(t)):e?.matches(t)??!1,OA=t=>{const e=[`${t.variant.toUpperCase()}: ${t.message}`];if(t.description)try{const r=JSON.parse(t.description);e.push(`Description:
|
|
75
|
-
${JSON.stringify(r,null,2)}`)}catch{e.push(`Description: ${t.description}`)}"details"in t&&
|
|
75
|
+
${JSON.stringify(r,null,2)}`)}catch{e.push(`Description: ${t.description}`)}"details"in t&&A.yu.isObject(t.details)&&"stack"in t.details&&e.push(`Stack Trace:
|
|
76
76
|
${String(t.details.stack)}`),console.error(e.join(`
|
|
77
77
|
|
|
78
|
-
`))},id=(t,e,r)=>{const n=
|
|
78
|
+
`))},id=(t,e,r)=>{const n=A.ol.fromException(t,e);return OA(n),zA(t,r)?null:n},od=(t,e,r,n)=>{if(typeof t=="function")return!0;const s=id(t,r,n);return s!=null&&e(s),!1},cd=async(t,e,r,n)=>{try{const s=t();s!=null&&await s}catch(s){const i=id(s,r,n);if(i!=null)return e(i)}},ld=t=>(e,r,n)=>{od(e,t,r,n)&&cd(e,t,r,n)},ud=t=>async(e,r,n)=>{od(e,t,r,n)&&await cd(e,t,r,n)},hd=a.z.object({statuses:A.ol.statusZ().array()}),pn="status.aggregator";class Gs extends qr{static TYPE="status.Aggregator";schema=hd;afterUpdate(e){e.wasSetPreviously(pn)||e.set(pn,{add:this.add.bind(this),create:A.ol.create})}add(e){this.setState(r=>({...r,statuses:[...r.statuses,A.ol.create(e)]}))}}const ci=t=>t.get(pn).add,TA=t=>{const e=t.getOptional(pn);return e!=null?e.add:()=>{}},dd=t=>ld(ci(t)),kA=t=>ud(ci(t)),SA={[Gs.TYPE]:Gs},NA=a.z.object({l0:A.Zu.colorZ,l1:A.Zu.colorZ,l2:A.Zu.colorZ,l3:A.Zu.colorZ,l4:A.Zu.colorZ,l5:A.Zu.colorZ,l6:A.Zu.colorZ,l7:A.Zu.colorZ,l8:A.Zu.colorZ,l9:A.Zu.colorZ,l10:A.Zu.colorZ,l11:A.Zu.colorZ}),ge=(t,e)=>[t[0],t[1],e,t[3]],EA=a.z.object({m2:A.Zu.colorZ,m1:A.Zu.colorZ,z:A.Zu.colorZ,p1:A.Zu.colorZ,p2:A.Zu.colorZ}),rn=EA.or(A.Zu.colorZ.transform(t=>{const e=A.Zu.hsla(t);return{m2:A.Zu.fromHSLA(ge(e,40)),m1:A.Zu.fromHSLA(ge(e,45)),z:t,p1:A.Zu.fromHSLA(ge(e,55)),p2:A.Zu.fromHSLA(ge(e,65))}})),fd=a.z.object({name:a.z.string(),key:a.z.string(),colors:a.z.object({border:A.Zu.colorZ,primary:rn,gray:NA,error:rn,secondary:rn,warning:rn,palettes:a.z.record(a.z.string(),A.Zu.paletteZ),visualization:a.z.object({palettes:a.z.record(a.z.string(),a.z.array(A.Zu.colorZ))}).default({palettes:{}}),white:A.Zu.colorZ,black:A.Zu.colorZ,text:A.Zu.colorZ,textInverted:A.Zu.colorZ,textOnPrimary:A.Zu.colorZ.default(A.Zu.ZERO),primaryText:A.Zu.colorZ,errorText:A.Zu.colorZ,warningText:A.Zu.colorZ,logo:a.z.string()}),sizes:a.z.object({base:a.z.number(),border:a.z.object({radius:a.z.number(),width:a.z.number(),thickWidth:a.z.number()}),schematic:a.z.object({elementStrokeWidth:a.z.number()})}),typography:a.z.object({family:a.z.string(),codeFamily:a.z.string(),h1:Qe.specZ,h2:Qe.specZ,h3:Qe.specZ,h4:Qe.specZ,h5:Qe.specZ,p:Qe.specZ,small:Qe.specZ})}).transform(t=>((t.colors.textOnPrimary==null||A.Zu.isZero(t.colors.textOnPrimary))&&(t.colors.textOnPrimary=A.Zu.pickByContrast(t.colors.primary.z,t.colors.text,t.colors.textInverted)),t)),AA='"Inter Variable", sans-serif',xA='"Geist Mono", monospace',IA=6,sr=[357,91,55,1],ar=[48,90,55,1],CA=["#FEFEFE","#FAFAFA","#F2F2F2","#ECECEC","#E4E4E4","#D1D1D1","#BCBCBC","#ACACAC","#8F8F8F","#4F4F4F","#292929","#050505"],ir=Object.fromEntries(CA.map((t,e)=>[`l${e}`,t])),jA=()=>typeof window>"u"?!1:window.devicePixelRatio>1,$A=jA(),Ks={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#356fc5",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:ir,border:ir.l4,error:{m2:A.Zu.fromHSLA(ge(sr,30)),m1:A.Zu.fromHSLA(ge(sr,40)),z:A.Zu.fromHSLA(sr),p1:A.Zu.fromHSLA(ge(sr,65)),p2:A.Zu.fromHSLA(ge(sr,77))},warning:{m2:A.Zu.fromHSLA(ge(ar,30)),m1:A.Zu.fromHSLA(ge(ar,40)),z:A.Zu.fromHSLA(ar),p1:A.Zu.fromHSLA(ge(ar,65)),p2:A.Zu.fromHSLA(ge(ar,75))},palettes:{recent:{key:"recent",name:"Recent",swatches:[]}},visualization:{palettes:{default:["#DC136C","#20A4F3","#7AC74F","#FFC43D","#FE5F55","#8075FF","#D90429","#f7aef8","#f18f01","#791e94","#279af1","#d9fff5","#ff6b6b","#52ffb8"]}},logo:"url(#synnax-linear-gradient)",white:"#FFFFFF",black:"#000000",text:ir.l11,textInverted:ir.l0,textOnPrimary:ir.l0,primaryText:"#3b82f6",errorText:"#ef4444",warningText:"#f59e0b"},sizes:{base:IA,border:{radius:3,width:$A?.5:1,thickWidth:1},schematic:{elementStrokeWidth:2}},typography:{family:AA,codeFamily:xA,h1:{size:5.5,weight:"500",lineHeight:5.5*1.5},h2:{size:4.5,weight:"medium",lineHeight:4.5*1.5},h3:{size:3.5,weight:"medium",lineHeight:3.5*1.5},h4:{size:2.6666,weight:"medium",lineHeight:2.6666*1.5},h5:{size:2.333333,weight:450,lineHeight:2.333333*1.5},p:{size:2.1666666666,weight:"regular",lineHeight:2*1.5},small:{size:1.916666,weight:"regular",lineHeight:2.3333333}}},pd=Object.freeze({...Ks,key:"synnaxLight",name:"Synnax Light"}),MA=["#020202","#080808","#151515","#202020","#272727","#3B3B3B","#4A4A4A","#5C5C5C","#767676","#959595","#dadada","#FAFAFA"],or=Object.fromEntries(MA.map((t,e)=>[`l${e}`,t])),yd=Object.freeze({...Ks,key:"synnaxDark",name:"Synnax Dark",colors:{...Ks.colors,gray:or,logo:"var(--pluto-text-color)",border:or.l4,text:or.l11,textInverted:or.l0,textOnPrimary:or.l11,primaryText:"#93c5fd",errorText:"#fca5a5",warningText:"#fcd34d"}}),_A={synnaxDark:yd,synnaxLight:pd},md=["tiny","small","medium","large","huge"],gd=a.z.enum(md),ZA=t=>gd.safeParse(t).success,Js="pluto-theming-context",wd=a.z.object({name:a.z.string(),url:a.z.string()}),UA=a.z.object({theme:fd,fontURLs:a.z.array(wd)});class Ar extends qr{static TYPE="theming.Provider";static z=UA;schema=Ar.z;afterUpdate(e){if(e.getOptional(Js)!=null&&this.state.theme.key===this.prevState.theme.key)return;e.set(Js,this.state.theme),dd(e)(async()=>{await this.loadFonts()},"failed to load theme fonts")}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:e,url:r})=>{const n=new FontFace(e,`url(${r})`);try{await n.load(),self.fonts.add(n)}catch(s){console.error(s)}}))}}const PA=t=>t.get(Js),RA={[Ar.TYPE]:Ar};exports.$A=vk;exports.$n=Tt;exports.Aggregator=Gs;exports.Composite=qr;exports.DA=US;exports.Gk=Xh;exports.HA=uN;exports.Hk=$E;exports.JA=CN;exports.Leaf=oi;exports.O=Wt;exports.PA=JS;exports.Provider=Ar;exports.QA=LN;exports.REGISTRY=RA;exports.REGISTRY$1=SA;exports.SA=Ob;exports.SIZES=md;exports.SYNNAX_DARK=yd;exports.SYNNAX_LIGHT=pd;exports.SYNNAX_THEMES=_A;exports.St=ie;exports.TA=ib;exports.UA=kS;exports.Vk=Qh;exports.W=W;exports.WA=ON;exports.YA=q0;exports._=Ht;exports.a$=ME;exports.aether=vA;exports.aggregatorStateZ=hd;exports.at=ot;exports.be=ed;exports.createAsyncErrorHandler=ud;exports.createErrorHandler=ld;exports.fA=tw;exports.fontSpecZ=wd;exports.g=sd;exports.g$1=E;exports.i$=jE;exports.isFireAndForget=ii;exports.isSize=ZA;exports.jA=wS;exports.kA=KT;exports.n$=dE;exports.pA=bw;exports.prettyParse=Ws;exports.qA=$0;exports.render=ad;exports.s$=zE;exports.size=gd;exports.themeZ=fd;exports.use=PA;exports.useAdder=ci;exports.useAsyncErrorHandler=kA;exports.useErrorHandler=dd;exports.useOptionalAdder=TA;exports.w=C;exports.wA=Aw;exports.xA=$k;exports.y=_;
|