@synnaxlabs/x 0.32.0 → 0.34.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.
Files changed (124) hide show
  1. package/.turbo/turbo-build.log +32 -32
  2. package/dist/binary.cjs +1 -1
  3. package/dist/binary.js +1 -1
  4. package/dist/bounds-CFI9wDXn.js +171 -0
  5. package/dist/bounds-DzCDHgdE.cjs +1 -0
  6. package/dist/bounds.cjs +1 -1
  7. package/dist/bounds.js +1 -1
  8. package/dist/box-DVCNGsJG.js +201 -0
  9. package/dist/box-Mf8E1Ypp.cjs +1 -0
  10. package/dist/box.cjs +1 -1
  11. package/dist/box.js +1 -1
  12. package/dist/caseconv.cjs +1 -1
  13. package/dist/caseconv.js +1 -1
  14. package/dist/compare.js +1 -1
  15. package/dist/deep.cjs +1 -1
  16. package/dist/deep.js +46 -48
  17. package/dist/{direction-DZbN47uL.cjs → direction-D7qoo_GJ.cjs} +1 -1
  18. package/dist/direction.cjs +1 -1
  19. package/dist/external-B3XSLDq5.cjs +1 -0
  20. package/dist/{external-CO221aaF.js → external-sVtvYJS6.js} +3 -3
  21. package/dist/{index-B5THJ1eb.js → index-BBa2mWG1.js} +1 -1
  22. package/dist/{index-DgaYJC35.cjs → index-CYxQwEdX.cjs} +1 -1
  23. package/dist/{index-B3BUDIdi.js → index-HQonyH7n.js} +1 -2
  24. package/dist/index-YsO0EMN8.cjs +1 -0
  25. package/dist/{index-Duv1uH08.js → index-eue4dSQX.js} +14 -10
  26. package/dist/index.cjs +2 -2
  27. package/dist/index.js +162 -145
  28. package/dist/{location-DjcaXEps.js → location-CI9x53qR.js} +8 -8
  29. package/dist/{location-gPB1RtfA.cjs → location-DetomF8Z.cjs} +1 -1
  30. package/dist/location.cjs +1 -1
  31. package/dist/location.js +1 -1
  32. package/dist/path-BBCx3K6k.cjs +1 -0
  33. package/dist/{path-B-1-i3qC.js → path-CmnoH3RC.js} +26 -26
  34. package/dist/{position-DkON65EZ.js → position-CFc9RsSn.js} +2 -2
  35. package/dist/{position-C71OiHiw.cjs → position-DKhPhvPh.cjs} +1 -1
  36. package/dist/position.cjs +1 -1
  37. package/dist/position.js +1 -1
  38. package/dist/runtime.cjs +1 -1
  39. package/dist/runtime.js +1 -1
  40. package/dist/{scale-COPgp55a.cjs → scale-CT61XD_X.cjs} +1 -1
  41. package/dist/{scale-qw6vRO4s.js → scale-DNQE1LMm.js} +25 -3
  42. package/dist/scale.cjs +1 -1
  43. package/dist/scale.js +1 -1
  44. package/dist/series-DWLXo7J6.cjs +11 -0
  45. package/dist/{series-B5eA90Ci.js → series-sjWkW8qe.js} +627 -466
  46. package/dist/spatial.cjs +1 -1
  47. package/dist/spatial.js +5 -5
  48. package/dist/src/binary/encoder.d.ts.map +1 -1
  49. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  50. package/dist/src/clamp/clamp.d.ts.map +1 -1
  51. package/dist/src/compare/compare.d.ts.map +1 -1
  52. package/dist/src/debounce/debounce.d.ts.map +1 -1
  53. package/dist/src/deep/difference.d.ts.map +1 -1
  54. package/dist/src/deep/merge.d.ts.map +1 -1
  55. package/dist/src/deep/path.d.ts +2 -2
  56. package/dist/src/deep/path.d.ts.map +1 -1
  57. package/dist/src/math/math.d.ts +26 -6
  58. package/dist/src/math/math.d.ts.map +1 -1
  59. package/dist/src/math/math.spec.d.ts +2 -0
  60. package/dist/src/math/math.spec.d.ts.map +1 -0
  61. package/dist/src/migrate/migrate.d.ts.map +1 -1
  62. package/dist/src/record.d.ts +4 -0
  63. package/dist/src/record.d.ts.map +1 -1
  64. package/dist/src/spatial/bounds/bounds.d.ts +208 -4
  65. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  66. package/dist/src/spatial/box/box.d.ts +4 -4
  67. package/dist/src/spatial/box/box.d.ts.map +1 -1
  68. package/dist/src/spatial/scale/scale.d.ts +177 -5
  69. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  70. package/dist/src/strings/strings.d.ts +14 -0
  71. package/dist/src/strings/strings.d.ts.map +1 -1
  72. package/dist/src/telem/generate.d.ts.map +1 -1
  73. package/dist/src/telem/series.d.ts +35 -10
  74. package/dist/src/telem/series.d.ts.map +1 -1
  75. package/dist/src/telem/telem.d.ts +12 -10
  76. package/dist/src/telem/telem.d.ts.map +1 -1
  77. package/dist/src/url/url.d.ts.map +1 -1
  78. package/dist/telem.cjs +1 -1
  79. package/dist/telem.js +1 -1
  80. package/dist/url.cjs +1 -1
  81. package/dist/url.js +1 -1
  82. package/dist/{zodutil-BWvwKcpb.cjs → zodutil-C6RYzvXd.cjs} +1 -1
  83. package/dist/{zodutil-qNM8aVYC.js → zodutil-Tmuc4CNq.js} +1 -1
  84. package/dist/zodutil.cjs +1 -1
  85. package/dist/zodutil.js +1 -1
  86. package/package.json +10 -9
  87. package/src/binary/encoder.ts +1 -2
  88. package/src/caseconv/caseconv.ts +8 -15
  89. package/src/clamp/clamp.ts +1 -1
  90. package/src/compare/compare.ts +1 -3
  91. package/src/debounce/debounce.ts +1 -2
  92. package/src/deep/difference.ts +3 -9
  93. package/src/deep/merge.ts +8 -15
  94. package/src/deep/path.spec.ts +1 -1
  95. package/src/deep/path.ts +4 -4
  96. package/src/math/math.spec.ts +149 -0
  97. package/src/math/math.ts +61 -10
  98. package/src/migrate/migrate.ts +4 -5
  99. package/src/record.ts +5 -0
  100. package/src/runtime/os.ts +2 -2
  101. package/src/spatial/bounds/bounds.spec.ts +135 -270
  102. package/src/spatial/bounds/bounds.ts +296 -29
  103. package/src/spatial/box/box.ts +13 -12
  104. package/src/spatial/direction/direction.ts +1 -1
  105. package/src/spatial/location/location.ts +5 -5
  106. package/src/spatial/scale/scale.ts +196 -12
  107. package/src/strings/strings.spec.ts +33 -1
  108. package/src/strings/strings.ts +52 -0
  109. package/src/telem/generate.ts +1 -3
  110. package/src/telem/series.spec.ts +235 -0
  111. package/src/telem/series.ts +310 -100
  112. package/src/telem/telem.spec.ts +27 -11
  113. package/src/telem/telem.ts +56 -36
  114. package/src/url/url.ts +9 -12
  115. package/src/zodutil/zodutil.spec.ts +5 -7
  116. package/tsconfig.tsbuildinfo +1 -1
  117. package/dist/bounds-CpboA0q6.js +0 -127
  118. package/dist/bounds-ZZc1c-_Z.cjs +0 -1
  119. package/dist/box-BQID-0jO.cjs +0 -1
  120. package/dist/box-xRqO6NvI.js +0 -202
  121. package/dist/external-B-DoBvh7.cjs +0 -1
  122. package/dist/index-xk130iQA.cjs +0 -1
  123. package/dist/path-577Fmn5N.cjs +0 -1
  124. package/dist/series-CJ65b1Uz.cjs +0 -11
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var g=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var i=(n,t,e)=>g(n,typeof t!="symbol"?t+"":t,e);const R=require("zod"),x=require("./bounds-ZZc1c-_Z.cjs"),u=require("./box-BQID-0jO.cjs"),T=require("./location-gPB1RtfA.cjs"),h=require("./xy-cP-FXJtR.cjs"),m=(n,t,e)=>t!==void 0&&n<t?t:e!==void 0&&n>e?e:n,q=R.z.object({offset:h.crudeZ,scale:h.crudeZ}),E=n=>(t,e,s,r)=>e==="dimension"?[t,s]:[t,r?s-n:s+n],I=n=>(t,e,s,r)=>[t,r?s/n:s*n],Y=n=>(t,e,s)=>{if(t===null)return[n,s];const{lower:r,upper:o}=t,{lower:p,upper:l}=n,f=o-r,w=l-p;if(e==="dimension")return[n,s*(w/f)];const B=(s-r)*(w/f)+p;return[n,B]},j=n=>(t,e,s)=>[n,s],z=()=>(n,t,e)=>{if(n===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[n,e];const{lower:s,upper:r}=n;return[n,r-(e-s)]},D=n=>(t,e,s)=>{const{lower:r,upper:o}=n;return s=m(s,r,o),[t,s]},a=class a{constructor(){i(this,"ops",[]);i(this,"currBounds",null);i(this,"currType",null);i(this,"reversed",!1);this.ops=[]}static translate(t){return new a().translate(t)}static magnify(t){return new a().magnify(t)}static scale(t,e){return new a().scale(t,e)}translate(t){const e=this.new(),s=E(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=I(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=x.construct(t,e),r=this.new(),o=Y(s);return o.type="scale",r.ops.push(o),r}clamp(t,e){const s=x.construct(t,e),r=this.new(),o=D(s);return o.type="clamp",r.ops.push(o),r}reBound(t,e){const s=x.construct(t,e),r=this.new(),o=j(s);return o.type="re-bound",r.ops.push(o),r}invert(){const t=z();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new a;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,r],o)=>o(s,t,r,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,r)=>{if(s.type==="scale"||e.some(([p,l])=>r>=p&&r<=l))return;const o=t.ops.findIndex((p,l)=>p.type==="scale"&&l>r);o!==-1&&e.push([r,o])}),e.forEach(([s,r])=>{const o=t.ops.slice(s,r);o.unshift(t.ops[r]),t.ops.splice(s,r-s+1,...o)}),t.reversed=!t.reversed,t}};i(a,"IDENTITY",new a);let y=a;const L=n=>({scale:{x:n.x.dim(1),y:n.y.dim(1)},offset:{x:n.x.pos(0),y:n.y.pos(0)}}),c=class c{constructor(t=new y,e=new y,s=null){i(this,"x");i(this,"y");i(this,"currRoot");this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=h.construct(t,e),r=this.copy();return r.x=this.x.translate(s.x),r.y=this.y.translate(s.y),r}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!T.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}};i(c,"IDENTITY",new c);let d=c;const M=Object.freeze(Object.defineProperty({__proto__:null,Scale:y,XY:d,crudeXYTransform:q,xyScaleToTransform:L},Symbol.toStringTag,{value:"Module"}));exports.clamp=m;exports.scale=M;
1
+ "use strict";var v=Object.defineProperty;var g=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var i=(n,t,e)=>g(n,typeof t!="symbol"?t+"":t,e);const R=require("zod"),x=require("./bounds-DzCDHgdE.cjs"),u=require("./box-Mf8E1Ypp.cjs"),T=require("./location-DetomF8Z.cjs"),h=require("./xy-cP-FXJtR.cjs"),m=(n,t,e)=>t!==void 0&&n<t?t:e!==void 0&&n>e?e:n,q=R.z.object({offset:h.crudeZ,scale:h.crudeZ}),E=n=>(t,e,s,r)=>e==="dimension"?[t,s]:[t,r?s-n:s+n],I=n=>(t,e,s,r)=>[t,r?s/n:s*n],Y=n=>(t,e,s)=>{if(t===null)return[n,s];const{lower:r,upper:o}=t,{lower:p,upper:l}=n,f=o-r,w=l-p;if(e==="dimension")return[n,s*(w/f)];const B=(s-r)*(w/f)+p;return[n,B]},j=n=>(t,e,s)=>[n,s],z=()=>(n,t,e)=>{if(n===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[n,e];const{lower:s,upper:r}=n;return[n,r-(e-s)]},D=n=>(t,e,s)=>{const{lower:r,upper:o}=n;return s=m(s,r,o),[t,s]},a=class a{constructor(){i(this,"ops",[]);i(this,"currBounds",null);i(this,"currType",null);i(this,"reversed",!1);this.ops=[]}static translate(t){return new a().translate(t)}static magnify(t){return new a().magnify(t)}static scale(t,e){return new a().scale(t,e)}translate(t){const e=this.new(),s=E(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=I(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=x.construct(t,e),r=this.new(),o=Y(s);return o.type="scale",r.ops.push(o),r}clamp(t,e){const s=x.construct(t,e),r=this.new(),o=D(s);return o.type="clamp",r.ops.push(o),r}reBound(t,e){const s=x.construct(t,e),r=this.new(),o=j(s);return o.type="re-bound",r.ops.push(o),r}invert(){const t=z();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new a;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,r],o)=>o(s,t,r,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,r)=>{if(s.type==="scale"||e.some(([p,l])=>r>=p&&r<=l))return;const o=t.ops.findIndex((p,l)=>p.type==="scale"&&l>r);o!==-1&&e.push([r,o])}),e.forEach(([s,r])=>{const o=t.ops.slice(s,r);o.unshift(t.ops[r]),t.ops.splice(s,r-s+1,...o)}),t.reversed=!t.reversed,t}};i(a,"IDENTITY",new a);let y=a;const L=n=>({scale:{x:n.x.dim(1),y:n.y.dim(1)},offset:{x:n.x.pos(0),y:n.y.pos(0)}}),c=class c{constructor(t=new y,e=new y,s=null){i(this,"x");i(this,"y");i(this,"currRoot");this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=h.construct(t,e),r=this.copy();return r.x=this.x.translate(s.x),r.y=this.y.translate(s.y),r}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!T.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}};i(c,"IDENTITY",new c);let d=c;const M=Object.freeze(Object.defineProperty({__proto__:null,Scale:y,XY:d,crudeXYTransform:q,xyScaleToTransform:L},Symbol.toStringTag,{value:"Module"}));exports.clamp=m;exports.scale=M;
@@ -2,9 +2,9 @@ var g = Object.defineProperty;
2
2
  var B = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var i = (r, t, e) => B(r, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { z as R } from "zod";
5
- import { c as l } from "./bounds-CpboA0q6.js";
6
- import { e as T, f as x, y as h, c as E } from "./box-xRqO6NvI.js";
7
- import { b as I } from "./location-DjcaXEps.js";
5
+ import { c as l } from "./bounds-CFI9wDXn.js";
6
+ import { e as T, f as x, y as h, c as E } from "./box-DVCNGsJG.js";
7
+ import { b as I } from "./location-CI9x53qR.js";
8
8
  import { b as w, c as Y } from "./xy-CrgPnICw.js";
9
9
  const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r, z = R.object({ offset: w, scale: w }), D = (r) => (t, e, s, n) => e === "dimension" ? [t, s] : [
10
10
  t,
@@ -34,19 +34,41 @@ const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r
34
34
  i(this, "reversed", !1);
35
35
  this.ops = [];
36
36
  }
37
+ /**
38
+ * @returns a new scale with a translation as its first operation. Any number provided
39
+ * to the {@link pos} operation on the scale will be translated by the specified value.
40
+ * @param value - The amount to translate by.
41
+ */
37
42
  static translate(t) {
38
43
  return new u().translate(t);
39
44
  }
45
+ /**
46
+ * @returns a new scale with a magnification as its first operation. Any number provided
47
+ * to the {@link pos} or {@link dim} operation will be multiplied by the specified value.
48
+ * @param value - The amount to translate by.
49
+ */
40
50
  static magnify(t) {
41
51
  return new u().magnify(t);
42
52
  }
43
53
  static scale(t, e) {
44
54
  return new u().scale(t, e);
45
55
  }
56
+ /**
57
+ * @returns a copy of the scale with a translation as its next operation. Any
58
+ * number provided to the {@link pos} method on the scale will be translated by the
59
+ * specified value.
60
+ * @param value - The amount to translate by.
61
+ */
46
62
  translate(t) {
47
63
  const e = this.new(), s = D(t);
48
64
  return s.type = "translate", e.ops.push(s), e;
49
65
  }
66
+ /**
67
+ * @returns a copy of the scale with a translation as its next operation. Any number
68
+ * provided to the {@link pos} or {@link dim} method on the scale will be multiplied
69
+ * by the specified value.
70
+ * @param value - The amount to magnify by.
71
+ */
50
72
  magnify(t) {
51
73
  const e = this.new(), s = L(t);
52
74
  return s.type = "magnify", e.ops.push(s), e;
package/dist/scale.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-COPgp55a.cjs");exports.scale=e.scale;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-CT61XD_X.cjs");exports.scale=e.scale;
package/dist/scale.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as e } from "./scale-qw6vRO4s.js";
1
+ import { s as e } from "./scale-DNQE1LMm.js";
2
2
  export {
3
3
  e as scale
4
4
  };
