@synnaxlabs/pluto 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Animated-CnvOerW9.js → Animated-C7JTBH0T.js} +6 -6
- package/dist/{Animated-Ck87AGOu.cjs → Animated-D4IT49PS.cjs} +1 -1
- package/dist/{Item--wCat2DH.js → Item-4yG7GmwK.js} +23 -23
- package/dist/{Item-DuNQFmgk.cjs → Item-DuYEON-n.cjs} +1 -1
- package/dist/{Keyboard-DPs95Etp.cjs → Keyboard-BPoxRive.cjs} +1 -1
- package/dist/{Keyboard-Dh_Fhwg4.js → Keyboard-Csje8Cyn.js} +2 -2
- package/dist/LinePlot-DbXPZbQH.cjs +34 -0
- package/dist/{LinePlot-6KHKqa-2.js → LinePlot-DqoSTxNs.js} +2630 -2365
- package/dist/{Link-BHtl4aby.cjs → Link-BRv9hhIc.cjs} +1 -1
- package/dist/{Link-CDG2-g6A.js → Link-Crud0q_J.js} +1 -1
- package/dist/{List-BjimX8fM.js → List-Cuz80sgI.js} +6 -6
- package/dist/{List-C8vXIE2j.cjs → List-Pyj0u9YT.cjs} +1 -1
- package/dist/{Pack-D6eMgf33.js → Pack-BzCJQZ58.js} +1 -1
- package/dist/{Pack-DijAGcm_.cjs → Pack-Dvf8sQVK.cjs} +1 -1
- package/dist/Text-BJ2Pml4B.cjs +1 -0
- package/dist/{Text-CzgVM_22.js → Text-DMMYBs-R.js} +12 -12
- package/dist/{Toggle-Cdu7WaiC.js → Toggle-CLkPIiQK.js} +10438 -10080
- package/dist/Toggle-DnW_7Wr_.cjs +143 -0
- package/dist/{Video-DYSz9XOF.js → Video-BGyV37o3.js} +1 -1
- package/dist/{Video-BgDjKMJx.cjs → Video-CGe5Hscl.cjs} +1 -1
- package/dist/{aggregator-DzdAnRwI.js → aggregator-23mu0FOF.js} +2322 -2177
- package/dist/aggregator-y-jNJhKX.cjs +67 -0
- package/dist/align.cjs +1 -1
- package/dist/align.js +1 -1
- 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/css-BghghSL0.cjs +1 -0
- package/dist/css-DJCM-h5_.js +1178 -0
- package/dist/css.cjs +1 -1
- package/dist/css.js +2 -2
- package/dist/dropdown.cjs +1 -1
- package/dist/dropdown.js +1 -1
- package/dist/ether.cjs +1 -1
- package/dist/ether.js +75 -62
- package/dist/{external-k3Jbrj0m.js → external-0a9KHHwz.js} +13 -13
- package/dist/external-3DAfrFCZ.cjs +1 -0
- package/dist/{external-eI1p10Vf.cjs → external-B7Vpq1ol.cjs} +1 -1
- package/dist/{external-DRHWURjA.cjs → external-BV_9eXZJ.cjs} +1 -1
- package/dist/{external-lgZ2Gmbx.js → external-BZwFy-XX.js} +16 -16
- package/dist/{external-CoQwrjWl.js → external-CIH3tMhP.js} +29 -29
- package/dist/{external-BOIjtEGO.js → external-Cf5a9Ia8.js} +2 -2
- package/dist/{external-FVIwMFDr.js → external-CgpiH-10.js} +102 -102
- package/dist/{external-DcMAC_pY.js → external-Cgq0p0a8.js} +133 -126
- package/dist/{external-D9Q5Xjko.js → external-Ci-UP3Vu.js} +2 -2
- package/dist/external-CqLAQBcO.cjs +1 -0
- package/dist/{external-Cc9o20Al.cjs → external-Ctvxtwfh.cjs} +1 -1
- package/dist/{external-CAIE4G3V.cjs → external-D-PsJ1E5.cjs} +1 -1
- package/dist/external-D7FmaiqY.js +248 -0
- package/dist/{external-DvRQ7lJU.js → external-DAbicix6.js} +2 -2
- package/dist/external-DVF3ZJ4z.js +32 -0
- package/dist/external-De9tKPlO.js +76 -0
- package/dist/{external-CYsmC4uZ.cjs → external-Dk1cXh1i.cjs} +1 -1
- package/dist/{external-mtlL4Z3a.cjs → external-DtnrBHvV.cjs} +1 -1
- package/dist/external-ZxIaRZdb.cjs +1 -0
- package/dist/{external-BbS4QDTb.cjs → external-iiNZw96o.cjs} +1 -1
- package/dist/{external-DsKRFJxV.cjs → external-t43feeRt.cjs} +1 -1
- package/dist/{external-mE-a2ecU.js → external-xhGCeglf.js} +1 -1
- package/dist/{external-CjmMj11F.cjs → external-xtDHiIUX.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +8292 -7208
- 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/src/breadcrumb/Breadcrumb.d.ts +10 -2
- package/dist/src/breadcrumb/Breadcrumb.d.ts.map +1 -1
- package/dist/src/button/Button.d.ts +2 -0
- package/dist/src/button/Button.d.ts.map +1 -1
- package/dist/src/button/Icon.d.ts +2 -0
- package/dist/src/button/Icon.d.ts.map +1 -1
- package/dist/src/color/GradientPicker.d.ts +10 -0
- package/dist/src/color/GradientPicker.d.ts.map +1 -0
- package/dist/src/color/Picker.d.ts +9 -0
- package/dist/src/color/Picker.d.ts.map +1 -0
- package/dist/src/color/Provider.d.ts +139 -0
- package/dist/src/color/Provider.d.ts.map +1 -0
- package/dist/src/color/Swatch.d.ts +13 -0
- package/dist/src/color/Swatch.d.ts.map +1 -0
- package/dist/src/color/core/external.d.ts +4 -0
- package/dist/src/color/core/external.d.ts.map +1 -0
- package/dist/src/color/core/gradient.d.ts +58 -0
- package/dist/src/color/core/gradient.d.ts.map +1 -0
- package/dist/src/color/core/index.d.ts +1 -2
- package/dist/src/color/core/index.d.ts.map +1 -1
- package/dist/src/color/core/palette.d.ts +74 -0
- package/dist/src/color/core/palette.d.ts.map +1 -0
- package/dist/src/color/external.d.ts +4 -1
- package/dist/src/color/external.d.ts.map +1 -1
- package/dist/src/haul/Haul.d.ts +0 -1
- package/dist/src/haul/Haul.d.ts.map +1 -1
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/index.d.ts.map +1 -1
- package/dist/src/hooks/useDelayedState.d.ts +11 -0
- package/dist/src/hooks/useDelayedState.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/input/Text.d.ts.map +1 -1
- package/dist/src/nav/Drawer.d.ts.map +1 -1
- package/dist/src/notation/Select.d.ts +8 -0
- package/dist/src/notation/Select.d.ts.map +1 -0
- package/dist/src/notation/external.d.ts +3 -0
- package/dist/src/notation/external.d.ts.map +1 -0
- package/dist/src/notation/index.d.ts +2 -0
- package/dist/src/notation/index.d.ts.map +1 -0
- package/dist/src/notation/notation.d.ts.map +1 -1
- package/dist/src/pluto/Pluto.d.ts +3 -1
- package/dist/src/pluto/Pluto.d.ts.map +1 -1
- package/dist/src/pluto/aether/pluto.d.ts.map +1 -1
- package/dist/src/select/Button.d.ts +5 -3
- package/dist/src/select/Button.d.ts.map +1 -1
- package/dist/src/select/Direction.d.ts +2 -1
- package/dist/src/select/Direction.d.ts.map +1 -1
- package/dist/src/select/Single.d.ts +1 -1
- package/dist/src/select/Single.d.ts.map +1 -1
- package/dist/src/status/Circle.d.ts +1 -1
- package/dist/src/status/Circle.d.ts.map +1 -1
- package/dist/src/table/Table.d.ts +30 -0
- package/dist/src/table/Table.d.ts.map +1 -0
- package/dist/src/table/aether/Table.d.ts +493 -0
- package/dist/src/table/aether/Table.d.ts.map +1 -0
- package/dist/src/table/aether/index.d.ts +2 -0
- package/dist/src/table/aether/index.d.ts.map +1 -0
- package/dist/src/table/cells/Cells.d.ts +191 -0
- package/dist/src/table/cells/Cells.d.ts.map +1 -0
- package/dist/src/table/cells/Forms.d.ts +7 -0
- package/dist/src/table/cells/Forms.d.ts.map +1 -0
- package/dist/src/table/cells/index.d.ts +2 -0
- package/dist/src/table/cells/index.d.ts.map +1 -0
- package/dist/src/table/cells/registry.d.ts +17 -0
- package/dist/src/table/cells/registry.d.ts.map +1 -0
- package/dist/src/table/external.d.ts +2 -0
- package/dist/src/table/external.d.ts.map +1 -0
- package/dist/src/table/index.d.ts +2 -0
- package/dist/src/table/index.d.ts.map +1 -0
- package/dist/src/telem/aether/pipeline.d.ts +35 -24
- package/dist/src/telem/aether/pipeline.d.ts.map +1 -1
- package/dist/src/telem/aether/provider.d.ts +7 -6
- package/dist/src/telem/aether/provider.d.ts.map +1 -1
- package/dist/src/telem/aether/static.d.ts +22 -1
- package/dist/src/telem/aether/static.d.ts.map +1 -1
- package/dist/src/telem/aether/transformers.d.ts +217 -2
- package/dist/src/telem/aether/transformers.d.ts.map +1 -1
- package/dist/src/telem/control/aether/controller.d.ts.map +1 -1
- package/dist/src/text/Editable.d.ts +2 -1
- package/dist/src/text/Editable.d.ts.map +1 -1
- package/dist/src/text/Select.d.ts +19 -0
- package/dist/src/text/Select.d.ts.map +1 -0
- package/dist/src/text/core/types.d.ts +2 -1
- package/dist/src/text/core/types.d.ts.map +1 -1
- package/dist/src/text/external.d.ts +1 -1
- package/dist/src/text/external.d.ts.map +1 -1
- package/dist/src/theming/Provider.d.ts.map +1 -1
- package/dist/src/theming/aether/provider.d.ts +375 -0
- package/dist/src/theming/aether/provider.d.ts.map +1 -1
- package/dist/src/theming/core/theme.d.ts +127 -0
- package/dist/src/theming/core/theme.d.ts.map +1 -1
- package/dist/src/tree/core.d.ts +3 -1
- package/dist/src/tree/core.d.ts.map +1 -1
- package/dist/src/vis/axis/canvas.d.ts +11 -0
- package/dist/src/vis/axis/canvas.d.ts.map +1 -1
- package/dist/src/vis/canvas/Canvas.d.ts.map +1 -1
- package/dist/src/vis/diagram/Diagram.d.ts +2 -1
- package/dist/src/vis/diagram/Diagram.d.ts.map +1 -1
- package/dist/src/vis/diagram/aether/types.d.ts +17 -0
- package/dist/src/vis/diagram/aether/types.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/Edge.d.ts +3 -2
- package/dist/src/vis/diagram/edge/Edge.d.ts.map +1 -1
- package/dist/src/vis/diagram/edge/paths.d.ts +20 -0
- package/dist/src/vis/diagram/edge/paths.d.ts.map +1 -0
- package/dist/src/vis/diagram/external.d.ts +1 -0
- package/dist/src/vis/diagram/external.d.ts.map +1 -1
- package/dist/src/vis/draw2d/canvas.d.ts +19 -0
- package/dist/src/vis/draw2d/canvas.d.ts.map +1 -1
- package/dist/src/vis/legend/Container.d.ts.map +1 -1
- package/dist/src/vis/line/aether/line.d.ts.map +1 -1
- package/dist/src/vis/lineplot/aether/YAxis.d.ts.map +1 -1
- package/dist/src/vis/render/context.d.ts.map +1 -1
- package/dist/src/vis/schematic/Forms.d.ts +1 -0
- package/dist/src/vis/schematic/Forms.d.ts.map +1 -1
- package/dist/src/vis/schematic/Grid.d.ts +16 -0
- package/dist/src/vis/schematic/Grid.d.ts.map +1 -0
- package/dist/src/vis/schematic/Symbols.d.ts +248 -371
- package/dist/src/vis/schematic/Symbols.d.ts.map +1 -1
- package/dist/src/vis/schematic/primitives/Primitives.d.ts +39 -0
- package/dist/src/vis/schematic/primitives/Primitives.d.ts.map +1 -1
- package/dist/src/vis/schematic/registry.d.ts +2 -2
- package/dist/src/vis/schematic/registry.d.ts.map +1 -1
- package/dist/src/vis/value/Form.d.ts +9 -0
- package/dist/src/vis/value/Form.d.ts.map +1 -0
- package/dist/src/vis/value/aether/value.d.ts +167 -0
- package/dist/src/vis/value/aether/value.d.ts.map +1 -1
- package/dist/src/vis/value/external.d.ts +1 -0
- package/dist/src/vis/value/external.d.ts.map +1 -1
- package/dist/src/vis/value/use.d.ts +56 -1
- package/dist/src/vis/value/use.d.ts.map +1 -1
- package/dist/src/workMain.d.ts +2 -0
- package/dist/src/workMain.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text.cjs +1 -1
- package/dist/text.js +2 -2
- 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/{units-CR-P9eLW.cjs → units-9h1yAbxY.cjs} +1 -1
- package/dist/{units-rb5QAWjs.js → units-D19WggGS.js} +1 -1
- package/dist/video.cjs +1 -1
- package/dist/video.js +1 -1
- package/package.json +6 -5
- package/dist/LinePlot--yLT9nkT.cjs +0 -34
- package/dist/Text-Cg0q7seY.cjs +0 -1
- package/dist/Toggle-CP9KtybX.cjs +0 -143
- package/dist/aggregator-C0Ab25_o.cjs +0 -67
- package/dist/css-B4FcyECk.js +0 -1112
- package/dist/css-Dh7n0EGs.cjs +0 -1
- package/dist/external-B72rRj4o.js +0 -76
- package/dist/external-CsqyDUsJ.js +0 -96
- package/dist/external-CsrLjLOh.cjs +0 -1
- package/dist/external-Dm2-owlq.cjs +0 -1
- package/dist/external-Yf8Lv9AU.js +0 -248
- package/dist/external-gz4sf3pG.cjs +0 -1
- package/dist/src/color/Picker/Picker.d.ts +0 -7
- package/dist/src/color/Picker/Picker.d.ts.map +0 -1
- package/dist/src/color/Picker/index.d.ts +0 -2
- package/dist/src/color/Picker/index.d.ts.map +0 -1
- package/dist/src/color/Swatch/Swatch.d.ts +0 -10
- package/dist/src/color/Swatch/Swatch.d.ts.map +0 -1
- package/dist/src/color/Swatch/index.d.ts +0 -2
- package/dist/src/color/Swatch/index.d.ts.map +0 -1
- package/dist/src/notation/SelectNotation.d.ts +0 -12
- package/dist/src/notation/SelectNotation.d.ts.map +0 -1
- package/dist/src/text/SelectLevel.d.ts +0 -12
- package/dist/src/text/SelectLevel.d.ts.map +0 -1
- package/dist/src/vis/schematic/Labeled.d.ts +0 -17
- package/dist/src/vis/schematic/Labeled.d.ts.map +0 -1
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";var ac=Object.defineProperty;var oc=(t,e,n)=>e in t?ac(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var P=(t,e,n)=>oc(t,typeof e!="symbol"?e+"":e,n);const s=require("zod"),O=require("./css-Dh7n0EGs.cjs"),Cs=require("react"),Yt=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var lc=Object.defineProperty,cc=(t,e,n)=>e in t?lc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,qt=(t,e,n)=>cc(t,typeof e!="symbol"?e+"":e,n);let uc=class{constructor(){qt(this,"contentType","application/json"),qt(this,"decoder"),qt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,n){return this.decodeString(this.decoder.decode(e),n)}decodeString(e,n){const r=JSON.parse(e),i=O.k(r);return n!=null?n.parse(i):i}encodeString(e){const n=O.C(e);return JSON.stringify(n,(r,i)=>ArrayBuffer.isView(i)?Array.from(i):Yt(i)&&"encode_value"in i?typeof i.value=="bigint"?i.value.toString():i.value:typeof i=="bigint"?i.toString():i)}static registerCustomType(){}},hc=class{constructor(){qt(this,"contentType","text/csv")}encode(e){const n=this.encodeString(e);return new TextEncoder().encode(n).buffer}decode(e,n){const r=new TextDecoder().decode(e);return this.decodeString(r,n)}encodeString(e){if(!Array.isArray(e)||e.length===0||!Yt(e[0]))throw new Error("Payload must be an array of objects");const n=Object.keys(e[0]),r=[n.join(",")];return e.forEach(i=>{const a=n.map(o=>JSON.stringify(i[o]??""));r.push(a.join(","))}),r.join(`
|
|
2
|
-
`)}decodeString(e,n){const[r,...i]=e.trim().split(`
|
|
3
|
-
`).map(c=>c.trim());if(r.length===0)return n!=null?n.parse({}):{};const a=r.split(",").map(c=>c.trim()),o={};return a.forEach(c=>{o[c]=[]}),i.forEach(c=>{const u=c.split(",").map(h=>h.trim());a.forEach((h,f)=>{const d=this.parseValue(u[f]);d!=null&&o[h].push(d)})}),n!=null?n.parse(o):o}parseValue(e){if(e==null||e.length===0)return null;const n=Number(e);return isNaN(n)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:n}static registerCustomType(){}},dc=class{constructor(){qt(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,n){const r=new TextDecoder().decode(e);return n!=null?n.parse(r):r}};const On=new uc;new hc;new dc;const Xr=t=>[...new Set(t)],Ta=t=>t!=null&&typeof t=="object"&&"toString"in t,fc=t=>{if(Ta(t))return(t==null?void 0:t.toString().length)===0;switch(typeof t){case"string":return t.length===0;case"number":return t===0;case"bigint":return t===0n;case"boolean":return!t;case"undefined":return!0;case"object":return t===null}},or=(t,e=!1)=>{const n=Ta(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?za(r):r},yc=(t,e,n)=>{const r=or(e[t],n);return(i,a)=>r(i[t],a[t])},gc=(t,e)=>t.length!==e.length?t.length-e.length:t.every((n,r)=>n===e[r])?0:-1,Sa=(t,e)=>{if(t.length!==e.length)return t.length-e.length;if(t.length===0)return 0;const n=or(t[0]),r=[...t].sort(n),i=[...e].sort(n);return r.every((a,o)=>a===i[o])?0:-1},pc=(t,e)=>{const n=Xr(t),r=Xr(e);return Sa(n,r)},mc=(t,e)=>t===e?0:t==="first"&&e==="last"?1:-1,za=t=>(e,n)=>t(n,e),ht=0,Tn=-1,Sn=1,Na=t=>t<ht,Ia=t=>t>ht,wc=t=>t>=ht,Ea=t=>t===ht,bc=(t,e)=>{const n=/([a-zA-Z]+)|(\d+)/g,r=t.replace(/[\s_.-]+/g,"").match(n),i=e.replace(/[\s_.-]+/g,"").match(n);if(!r||!i)return 0;for(let a=0;a<Math.min(r.length,i.length);a++){const o=r[a],c=i[a];if(isNaN(Number(o))&&isNaN(Number(c))){const u=o.localeCompare(c);if(u!==0)return u}else if(!isNaN(Number(o))&&!isNaN(Number(c))){const u=Number(o)-Number(c);if(u!==0)return u}else return isNaN(Number(o))?-1:1}return r.length-i.length},vc=Object.freeze(Object.defineProperty({__proto__:null,EQUAL:ht,GREATER_THAN:Sn,LESS_THAN:Tn,isEqualTo:Ea,isGreaterThan:Ia,isGreaterThanEqual:wc,isLessThan:Na,newF:or,newFieldF:yc,order:mc,primitiveArrays:gc,reverseF:za,stringsWithNumbers:bc,uniqueUnorderedPrimitiveArrays:pc,unorderedPrimitiveArrays:Sa},Symbol.toStringTag,{value:"Module"})),Oc=(t,e)=>{let n=null;return e===0?t:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...r),e)}},Tc=(t,e)=>{let n=null;return e===0?t:(...r)=>{n===null&&(n=setTimeout(()=>{t(...r),n=null},e))}},Aa=(t,e,n=".")=>{const r=t.split(n);return r.map((i,a)=>{const o=e(i,a,r);return o==null?null:typeof o=="string"?o:o.join(n)}).filter(i=>i!=null).join(n)},$s=(t,e,n={optional:!1,separator:"."})=>{n.separator??(n.separator=".");const{optional:r,getter:i=(c,u)=>c[u]}=n,a=e.split(n.separator);if(a.length===1&&a[0]==="")return t;let o=t;for(const c of a){const u=i(o,c);if(u==null){if(r)return null;throw new Error(`Path ${e} does not exist. ${c} is null`)}o=u}return o},Sc=(t,e,n)=>{const r=e.split(".");let i=t;for(let a=0;a<r.length-1;a++){const o=r[a];i[o]??(i[o]={}),i=i[o]}i[r[r.length-1]]=n},zc=(t,e)=>{const n=e.split(".");let r=t;for(let i=0;i<n.length-1;i++){const a=n[i];if(r[a]==null)return;r=r[a]}if(Array.isArray(r)){const i=parseInt(n[n.length-1]);if(isNaN(i))return;r.splice(i,1);return}delete r[n[n.length-1]]},Nc=(t,e)=>{const n=t.split(".");return e<0?n[n.length+e]:n[e]},Ic=(t,e)=>{try{return $s(t,e),!0}catch{return!1}},Ec=(t,e)=>{if(e.length===0)return!0;const n=t.split("."),r=e.split(".");if(r.length>n.length)return!1;for(let i=0;i<r.length;i++){const a=n[i],o=r[i];if(o!=="*"&&a!==o)return!1}return!0},Ac=t=>JSON.parse(JSON.stringify(t)),kc=(t,...e)=>(e.forEach(n=>{let r=t;const i=n.split(".");i.forEach((a,o)=>{o===i.length-1?delete r[a]:a in r&&(r=r[a])})}),t),xc=(t,e,n="")=>{const r={},i=(a,o,c)=>{if(typeof a!=typeof o||a===null||o===null){r[c]=[a,o];return}if(typeof a=="object"&&typeof o=="object")if(Array.isArray(a)&&Array.isArray(o)){if(a.length!==o.length){r[c]=[a,o];return}for(let u=0;u<a.length;u++)i(a[u],o[u],`${c}[${u}]`)}else new Set([...Object.keys(a),...Object.keys(o)]).forEach(u=>{i(a[u],o[u],c!==""?`${c}.${u}`:u)});else a!==o&&(r[c]=[a,o])};return i(t,e,n),r},Qr=(t,e)=>{const n=Array.isArray(t),r=Array.isArray(e);if(n!==r)return!1;if(n&&r){const o=t,c=e;if(o.length!==c.length)return!1;for(let u=0;u<o.length;u++)if(!Qr(o[u],c[u]))return!1;return!0}if(t==null||e==null||typeof t!="object"||typeof e!="object")return t===e;if("equals"in t)return t.equals(e);const i=Object.keys(t),a=Object.keys(e);if(i.length!==a.length)return!1;for(const o of i){const c=t[o],u=e[o];if(typeof c=="object"&&typeof u=="object"){if(!Qr(c,u))return!1}else if(c!==u)return!1}return!0},ka=(t,e)=>{if(typeof t!="object"||t==null)return t===e;const n=Object.keys(t),r=Object.keys(e);if(r.length>n.length)return!1;for(const i of r){const a=t[i],o=e[i];if(typeof a=="object"&&typeof o=="object"){if(!ka(a,o))return!1}else if(a!==o)return!1}return!0},es=(t,...e)=>{if(e.length===0)return t;const n=e.shift();if(Yt(t)&&Yt(n))for(const r in n)try{Yt(n[r])?(r in t||Object.assign(t,{[r]:{}}),es(t[r],n[r])):Object.assign(t,{[r]:n[r]})}catch(i){throw i instanceof TypeError?new TypeError(`.${r}: ${i.message}`):i}return es(t,...e)},Cc=(t,e,n)=>{const r=(i,a,o)=>{for(const c in a){const u=a[c];if(o!=null&&o.shape[c]){const h=o.shape[c].safeParse(u);h.success&&(i[c]=h.data)}else typeof u=="object"&&!Array.isArray(u)&&u!==null&&o&&o.shape&&o.shape[c]&&(i[c]||(i[c]={}),r(i[c],u,o.shape[c]))}return i};return r({...t},e,n)},xa=Object.freeze(Object.defineProperty({__proto__:null,copy:Ac,deleteD:kc,difference:xc,element:Nc,equal:Qr,get:$s,has:Ic,override:es,overrideValidItems:Cc,partialEqual:ka,pathsMatch:Ec,remove:zc,set:Sc,transformPath:Aa},Symbol.toStringTag,{value:"Module"})),Ca=t=>Aa(t,(e,n,r)=>{const i=n===r.length-1,a=!isNaN(parseInt(e)),o=!isNaN(parseInt(r[n+1]));return a&&(e="element"),i||o?e:[e,"shape"]}),ui=(t,e)=>{if(t==null)return null;const n=t[e];return n==null&&typeof t=="object"&&"sourceType"in t?t.sourceType()[e]:n},$c=(t,e,n)=>$s(ui(t,"shape"),Ca(e),{...n,getter:ui}),Rc=(t,e)=>n=>{const r=e.find(i=>i.safeParse(n).success);return r==null?null:t(r.parse(n))},$a=s.z.bigint().or(s.z.string().transform(BigInt)),jc=Object.freeze(Object.defineProperty({__proto__:null,bigInt:$a,getFieldSchema:$c,getFieldSchemaPath:Ca,transformer:Rc},Symbol.toStringTag,{value:"Module"}));var Bc=Object.defineProperty,Mc=(t,e,n)=>e in t?Bc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,y=(t,e,n)=>Mc(t,typeof e!="symbol"?e+"":e,n);let Dc=(t,e=21)=>(n=e)=>{let r="",i=n;for(;i--;)r+=t[Math.random()*t.length|0];return r};const Pc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ra=Dc(Pc,11),ja=Object.freeze(Object.defineProperty({__proto__:null,id:Ra},Symbol.toStringTag,{value:"Module"})),Uc=s.z.enum(["static","dynamic"]),Ba=(t,e)=>{const n=new W(e);if(![Z.DAY,Z.HOUR,Z.MINUTE,Z.SECOND,Z.MILLISECOND,Z.MICROSECOND,Z.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof W?new W(r):new Z(r)},U=class S{constructor(e,n="UTC"){if(y(this,"value"),y(this,"encodeValue",!0),e==null)this.value=S.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*S.MILLISECOND.valueOf();else if(typeof e=="string")this.value=S.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=S.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=S.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=S.MAX:e=S.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new S(BigInt(i.getTime())*S.MILLISECOND.valueOf()).truncate(S.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=S.hours(parseInt(r??"00")).add(S.minutes(parseInt(i??"00"))).add(S.seconds(parseInt(o??"00"))).add(S.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(S.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return S.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new S(BigInt(r.getTime())*S.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(S.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new Z(BigInt(new Date().getTimezoneOffset())*S.MINUTE.valueOf())}static since(e){return new S().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new S(e).valueOf()}span(e){return this.range(e).span}range(e){return new it(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new S(e).valueOf()}afterEq(e){return this.valueOf()>=new S(e).valueOf()}before(e){return this.valueOf()<new S(e).valueOf()}beforeEq(e){return this.valueOf()<=new S(e).valueOf()}add(e){return new S(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new S(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(S.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Ba(this,e)}get isToday(){return this.truncate(Z.DAY).equals(S.now().truncate(Z.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new S(new Date)}static max(...e){let n=S.MIN;for(const r of e){const i=new S(r);i.after(n)&&(n=i)}return n}static min(...e){let n=S.MAX;for(const r of e){const i=new S(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new S(e)}static microseconds(e){return S.nanoseconds(e*1e3)}static milliseconds(e){return S.microseconds(e*1e3)}static seconds(e){return S.milliseconds(e*1e3)}static minutes(e){return S.seconds(e*60)}static hours(e){return S.minutes(e*60)}static days(e){return S.hours(e*24)}};y(U,"NANOSECOND",U.nanoseconds(1)),y(U,"MICROSECOND",U.microseconds(1)),y(U,"MILLISECOND",U.milliseconds(1)),y(U,"SECOND",U.seconds(1)),y(U,"MINUTE",U.minutes(1)),y(U,"HOUR",U.hours(1)),y(U,"DAY",U.days(1)),y(U,"MAX",new U((1n<<63n)-1n)),y(U,"MIN",new U(0)),y(U,"ZERO",new U(0)),y(U,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new U(t.value)),s.z.string().transform(t=>new U(BigInt(t))),s.z.instanceof(Number).transform(t=>new U(t)),s.z.number().transform(t=>new U(t)),s.z.instanceof(U)]));let W=U;const L=class I{constructor(e){y(this,"value"),y(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof I?e:e instanceof ts?e.period:e instanceof W?new I(e):["number","bigint"].includes(typeof e)?I.seconds(e):new I(e)}static fromMilliseconds(e){return e instanceof I?e:e instanceof ts?e.period:e instanceof W?new I(e):["number","bigint"].includes(typeof e)?I.milliseconds(e):new I(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new I(e).valueOf()}greaterThan(e){return this.valueOf()>new I(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new I(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new I(e).valueOf()}remainder(e){return Ba(this,e)}truncate(e){return new I(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(I.DAY),n=this.truncate(I.HOUR),r=this.truncate(I.MINUTE),i=this.truncate(I.SECOND),a=this.truncate(I.MILLISECOND),o=this.truncate(I.MICROSECOND),c=this.truncate(I.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),k=a.sub(i),D=o.sub(a),ie=c.sub(o);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 `),k.isZero||(B+=`${k.milliseconds}ms `),D.isZero||(B+=`${D.microseconds}µs `),ie.isZero||(B+=`${ie.nanoseconds}ns`),B.trim()}get days(){return Number(this.valueOf())/Number(I.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(I.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(I.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(I.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(I.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(I.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new I(e).valueOf()}add(e){return new I(this.valueOf()+new I(e).valueOf())}sub(e){return new I(this.valueOf()-new I(e).valueOf())}static nanoseconds(e=1){return new I(e)}static microseconds(e=1){return I.nanoseconds(O.M(e,1e3))}static milliseconds(e=1){return I.microseconds(O.M(e,1e3))}static seconds(e=1){return I.milliseconds(O.M(e,1e3))}static minutes(e=1){return I.seconds(O.M(e,60))}static hours(e){return I.minutes(O.M(e,60))}static days(e){return I.hours(O.M(e,24))}};y(L,"NANOSECOND",L.nanoseconds(1)),y(L,"MICROSECOND",L.microseconds(1)),y(L,"MILLISECOND",L.milliseconds(1)),y(L,"SECOND",L.seconds(1)),y(L,"MINUTE",L.minutes(1)),y(L,"HOUR",L.hours(1)),y(L,"DAY",L.days(1)),y(L,"MAX",new L((1n<<63n)-1n)),y(L,"MIN",new L(0)),y(L,"ZERO",new L(0)),y(L,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new L(t.value)),s.z.string().transform(t=>new L(BigInt(t))),s.z.instanceof(Number).transform(t=>new L(t)),s.z.number().transform(t=>new L(t)),s.z.instanceof(L)]));let Z=L;const Tt=class zn extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new zn(e).valueOf()}get period(){return Z.seconds(1/this.valueOf())}sampleCount(e){return new Z(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new ce(n).valueOf()}span(e){return Z.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new zn(e)}static khz(e){return zn.hz(e*1e3)}};y(Tt,"z",s.z.union([s.z.number().transform(t=>new Tt(t)),s.z.instanceof(Number).transform(t=>new Tt(t)),s.z.instanceof(Tt)]));let ts=Tt;const te=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Zt(e*this.valueOf())}};y(te,"UNKNOWN",new te(0)),y(te,"BIT128",new te(16)),y(te,"BIT64",new te(8)),y(te,"BIT32",new te(4)),y(te,"BIT16",new te(2)),y(te,"BIT8",new te(1)),y(te,"z",s.z.union([s.z.number().transform(t=>new te(t)),s.z.instanceof(Number).transform(t=>new te(t)),s.z.instanceof(te)]));let ce=te;const Se=class Nn{constructor(e,n){y(this,"start"),y(this,"end"),typeof e=="object"&&"start"in e?(this.start=new W(e.start),this.end=new W(e.end)):(this.start=new W(e),this.end=new W(n))}get span(){return new Z(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Nn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=Z.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=W.max(r.start,e.start),a=W.min(r.end,e.end);return a.before(i)?!1:new Z(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof Nn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new Nn(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};y(Se,"MAX",new Se(W.MIN,W.MAX)),y(Se,"MIN",new Se(W.MAX,W.MIN)),y(Se,"ZERO",new Se(W.ZERO,W.ZERO)),y(Se,"z",s.z.union([s.z.object({start:W.z,end:W.z}).transform(t=>new Se(t.start,t.end)),s.z.instanceof(Se)]));let it=Se;const p=class ze extends String{constructor(e){if(e instanceof ze||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=ze.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(ze.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=ze.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(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(ze.JSON)||this.equals(ze.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(ze.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=ze.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return ze.BIG_INT_TYPES.some(e=>e.equals(this))}};y(p,"UNKNOWN",new p("unknown")),y(p,"FLOAT64",new p("float64")),y(p,"FLOAT32",new p("float32")),y(p,"INT64",new p("int64")),y(p,"INT32",new p("int32")),y(p,"INT16",new p("int16")),y(p,"INT8",new p("int8")),y(p,"UINT64",new p("uint64")),y(p,"UINT32",new p("uint32")),y(p,"UINT16",new p("uint16")),y(p,"UINT8",new p("uint8")),y(p,"BOOLEAN",p.UINT8),y(p,"TIMESTAMP",new p("timestamp")),y(p,"UUID",new p("uuid")),y(p,"STRING",new p("string")),y(p,"JSON",new p("json")),y(p,"ARRAY_CONSTRUCTORS",new Map([[p.UINT8.toString(),Uint8Array],[p.UINT16.toString(),Uint16Array],[p.UINT32.toString(),Uint32Array],[p.UINT64.toString(),BigUint64Array],[p.FLOAT32.toString(),Float32Array],[p.FLOAT64.toString(),Float64Array],[p.INT8.toString(),Int8Array],[p.INT16.toString(),Int16Array],[p.INT32.toString(),Int32Array],[p.INT64.toString(),BigInt64Array],[p.TIMESTAMP.toString(),BigInt64Array],[p.STRING.toString(),Uint8Array],[p.JSON.toString(),Uint8Array],[p.UUID.toString(),Uint8Array]])),y(p,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,p.UINT8],[Uint16Array.name,p.UINT16],[Uint32Array.name,p.UINT32],[BigUint64Array.name,p.UINT64],[Float32Array.name,p.FLOAT32],[Float64Array.name,p.FLOAT64],[Int8Array.name,p.INT8],[Int16Array.name,p.INT16],[Int32Array.name,p.INT32],[BigInt64Array.name,p.INT64]])),y(p,"DENSITIES",new Map([[p.UINT8.toString(),ce.BIT8],[p.UINT16.toString(),ce.BIT16],[p.UINT32.toString(),ce.BIT32],[p.UINT64.toString(),ce.BIT64],[p.FLOAT32.toString(),ce.BIT32],[p.FLOAT64.toString(),ce.BIT64],[p.INT8.toString(),ce.BIT8],[p.INT16.toString(),ce.BIT16],[p.INT32.toString(),ce.BIT32],[p.INT64.toString(),ce.BIT64],[p.TIMESTAMP.toString(),ce.BIT64],[p.STRING.toString(),ce.UNKNOWN],[p.JSON.toString(),ce.UNKNOWN],[p.UUID.toString(),ce.BIT128]])),y(p,"ALL",[p.UNKNOWN,p.FLOAT64,p.FLOAT32,p.INT64,p.INT32,p.INT16,p.INT8,p.UINT64,p.UINT32,p.UINT16,p.UINT8,p.TIMESTAMP,p.UUID,p.STRING,p.JSON]),y(p,"BIG_INT_TYPES",[p.INT64,p.UINT64,p.TIMESTAMP]),y(p,"z",s.z.union([s.z.string().transform(t=>new p(t)),s.z.instanceof(p)]));let j=p;const ae=class J extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return J.bytes(this.valueOf()+e.valueOf())}sub(e){return J.bytes(this.valueOf()-e.valueOf())}truncate(e){return new J(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return J.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/J.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/J.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/J.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/J.TERABYTE.valueOf()}toString(){const e=this.truncate(J.TERABYTE),n=this.truncate(J.GIGABYTE),r=this.truncate(J.MEGABYTE),i=this.truncate(J.KILOBYTE),a=this.truncate(J.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new J(e)}static kilobytes(e=1){return J.bytes(e.valueOf()*1e3)}static megabytes(e=1){return J.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return J.megabytes(e.valueOf()*1e3)}static terabytes(e){return J.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};y(ae,"BYTE",new ae(1)),y(ae,"KILOBYTE",ae.kilobytes(1)),y(ae,"MEGABYTE",ae.megabytes(1)),y(ae,"GIGABYTE",ae.gigabytes(1)),y(ae,"TERABYTE",ae.terabytes(1)),y(ae,"ZERO",new ae(0)),y(ae,"z",s.z.union([s.z.number().transform(t=>new ae(t)),s.z.instanceof(ae)]));let Zt=ae;const Lc=s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]),Ma=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof W||t instanceof Z||t instanceof Date},_c=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):zt(n,-r).valueOf(),Yc=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Da?!0:Ma(t),Pe=-1,ns={[Symbol.iterator]:()=>ns,next:()=>({done:!0,value:void 0})},qc=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Fc=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),rs=10,St=class Ne{constructor(e){y(this,"key",""),y(this,"isSynnaxSeries",!0),y(this,"dataType"),y(this,"sampleOffset"),y(this,"gl"),y(this,"_data"),y(this,"_timeRange"),y(this,"alignment",0n),y(this,"_cachedMin"),y(this,"_cachedMax"),y(this,"writePos",Pe),y(this,"_refCount",0),y(this,"_cachedLength"),y(this,"_cachedIndexes"),Yc(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=Ra()}=e,u=e.data??[];if(u instanceof Ne||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=Ma(u),f=Array.isArray(u);if(n!=null)this.dataType=new j(n);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=j.STRING;else if(typeof d=="number")this.dataType=j.FLOAT64;else if(typeof d=="bigint")this.dataType=j.INT64;else if(typeof d=="boolean")this.dataType=j.BOOLEAN;else if(d instanceof W||d instanceof Date||d instanceof W)this.dataType=j.TIMESTAMP;else if(typeof d=="object")this.dataType=j.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new j(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const k=d[0];(k instanceof W||k instanceof Date||k instanceof Z)&&(d=d.map(D=>new W(D).valueOf())),this.dataType.equals(j.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`)):this.dataType.equals(j.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(D=>On.encodeString(D)).join(`
|
|
6
|
-
`)}
|
|
7
|
-
`)):this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new j(n).Array(e),a=new Ne({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static generateTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new Ne({data:a,dataType:j.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`);return new Ne({data:r,dataType:j.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>On.encodeString(i)).join(`
|
|
10
|
-
`)}
|
|
11
|
-
`);return new Ne({data:r,dataType:j.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Pe)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Pe)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return this._data instanceof ArrayBuffer||this._data instanceof SharedArrayBuffer?this._data:this._data.buffer}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Pe?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(j.STRING,j.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(j.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=j.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(j.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
-
`).slice(0,-1).map(n=>e.parse(On.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Zt(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Pe?this.byteCapacity:this.dataType.isVariable?new Zt(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Pe?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===rs&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=_c(this.dataType,e,this.data[i],n);return new Ne({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(j.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),zt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(j.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),zt(this._cachedMin,this.sampleOffset))}get bounds(){return O.i(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return zt(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return zt(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===rs){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(j.STRING)?new TextDecoder().decode(a):O.k(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=or(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(j.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Pe){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.underlyingData,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Pe}as(e){if(e==="string"){if(!this.dataType.equals(j.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(j.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return O.i(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Vc(this);return this.dataType.equals(j.JSON)?new Wc(e):e}return new Gc(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new hi(this,e,n??this.length)}subAlignmentIterator(e,n){return new hi(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new Ne({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new Ne({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new Ne({data:this.buffer,dataType:this.dataType,timeRange:it.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};y(St,"crudeZ",s.z.object({timeRange:it.z.optional(),dataType:j.z,alignment:$a.optional(),data:s.z.union([qc,Fc,s.z.instanceof(ArrayBuffer)]),glBufferUsage:Uc.optional().default("static").optional()})),y(St,"z",St.crudeZ.transform(t=>new St(t)));let Da=St,hi=class{constructor(e,n,r){y(this,"series"),y(this,"end"),y(this,"index"),this.series=e;const i=O.i(0,e.length);this.end=O.T(i,r),this.index=O.T(i,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}},Vc=class{constructor(e){if(y(this,"series"),y(this,"index"),y(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==rs;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}};var di,fi;let Wc=class{constructor(e){y(this,"wrapped"),y(this,di,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:On.decodeString(e.value)}}[(fi=Symbol.iterator,di=Symbol.toStringTag,fi)](){return this}};var yi,gi;let Gc=class{constructor(e){y(this,"series"),y(this,"index"),y(this,yi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(gi=Symbol.iterator,yi=Symbol.toStringTag,gi)](){return this}};const zt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);let Zc=class{constructor(e){if(y(this,"series"),e.length!==0){const n=e[0].dataType;for(let r=1;r<e.length;r++)if(!e[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new j(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?j.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?it.ZERO:new it(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?O.i(0n,0n):O.i(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,n)=>e+n.length,0)}atAlignment(e,n){if(this.series.length===0){if(n)throw new Error(`[series] - no value at alignment ${e}`);return}for(const r of this.series)if(O.a(r.alignmentBounds,e))return r.atAlignment(e,n);if(n)throw new Error(`[series] - no value at alignment ${e}`)}at(e,n=!1){e<0&&(e=this.length+e);for(const r of this.series){if(e<r.length)return r.at(e,n);e-=r.length}if(n)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,n){return new Ir(this,e,n??this.length)}subAlignmentIterator(e,n){if(e>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return ns;let r=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)r+=o.length;else if(O.a(o.alignmentBounds,e)){r+=Number(e-o.alignment);break}}let i=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)i+=o.length;else if(O.a(o.alignmentBounds,n)){i+=Number(n-o.alignment);break}}return new Ir(this,r,i)}subAlignmentSpanIterator(e,n){if(e>=this.alignmentBounds.upper)return ns;let r=0;for(let i=0;i<this.series.length;i++){const a=this.series[i];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)r+=a.length;else if(O.a(a.alignmentBounds,e)){r+=Number(e-a.alignment);break}}return new Ir(this,r,r+n)}get byteLength(){return new Zt(this.series.reduce((e,n)=>e+n.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let n=0;for(const r of this.series)e.set(r.data,n),n+=r.length;return new this.dataType.Array(e)}traverseAlignment(e,n){const r=this.series.map(i=>i.alignmentBounds);return O.k$1(r,e,n)}distance(e,n){const r=this.series.map(i=>i.alignmentBounds);return O.U(r,e,n)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Kc(this.series)}};var pi,mi;class Kc{constructor(e){y(this,"series"),y(this,"seriesIndex"),y(this,"internal"),y(this,pi,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(mi=Symbol.iterator,pi=Symbol.toStringTag,mi)](){return this}}let Ir=class{constructor(e,n,r){y(this,"series"),y(this,"index"),y(this,"end"),this.series=e,this.end=r,this.index=n}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const Pa=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Jc=Pa(),Ua=["MacOS","Windows","Linux","Docker"],Hc=s.z.enum(Ua);let Er;const Xc=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},Qc=(t={})=>{const{force:e,default:n}=t;return e??Er??(Er=Xc(),Er??n)},La=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ua,RUNTIME:Jc,detect:Pa,getOS:Qc,osZ:Hc},Symbol.toStringTag,{value:"Module"})),eu=t=>Array.isArray(t)?t:[t],tu=t=>Array.isArray(t)?t:t===null?[]:[t];var nu=Object.defineProperty,ru=(t,e,n)=>e in t?nu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nt=(t,e,n)=>ru(t,typeof e!="symbol"?e+"":e,n);const su=(...t)=>t.map(_a).join(""),_a=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),iu=t=>t.endsWith("/")?t.slice(0,-1):t,wi=class ss{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){Nt(this,"protocol"),Nt(this,"host"),Nt(this,"port"),Nt(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=_a(i)}replace(e){return new ss({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new ss({...this,pathPrefix:su(this.path,e)})}toString(){return iu(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Nt(wi,"UNKNOWN",new wi({host:"unknown",port:0}));var au=Object.defineProperty,ou=(t,e,n)=>e in t?au(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Qn=(t,e,n)=>ou(t,typeof e!="symbol"?e+"":e,n);let lu=class{constructor(e){Qn(this,"sender"),Qn(this,"handlers"),this.sender=e,this.handlers=new Map}handle({data:e}){var n;const r=(n=this.handlers.get(e.type))==null?void 0:n.handler;r==null?console.warn(`No handler for ${e.type}`):r(e.payload)}route(e){const n=cu(e,this.sender),r=new uu(n);return this.handlers.set(e,r),r}};const cu=(t,e)=>(n,r)=>e({type:t,payload:n},r);let uu=class{constructor(e){Qn(this,"_send"),Qn(this,"handler"),this._send=e,this.handler=null}send(e,n=[]){this._send(e,n)}handle(e){this.handler=e}};var hu=Object.defineProperty,du=(t,e,n)=>e in t?hu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,In=(t,e,n)=>du(t,typeof e!="symbol"?e+"":e,n);const Ge=class extends Number{};In(Ge,"Absolute",255),In(Ge,"Default",1),In(Ge,"z",s.z.union([s.z.instanceof(Ge),s.z.number().int().min(0).max(255).transform(t=>new Ge(t)),s.z.instanceof(Number).transform(t=>new Ge(t))]));let Ya=Ge;const qa=s.z.object({name:s.z.string(),key:s.z.string()}),fu=t=>s.z.object({subject:qa,resource:t,authority:Ya.z}),yu=(...t)=>e=>e.filter(n=>{let r=!1;return n.to!=null&&(r=t.includes(n.to.resource)),n.from!=null&&!r&&(r=t.includes(n.from.resource)),r}),gu=Object.freeze(Object.defineProperty({__proto__:null,Authority:Ya,filterTransfersByChannelKey:yu,stateZ:fu,subjectZ:qa},Symbol.toStringTag,{value:"Module"})),Fa=class It extends Error{constructor(){super(It.MESSAGE)}matches(e){return typeof e=="string"?e.includes(It.MESSAGE):e instanceof It||e.message.includes(It.MESSAGE)}};In(Fa,"MESSAGE","canceled");let pu=Fa;new pu;const mu=t=>t?-1:1,is=s.z.string().regex(/^\d+\.\d+\.\d+$/),nn=(t,e,n={})=>{n.checkMajor??(n.checkMajor=!0),n.checkMinor??(n.checkMinor=!0),n.checkPatch??(n.checkPatch=!0);const r=is.parse(t),i=is.parse(e),[a,o,c]=r.split(".").map(Number),[u,h,f]=i.split(".").map(Number);if(n.checkMajor){if(a<u)return Tn;if(a>u)return Sn}if(n.checkMinor){if(o<h)return Tn;if(o>h)return Sn}if(n.checkPatch){if(c<f)return Tn;if(c>f)return Sn}return ht},wu=(t,e,n={})=>Ea(nn(t,e,n)),Va=(t,e,n={})=>Ia(nn(t,e,n)),bu=(t,e,n={})=>Na(nn(t,e,n)),vu=({name:t,migrate:e})=>n=>{try{const r=e(n);return console.log(`${t} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${t} failed to migrate from ${n.version}`),console.error(r),r}},Ou=({name:t,migrations:e,targetSchema:n,defaultVersion:r,def:i})=>{const a=Object.keys(e).sort(nn).pop();if(a==null)return h=>{if(h.version??(h.version=r),h.version!==i.version)return console.log(`${t} version ${h.version} is newer than latest version of ${i.version}.
|
|
14
|
-
Returning default instead.
|
|
15
|
-
`),i;try{return n!=null?n.parse(h):h}catch(f){return console.log(`${t} failed to parse default. Exiting with default`),console.error(f),i}};const o=Object.keys(e).length;let c=!1;const u=h=>{try{if(o===0||Va(h.version,a))return console.log(c?`${t} ${h.version} now up to date`:`${t} version ${h.version} is up to date with target version ${i.version}`),h;const f=h.version,d=e[f],k=d(h);return c=!0,u(k)}catch(f){return console.log(`${t} failed to migrate from ${h.version} to ${a}`),console.error(f),i}};return h=>{try{if(h.version==null)if(r!=null)console.log(`${t} version is null. Setting version to default of ${r}`),h.version=r;else return console.log(`${t} version is null and no default version set. Exiting with default`),i;return u(h)}catch(f){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(f),i}}},Tu=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:nn,createMigration:vu,migrator:Ou,semVerNewer:Va,semVerOlder:bu,semVerZ:is,versionsEqual:wu},Symbol.toStringTag,{value:"Module"})),Su=t=>{if(t===void 0||typeof t=="string"||typeof t=="number")return t;if(t.toString===void 0)throw new Error("invalid renderer");return t.toString()},zu=t=>Array.isArray(t)?[...t]:typeof t=="object"&&t!==null?{...t}:t,Rs=t=>typeof t=="function",js=(t,e)=>Rs(t)?t(e):t,rn=t=>Wa(t)?t():t,Wa=t=>typeof t=="function",Ga=({initial:t,value:e,onChange:n})=>{const[r,i]=Cs.useState(rn(e??t));return e!=null&&n!=null?[e,n]:[r,i]},Za=({initial:t,value:e,onChange:n})=>{const[r,i]=Cs.useState(rn(e??t));return e!=null&&n!=null?[e,n]:[r,i]},Nu=(t,e)=>{const[n,r]=Cs.useState(()=>{const i=localStorage.getItem(e);return i==null?rn(t):JSON.parse(i)});return[n,i=>{r(i),localStorage.setItem(e,JSON.stringify(i))}]},Iu=Object.freeze(Object.defineProperty({__proto__:null,executeInitialSetter:rn,executeSetter:js,isInitialSetter:Wa,isSetter:Rs,usePassthrough:Ga,usePersisted:Nu,usePurePassthrough:Za},Symbol.toStringTag,{value:"Module"})),Ka=["h1","h2","h3","h4","h5","p","small"],Eu=s.z.enum(Ka),Au={h1:"h2",h2:"h3",h3:"h4",h4:"h5",h5:"p",p:"small",small:"small"},ku=t=>Au[t],xu={h1:"h1",h2:"h1",h3:"h2",h4:"h3",h5:"h4",p:"h5",small:"p"},Cu=t=>xu[t],Ye=s.z.object({size:s.z.number(),weight:s.z.union([s.z.number(),s.z.string()]),lineHeight:s.z.number(),textTransform:s.z.string().optional()}),Ja={small:"small",medium:"p",large:"h5",huge:"h2"},$u={h1:"huge",h2:"huge",h3:"huge",h4:"large",h5:"small",p:"medium",small:"small"};let bi=null;const Ru=()=>(bi??(bi=document.createElement("canvas")),bi),ju=(t,e,n)=>{if(La.RUNTIME==="node")return{width:0,height:0};n??(n=Ru().getContext("2d")),n.font=e;const r=n.measureText(t);return{width:Math.trunc(Math.abs(r.actualBoundingBoxLeft)+Math.abs(r.actualBoundingBoxRight)),height:Math.trunc(Math.abs(r.actualBoundingBoxAscent)+Math.abs(r.actualBoundingBoxDescent))}},Bu=s.z.object({l0:O.Color.z,l1:O.Color.z,l2:O.Color.z,l3:O.Color.z,l4:O.Color.z,l5:O.Color.z,l6:O.Color.z,l7:O.Color.z,l8:O.Color.z,l9:O.Color.z,l10:O.Color.z}),we=(t,e)=>[t[0],t[1],e,t[3]],Mu=s.z.object({m2:O.Color.z,m1:O.Color.z,z:O.Color.z,p1:O.Color.z,p2:O.Color.z}),fn=Mu.or(O.Color.z.transform(t=>{const e=t.hsla;return{m2:new O.Color(O.fromHSLA(we(e,40))),m1:new O.Color(O.fromHSLA(we(e,45))),z:t,p1:new O.Color(O.fromHSLA(we(e,55))),p2:new O.Color(O.fromHSLA(we(e,65)))}})),Ha=s.z.object({name:s.z.string(),key:s.z.string(),colors:s.z.object({border:O.Color.z,primary:fn,gray:Bu,error:fn,secondary:fn,warning:fn,visualization:s.z.object({palettes:s.z.record(s.z.array(O.Color.z))}).optional().default({palettes:{}}),white:O.Color.z,black:O.Color.z,text:O.Color.z,textInverted:O.Color.z,textOnPrimary:O.Color.z.optional().default(O.ZERO),logo:s.z.string()}),sizes:s.z.object({base:s.z.number(),border:s.z.object({radius:s.z.number(),width:s.z.number()}),schematic:s.z.object({elementStrokeWidth:s.z.number()})}),typography:s.z.object({family:s.z.string(),codeFamily:s.z.string(),h1:Ye,h2:Ye,h3:Ye,h4:Ye,h5:Ye,p:Ye,small:Ye})}).transform(t=>((t.colors.textOnPrimary==null||t.colors.textOnPrimary.isZero)&&(t.colors.textOnPrimary=t.colors.primary.z.pickByContrast(t.colors.text,t.colors.textInverted)),t)),Du="'Inter Variable', sans-serif",Pu="'Geist Mono', monospace",Uu=6,pt=[357,91,55,1],mt=[58,100,50,1],Lu=["#FDFDFD","#FAFAFA","#F3F3F3","#EAEAEA","#D8D8D8","#ADADAD","#878787","#616161","#404040","#1C1C1C","#050505"],wt=Object.fromEntries(Lu.map((t,e)=>[`l${e}`,t])),as={key:"synnaxBase",name:"Synnax Base",colors:{primary:{m2:"#041B3D",m1:"#164FA0",z:"#3774D0",p1:"#5E94EE",p2:"#8AB8FF"},secondary:{m2:"#2D8F4E",m1:"#38B261",z:"#50C878",p1:"#73D393",p2:"#96DEAE"},gray:wt,border:wt.l3,error:{m2:O.fromHSLA(we(pt,30)),m1:O.fromHSLA(we(pt,40)),z:O.fromHSLA(pt),p1:O.fromHSLA(we(pt,65)),p2:O.fromHSLA(we(pt,77))},warning:{m2:O.fromHSLA(we(mt,30)),m1:O.fromHSLA(we(mt,40)),z:O.fromHSLA(mt),p1:O.fromHSLA(we(mt,65)),p2:O.fromHSLA(we(mt,75))},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:wt.l9,textInverted:wt.l0,textOnPrimary:wt.l0},sizes:{base:Uu,border:{radius:3,width:1},schematic:{elementStrokeWidth:2}},typography:{family:Du,codeFamily:Pu,h1:{size:7,weight:"500",lineHeight:7*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:1.9166666*1.5}}},Xa=Object.freeze({...as,key:"synnaxLight",name:"Synnax Light"}),_u=["#020202","#0A0A0A","#131313","#1E1E1E","#2E2E2E","#444444","#646464","#8A8A8A","#AFAFAF","#D5D5D5","#FDFDFD"],bt=Object.fromEntries(_u.map((t,e)=>[`l${e}`,t])),Qa=Object.freeze({...as,key:"synnaxDark",name:"Synnax Dark",colors:{...as.colors,gray:bt,logo:"var(--pluto-text-color)",border:bt.l3,text:bt.l9,textInverted:bt.l0,textOnPrimary:bt.l10}}),Yu={synnaxDark:Qa,synnaxLight:Xa},qu=["small","medium","large","huge"],Fu=s.z.enum(qu),Vu=t=>Fu.safeParse(t).success,Wu=(t,{level:e,weight:n,code:r})=>{const{typography:i,sizes:{base:a}}=t,o=i[Vu(e)?Ja[e]:e].size,c=a*o,u=r?i.codeFamily:i.family,[h,f]=u.split(", ");return n!=null?` ${n} ${c}px ${h}, ${f}`:` ${c}px ${u}`};var Gu=Object.defineProperty,Zu=(t,e,n)=>e in t?Gu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,l=(t,e,n)=>Zu(t,typeof e!="symbol"?e+"":e,n);const T=t=>Array.isArray(t)?t:[t];var Ku=Object.defineProperty,Ju=(t,e,n)=>e in t?Ku(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,M=(t,e,n)=>Ju(t,typeof e!="symbol"?e+"":e,n);const Hu=t=>{const e=t.replace(/_[a-z]/g,n=>n[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)},eo=t=>{const e=(n,r=os)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!Ar(n))return n;r=eh(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&(Ar(c)?Oi(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&vi(c)&&(c=[...c].map(h=>{let f=h;return Ar(h)?Oi(f,r.keepTypesOnRecursion)||(f=e(h,r)):vi(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},to=eo(Hu),Xu=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),Qu=eo(Xu),os={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},eh=(t=os)=>(t.recursive==null?t=os:t.recursiveInArray??(t.recursiveInArray=!1),t),vi=t=>t!=null&&Array.isArray(t),Ar=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Oi=(t,e)=>(e||[]).some(n=>t instanceof n),no=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var th=Object.defineProperty,nh=(t,e,n)=>e in t?th(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ft=(t,e,n)=>nh(t,typeof e!="symbol"?e+"":e,n);let rh=class{constructor(){Ft(this,"contentType","application/json"),Ft(this,"decoder"),Ft(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=to(n);return e!=null?e.parse(r):r}encodeString(t){const e=Qu(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):no(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},sh=class{constructor(){Ft(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!no(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
|
|
16
|
-
`)}decodeString(t,e){const[n,...r]=t.trim().split(`
|
|
17
|
-
`).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},ih=class{constructor(){Ft(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const En=new rh;new sh;new ih;const lr=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const ro=s.z.object({width:s.z.number(),height:s.z.number()}),ah=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),oh=["width","height"];s.z.enum(oh);const lh=["start","center","end"],ch=["signedWidth","signedHeight"];s.z.enum(ch);const er=s.z.object({x:s.z.number(),y:s.z.number()}),uh=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),hh=["x","y"],so=s.z.enum(hh),io=["top","right","bottom","left"];s.z.enum(io);const dh=["left","right"],ao=s.z.enum(dh),fh=["top","bottom"],oo=s.z.enum(fh),lo=["center"],Ti=s.z.enum(lo),yh=[...io,...lo],co=s.z.enum(yh);s.z.enum(lh);const gh=["first","last"];s.z.enum(gh);const ph=s.z.object({lower:s.z.number(),upper:s.z.number()}),mh=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([ph,lr]);s.z.union([mh,lr]);s.z.union([so,co]);s.z.union([so,co,s.z.instanceof(String)]);const wh=t=>typeof t=="bigint"||t instanceof BigInt,et=(t,e)=>wh(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),He=(t,e)=>{const n={};if(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 return Si(t);return Si(n)},Si=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,zi=(t,e)=>{const n=He(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e};s.z.object({x:ao.or(Ti),y:oo.or(Ti)});const bh=s.z.object({x:ao,y:oo}),vh=Object.freeze({x:"left",y:"top"}),Oh=(t,e)=>t.x===e.x&&t.y===e.y,Ni=s.z.union([s.z.number(),er,lr,ro,ah,uh]),Th=(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}},Ii=Object.freeze({x:0,y:0}),yn=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:yn,left:yn,width:yn,height:yn});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:er,two:er,root:bh});const Bs=(t,e,n=0,r=0,i)=>{const a={one:{...Ii},two:{...Ii},root:i??vh};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},kr=t=>{const e=Bs(t);return{lower:e.one.x,upper:e.two.x}},xr=t=>{const e=Bs(t);return{lower:e.one.y,upper:e.two.y}},Sh=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var zh=Object.defineProperty,Nh=(t,e,n)=>e in t?zh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Be=(t,e,n)=>Nh(t,typeof e!="symbol"?e+"":e,n);const Ih=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:Ni,scale:Ni});const Eh=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],Ah=t=>(e,n,r,i)=>[e,i?r/t:r*t],kh=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},xh=t=>(e,n,r)=>[t,r],Ch=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},$h=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=Ih(r,i,a),[e,r]},ls=class Et{constructor(){Be(this,"ops",[]),Be(this,"currBounds",null),Be(this,"currType",null),Be(this,"reversed",!1),this.ops=[]}static translate(e){return new Et().translate(e)}static magnify(e){return new Et().magnify(e)}static scale(e,n){return new Et().scale(e,n)}translate(e){const n=this.new(),r=Eh(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=Ah(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=He(e,n),i=this.new(),a=kh(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=He(e,n),i=this.new(),a=$h(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=He(e,n),i=this.new(),a=xh(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=Ch();e.type="invert";const n=this.new();return n.ops.push(e),n}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Et;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}};Be(ls,"IDENTITY",new ls);let Ei=ls;const Ai=class Re{constructor(e=new Ei,n=new Ei,r=null){Be(this,"x"),Be(this,"y"),Be(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new Re().translate(e,n)}static translateX(e){return new Re().translateX(e)}static translateY(e){return new Re().translateY(e)}static clamp(e){return new Re().clamp(e)}static magnify(e){return new Re().magnify(e)}static scale(e){return new Re().scale(e)}static reBound(e){return new Re().reBound(e)}translate(e,n){const r=Th(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(Sh(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!Oh(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(kr(e)),n.y=n.y.scale(xr(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(kr(e)),n.y=this.y.reBound(xr(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(kr(e)),n.y=this.y.clamp(xr(e)),n}copy(){const e=new Re;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Bs(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Be(Ai,"IDENTITY",new Ai);const Rh=t=>t!=null&&typeof t=="object"&&"toString"in t,jh=(t,e=!1)=>{const n=Rh(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?Bh(r):r},Bh=t=>(e,n)=>t(n,e),Mh=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([ro,Mh,er,lr]);const Dh=s.z.bigint().or(s.z.string().transform(BigInt));var Ph=Object.defineProperty,Uh=(t,e,n)=>e in t?Ph(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,b=(t,e,n)=>Uh(t,typeof e!="symbol"?e+"":e,n);let Lh=(t,e=21)=>(n=e)=>{let r="",i=n;for(;i--;)r+=t[Math.random()*t.length|0];return r};const _h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Yh=Lh(_h,11),qh=s.z.enum(["static","dynamic"]),uo=(t,e)=>{const n=new G(e);if(![Q.DAY,Q.HOUR,Q.MINUTE,Q.SECOND,Q.MILLISECOND,Q.MICROSECOND,Q.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof G?new G(r):new Q(r)},_=class z{constructor(e,n="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new z(BigInt(i.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=z.hours(parseInt(r??"00")).add(z.minutes(parseInt(i??"00"))).add(z.seconds(parseInt(o??"00"))).add(z.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(z.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new z(BigInt(r.getTime())*z.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new Q(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new Ms(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return uo(this,e)}get isToday(){return this.truncate(Q.DAY).equals(z.now().truncate(Q.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let n=z.MIN;for(const r of e){const i=new z(r);i.after(n)&&(n=i)}return n}static min(...e){let n=z.MAX;for(const r of e){const i=new z(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};b(_,"NANOSECOND",_.nanoseconds(1)),b(_,"MICROSECOND",_.microseconds(1)),b(_,"MILLISECOND",_.milliseconds(1)),b(_,"SECOND",_.seconds(1)),b(_,"MINUTE",_.minutes(1)),b(_,"HOUR",_.hours(1)),b(_,"DAY",_.days(1)),b(_,"MAX",new _((1n<<63n)-1n)),b(_,"MIN",new _(0)),b(_,"ZERO",new _(0)),b(_,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new _(t.value)),s.z.string().transform(t=>new _(BigInt(t))),s.z.instanceof(Number).transform(t=>new _(t)),s.z.number().transform(t=>new _(t)),s.z.instanceof(_)]));let G=_;const Y=class E{constructor(e){b(this,"value"),b(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof E?e:e instanceof ki?e.period:e instanceof G?new E(e):["number","bigint"].includes(typeof e)?E.seconds(e):new E(e)}static fromMilliseconds(e){return e instanceof E?e:e instanceof ki?e.period:e instanceof G?new E(e):["number","bigint"].includes(typeof e)?E.milliseconds(e):new E(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new E(e).valueOf()}greaterThan(e){return this.valueOf()>new E(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new E(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new E(e).valueOf()}remainder(e){return uo(this,e)}truncate(e){return new E(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(E.DAY),n=this.truncate(E.HOUR),r=this.truncate(E.MINUTE),i=this.truncate(E.SECOND),a=this.truncate(E.MILLISECOND),o=this.truncate(E.MICROSECOND),c=this.truncate(E.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),k=a.sub(i),D=o.sub(a),ie=c.sub(o);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 `),k.isZero||(B+=`${k.milliseconds}ms `),D.isZero||(B+=`${D.microseconds}µs `),ie.isZero||(B+=`${ie.nanoseconds}ns`),B.trim()}get days(){return Number(this.valueOf())/Number(E.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(E.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(E.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(E.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(E.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(E.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new E(e).valueOf()}add(e){return new E(this.valueOf()+new E(e).valueOf())}sub(e){return new E(this.valueOf()-new E(e).valueOf())}static nanoseconds(e=1){return new E(e)}static microseconds(e=1){return E.nanoseconds(et(e,1e3))}static milliseconds(e=1){return E.microseconds(et(e,1e3))}static seconds(e=1){return E.milliseconds(et(e,1e3))}static minutes(e=1){return E.seconds(et(e,60))}static hours(e){return E.minutes(et(e,60))}static days(e){return E.hours(et(e,24))}};b(Y,"NANOSECOND",Y.nanoseconds(1)),b(Y,"MICROSECOND",Y.microseconds(1)),b(Y,"MILLISECOND",Y.milliseconds(1)),b(Y,"SECOND",Y.seconds(1)),b(Y,"MINUTE",Y.minutes(1)),b(Y,"HOUR",Y.hours(1)),b(Y,"DAY",Y.days(1)),b(Y,"MAX",new Y((1n<<63n)-1n)),b(Y,"MIN",new Y(0)),b(Y,"ZERO",new Y(0)),b(Y,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new Y(t.value)),s.z.string().transform(t=>new Y(BigInt(t))),s.z.instanceof(Number).transform(t=>new Y(t)),s.z.number().transform(t=>new Y(t)),s.z.instanceof(Y)]));let Q=Y;const At=class An extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new An(e).valueOf()}get period(){return Q.seconds(1/this.valueOf())}sampleCount(e){return new Q(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new ue(n).valueOf()}span(e){return Q.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new An(e)}static khz(e){return An.hz(e*1e3)}};b(At,"z",s.z.union([s.z.number().transform(t=>new At(t)),s.z.instanceof(Number).transform(t=>new At(t)),s.z.instanceof(At)]));let ki=At;const ne=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new cs(e*this.valueOf())}};b(ne,"UNKNOWN",new ne(0)),b(ne,"BIT128",new ne(16)),b(ne,"BIT64",new ne(8)),b(ne,"BIT32",new ne(4)),b(ne,"BIT16",new ne(2)),b(ne,"BIT8",new ne(1)),b(ne,"z",s.z.union([s.z.number().transform(t=>new ne(t)),s.z.instanceof(Number).transform(t=>new ne(t)),s.z.instanceof(ne)]));let ue=ne;const Ie=class kn{constructor(e,n){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new G(e.start),this.end=new G(e.end)):(this.start=new G(e),this.end=new G(n))}get span(){return new Q(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new kn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=Q.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=G.max(r.start,e.start),a=G.min(r.end,e.end);return a.before(i)?!1:new Q(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof kn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new kn(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};b(Ie,"MAX",new Ie(G.MIN,G.MAX)),b(Ie,"MIN",new Ie(G.MAX,G.MIN)),b(Ie,"ZERO",new Ie(G.ZERO,G.ZERO)),b(Ie,"z",s.z.union([s.z.object({start:G.z,end:G.z}).transform(t=>new Ie(t.start,t.end)),s.z.instanceof(Ie)]));let Ms=Ie;const m=class Ee extends String{constructor(e){if(e instanceof Ee||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=Ee.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(Ee.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Ee.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(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(Ee.JSON)||this.equals(Ee.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Ee.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Ee.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Ee.BIG_INT_TYPES.some(e=>e.equals(this))}};b(m,"UNKNOWN",new m("unknown")),b(m,"FLOAT64",new m("float64")),b(m,"FLOAT32",new m("float32")),b(m,"INT64",new m("int64")),b(m,"INT32",new m("int32")),b(m,"INT16",new m("int16")),b(m,"INT8",new m("int8")),b(m,"UINT64",new m("uint64")),b(m,"UINT32",new m("uint32")),b(m,"UINT16",new m("uint16")),b(m,"UINT8",new m("uint8")),b(m,"BOOLEAN",m.UINT8),b(m,"TIMESTAMP",new m("timestamp")),b(m,"UUID",new m("uuid")),b(m,"STRING",new m("string")),b(m,"JSON",new m("json")),b(m,"ARRAY_CONSTRUCTORS",new Map([[m.UINT8.toString(),Uint8Array],[m.UINT16.toString(),Uint16Array],[m.UINT32.toString(),Uint32Array],[m.UINT64.toString(),BigUint64Array],[m.FLOAT32.toString(),Float32Array],[m.FLOAT64.toString(),Float64Array],[m.INT8.toString(),Int8Array],[m.INT16.toString(),Int16Array],[m.INT32.toString(),Int32Array],[m.INT64.toString(),BigInt64Array],[m.TIMESTAMP.toString(),BigInt64Array],[m.STRING.toString(),Uint8Array],[m.JSON.toString(),Uint8Array],[m.UUID.toString(),Uint8Array]])),b(m,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,m.UINT8],[Uint16Array.name,m.UINT16],[Uint32Array.name,m.UINT32],[BigUint64Array.name,m.UINT64],[Float32Array.name,m.FLOAT32],[Float64Array.name,m.FLOAT64],[Int8Array.name,m.INT8],[Int16Array.name,m.INT16],[Int32Array.name,m.INT32],[BigInt64Array.name,m.INT64]])),b(m,"DENSITIES",new Map([[m.UINT8.toString(),ue.BIT8],[m.UINT16.toString(),ue.BIT16],[m.UINT32.toString(),ue.BIT32],[m.UINT64.toString(),ue.BIT64],[m.FLOAT32.toString(),ue.BIT32],[m.FLOAT64.toString(),ue.BIT64],[m.INT8.toString(),ue.BIT8],[m.INT16.toString(),ue.BIT16],[m.INT32.toString(),ue.BIT32],[m.INT64.toString(),ue.BIT64],[m.TIMESTAMP.toString(),ue.BIT64],[m.STRING.toString(),ue.UNKNOWN],[m.JSON.toString(),ue.UNKNOWN],[m.UUID.toString(),ue.BIT128]])),b(m,"ALL",[m.UNKNOWN,m.FLOAT64,m.FLOAT32,m.INT64,m.INT32,m.INT16,m.INT8,m.UINT64,m.UINT32,m.UINT16,m.UINT8,m.TIMESTAMP,m.UUID,m.STRING,m.JSON]),b(m,"BIG_INT_TYPES",[m.INT64,m.UINT64,m.TIMESTAMP]),b(m,"z",s.z.union([s.z.string().transform(t=>new m(t)),s.z.instanceof(m)]));let q=m;const oe=class H extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return H.bytes(this.valueOf()+e.valueOf())}sub(e){return H.bytes(this.valueOf()-e.valueOf())}truncate(e){return new H(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return H.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/H.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/H.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/H.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/H.TERABYTE.valueOf()}toString(){const e=this.truncate(H.TERABYTE),n=this.truncate(H.GIGABYTE),r=this.truncate(H.MEGABYTE),i=this.truncate(H.KILOBYTE),a=this.truncate(H.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new H(e)}static kilobytes(e=1){return H.bytes(e.valueOf()*1e3)}static megabytes(e=1){return H.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return H.megabytes(e.valueOf()*1e3)}static terabytes(e){return H.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(oe,"BYTE",new oe(1)),b(oe,"KILOBYTE",oe.kilobytes(1)),b(oe,"MEGABYTE",oe.megabytes(1)),b(oe,"GIGABYTE",oe.gigabytes(1)),b(oe,"TERABYTE",oe.terabytes(1)),b(oe,"ZERO",new oe(0)),b(oe,"z",s.z.union([s.z.number().transform(t=>new oe(t)),s.z.instanceof(oe)]));let cs=oe;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const ho=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof G||t instanceof Q||t instanceof Date},Fh=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):xt(n,-r).valueOf(),Vh=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Zh?!0:ho(t),Ue=-1,Wh=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Gh=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),us=10,kt=class Ae{constructor(e){b(this,"key",""),b(this,"isSynnaxSeries",!0),b(this,"dataType"),b(this,"sampleOffset"),b(this,"gl"),b(this,"_data"),b(this,"_timeRange"),b(this,"alignment",0n),b(this,"_cachedMin"),b(this,"_cachedMax"),b(this,"writePos",Ue),b(this,"_refCount",0),b(this,"_cachedLength"),b(this,"_cachedIndexes"),Vh(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=Yh()}=e,u=e.data??[];if(u instanceof Ae||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=ho(u),f=Array.isArray(u);if(n!=null)this.dataType=new q(n);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=q.STRING;else if(typeof d=="number")this.dataType=q.FLOAT64;else if(typeof d=="bigint")this.dataType=q.INT64;else if(typeof d=="boolean")this.dataType=q.BOOLEAN;else if(d instanceof G||d instanceof Date||d instanceof G)this.dataType=q.TIMESTAMP;else if(typeof d=="object")this.dataType=q.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new q(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const k=d[0];(k instanceof G||k instanceof Date||k instanceof Q)&&(d=d.map(D=>new G(D).valueOf())),this.dataType.equals(q.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
18
|
-
`)}
|
|
19
|
-
`)):this.dataType.equals(q.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(D=>En.encodeString(D)).join(`
|
|
20
|
-
`)}
|
|
21
|
-
`)):this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new q(n).Array(e),a=new Ae({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static generateTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new Ae({data:a,dataType:q.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
|
|
22
|
-
`)}
|
|
23
|
-
`);return new Ae({data:r,dataType:q.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>En.encodeString(i)).join(`
|
|
24
|
-
`)}
|
|
25
|
-
`);return new Ae({data:r,dataType:q.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Ue)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Ue)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return this._data instanceof ArrayBuffer||this._data instanceof SharedArrayBuffer?this._data:this._data.buffer}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ue?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(q.STRING,q.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
26
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(q.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=q.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(q.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
27
|
-
`).slice(0,-1).map(n=>e.parse(En.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new cs(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ue?this.byteCapacity:this.dataType.isVariable?new cs(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ue?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===us&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=Fh(this.dataType,e,this.data[i],n);return new Ae({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(q.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),xt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(q.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),xt(this._cachedMin,this.sampleOffset))}get bounds(){return He(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return xt(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return xt(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===us){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(q.STRING)?new TextDecoder().decode(a):to(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=jh(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(q.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ue){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.underlyingData,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ue}as(e){if(e==="string"){if(!this.dataType.equals(q.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(q.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return He(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Kh(this);return this.dataType.equals(q.JSON)?new Jh(e):e}return new Hh(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new xi(this,e,n??this.length)}subAlignmentIterator(e,n){return new xi(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new Ae({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new Ae({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new Ae({data:this.buffer,dataType:this.dataType,timeRange:Ms.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};b(kt,"crudeZ",s.z.object({timeRange:Ms.z.optional(),dataType:q.z,alignment:Dh.optional(),data:s.z.union([Wh,Gh,s.z.instanceof(ArrayBuffer)]),glBufferUsage:qh.optional().default("static").optional()})),b(kt,"z",kt.crudeZ.transform(t=>new kt(t)));let Zh=kt;class xi{constructor(e,n,r){b(this,"series"),b(this,"end"),b(this,"index"),this.series=e;const i=He(0,e.length);this.end=zi(i,r),this.index=zi(i,n)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class Kh{constructor(e){if(b(this,"series"),b(this,"index"),b(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==us;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Ci,$i;class Jh{constructor(e){b(this,"wrapped"),b(this,Ci,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:En.decodeString(e.value)}}[($i=Symbol.iterator,Ci=Symbol.toStringTag,$i)](){return this}}var Ri,ji;class Hh{constructor(e){b(this,"series"),b(this,"index"),b(this,Ri,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(ji=Symbol.iterator,Ri=Symbol.toStringTag,ji)](){return this}}const xt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);s.z.object({key:s.z.string(),value:s.z.string()});s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown());const fo=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Xh=fo(),yo=["MacOS","Windows","Linux","Docker"],Qh=s.z.enum(yo);let Cr;const ed=()=>{if(typeof window>"u")return;const t=window.navigator.userAgent.toLowerCase();if(t.includes("mac"))return"MacOS";if(t.includes("win"))return"Windows";if(t.includes("linux"))return"Linux"},td=(t={})=>{const{force:e,default:n}=t;return e??Cr??(Cr=ed(),Cr??n)},go=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:yo,RUNTIME:Xh,detect:fo,getOS:td,osZ:Qh},Symbol.toStringTag,{value:"Module"}));var nd=Object.defineProperty,rd=(t,e,n)=>e in t?nd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ct=(t,e,n)=>rd(t,typeof e!="symbol"?e+"":e,n);const sd=(...t)=>t.map(po).join(""),po=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),id=t=>t.endsWith("/")?t.slice(0,-1):t,ad=(t,e="")=>t===null?"":`?${Object.entries(t).filter(([,n])=>n==null?!1:Array.isArray(n)?n.length>0:!0).map(([n,r])=>`${e}${n}=${r}`).join("&")}`,hs=class ds{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){Ct(this,"protocol"),Ct(this,"host"),Ct(this,"port"),Ct(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=po(i)}replace(e){return new ds({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new ds({...this,pathPrefix:sd(this.path,e)})}toString(){return id(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Ct(hs,"UNKNOWN",new hs({host:"unknown",port:0}));let od=hs;var ld=Object.defineProperty,cd=(t,e,n)=>e in t?ld(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,xn=(t,e,n)=>cd(t,typeof e!="symbol"?e+"":e,n);const tt=class extends Number{};xn(tt,"Absolute",255),xn(tt,"Default",1),xn(tt,"z",s.z.union([s.z.instanceof(tt),s.z.number().int().min(0).max(255).transform(t=>new tt(t)),s.z.instanceof(Number).transform(t=>new tt(t))]));s.z.object({name:s.z.string(),key:s.z.string()});const mo=class $t extends Error{constructor(){super($t.MESSAGE)}matches(e){return typeof e=="string"?e.includes($t.MESSAGE):e instanceof $t||e.message.includes($t.MESSAGE)}};xn(mo,"MESSAGE","canceled");let ud=mo;new ud;s.z.string().regex(/^\d+\.\d+\.\d+$/);const fe=t=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(t):e instanceof Error?e.message.includes(t):typeof e!="string"?!1:e.includes(t);let Te=class extends Error{constructor(){super(...arguments),M(this,"discriminator","FreighterError"),M(this,"type","")}};const hd=t=>{if(t==null||typeof t!="object")return!1;const e=t;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Bi="unknown",Mi="nil",dd="freighter",sn=s.z.object({type:s.z.string(),data:s.z.string()});class fd{constructor(){M(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:Mi,data:""};if(hd(e))for(const n of this.providers){const r=n.encode(e);if(r!=null)return r}return{type:Bi,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===Mi)return null;if(e.type===Bi)return new Di(e.data);for(const n of this.providers){const r=n.decode(e);if(r!=null)return r}return new Di(e.data)}}const wo=new fd,bo=({encode:t,decode:e})=>wo.register({encode:t,decode:e}),Ds=t=>wo.decode(t);class Di extends Te{constructor(){super(...arguments),M(this,"type","unknown")}}const cr="freighter.",Cn=class vo extends Te{constructor(){super("EOF"),M(this,"type",vo.TYPE)}};M(Cn,"TYPE",`${cr}eof`),M(Cn,"matches",fe(Cn.TYPE));let qe=Cn;const $n=class Oo extends Te{constructor(){super("StreamClosed"),M(this,"type",Oo.TYPE)}};M($n,"TYPE",`${cr}stream_closed`),M($n,"matches",fe($n.TYPE));let at=$n;const Rn=class To extends Te{constructor(e={}){const{message:n="Unreachable",url:r=od.UNKNOWN}=e;super(n),M(this,"type",To.TYPE),M(this,"url"),this.url=r}};M(Rn,"TYPE",`${cr}unreachable`),M(Rn,"matches",fe(Rn.TYPE));let Xe=Rn;const yd=t=>{if(!t.type.startsWith(dd))return null;if(qe.matches(t))return{type:qe.TYPE,data:"EOF"};if(at.matches(t))return{type:at.TYPE,data:"StreamClosed"};if(Xe.matches(t))return{type:Xe.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${t.type}: ${t.message}`)},gd=t=>{if(!t.type.startsWith(cr))return null;switch(t.type){case qe.TYPE:return new qe;case at.TYPE:return new at;case Xe.TYPE:return new Xe;default:throw new Error(`Unknown error type: ${t.data}`)}};bo({encode:yd,decode:gd});let So=class{constructor(){M(this,"middleware",[])}use(...t){this.middleware.push(...t)}async executeMiddleware(t,e){let n=0;const r=async i=>{if(n===this.middleware.length)return await e(i);const a=this.middleware[n];return n++,await a(i,r)};return await r(t)}};const zo="Content-Type",Pi=t=>{if(go.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(t==="http")return e;const n=require("https"),r=new n.Agent({rejectUnauthorized:!1});return async(i,a)=>await e(i,{...a,agent:r})};class pd extends So{constructor(e,n,r=!1){return super(),M(this,"endpoint"),M(this,"encoder"),M(this,"fetch"),this.endpoint=e.replace({protocol:r?"https":"http"}),this.encoder=n,this.fetch=Pi(this.endpoint.protocol),new Proxy(this,{get:(i,a,o)=>a==="endpoint"?this.endpoint:Reflect.get(i,a,o)})}get headers(){return{[zo]:this.encoder.contentType}}async send(e,n,r,i){n=r==null?void 0:r.parse(n);let a=null;const o=this.endpoint.child(e),c={};c.method="POST",c.body=this.encoder.encode(n??{});const[,u]=await this.executeMiddleware({target:o.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async h=>{const f={...h,params:{}};c.headers={...this.headers,...h.params};let d;try{d=await Pi(h.protocol)(h.target,c)}catch(D){let ie=D;return ie.message==="Load failed"&&(ie=new Xe({url:o})),[f,ie]}const k=await d.arrayBuffer();if(d!=null&&d.ok)return i!=null&&(a=this.encoder.decode(k,i)),[f,null];try{if(d.status!==400)return[f,new Error(d.statusText)];const D=this.encoder.decode(k,sn),ie=Ds(D);return[f,ie]}catch(D){return[f,new Error(`[freighter] - failed to decode error: ${d.statusText}: ${D.message}`)]}});return[a,u]}}const v=async(t,e,n,r,i)=>{const[a,o]=await t.send(e,n,r,i);if(o!=null)throw o;return a},md=()=>go.RUNTIME!=="node"?t=>new WebSocket(t):t=>new(require("ws")).WebSocket(t,{rejectUnauthorized:!1}),wd=s.z.object({type:s.z.union([s.z.literal("data"),s.z.literal("close")]),payload:s.z.unknown().optional(),error:s.z.optional(sn)});class bd{constructor(e,n,r,i){M(this,"encoder"),M(this,"reqSchema"),M(this,"resSchema"),M(this,"ws"),M(this,"serverClosed"),M(this,"sendClosed"),M(this,"receiveDataQueue",[]),M(this,"receiveCallbacksQueue",[]),this.encoder=n,this.reqSchema=r,this.resSchema=i,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new qe;if(this.sendClosed)throw new at;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Ds(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((e,n)=>this.receiveCallbacksQueue.push({resolve:e,reject:n}))}addMessage(e){const n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,wd)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:zd(e)?qe.TYPE:at.TYPE,data:""}})}}const vd="freighterctx",Od=1e3,Td=1001,Sd=[Od,Td],zd=t=>Sd.includes(t.code),No=class Io extends So{constructor(e,n,r=!1){super(),M(this,"baseUrl"),M(this,"encoder"),this.baseUrl=e.replace({protocol:r?"wss":"ws"}),this.encoder=n}async stream(e,n,r){const i=md();let a;const[,o]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async c=>{const u=i(this.buildURL(e,c)),h={...c,params:{}};u.binaryType=Io.MESSAGE_TYPE;const f=await this.wrapSocket(u,n,r);return f instanceof Error?[h,f]:(a=f,[h,null])});if(o!=null)throw o;return a}buildURL(e,n){const r=ad({[zo]:this.encoder.contentType,...n.params},vd);return this.baseUrl.child(e).toString()+r}async wrapSocket(e,n,r){return await new Promise(i=>{e.onopen=()=>{i(new bd(e,this.encoder,n,r))},e.onerror=a=>{const o=a;i(new Error(o.message))}})}};M(No,"MESSAGE_TYPE","arraybuffer");let Nd=No;const fs=s.z.union([s.z.literal("all"),s.z.literal("create"),s.z.literal("delete"),s.z.literal("retrieve"),s.z.literal("update")]),Id=t=>{const e=t.replace(/_[a-z]/g,n=>n[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)},Eo=t=>{const e=(n,r=ys)=>{if(typeof n=="string")return t(n);if(Array.isArray(n))return n.map(o=>e(o,r));if(!$r(n))return n;r=kd(r);const i={},a=n;return Object.keys(a).forEach(o=>{let c=a[o];const u=t(o);r.recursive&&($r(c)?Li(c,r.keepTypesOnRecursion)||(c=e(c,r)):r.recursiveInArray&&Ui(c)&&(c=[...c].map(h=>{let f=h;return $r(h)?Li(f,r.keepTypesOnRecursion)||(f=e(h,r)):Ui(h)&&(f=e({key:h},r).key),f}))),i[u]=c}),i};return e},Ao=Eo(Id),Ed=t=>t.replace(/([a-z0-9])([A-Z])/g,(e,n,r)=>`${n}_${r.toLowerCase()}`),Ad=Eo(Ed),ys={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},kd=(t=ys)=>(t.recursive==null?t=ys:t.recursiveInArray??(t.recursiveInArray=!1),t),Ui=t=>t!=null&&Array.isArray(t),$r=t=>t!=null&&typeof t=="object"&&!Array.isArray(t),Li=(t,e)=>(e||[]).some(n=>t instanceof n),Ps=t=>t!=null&&typeof t=="object"&&!Array.isArray(t);var xd=Object.defineProperty,Cd=(t,e,n)=>e in t?xd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Vt=(t,e,n)=>Cd(t,typeof e!="symbol"?e+"":e,n);let ko=class{constructor(){Vt(this,"contentType","application/json"),Vt(this,"decoder"),Vt(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(t){return this.encoder.encode(this.encodeString(t)).buffer}decode(t,e){return this.decodeString(this.decoder.decode(t),e)}decodeString(t,e){const n=JSON.parse(t),r=Ao(n);return e!=null?e.parse(r):r}encodeString(t){const e=Ad(t);return JSON.stringify(e,(n,r)=>ArrayBuffer.isView(r)?Array.from(r):Ps(r)&&"encode_value"in r?typeof r.value=="bigint"?r.value.toString():r.value:typeof r=="bigint"?r.toString():r)}static registerCustomType(){}},xo=class{constructor(){Vt(this,"contentType","text/csv")}encode(t){const e=this.encodeString(t);return new TextEncoder().encode(e).buffer}decode(t,e){const n=new TextDecoder().decode(t);return this.decodeString(n,e)}encodeString(t){if(!Array.isArray(t)||t.length===0||!Ps(t[0]))throw new Error("Payload must be an array of objects");const e=Object.keys(t[0]),n=[e.join(",")];return t.forEach(r=>{const i=e.map(a=>JSON.stringify(r[a]??""));n.push(i.join(","))}),n.join(`
|
|
28
|
-
`)}decodeString(t,e){const[n,...r]=t.trim().split(`
|
|
29
|
-
`).map(o=>o.trim());if(n.length===0)return e!=null?e.parse({}):{};const i=n.split(",").map(o=>o.trim()),a={};return i.forEach(o=>{a[o]=[]}),r.forEach(o=>{const c=o.split(",").map(u=>u.trim());i.forEach((u,h)=>{const f=this.parseValue(c[h]);f!=null&&a[u].push(f)})}),e!=null?e.parse(a):a}parseValue(t){if(t==null||t.length===0)return null;const e=Number(t);return isNaN(e)?t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t:e}static registerCustomType(){}},Co=class{constructor(){Vt(this,"contentType","text/plain")}encode(t){return new TextEncoder().encode(t).buffer}decode(t,e){const n=new TextDecoder().decode(t);return e!=null?e.parse(n):n}};const st=new ko,$d=new xo,Rd=new Co,jd=[st],dt=Object.freeze(Object.defineProperty({__proto__:null,CSVCodec:xo,CSV_CODEC:$d,ENCODERS:jd,JSONCodec:ko,JSON_CODEC:st,TEXT_CODEC:Rd,TextCodec:Co},Symbol.toStringTag,{value:"Module"})),ur=s.z.tuple([s.z.number(),s.z.number()]);s.z.tuple([s.z.bigint(),s.z.bigint()]);const $o=s.z.object({width:s.z.number(),height:s.z.number()}),Bd=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()}),Md=["width","height"];s.z.enum(Md);const Dd=["start","center","end"],Pd=["signedWidth","signedHeight"];s.z.enum(Pd);const tr=s.z.object({x:s.z.number(),y:s.z.number()}),Ud=s.z.object({clientX:s.z.number(),clientY:s.z.number()}),Ld=["x","y"],Ro=s.z.enum(Ld),jo=["top","right","bottom","left"];s.z.enum(jo);const _d=["left","right"],Bo=s.z.enum(_d),Yd=["top","bottom"],Mo=s.z.enum(Yd),Do=["center"],_i=s.z.enum(Do),qd=[...jo,...Do],Po=s.z.enum(qd);s.z.enum(Dd);const Fd=["first","last"];s.z.enum(Fd);const Vd=s.z.object({lower:s.z.number(),upper:s.z.number()}),Wd=s.z.object({lower:s.z.bigint(),upper:s.z.bigint()});s.z.union([Vd,ur]);s.z.union([Wd,ur]);s.z.union([Ro,Po]);s.z.union([Ro,Po,s.z.instanceof(String)]);const ft=t=>typeof t=="bigint"||t instanceof BigInt,Rr=(t,e)=>ft(t)?t.valueOf()-BigInt(e.valueOf().valueOf()):t.valueOf()-Number(e.valueOf()),Gd=(t,e)=>ft(t)?t.valueOf()+BigInt(e.valueOf().valueOf()):t+Number(e.valueOf()),Yi=(t,e)=>ft(t)?t===BigInt(e.valueOf().valueOf()):t===Number(e.valueOf()),Zd=(t,e)=>ft(t)?t.valueOf()<BigInt(e.valueOf())?t:BigInt(e.valueOf()):t.valueOf()<Number(e.valueOf())?t:Number(e.valueOf()),Kd=t=>ft(t)||t instanceof BigInt?t.valueOf()<0n?-t:t:t.valueOf()<0?-t:t,nt=(t,e)=>ft(t)?t.valueOf()*BigInt(e.valueOf()):t.valueOf()*Number(e.valueOf()),de=(t,e)=>{const n={};if(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 return qi(t);return qi(n)},qi=t=>t.lower>t.upper?{lower:t.upper,upper:t.lower}:t,Fi=(t,e)=>{const n=de(t);return e<n.lower?n.lower:e>=n.upper?n.upper-(typeof n.upper=="number"?1:1n):e},gn=(t,e)=>{const n=de(t);if(typeof e=="number"||typeof e=="bigint")return e>=n.lower&&e<n.upper;const r=de(e);return r.lower>=n.lower&&r.upper<=n.upper},Jd=(t,e,n)=>{const r=t.map(c=>de(c)),i=n>0?1:n<0?-1:0;if(i===0)return e;let a=n,o=e;for(;Yi(a,0)===!1;){const c=r.findIndex(u=>i>0?o>=u.lower&&o<u.upper:o>u.lower&&o<=u.upper);if(c!==-1){const u=r[c];let h;if(i>0?h=Rr(u.upper,o):h=Rr(o,u.lower),h>0){const f=Zd(Kd(a),h);if(o=Gd(o,i>0?f:-f),a=Rr(a,i>0?f:-f),Yi(a,0))return o;continue}}if(i>0){const u=r.filter(h=>h.lower>o);if(u.length>0)o=u[0].lower;else return o}else{const u=r.filter(h=>h.upper<o);if(u.length>0)o=u[u.length-1].upper;else return o}}return o},Hd=(t,e,n)=>{const r=t.map(o=>de(o));if(e===n)return typeof e=="bigint"?0n:0;const i=e<n?de([e,n]):de([n,e]);let a=typeof e=="bigint"?0n:0;for(const o of r){const c=o.lower>i.lower?o.lower:i.lower,u=o.upper<i.upper?o.upper:i.upper;if(c<u){const h=u-c;a=a+h}}return a};s.z.object({x:Bo.or(_i),y:Mo.or(_i)});const Xd=s.z.object({x:Bo,y:Mo}),Qd=Object.freeze({x:"left",y:"top"}),ef=(t,e)=>t.x===e.x&&t.y===e.y,Vi=s.z.union([s.z.number(),tr,ur,$o,Bd,Ud]),tf=(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}},Wi=Object.freeze({x:0,y:0}),pn=s.z.union([s.z.number(),s.z.string()]);s.z.object({top:pn,left:pn,width:pn,height:pn});s.z.object({left:s.z.number(),top:s.z.number(),right:s.z.number(),bottom:s.z.number()});s.z.object({one:tr,two:tr,root:Xd});const Us=(t,e,n=0,r=0,i)=>{const a={one:{...Wi},two:{...Wi},root:i??Qd};if(typeof t=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:t,y:e},a.two={x:a.one.x+n,y:a.one.y+r},a}return"one"in t&&"two"in t&&"root"in t?{...t,root:i??t.root}:("getBoundingClientRect"in t&&(t=t.getBoundingClientRect()),"left"in t?(a.one={x:t.left,y:t.top},a.two={x:t.right,y:t.bottom},a):(a.one=t,e==null?a.two={x:a.one.x+n,y:a.one.y+r}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+n}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},jr=t=>{const e=Us(t);return{lower:e.one.x,upper:e.two.x}},Br=t=>{const e=Us(t);return{lower:e.one.y,upper:e.two.y}},nf=t=>typeof t!="object"||t==null?!1:"one"in t&&"two"in t&&"root"in t;var rf=Object.defineProperty,sf=(t,e,n)=>e in t?rf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Me=(t,e,n)=>sf(t,typeof e!="symbol"?e+"":e,n);const af=(t,e,n)=>e!==void 0&&t<e?e:n!==void 0&&t>n?n:t;s.z.object({offset:Vi,scale:Vi});const of=t=>(e,n,r,i)=>n==="dimension"?[e,r]:[e,i?r-t:r+t],lf=t=>(e,n,r,i)=>[e,i?r/t:r*t],cf=t=>(e,n,r)=>{if(e===null)return[t,r];const{lower:i,upper:a}=e,{lower:o,upper:c}=t,u=a-i,h=c-o;if(n==="dimension")return[t,r*(h/u)];const f=(r-i)*(h/u)+o;return[t,f]},uf=t=>(e,n,r)=>[t,r],hf=()=>(t,e,n)=>{if(t===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[t,n];const{lower:r,upper:i}=t;return[t,i-(n-r)]},df=t=>(e,n,r)=>{const{lower:i,upper:a}=t;return r=af(r,i,a),[e,r]},gs=class Rt{constructor(){Me(this,"ops",[]),Me(this,"currBounds",null),Me(this,"currType",null),Me(this,"reversed",!1),this.ops=[]}static translate(e){return new Rt().translate(e)}static magnify(e){return new Rt().magnify(e)}static scale(e,n){return new Rt().scale(e,n)}translate(e){const n=this.new(),r=of(e);return r.type="translate",n.ops.push(r),n}magnify(e){const n=this.new(),r=lf(e);return r.type="magnify",n.ops.push(r),n}scale(e,n){const r=de(e,n),i=this.new(),a=cf(r);return a.type="scale",i.ops.push(a),i}clamp(e,n){const r=de(e,n),i=this.new(),a=df(r);return a.type="clamp",i.ops.push(a),i}reBound(e,n){const r=de(e,n),i=this.new(),a=uf(r);return a.type="re-bound",i.ops.push(a),i}invert(){const e=hf();e.type="invert";const n=this.new();return n.ops.push(e),n}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,n){return this.currBounds=null,this.ops.reduce(([r,i],a)=>a(r,e,i,this.reversed),[null,n])[1]}reverse(){const e=this.new();e.ops.reverse();const n=[];return e.ops.forEach((r,i)=>{if(r.type==="scale"||n.some(([o,c])=>i>=o&&i<=c))return;const a=e.ops.findIndex((o,c)=>o.type==="scale"&&c>i);a!==-1&&n.push([i,a])}),n.forEach(([r,i])=>{const a=e.ops.slice(r,i);a.unshift(e.ops[i]),e.ops.splice(r,i-r+1,...a)}),e.reversed=!e.reversed,e}};Me(gs,"IDENTITY",new gs);let Gi=gs;const Zi=class je{constructor(e=new Gi,n=new Gi,r=null){Me(this,"x"),Me(this,"y"),Me(this,"currRoot"),this.x=e,this.y=n,this.currRoot=r}static translate(e,n){return new je().translate(e,n)}static translateX(e){return new je().translateX(e)}static translateY(e){return new je().translateY(e)}static clamp(e){return new je().clamp(e)}static magnify(e){return new je().magnify(e)}static scale(e){return new je().scale(e)}static reBound(e){return new je().reBound(e)}translate(e,n){const r=tf(e,n),i=this.copy();return i.x=this.x.translate(r.x),i.y=this.y.translate(r.y),i}translateX(e){const n=this.copy();return n.x=this.x.translate(e),n}translateY(e){const n=this.copy();return n.y=this.y.translate(e),n}magnify(e){const n=this.copy();return n.x=this.x.magnify(e.x),n.y=this.y.magnify(e.y),n}scale(e){const n=this.copy();if(nf(e)){const r=this.currRoot;return n.currRoot=e.root,r!=null&&!ef(r,e.root)&&(r.x!==e.root.x&&(n.x=n.x.invert()),r.y!==e.root.y&&(n.y=n.y.invert())),n.x=n.x.scale(jr(e)),n.y=n.y.scale(Br(e)),n}return n.x=n.x.scale(e.width),n.y=n.y.scale(e.height),n}reBound(e){const n=this.copy();return n.x=this.x.reBound(jr(e)),n.y=this.y.reBound(Br(e)),n}clamp(e){const n=this.copy();return n.x=this.x.clamp(jr(e)),n.y=this.y.clamp(Br(e)),n}copy(){const e=new je;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Us(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};Me(Zi,"IDENTITY",new Zi);const Ki=t=>[...new Set(t)],ff=t=>t!=null&&typeof t=="object"&&"toString"in t,yf=(t,e=!1)=>{const n=ff(t)?"stringer":typeof t;let r;switch(n){case"string":r=(i,a)=>i.localeCompare(a);break;case"stringer":r=(i,a)=>i.toString().localeCompare(a.toString());break;case"number":r=(i,a)=>Number(i)-Number(a);break;case"bigint":r=(i,a)=>BigInt(i)-BigInt(a)>0n?1:-1;break;case"boolean":r=(i,a)=>Number(i)-Number(a);break;case"undefined":r=()=>0;break;default:return console.warn(`sortFunc: unknown type ${n}`),()=>-1}return e?gf(r):r},gf=t=>(e,n)=>t(n,e),hr=0,Mr=-1,Dr=1,pf=t=>t<hr,mf=t=>t>hr,wf=t=>t===hr,bf=(t,e)=>{let n=null;return e===0?t:(...r)=>{n!==null&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...r),e)}},vf=s.z.object({signedWidth:s.z.number(),signedHeight:s.z.number()});s.z.union([$o,vf,tr,ur]);const Of=s.z.bigint().or(s.z.string().transform(BigInt));var Tf=Object.defineProperty,Sf=(t,e,n)=>e in t?Tf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e,n)=>Sf(t,typeof e!="symbol"?e+"":e,n);let zf=(t,e=21)=>(n=e)=>{let r="",i=n;for(;i--;)r+=t[Math.random()*t.length|0];return r};const Nf="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Uo=zf(Nf,11),If=Object.freeze(Object.defineProperty({__proto__:null,id:Uo},Symbol.toStringTag,{value:"Module"})),Ef=s.z.enum(["static","dynamic"]),Lo=(t,e)=>{const n=new x(e);if(![$.DAY,$.HOUR,$.MINUTE,$.SECOND,$.MILLISECOND,$.MICROSECOND,$.NANOSECOND].some(i=>i.equals(n)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=t.valueOf()%n.valueOf();return t instanceof x?new x(r):new $(r)},F=class N{constructor(e,n="UTC"){if(g(this,"value"),g(this,"encodeValue",!0),e==null)this.value=N.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*N.MILLISECOND.valueOf();else if(typeof e=="string")this.value=N.parseDateTimeString(e,n).valueOf();else if(Array.isArray(e))this.value=N.parseDate(e);else{let r=BigInt(0);e instanceof Number&&(e=e.valueOf()),n==="local"&&(r=N.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=N.MAX:e=N.MIN)),this.value=BigInt(e.valueOf())+r}}static parseDate([e=1970,n=1,r=1]){const i=new Date(e,n-1,r,0,0,0,0);return new N(BigInt(i.getTime())*N.MILLISECOND.valueOf()).truncate(N.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,n="UTC"){const[r,i,a]=e.split(":");let o="00",c="00";a!=null&&([o,c]=a.split("."));let u=N.hours(parseInt(r??"00")).add(N.minutes(parseInt(i??"00"))).add(N.seconds(parseInt(o??"00"))).add(N.milliseconds(parseInt(c??"00")));return n==="local"&&(u=u.add(N.utcOffset)),u.valueOf()}static parseDateTimeString(e,n="UTC"){if(!e.includes("/")&&!e.includes("-"))return N.parseTimeString(e,n);const r=new Date(e);return e.includes(":")||r.setUTCHours(0,0,0,0),new N(BigInt(r.getTime())*N.MILLISECOND.valueOf(),n).valueOf()}fString(e="ISO",n="UTC"){switch(e){case"ISODate":return this.toISOString(n).slice(0,10);case"ISOTime":return this.toISOString(n).slice(11,23);case"time":return this.timeString(!1,n);case"preciseTime":return this.timeString(!0,n);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,n)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,n)}`;default:return this.toISOString(n)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(N.utcOffset).date().toISOString()}timeString(e=!1,n="UTC"){const r=this.toISOString(n);return e?r.slice(11,23):r.slice(11,19)}dateString(){const e=this.date(),n=e.toLocaleString("default",{month:"short"}),r=e.toLocaleString("default",{day:"numeric"});return`${n} ${r}`}static get utcOffset(){return new $(BigInt(new Date().getTimezoneOffset())*N.MINUTE.valueOf())}static since(e){return new N().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new N(e).valueOf()}span(e){return this.range(e).span}range(e){return new se(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new N(e).valueOf()}afterEq(e){return this.valueOf()>=new N(e).valueOf()}before(e){return this.valueOf()<new N(e).valueOf()}beforeEq(e){return this.valueOf()<=new N(e).valueOf()}add(e){return new N(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new N(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(N.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Lo(this,e)}get isToday(){return this.truncate($.DAY).equals(N.now().truncate($.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new N(new Date)}static max(...e){let n=N.MIN;for(const r of e){const i=new N(r);i.after(n)&&(n=i)}return n}static min(...e){let n=N.MAX;for(const r of e){const i=new N(r);i.before(n)&&(n=i)}return n}static nanoseconds(e){return new N(e)}static microseconds(e){return N.nanoseconds(e*1e3)}static milliseconds(e){return N.microseconds(e*1e3)}static seconds(e){return N.milliseconds(e*1e3)}static minutes(e){return N.seconds(e*60)}static hours(e){return N.minutes(e*60)}static days(e){return N.hours(e*24)}};g(F,"NANOSECOND",F.nanoseconds(1)),g(F,"MICROSECOND",F.microseconds(1)),g(F,"MILLISECOND",F.milliseconds(1)),g(F,"SECOND",F.seconds(1)),g(F,"MINUTE",F.minutes(1)),g(F,"HOUR",F.hours(1)),g(F,"DAY",F.days(1)),g(F,"MAX",new F((1n<<63n)-1n)),g(F,"MIN",new F(0)),g(F,"ZERO",new F(0)),g(F,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new F(t.value)),s.z.string().transform(t=>new F(BigInt(t))),s.z.instanceof(Number).transform(t=>new F(t)),s.z.number().transform(t=>new F(t)),s.z.instanceof(F)]));let x=F;const V=class A{constructor(e){g(this,"value"),g(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof A?e:e instanceof Kt?e.period:e instanceof x?new A(e):["number","bigint"].includes(typeof e)?A.seconds(e):new A(e)}static fromMilliseconds(e){return e instanceof A?e:e instanceof Kt?e.period:e instanceof x?new A(e):["number","bigint"].includes(typeof e)?A.milliseconds(e):new A(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new A(e).valueOf()}greaterThan(e){return this.valueOf()>new A(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new A(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new A(e).valueOf()}remainder(e){return Lo(this,e)}truncate(e){return new A(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(A.DAY),n=this.truncate(A.HOUR),r=this.truncate(A.MINUTE),i=this.truncate(A.SECOND),a=this.truncate(A.MILLISECOND),o=this.truncate(A.MICROSECOND),c=this.truncate(A.NANOSECOND),u=e,h=n.sub(e),f=r.sub(n),d=i.sub(r),k=a.sub(i),D=o.sub(a),ie=c.sub(o);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 `),k.isZero||(B+=`${k.milliseconds}ms `),D.isZero||(B+=`${D.microseconds}µs `),ie.isZero||(B+=`${ie.nanoseconds}ns`),B.trim()}get days(){return Number(this.valueOf())/Number(A.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(A.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(A.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(A.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(A.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(A.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new A(e).valueOf()}add(e){return new A(this.valueOf()+new A(e).valueOf())}sub(e){return new A(this.valueOf()-new A(e).valueOf())}static nanoseconds(e=1){return new A(e)}static microseconds(e=1){return A.nanoseconds(nt(e,1e3))}static milliseconds(e=1){return A.microseconds(nt(e,1e3))}static seconds(e=1){return A.milliseconds(nt(e,1e3))}static minutes(e=1){return A.seconds(nt(e,60))}static hours(e){return A.minutes(nt(e,60))}static days(e){return A.hours(nt(e,24))}};g(V,"NANOSECOND",V.nanoseconds(1)),g(V,"MICROSECOND",V.microseconds(1)),g(V,"MILLISECOND",V.milliseconds(1)),g(V,"SECOND",V.seconds(1)),g(V,"MINUTE",V.minutes(1)),g(V,"HOUR",V.hours(1)),g(V,"DAY",V.days(1)),g(V,"MAX",new V((1n<<63n)-1n)),g(V,"MIN",new V(0)),g(V,"ZERO",new V(0)),g(V,"z",s.z.union([s.z.object({value:s.z.bigint()}).transform(t=>new V(t.value)),s.z.string().transform(t=>new V(BigInt(t))),s.z.instanceof(Number).transform(t=>new V(t)),s.z.number().transform(t=>new V(t)),s.z.instanceof(V)]));let $=V;const jt=class jn extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new jn(e).valueOf()}get period(){return $.seconds(1/this.valueOf())}sampleCount(e){return new $(e).seconds*this.valueOf()}byteCount(e,n){return this.sampleCount(e)*new he(n).valueOf()}span(e){return $.seconds(e/this.valueOf())}byteSpan(e,n){return this.span(e.valueOf()/n.valueOf())}static hz(e){return new jn(e)}static khz(e){return jn.hz(e*1e3)}};g(jt,"z",s.z.union([s.z.number().transform(t=>new jt(t)),s.z.instanceof(Number).transform(t=>new jt(t)),s.z.instanceof(jt)]));let Kt=jt;const re=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new ot(e*this.valueOf())}};g(re,"UNKNOWN",new re(0)),g(re,"BIT128",new re(16)),g(re,"BIT64",new re(8)),g(re,"BIT32",new re(4)),g(re,"BIT16",new re(2)),g(re,"BIT8",new re(1)),g(re,"z",s.z.union([s.z.number().transform(t=>new re(t)),s.z.instanceof(Number).transform(t=>new re(t)),s.z.instanceof(re)]));let he=re;const ke=class Bn{constructor(e,n){g(this,"start"),g(this,"end"),typeof e=="object"&&"start"in e?(this.start=new x(e.start),this.end=new x(e.end)):(this.start=new x(e),this.end=new x(n))}get span(){return new $(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new Bn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,n=$.ZERO){e=e.makeValid();const r=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(r.start)||r.end.equals(e.start))return!1;const i=x.max(r.start,e.start),a=x.min(r.end,e.end);return a.before(i)?!1:new $(a.sub(i)).greaterThanOrEqual(n)}roughlyEquals(e,n){let r=this.start.sub(e.start).valueOf(),i=this.end.sub(e.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=n.valueOf()&&i<=n.valueOf()}contains(e){return e instanceof Bn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const n=new Bn(this.start,this.end);return e.start.after(this.start)&&(n.start=e.start),e.start.after(this.end)&&(n.end=e.start),e.end.before(this.end)&&(n.end=e.end),e.end.before(this.start)&&(n.start=e.end),n}};g(ke,"MAX",new ke(x.MIN,x.MAX)),g(ke,"MIN",new ke(x.MAX,x.MIN)),g(ke,"ZERO",new ke(x.ZERO,x.ZERO)),g(ke,"z",s.z.union([s.z.object({start:x.z,end:x.z}).transform(t=>new ke(t.start,t.end)),s.z.instanceof(ke)]));let se=ke;const w=class xe extends String{constructor(e){if(e instanceof xe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const n=xe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(n!=null){super(n.valueOf());return}throw super(xe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=xe.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(n=>this.equals(n))}toString(){return this.valueOf()}get isVariable(){return this.equals(xe.JSON)||this.equals(xe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(xe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=xe.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return xe.BIG_INT_TYPES.some(e=>e.equals(this))}};g(w,"UNKNOWN",new w("unknown")),g(w,"FLOAT64",new w("float64")),g(w,"FLOAT32",new w("float32")),g(w,"INT64",new w("int64")),g(w,"INT32",new w("int32")),g(w,"INT16",new w("int16")),g(w,"INT8",new w("int8")),g(w,"UINT64",new w("uint64")),g(w,"UINT32",new w("uint32")),g(w,"UINT16",new w("uint16")),g(w,"UINT8",new w("uint8")),g(w,"BOOLEAN",w.UINT8),g(w,"TIMESTAMP",new w("timestamp")),g(w,"UUID",new w("uuid")),g(w,"STRING",new w("string")),g(w,"JSON",new w("json")),g(w,"ARRAY_CONSTRUCTORS",new Map([[w.UINT8.toString(),Uint8Array],[w.UINT16.toString(),Uint16Array],[w.UINT32.toString(),Uint32Array],[w.UINT64.toString(),BigUint64Array],[w.FLOAT32.toString(),Float32Array],[w.FLOAT64.toString(),Float64Array],[w.INT8.toString(),Int8Array],[w.INT16.toString(),Int16Array],[w.INT32.toString(),Int32Array],[w.INT64.toString(),BigInt64Array],[w.TIMESTAMP.toString(),BigInt64Array],[w.STRING.toString(),Uint8Array],[w.JSON.toString(),Uint8Array],[w.UUID.toString(),Uint8Array]])),g(w,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,w.UINT8],[Uint16Array.name,w.UINT16],[Uint32Array.name,w.UINT32],[BigUint64Array.name,w.UINT64],[Float32Array.name,w.FLOAT32],[Float64Array.name,w.FLOAT64],[Int8Array.name,w.INT8],[Int16Array.name,w.INT16],[Int32Array.name,w.INT32],[BigInt64Array.name,w.INT64]])),g(w,"DENSITIES",new Map([[w.UINT8.toString(),he.BIT8],[w.UINT16.toString(),he.BIT16],[w.UINT32.toString(),he.BIT32],[w.UINT64.toString(),he.BIT64],[w.FLOAT32.toString(),he.BIT32],[w.FLOAT64.toString(),he.BIT64],[w.INT8.toString(),he.BIT8],[w.INT16.toString(),he.BIT16],[w.INT32.toString(),he.BIT32],[w.INT64.toString(),he.BIT64],[w.TIMESTAMP.toString(),he.BIT64],[w.STRING.toString(),he.UNKNOWN],[w.JSON.toString(),he.UNKNOWN],[w.UUID.toString(),he.BIT128]])),g(w,"ALL",[w.UNKNOWN,w.FLOAT64,w.FLOAT32,w.INT64,w.INT32,w.INT16,w.INT8,w.UINT64,w.UINT32,w.UINT16,w.UINT8,w.TIMESTAMP,w.UUID,w.STRING,w.JSON]),g(w,"BIG_INT_TYPES",[w.INT64,w.UINT64,w.TIMESTAMP]),g(w,"z",s.z.union([s.z.string().transform(t=>new w(t)),s.z.instanceof(w)]));let C=w;const le=class X extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return X.bytes(this.valueOf()+e.valueOf())}sub(e){return X.bytes(this.valueOf()-e.valueOf())}truncate(e){return new X(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return X.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/X.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/X.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/X.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/X.TERABYTE.valueOf()}toString(){const e=this.truncate(X.TERABYTE),n=this.truncate(X.GIGABYTE),r=this.truncate(X.MEGABYTE),i=this.truncate(X.KILOBYTE),a=this.truncate(X.BYTE),o=e,c=n.sub(e),u=r.sub(n),h=i.sub(r),f=a.sub(i);let d="";return o.isZero||(d+=`${o.terabytes}TB `),c.isZero||(d+=`${c.gigabytes}GB `),u.isZero||(d+=`${u.megabytes}MB `),h.isZero||(d+=`${h.kilobytes}KB `),(!f.isZero||d==="")&&(d+=`${f.valueOf()}B`),d.trim()}static bytes(e=1){return new X(e)}static kilobytes(e=1){return X.bytes(e.valueOf()*1e3)}static megabytes(e=1){return X.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return X.megabytes(e.valueOf()*1e3)}static terabytes(e){return X.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};g(le,"BYTE",new le(1)),g(le,"KILOBYTE",le.kilobytes(1)),g(le,"MEGABYTE",le.megabytes(1)),g(le,"GIGABYTE",le.gigabytes(1)),g(le,"TERABYTE",le.terabytes(1)),g(le,"ZERO",new le(0)),g(le,"z",s.z.union([s.z.number().transform(t=>new le(t)),s.z.instanceof(le)]));let ot=le;s.z.union([s.z.instanceof(Uint8Array),s.z.instanceof(Uint16Array),s.z.instanceof(Uint32Array),s.z.instanceof(BigUint64Array),s.z.instanceof(Float32Array),s.z.instanceof(Float64Array),s.z.instanceof(Int8Array),s.z.instanceof(Int16Array),s.z.instanceof(Int32Array),s.z.instanceof(BigInt64Array)]);const _o=t=>{const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||t instanceof x||t instanceof $||t instanceof Date},Af=(t,e,n,r=0)=>t.usesBigInt&&!e.usesBigInt?Number(n)-Number(r):!t.usesBigInt&&e.usesBigInt?BigInt(n.valueOf())-BigInt(r.valueOf()):Mt(n,-r).valueOf(),kf=t=>t==null?!1:Array.isArray(t)||t instanceof ArrayBuffer||ArrayBuffer.isView(t)&&!(t instanceof DataView)||t instanceof Ke?!0:_o(t),Le=-1,ps={[Symbol.iterator]:()=>ps,next:()=>({done:!0,value:void 0})},xf=s.z.string().transform(t=>new Uint8Array(atob(t).split("").map(e=>e.charCodeAt(0))).buffer),Cf=s.z.union([s.z.null(),s.z.undefined()]).transform(()=>new Uint8Array().buffer),ms=10,Bt=class Ce{constructor(e){g(this,"key",""),g(this,"isSynnaxSeries",!0),g(this,"dataType"),g(this,"sampleOffset"),g(this,"gl"),g(this,"_data"),g(this,"_timeRange"),g(this,"alignment",0n),g(this,"_cachedMin"),g(this,"_cachedMax"),g(this,"writePos",Le),g(this,"_refCount",0),g(this,"_cachedLength"),g(this,"_cachedIndexes"),kf(e)&&(e={data:e});const{dataType:n,timeRange:r,sampleOffset:i=0,glBufferUsage:a="static",alignment:o=0n,key:c=Uo()}=e,u=e.data??[];if(u instanceof Ce||typeof u=="object"&&"isSynnaxSeries"in u&&u.isSynnaxSeries===!0){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._cachedMin=d._cachedMin,this._cachedMax=d._cachedMax,this.writePos=d.writePos,this._refCount=d._refCount,this._cachedLength=d._cachedLength;return}const h=_o(u),f=Array.isArray(u);if(n!=null)this.dataType=new C(n);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=C.STRING;else if(typeof d=="number")this.dataType=C.FLOAT64;else if(typeof d=="bigint")this.dataType=C.INT64;else if(typeof d=="boolean")this.dataType=C.BOOLEAN;else if(d instanceof x||d instanceof Date||d instanceof x)this.dataType=C.TIMESTAMP;else if(typeof d=="object")this.dataType=C.JSON;else throw new Error(`cannot infer data type of ${typeof d} when constructing a Series from a JS array`)}else this.dataType=new C(u)}if(!f&&!h)this._data=u;else{let d=h?[u]:u;const k=d[0];(k instanceof x||k instanceof Date||k instanceof $)&&(d=d.map(D=>new x(D).valueOf())),this.dataType.equals(C.STRING)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.join(`
|
|
30
|
-
`)}
|
|
31
|
-
`)):this.dataType.equals(C.JSON)?(this._cachedLength=d.length,this._data=new TextEncoder().encode(`${d.map(D=>st.encodeString(D)).join(`
|
|
32
|
-
`)}
|
|
33
|
-
`)):this._data=new this.dataType.Array(d).buffer}this.key=c,this.alignment=o,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:n,...r}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new C(n).Array(e),a=new Ce({data:i.buffer,dataType:n,...r});return a.writePos=0,a}static generateTimestamps(e,n,r){const i=r.spanRange(n.span(e)),a=new BigInt64Array(e);for(let o=0;o<e;o++)a[o]=BigInt(r.add(n.span(o)).valueOf());return new Ce({data:a,dataType:C.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(e,n){const r=new TextEncoder().encode(`${e.join(`
|
|
34
|
-
`)}
|
|
35
|
-
`);return new Ce({data:r,dataType:C.STRING,timeRange:n})}static fromJSON(e,n){const r=new TextEncoder().encode(`${e.map(i=>st.encodeString(i)).join(`
|
|
36
|
-
`)}
|
|
37
|
-
`);return new Ce({data:r,dataType:C.JSON,timeRange:n})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===Le)return 0;const n=this.byteCapacity.valueOf()-this.writePos,r=e.subBytes(0,n);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(e){if(this.writePos===Le)return 0;const n=this.capacity-this.writePos,r=e.sub(0,n);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return this._data instanceof ArrayBuffer||this._data instanceof SharedArrayBuffer?this._data:this._data.buffer}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Le?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(C.STRING,C.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
38
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(C.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=C.UUID.density.valueOf(),n=Array(this.length);for(let r=0;r<this.length;r++){const i=this.underlyingData.slice(r*e,(r+1)*e),a=Array.from(new Uint8Array(i),o=>o.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");n[r]=a}return n}parseJSON(e){if(!this.dataType.equals(C.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
39
|
-
`).slice(0,-1).map(n=>e.parse(st.decodeString(n)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new ot(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Le?this.byteCapacity:this.dataType.isVariable?new ot(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Le?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const n=[0];return this.data.forEach((r,i)=>{r===ms&&(e++,n.push(i+1))}),this._cachedIndexes=n,this._cachedLength=e,e}convert(e,n=0){if(this.dataType.equals(e))return this;const r=new e.Array(this.length);for(let i=0;i<this.length;i++)r[i]=Af(this.dataType,e,this.data[i],n);return new Ce({data:r.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:n,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(C.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}else{const e=this.data;this._cachedMax=e.reduce((n,r)=>n>r?n:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),Mt(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(C.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}else{const e=this.data;this._cachedMin=e.reduce((n,r)=>n<r?n:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),Mt(this._cachedMin,this.sampleOffset))}get bounds(){return de(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const n=e._cachedMin??e.calcRawMin();n<this._cachedMin&&(this._cachedMin=n)}if(this._cachedMax!=null){const n=e._cachedMax??e.calcRawMax();n>this._cachedMax&&(this._cachedMax=n)}}enrich(){this.max,this.min}get range(){return Mt(this.max,-this.min)}atAlignment(e,n){const r=Number(e-this.alignment);if(r<0||r>=this.length){if(n===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,n)}at(e,n){if(this.dataType.isVariable)return this.atVariable(e,n??!1);e<0&&(e=this.length+e);const r=this.data[e];if(r==null){if(n===!0)throw new Error(`[series] - no value at index ${e}`);return}return Mt(r,this.sampleOffset)}atVariable(e,n){let r=0,i=0;if(this._cachedIndexes!=null)r=this._cachedIndexes[e],i=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let o=0;o<this.data.length;o++)if(this.data[o]===ms){if(e===0){i=o;break}r=o+1,e--}if(i===0&&(i=this.data.length),r>=i||e>0){if(n)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(r,i);return this.dataType.equals(C.STRING)?new TextDecoder().decode(a):Ao(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let n=0,r=this.length-1;const i=yf(e);for(;n<=r;){const a=Math.floor((n+r)/2),o=i(this.at(a,!0),e);if(o===0)return a;o<0?n=a+1:r=a-1}return n}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(C.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:n,bufferUsage:r,prevBuffer:i}=this.gl;if(n==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==i)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Le){i===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(i).valueOf(),o=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,o.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.underlyingData,r==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Le}as(e){if(e==="string"){if(!this.dataType.equals(C.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(C.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return de(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new $f(this);return this.dataType.equals(C.JSON)?new Rf(e):e}return new jf(this)}slice(e,n){return this.sliceSub(!1,e,n)}sub(e,n){return this.sliceSub(!0,e,n)}subIterator(e,n){return new Ji(this,e,n??this.length)}subAlignmentIterator(e,n){return new Ji(this,Number(e-this.alignment),Number(n-this.alignment))}subBytes(e,n){if(e>=0&&(n==null||n>=this.byteLength.valueOf()))return this;const r=this.data.subarray(e,n);return new Ce({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,n,r){if(n<=0&&(r==null||r>=this.length))return this;let i;return e?i=this.data.subarray(n,r):i=this.data.slice(n,r),new Ce({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(n)})}reAlign(e){return new Ce({data:this.buffer,dataType:this.dataType,timeRange:se.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};g(Bt,"crudeZ",s.z.object({timeRange:se.z.optional(),dataType:C.z,alignment:Of.optional(),data:s.z.union([xf,Cf,s.z.instanceof(ArrayBuffer)]),glBufferUsage:Ef.optional().default("static").optional()})),g(Bt,"z",Bt.crudeZ.transform(t=>new Bt(t)));let Ke=Bt,Ji=class{constructor(t,e,n){g(this,"series"),g(this,"end"),g(this,"index"),this.series=t;const r=de(0,t.length);this.end=Fi(r,n),this.index=Fi(r,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};class $f{constructor(e){if(g(this,"series"),g(this,"index"),g(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,n=this.series.data;for(;this.index<n.length&&n[this.index]!==ms;)this.index++;const r=this.index;return e===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,r))})}[Symbol.iterator](){return this}}var Hi,Xi;class Rf{constructor(e){g(this,"wrapped"),g(this,Hi,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:st.decodeString(e.value)}}[(Xi=Symbol.iterator,Hi=Symbol.toStringTag,Xi)](){return this}}var Qi,ea;class jf{constructor(e){g(this,"series"),g(this,"index"),g(this,Qi,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(ea=Symbol.iterator,Qi=Symbol.toStringTag,ea)](){return this}}const Mt=(t,e)=>typeof t=="bigint"&&typeof e=="bigint"||typeof t=="number"&&typeof e=="number"?t+e:e===0?t:t===0?e:Number(t)+Number(e);class Bf{constructor(e){if(g(this,"series"),e.length!==0){const n=e[0].dataType;for(let r=1;r<e.length;r++)if(!e[r].dataType.equals(n))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new C(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?C.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?se.ZERO:new se(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?de(0n,0n):de(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,n)=>e+n.length,0)}atAlignment(e,n){if(this.series.length===0){if(n)throw new Error(`[series] - no value at alignment ${e}`);return}for(const r of this.series)if(gn(r.alignmentBounds,e))return r.atAlignment(e,n);if(n)throw new Error(`[series] - no value at alignment ${e}`)}at(e,n=!1){e<0&&(e=this.length+e);for(const r of this.series){if(e<r.length)return r.at(e,n);e-=r.length}if(n)throw new Error(`[series] - no value at index ${e}`)}subIterator(e,n){return new Pr(this,e,n??this.length)}subAlignmentIterator(e,n){if(e>=this.alignmentBounds.upper||n<=this.alignmentBounds.lower)return ps;let r=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(e<o.alignment)break;if(e>=o.alignmentBounds.upper)r+=o.length;else if(gn(o.alignmentBounds,e)){r+=Number(e-o.alignment);break}}let i=0;for(let a=0;a<this.series.length;a++){const o=this.series[a];if(n<o.alignment)break;if(n>=o.alignmentBounds.upper)i+=o.length;else if(gn(o.alignmentBounds,n)){i+=Number(n-o.alignment);break}}return new Pr(this,r,i)}subAlignmentSpanIterator(e,n){if(e>=this.alignmentBounds.upper)return ps;let r=0;for(let i=0;i<this.series.length;i++){const a=this.series[i];if(e<a.alignment)break;if(e>=a.alignmentBounds.upper)r+=a.length;else if(gn(a.alignmentBounds,e)){r+=Number(e-a.alignment);break}}return new Pr(this,r,r+n)}get byteLength(){return new ot(this.series.reduce((e,n)=>e+n.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let n=0;for(const r of this.series)e.set(r.data,n),n+=r.length;return new this.dataType.Array(e)}traverseAlignment(e,n){const r=this.series.map(i=>i.alignmentBounds);return Jd(r,e,n)}distance(e,n){const r=this.series.map(i=>i.alignmentBounds);return Hd(r,e,n)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Mf(this.series)}}var ta,na;class Mf{constructor(e){g(this,"series"),g(this,"seriesIndex"),g(this,"internal"),g(this,ta,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(na=Symbol.iterator,ta=Symbol.toStringTag,na)](){return this}}class Pr{constructor(e,n,r){g(this,"series"),g(this,"index"),g(this,"end"),this.series=e,this.end=r,this.index=n}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}s.z.object({key:s.z.string(),value:s.z.string()});var Df=Object.defineProperty,Pf=(t,e,n)=>e in t?Df(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Mn=(t,e,n)=>Pf(t,typeof e!="symbol"?e+"":e,n);let Uf=class{constructor(t,e){Mn(this,"handlers"),Mn(this,"transform"),Mn(this,"closer"),this.transform=t,this.handlers=e??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){let e=t;if(this.transform!=null){const[n,r]=this.transform(t);if(!r)return;e=n}this.handlers.forEach((n,r)=>r(e))}setCloser(t){this.closer=t}async close(){var t;return await((t=this.closer)==null?void 0:t.call(this))}},Lf=class{constructor(t){Mn(this,"handlers"),this.handlers=t??new Map}onChange(t){return this.handlers.set(t,null),()=>this.handlers.delete(t)}notify(t){this.handlers.forEach((e,n)=>n(t))}};const Qe=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:Lf,Observer:Uf},Symbol.toStringTag,{value:"Module"})),dr=s.z.record(s.z.union([s.z.number(),s.z.string(),s.z.symbol()]),s.z.unknown()),_f=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";_f();const Yf=["MacOS","Windows","Linux","Docker"];s.z.enum(Yf);var qf=Object.defineProperty,Ff=(t,e,n)=>e in t?qf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Dt=(t,e,n)=>Ff(t,typeof e!="symbol"?e+"":e,n);const Vf=(...t)=>t.map(Yo).join(""),Yo=t=>(t.endsWith("/")||(t+="/"),t.startsWith("/")&&(t=t.slice(1)),t),Wf=t=>t.endsWith("/")?t.slice(0,-1):t,ws=class bs{constructor({host:e,port:n,protocol:r="",pathPrefix:i=""}){Dt(this,"protocol"),Dt(this,"host"),Dt(this,"port"),Dt(this,"path"),this.protocol=r,this.host=e,this.port=n,this.path=Yo(i)}replace(e){return new bs({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new bs({...this,pathPrefix:Vf(this.path,e)})}toString(){return Wf(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};Dt(ws,"UNKNOWN",new ws({host:"unknown",port:0}));let Gf=ws;var Zf=Object.defineProperty,Kf=(t,e,n)=>e in t?Zf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Dn=(t,e,n)=>Kf(t,typeof e!="symbol"?e+"":e,n);const Ze=class extends Number{};Dn(Ze,"Absolute",255),Dn(Ze,"Default",1),Dn(Ze,"z",s.z.union([s.z.instanceof(Ze),s.z.number().int().min(0).max(255).transform(t=>new Ze(t)),s.z.instanceof(Number).transform(t=>new Ze(t))]));let qo=Ze;const Fo=s.z.object({name:s.z.string(),key:s.z.string()}),Jf=t=>s.z.object({subject:Fo,resource:t,authority:qo.z}),Hf=(...t)=>e=>e.filter(n=>{let r=!1;return n.to!=null&&(r=t.includes(n.to.resource)),n.from!=null&&!r&&(r=t.includes(n.from.resource)),r}),lt=Object.freeze(Object.defineProperty({__proto__:null,Authority:qo,filterTransfersByChannelKey:Hf,stateZ:Jf,subjectZ:Fo},Symbol.toStringTag,{value:"Module"})),Vo=class Pt extends Error{constructor(){super(Pt.MESSAGE)}matches(e){return typeof e=="string"?e.includes(Pt.MESSAGE):e instanceof Pt||e.message.includes(Pt.MESSAGE)}};Dn(Vo,"MESSAGE","canceled");let Xf=Vo;new Xf;const vs=s.z.string().regex(/^\d+\.\d+\.\d+$/),an=(t,e,n={})=>{n.checkMajor??(n.checkMajor=!0),n.checkMinor??(n.checkMinor=!0),n.checkPatch??(n.checkPatch=!0);const r=vs.parse(t),i=vs.parse(e),[a,o,c]=r.split(".").map(Number),[u,h,f]=i.split(".").map(Number);if(n.checkMajor){if(a<u)return Mr;if(a>u)return Dr}if(n.checkMinor){if(o<h)return Mr;if(o>h)return Dr}if(n.checkPatch){if(c<f)return Mr;if(c>f)return Dr}return hr},Qf=(t,e,n={})=>wf(an(t,e,n)),Wo=(t,e,n={})=>mf(an(t,e,n)),ey=(t,e,n={})=>pf(an(t,e,n)),ty=({name:t,migrate:e})=>n=>{try{const r=e(n);return console.log(`${t} migrated: ${n.version} -> ${r.version}`),r}catch(r){throw console.log(`${t} failed to migrate from ${n.version}`),console.error(r),r}},ny=({name:t,migrations:e,targetSchema:n,defaultVersion:r,def:i})=>{const a=Object.keys(e).sort(an).pop();if(a==null)return h=>{if(h.version??(h.version=r),h.version!==i.version)return console.log(`${t} version ${h.version} is newer than latest version of ${i.version}.
|
|
40
|
-
Returning default instead.
|
|
41
|
-
`),i;try{return n!=null?n.parse(h):h}catch(f){return console.log(`${t} failed to parse default. Exiting with default`),console.error(f),i}};const o=Object.keys(e).length;let c=!1;const u=h=>{try{if(o===0||Wo(h.version,a))return console.log(c?`${t} ${h.version} now up to date`:`${t} version ${h.version} is up to date with target version ${i.version}`),h;const f=h.version,d=e[f],k=d(h);return c=!0,u(k)}catch(f){return console.log(`${t} failed to migrate from ${h.version} to ${a}`),console.error(f),i}};return h=>{try{if(h.version==null)if(r!=null)console.log(`${t} version is null. Setting version to default of ${r}`),h.version=r;else return console.log(`${t} version is null and no default version set. Exiting with default`),i;return u(h)}catch(f){return console.log(`${t} failed to parse final result. Exiting with default`),console.error(f),i}}},ra=Object.freeze(Object.defineProperty({__proto__:null,compareSemVer:an,createMigration:ty,migrator:ny,semVerNewer:Wo,semVerOlder:ey,semVerZ:vs,versionsEqual:Qf},Symbol.toStringTag,{value:"Module"})),Fe="sy.",Pn=class Go extends Te{constructor(){super(...arguments),l(this,"type",Go.TYPE)}};l(Pn,"TYPE",`${Fe}validation`),l(Pn,"matches",fe(Pn.TYPE));let K=Pn;const Un=class Zo extends K{constructor(e,n){super(`${e}: ${n}`),l(this,"type",Zo.TYPE),l(this,"field"),l(this,"message"),this.field=e,this.message=n}};l(Un,"TYPE",`${K.TYPE}.field`),l(Un,"matches",fe(Un.TYPE));let sa=Un;const Ln=class Ko extends Te{constructor(){super(...arguments),l(this,"type",Ko.TYPE)}};l(Ln,"TYPE",`${Fe}auth`),l(Ln,"matches",fe(Ln.TYPE));let nr=Ln;const _n=class Jo extends nr{constructor(){super(...arguments),l(this,"type",Jo.TYPE)}};l(_n,"TYPE",`${nr.TYPE}.invalid-token`),l(_n,"matches",fe(_n.TYPE));let Os=_n;const Yn=class Ho extends Te{constructor(e){super(`
|
|
42
|
-
Unexpected error encountered:
|
|
43
|
-
|
|
44
|
-
${e}
|
|
45
|
-
|
|
46
|
-
Please report this to the Synnax team.
|
|
47
|
-
`),l(this,"type",Ho.TYPE)}};l(Yn,"TYPE",`${Fe}unexpected`),l(Yn,"matches",fe(Yn.TYPE));let be=Yn;const qn=class Xo extends Te{constructor(){super(...arguments),l(this,"type",Xo.TYPE)}};l(qn,"TYPE",`${Fe}query`),l(qn,"matches",fe(qn.TYPE));let Oe=qn;const Fn=class Qo extends Oe{constructor(){super(...arguments),l(this,"type",Qo.TYPE)}};l(Fn,"TYPE",`${Oe.TYPE}.not_found`),l(Fn,"matches",fe(Fn.TYPE));let ct=Fn;const Vn=class el extends Oe{constructor(){super(...arguments),l(this,"type",el.TYPE)}};l(Vn,"TYPE",`${Oe.TYPE}.multiple_results`),l(Vn,"matches",fe(Vn.TYPE));let ut=Vn;const Wn=class tl extends Te{constructor(e,n){super(e),l(this,"type",tl.TYPE),l(this,"path"),this.path=n}};l(Wn,"TYPE",`${Fe}route`),l(Wn,"matches",fe(Wn.TYPE));let ia=Wn;const Gn=class nl extends Te{constructor(){super(...arguments),l(this,"type",nl.TYPE)}};l(Gn,"TYPE",`${Fe}control`),l(Gn,"matches",fe(Gn.TYPE));let rr=Gn;const Zn=class rl extends rr{constructor(){super(...arguments),l(this,"type",rl.TYPE)}};l(Zn,"TYPE",`${rr.TYPE}.unauthorized`),l(Zn,"matches",fe(Zn.TYPE));let aa=Zn;const Ur=class sl extends Te{constructor(){super(...arguments),l(this,"type",sl.TYPE)}};l(Ur,"TYPE",`${Fe}contiguity`),l(Ur,"matches",fe(Ur.TYPE));const ry=t=>{if(!t.type.startsWith(Fe))return null;if(t.type.startsWith(K.TYPE)){if(t.type===sa.TYPE){const e=t.data.split(": ");return e.length<2?new K(t.data):new sa(e[0],e[1])}return new K(t.data)}return t.type.startsWith(nr.TYPE)?t.type.startsWith(Os.TYPE)?new Os(t.data):new nr(t.data):t.type.startsWith(be.TYPE)?new be(t.data):t.type.startsWith(Oe.TYPE)?t.type.startsWith(ct.TYPE)?new ct(t.data):t.type.startsWith(ut.TYPE)?new ut(t.data):new Oe(t.data):t.type.startsWith(rr.TYPE)?t.type.startsWith(aa.TYPE)?new aa(t.data):new rr(t.data):t.type.startsWith(ia.TYPE)?new ia(t.data,t.data):new be(t.data)},sy=()=>{throw new Error("Not implemented")};bo({encode:sy,decode:ry});const iy=async(t,e)=>{const[n,r]=await e(t);return r==null?[n,r]:r instanceof Xe?[n,new Xe({message:`Cannot reach cluster at ${r.url.host}:${r.url.port}`,url:r.url})]:[n,r]};class il{constructor(e,n){l(this,"key"),l(this,"name"),this.key=n,this.name=e}get ontologyID(){return new R({type:"group",key:this.key})}}const ay=s.z.string().uuid(),al=s.z.object({key:ay,name:s.z.string()}),fr=s.z.union([s.z.literal("label"),s.z.literal("log"),s.z.literal("allow_all"),s.z.literal("builtin"),s.z.literal("cluster"),s.z.literal("channel"),s.z.literal("node"),s.z.literal("group"),s.z.literal("range"),s.z.literal("framer"),s.z.literal("range-alias"),s.z.literal("user"),s.z.literal("workspace"),s.z.literal("schematic"),s.z.literal("lineplot"),s.z.literal("rack"),s.z.literal("device"),s.z.literal("task"),s.z.literal("policy")]),ge=s.z.object({type:fr,key:s.z.string()}),oy=s.z.string().transform(t=>{const[e,n]=t.split(":");return{type:fr.parse(e),key:n??""}}),Ut=s.z.union([oy,ge]),Kn=class ol{constructor(e){if(l(this,"type"),l(this,"key"),e instanceof ol){this.type=e.type,this.key=e.key;return}if(typeof e=="string"){const[n,r]=e.split(":");this.type=n,this.key=r??"";return}this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}isType(){return this.key===""}matchesType(e){return this.type===e&&this.isType()}get payload(){return{type:this.type,key:this.key}}};l(Kn,"z",s.z.union([s.z.instanceof(Kn),Ut.transform(t=>new Kn(t))]));let R=Kn;new R({type:"builtin",key:"root"});const ly=s.z.object({type:s.z.number()}),cy=s.z.object({type:fr,fields:s.z.record(ly)}),uy=s.z.object({id:R.z,name:s.z.string(),schema:cy.optional().nullable(),data:s.z.record(s.z.unknown()).optional().nullable()}).transform(t=>({key:t.id.toString(),...t}));s.z.object({from:R.z,type:s.z.string(),to:R.z});const oa=t=>{const[e,n,r]=t.split("->");return{from:new R(e),type:n,to:new R(r)}},hy=s.z.object({group:al}),dy=s.z.object({parent:ge,key:s.z.string().uuid().optional(),name:s.z.string()}),fy=s.z.object({key:s.z.string(),name:s.z.string()}),yy=s.z.object({keys:s.z.array(s.z.string())});var _e;let gy=(_e=class{constructor(t){l(this,"client"),this.client=t}async create(t,e,n){return(await v(this.client,_e.ENDPOINT,{parent:t,name:e,key:n},dy,hy)).group}async rename(t,e){await v(this.client,_e.ENDPOINT_RENAME,{key:t,name:e},fy,s.z.object({}))}async delete(t){await v(this.client,_e.ENDPOINT_DELETE,{keys:t},yy,s.z.object({}))}},l(_e,"ENDPOINT","/ontology/create-group"),l(_e,"ENDPOINT_RENAME","/ontology/rename-group"),l(_e,"ENDPOINT_DELETE","/ontology/delete-group"),_e),py=class{constructor(t){l(this,"creator"),this.creator=new gy(t)}async create(t,e,n){return this.sugar(await this.creator.create(t,e,n))}async rename(t,e){return await this.creator.rename(t,e)}async delete(...t){return await this.creator.delete(t)}sugar(t){return new il(t.name,t.key)}};const Lr={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},la=s.z.object({id:ge,children:ge.array()}),my=s.z.object({from:ge,to:ge,children:ge.array()});let wy=class{constructor(t){l(this,"client"),this.client=t}async addChildren(t,...e){await v(this.client,Lr.ADD_CHILDREN,{id:new R(t).payload,children:e.map(n=>new R(n).payload)},la,s.z.object({}))}async removeChildren(t,...e){await v(this.client,Lr.REMOVE_CHILDREN,{id:new R(t).payload,children:e.map(n=>new R(n).payload)},la,s.z.object({}))}async moveChildren(t,e,...n){const r={from:new R(t).payload,to:new R(e).payload,children:n.map(i=>new R(i).payload)};await v(this.client,Lr.MOVE_CHILDREN,r,my,s.z.object({}))}};const by="/ontology/retrieve",vy=s.z.object({ids:ge.array().optional(),children:s.z.boolean().optional(),parents:s.z.boolean().optional(),includeSchema:s.z.boolean().optional(),excludeFieldData:s.z.boolean().optional(),term:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),types:fr.array().optional()}),Oy=s.z.object({resources:uy.array()}),_r=t=>T(t).map(e=>new R(e).payload);let Ty=class{constructor(t,e){l(this,"type","ontology"),l(this,"groups"),l(this,"client"),l(this,"writer"),l(this,"framer"),this.client=t,this.writer=new wy(t),this.groups=new py(t),this.framer=e}async search(t,e){return await this.execRetrieve({term:t,...e})}async retrieve(t,e){const n=await this.execRetrieve({ids:_r(t),...e});if(Array.isArray(t))return n;if(n.length===0)throw new Oe(`No resource found with ID ${t.toString()}`);return n[0]}async page(t,e,n){return await this.execRetrieve({offset:t,limit:e,...n})}async retrieveChildren(t,e){return await this.execRetrieve({ids:_r(t),children:!0,...e})}async retrieveParents(t,e){return await this.execRetrieve({ids:_r(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,...n){return await this.writer.moveChildren(t,e,...n)}async openChangeTracker(){return await yr.open(this.framer,this)}async openDependentTracker(t){return await Ls.open(t,this.framer,this)}newSearcherWithOptions(t){return{type:this.type,search:e=>this.search(e,t),retrieve:e=>this.retrieve(e,t),page:(e,n)=>this.page(e,n,t)}}async execRetrieve(t){const{resources:e}=await v(this.client,by,t,vy,Oy);return e}};const ca="sy_ontology_resource_set",ua="sy_ontology_resource_delete",ha="sy_ontology_relationship_set",da="sy_ontology_relationship_delete";class yr{constructor(e,n){l(this,"relationships"),l(this,"resources"),l(this,"resourceObs"),l(this,"relationshipObs"),l(this,"streamer"),l(this,"client"),l(this,"closePromise"),this.relationshipObs=new Qe.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Qe.Observer,this.resources=this.resourceObs,this.client=n,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const n=await this.parseResourceSets(e),r=this.parseResourceDeletes(e);n.concat(r).length>0&&this.resourceObs.notify(n.concat(r));const i=this.parseRelationshipSets(e),a=this.parseRelationshipDeletes(e);i.concat(a).length>0&&this.relationshipObs.notify(i.concat(a))}parseRelationshipSets(e){const n=e.get(ha);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"set",key:oa(r),value:void 0}))}parseRelationshipDeletes(e){const n=e.get(da);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:oa(r)}))}async parseResourceSets(e){const n=e.get(ca);if(n.length===0)return[];const r=Array.from(n.as("string")).map(i=>new R(i));try{return(await this.client.retrieve(r)).map(i=>({variant:"set",key:i.id,value:i}))}catch(i){if(i instanceof Oe)return[];throw i}}parseResourceDeletes(e){const n=e.get(ua);return n.length===0?[]:Array.from(n.as("string")).map(r=>({variant:"delete",key:new R(r)}))}static async open(e,n){const r=await e.openStreamer([ca,ua,ha,da]);return new yr(r,n)}}const fa=t=>t==="from"?"to":"from";class Ls extends Qe.Observer{constructor({target:e,dependents:n,relationshipType:r="parent",relationshipDirection:i="from",resourceType:a},o,c){super(),l(this,"internal"),l(this,"target"),l(this,"relDir"),l(this,"resourceType"),l(this,"dependents"),l(this,"client"),l(this,"relType"),l(this,"handleResourceChange",u=>{this.dependents=this.dependents.map(h=>{const f=u.find(d=>d.key.toString()==h.id.toString());return f==null||f.variant==="delete"?h:f.value}),this.notify(this.dependents)}),l(this,"handleRelationshipChange",u=>{const h=u.filter(d=>d.variant==="delete"&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[fa(this.relDir)].type===this.resourceType));this.dependents=this.dependents.filter(d=>!h.some(k=>k.key.to.toString()===d.id.toString()&&k.key.type===this.relType));const f=u.filter(d=>d.variant==="set"&&d.key.type===this.relType&&d.key[this.relDir].toString()===this.target.toString()&&(this.resourceType==null||d.key[fa(this.relDir)].type===this.resourceType));if(f.length===0)return this.notify(this.dependents);this.client.retrieve(f.map(d=>d.key.to)).then(d=>{this.dependents=this.dependents.concat(d),this.notify(this.dependents)})}),this.resourceType=a,this.internal=o,this.target=e,this.dependents=n,this.resourceType!=null&&(this.dependents=this.dependents.filter(u=>u.id.type===this.resourceType)),this.client=c,this.relType=r,this.relDir=i,this.internal.resources.onChange(this.handleResourceChange),this.internal.relationships.onChange(this.handleRelationshipChange)}static async open(e,n,r){const i=await yr.open(n,r);return new Ls(e,i,r)}async close(){await this.internal.close()}}const me=t=>s.z.union([s.z.null().transform(()=>[]),t.array()]),gr=s.z.string().uuid(),Sy=s.z.object({key:gr.optional(),subjects:Ut.array().or(Ut),objects:Ut.array().or(Ut),actions:fs.array().or(fs)}),_s=s.z.object({key:gr,subjects:me(ge),objects:me(ge),actions:me(fs)}),zy="allow_all";new R({type:zy,key:""});const Ny=s.z.object({keys:gr.array().optional(),subjects:ge.array().optional()}),Iy=s.z.object({policies:me(_s)}),Ey="/access/policy/retrieve";let Ay=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await v(this.client,Ey,t,Ny,Iy)).policies}};const ky=s.z.object({policies:_s.partial({key:!0}).array()}),xy=s.z.object({policies:_s.array()}),Cy=s.z.object({keys:gr.array()}),$y=s.z.object({}),Ry="/access/policy/create",jy="/access/policy/delete";let By=class{constructor(t){l(this,"client"),this.client=t}async create(t){const e=Sy.array().parse(T(t)).map(n=>({objects:T(n.objects),actions:T(n.actions),subjects:T(n.subjects)}));return(await v(this.client,Ry,{policies:e},ky,xy)).policies}async delete(t){await v(this.client,jy,{keys:T(t)},Cy,$y)}},My=class{constructor(t){l(this,"retriever"),l(this,"writer"),this.retriever=new Ay(t),this.writer=new By(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve({keys:T(t)});return e?n:n[0]}async retrieveFor(t){const e=T(t).map(n=>new R(n).payload);return await this.retriever.retrieve({subjects:e})}async delete(t){await this.writer.delete(t)}},Dy=class{constructor(t){l(this,"policy"),this.policy=new My(t)}};const Ve=s.z.number(),on=s.z.object({name:s.z.string(),key:s.z.number(),rate:Kt.z,dataType:C.z,leaseholder:s.z.number(),index:s.z.number(),isIndex:s.z.boolean(),internal:s.z.boolean(),virtual:s.z.boolean(),alias:s.z.string().optional()}),ll=on.extend({key:s.z.number().optional(),leaseholder:s.z.number().optional(),index:s.z.number().optional(),rate:Kt.z.optional().default(0),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional().default(!1),virtual:s.z.boolean().optional().default(!1)}),cl="channel",Py=t=>new R({type:cl,key:t.toString()}),Uy=new Error("request for lock canceled");var Ly=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class _y{constructor(e,n=Uy){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=ul(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Ly(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Yy(this._weightedWaiters[e-1],{resolve:r,priority:n})})}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 n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function Yy(t,e){const n=ul(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function ul(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var qy=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Fy{constructor(e){this._semaphore=new _y(1,e)}acquire(){return qy(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}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 pr=(t,e,{convertNumericStrings:n=!0}={})=>{const r=!Array.isArray(t);let i=T(t);const a=i[0],o=typeof a;let c;return o==="string"&&n&&!isNaN(parseInt(a))&&"number"in e?(c=e.number,i=i.map(u=>parseInt(u))):c=e[o],{single:r,variant:c,normalized:i,actual:t}},mr=(t,e,n,r)=>{if(r){if(n.length===0)throw new ct(`${t} not found matching ${JSON.stringify(e)}`);if(n.length>1)throw new ut(`Expected one ${t} matching ${JSON.stringify(e)}, but found ${n.length}`)}},Vy=s.z.object({leaseholder:s.z.number().optional(),keys:s.z.number().array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),rangeKey:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),dataTypes:C.z.array().optional(),notDataTypes:C.z.array().optional(),virtual:s.z.boolean().optional(),isIndex:s.z.boolean().optional(),internal:s.z.boolean().optional()}),Wy=s.z.object({channels:me(on)}),De=t=>pr(t,{number:"keys",string:"names"}),hl=class dl{constructor(e){l(this,"client"),this.client=e}async search(e,n){return await this.execute({search:e,...n})}async retrieve(e,n){const r=De(e),{variant:i}=r;let{normalized:a}=r;return i==="keys"&&a.indexOf(0)!==-1&&(a=a.filter(o=>o!==0)),a.length===0?[]:await this.execute({[i]:a,...n})}async page(e,n,r){return await this.execute({offset:e,limit:n,...r})}async execute(e){const[n,r]=await this.client.send(dl.ENDPOINT,e,Vy,Wy);if(r!=null)throw r;return n.channels}};l(hl,"ENDPOINT","/channel/retrieve");let Ys=hl;class qs{constructor(e){l(this,"cache"),l(this,"namesToKeys"),l(this,"wrapped"),this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e,n){const{normalized:r}=pr(e,{string:"names",number:"keys"}),i=[],a=[];if(r.forEach(c=>{const u=this.get(c);u!=null?i.push(...u):a.push(c)}),a.length===0)return i;const o=await this.wrapped.retrieve(a,n);return this.set(o),i.concat(o)}delete(e){const{variant:n,normalized:r}=De(e);n==="names"?r.forEach(i=>{const a=this.namesToKeys.get(i);a!=null&&(a.forEach(o=>this.cache.delete(o)),this.namesToKeys.delete(i))}):r.forEach(i=>{const a=this.cache.get(i);a!=null&&(this.cache.delete(i),this.namesToKeys.delete(a.name))})}rename(e,n){e.forEach((r,i)=>{const a=n[i],o=this.cache.get(r);if(o==null)return;this.cache.delete(r);const c=this.namesToKeys.get(o.name);c!=null&&(c.delete(r),c.size===0&&this.namesToKeys.delete(o.name)),o.name=a,this.cache.set(r,o);const u=this.namesToKeys.get(a);u==null?this.namesToKeys.set(a,new Set([r])):u.add(r)})}set(e){e.forEach(n=>{this.cache.set(n.key,n);const r=this.namesToKeys.get(n.name);r==null?this.namesToKeys.set(n.name,new Set([n.key])):r.add(n.key)})}get(e){if(typeof e=="number"){const i=this.cache.get(e);return i==null?void 0:[i]}const n=this.namesToKeys.get(e);if(n==null)return;const r=[];if(n.forEach(i=>{const a=this.cache.get(i);a!=null&&r.push(a)}),r.length!==0)return r}}class fl{constructor(e,n){l(this,"mu",new Fy),l(this,"requests",new Map),l(this,"wrapped"),l(this,"debouncedRun"),this.wrapped=e,this.debouncedRun=bf(()=>{this.run()},n)}async search(e,n){return await this.wrapped.search(e,n)}async page(e,n,r){return await this.wrapped.page(e,n,r)}async retrieve(e){const{normalized:n,variant:r}=De(e);return r==="names"?await this.wrapped.retrieve(n):await new Promise((i,a)=>{this.mu.runExclusive(()=>{this.requests.set(n,{resolve:i,reject:a}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((n,r)=>r.forEach(i=>e.add(i)));try{const n=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((r,i)=>r.resolve(n.filter(a=>i.includes(a.key))))}catch(n){this.requests.forEach(r=>r.reject(n))}finally{this.requests.clear()}})}}const yl=async(t,e)=>{const{normalized:n}=De(e),r=await t.retrieve(n),i=[];if(n.forEach(a=>{r.find(o=>o.name===a||o.key===a)==null&&i.push(a)}),i.length>0)throw new Oe(`Could not find channels: ${JSON.stringify(i)}`);return r};class gl{constructor({dataType:e,rate:n,name:r,leaseholder:i=0,key:a=0,isIndex:o=!1,index:c=0,internal:u=!1,virtual:h=!1,frameClient:f,alias:d}){l(this,"_frameClient"),l(this,"key"),l(this,"name"),l(this,"rate"),l(this,"dataType"),l(this,"leaseholder"),l(this,"index"),l(this,"isIndex"),l(this,"internal"),l(this,"alias"),l(this,"virtual"),this.key=a,this.name=r,this.rate=new Kt(n??0),this.dataType=new C(e),this.leaseholder=i,this.index=c,this.isIndex=o,this.internal=u,this.alias=d,this.virtual=h,this._frameClient=f??null}get framer(){if(this._frameClient==null)throw new K("cannot read from a channel that has not been created");return this._frameClient}get payload(){return on.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex,internal:this.internal})}get ontologyID(){return new R({type:"channel",key:this.key.toString()})}async read(e){return await this.framer.read(e,this.key)}async write(e,n){return await this.framer.write(e,this.key,n)}}const Gy="/channel/retrieve-group",Zy=s.z.object({}),Ky=s.z.object({group:al});let pl=class{constructor(t,e,n,r){l(this,"type","channel"),l(this,"frameClient"),l(this,"client"),l(this,"retriever"),l(this,"writer"),this.frameClient=t,this.retriever=e,this.client=n,this.writer=r}async create(t,e={}){const{retrieveIfNameExists:n=!1}=e,r=!Array.isArray(t);let i=T(t),a=[];if(n){const o=await this.retriever.retrieve(i.map(u=>u.name)),c=new Set(o.map(u=>u.name));i=i.filter(u=>!c.has(u.name)),a=this.sugar(o)}return a=a.concat(this.sugar(await this.writer.create(i))),r?a[0]:a}async retrieve(t,e){const n=!Array.isArray(t),r=this.sugar(await this.retriever.retrieve(t,e));return mr("channel",t,r,n),n?r[0]:r}async search(t,e){return this.sugar(await this.retriever.search(t,e))}async delete(t){const{normalized:e,variant:n}=De(t);return n==="keys"?await this.writer.delete({keys:e}):await this.writer.delete({names:e})}async rename(t,e){return await this.writer.rename(T(t),T(e))}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}async page(t,e,n){return this.sugar(await this.retriever.page(t,e,n))}createDebouncedBatchRetriever(t=10){return new qs(new fl(new Ys(this.client),t))}sugar(t){const{frameClient:e}=this;return t.map(n=>new gl({...n,frameClient:e}))}async retrieveGroup(){const t=await v(this.client,Gy,{},Zy,Ky);return new il(t.group.name,t.group.key)}};const Jy=s.z.object({channels:ll.array()}),Hy=s.z.object({channels:on.array()}),Xy=s.z.object({keys:Ve.array().optional(),names:s.z.string().array().optional()}),Qy=s.z.object({}),eg=s.z.object({keys:Ve.array(),names:s.z.string().array()}),tg=s.z.object({}),ng="/channel/create",rg="/channel/delete",sg="/channel/rename";let ml=class{constructor(t,e){l(this,"client"),l(this,"cache"),this.client=t,this.cache=e}async create(t){const{channels:e}=await v(this.client,ng,{channels:t},Jy,Hy);return this.cache.set(e),e}async delete(t){await v(this.client,rg,t,Xy,Qy),t.keys!=null&&this.cache.delete(t.keys),t.names!=null&&this.cache.delete(t.names)}async rename(t,e){await v(this.client,sg,{keys:t,names:e},eg,tg),this.cache.rename(t,e)}};const ig=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:qs,Channel:gl,Client:pl,ClusterRetriever:Ys,DebouncedBatchRetriever:fl,ONTOLOGY_TYPE:cl,Writer:ml,analyzeChannelParams:De,keyZ:Ve,newPayload:ll,ontologyID:Py,payload:on,retrieveRequired:yl},Symbol.toStringTag,{value:"Module"})),ln=s.z.string().uuid(),wr=s.z.object({key:ln,username:s.z.string().min(1),firstName:s.z.string().default(""),lastName:s.z.string().default(""),rootUser:s.z.boolean().default(!0)}),ag=wr.partial({key:!0,firstName:!0,lastName:!0}).omit({rootUser:!0}).extend({password:s.z.string().min(1)}),og=s.z.object({keys:ln.array().optional(),usernames:s.z.string().array().optional()}),lg=s.z.object({users:me(wr)}),cg="/user/retrieve";let ug=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){return(await v(this.client,cg,t,og,lg)).users}};const hg=s.z.object({users:ag.array()}),dg=s.z.object({users:wr.array()}),fg=s.z.object({key:ln,username:s.z.string().min(1)}),yg=s.z.object({}),gg=s.z.object({key:ln,firstName:s.z.string().optional(),lastName:s.z.string().optional()}),pg=s.z.object({}),mg=s.z.object({keys:ln.array()}),wg=s.z.object({}),bg="/user/create",vg="/user/change-username",Og="/user/rename",Tg="/user/delete";let Sg=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await v(this.client,bg,{users:T(t)},hg,dg)).users}async changeUsername(t,e){await v(this.client,vg,{key:t,username:e},fg,yg)}async rename(t,e,n){await v(this.client,Og,{key:t,firstName:e,lastName:n},gg,pg)}async delete(t){await v(this.client,Tg,{keys:T(t)},mg,wg)}},zg=class{constructor(t){l(this,"reader"),l(this,"writer"),this.writer=new Sg(t),this.reader=new ug(t)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async changeUsername(t,e){await this.writer.changeUsername(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.reader.retrieve({keys:T(t)});if(e)return n;if(n.length===0)throw new ct(`No user with key ${t} found`);if(n.length>1)throw new ut(`Multiple users found with key ${t}`);return n[0]}async retrieveByName(t){const e=Array.isArray(t),n=await this.reader.retrieve({usernames:T(t)});if(e)return n;if(n.length===0)throw new ct(`No user with username ${t} found`);if(n.length>1)throw new ut(`Multiple users found with username ${t}`);return n[0]}async rename(t,e,n){await this.writer.rename(t,e,n)}async delete(t){await this.writer.delete(t)}};const Ng=s.z.object({username:s.z.string(),password:s.z.string()}),Ig=s.z.object({token:s.z.string(),user:wr}),ya="/auth/login",Eg=3,Ag="/auth/change-password",kg=s.z.object({username:s.z.string(),password:s.z.string(),newPassword:s.z.string().min(1)}),xg=s.z.object({});let Cg=class{constructor(t,e){l(this,"token"),l(this,"client"),l(this,"credentials"),l(this,"authenticating"),l(this,"authenticated"),l(this,"user"),l(this,"retryCount"),this.client=t,this.authenticated=!1,this.credentials=e,this.retryCount=0}async changePassword(t){if(!this.authenticated)throw new Error("Not authenticated");await v(this.client,Ag,{username:this.credentials.username,password:this.credentials.password,newPassword:t},kg,xg),this.credentials.password=t}middleware(){const t=async(e,n)=>{if(!this.authenticated&&!e.target.endsWith(ya)){this.authenticating??(this.authenticating=new Promise((o,c)=>{this.client.send(ya,this.credentials,Ng,Ig).then(([u,h])=>{if(h!=null)return o(h);this.token=u==null?void 0:u.token,this.user=u==null?void 0:u.user,this.authenticated=!0,o(null)}).catch(c)}));const a=await this.authenticating;if(a!=null)return[e,a]}e.params.Authorization=`Bearer ${this.token}`;const[r,i]=await n(e);return Os.matches(i)&&this.retryCount<Eg?(this.authenticated=!1,this.authenticating=void 0,this.retryCount+=1,t(e,n)):(this.retryCount=0,[r,i])};return t}};const $g=["disconnected","connecting","connected","failed"],Rg=s.z.enum($g),jg=s.z.object({status:Rg,error:s.z.instanceof(Error).optional(),message:s.z.string().optional(),clusterKey:s.z.string(),clientVersion:s.z.string(),clientServerCompatible:s.z.boolean(),nodeVersion:s.z.string().optional()}),Bg=s.z.object({clusterKey:s.z.string(),nodeVersion:s.z.string().optional()}),wl={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected",clientServerCompatible:!1,clientVersion:"0.34.0"},ga=(t,e,n)=>{const r=n?"cluster":"client";return`Synnax cluster node version ${t!=null?`${t} `:""}is too ${n?"old":"new"} for client version ${e}.
|
|
48
|
-
This may cause compatibility issues. We recommend updating the ${r}. For more information, see
|
|
49
|
-
https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${r}-version`},Jn=class bl{constructor(e,n=$.seconds(30),r,i){l(this,"_state"),l(this,"pollFrequency",$.seconds(30)),l(this,"client"),l(this,"name"),l(this,"interval"),l(this,"clientVersion"),l(this,"onChangeHandlers",[]),l(this,"versionWarned",!1),this._state={...wl},this.client=e,this.pollFrequency=n,this.clientVersion=r,this.name=i,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var e;const n=this._state.status;try{const[r,i]=await this.client.send(bl.ENDPOINT,{},s.z.object({}),Bg);if(i!=null)throw i;const a=r.nodeVersion,o=this.clientVersion,c=this.versionWarned;a==null?(this._state.clientServerCompatible=!1,c||(console.warn(ga(null,o,!0)),this.versionWarned=!0)):ra.versionsEqual(o,a,{checkMajor:!0,checkMinor:!0,checkPatch:!1})?this._state.clientServerCompatible=!0:(this._state.clientServerCompatible=!1,c||(console.warn(ga(a,o,ra.semVerNewer(o,a))),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=(e=this.state.error)==null?void 0:e.message}return this.onChangeHandlers.length>0&&n!==this._state.status&&this.onChangeHandlers.forEach(r=>r(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};l(Jn,"ENDPOINT","/connectivity/check"),l(Jn,"DEFAULT",wl),l(Jn,"connectionStateZ",jg);let vl=Jn;const Mg=s.z.object({keys:Ve.array().optional(),bounds:se.z,names:s.z.string().array().optional()}),Dg=s.z.object({}),Pg="/frame/delete";class Ug{constructor(e){l(this,"client"),this.client=e}async delete(e){await v(this.client,Pg,e,Mg,Dg)}}const pa=t=>{const e=T(t);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},ma=(t,e)=>{const n=T(t);if(n.length===e.length)return;const r=pa(t);throw pa===null?new K("[Frame] - channel keys or names must be provided when constructing a frame."):new K(`[Frame] - ${r}s and series must be the same length.
|
|
50
|
-
Got ${n.length} ${r}s and ${e.length} series.`)};let ve=class rt{constructor(e=[],n=[]){if(l(this,"columns",[]),l(this,"series",[]),e instanceof rt){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((r,i)=>this.push(i,...T(r)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const r=e;r.series??(r.series=[]),r.keys??(r.keys=[]);const i=r.series.map(a=>Lg(a));ma(r.keys,i),r.keys.forEach((a,o)=>this.push(a,i[o]))}else Object.entries(e).forEach(([r,i])=>{const a=parseInt(r);if(!isNaN(a))return this.push(a,...T(i));this.push(r,...T(i))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const r=T(n),i=T(e);ma(i,r),r.forEach((a,o)=>this.push(i[o],a));return}throw new K(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
|
|
51
|
-
payload, a list of lazy series, a lazy array, a map, or a record keyed by channel
|
|
52
|
-
name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new be("colType is not key");return this.columns??[]}get uniqueKeys(){return Ki(this.keys)}get names(){if(this.colType==="key")throw new be("colType is not name");return this.columns??[]}get uniqueNames(){return Ki(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>_g(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(n=>n.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return se.ZERO;const r=x.min(...this.series.map(a=>a.timeRange.start)),i=x.max(...this.series.map(a=>a.timeRange.end));return new se(r,i)}const n=this.get(e);return n==null?se.ZERO:n.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(n=>e.includes(n)):new Bf(this.series.filter((n,r)=>this.columns[r]===e))}push(e,...n){if(e instanceof rt){if(this.colType!==null&&e.colType!==this.colType)throw new K("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...n),typeof e=="string"&&this.colType==="key")throw new K("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new K("keyVariant must match");this.columns.push(...Array.from({length:n.length},()=>e))}}concat(e){return new rt([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const n=new rt;return this.forEach((r,i,a)=>n.push(...e(r,i,a))),n}forEach(e){this.columns.forEach((n,r)=>{const i=this.series[r];e(n,i,r)})}at(e,n=!1){const r={};return this.uniqueColumns.forEach(i=>{r[i]=this.get(i).at(e,n)}),r}filter(e){const n=new rt;return this.columns.forEach((r,i)=>{const a=this.series[i];e(r,a,i)&&n.push(r,a)}),n}get byteLength(){return new ot(this.series.reduce((e,n)=>e.add(n.byteLength),ot.ZERO))}get length(){return this.series.reduce((e,n)=>e+n.length,0)}};const Fs=s.z.object({keys:s.z.union([s.z.null().transform(()=>[]),s.z.number().array().optional().default([])]),series:s.z.union([s.z.null().transform(()=>[]),Ke.crudeZ.array().optional().default([])])}),Lg=t=>{const{dataType:e,data:n,timeRange:r,alignment:i}=t;return new Ke({data:n,dataType:e,timeRange:r,glBufferUsage:"static",alignment:i})},_g=t=>({timeRange:t._timeRange,dataType:t.dataType,data:new Uint8Array(t.data.buffer),alignment:t.alignment});class br{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new br(e);return await r.update(n),r}async update(e){const{variant:n,normalized:r}=De(e);if(n==="keys"){this.adapter=null,this.keys=r;return}const i=await this.retriever.retrieve(r),a=new Map;this.adapter=a,r.forEach(o=>{const c=i.find(u=>u.name===o);if(c==null)throw new Error(`Channel ${o} not found`);a.set(c.key,c.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const n=this.adapter;return e.map((r,i)=>{if(typeof r=="number"){const a=n.get(r);if(a==null)throw new Error(`Channel ${r} not found`);return[a,i]}return[r,i]})}}class Vs{constructor(e){l(this,"adapter"),l(this,"retriever"),l(this,"keys"),this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,n){const r=new Vs(e);return await r.update(n),r}async adaptObjectKeys(e){const n={};for(const[r,i]of Object.entries(e))n[await this.adaptToKey(r)]=i;return n}async update(e){const n=await yl(this.retriever,e);this.adapter=new Map(n.map(r=>[r.name,r.key])),this.keys=n.map(r=>r.key)}async fetchChannel(e){const n=await this.retriever.retrieve(e);if(n.length===0)throw new Error(`Channel ${e} not found`);return n[0]}async adaptToKey(e){return typeof e=="number"?e:(await this.fetchChannel(e)).key}async adapt(e,n){if(typeof e=="string"||typeof e=="number"){if(n==null)throw new K(`
|
|
53
|
-
Received a single channel name or key but no series.
|
|
54
|
-
`);if(Array.isArray(n)){if(n.some(u=>u instanceof Ke||Array.isArray(u)))throw new K(`
|
|
55
|
-
Received a single channel name or key but multiple series.
|
|
56
|
-
`);n=n}const o=await this.fetchChannel(e),c=new Ke({data:n,dataType:o.dataType});return new ve(o.key,c)}if(Array.isArray(e)){if(n==null)throw new K(`
|
|
57
|
-
Received an array of channel names or keys but no series.
|
|
58
|
-
`);if(!Array.isArray(n))throw new K(`
|
|
59
|
-
Received an array of channel names or keys but no array of series.
|
|
60
|
-
`);const o=[],c=[];for(let u=0;u<e.length;u++){const h=await this.fetchChannel(e[u]);if(u>=n.length)throw new K(`
|
|
61
|
-
Received an array of channel names or keys but not enough series.
|
|
62
|
-
`);const f=new Ke({data:n[u],dataType:h.dataType});o.push(h.key),c.push(f)}return new ve(o,c)}if(e instanceof ve||e instanceof Map){const o=new ve(e);if(this.adapter==null)return o;const c=o.columns.map(u=>{var h;const f=typeof u=="string"?(h=this.adapter)==null?void 0:h.get(u):u;if(f==null)throw new K(`
|
|
63
|
-
Channel ${u} was not provided in the list of channels when opening the writer
|
|
64
|
-
`);return f});return new ve(c,o.series)}const r=[],i=[],a=Object.entries(e);for(let o=0;o<a.length;o++){const[c,u]=a[o],h=await this.fetchChannel(c),f=new Ke({data:u,dataType:h.dataType});r.push(h.key),i.push(f)}return new ve(r,i)}}class Ws{constructor(e,n){l(this,"name"),l(this,"stream"),this.stream=n,this.name=e}async receive(){const[e,n]=await this.stream.receive();if(n!=null)throw n;return e}received(){return this.stream.received()}async closeAndAck(){for(this.stream.closeSend();;){const[e,n]=await this.stream.receive();if(e!=null&&console.warn(`${this.name} received unexpected response on closure.
|
|
65
|
-
Please report this error to the Synnax team. ${JSON.stringify(e)}`),n!=null){if(qe.matches(n))return;throw n}}}closeSend(){this.stream.closeSend()}send(e){const n=this.stream.send(e);if(n!=null)throw n}}const wa=new $(-1);var Gs=(t=>(t[t.Open=0]="Open",t[t.Next=1]="Next",t[t.Prev=2]="Prev",t[t.SeekFirst=3]="SeekFirst",t[t.SeekLast=4]="SeekLast",t[t.SeekLE=5]="SeekLE",t[t.SeekGE=6]="SeekGE",t[t.Valid=7]="Valid",t[t.Error=8]="Error",t))(Gs||{}),Ol=(t=>(t[t.None=0]="None",t[t.Ack=1]="Ack",t[t.Data=2]="Data",t))(Ol||{});const Yg=s.z.object({command:s.z.nativeEnum(Gs),span:$.z.optional(),bounds:se.z.optional(),stamp:x.z.optional(),keys:s.z.number().array().optional(),chunkSize:s.z.number().optional()}),qg=s.z.object({variant:s.z.nativeEnum(Ol),ack:s.z.boolean(),command:s.z.nativeEnum(Gs),error:sn.optional().nullable(),frame:Fs.optional()}),Tl=class Ts{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"value"),this.stream=new Ws("Iterator",e),this.value=new ve,this.adapter=n}static async _open(e,n,r,i,a={}){const o=await br.open(r,n),c=await i.stream(Ts.ENDPOINT,Yg,qg),u=new Ts(c,o);return await u.execute({command:0,keys:o.keys,bounds:new se(e),chunkSize:a.chunkSize??1e5}),u}async next(e=wa){return await this.execute({command:1,span:new $(e)})}async prev(e=wa){return await this.execute({command:2,span:new $(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new x(e)})}async seekGE(e){return await this.execute({command:6,stamp:new x(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Vg(this)}async execute(e){for(this.stream.send(e),this.value=new ve;;){const n=await this.stream.receive();if(n.variant===1)return n.ack;this.value.push(this.adapter.adapt(new ve(n.frame)))}}};l(Tl,"ENDPOINT","/frame/iterate");let Fg=Tl;class Vg{constructor(e){l(this,"iter"),l(this,"open",!1),this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Wg=s.z.object({keys:s.z.number().array(),downsampleFactor:s.z.number()}),Gg=s.z.object({frame:Fs,error:sn.optional().nullable()}),Zg="/frame/stream";class Zs{constructor(e,n){l(this,"stream"),l(this,"adapter"),l(this,"downsampleFactor"),this.stream=new Ws("Streamer",e),this.adapter=n,this.downsampleFactor=1}get keys(){return this.adapter.keys}static async _open(e,n,{channels:r,downsampleFactor:i}){const a=await br.open(e,r),o=await n.stream(Zg,Wg,Gg),c=new Zs(o,a);o.send({keys:a.keys,downsampleFactor:i??1});const[,u]=await o.receive();if(u!=null)throw u;return c}async next(){try{return{done:!1,value:await this.read()}}catch(e){if(qe.matches(e))return{done:!0,value:void 0};throw e}}async read(){return this.adapter.adapt(new ve((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys,downsampleFactor:this.downsampleFactor})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}class vr extends Qe.Observer{constructor(e,n){super(n),l(this,"streamer"),l(this,"closePromise"),this.streamer=e,this.closePromise=this.stream()}async close(){this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer)this.notify(e)}}var Ks=(t=>(t[t.Open=0]="Open",t[t.Write=1]="Write",t[t.Commit=2]="Commit",t[t.Error=3]="Error",t[t.SetAuthority=4]="SetAuthority",t))(Ks||{}),Jt=(t=>(t[t.PersistStream=1]="PersistStream",t[t.Persist=2]="Persist",t[t.Stream=3]="Stream",t))(Jt||{});const Kg=t=>{switch(t){case"persist":return 2;case"stream":return 3;case"persistStream":return 1;default:if(typeof t=="number"&&t in Jt)return t;throw new Error(`invalid writer mode: ${t}`)}};new $(-1);const Jg=s.z.object({start:x.z.optional(),controlSubject:lt.subjectZ.optional(),keys:s.z.number().array().optional(),authorities:lt.Authority.z.array().optional(),mode:s.z.nativeEnum(Jt).optional(),errOnUnauthorized:s.z.boolean().optional(),enableAutoCommit:s.z.boolean().optional(),autoIndexPersistInterval:$.z.optional()}),Hg=s.z.object({command:s.z.nativeEnum(Ks),config:Jg.optional(),frame:Fs.optional()}),Xg=s.z.object({ack:s.z.boolean(),command:s.z.nativeEnum(Ks),error:sn.optional().nullable()});var vt;let Qg=(vt=class{constructor(t,e){l(this,"stream"),l(this,"adapter"),this.stream=new Ws("Writer",t),this.adapter=e}static async _open(t,e,{channels:n,start:r=x.now(),authorities:i=lt.Authority.Absolute,controlSubject:a,mode:o=1,errOnUnauthorized:c=!1,enableAutoCommit:u=!1,autoIndexPersistInterval:h=$.SECOND}){const f=await Vs.open(t,n),d=await e.stream(vt.ENDPOINT,Hg,Xg),k=new vt(d,f);return await k.execute({command:0,config:{start:new x(r),keys:f.keys,controlSubject:a,authorities:T(i),mode:Kg(o),errOnUnauthorized:c,enableAutoCommit:u,autoIndexPersistInterval:h}}),k}async write(t,e){const n=await this.adapter.adapt(t,e);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(t,e){let n;if(typeof t=="number"&&e==null)n={keys:[],authorities:[t]};else{let r;typeof t=="string"||typeof t=="number"?r={[t]:e}:r=t,r=await this.adapter.adaptObjectKeys(r),n={keys:Object.keys(r).map(i=>Number(i)),authorities:Object.values(r)}}return(await this.execute({command:4,config:n})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const t=await this.execute({command:3});return t.error!=null?Ds(t.error):null}async close(){await this.stream.closeAndAck()}async execute(t){for(this.stream.send(t);;){const e=await this.stream.receive();if(e.command===t.command)return e;console.warn("writer received unexpected response",e)}}get errorAccumulated(){return this.stream.received()}},l(vt,"ENDPOINT","/frame/write"),vt),ep=class{constructor(t,e,n){l(this,"streamClient"),l(this,"retriever"),l(this,"deleter"),this.streamClient=t,this.retriever=n,this.deleter=new Ug(e)}async openIterator(t,e,n){return await Fg._open(t,e,this.retriever,this.streamClient,n)}async openWriter(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t}),await Qg._open(this.retriever,this.streamClient,t)}async openStreamer(t){return(Array.isArray(t)||typeof t!="object")&&(t={channels:t,downsampleFactor:1}),await Zs._open(this.retriever,this.streamClient,t)}async write(t,e,n){if(n==null){const i=e,a=await this.openWriter({start:t,channels:Object.keys(i),mode:Jt.Persist});try{await a.write(i),await a.commit()}finally{await a.close()}return}const r=await this.openWriter({start:t,channels:e,mode:Jt.Persist,errOnUnauthorized:!0,enableAutoCommit:!0,autoIndexPersistInterval:$.MAX});try{await r.write(e,n)}finally{await r.close()}}async read(t,e){const{single:n}=De(e),r=await this.readFrame(t,e);return n?r.get(e):r}async readFrame(t,e){const n=await this.openIterator(t,e),r=new ve;try{for await(const i of n)r.push(i)}finally{await n.close()}return r}async delete(t,e){const{normalized:n,variant:r}=De(t);return r==="keys"?await this.deleter.delete({keys:n,bounds:e}):await this.deleter.delete({names:n,bounds:e})}};const tp=lt.Authority,np=lt.stateZ(s.z.number()),rp=t=>{var e,n;return t.to==null?`${(e=t.from)==null?void 0:e.resource} - ${(n=t.from)==null?void 0:n.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()})`};class Sl extends vr{constructor(e){super(e,n=>{const r=this.codec.decode(n.series[0].data);return this.merge(r),[r.transfers,!0]}),l(this,"states"),l(this,"codec"),this.states=new Map,this.codec=new dt.JSONCodec}subjects(){const e=new Map;return this.states.forEach(n=>e.set(n.subject.key,n.subject)),Array.from(e.values())}merge(e){e.transfers.forEach(n=>{n.from==null&&n.to==null&&console.warn("Invalid transfer: ",n),n.to==null?this.states.delete(n.from.resource):this.states.set(n.to.resource,n.to)})}}const sp="sy_node_1_control";let zl=class{constructor(t){l(this,"framer"),this.framer=t}async openStateTracker(){const t=await this.framer.openStreamer(sp);return new Sl(t)}};const ip=Object.freeze(Object.defineProperty({__proto__:null,Authority:tp,Client:zl,StateTracker:Sl,stateZ:np,transferString:rp},Symbol.toStringTag,{value:"Module"}));let ap=class{constructor(t,e,n){l(this,"tasks"),l(this,"racks"),l(this,"devices"),this.tasks=t,this.racks=e,this.devices=n}};const cn=s.z.number(),Js=s.z.object({key:cn,name:s.z.string()}),op=Js.partial({key:!0}),Hs=s.z.string(),Or=s.z.object({key:Hs,rack:cn,name:s.z.string(),make:s.z.string(),model:s.z.string(),location:s.z.string(),configured:s.z.boolean().optional(),properties:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:dt.JSON_CODEC.decodeString(t)))}),lp=Or.extend({properties:s.z.unknown().transform(t=>dt.JSON_CODEC.encodeString(t))}),yt=async(t,e,n,r)=>{const i=await t.openStreamer([e,n]),a=o=>{const c=[];return n!=null&&c.push(...o.get(n).series.flatMap(u=>r("delete",u))),e!=null&&c.push(...o.get(e).series.flatMap(u=>r("set",u))),[c,c.length>0]};return new vr(i,a)},cp="sy_device_set",up="sy_device_delete",Yr="/hardware/device/retrieve",hp="/hardware/device/create",dp="/hardware/device/delete",fp=s.z.object({devices:lp.array()}),yp=s.z.object({devices:Or.array()}),gp=s.z.object({keys:Hs.array()}),pp=s.z.object({}),qr=s.z.object({search:s.z.string().optional(),limit:s.z.number().optional(),offset:s.z.number().optional(),keys:Hs.array().optional(),names:s.z.string().array().optional(),makes:s.z.string().array().optional()}),Fr=s.z.object({devices:me(Or)});let mp=class{constructor(t,e){l(this,"type","device"),l(this,"client"),l(this,"frameClient"),this.client=t,this.frameClient=e}async retrieve(t,e){const n=!Array.isArray(t),r=await v(this.client,Yr,{keys:T(t),...e},qr,Fr);return mr("Device",t,r.devices,n),n?r.devices[0]:r.devices}async search(t,e){return(await v(this.client,Yr,{search:t,...e},qr,Fr)).devices}async page(t,e,n){return(await v(this.client,Yr,{offset:t,limit:e,...n},qr,Fr)).devices}async create(t){const e=!Array.isArray(t),n=await v(this.client,hp,{devices:T(t)},fp,yp);return e?n.devices[0]:n.devices}async delete(t){await v(this.client,dp,{keys:T(t)},gp,pp)}async openDeviceTracker(){return await yt(this.frameClient,cp,up,wp)}newSearcherWithOptions(t){return{type:this.type,search:async e=>await this.search(e,t),retrieve:async e=>await this.retrieve(e,t),page:async(e,n)=>await this.page(e,n,t)}}};const wp=(t,e)=>t==="delete"?e.toStrings().map(n=>({variant:t,key:n,value:void 0})):e.parseJSON(Or).map(n=>({variant:t,key:n.key,value:n})),Vr="/hardware/rack/retrieve",bp="/hardware/rack/create",vp="/hardware/rack/delete",Wr=s.z.object({keys:cn.array().optional(),names:s.z.string().array().optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),Gr=s.z.object({racks:me(Js)}),Op=s.z.object({racks:op.array()}),Tp=s.z.object({racks:Js.array()}),Sp=s.z.object({keys:cn.array()}),zp=s.z.object({});let Np=class{constructor(t,e,n){l(this,"type","rack"),l(this,"client"),l(this,"frameClient"),l(this,"tasks"),this.client=t,this.frameClient=e,this.tasks=n}async delete(t){await v(this.client,vp,{keys:T(t)},Sp,zp)}async create(t){const e=!Array.isArray(t),n=await v(this.client,bp,{racks:T(t)},Op,Tp),r=this.sugar(n.racks);return e?r[0]:r}async search(t){const e=await v(this.client,Vr,{search:t},Wr,Gr);return this.sugar(e.racks)}async page(t,e){const n=await v(this.client,Vr,{offset:t,limit:e},Wr,Gr);return this.sugar(n.racks)}async retrieve(t){const{variant:e,normalized:n,single:r}=pr(t,{string:"names",number:"keys"}),i=await v(this.client,Vr,{[e]:n},Wr,Gr),a=this.sugar(i.racks);return mr("Rack",t,a,r),r?a[0]:a}sugar(t){return t.map(({key:e,name:n})=>new Ip(e,n,this.tasks))}};class Ip{constructor(e,n,r){l(this,"key"),l(this,"name"),l(this,"tasks"),this.key=e,this.name=n,this.tasks=r}async listTasks(){return await this.tasks.retrieve(this.key)}async retrieveTaskByName(e){return await this.tasks.retrieveByName(e,this.key)}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),await this.tasks.create(e)}async deleteTask(e){await this.tasks.delete([e])}}const gt=s.z.union([s.z.string(),s.z.bigint().transform(t=>t.toString()),s.z.number().transform(t=>t.toString())]),sr=s.z.object({task:gt,variant:s.z.string(),key:s.z.string().optional(),details:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t))).or(s.z.array(s.z.unknown())).or(s.z.null())}),Tr=s.z.object({key:gt,name:s.z.string(),type:s.z.string(),internal:s.z.boolean().optional(),config:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:dt.JSON_CODEC.decodeString(t))),state:sr.optional().nullable(),snapshot:s.z.boolean().optional()}),Ep=Tr.omit({key:!0}).extend({key:gt.transform(t=>t.toString()).optional(),config:s.z.unknown().transform(t=>dt.JSON_CODEC.encodeString(t))});s.z.object({task:gt,type:s.z.string(),key:s.z.string(),args:s.z.record(s.z.unknown()).or(s.z.string().transform(t=>t===""?{}:JSON.parse(t)))});const Wt="sy_task_state",ba="sy_task_cmd",mn=new Error("Task not created");class Ap{constructor(e,n,r,i,a=!1,o=!1,c,u=null,h=null,f=null){l(this,"key"),l(this,"name"),l(this,"internal"),l(this,"type"),l(this,"config"),l(this,"snapshot"),l(this,"state"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=e,this.name=n,this.type=r,this.config=i,this.internal=a,this.snapshot=o,c!==null&&(this.state=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,state:this.state,internal:this.internal}}get ontologyID(){return new R({type:"task",key:this.key})}async executeCommand(e,n){if(this.frameClient==null)throw mn;const r=await this.frameClient.openWriter(ba),i=If.id();return await r.write(ba,[{task:this.key,type:e,key:i,args:n}]),await r.close(),i}async executeCommandSync(e,n,r){if(this.frameClient==null)throw mn;const i=await this.frameClient.openStreamer(Wt),a=await this.executeCommand(e,n);let o;const c=new Promise(u=>setTimeout(()=>u(!1),new $(r).milliseconds));for(;;){const u=await Promise.any([i.read(),c]);if(u===!1)throw new Error("Command timed out");const h=sr.safeParse(u.at(-1).sy_task_state);if(h.success){if(o=h.data,o.key===a)break}else console.error(h.error)}return i.close(),o}async openStateObserver(){if(this.frameClient==null)throw mn;return new vr(await this.frameClient.openStreamer(Wt),e=>{const n=e.get(Wt);if(n.length===0)return[null,!1];const r=sr.safeParse(n.at(-1));if(!r.success)return[null,!1];const i=r.data;return i.task!==this.key?[null,!1]:[i,!0]})}async snapshottedTo(){if(this.ontologyClient==null||this.rangeClient==null)throw mn;if(!this.snapshot)return null;const e=await this.ontologyClient.retrieveParents(this.ontologyID);return e.length==0?null:e[0]}}const kp=s.z.object({rack:cn.optional(),keys:s.z.string().array().optional(),names:s.z.string().array().optional(),offset:s.z.number().optional(),limit:s.z.number().optional(),includeState:s.z.boolean().optional()}),xp=s.z.object({tasks:me(Tr)}),Cp="/hardware/task/retrieve",$p="/hardware/task/create",Rp="/hardware/task/delete",jp="/hardware/task/copy",Bp=s.z.object({tasks:Ep.array()}),Mp=s.z.object({tasks:Tr.array()}),Dp=s.z.object({keys:gt.array()}),Pp=s.z.object({}),Up=s.z.object({key:gt,name:s.z.string(),snapshot:s.z.boolean()}),Lp=s.z.object({task:Tr});let _p=class{constructor(t,e,n,r){l(this,"type","task"),l(this,"client"),l(this,"frameClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.client=t,this.frameClient=e,this.ontologyClient=n,this.rangeClient=r}async create(t){const e=!Array.isArray(t),n=await v(this.client,$p,{tasks:T(t)},Bp,Mp),r=this.sugar(n.tasks);return e?r[0]:r}async delete(t){await v(this.client,Rp,{keys:T(t)},Dp,Pp)}async search(t){return await this.execRetrieve({keys:[t]})}async page(t,e){return await this.execRetrieve({offset:t,limit:e})}async list(t={}){return this.sugar(await this.execRetrieve(t))}async retrieve(t,e){const{single:n,normalized:r,variant:i}=pr(t,{number:"rack",string:"keys"},{convertNumericStrings:!1}),a={...e};i==="rack"?a.rack=t:a.keys=r;const o=await this.execRetrieve(a),c=this.sugar(o);return n&&i!=="rack"?c[0]:c}async copy(t,e,n){const r=await v(this.client,jp,{key:t,name:e,snapshot:n},Up,Lp);return this.sugar([r.task])[0]}async retrieveByName(t,e){const n=await this.execRetrieve({names:[t],rack:e});return mr("Task",t,n,!0),this.sugar(n)[0]}async execRetrieve(t){return(await v(this.client,Cp,t,kp,xp)).tasks}sugar(t){return t.map(({key:e,name:n,type:r,config:i,state:a,internal:o,snapshot:c})=>new Ap(e,n,r,i,o,c,a,this.frameClient,this.ontologyClient,this.rangeClient))}async openTracker(){return await yt(this.frameClient,"sy_task_set","sy_task_delete",(t,e)=>Array.from(e).map(n=>({variant:t,key:n.toString(),value:n.toString()})))}async openStateObserver(){return new vr(await this.frameClient.openStreamer(Wt),t=>{const e=t.get(Wt);if(e.length===0)return[null,!1];const n=sr.safeParse(e.at(-1));return n.success?[n.data,!0]:[null,!1]})}};const un=s.z.string().uuid(),Sr=s.z.object({key:un,name:s.z.string().min(1),color:s.z.string()}),Yp=s.z.object({keys:un.array().optional(),for:ge.optional(),search:s.z.string().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),qp=s.z.object({labels:me(Sr)});var wn;let Fp=(wn=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){const e=T(t);return await this.execute({keys:e})}async retrieveFor(t){return await this.execute({for:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){const[e,n]=await this.client.send(wn.ENDPOINT,t,Yp,qp);if(n!=null)throw n;return e.labels}},l(wn,"ENDPOINT","/label/retrieve"),wn);const Vp=Sr.extend({key:un.optional()}),Wp=s.z.object({labels:Vp.array()}),Gp=s.z.object({labels:Sr.array()}),Zp=s.z.object({keys:un.array()}),Nl=s.z.object({id:ge,labels:un.array(),replace:s.z.boolean().optional()}),Kp=Nl.omit({replace:!0}),Zr=s.z.object({}),Jp="/label/create",Hp="/label/delete",Xp="/label/set",Qp="/label/remove";let em=class{constructor(t){l(this,"client"),this.client=t}async create(t){return(await v(this.client,Jp,{labels:T(t)},Wp,Gp)).labels}async delete(t){await v(this.client,Hp,{keys:T(t)},Zp,Zr)}async set(t,e,{replace:n}={}){await v(this.client,Xp,{id:t,labels:e,replace:n},Nl,Zr)}async remove(t,e){await v(this.client,Qp,{id:t,labels:e},Kp,Zr)}};const tm="sy_label_set",nm="sy_label_delete";let rm=class{constructor(t,e,n){l(this,"type","label"),l(this,"retriever"),l(this,"writer"),l(this,"frameClient"),l(this,"ontology"),this.writer=new em(t),this.retriever=new Fp(t),this.frameClient=e,this.ontology=n}async search(t){return await this.retriever.search(t)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async retrieveFor(t){return await this.retriever.retrieveFor(new R(t))}async label(t,e,n={}){await this.writer.set(new R(t),e,n)}async removeLabels(t,e){await this.writer.remove(new R(t),e)}async page(t,e){return await this.retriever.page(t,e)}async create(t){const e=Array.isArray(t),n=await this.writer.create(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}async openChangeTracker(){return await yt(this.frameClient,tm,nm,sm)}async trackLabelsOf(t){const e=new Qe.Observer,n=(await this.retrieveFor(t)).map(r=>({id:new R({key:r.key,type:"label"}),key:r.key,name:r.name,data:r}));return(await this.ontology.openDependentTracker({target:new R(t),dependents:n,relationshipType:"labeled_by"})).onChange(r=>e.notify(r.map(i=>{var a,o;return{key:i.id.key,color:(a=i.data)==null?void 0:a.color,name:(o=i.data)==null?void 0:o.name}}))),e}};const sm=(t,e)=>t==="delete"?e.toUUIDs().map(n=>({variant:t,key:n})):e.parseJSON(Sr).map(n=>({variant:t,key:n.key,value:n})),ye=s.z.string().uuid(),hn=s.z.object({key:ye,name:s.z.string().min(1),timeRange:se.z,color:s.z.string().optional()}),Il=hn.extend({key:s.z.string().uuid().optional()}),El=t=>{const e=T(t),n=e.length===0;let r=!1;return n||(r=ye.safeParse(e[0]).success),{single:!Array.isArray(t),variant:r?"keys":"names",normalized:e,actual:t,empty:n}},Al="range",kl="range-alias",im=t=>new R({type:Al,key:t}),am=t=>new R({type:kl,key:t}),om="sy_range_alias_set",lm="sy_range_alias_delete",cm=s.z.object({range:ye,aliases:s.z.string().array()}),um=s.z.object({aliases:s.z.record(s.z.string(),Ve)}),hm=s.z.object({range:ye,aliases:s.z.record(Ve.or(s.z.string()),s.z.string())}),dm=s.z.unknown(),fm=s.z.object({range:ye,channels:Ve.array()}),ym=s.z.unknown(),gm=s.z.object({range:ye}),pm=s.z.object({aliases:s.z.record(s.z.string(),s.z.string())}),Lt=class _t{constructor(e,n,r){l(this,"frameClient"),l(this,"cache",new Map),l(this,"client"),l(this,"rangeKey"),this.rangeKey=e,this.cache=new Map,this.client=r,this.frameClient=n}async resolve(e){const n=[],r=typeof e=="string",i={};if(r){const o=this.cache.get(e);if(o!=null)return o;n.push(e)}else e.forEach(o=>{const c=this.cache.get(o);c!=null?i[o]=c:n.push(o)});if(n.length===0)return i;const a=await v(this.client,_t.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:n},cm,um);return Object.entries(a.aliases).forEach(([o,c])=>this.cache.set(o,c)),r?a.aliases[n[0]]:{...i,...a.aliases}}async set(e){await v(this.client,_t.SET_ENDPOINT,{range:this.rangeKey,aliases:e},hm,dm)}async list(){return(await v(this.client,_t.LIST_ENDPOINT,{range:this.rangeKey},gm,pm)).aliases}async delete(e){await v(this.client,_t.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},fm,ym)}async openChangeTracker(){return await yt(this.frameClient,om,lm,vm(this.rangeKey))}};l(Lt,"SET_ENDPOINT","/range/alias/set"),l(Lt,"RESOLVE_ENDPOINT","/range/alias/resolve"),l(Lt,"LIST_ENDPOINT","/range/alias/list"),l(Lt,"DELETE_ENDPOINT","/range/alias/delete");let mm=Lt;const wm=s.z.object({range:ye,channel:Ve,alias:s.z.string()}),bm="---",vm=t=>(e,n)=>e==="delete"?n.toStrings().filter(r=>r.split(bm)[0]===t).map(r=>({variant:e,key:r,value:void 0})):n.parseJSON(wm).map(r=>({variant:e,key:r.alias,value:r})),Om=s.z.object({range:ye,keys:s.z.string().array()}),Xs=s.z.object({range:ye,key:s.z.string(),value:s.z.string()}),Tm=s.z.object({pairs:me(Xs)}),Sm=s.z.object({range:ye,pairs:Xs.array()}),zm=s.z.object({range:ye,keys:s.z.string().array()}),Hn=class Xn{constructor(e,n,r){l(this,"rangeKey"),l(this,"client"),l(this,"frameClient"),this.rangeKey=e,this.client=n,this.frameClient=r}async get(e){const n=await v(this.client,Xn.GET_ENDPOINT,{range:this.rangeKey,keys:T(e)},Om,Tm);return typeof e=="string"?n.pairs[0].value:Object.fromEntries(n.pairs.map(r=>[r.key,r.value]))}async list(){return this.get([])}async set(e,n=""){let r;Ps(e)?r=Object.entries(e).map(([i,a])=>({range:this.rangeKey,key:i,value:a})):r=[{range:this.rangeKey,key:e,value:n}],await v(this.client,Xn.SET_ENDPOINT,{range:this.rangeKey,pairs:r},Sm,s.z.unknown())}async delete(e){await v(this.client,Xn.DELETE_ENDPOINT,{range:this.rangeKey,keys:T(e)},zm,s.z.unknown())}async openTracker(){return await yt(this.frameClient,"sy_range_kv_set","sy_range_kv_delete",(e,n)=>e==="delete"?n.toStrings().map(r=>{const[i,a]=r.split("<--->",2);return{variant:e,key:r,value:{range:i,key:a,value:""}}}):n.parseJSON(Xs).map(r=>({variant:e,key:`${r.range}${r.key}`,value:r})))}};l(Hn,"GET_ENDPOINT","/range/kv/get"),l(Hn,"SET_ENDPOINT","/range/kv/set"),l(Hn,"DELETE_ENDPOINT","/range/kv/delete");let Ss=Hn;const Kr=t=>new R({type:"range",key:t});class xl{constructor(e,n=se.ZERO,r,i,a,o,c,u,h,f,d){l(this,"key"),l(this,"name"),l(this,"kv"),l(this,"timeRange"),l(this,"color"),l(this,"channels"),l(this,"aliaser"),l(this,"frameClient"),l(this,"labelClient"),l(this,"ontologyClient"),l(this,"rangeClient"),this.key=r,this.name=e,this.timeRange=n,this.frameClient=a,this.color=i,this.kv=o,this.aliaser=c,this.channels=u,this.labelClient=h,this.ontologyClient=f,this.rangeClient=d}get ontologyID(){return new R({key:this.key,type:"range"})}get payload(){return{key:this.key,name:this.name,timeRange:this.timeRange,color:this.color}}async setAlias(e,n){const r=await this.channels.retrieve(e);if(r.length===0)throw new Oe(`Channel ${e} does not exist`);await this.aliaser.set({[r[0].key]:n})}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 openAliasTracker(){return await this.aliaser.openChangeTracker()}async retrieveParent(){return this.rangeClient.retrieveParent(this.key)}async retrieveChildren(){const e=(await this.ontologyClient.retrieveChildren(this.ontologyID,{excludeFieldData:!0,types:["range"]})).map(n=>n.id.key);return await this.rangeClient.retrieve(e)}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Kr(this.key))}async addLabel(...e){await this.labelClient.label(Kr(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Kr(this.key),e)}async openChildRangeTracker(){const e=new Qe.Observer,n=(await this.retrieveChildren()).map(i=>{const a=new R({key:i.key,type:"range"});return{id:a,key:a.toString(),name:i.name,data:i.payload}}),r=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:n,resourceType:"range"});return r.onChange(i=>e.notify(this.rangeClient.resourcesToRanges(i))),e.setCloser(async()=>await r.close()),e}async openParentRangeTracker(){const e=new Qe.Observer,n=await this.retrieveParent();if(n==null)return null;const r=new R({key:n.key,type:"range"}),i={id:r,key:r.toString(),name:n.name,data:n.payload},a=await this.ontologyClient.openDependentTracker({target:this.ontologyID,dependents:[i],relationshipDirection:"to"});return a.onChange(o=>{const c=this.rangeClient.resourcesToRanges(o);if(c.length===0)return;const u=c[0];e.notify(u)}),e.setCloser(async()=>await a.close()),e}}const Nm=s.z.object({keys:ye.array().optional(),names:s.z.array(s.z.string()).optional(),term:s.z.string().optional(),overlapsWith:se.z.optional(),limit:s.z.number().int().optional(),offset:s.z.number().int().optional()}),Im="/range/retrieve",Em=s.z.object({ranges:me(hn)});let Cl=class{constructor(t,e,n,r,i,a){l(this,"type","range"),l(this,"frameClient"),l(this,"writer"),l(this,"unaryClient"),l(this,"channels"),l(this,"labelClient"),l(this,"ontologyClient"),this.frameClient=t,this.writer=e,this.unaryClient=n,this.channels=r,this.labelClient=i,this.ontologyClient=a}async create(t,e){const n=!Array.isArray(t),r=this.sugarMany(await this.writer.create(T(t),e));return n?r[0]:r}async rename(t,e){await this.writer.rename(t,e)}async delete(t){await this.writer.delete(T(t))}async search(t){return this.sugarMany(await this.execRetrieve({term:t}))}async page(t,e){return this.sugarMany(await this.execRetrieve({offset:t,limit:e}))}async retrieve(t){if(typeof t=="object"&&"start"in t)return await this.execRetrieve({overlapsWith:new se(t)});const{single:e,actual:n,variant:r,normalized:i,empty:a}=El(t);if(a)return[];const o=await this.execRetrieve({[r]:i});if(!e)return o;if(o.length===0)throw new ct(`range matching ${n} not found`);if(o.length>1)throw new ut(`multiple ranges matching ${n} found`);return o[0]}getKV(t){return new Ss(t,this.unaryClient,this.frameClient)}async execRetrieve(t){const{ranges:e}=await v(this.unaryClient,Im,t,Nm,Em);return this.sugarMany(e)}async retrieveParent(t){const e=await this.ontologyClient.retrieveParents({key:t,type:"range"});if(e.length===0)return null;const n=e[0];return n.id.type!=="range"?null:await this.retrieve(n.id.key)}sugarOne(t){return new xl(t.name,t.timeRange,t.key,t.color,this.frameClient,new Ss(t.key,this.unaryClient,this.frameClient),new mm(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient,this.ontologyClient,this)}sugarMany(t){return t.map(e=>this.sugarOne(e))}async openTracker(){return await yt(this.frameClient,"sy_range_set","sy_range_delete",(t,e)=>t==="delete"?e.toStrings().map(n=>({variant:t,key:n,value:void 0})):this.sugarMany(e.parseJSON(hn)).map(n=>({variant:t,key:n.key,value:n})))}resourcesToRanges(t){return t.map(e=>this.resourceToRange(e))}resourceToRange(t){var e,n,r;return this.sugarOne({key:t.id.key,name:(e=t.data)==null?void 0:e.name,timeRange:new se((n=t.data)==null?void 0:n.timeRange),color:(r=t.data)==null?void 0:r.color})}};const Am=s.z.object({ranges:hn.array()}),km=s.z.object({parent:ge.optional(),ranges:Il.array()}),xm=s.z.object({keys:ye.array()}),Cm=s.z.object({}),$m=s.z.object({key:ye,name:s.z.string()}),Rm=s.z.object({}),jm="/range/create",Bm="/range/delete",Mm="/range/rename";let $l=class{constructor(t){l(this,"client"),this.client=t}async rename(t,e){await v(this.client,Mm,{key:t,name:e},$m,Rm)}async create(t,e){return(await v(this.client,jm,{ranges:t,...e},km,Am)).ranges}async delete(t){await v(this.client,Bm,{keys:t},xm,Cm)}};const Dm=Object.freeze(Object.defineProperty({__proto__:null,ALIAS_ONTOLOGY_TYPE:kl,Client:Cl,KV:Ss,ONTOLOGY_TYPE:Al,Range:xl,Writer:$l,analyzeParams:El,keyZ:ye,newPayloadZ:Il,payloadZ:hn,rangeAliasOntologyID:am,rangeOntologyID:im},Symbol.toStringTag,{value:"Module"})),Pm="/api/v1/";class Um{constructor(e,n=!1){l(this,"url"),l(this,"unary"),l(this,"stream"),l(this,"secure"),this.secure=n,this.url=e.child(Pm);const r=new dt.JSONCodec;this.unary=new pd(this.url,r,this.secure),this.stream=new Nd(this.url,r,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Qs=s.z.string().uuid(),ei=s.z.object({key:s.z.string(),name:s.z.string(),data:dr.or(s.z.string().transform(t=>JSON.parse(t)))}),Lm=s.z.object({keys:s.z.string().array()}),_m=s.z.object({linePlots:ei.array()});let Ym=class{constructor(t){l(this,"ENDPOINT","/workspace/lineplot/retrieve"),l(this,"client"),this.client=t}async retrieve(t){const e=T(t);return(await v(this.client,this.ENDPOINT,{keys:e},Lm,_m)).linePlots}};const We=s.z.string().uuid(),Rl=t=>JSON.parse(t),jl=s.z.object({name:s.z.string(),key:We,layout:dr.or(s.z.string().transform(t=>Rl(t)))}),Bl=jl.omit({layout:!0}).extend({layout:s.z.string().transform(t=>Rl(t))}),qm=ei.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Fm=s.z.object({workspace:We,linePlots:qm.array()}),Vm=s.z.object({linePlots:ei.array()}),Wm=s.z.object({keys:Qs.array()}),Gm=s.z.object({}),Zm=s.z.object({key:Qs,name:s.z.string()}),Km=s.z.object({}),Jm=s.z.object({key:Qs,data:s.z.string()}),Hm=s.z.object({}),Xm="/workspace/lineplot/create",Qm="/workspace/lineplot/delete",ew="/workspace/lineplot/rename",tw="/workspace/lineplot/set-data";let nw=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n={...e,data:JSON.stringify(e.data)};return(await v(this.client,Xm,{workspace:t,linePlots:[n]},Fm,Vm)).linePlots[0]}async delete(t){const e=T(t);await v(this.client,Qm,{keys:e},Wm,Gm)}async rename(t,e){await v(this.client,ew,{key:t,name:e},Zm,Km)}async setData(t,e){await v(this.client,tw,{key:t,data:JSON.stringify(e)},Jm,Hm)}},rw=class{constructor(t){l(this,"writer"),l(this,"retriever"),this.writer=new nw(t),this.retriever=new Ym(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}};const ti=s.z.string().uuid(),sw=s.z.object({key:s.z.string(),name:s.z.string(),data:dr.or(s.z.string().transform(t=>JSON.parse(t)))}),Ml=s.z.object({key:s.z.string(),name:s.z.string(),data:s.z.string().transform(t=>JSON.parse(t))}),iw=s.z.object({keys:s.z.string().array()}),aw=s.z.object({logs:Ml.array()});let ow=class{constructor(t){l(this,"ENDPOINT","/workspace/log/retrieve"),l(this,"client"),this.client=t}async retrieve(t){return(await v(this.client,this.ENDPOINT,{keys:T(t)},iw,aw)).logs}};const lw=sw.partial({key:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),cw=s.z.object({workspace:We,logs:lw.array()}),uw=s.z.object({logs:Ml.array()}),hw=s.z.object({keys:ti.array()}),dw=s.z.object({}),fw=s.z.object({key:ti,name:s.z.string()}),yw=s.z.object({}),gw=s.z.object({key:ti,data:s.z.string()}),pw=s.z.object({}),mw="/workspace/log/create",ww="/workspace/log/delete",bw="/workspace/log/rename",vw="/workspace/log/set-data";let Ow=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n={...e,data:JSON.stringify(e.data)};return(await v(this.client,mw,{workspace:t,logs:[n]},cw,uw)).logs[0]}async delete(t){const e=T(t);await v(this.client,ww,{keys:e},hw,dw)}async rename(t,e){await v(this.client,bw,{key:t,name:e},fw,yw)}async setData(t,e){await v(this.client,vw,{key:t,data:JSON.stringify(e)},gw,pw)}},Tw=class{constructor(t){l(this,"writer"),l(this,"retriever"),this.writer=new Ow(t),this.retriever=new ow(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}};const Sw=s.z.object({keys:We.array().optional(),search:s.z.string().optional(),author:s.z.string().uuid().optional(),offset:s.z.number().optional(),limit:s.z.number().optional()}),zw=s.z.object({workspaces:me(Bl)});var bn;let Nw=(bn=class{constructor(t){l(this,"client"),this.client=t}async retrieve(t){const e=T(t);return await this.execute({keys:e})}async retrieveByAuthor(t){return await this.execute({author:t})}async search(t){return await this.execute({search:t})}async page(t,e){return await this.execute({offset:t,limit:e})}async execute(t){return(await v(this.client,bn.ENDPOINT,t,Sw,zw)).workspaces}},l(bn,"ENDPOINT","/workspace/retrieve"),bn);const zr=s.z.string().uuid(),Iw=s.z.object({key:s.z.string(),name:s.z.string(),data:dr.or(s.z.string().transform(t=>JSON.parse(t))),snapshot:s.z.boolean()}),ni=s.z.object({key:s.z.string(),name:s.z.string(),snapshot:s.z.boolean(),data:s.z.string().transform(t=>JSON.parse(t))}),Ew=s.z.object({keys:s.z.string().array()}),Aw=s.z.object({schematics:ni.array()});class kw{constructor(e){l(this,"ENDPOINT","/workspace/schematic/retrieve"),l(this,"client"),this.client=e}async retrieve(e){return(await v(this.client,this.ENDPOINT,{keys:T(e)},Ew,Aw)).schematics}}const xw=Iw.partial({key:!0,snapshot:!0}).transform(t=>({...t,data:JSON.stringify(t.data)})),Cw=s.z.object({workspace:We,schematics:xw.array()}),$w=s.z.object({schematics:ni.array()}),Rw=s.z.object({keys:zr.array()}),jw=s.z.object({}),Bw=s.z.object({key:zr,name:s.z.string()}),Mw=s.z.object({}),Dw=s.z.object({key:zr,data:s.z.string()}),Pw=s.z.object({}),Uw=s.z.object({key:zr,name:s.z.string(),snapshot:s.z.boolean()}),Lw=s.z.object({schematic:ni}),_w="/workspace/schematic/create",Yw="/workspace/schematic/delete",qw="/workspace/schematic/rename",Fw="/workspace/schematic/set-data",Vw="/workspace/schematic/copy";let Ww=class{constructor(t){l(this,"client"),this.client=t}async create(t,e){const n={...e,data:JSON.stringify(e.data)};return(await v(this.client,_w,{workspace:t,schematics:[n]},Cw,$w)).schematics[0]}async copy(t,e,n){return(await v(this.client,Vw,{key:t,name:e,snapshot:n},Uw,Lw)).schematic}async delete(t){const e=T(t);await v(this.client,Yw,{keys:e},Rw,jw)}async rename(t,e){await v(this.client,qw,{key:t,name:e},Bw,Mw)}async setData(t,e){await v(this.client,Fw,{key:t,data:JSON.stringify(e)},Dw,Pw)}},Gw=class{constructor(t){l(this,"writer"),l(this,"retriever"),this.writer=new Ww(t),this.retriever=new kw(t)}async create(t,e){return await this.writer.create(t,e)}async rename(t,e){await this.writer.rename(t,e)}async setData(t,e){await this.writer.setData(t,e)}async retrieve(t){const e=Array.isArray(t),n=await this.retriever.retrieve(t);return e?n:n[0]}async delete(t){await this.writer.delete(t)}async copy(t,e,n){return await this.writer.copy(t,e,n)}};const Zw=jl.partial({key:!0}).transform(t=>({...t,layout:JSON.stringify(t.layout)})),Kw=s.z.object({workspaces:Zw.array()}),Jw=s.z.object({workspaces:Bl.array()}),Hw=s.z.object({keys:We.array()}),Xw=s.z.object({}),Qw=s.z.object({key:We,name:s.z.string()}),eb=s.z.object({}),tb=s.z.object({key:We,layout:s.z.string()}),nb=s.z.object({}),rb="/workspace/create",sb="/workspace/delete",ib="/workspace/rename",ab="/workspace/set-layout";class ob{constructor(e){l(this,"client"),this.client=e}async create(e){return(await v(this.client,rb,{workspaces:T(e)},Kw,Jw)).workspaces}async delete(e){await v(this.client,sb,{keys:T(e)},Hw,Xw)}async rename(e,n){await v(this.client,ib,{key:e,name:n},Qw,eb)}async setLayout(e,n){await v(this.client,ab,{key:e,layout:JSON.stringify(n)},tb,nb)}}class lb{constructor(e){l(this,"type","workspace"),l(this,"schematic"),l(this,"linePlot"),l(this,"log"),l(this,"retriever"),l(this,"writer"),this.schematic=new Gw(e),this.linePlot=new rw(e),this.retriever=new Nw(e),this.log=new Tw(e),this.writer=new ob(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const n=Array.isArray(e),r=await this.retriever.retrieve(e);return n?r:r[0]}async page(e,n){return await this.retriever.page(e,n)}async create(e){const n=Array.isArray(e),r=await this.writer.create(e);return n?r:r[0]}async rename(e,n){await this.writer.rename(e,n)}async setLayout(e,n){await this.writer.setLayout(e,n)}async delete(...e){await this.writer.delete(e)}}const Dl=s.z.object({host:s.z.string({required_error:"Host is required"}).min(1,"Host is required"),port:s.z.number({required_error:"Port is required"}).or(s.z.string({required_error:"Port is required"})),username:s.z.string().min(1,"Username is required"),password:s.z.string().min(1,"Password is required"),connectivityPollFrequency:$.z.default($.seconds(30)),secure:s.z.boolean().optional().default(!1),name:s.z.string().optional()});class Pl extends ep{constructor(e){const n=Dl.parse(e),{host:r,port:i,username:a,password:o,connectivityPollFrequency:c,secure:u}=n,h=new Um(new Gf({host:r,port:Number(i)}),u);h.use(iy);let f;a!=null&&o!=null&&(f=new Cg(h.unary,{username:a,password:o}),h.use(f.middleware()));const d=new qs(new Ys(h.unary)),k=new ml(h.unary,d);super(h.stream,h.unary,d),l(this,"createdAt"),l(this,"props"),l(this,"ranges"),l(this,"channels"),l(this,"auth"),l(this,"user"),l(this,"access"),l(this,"connectivity"),l(this,"ontology"),l(this,"workspaces"),l(this,"labels"),l(this,"hardware"),l(this,"control"),l(this,"transport"),l(this,"clientVersion","0.34.0"),this.createdAt=x.now(),this.props=n,this.auth=f,this.transport=h,this.channels=new pl(this,d,h.unary,k),this.connectivity=new vl(h.unary,c,this.clientVersion,n.name),this.control=new zl(this),this.ontology=new Ty(h.unary,this);const D=new $l(this.transport.unary);this.labels=new rm(this.transport.unary,this,this.ontology),this.ranges=new Cl(this,D,this.transport.unary,d,this.labels,this.ontology),this.access=new Dy(this.transport.unary),this.user=new zg(this.transport.unary),this.workspaces=new lb(this.transport.unary);const ie=new mp(this.transport.unary,this),B=new _p(this.transport.unary,this,this.ontology,this.ranges),ic=new Np(this.transport.unary,this,B);this.hardware=new ap(B,ic,ie)}get key(){return this.createdAt.valueOf().toString()}close(){this.connectivity.stopChecking()}}l(Pl,"connectivity",vl);const cb=lt.Authority,zs=(t,e,n="")=>{try{return t.parse(e)}catch(r){if(r instanceof s.z.ZodError){const i=r.errors.map(a=>a.path.length===0?a.message:`${a.path.join(".")}: ${a.message}`);throw new Error(`${n} - ${i.join(`
|
|
66
|
-
`)}`)}else throw r}};var ub=Object.defineProperty,hb=(t,e,n)=>e in t?ub(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ee=(t,e,n)=>hb(t,typeof e!="symbol"?e+"":e,n);const Ns=class Ul{constructor(e,n,r="",i=!1){ee(this,"_noop",!1),ee(this,"key"),ee(this,"path"),ee(this,"serviceName"),this.key=e,this.path=n,this.serviceName=r,this._noop=i}child(e){return new Ul(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};ee(Ns,"NOOP",new Ns("","",""));let ri=Ns;const Is=["debug","info","warn","error"],db=t=>{const e=Is.indexOf(t);return({level:n})=>Is.indexOf(n)>=e},fb=t=>{const{include:e,exclude:n}=t;return({path:r})=>!(e!=null&&!e.some(i=>r.startsWith(i))||n!=null&&n.some(i=>r.startsWith(i)))},Es=class Ll{constructor(e={}){ee(this,"meta",ri.NOOP),ee(this,"filters");const{filters:n=[]}=e;this.filters=n}filter(e){return!this.meta.noop&&this.filters.every(n=>n({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const n=new Ll({filters:this.filters});return n.meta=e,n}debug(e,n,r=!1){!this.filter("debug")&&!r||(n==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,vn(n)))}info(e,n,r=!1){!this.filter("info")&&!r||(n==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,vn(n)))}warn(e,n,r=!1){!this.filter("warn")&&!r||(n==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,vn(n)))}error(e,n,r=!1){!this.filter("error")&&!r||(n==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,vn(n)))}};ee(Es,"NOOP",new Es);let _l=Es;const vn=t=>typeof t=="function"?t():t;var yb=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Je="1.9.0",va=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function gb(t){var e=new Set([t]),n=new Set,r=t.match(va);if(!r)return function(){return!1};var i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(c){return c===t};function a(c){return n.add(c),!1}function o(c){return e.add(c),!0}return function(c){if(e.has(c))return!0;if(n.has(c))return!1;var u=c.match(va);if(!u)return a(c);var h={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return h.prerelease!=null||i.major!==h.major?a(c):i.major===0?i.minor===h.minor&&i.patch<=h.patch?o(c):a(c):i.minor<=h.minor?o(c):a(c)}}var pb=gb(Je),mb=Je.split(".")[0],Ht=Symbol.for("opentelemetry.js.api."+mb),Xt=yb;function si(t,e,n,r){var i;r===void 0&&(r=!1);var a=Xt[Ht]=(i=Xt[Ht])!==null&&i!==void 0?i:{version:Je};if(!r&&a[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return n.error(o.stack||o.message),!1}if(a.version!==Je){var o=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+Je);return n.error(o.stack||o.message),!1}return a[t]=e,n.debug("@opentelemetry/api: Registered a global for "+t+" v"+Je+"."),!0}function Qt(t){var e,n,r=(e=Xt[Ht])===null||e===void 0?void 0:e.version;if(!(!r||!pb(r)))return(n=Xt[Ht])===null||n===void 0?void 0:n[t]}function ii(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Je+".");var n=Xt[Ht];n&&delete n[t]}var wb=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},bb=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},vb=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ot("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ot("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ot("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ot("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ot("verbose",this._namespace,e)},t}();function Ot(t,e,n){var r=Qt("diag");if(r)return n.unshift(e),r[t].apply(r,bb([],wb(n),!1))}var pe;(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"})(pe||(pe={}));function Ob(t,e){t<pe.NONE?t=pe.NONE:t>pe.ALL&&(t=pe.ALL),e=e||{};function n(r,i){var a=e[r];return typeof a=="function"&&t>=i?a.bind(e):function(){}}return{error:n("error",pe.ERROR),warn:n("warn",pe.WARN),info:n("info",pe.INFO),debug:n("debug",pe.DEBUG),verbose:n("verbose",pe.VERBOSE)}}var Tb=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Sb=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},zb="diag",en=function(){function t(){function e(i){return function(){for(var a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var c=Qt("diag");if(c)return c[i].apply(c,Sb([],Tb(a),!1))}}var n=this,r=function(i,a){var o,c,u;if(a===void 0&&(a={logLevel:pe.INFO}),i===n){var h=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=h.stack)!==null&&o!==void 0?o:h.message),!1}typeof a=="number"&&(a={logLevel:a});var f=Qt("diag"),d=Ob((c=a.logLevel)!==null&&c!==void 0?c:pe.INFO,i);if(f&&!a.suppressOverrideMessage){var k=(u=new Error().stack)!==null&&u!==void 0?u:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+k),d.warn("Current logger will overwrite one already registered from "+k)}return si("diag",d,n,!0)};n.setLogger=r,n.disable=function(){ii(zb,n)},n.createComponentLogger=function(i){return new vb(i)},n.verbose=e("verbose"),n.debug=e("debug"),n.info=e("info"),n.warn=e("warn"),n.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}(),Nb=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Ib=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Eb=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var n=this._entries.get(e);if(n)return Object.assign({},n)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var n=Nb(e,2),r=n[0],i=n[1];return[r,i]})},t.prototype.setEntry=function(e,n){var r=new t(this._entries);return r._entries.set(e,n),r},t.prototype.removeEntry=function(e){var n=new t(this._entries);return n._entries.delete(e),n},t.prototype.removeEntries=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var a=new t(this._entries);try{for(var o=Ib(r),c=o.next();!c.done;c=o.next()){var u=c.value;a._entries.delete(u)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return a},t.prototype.clear=function(){return new t},t}();en.instance();function Ab(t){return t===void 0&&(t={}),new Eb(new Map(Object.entries(t)))}function kb(t){return Symbol.for(t)}var xb=function(){function t(e){var n=this;n._currentContext=e?new Map(e):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,i){var a=new t(n._currentContext);return a._currentContext.set(r,i),a},n.deleteValue=function(r){var i=new t(n._currentContext);return i._currentContext.delete(r),i}}return t}(),Cb=new xb,$b={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Rb={set:function(t,e,n){t!=null&&(t[e]=n)}},jb=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Bb=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Mb=function(){function t(){}return t.prototype.active=function(){return Cb},t.prototype.with=function(e,n,r){for(var i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return n.call.apply(n,Bb([r],jb(i),!1))},t.prototype.bind=function(e,n){return n},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),Db=function(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,a=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a},Pb=function(t,e,n){if(arguments.length===2)for(var r=0,i=e.length,a;r<i;r++)(a||!(r in e))&&(a||(a=Array.prototype.slice.call(e,0,r)),a[r]=e[r]);return t.concat(a||Array.prototype.slice.call(e))},Jr="context",Ub=new Mb,Yl=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return si(Jr,e,en.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,n,r){for(var i,a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Pb([e,n,r],Db(a),!1))},t.prototype.bind=function(e,n){return this._getContextManager().bind(e,n)},t.prototype._getContextManager=function(){return Qt(Jr)||Ub},t.prototype.disable=function(){this._getContextManager().disable(),ii(Jr,en.instance())},t}(),As;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(As||(As={}));var Lb=Yl.getInstance(),_b=function(){function t(){}return t.prototype.inject=function(e,n){},t.prototype.extract=function(e,n){return e},t.prototype.fields=function(){return[]},t}(),ai=kb("OpenTelemetry Baggage Key");function ql(t){return t.getValue(ai)||void 0}function Yb(){return ql(Yl.getInstance().active())}function qb(t,e){return t.setValue(ai,e)}function Fb(t){return t.deleteValue(ai)}var Hr="propagation",Vb=new _b,Wb=function(){function t(){this.createBaggage=Ab,this.getBaggage=ql,this.getActiveBaggage=Yb,this.setBaggage=qb,this.deleteBaggage=Fb}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return si(Hr,e,en.instance())},t.prototype.inject=function(e,n,r){return r===void 0&&(r=Rb),this._getGlobalPropagator().inject(e,n,r)},t.prototype.extract=function(e,n,r){return r===void 0&&(r=$b),this._getGlobalPropagator().extract(e,n,r)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){ii(Hr,en.instance())},t.prototype._getGlobalPropagator=function(){return Qt(Hr)||Vb},t}(),Gb=Wb.getInstance();const Oa=["bench","debug","prod"],Zb=t=>e=>Oa.indexOf(e)>=Oa.indexOf(t),ks=class Fl{constructor(e,n=Zb("debug")){ee(this,"meta",ri.NOOP),ee(this,"tracer"),ee(this,"filter"),this.tracer=e,this.filter=n}child(e){const n=new Fl(this.tracer,this.filter);return n.meta=e,n}debug(e,n){return this.trace(e,"debug",n)}bench(e,n){return this.trace(e,"bench",n)}prod(e,n){return this.trace(e,"prod",n)}trace(e,n,r){return this.meta.noop||!this.filter(n)?r(new Gl(e)):this.tracer.startActiveSpan(e,i=>{const a=new Wl(e,i),o=r(a);return i.end(),o})}propagate(e){if(this.meta.noop)return;const n=Lb.active();Gb.inject(n,e,{set:(r,i,a)=>{r[i]=a}})}};ee(ks,"NOOP",new ks);let Vl=ks;class Wl{constructor(e,n){ee(this,"key"),ee(this,"otel"),this.key=e,this.otel=n}set(e,n){this.otel.setAttribute(e,n)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:As.ERROR}))}}class Gl{constructor(e){ee(this,"key"),this.key=e}set(){}recordError(e){}}const xs=class Zl{constructor({key:e="",serviceName:n="",logger:r=_l.NOOP,tracer:i=Vl.NOOP,noop:a=!1,__meta:o}){ee(this,"meta"),ee(this,"T"),ee(this,"L"),this.meta=o??new ri(e,e,n,a),this.T=i.child(this.meta),this.L=r.child(this.meta)}child(e){const n=this.meta.child(e);return new Zl({__meta:n,tracer:this.T,logger:this.L})}};ee(xs,"NOOP",new xs({noop:!0}));let oi=xs;const Kb=oi.NOOP,Kl=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:oi,LOG_LEVELS:Is,Logger:_l,NOOP:Kb,NoopSpan:Gl,Tracer:Vl,_Span:Wl,logLevelKeyFiler:fb,logThresholdFilter:db},Symbol.toStringTag,{value:"Module"})),Jb=new Error("request for lock canceled");var Hb=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Xb{constructor(e,n=Jb){this._value=e,this._cancelError=n,this._queue=[],this._weightedWaiters=[]}acquire(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((r,i)=>{const a={resolve:r,reject:i,weight:e,priority:n},o=Jl(this._queue,c=>n<=c.priority);o===-1&&e<=this._value?this._dispatchItem(a):this._queue.splice(o+1,0,a)})}runExclusive(e){return Hb(this,arguments,void 0,function*(n,r=1,i=0){const[a,o]=yield this.acquire(r,i);try{return yield n(a)}finally{o()}})}waitForUnlock(e=1,n=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,n)?Promise.resolve():new Promise(r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),Qb(this._weightedWaiters[e-1],{resolve:r,priority:n})})}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 n=this._value;this._value-=e.weight,e.resolve([n,this._newReleaser(e.weight)])}_newReleaser(e){let n=!1;return()=>{n||(n=!0,this.release(e))}}_drainUnlockWaiters(){if(this._queue.length===0)for(let e=this._value;e>0;e--){const n=this._weightedWaiters[e-1];n&&(n.forEach(r=>r.resolve()),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let n=this._value;n>0;n--){const r=this._weightedWaiters[n-1];if(!r)continue;const i=r.findIndex(a=>a.priority<=e);(i===-1?r:r.splice(0,i)).forEach(a=>a.resolve())}}}_couldLockImmediately(e,n){return(this._queue.length===0||this._queue[0].priority<n)&&e<=this._value}}function Qb(t,e){const n=Jl(t,r=>e.priority<=r.priority);t.splice(n+1,0,e)}function Jl(t,e){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return n;return-1}var ev=function(t,e,n,r){function i(a){return a instanceof n?a:new n(function(o){o(a)})}return new(n||(n=Promise))(function(a,o){function c(f){try{h(r.next(f))}catch(d){o(d)}}function u(f){try{h(r.throw(f))}catch(d){o(d)}}function h(f){f.done?a(f.value):i(f.value).then(c,u)}h((r=r.apply(t,e||[])).next())})};class Hl{constructor(e){this._semaphore=new Xb(1,e)}acquire(){return ev(this,arguments,void 0,function*(e=0){const[,n]=yield this._semaphore.acquire(1,e);return n})}runExclusive(e,n=0){return this._semaphore.runExclusive(()=>e(),1,n)}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()}}class Nr{constructor(e,n,r=new Map){P(this,"providers");P(this,"registry");P(this,"sender");P(this,"changedKeys");this.providers=r,this.registry=n,this.changedKeys=[],this.sender=e}propagateState(e,n,r=[]){this.sender.send({key:e,state:n},r)}copyAndMerge(e){const n=new Nr(this.sender,this.registry,new Map);return e==null||e.providers.forEach((r,i)=>n.providers.set(i,r)),this.providers.forEach((r,i)=>n.providers.set(i,r)),n.changedKeys=[],n}get changed(){return this.changedKeys.length>0}set(e,n,r=!0){this.providers.set(e,n),r&&this.changedKeys.push(e)}setIfNotHas(e,n){this.providers.has(e)||this.set(e,n)}async create(e){const n=this.registry[e.type];if(n==null)throw new Error(`[AetherRoot.create] - could not find component ${e.type}`);const r=new n(e);return await r.internalUpdate(e),r}getOptional(e){return this.providers.get(e)??null}has(e){return this.providers.has(e)}get(e){const n=this.getOptional(e);if(n==null)throw new Error(`[AetherRoot.get] - could not find provider ${e}`);return n}}class li{constructor(e){P(this,"type");P(this,"key");P(this,"_ctx");P(this,"_internalState");P(this,"_state");P(this,"_prevState");P(this,"_deleted",!1);P(this,"instrumentation");P(this,"schema");this.type=e.type,this.key=e.path[0],this._ctx=e.ctx,this._internalState={},this.instrumentation=e.instrumentation.child(`${this.type}(${this.key})`)}get _schema(){if(this.schema==null)throw new K(`[AetherLeaf] - expected subclass to define component schema, but none was found.
|
|
67
|
-
Make sure to defne a property 'schema' on the class.`);return this.schema}setState(e){const n=js(e,this._state);this._prevState={...this._state},this._state=zs(this._schema,n,`${this.type}:${this.key}`),this.ctx.propagateState(this.key,n)}get ctx(){if(this._ctx==null)throw new be("context not defined");return this._ctx}get state(){if(this._state==null)throw new be("state not defined");return this._state}get internal(){return this._internalState}get prevState(){return this._prevState}get deleted(){return this._deleted}async internalUpdate({variant:e,path:n,ctx:r,state:i}){if(!this.deleted){if(this._ctx=r,e==="state"){this.validatePath(n);const a=zs(this._schema,i,`${this.type}:${this.key}`);this._state!=null?this.instrumentation.L.debug("updating state",()=>({diff:xa.difference(this.state,a)})):this.instrumentation.L.debug("setting initial state",{state:i}),this._prevState=this._state??a,this._state=a}else this.instrumentation.L.debug("updating context");await this.afterUpdate()}}async internalDelete(e){this.validatePath(e),this._deleted=!0,await this.afterDelete()}beforeUpdate(){}async afterUpdate(){}async afterDelete(){}validatePath(e){if(e.length===0)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received an empty path`);const n=e[e.length-1];if(e.length>1)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received a subPath ${e.join(".")} but is a leaf`);if(n!==this.key)throw new be(`[Leaf.setState] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`)}}class dn extends li{constructor(n){super(n);P(this,"_children");this._children=new Map}get children(){return Array.from(this._children.values())}async internalUpdate(n){const{variant:r,path:i}=n;if(r==="context")return this._ctx=n.ctx.copyAndMerge(this._ctx),await this.updateContext({...n,ctx:this.ctx});const[a,o]=this.getRequiredKey(i),c={...n,ctx:this.ctx};return o.length===0?await this.updateThis(a,c):await this.updateChild(o,c)}async updateContext(n){await super.internalUpdate(n);for(const r of this.children)await r.internalUpdate({...n,ctx:this.ctx,variant:"context"})}async updateChild(n,r){const i=n[0],a=this.getChild(i);if(a!=null)return await a.internalUpdate({...r,path:n});if(n.length>1)throw new Error(`[Composite.setState] - ${this.type}:${this.key} could not find child with key ${i} while updating `);this._children.set(i,await r.ctx.create({...r,path:n}))}async updateThis(n,r){const i=r.ctx.copyAndMerge(this._ctx);if(n!==this.key)throw new be(`[Composite.update] - ${this.type}:${this.key} received a key ${n} but expected ${this.key}`);if(await super.internalUpdate({...r,ctx:i}),!!i.changed){this.instrumentation.L.debug("context changed",{changedKeys:i.changedKeys});for(const a of this.children)await a.internalUpdate({...r,ctx:this.ctx,variant:"context"})}}async internalDelete(n){const[r,i]=this.getRequiredKey(n);if(i.length===0){if(r!==this.key)throw new Error(`[Composite.delete] - ${this.type}:${this.key} received a key ${r} but expected ${this.key}`);const o=this.children;this._children=new Map;for(const c of o)await c.internalDelete([c.key]);await super.internalDelete([this.key])}const a=this.getChild(i[0]);a!=null&&(i.length>1?await a.internalDelete(i):(this._children.delete(a.key),await a.internalDelete(i)))}getRequiredKey(n,r){const[i,...a]=n;if(i==null)throw new Error(`Composite ${this.type}:${this.key} received an empty path${r!=null?` for ${r}`:""}`);return[i,a]}getChild(n){return this._children.get(n)??null}childrenOfType(...n){return this.children.filter(r=>n.includes(r.type))}}const tv=s.z.object({}),$e=class $e extends dn{constructor({worker:n,registry:r,instrumentation:i=Kl.Instrumentation.NOOP}){const o={ctx:new Nr(n,r,new Map),...$e.ZERO_UPDATE,instrumentation:i};super(o);P(this,"wrap");P(this,"schema",$e.schema);P(this,"mu",new Hl);this.mu.runExclusive(async()=>await this.internalUpdate(o)),this.wrap=n,this.wrap.handle(c=>{this.mu.runExclusive(async()=>await this.handle(c))})}async handle(n){if(n.variant==="delete")await this.internalDelete(n.path);else{const r={...n,variant:"state",ctx:this.ctx,instrumentation:this.instrumentation};await this.internalUpdate(r)}}};P($e,"TYPE","root"),P($e,"KEY","root"),P($e,"ZERO_UPDATE",{path:[$e.KEY],type:$e.TYPE,variant:"state",state:{}}),P($e,"schema",tv);let ir=$e;const Xl=t=>new ir(t),nv=Object.freeze(Object.defineProperty({__proto__:null,Composite:dn,Context:Nr,Leaf:li,Root:ir,render:Xl},Symbol.toStringTag,{value:"Module"})),Ql="pluto-theming-context",ec=s.z.object({name:s.z.string(),url:s.z.string()}),rv=s.z.object({theme:Ha,fontURLs:s.z.array(ec)}),Gt=class Gt extends dn{constructor(){super(...arguments);P(this,"schema",Gt.z)}async afterUpdate(){this.ctx.set(Ql,this.state.theme),await this.loadFonts()}async loadFonts(){await Promise.all(this.state.fontURLs.map(async({name:n,url:r})=>{const i=new FontFace(n,`url(${r})`);await i.load(),self.fonts.add(i)}))}};P(Gt,"TYPE","theming.Provider"),P(Gt,"z",rv);let tn=Gt;const sv=t=>t.get(Ql),iv={[tn.TYPE]:tn},tc=["success","error","warning","info","loading","disabled","secondary"],nc=s.z.enum(tc),rc=s.z.object({key:s.z.string(),variant:nc,message:s.z.string(),description:s.z.string().optional(),time:W.z,data:s.z.record(s.z.unknown()).optional()}),sc=s.z.object({statuses:rc.array()}),ci="status.aggregator";class ar extends dn{constructor(){super(...arguments);P(this,"schema",sc)}async afterUpdate(){this.ctx.set(ci,this)}add(n){this.setState(r=>({...r,statuses:[...r.statuses,{time:W.now(),key:ja.id(),...n}]}))}}P(ar,"TYPE","status.Aggregator");const av=t=>{const e=t.get(ci);return e.add.bind(e)},ov=t=>{const e=t.getOptional(ci);return e!=null?e.add.bind(e):()=>{}},lv={[ar.TYPE]:ar};exports.A=eu;exports.Aggregator=ar;exports.B=K;exports.B$1=oi;exports.B$2=mu;exports.Bg=Dm;exports.Ce=be;exports.ComponentSizeLevels=Ja;exports.Composite=dn;exports.Ct=Zc;exports.E=it;exports.F=vc;exports.H=Tu;exports.I=x;exports.Kg=cb;exports.LEVELS=Ka;exports.Leaf=li;exports.LevelComponentSizes=$u;exports.Lf=Pl;exports.Mutex=Hl;exports.N=jc;exports.Og=ip;exports.P=ts;exports.Provider=tn;exports.Q=Su;exports.REGISTRY=iv;exports.REGISTRY$1=lv;exports.Rt=ja;exports.SYNNAX_DARK=Qa;exports.SYNNAX_LIGHT=Xa;exports.SYNNAX_THEMES=Yu;exports.U=zu;exports.V=Da;exports.V$1=se;exports.VARIANTS=tc;exports.W=gu;exports.Zf=Dl;exports._=xa;exports.aether=nv;exports.aggregatorStateZ=sc;exports.b=ce;exports.dg=ig;exports.dimensions=ju;exports.downLevel=ku;exports.executeInitialSetter=rn;exports.executeSetter=js;exports.fontSpecZ=ec;exports.fontString=Wu;exports.g=j;exports.g$1=Kl;exports.isSetter=Rs;exports.k=$;exports.l=lu;exports.levelZ=Eu;exports.m=W;exports.n=Xr;exports.o=Oc;exports.o$1=tu;exports.prettyParse=zs;exports.r=Tc;exports.re=Oe;exports.render=Xl;exports.specZ=Ye;exports.specZ$1=rc;exports.state=Iu;exports.themeZ=Ha;exports.upLevel=Cu;exports.use=sv;exports.useAggregate=av;exports.useOptionalAggregate=ov;exports.usePassthrough=Ga;exports.usePurePassthrough=Za;exports.variantZ=nc;exports.w=La;exports.w$1=fc;exports.x=Zt;exports.xt=Lc;exports.y=Z;
|