@@ -0,0 +1,11 @@
1
+ "use strict";var _=Object.defineProperty;var tt=(l,t,e)=>t in l?_(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var i=(l,t,e)=>tt(l,typeof t!="symbol"?t+"":t,e);const o=require("zod"),D=require("./index-CYxQwEdX.cjs"),et=require("./index-YsO0EMN8.cjs"),nt=require("./index-h-QAL9T1.cjs"),w=require("./bounds-DzCDHgdE.cjs");require("./box-Mf8E1Ypp.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-DetomF8Z.cjs");require("./scale-CT61XD_X.cjs");require("./xy-cP-FXJtR.cjs");const rt=require("./zodutil-C6RYzvXd.cjs");let it=(l,t=21)=>(e=t)=>{let n="",s=e;for(;s--;)n+=l[Math.random()*l.length|0];return n};const st="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",K=it(st,11),at=Object.freeze(Object.defineProperty({__proto__:null,id:K},Symbol.toStringTag,{value:"Module"})),ut=o.z.enum(["static","dynamic"]),H=(l,t)=>{const e=new m(t);if(![y.DAY,y.HOUR,y.MINUTE,y.SECOND,y.MILLISECOND,y.MICROSECOND,y.NANOSECOND].some(s=>s.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=l.valueOf()%e.valueOf();return l instanceof m?new m(n):new y(n)},a=class a{constructor(t,e="UTC"){i(this,"value");i(this,"encodeValue",!0);if(t==null)this.value=a.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*a.MILLISECOND.valueOf();else if(typeof t=="string")this.value=a.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=a.parseDate(t);else{let n=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(n=a.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=a.MAX:t=a.MIN)),this.value=BigInt(t.valueOf())+n}}static parseDate([t=1970,e=1,n=1]){const s=new Date(t,e-1,n,0,0,0,0);return new a(BigInt(s.getTime())*a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[n,s,c]=t.split(":");let f="00",v="00";c!=null&&([f,v]=c.split("."));let O=a.hours(parseInt(n??"00")).add(a.minutes(parseInt(s??"00"))).add(a.seconds(parseInt(f??"00"))).add(a.milliseconds(parseInt(v??"00")));return e==="local"&&(O=O.add(a.utcOffset)),O.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return a.parseTimeString(t,e);const n=new Date(t);return t.includes(":")||n.setUTCHours(0,0,0,0),new a(BigInt(n.getTime())*a.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(a.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const n=this.toISOString(e);return t?n.slice(11,23):n.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${e} ${n}`}static get utcOffset(){return new y(BigInt(new Date().getTimezoneOffset())*a.MINUTE.valueOf())}static since(t){return new a().span(t)}date(){return new Date(this.milliseconds())}equals(t){return this.valueOf()===new a(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(t){return this.valueOf()>new a(t).valueOf()}afterEq(t){return this.valueOf()>=new a(t).valueOf()}before(t){return this.valueOf()<new a(t).valueOf()}beforeEq(t){return this.valueOf()<=new a(t).valueOf()}add(t){return new a(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new a(this.valueOf()-BigInt(t.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(a.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(t){return H(this,t)}get isToday(){return this.truncate(y.DAY).equals(a.now().truncate(y.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new a(new Date)}static max(...t){let e=a.MIN;for(const n of t){const s=new a(n);s.after(e)&&(e=s)}return e}static min(...t){let e=a.MAX;for(const n of t){const s=new a(n);s.before(e)&&(e=s)}return e}static nanoseconds(t){return new a(t)}static microseconds(t){return a.nanoseconds(t*1e3)}static milliseconds(t){return a.microseconds(t*1e3)}static seconds(t){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};i(a,"NANOSECOND",a.nanoseconds(1)),i(a,"MICROSECOND",a.microseconds(1)),i(a,"MILLISECOND",a.milliseconds(1)),i(a,"SECOND",a.seconds(1)),i(a,"MINUTE",a.minutes(1)),i(a,"HOUR",a.hours(1)),i(a,"DAY",a.days(1)),i(a,"MAX",new a((1n<<63n)-1n)),i(a,"MIN",new a(0)),i(a,"ZERO",new a(0)),i(a,"z",o.z.union([o.z.object({value:o.z.bigint()}).transform(t=>new a(t.value)),o.z.string().transform(t=>new a(BigInt(t))),o.z.instanceof(Number).transform(t=>new a(t)),o.z.number().transform(t=>new a(t)),o.z.instanceof(a)]));let m=a;const u=class u{constructor(t){i(this,"value");i(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}static fromSeconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.seconds(t):new u(t)}static fromMilliseconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.milliseconds(t):new u(t)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new u(t).valueOf()}greaterThan(t){return this.valueOf()>new u(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new u(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new u(t).valueOf()}remainder(t){return H(this,t)}truncate(t){return new u(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(u.DAY),e=this.truncate(u.HOUR),n=this.truncate(u.MINUTE),s=this.truncate(u.SECOND),c=this.truncate(u.MILLISECOND),f=this.truncate(u.MICROSECOND),v=this.truncate(u.NANOSECOND),O=t,N=e.sub(t),A=n.sub(e),h=s.sub(n),R=c.sub(s),C=f.sub(c),Y=v.sub(f);let B="";return O.isZero||(B+=`${O.days}d `),N.isZero||(B+=`${N.hours}h `),A.isZero||(B+=`${A.minutes}m `),h.isZero||(B+=`${h.seconds}s `),R.isZero||(B+=`${R.milliseconds}ms `),C.isZero||(B+=`${C.microseconds}µs `),Y.isZero||(B+=`${Y.nanoseconds}ns`),B.trim()}get days(){return Number(this.valueOf())/Number(u.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(u.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(u.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(u.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(u.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(u.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(t){return this.valueOf()===new u(t).valueOf()}add(t){return new u(this.valueOf()+new u(t).valueOf())}sub(t){return new u(this.valueOf()-new u(t).valueOf())}static nanoseconds(t=1){return new u(t)}static microseconds(t=1){return u.nanoseconds(w.mult(t,1e3))}static milliseconds(t=1){return u.microseconds(w.mult(t,1e3))}static seconds(t=1){return u.milliseconds(w.mult(t,1e3))}static minutes(t=1){return u.seconds(w.mult(t,60))}static hours(t){return u.minutes(w.mult(t,60))}static days(t){return u.hours(w.mult(t,24))}};i(u,"NANOSECOND",u.nanoseconds(1)),i(u,"MICROSECOND",u.microseconds(1)),i(u,"MILLISECOND",u.milliseconds(1)),i(u,"SECOND",u.seconds(1)),i(u,"MINUTE",u.minutes(1)),i(u,"HOUR",u.hours(1)),i(u,"DAY",u.days(1)),i(u,"MAX",new u((1n<<63n)-1n)),i(u,"MIN",new u(0)),i(u,"ZERO",new u(0)),i(u,"z",o.z.union([o.z.object({value:o.z.bigint()}).transform(t=>new u(t.value)),o.z.string().transform(t=>new u(BigInt(t))),o.z.instanceof(Number).transform(t=>new u(t)),o.z.number().transform(t=>new u(t)),o.z.instanceof(u)]));let y=u;const p=class p extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new p(t).valueOf()}get period(){return y.seconds(1/this.valueOf())}sampleCount(t){return new y(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return y.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new p(t)}static khz(t){return p.hz(t*1e3)}};i(p,"z",o.z.union([o.z.number().transform(t=>new p(t)),o.z.instanceof(Number).transform(t=>new p(t)),o.z.instanceof(p)]));let L=p;const b=class b extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new U(t*this.valueOf())}};i(b,"UNKNOWN",new b(0)),i(b,"BIT128",new b(16)),i(b,"BIT64",new b(8)),i(b,"BIT32",new b(4)),i(b,"BIT16",new b(2)),i(b,"BIT8",new b(1)),i(b,"z",o.z.union([o.z.number().transform(t=>new b(t)),o.z.instanceof(Number).transform(t=>new b(t)),o.z.instanceof(b)]));let I=b;const S=class S{constructor(t,e){i(this,"start");i(this,"end");typeof t=="object"&&"start"in t?(this.start=new m(t.start),this.end=new m(t.end)):(this.start=new m(t),this.end=new m(e))}get span(){return new y(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new S(this.end,this.start)}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=y.ZERO){t=t.makeValid();const n=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(n.start)||n.end.equals(t.start))return!1;const s=m.max(n.start,t.start),c=m.min(n.end,t.end);return c.before(s)?!1:new y(c.sub(s)).greaterThanOrEqual(e)}roughlyEquals(t,e){let n=this.start.sub(t.start).valueOf(),s=this.end.sub(t.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=e.valueOf()&&s<=e.valueOf()}contains(t){return t instanceof S?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new S(this.start,this.end);return t.start.after(this.start)&&(e.start=t.start),t.start.after(this.end)&&(e.end=t.start),t.end.before(this.end)&&(e.end=t.end),t.end.before(this.start)&&(e.start=t.end),e}};i(S,"MAX",new S(m.MIN,m.MAX)),i(S,"MIN",new S(m.MAX,m.MIN)),i(S,"ZERO",new S(m.ZERO,m.ZERO)),i(S,"z",o.z.union([o.z.object({start:m.z,end:m.z}).transform(t=>new S(t.start,t.end)),o.z.instanceof(S)]));let M=S;const r=class r extends String{constructor(t){if(t instanceof r||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}const e=r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}throw super(r.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=r.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(e=>this.equals(e))}toString(){return this.valueOf()}get isVariable(){return this.equals(r.JSON)||this.equals(r.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(r.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=r.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}canSafelyCastTo(t){return this.equals(t)?!0:this.isVariable&&!t.isVariable||!this.isVariable&&t.isVariable?!1:this.isFloat&&t.isInteger||this.isInteger&&t.isFloat?this.density.valueOf()<t.density.valueOf():this.isFloat&&t.isFloat||this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf():!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return r.BIG_INT_TYPES.some(t=>t.equals(this))}};i(r,"UNKNOWN",new r("unknown")),i(r,"FLOAT64",new r("float64")),i(r,"FLOAT32",new r("float32")),i(r,"INT64",new r("int64")),i(r,"INT32",new r("int32")),i(r,"INT16",new r("int16")),i(r,"INT8",new r("int8")),i(r,"UINT64",new r("uint64")),i(r,"UINT32",new r("uint32")),i(r,"UINT16",new r("uint16")),i(r,"UINT8",new r("uint8")),i(r,"BOOLEAN",r.UINT8),i(r,"TIMESTAMP",new r("timestamp")),i(r,"UUID",new r("uuid")),i(r,"STRING",new r("string")),i(r,"JSON",new r("json")),i(r,"ARRAY_CONSTRUCTORS",new Map([[r.UINT8.toString(),Uint8Array],[r.UINT16.toString(),Uint16Array],[r.UINT32.toString(),Uint32Array],[r.UINT64.toString(),BigUint64Array],[r.FLOAT32.toString(),Float32Array],[r.FLOAT64.toString(),Float64Array],[r.INT8.toString(),Int8Array],[r.INT16.toString(),Int16Array],[r.INT32.toString(),Int32Array],[r.INT64.toString(),BigInt64Array],[r.TIMESTAMP.toString(),BigInt64Array],[r.STRING.toString(),Uint8Array],[r.JSON.toString(),Uint8Array],[r.UUID.toString(),Uint8Array]])),i(r,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,r.UINT8],[Uint16Array.name,r.UINT16],[Uint32Array.name,r.UINT32],[BigUint64Array.name,r.UINT64],[Float32Array.name,r.FLOAT32],[Float64Array.name,r.FLOAT64],[Int8Array.name,r.INT8],[Int16Array.name,r.INT16],[Int32Array.name,r.INT32],[BigInt64Array.name,r.INT64]])),i(r,"DENSITIES",new Map([[r.UINT8.toString(),I.BIT8],[r.UINT16.toString(),I.BIT16],[r.UINT32.toString(),I.BIT32],[r.UINT64.toString(),I.BIT64],[r.FLOAT32.toString(),I.BIT32],[r.FLOAT64.toString(),I.BIT64],[r.INT8.toString(),I.BIT8],[r.INT16.toString(),I.BIT16],[r.INT32.toString(),I.BIT32],[r.INT64.toString(),I.BIT64],[r.TIMESTAMP.toString(),I.BIT64],[r.STRING.toString(),I.UNKNOWN],[r.JSON.toString(),I.UNKNOWN],[r.UUID.toString(),I.BIT128]])),i(r,"ALL",[r.UNKNOWN,r.FLOAT64,r.FLOAT32,r.INT64,r.INT32,r.INT16,r.INT8,r.UINT64,r.UINT32,r.UINT16,r.UINT8,r.TIMESTAMP,r.UUID,r.STRING,r.JSON]),i(r,"BIG_INT_TYPES",[r.INT64,r.UINT64,r.TIMESTAMP]),i(r,"z",o.z.union([o.z.string().transform(t=>new r(t)),o.z.instanceof(r)]));let g=r;const d=class d extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return d.bytes(this.valueOf()+t.valueOf())}sub(t){return d.bytes(this.valueOf()-t.valueOf())}truncate(t){return new d(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return d.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/d.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/d.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/d.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/d.TERABYTE.valueOf()}toString(){const t=this.truncate(d.TERABYTE),e=this.truncate(d.GIGABYTE),n=this.truncate(d.MEGABYTE),s=this.truncate(d.KILOBYTE),c=this.truncate(d.BYTE),f=t,v=e.sub(t),O=n.sub(e),N=s.sub(n),A=c.sub(s);let h="";return f.isZero||(h+=`${f.terabytes}TB `),v.isZero||(h+=`${v.gigabytes}GB `),O.isZero||(h+=`${O.megabytes}MB `),N.isZero||(h+=`${N.kilobytes}KB `),(!A.isZero||h==="")&&(h+=`${A.valueOf()}B`),h.trim()}static bytes(t=1){return new d(t)}static kilobytes(t=1){return d.bytes(t.valueOf()*1e3)}static megabytes(t=1){return d.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return d.megabytes(t.valueOf()*1e3)}static terabytes(t){return d.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};i(d,"BYTE",new d(1)),i(d,"KILOBYTE",d.kilobytes(1)),i(d,"MEGABYTE",d.megabytes(1)),i(d,"GIGABYTE",d.gigabytes(1)),i(d,"TERABYTE",d.terabytes(1)),i(d,"ZERO",new d(0)),i(d,"z",o.z.union([o.z.number().transform(t=>new d(t)),o.z.instanceof(d)]));let U=d;const ot=o.z.union([o.z.instanceof(Uint8Array),o.z.instanceof(Uint16Array),o.z.instanceof(Uint32Array),o.z.instanceof(BigUint64Array),o.z.instanceof(Float32Array),o.z.instanceof(Float64Array),o.z.instanceof(Int8Array),o.z.instanceof(Int16Array),o.z.instanceof(Int32Array),o.z.instanceof(BigInt64Array)]),F=l=>{const t=typeof l;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||l instanceof m||l instanceof y||l instanceof Date},X=(l,t,e,n=0)=>l.usesBigInt&&!t.usesBigInt?Number(e)-Number(n):!l.usesBigInt&&t.usesBigInt?BigInt(e.valueOf())-BigInt(n.valueOf()):x(e,-n).valueOf(),Q=l=>l==null?!1:Array.isArray(l)||l instanceof ArrayBuffer||ArrayBuffer.isView(l)&&!(l instanceof DataView)||l instanceof z?!0:F(l),E=-1,$={[Symbol.iterator]:()=>$,next:()=>({done:!0,value:void 0})},lt=o.z.string().transform(l=>new Uint8Array(atob(l).split("").map(t=>t.charCodeAt(0))).buffer),ct=o.z.union([o.z.null(),o.z.undefined()]).transform(()=>new Uint8Array().buffer),P=10,T=class T{constructor(t){i(this,"key","");i(this,"isSynnaxSeries",!0);i(this,"dataType");i(this,"sampleOffset");i(this,"gl");i(this,"_data");i(this,"_timeRange");i(this,"alignment",0n);i(this,"_cachedMin");i(this,"_cachedMax");i(this,"writePos",E);i(this,"_refCount",0);i(this,"_cachedLength");i(this,"_cachedIndexes");Q(t)&&(t={data:t});const{dataType:e,timeRange:n,sampleOffset:s=0,glBufferUsage:c="static",alignment:f=0n,key:v=K()}=t,O=t.data??[];if(O instanceof T||typeof O=="object"&&"isSynnaxSeries"in O&&O.isSynnaxSeries===!0){const h=O;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const N=F(O),A=Array.isArray(O);if(e!=null)this.dataType=new g(e);else{if(O instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(A||N){let h=O;if(!N){if(O.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=O[0]}if(typeof h=="string")this.dataType=g.STRING;else if(typeof h=="number")this.dataType=g.FLOAT64;else if(typeof h=="bigint")this.dataType=g.INT64;else if(typeof h=="boolean")this.dataType=g.BOOLEAN;else if(h instanceof m||h instanceof Date||h instanceof m)this.dataType=g.TIMESTAMP;else if(typeof h=="object")this.dataType=g.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new g(O)}if(!A&&!N)this._data=O;else{let h=N?[O]:O;const R=h[0];(R instanceof m||R instanceof Date||R instanceof y)&&(h=h.map(C=>new m(C).valueOf())),this.dataType.equals(g.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(`${h.join(`
2
+ `)}
3
+ `)):this.dataType.equals(g.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(`${h.map(C=>D.JSON_CODEC.encodeString(C)).join(`
4
+ `)}
5
+ `)):this._data=new this.dataType.Array(h).buffer}this.key=v,this.alignment=f,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:c}}static alloc({capacity:t,dataType:e,...n}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new g(e).Array(t),c=new T({data:s.buffer,dataType:e,...n});return c.writePos=0,c}static generateTimestamps(t,e,n){const s=n.spanRange(e.span(t)),c=new BigInt64Array(t);for(let f=0;f<t;f++)c[f]=BigInt(n.add(e.span(f)).valueOf());return new T({data:c,dataType:g.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(t,e){const n=new TextEncoder().encode(`${t.join(`
6
+ `)}
7
+ `);return new T({data:n,dataType:g.STRING,timeRange:e})}static fromJSON(t,e){const n=new TextEncoder().encode(`${t.map(s=>D.JSON_CODEC.encodeString(s)).join(`
8
+ `)}
9
+ `);return new T({data:n,dataType:g.JSON,timeRange:e})}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}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(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(t):this.writeFixed(t)}writeVariable(t){if(this.writePos===E)return 0;const e=this.byteCapacity.valueOf()-this.writePos,n=t.subBytes(0,e);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(t){if(this.writePos===E)return 0;const e=this.capacity-this.writePos,n=t.sub(0,e);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(t){this.underlyingData.set(t.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===E?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(g.STRING,g.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
10
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(g.UUID))throw new Error("cannot convert non-uuid series to uuids");const t=g.UUID.density.valueOf(),e=Array(this.length);for(let n=0;n<this.length;n++){const s=this.underlyingData.slice(n*t,(n+1)*t),c=Array.from(new Uint8Array(s),f=>f.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");e[n]=c}return e}parseJSON(t){if(!this.dataType.equals(g.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
11
+ `).slice(0,-1).map(e=>t.parse(D.JSON_CODEC.decodeString(e)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new U(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity:this.dataType.isVariable?new U(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===E?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const e=[0];return this.data.forEach((n,s)=>{n===P&&(t++,e.push(s+1))}),this._cachedIndexes=e,this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const n=new t.Array(this.length);for(let s=0;s<this.length;s++)n[s]=X(this.dataType,t,this.data[s],e);return new T({data:n.buffer,dataType:t,timeRange:this._timeRange,sampleOffset:e,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}else{const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),x(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}else{const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),x(this._cachedMin,this.sampleOffset))}get bounds(){return w.construct(Number(this.min),Number(this.max))}maybeRecomputeMinMax(t){if(this._cachedMin!=null){const e=t._cachedMin??t.calcRawMin();e<this._cachedMin&&(this._cachedMin=e)}if(this._cachedMax!=null){const e=t._cachedMax??t.calcRawMax();e>this._cachedMax&&(this._cachedMax=e)}}enrich(){this.max,this.min}get range(){return x(this.max,-this.min)}atAlignment(t,e){const n=Number(t-this.alignment);if(n<0||n>=this.length){if(e===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,e)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const n=this.data[t];if(n==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return x(n,this.sampleOffset)}atVariable(t,e){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[t],s=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let f=0;f<this.data.length;f++)if(this.data[f]===P){if(t===0){s=f;break}n=f+1,t--}if(s===0&&(s=this.data.length),n>=s||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}}const c=this.data.slice(n,s);return this.dataType.equals(g.STRING)?new TextDecoder().decode(c):et.snakeToCamel(JSON.parse(new TextDecoder().decode(c)))}binarySearch(t){let e=0,n=this.length-1;const s=nt.newF(t);for(;e<=n;){const c=Math.floor((e+n)/2),f=s(this.at(c,!0),t);if(f===0)return c;f<0?e=c+1:n=c-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(g.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:e,bufferUsage:n,prevBuffer:s}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==s)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==E){s===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const c=this.dataType.density.size(s).valueOf(),f=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,c,f.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.underlyingData,n==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=E}as(t){if(t==="string"){if(!this.dataType.equals(g.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(t==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(t==="bigint"){if(!this.dataType.equals(g.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${t}`)}get digest(){var t;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(t=this._timeRange)==null?void 0:t.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 w.construct(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.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 t=new ht(this);return this.dataType.equals(g.JSON)?new ft(t):t}return new dt(this)}slice(t,e){return this.sliceSub(!1,t,e)}sub(t,e){return this.sliceSub(!0,t,e)}subIterator(t,e){return new V(this,t,e??this.length)}subAlignmentIterator(t,e){return new V(this,Number(t-this.alignment),Number(e-this.alignment))}subBytes(t,e){if(t>=0&&(e==null||e>=this.byteLength.valueOf()))return this;const n=this.data.subarray(t,e);return new T({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,e,n){if(e<=0&&(n==null||n>=this.length))return this;let s;return t?s=this.data.subarray(e,n):s=this.data.slice(e,n),new T({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(t){return new T({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}};i(T,"crudeZ",o.z.object({timeRange:M.z.optional(),dataType:g.z,alignment:rt.bigInt.optional(),data:o.z.union([lt,ct,o.z.instanceof(ArrayBuffer)]),glBufferUsage:ut.optional().default("static").optional()})),i(T,"z",T.crudeZ.transform(t=>new T(t)));let z=T;class V{constructor(t,e,n){i(this,"series");i(this,"end");i(this,"index");this.series=t;const s=w.construct(0,t.length);this.end=w.clamp(s,n),this.index=w.clamp(s,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 ht{constructor(t){i(this,"series");i(this,"index");i(this,"decoder");if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==P;)this.index++;const n=this.index;return t===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,n))})}[Symbol.iterator](){return this}}var Z,k;class ft{constructor(t){i(this,"wrapped");i(this,Z,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:D.JSON_CODEC.decodeString(t.value)}}[(k=Symbol.iterator,Z=Symbol.toStringTag,k)](){return this}}var G,J;class dt{constructor(t){i(this,"series");i(this,"index");i(this,G,"SeriesIterator");this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(J=Symbol.iterator,G=Symbol.toStringTag,J)](){return this}}const x=(l,t)=>typeof l=="bigint"&&typeof t=="bigint"||typeof l=="number"&&typeof t=="number"?l+t:t===0?l:l===0?t:Number(l)+Number(t);class gt{constructor(t){i(this,"series");if(t.length!==0){const e=t[0].dataType;for(let n=1;n<t.length;n++)if(!t[n].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){if(!new g(t).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`);return this}get dataType(){return this.series.length===0?g.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(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?w.construct(0n,0n):w.construct(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){this.series.push(t)}get length(){return this.series.reduce((t,e)=>t+e.length,0)}atAlignment(t,e){if(this.series.length===0){if(e)throw new Error(`[series] - no value at alignment ${t}`);return}for(const n of this.series)if(w.contains(n.alignmentBounds,t))return n.atAlignment(t,e);if(e)throw new Error(`[series] - no value at alignment ${t}`)}at(t,e=!1){t<0&&(t=this.length+t);for(const n of this.series){if(t<n.length)return n.at(t,e);t-=n.length}if(e)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,e){return new q(this,t,e??this.length)}subAlignmentIterator(t,e){if(t>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return $;let n=0;for(let c=0;c<this.series.length;c++){const f=this.series[c];if(t<f.alignment)break;if(t>=f.alignmentBounds.upper)n+=f.length;else if(w.contains(f.alignmentBounds,t)){n+=Number(t-f.alignment);break}}let s=0;for(let c=0;c<this.series.length;c++){const f=this.series[c];if(e<f.alignment)break;if(e>=f.alignmentBounds.upper)s+=f.length;else if(w.contains(f.alignmentBounds,e)){s+=Number(e-f.alignment);break}}return new q(this,n,s)}subAlignmentSpanIterator(t,e){if(t>=this.alignmentBounds.upper)return $;let n=0;for(let s=0;s<this.series.length;s++){const c=this.series[s];if(t<c.alignment)break;if(t>=c.alignmentBounds.upper)n+=c.length;else if(w.contains(c.alignmentBounds,t)){n+=Number(t-c.alignment);break}}return new q(this,n,n+e)}get byteLength(){return new U(this.series.reduce((t,e)=>t+e.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let e=0;for(const n of this.series)t.set(n.data,e),e+=n.length;return new this.dataType.Array(t)}traverseAlignment(t,e){const n=this.series.map(s=>s.alignmentBounds);return w.traverse(n,t,e)}distance(t,e){const n=this.series.map(s=>s.alignmentBounds);return w.distance(n,t,e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new mt(this.series)}}var W,j;class mt{constructor(t){i(this,"series");i(this,"seriesIndex");i(this,"internal");i(this,W,"MultiSeriesIterator");this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(j=Symbol.iterator,W=Symbol.toStringTag,j)](){return this}}class q{constructor(t,e,n){i(this,"series");i(this,"index");i(this,"end");this.series=t,this.end=n,this.index=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}}exports.DataType=g;exports.Density=I;exports.MultiSeries=gt;exports.Rate=L;exports.Series=z;exports.Size=U;exports.TimeRange=M;exports.TimeSpan=y;exports.TimeStamp=m;exports.addSamples=x;exports.convertDataType=X;exports.id=at;exports.isCrudeSeries=Q;exports.isTelemValue=F;exports.typedArrayZ=ot;